@xyo-network/wasm 2.75.0 → 2.75.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,92 @@
1
+ export declare const WasmFeatureDetectors: {
2
+ readonly bigInt: () => Promise<boolean>;
3
+ readonly bulkMemory: () => Promise<boolean>;
4
+ readonly exceptions: () => Promise<boolean>;
5
+ readonly extendedConst: () => Promise<boolean>;
6
+ readonly gc: () => Promise<boolean>;
7
+ readonly memory64: () => Promise<boolean>;
8
+ readonly multiValue: () => Promise<boolean>;
9
+ readonly mutableGlobals: () => Promise<boolean>;
10
+ readonly referenceTypes: () => Promise<boolean>;
11
+ readonly relaxedSimd: () => Promise<boolean>;
12
+ readonly saturatedFloatToInt: () => Promise<boolean>;
13
+ readonly signExtensions: () => Promise<boolean>;
14
+ readonly simd: () => Promise<boolean>;
15
+ readonly streamingCompilation: () => Promise<boolean>;
16
+ readonly tailCall: () => Promise<boolean>;
17
+ readonly threads: () => Promise<boolean>;
18
+ };
19
+ export type WasmFeature = keyof typeof WasmFeatureDetectors;
20
+ export declare class WasmSupport {
21
+ protected desiredFeatures: WasmFeature[];
22
+ private _allowWasm;
23
+ private _featureSupport;
24
+ private _forceWasm;
25
+ private _isInitialized;
26
+ private _isWasmFeatureSetSupported;
27
+ /**
28
+ * Instance constructor for use where async instantiation
29
+ * is not possible. Where possible, prefer the static
30
+ * create method over use of this constructor directly
31
+ * as no initialization (feature detection) is able to
32
+ * be done here
33
+ * @param desiredFeatures The desired feature set
34
+ */
35
+ constructor(desiredFeatures: WasmFeature[]);
36
+ /**
37
+ * Is Wasm allowed
38
+ */
39
+ get allowWasm(): boolean;
40
+ /**
41
+ * Whether or not to allow WASM usage
42
+ */
43
+ set allowWasm(v: boolean);
44
+ /**
45
+ * Whether or not Wasm should be used based on the desired
46
+ * feature set, initialization state, or force-use settings
47
+ */
48
+ get canUseWasm(): boolean;
49
+ /**
50
+ * Returns a object containing a property for each desired wasm feature
51
+ * with a boolean value indicating whether or not the feature is supported
52
+ */
53
+ get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>>;
54
+ /**
55
+ * Force use of Wasm
56
+ */
57
+ get forceWasm(): boolean;
58
+ /**
59
+ * Whether or not to force Wasm usage
60
+ */
61
+ set forceWasm(v: boolean);
62
+ /**
63
+ * Whether or not Wasm is supported based
64
+ * on the desired feature set
65
+ */
66
+ get isDesiredFeatureSetSupported(): boolean;
67
+ /**
68
+ * Whether or not Wasm detection has been run
69
+ * for the desired feature set
70
+ */
71
+ get isInitialized(): boolean;
72
+ /**
73
+ * Static creation & async initialization for use where
74
+ * async instantiation is possible
75
+ * @param desiredFeatures The desired feature set
76
+ * @returns An initialized instance of the class with detection
77
+ * for the desired feature set
78
+ */
79
+ static create(desiredFeatures: WasmFeature[]): Promise<WasmSupport>;
80
+ /**
81
+ * Checks for specific wasm features
82
+ * @param features The list of features to check for
83
+ * @returns True if all the features are supported, false otherwise
84
+ */
85
+ featureCheck(features: WasmFeature[]): Promise<boolean>;
86
+ /**
87
+ * Does feature detection for the desired feature set
88
+ */
89
+ initialize(): Promise<void>;
90
+ protected detectDesiredFeatures(): Promise<void>;
91
+ }
92
+ //# sourceMappingURL=WasmSupport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WasmSupport.d.ts","sourceRoot":"","sources":["../../src/WasmSupport.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;CAiBvB,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,oBAAoB,CAAA;AAE3D,qBAAa,WAAW;IAeV,SAAS,CAAC,eAAe,EAAE,WAAW,EAAE;IAdpD,OAAO,CAAC,UAAU,CAAO;IACzB,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,0BAA0B,CAAQ;IAE1C;;;;;;;OAOG;gBACmB,eAAe,EAAE,WAAW,EAAE;IAEpD;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IACD;;OAEG;IACH,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAED;;;OAGG;IACH,IAAI,UAAU,IAAI,OAAO,CASxB;IAED;;;OAGG;IACH,IAAI,cAAc,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAEpE;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IACD;;OAEG;IACH,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAED;;;OAGG;IACH,IAAI,4BAA4B,IAAI,OAAO,CAE1C;IAED;;;OAGG;IACH,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED;;;;;;OAMG;WACU,MAAM,CAAC,eAAe,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAMzE;;;;OAIG;IACG,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAK7D;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAOjB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAYvD"}
@@ -1,4 +1,3 @@
1
- // src/WasmSupport.ts
2
1
  import {
3
2
  bigInt,
4
3
  bulkMemory,
@@ -17,7 +16,7 @@ import {
17
16
  tailCall,
18
17
  threads
19
18
  } from "wasm-feature-detect";
20
- var WasmFeatureDetectors = {
19
+ const WasmFeatureDetectors = {
21
20
  bigInt,
22
21
  bulkMemory,
23
22
  exceptions,
@@ -35,7 +34,7 @@ var WasmFeatureDetectors = {
35
34
  tailCall,
36
35
  threads
37
36
  };
38
- var WasmSupport = class _WasmSupport {
37
+ class WasmSupport {
39
38
  /**
40
39
  * Instance constructor for use where async instantiation
41
40
  * is not possible. Where possible, prefer the static
@@ -117,7 +116,7 @@ var WasmSupport = class _WasmSupport {
117
116
  * for the desired feature set
118
117
  */
119
118
  static async create(desiredFeatures) {
120
- const instance = new _WasmSupport(desiredFeatures);
119
+ const instance = new WasmSupport(desiredFeatures);
121
120
  await instance.initialize();
122
121
  return Promise.resolve(instance);
123
122
  }
@@ -152,7 +151,7 @@ var WasmSupport = class _WasmSupport {
152
151
  }
153
152
  this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every((v) => v);
154
153
  }
155
- };
154
+ }
156
155
  export {
157
156
  WasmFeatureDetectors,
158
157
  WasmSupport
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/WasmSupport.ts"],"sourcesContent":["import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n referenceTypes,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: referenceTypes,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return Promise.resolve(instance)\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every((result) => result)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n return\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n if (!(await detector())) {\n this._featureSupport[desiredFeature] = false\n } else {\n this._featureSupport[desiredFeature] = true\n }\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every((v) => v)\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,IAAM,cAAN,MAAM,aAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAevB,YAAsB,iBAAgC;AAAhC;AAAA,EAAiC;AAAA,EAd/C,aAAa;AAAA,EACb,kBAAyD,CAAC;AAAA,EAC1D,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,6BAA6B;AAAA;AAAA;AAAA;AAAA,EAerC,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAsB;AACxB;AAAA;AAAA,MAEE,KAAK;AAAA,MAEJ,KAAK,cAAc,CAAC,KAAK;AAAA,MAEzB,KAAK,cAAc,KAAK,kBAAkB,KAAK;AAAA;AAAA,EAEpD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,iBAAkE;AACpE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A6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC;AAAA,EACtF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/WasmSupport.ts"],"sourcesContent":["import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n referenceTypes,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: referenceTypes,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return Promise.resolve(instance)\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every((result) => result)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n return\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n if (!(await detector())) {\n this._featureSupport[desiredFeature] = false\n } else {\n this._featureSupport[desiredFeature] = true\n }\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every((v) => v)\n }\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAC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AAA;AAAA;AAAA;AAAA,EAMA,IAAI,gBAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAa,OAAO,iBAAsD;AACxE,UAAM,WAAW,IAAI,YAAY,eAAe;AAChD,UAAM,SAAS,WAAW;AAC1B,WAAO,QAAQ,QAAQ,QAAQ;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,UAA2C;AAC5D,UAAM,UAAU,MAAM,QAAQ,IAAI,SAAS,IAAI,CAAC,YAAY,qBAAqB,OAAO,CAAC,EAAE,IAAI,OAAO,aAAa,MAAM,SAAS,CAAC,CAAC;AACpI,WAAO,QAAQ,MAAM,CAAC,WAAW,MAAM;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK;AAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AACtB;AAAA,EACF;AAAA,EAEA,MAAgB,wBAAuC;AACrD,aAAS,UAAU,GAAG,UAAU,KAAK,gBAAgB,QAAQ,WAAW;AACtE,YAAM,iBAAiB,KAAK,gBAAgB,OAAO;AACnD,YAAM,WAAW,qBAAqB,cAAc;AACpD,UAAI,CAAE,MAAM,SAAS,GAAI;AACvB,aAAK,gBAAgB,cAAc,IAAI;AAAA,MACzC,OAAO;AACL,aAAK,gBAAgB,cAAc,IAAI;AAAA,MACzC;AAAA,IACF;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC;AAAA,EACtF;AACF;","names":[]}
@@ -0,0 +1,2 @@
1
+ export * from './WasmSupport';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -1,160 +1,2 @@
1
- // src/WasmSupport.ts
2
- import {
3
- bigInt,
4
- bulkMemory,
5
- exceptions,
6
- extendedConst,
7
- gc,
8
- memory64,
9
- multiValue,
10
- mutableGlobals,
11
- referenceTypes,
12
- relaxedSimd,
13
- saturatedFloatToInt,
14
- signExtensions,
15
- simd,
16
- streamingCompilation,
17
- tailCall,
18
- threads
19
- } from "wasm-feature-detect";
20
- var WasmFeatureDetectors = {
21
- bigInt,
22
- bulkMemory,
23
- exceptions,
24
- extendedConst,
25
- gc,
26
- memory64,
27
- multiValue,
28
- mutableGlobals,
29
- referenceTypes,
30
- relaxedSimd,
31
- saturatedFloatToInt,
32
- signExtensions,
33
- simd,
34
- streamingCompilation,
35
- tailCall,
36
- threads
37
- };
38
- var WasmSupport = class _WasmSupport {
39
- /**
40
- * Instance constructor for use where async instantiation
41
- * is not possible. Where possible, prefer the static
42
- * create method over use of this constructor directly
43
- * as no initialization (feature detection) is able to
44
- * be done here
45
- * @param desiredFeatures The desired feature set
46
- */
47
- constructor(desiredFeatures) {
48
- this.desiredFeatures = desiredFeatures;
49
- }
50
- _allowWasm = true;
51
- _featureSupport = {};
52
- _forceWasm = false;
53
- _isInitialized = false;
54
- _isWasmFeatureSetSupported = false;
55
- /**
56
- * Is Wasm allowed
57
- */
58
- get allowWasm() {
59
- return this._allowWasm;
60
- }
61
- /**
62
- * Whether or not to allow WASM usage
63
- */
64
- set allowWasm(v) {
65
- this._allowWasm = v;
66
- }
67
- /**
68
- * Whether or not Wasm should be used based on the desired
69
- * feature set, initialization state, or force-use settings
70
- */
71
- get canUseWasm() {
72
- return (
73
- // Just force WASM
74
- this._forceWasm || // Or if we haven't checked be optimistic
75
- this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
76
- this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
77
- );
78
- }
79
- /**
80
- * Returns a object containing a property for each desired wasm feature
81
- * with a boolean value indicating whether or not the feature is supported
82
- */
83
- get featureSupport() {
84
- return { ...this._featureSupport };
85
- }
86
- /**
87
- * Force use of Wasm
88
- */
89
- get forceWasm() {
90
- return this._forceWasm;
91
- }
92
- /**
93
- * Whether or not to force Wasm usage
94
- */
95
- set forceWasm(v) {
96
- this._forceWasm = v;
97
- }
98
- /**
99
- * Whether or not Wasm is supported based
100
- * on the desired feature set
101
- */
102
- get isDesiredFeatureSetSupported() {
103
- return this._isWasmFeatureSetSupported;
104
- }
105
- /**
106
- * Whether or not Wasm detection has been run
107
- * for the desired feature set
108
- */
109
- get isInitialized() {
110
- return this._isInitialized;
111
- }
112
- /**
113
- * Static creation & async initialization for use where
114
- * async instantiation is possible
115
- * @param desiredFeatures The desired feature set
116
- * @returns An initialized instance of the class with detection
117
- * for the desired feature set
118
- */
119
- static async create(desiredFeatures) {
120
- const instance = new _WasmSupport(desiredFeatures);
121
- await instance.initialize();
122
- return Promise.resolve(instance);
123
- }
124
- /**
125
- * Checks for specific wasm features
126
- * @param features The list of features to check for
127
- * @returns True if all the features are supported, false otherwise
128
- */
129
- async featureCheck(features) {
130
- const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
131
- return results.every((result) => result);
132
- }
133
- /**
134
- * Does feature detection for the desired feature set
135
- */
136
- async initialize() {
137
- if (this._isInitialized)
138
- return;
139
- await this.detectDesiredFeatures();
140
- this._isInitialized = true;
141
- return;
142
- }
143
- async detectDesiredFeatures() {
144
- for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
145
- const desiredFeature = this.desiredFeatures[feature];
146
- const detector = WasmFeatureDetectors[desiredFeature];
147
- if (!await detector()) {
148
- this._featureSupport[desiredFeature] = false;
149
- } else {
150
- this._featureSupport[desiredFeature] = true;
151
- }
152
- }
153
- this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every((v) => v);
154
- }
155
- };
156
- export {
157
- WasmFeatureDetectors,
158
- WasmSupport
159
- };
1
+ export * from "./WasmSupport";
160
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/WasmSupport.ts"],"sourcesContent":["import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n referenceTypes,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: referenceTypes,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return Promise.resolve(instance)\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every((result) => result)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n return\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n if (!(await detector())) {\n this._featureSupport[desiredFeature] = false\n } else {\n this._featureSupport[desiredFeature] = true\n }\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every((v) => v)\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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