@xyo-network/wasm 3.18.5 → 3.18.7

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.
@@ -16,6 +16,7 @@ import {
16
16
  tailCall,
17
17
  threads
18
18
  } from "wasm-feature-detect";
19
+ import { isTruthy } from "@xylabs/typeof";
19
20
  var WasmFeatureDetectors = {
20
21
  bigInt,
21
22
  bulkMemory,
@@ -139,7 +140,7 @@ var WasmSupport = class _WasmSupport {
139
140
  for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
140
141
  const desiredFeature = this.desiredFeatures[feature];
141
142
  const detector = WasmFeatureDetectors[desiredFeature];
142
- this._featureSupport[desiredFeature] = await detector() ? true : false;
143
+ this._featureSupport[desiredFeature] = isTruthy(await detector());
143
144
  }
144
145
  this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
145
146
  }
@@ -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 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,6BAA6B;AAAA;AAAA;AAAA;AAAA,EAerC,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAsB;AACxB;AAAA;AAAA,MAEE,KA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AAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/WasmSupport.ts"],"sourcesContent":["import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n 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\nimport { isTruthy } from '@xylabs/typeof'\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] = isTruthy(await detector())\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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;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,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,IAAI,SAAS,MAAM,SAAS,CAAC;AAAA,IAClE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
@@ -16,6 +16,7 @@ import {
16
16
  tailCall,
17
17
  threads
18
18
  } from "wasm-feature-detect";
19
+ import { isTruthy } from "@xylabs/typeof";
19
20
  var WasmFeatureDetectors = {
20
21
  bigInt,
21
22
  bulkMemory,
@@ -139,7 +140,7 @@ var WasmSupport = class _WasmSupport {
139
140
  for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
140
141
  const desiredFeature = this.desiredFeatures[feature];
141
142
  const detector = WasmFeatureDetectors[desiredFeature];
142
- this._featureSupport[desiredFeature] = await detector() ? true : false;
143
+ this._featureSupport[desiredFeature] = isTruthy(await detector());
143
144
  }
144
145
  this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
145
146
  }
@@ -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 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;AA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d;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,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":[]}
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\nimport { isTruthy } from '@xylabs/typeof'\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] = isTruthy(await detector())\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;AAqBP,SAAS,gBAAgB;AAnBlB,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;AAMO,IAAM,cAAN,MAAM,aAAY;AAAA;AAAA;AAAA;AAAA;AAAA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S,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,IAAI,SAAS,MAAM,SAAS,CAAC;AAAA,IAClE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
@@ -16,6 +16,7 @@ import {
16
16
  tailCall,
17
17
  threads
18
18
  } from "wasm-feature-detect";
19
+ import { isTruthy } from "@xylabs/typeof";
19
20
  var WasmFeatureDetectors = {
20
21
  bigInt,
21
22
  bulkMemory,
@@ -139,7 +140,7 @@ var WasmSupport = class _WasmSupport {
139
140
  for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
140
141
  const desiredFeature = this.desiredFeatures[feature];
141
142
  const detector = WasmFeatureDetectors[desiredFeature];
142
- this._featureSupport[desiredFeature] = await detector() ? true : false;
143
+ this._featureSupport[desiredFeature] = isTruthy(await detector());
143
144
  }
144
145
  this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
145
146
  }
@@ -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 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;AA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AAC;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":[]}
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\nimport { isTruthy } from '@xylabs/typeof'\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] = isTruthy(await detector())\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;AAqBP,SAAS,gBAAgB;AAnBlB,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;AAMO,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,EAKA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAsB;AACxB;AAAA;AAAA,MAEE,KAAK,cAED,KAAK,cAAc,CAAC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K,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
@@ -18,13 +18,7 @@ export declare const WasmFeatureDetectors: {
18
18
  resolve(): Promise<void>;
19
19
  resolve<T>(value: T): Promise<Awaited<T>>;
20
20
  resolve<T>(value: T | PromiseLike<T>): Promise<Awaited<T>>;
21
- allSettled<T extends readonly unknown[] | []>(values: T): Promise<{
22
- /**
23
- * Is Wasm allowed
24
- */
25
- - /**
26
- * Is Wasm allowed
27
- */readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>; }>;
21
+ allSettled<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>; }>;
28
22
  allSettled<T>(values: Iterable<T | PromiseLike<T>>): Promise<PromiseSettledResult<Awaited<T>>[]>;
29
23
  any<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
30
24
  any<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
@@ -1 +1 @@
1
- {"version":3,"file":"WasmSupport.d.ts","sourceRoot":"","sources":["../../src/WasmSupport.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,oBAAoB;;;;;;;;;;iGAoCa,CAAC;;qEAoB7C,CAAD;;;;;;;;;QAlBC;;WAEG;QACH,CAHF,CAAE;;WAEG;;;;;iDAQqB,GAAG;;;;;;;;;;CA/BnB,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,oBAAoB,CAAA;AAE3D,qBAAa,WAAW;IAeV,SAAS,CAAC,eAAe,EAAE,WAAW,EAAE;IAdpD,OAAO,CAAC,UAAU,CAAO;IACzB,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,0BAA0B,CAAQ;IAE1C;;;;;;;OAOG;gBACmB,eAAe,EAAE,WAAW,EAAE;IAEpD;;OA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AO,CAAC,0BAA0B,CAAQ;IAE1C;;;;;;;OAOG;gBACmB,eAAe,EAAE,WAAW,EAAE;IAEpD;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;OAEG;IACH,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAED;;;OAGG;IACH,IAAI,UAAU,IAAI,OAAO,CASxB;IAED;;;OAGG;IACH,IAAI,cAAc,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAEpE;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;OAEG;IACH,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;IAED;;;OAGG;IACH,IAAI,4BAA4B,IAAI,OAAO,CAE1C;IAED;;;OAGG;IACH,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED;;;;;;OAMG;WACU,MAAM,CAAC,eAAe,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAMzE;;;;OAIG;IACG,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAK7D;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAMjB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAQvD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/wasm",
3
- "version": "3.18.5",
3
+ "version": "3.18.7",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -29,14 +29,15 @@
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/types/index.d.ts",
31
31
  "dependencies": {
32
+ "@xylabs/typeof": "^4.11.17",
32
33
  "wasm-feature-detect": "^1.8.0"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@xylabs/ts-scripts-yarn3": "^6.5.8",
36
37
  "@xylabs/tsconfig": "^6.5.8",
37
- "@xylabs/vitest-extended": "^4.11.16",
38
+ "@xylabs/vitest-extended": "^4.11.17",
38
39
  "typescript": "^5.8.3",
39
- "vitest": "^3.2.2"
40
+ "vitest": "^3.2.3"
40
41
  },
41
42
  "publishConfig": {
42
43
  "access": "public"
@@ -35,6 +35,8 @@ export const WasmFeatureDetectors = {
35
35
  threads: threads,
36
36
  } as const
37
37
 
38
+ import { isTruthy } from '@xylabs/typeof'
39
+
38
40
  export type WasmFeature = keyof typeof WasmFeatureDetectors
39
41
 
40
42
  export class WasmSupport {
@@ -157,7 +159,7 @@ export class WasmSupport {
157
159
  for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
158
160
  const desiredFeature = this.desiredFeatures[feature]
159
161
  const detector = WasmFeatureDetectors[desiredFeature]
160
- this._featureSupport[desiredFeature] = (await detector()) ? true : false
162
+ this._featureSupport[desiredFeature] = isTruthy(await detector())
161
163
  }
162
164
  this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)
163
165
  }