@xyo-network/wasm 2.110.18 → 2.111.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"WasmSupport.d.ts","sourceRoot":"","sources":["../../src/WasmSupport.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,oBAAoB;;;;;;;;;;iGAoCa,CAAC;;qEAmB7C,CAAA;;;;;;;;4EAdA,CAHF;;;;;;;;;;;;;;CArBU,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;gBAUpB,eAAe,EAAE,WAAW,EAAE;IAKpD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAID,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAMD,IAAI,UAAU,IAAI,OAAO,CASxB;IAMD,IAAI,cAAc,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAEpE;IAKD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAID,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAMD,IAAI,4BAA4B,IAAI,OAAO,CAE1C;IAMD,IAAI,aAAa,IAAI,OAAO,CAE3B;WASY,MAAM,CAAC,eAAe,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAWnE,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAQvD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAMjB,qBAAqB,I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AAS,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;gBAUpB,eAAe,EAAE,WAAW,EAAE;IAKpD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAKD,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAMD,IAAI,UAAU,IAAI,OAAO,CASxB;IAMD,IAAI,cAAc,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAEpE;IAKD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAKD,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAMD,IAAI,4BAA4B,IAAI,OAAO,CAE1C;IAMD,IAAI,aAAa,IAAI,OAAO,CAE3B;WASY,MAAM,CAAC,eAAe,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAWnE,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAQvD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAMjB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAQvD"}
@@ -81,9 +81,7 @@ var WasmSupport = class _WasmSupport {
81
81
  get canUseWasm() {
82
82
  return (
83
83
  // Just force WASM
84
- this._forceWasm || // Or if we haven't checked be optimistic
85
- this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
86
- this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
84
+ this._forceWasm || this._allowWasm && !this._isInitialized || this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
87
85
  );
88
86
  }
89
87
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport.ts'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\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: () => Promise<boolean>,\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iCAgBO;AAEA,IAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,IAAI;AAAA,EACJ,UA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Aa,OAAO,iBAAsD;AACxE,UAAM,WAAW,IAAI,aAAY,eAAe;AAChD,UAAM,SAAS,WAAW;AAC1B,WAAO;AAAA,EACT;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,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK,eAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AAAA,EACxB;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,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport.ts'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\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: () => Promise<boolean>,\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 /**\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 /**\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iCAgBO;AAEA,IAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,gBAAgB,MAAM;AAAA,EACtB,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,sBAAsB;AAAA,EACtB,UAAU;AAAA,EACV,SAAS;AACX;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,iBAA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BAAsB;AACjC,SAAK,iBAAiB;AAAA,EACxB;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,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
@@ -70,9 +70,7 @@ var WasmSupport = class _WasmSupport {
70
70
  get canUseWasm() {
71
71
  return (
72
72
  // Just force WASM
73
- this._forceWasm || // Or if we haven't checked be optimistic
74
- this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
75
- this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
73
+ this._forceWasm || this._allowWasm && !this._isInitialized || this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
76
74
  );
77
75
  }
78
76
  /**
@@ -150,4 +148,4 @@ export {
150
148
  WasmFeatureDetectors,
151
149
  WasmSupport
152
150
  };
153
- //# sourceMappingURL=index.js.map
151
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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 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: () => Promise<boolean>,\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 /**\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 /**\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\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,OACK;AAEA,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB,MAAM;AAAA,EACtB;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,6BAA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ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,oBAAoB;;;;;;;;;;iGAoCa,CAAC;;qEAoB7C,CAAD;;;;;;;;4EAfC,CAHF;;;;;;;;;;;;;;CArBU,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;gBAUpB,eAAe,EAAE,WAAW,EAAE;IAKpD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAKD,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAMD,IAAI,UAAU,IAAI,OAAO,CASxB;IAMD,IAAI,cAAc,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAEpE;IAKD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAKD,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAMD,IAAI,4BAA4B,IAAI,OAAO,CAE1C;IAMD,IAAI,aAAa,IAAI,OAAO,CAE3B;WASY,MAAM,CAAC,eAAe,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAWnE,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAQvD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAMjB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAQvD"}
@@ -81,9 +81,7 @@ var WasmSupport = class _WasmSupport {
81
81
  get canUseWasm() {
82
82
  return (
83
83
  // Just force WASM
84
- this._forceWasm || // Or if we haven't checked be optimistic
85
- this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
86
- this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
84
+ this._forceWasm || this._allowWasm && !this._isInitialized || this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
87
85
  );
88
86
  }
89
87
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport.ts'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\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: () => Promise<boolean>,\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean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pB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,+BAAwC;AAC1C,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;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,aAAY,eAAe;AAChD,UAAM,SAAS,WAAW;AAC1B,WAAO;AAAA,EACT;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,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK,eAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AAAA,EACxB;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,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport.ts'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\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: () => Promise<boolean>,\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 /**\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 /**\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iCAgBO;AAEA,IAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,gBAAgB,MAAM;AAAA,EACtB,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,sBAAsB;AAAA,EACtB,UAAU;AAAA,E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,SAAS,IAAI,aAAW,qBAAqB,OAAO,CAAC,EAAE,IAAI,OAAM,aAAY,MAAM,SAAS,CAAC,CAAC;AAChI,WAAO,QAAQ,MAAM,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK,eAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AAAA,EACxB;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,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
@@ -70,9 +70,7 @@ var WasmSupport = class _WasmSupport {
70
70
  get canUseWasm() {
71
71
  return (
72
72
  // Just force WASM
73
- this._forceWasm || // Or if we haven't checked be optimistic
74
- this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
75
- this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
73
+ this._forceWasm || this._allowWasm && !this._isInitialized || this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
76
74
  );
77
75
  }
78
76
  /**
@@ -150,4 +148,4 @@ export {
150
148
  WasmFeatureDetectors,
151
149
  WasmSupport
152
150
  };
153
- //# sourceMappingURL=index.js.map
151
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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 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: () => Promise<boolean>,\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 /**\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 /**\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\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,OACK;AAEA,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB,MAAM;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,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CAAC,IAAI,CAAC;cAMjB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAQvD"}
@@ -81,9 +81,7 @@ var WasmSupport = class _WasmSupport {
81
81
  get canUseWasm() {
82
82
  return (
83
83
  // Just force WASM
84
- this._forceWasm || // Or if we haven't checked be optimistic
85
- this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
86
- this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
84
+ this._forceWasm || this._allowWasm && !this._isInitialized || this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
87
85
  );
88
86
  }
89
87
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport.ts'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\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: () => Promise<boolean>,\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iCAgBO;AAEA,IAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,gBAAgB,MAAM;AAAA,EACtB,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,sBAAsB;AAAA,EACtB,UAAU;AAAA,EACV,SAAS;AACX;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;AAA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,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport.ts'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\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: () => Promise<boolean>,\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 /**\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 /**\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iCAgBO;AAEA,IAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe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AAAA;AAAA,EASA,aAAa,OAAO,iBAAsD;AACxE,UAAM,WAAW,IAAI,aAAY,eAAe;AAChD,UAAM,SAAS,WAAW;AAC1B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,UAA2C;AAC5D,UAAM,UAAU,MAAM,QAAQ,IAAI,SAAS,IAAI,aAAW,qBAAqB,OAAO,CAAC,EAAE,IAAI,OAAM,aAAY,MAAM,SAAS,CAAC,CAAC;AAChI,WAAO,QAAQ,MAAM,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK,eAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AAAA,EACxB;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,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
@@ -70,9 +70,7 @@ var WasmSupport = class _WasmSupport {
70
70
  get canUseWasm() {
71
71
  return (
72
72
  // Just force WASM
73
- this._forceWasm || // Or if we haven't checked be optimistic
74
- this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
75
- this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
73
+ this._forceWasm || this._allowWasm && !this._isInitialized || this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
76
74
  );
77
75
  }
78
76
  /**
@@ -150,4 +148,4 @@ export {
150
148
  WasmFeatureDetectors,
151
149
  WasmSupport
152
150
  };
153
- //# sourceMappingURL=index.js.map
151
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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 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: () => Promise<boolean>,\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 /**\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 /**\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\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,OACK;A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a,OAAO,iBAAsD;AACxE,UAAM,WAAW,IAAI,aAAY,eAAe;AAChD,UAAM,SAAS,WAAW;AAC1B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,UAA2C;AAC5D,UAAM,UAAU,MAAM,QAAQ,IAAI,SAAS,IAAI,aAAW,qBAAqB,OAAO,CAAC,EAAE,IAAI,OAAM,aAAY,MAAM,SAAS,CAAC,CAAC;AAChI,WAAO,QAAQ,MAAM,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK,eAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AAAA,EACxB;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,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
package/package.json CHANGED
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "description": "Primary SDK for using XYO Protocol 2.0",
16
16
  "devDependencies": {
17
- "@xylabs/ts-scripts-yarn3": "^3.14.1",
18
- "@xylabs/tsconfig": "^3.14.1",
17
+ "@xylabs/ts-scripts-yarn3": "^3.15.5",
18
+ "@xylabs/tsconfig": "^3.15.5",
19
19
  "typescript": "^5.5.4"
20
20
  },
21
21
  "exports": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "import": {
29
29
  "types": "./dist/browser/index.d.mts",
30
- "default": "./dist/browser/index.js"
30
+ "default": "./dist/browser/index.mjs"
31
31
  }
32
32
  },
33
33
  "node": {
@@ -37,14 +37,14 @@
37
37
  },
38
38
  "import": {
39
39
  "types": "./dist/node/index.d.mts",
40
- "default": "./dist/node/index.js"
40
+ "default": "./dist/node/index.mjs"
41
41
  }
42
42
  }
43
43
  },
44
44
  "./package.json": "./package.json"
45
45
  },
46
46
  "main": "dist/node/index.cjs",
47
- "module": "dist/node/index.js",
47
+ "module": "dist/node/index.mjs",
48
48
  "types": "dist/node/index.d.mts",
49
49
  "homepage": "https://xyo.network",
50
50
  "license": "LGPL-3.0-or-later",
@@ -56,6 +56,6 @@
56
56
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
57
57
  },
58
58
  "sideEffects": false,
59
- "version": "2.110.18",
59
+ "version": "2.111.0",
60
60
  "type": "module"
61
61
  }
@@ -60,6 +60,7 @@ export class WasmSupport {
60
60
  get allowWasm(): boolean {
61
61
  return this._allowWasm
62
62
  }
63
+
63
64
  /**
64
65
  * Whether or not to allow WASM usage
65
66
  */
@@ -74,11 +75,11 @@ export class WasmSupport {
74
75
  get canUseWasm(): boolean {
75
76
  return (
76
77
  // Just force WASM
77
- this._forceWasm ||
78
+ this._forceWasm
78
79
  // Or if we haven't checked be optimistic
79
- (this._allowWasm && !this._isInitialized) ||
80
+ || (this._allowWasm && !this._isInitialized)
80
81
  // Or if we have checked and WASM is not supported, be realistic
81
- (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)
82
+ || (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)
82
83
  )
83
84
  }
84
85
 
@@ -96,6 +97,7 @@ export class WasmSupport {
96
97
  get forceWasm(): boolean {
97
98
  return this._forceWasm
98
99
  }
100
+
99
101
  /**
100
102
  * Whether or not to force Wasm usage
101
103
  */
@@ -138,7 +140,7 @@ export class WasmSupport {
138
140
  * @returns True if all the features are supported, false otherwise
139
141
  */
140
142
  async featureCheck(features: WasmFeature[]): Promise<boolean> {
141
- const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))
143
+ const results = await Promise.all(features.map(feature => WasmFeatureDetectors[feature]).map(async detector => await detector()))
142
144
  return results.every(Boolean)
143
145
  }
144
146
 
@@ -1 +0,0 @@
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 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: () => Promise<boolean>,\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\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;A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AAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAa,OAAO,iBAAsD;AACxE,UAAM,WAAW,IAAI,aAAY,eAAe;AAChD,UAAM,SAAS,WAAW;AAC1B,WAAO;AAAA,EACT;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,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK,eAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AAAA,EACxB;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,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
@@ -1 +0,0 @@
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 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: () => Promise<boolean>,\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\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,OACK;AAEA,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB,MAAM;AAAA,EACtB;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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AAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK,eAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AAAA,EACxB;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,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
@@ -1 +0,0 @@
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 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: () => Promise<boolean>,\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 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(Boolean)\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 }\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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\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,OACK;AAEA,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB,MAAM;AAAA,EACtB;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;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