-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bindgen): Default to itk-wasm package asset configuration
At runtime, we use in order of preference: 1. Package asset configuration 2. itk-wasm asset configuration 3. jsDeliver
- Loading branch information
Showing
8 changed files
with
71 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 13 additions & 2 deletions
15
packages/compress-stringify/typescript/src/pipeline-worker-url.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
// @ts-ignore: TS2305: Module '"itk-wasm"' has no exported member 'getPipelineWorkerUrl'. | ||
import { getPipelineWorkerUrl as itkWasmGetPipelineWorkerUrl } from 'itk-wasm' | ||
import packageJson from '../package.json' | ||
let pipelineWorkerUrl: string | URL | null = `https://cdn.jsdelivr.net/npm/itk-compress-stringify@${packageJson.version}/dist/web-workers/pipeline.worker.js` | ||
|
||
let pipelineWorkerUrl: string | URL | null | undefined | ||
let defaultPipelineWorkerUrl: string | URL | null = `https://cdn.jsdelivr.net/npm/itk-compress-stringify@${packageJson.version}/dist/web-workers/pipeline.worker.js` | ||
|
||
export function setPipelineWorkerUrl (workerUrl: string | URL | null): void { | ||
pipelineWorkerUrl = workerUrl | ||
} | ||
|
||
export function getPipelineWorkerUrl (): string | URL | null { | ||
return pipelineWorkerUrl | ||
if (typeof pipelineWorkerUrl !== 'undefined') { | ||
return pipelineWorkerUrl | ||
} | ||
const itkWasmPipelineWorkerUrl = itkWasmGetPipelineWorkerUrl() | ||
if (typeof itkWasmPipelineWorkerUrl !== 'undefined') { | ||
return itkWasmPipelineWorkerUrl | ||
} | ||
return defaultPipelineWorkerUrl | ||
} |
15 changes: 13 additions & 2 deletions
15
packages/compress-stringify/typescript/src/pipelines-base-url.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
// @ts-ignore: TS2305: Module '"itk-wasm"' has no exported member 'getPipelinesBaseUrl'. | ||
import { getPipelinesBaseUrl as itkWasmGetPipelinesBaseUrl } from 'itk-wasm' | ||
import packageJson from '../package.json' | ||
let pipelinesBaseUrl: string | URL = `https://cdn.jsdelivr.net/npm/itk-compress-stringify@${packageJson.version}/dist/pipelines` | ||
|
||
let pipelinesBaseUrl: string | URL | undefined | ||
const defaultPipelinesBaseUrl = `https://cdn.jsdelivr.net/npm/itk-compress-stringify@${packageJson.version}/dist/pipelines` | ||
|
||
export function setPipelinesBaseUrl (baseUrl: string | URL): void { | ||
pipelinesBaseUrl = baseUrl | ||
} | ||
|
||
export function getPipelinesBaseUrl (): string | URL { | ||
return pipelinesBaseUrl | ||
if (typeof pipelinesBaseUrl !== 'undefined') { | ||
return pipelinesBaseUrl | ||
} | ||
const itkWasmPipelinesBaseUrl = itkWasmGetPipelinesBaseUrl() | ||
if (typeof itkWasmPipelinesBaseUrl !== 'undefined') { | ||
return itkWasmPipelinesBaseUrl | ||
} | ||
return defaultPipelinesBaseUrl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
// @ts-expect-error error TS2732: Cannot find module '../package.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. | ||
// @ts-ignore: TS2305: Module '"itk-wasm"' has no exported member 'getPipelineWorkerUrl'. | ||
import { getPipelineWorkerUrl as itkWasmGetPipelineWorkerUrl } from 'itk-wasm' | ||
import packageJson from '../package.json' | ||
let pipelineWorkerUrl: string | URL | null = `https://cdn.jsdelivr.net/npm/<bindgenPackageName>@${packageJson.version as string}/dist/web-workers/pipeline.worker.js` | ||
|
||
let pipelineWorkerUrl: string | URL | null | undefined | ||
const defaultPipelineWorkerUrl = `https://cdn.jsdelivr.net/npm/<bindgenPackageName>@${packageJson.version}/dist/web-workers/pipeline.worker.js` | ||
|
||
export function setPipelineWorkerUrl (workerUrl: string | URL | null): void { | ||
pipelineWorkerUrl = workerUrl | ||
} | ||
|
||
export function getPipelineWorkerUrl (): string | URL | null { | ||
return pipelineWorkerUrl | ||
if (typeof pipelineWorkerUrl !== 'undefined') { | ||
return pipelineWorkerUrl | ||
} | ||
const itkWasmPipelineWorkerUrl = itkWasmGetPipelineWorkerUrl() | ||
if (typeof itkWasmPipelineWorkerUrl !== 'undefined') { | ||
return itkWasmPipelineWorkerUrl | ||
} | ||
return defaultPipelineWorkerUrl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
// @ts-expect-error error TS2732: Cannot find module '../package.json'. Consider using '--resolveJsonModule' to import module with '.json' extension. | ||
// @ts-ignore: TS2305: Module '"itk-wasm"' has no exported member 'getPipelinesBaseUrl'. | ||
import { getPipelinesBaseUrl as itkWasmGetPipelinesBaseUrl } from 'itk-wasm' | ||
import packageJson from '../package.json' | ||
let pipelinesBaseUrl: string | URL = `https://cdn.jsdelivr.net/npm/<bindgenPackageName>@${packageJson.version as string}/dist/pipelines` | ||
|
||
let pipelinesBaseUrl: string | URL | undefined | ||
let defaultPipelinesBaseUrl: string | URL = `https://cdn.jsdelivr.net/npm/itk-compress-stringify@${packageJson.version}/dist/pipelines` | ||
|
||
export function setPipelinesBaseUrl (baseUrl: string | URL): void { | ||
pipelinesBaseUrl = baseUrl | ||
} | ||
|
||
export function getPipelinesBaseUrl (): string | URL { | ||
return pipelinesBaseUrl | ||
if (typeof pipelinesBaseUrl !== 'undefined') { | ||
return pipelinesBaseUrl | ||
} | ||
const itkWasmPipelinesBaseUrl = itkWasmGetPipelinesBaseUrl() | ||
if (typeof itkWasmPipelinesBaseUrl !== 'undefined') { | ||
return itkWasmPipelinesBaseUrl | ||
} | ||
return defaultPipelinesBaseUrl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters