File tree Expand file tree Collapse file tree 4 files changed +35
-1
lines changed
packages/core/typescript/itk-wasm Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change
1
+ export { default as pthreadSupportAvailable } from './pthread-support-available.js'
2
+
1
3
export type { default as ItkWasmEmscriptenModule } from './itk-wasm-emscripten-module.js'
2
4
3
5
export type { default as PipelineInput } from './pipeline-input.js'
Original file line number Diff line number Diff line change 1
- // itk-wasm Browser pipeline functions
1
+ // ITK-Wasm Browser pipeline functions
2
2
3
3
export { default as runPipeline } from './run-pipeline.js'
4
4
export { default as createWebWorker } from './create-web-worker.js'
Original file line number Diff line number Diff line change
1
+ function pthreadSupportAvailable ( ) : boolean {
2
+ const haveSharedArrayBuffer =
3
+ typeof globalThis . SharedArrayBuffer === 'function'
4
+
5
+ // Emscripten ENVIRONMENT_IS_NODE
6
+ const isNode =
7
+ typeof process == 'object' &&
8
+ typeof process . versions == 'object' &&
9
+ typeof process . versions . node == 'string' &&
10
+ // @ts -ignore: ts(2339)
11
+ process . type != 'renderer'
12
+
13
+ const isCrossOriginIsolated =
14
+ typeof crossOriginIsolated !== 'undefined'
15
+ ? crossOriginIsolated
16
+ : globalThis . crossOriginIsolated || false
17
+
18
+ if ( isNode ) {
19
+ return haveSharedArrayBuffer
20
+ }
21
+
22
+ return haveSharedArrayBuffer && isCrossOriginIsolated
23
+ }
24
+
25
+ export default pthreadSupportAvailable
Original file line number Diff line number Diff line change
1
+ import test from 'ava'
2
+
3
+ import { pthreadSupportAvailable } from '../../../dist/index-node.js'
4
+
5
+ test ( 'node pthread support available' , ( t ) => {
6
+ t . truthy ( pthreadSupportAvailable ( ) )
7
+ } )
You can’t perform that action at this time.
0 commit comments