@xyo-network/wasm 2.104.0 → 2.104.1

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.
@@ -156,8 +156,7 @@ var WasmSupport = class _WasmSupport {
156
156
  * Does feature detection for the desired feature set
157
157
  */
158
158
  async initialize() {
159
- if (this._isInitialized)
160
- return;
159
+ if (this._isInitialized) return;
161
160
  await this.detectDesiredFeatures();
162
161
  this._isInitialized = true;
163
162
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\n","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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACAA,iCAiBO;AAEA,IAAMA,uBAAuB;EAClCC,QAAQA;EACRC,YAAYA;EACZC,YAAYA;EACZC,eAAeA;EACfC,IAAIA;EACJC,UAAUA;EACVC,YAAYA;EACZC,gBAAgBA;EAChBC,gBAAgBA;EAChBC,aAAaA;EACbC,qBAAqBA;EACrBC,gBAAgBA;EAChBC,MAAMA;EACNC,sBAAsBA;EACtBC,UAAUA;EACVC,SAASA;AACX;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAxCb,OAwCaA;;;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb;AAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\n","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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACAA,iCAiBO;AAEA,IAAMA,uBAAuB;EAClCC,QAAQA;EACRC,YAAYA;EACZC,YAAYA;EACZC,eAAeA;EACfC,IAAIA;EACJC,UAAUA;EACVC,YAAYA;EACZC,gBAAgBA;EAChBC,gBAAgBA;EAChBC,aAAaA;EACbC,qBAAqBA;EACrBC,gBAAgBA;EAChBC,MAAMA;EACNC,sBA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AAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
@@ -131,8 +131,7 @@ var WasmSupport = class _WasmSupport {
131
131
  * Does feature detection for the desired feature set
132
132
  */
133
133
  async initialize() {
134
- if (this._isInitialized)
135
- return;
134
+ if (this._isInitialized) return;
136
135
  await this.detectDesiredFeatures();
137
136
  this._isInitialized = true;
138
137
  return;
@@ -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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;AAAA,SACEA,QACAC,YACAC,YACAC,eACAC,IACAC,UACAC,YACAC,gBACAC,gBACAC,aACAC,qBACAC,gBACAC,MACAC,sBACAC,UACAC,eACK;AAEA,IAAMC,uBAAuB;EAClCC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;AACF;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAxCb,OAwCaA;;;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY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["bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;AAAA,SACEA,QACAC,YACAC,YACAC,eACAC,IACAC,UACAC,YACAC,gBACAC,gBACAC,aACAC,qBACAC,gBACAC,MACAC,sBACAC,UACAC,eACK;AAEA,IAAMC,uBAAuB;EAClCC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;AACF;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAxCb,OAwCaA;;;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb,eAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
@@ -156,8 +156,7 @@ var WasmSupport = class _WasmSupport {
156
156
  * Does feature detection for the desired feature set
157
157
  */
158
158
  async initialize() {
159
- if (this._isInitialized)
160
- return;
159
+ if (this._isInitialized) return;
161
160
  await this.detectDesiredFeatures();
162
161
  this._isInitialized = true;
163
162
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\n","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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACAA,iCAiBO;AAEA,IAAMA,uBAAuB;EAClCC,QAAQA;EACRC,YAAYA;EACZC,YAAYA;EACZC,eAAeA;EACfC,IAAIA;EACJC,UAAUA;EACVC,YAAYA;EACZC,gBAAgBA;EAChBC,gBAAgBA;EAChBC,aAAaA;EACbC,qBAAqBA;EACrBC,gBAAgBA;EAChBC,MAAMA;EACNC,sBAAsBA;EACtBC,UAAUA;EACVC,SAASA;AACX;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAxCb,OAwCaA;;;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb;AAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\n","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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACAA,iCAiBO;AAEA,IAAMA,uBAAuB;EAClCC,QAAQA;EACRC,YAAYA;EACZC,YAAYA;EACZC,eAAeA;EACfC,IAAIA;EACJC,UAAUA;EACVC,YAAYA;EACZC,gBAAgBA;EAChBC,gBAAgBA;EAChBC,aAAaA;EACbC,qBAAqBA;EACrBC,gBAAgBA;EAChBC,MAAMA;EACNC,sBAAsBA;EACtBC,UAAUA;EACVC,SAASA;AACX;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAx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,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
@@ -131,8 +131,7 @@ var WasmSupport = class _WasmSupport {
131
131
  * Does feature detection for the desired feature set
132
132
  */
133
133
  async initialize() {
134
- if (this._isInitialized)
135
- return;
134
+ if (this._isInitialized) return;
136
135
  await this.detectDesiredFeatures();
137
136
  this._isInitialized = true;
138
137
  return;
@@ -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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;AAAA,SACEA,QACAC,YACAC,YACAC,eACAC,IACAC,UACAC,YACAC,gBACAC,gBACAC,aACAC,qBACAC,gBACAC,MACAC,sBACAC,UACAC,eACK;AAEA,IAAMC,uBAAuB;EAClCC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;AACF;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAxCb,OAwCaA;;;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb;AAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;AAAA,SACEA,QACAC,YACAC,YACAC,eACAC,IACAC,UACAC,YACAC,gBACAC,gBACAC,aACAC,qBACAC,gBACAC,MACAC,sBACAC,UACAC,eACK;AAEA,IAAMC,uBAAuB;EAClCC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;AACF;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAxCb,OAwCaA;;;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb,eAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
@@ -153,8 +153,7 @@ var _WasmSupport = class _WasmSupport {
153
153
  * Does feature detection for the desired feature set
154
154
  */
155
155
  async initialize() {
156
- if (this._isInitialized)
157
- return;
156
+ if (this._isInitialized) return;
158
157
  await this.detectDesiredFeatures();
159
158
  this._isInitialized = true;
160
159
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\n","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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\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H,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb;AAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;AA3Ha3B;AAAN,IAAMA,cAAN;","names":["WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\n","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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACAA,iCAiBO;AAEA,IAAMA,uBAAuB;EAClCC,QAAQA;EACRC,YAAYA;EACZC,YAAYA;EACZC,eAAeA;EACfC,IAAIA;EACJC,UAAUA;EACVC,YAAYA;EACZC,gBAAgBA;EAChBC,gBAAgBA;EAChBC,aAAaA;EACbC,qBAAqBA;EACrBC,gBAAgBA;EAChBC,MAAMA;EACNC,sBAAsBA;EACtBC,UAAUA;EACVC,SAASA;AACX;AAIO,IAAMC,eAAN,MAAMA,aAAAA;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;S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BAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;AA3Ha3B;AAAN,IAAMA,cAAN;","names":["WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
@@ -128,8 +128,7 @@ var _WasmSupport = class _WasmSupport {
128
128
  * Does feature detection for the desired feature set
129
129
  */
130
130
  async initialize() {
131
- if (this._isInitialized)
132
- return;
131
+ if (this._isInitialized) return;
133
132
  await this.detectDesiredFeatures();
134
133
  this._isInitialized = true;
135
134
  return;
@@ -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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;AAAA,SACEA,QACAC,YACAC,YACAC,eACAC,IACAC,UACAC,YACAC,gBACAC,gBACAC,aACAC,qBACAC,gBACAC,MACAC,sBACAC,UACAC,eACK;AAEA,IAAMC,uBAAuB;EAClCC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;AACF;AAIO,IAAMC,eAAN,MAAMA,aAAAA;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb;AAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;AA3Ha3B;AAAN,IAAMA,cAAN;","names":["bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
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 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 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 this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;AAAA,SACEA,QACAC,YACAC,YACAC,eACAC,IACAC,UACAC,YACAC,gBACAC,gBACAC,aACAC,qBACAC,gBACAC,MACAC,sBACAC,UACAC,eACK;AAEA,IAAMC,uBAAuB;EAClCC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;AACF;AAIO,IAAMC,eAAN,MAAMA,aAAAA;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb,eAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;AA3Ha3B;AAAN,IAAMA,cAAN;","names":["bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
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.10.4",
18
- "@xylabs/tsconfig": "^3.10.4",
17
+ "@xylabs/ts-scripts-yarn3": "^3.11.2",
18
+ "@xylabs/tsconfig": "^3.11.2",
19
19
  "typescript": "^5.4.5"
20
20
  },
21
21
  "exports": {
@@ -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.104.0",
59
+ "version": "2.104.1",
60
60
  "type": "module"
61
61
  }