@xyo-network/wasm 2.84.19 → 2.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -46,38 +47,47 @@ var WasmFeatureDetectors = {
46
47
  threads: import_wasm_feature_detect.threads
47
48
  };
48
49
  var WasmSupport = class _WasmSupport {
50
+ static {
51
+ __name(this, "WasmSupport");
52
+ }
53
+ desiredFeatures;
54
+ _allowWasm;
55
+ _featureSupport;
56
+ _forceWasm;
57
+ _isInitialized;
58
+ _isWasmFeatureSetSupported;
49
59
  /**
50
- * Instance constructor for use where async instantiation
51
- * is not possible. Where possible, prefer the static
52
- * create method over use of this constructor directly
53
- * as no initialization (feature detection) is able to
54
- * be done here
55
- * @param desiredFeatures The desired feature set
56
- */
60
+ * Instance constructor for use where async instantiation
61
+ * is not possible. Where possible, prefer the static
62
+ * create method over use of this constructor directly
63
+ * as no initialization (feature detection) is able to
64
+ * be done here
65
+ * @param desiredFeatures The desired feature set
66
+ */
57
67
  constructor(desiredFeatures) {
58
68
  this.desiredFeatures = desiredFeatures;
69
+ this._allowWasm = true;
70
+ this._featureSupport = {};
71
+ this._forceWasm = false;
72
+ this._isInitialized = false;
73
+ this._isWasmFeatureSetSupported = false;
59
74
  }
60
- _allowWasm = true;
61
- _featureSupport = {};
62
- _forceWasm = false;
63
- _isInitialized = false;
64
- _isWasmFeatureSetSupported = false;
65
75
  /**
66
- * Is Wasm allowed
67
- */
76
+ * Is Wasm allowed
77
+ */
68
78
  get allowWasm() {
69
79
  return this._allowWasm;
70
80
  }
71
81
  /**
72
- * Whether or not to allow WASM usage
73
- */
82
+ * Whether or not to allow WASM usage
83
+ */
74
84
  set allowWasm(v) {
75
85
  this._allowWasm = v;
76
86
  }
77
87
  /**
78
- * Whether or not Wasm should be used based on the desired
79
- * feature set, initialization state, or force-use settings
80
- */
88
+ * Whether or not Wasm should be used based on the desired
89
+ * feature set, initialization state, or force-use settings
90
+ */
81
91
  get canUseWasm() {
82
92
  return (
83
93
  // Just force WASM
@@ -87,62 +97,64 @@ var WasmSupport = class _WasmSupport {
87
97
  );
88
98
  }
89
99
  /**
90
- * Returns a object containing a property for each desired wasm feature
91
- * with a boolean value indicating whether or not the feature is supported
92
- */
100
+ * Returns a object containing a property for each desired wasm feature
101
+ * with a boolean value indicating whether or not the feature is supported
102
+ */
93
103
  get featureSupport() {
94
- return { ...this._featureSupport };
104
+ return {
105
+ ...this._featureSupport
106
+ };
95
107
  }
96
108
  /**
97
- * Force use of Wasm
98
- */
109
+ * Force use of Wasm
110
+ */
99
111
  get forceWasm() {
100
112
  return this._forceWasm;
101
113
  }
102
114
  /**
103
- * Whether or not to force Wasm usage
104
- */
115
+ * Whether or not to force Wasm usage
116
+ */
105
117
  set forceWasm(v) {
106
118
  this._forceWasm = v;
107
119
  }
108
120
  /**
109
- * Whether or not Wasm is supported based
110
- * on the desired feature set
111
- */
121
+ * Whether or not Wasm is supported based
122
+ * on the desired feature set
123
+ */
112
124
  get isDesiredFeatureSetSupported() {
113
125
  return this._isWasmFeatureSetSupported;
114
126
  }
115
127
  /**
116
- * Whether or not Wasm detection has been run
117
- * for the desired feature set
118
- */
128
+ * Whether or not Wasm detection has been run
129
+ * for the desired feature set
130
+ */
119
131
  get isInitialized() {
120
132
  return this._isInitialized;
121
133
  }
122
134
  /**
123
- * Static creation & async initialization for use where
124
- * async instantiation is possible
125
- * @param desiredFeatures The desired feature set
126
- * @returns An initialized instance of the class with detection
127
- * for the desired feature set
128
- */
135
+ * Static creation & async initialization for use where
136
+ * async instantiation is possible
137
+ * @param desiredFeatures The desired feature set
138
+ * @returns An initialized instance of the class with detection
139
+ * for the desired feature set
140
+ */
129
141
  static async create(desiredFeatures) {
130
142
  const instance = new _WasmSupport(desiredFeatures);
131
143
  await instance.initialize();
132
144
  return instance;
133
145
  }
134
146
  /**
135
- * Checks for specific wasm features
136
- * @param features The list of features to check for
137
- * @returns True if all the features are supported, false otherwise
138
- */
147
+ * Checks for specific wasm features
148
+ * @param features The list of features to check for
149
+ * @returns True if all the features are supported, false otherwise
150
+ */
139
151
  async featureCheck(features) {
140
152
  const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
141
153
  return results.every(Boolean);
142
154
  }
143
155
  /**
144
- * Does feature detection for the desired feature set
145
- */
156
+ * Does feature detection for the desired feature set
157
+ */
146
158
  async initialize() {
147
159
  if (this._isInitialized)
148
160
  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;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iCAiBO;AAEA,IAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,sBAAsB;AAAA,EACtB,UAAU;AAAA,EACV,SAAS;AACX;AAIO,IAAM,cAAN,MAAM,aAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAevB,YAAsB,iBAAgC;AAAhC;AAAA,EAAiC;AAAA,EAd/C,aAAa;AAAA,EACb,kBAAyD,CAAC;AAAA,EAC1D,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,6BAA6B;AAAA;AAAA;AAAA;AAAA,EAerC,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAsB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AACpD,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\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"],"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AQC,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,22 +1,8 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
1
4
  // src/WasmSupport.ts
2
- import {
3
- bigInt,
4
- bulkMemory,
5
- exceptions,
6
- extendedConst,
7
- gc,
8
- memory64,
9
- multiValue,
10
- mutableGlobals,
11
- referenceTypes,
12
- relaxedSimd,
13
- saturatedFloatToInt,
14
- signExtensions,
15
- simd,
16
- streamingCompilation,
17
- tailCall,
18
- threads
19
- } from "wasm-feature-detect";
5
+ import { bigInt, bulkMemory, exceptions, extendedConst, gc, memory64, multiValue, mutableGlobals, referenceTypes, relaxedSimd, saturatedFloatToInt, signExtensions, simd, streamingCompilation, tailCall, threads } from "wasm-feature-detect";
20
6
  var WasmFeatureDetectors = {
21
7
  bigInt,
22
8
  bulkMemory,
@@ -36,38 +22,47 @@ var WasmFeatureDetectors = {
36
22
  threads
37
23
  };
38
24
  var WasmSupport = class _WasmSupport {
25
+ static {
26
+ __name(this, "WasmSupport");
27
+ }
28
+ desiredFeatures;
29
+ _allowWasm;
30
+ _featureSupport;
31
+ _forceWasm;
32
+ _isInitialized;
33
+ _isWasmFeatureSetSupported;
39
34
  /**
40
- * Instance constructor for use where async instantiation
41
- * is not possible. Where possible, prefer the static
42
- * create method over use of this constructor directly
43
- * as no initialization (feature detection) is able to
44
- * be done here
45
- * @param desiredFeatures The desired feature set
46
- */
35
+ * Instance constructor for use where async instantiation
36
+ * is not possible. Where possible, prefer the static
37
+ * create method over use of this constructor directly
38
+ * as no initialization (feature detection) is able to
39
+ * be done here
40
+ * @param desiredFeatures The desired feature set
41
+ */
47
42
  constructor(desiredFeatures) {
48
43
  this.desiredFeatures = desiredFeatures;
44
+ this._allowWasm = true;
45
+ this._featureSupport = {};
46
+ this._forceWasm = false;
47
+ this._isInitialized = false;
48
+ this._isWasmFeatureSetSupported = false;
49
49
  }
50
- _allowWasm = true;
51
- _featureSupport = {};
52
- _forceWasm = false;
53
- _isInitialized = false;
54
- _isWasmFeatureSetSupported = false;
55
50
  /**
56
- * Is Wasm allowed
57
- */
51
+ * Is Wasm allowed
52
+ */
58
53
  get allowWasm() {
59
54
  return this._allowWasm;
60
55
  }
61
56
  /**
62
- * Whether or not to allow WASM usage
63
- */
57
+ * Whether or not to allow WASM usage
58
+ */
64
59
  set allowWasm(v) {
65
60
  this._allowWasm = v;
66
61
  }
67
62
  /**
68
- * Whether or not Wasm should be used based on the desired
69
- * feature set, initialization state, or force-use settings
70
- */
63
+ * Whether or not Wasm should be used based on the desired
64
+ * feature set, initialization state, or force-use settings
65
+ */
71
66
  get canUseWasm() {
72
67
  return (
73
68
  // Just force WASM
@@ -77,62 +72,64 @@ var WasmSupport = class _WasmSupport {
77
72
  );
78
73
  }
79
74
  /**
80
- * Returns a object containing a property for each desired wasm feature
81
- * with a boolean value indicating whether or not the feature is supported
82
- */
75
+ * Returns a object containing a property for each desired wasm feature
76
+ * with a boolean value indicating whether or not the feature is supported
77
+ */
83
78
  get featureSupport() {
84
- return { ...this._featureSupport };
79
+ return {
80
+ ...this._featureSupport
81
+ };
85
82
  }
86
83
  /**
87
- * Force use of Wasm
88
- */
84
+ * Force use of Wasm
85
+ */
89
86
  get forceWasm() {
90
87
  return this._forceWasm;
91
88
  }
92
89
  /**
93
- * Whether or not to force Wasm usage
94
- */
90
+ * Whether or not to force Wasm usage
91
+ */
95
92
  set forceWasm(v) {
96
93
  this._forceWasm = v;
97
94
  }
98
95
  /**
99
- * Whether or not Wasm is supported based
100
- * on the desired feature set
101
- */
96
+ * Whether or not Wasm is supported based
97
+ * on the desired feature set
98
+ */
102
99
  get isDesiredFeatureSetSupported() {
103
100
  return this._isWasmFeatureSetSupported;
104
101
  }
105
102
  /**
106
- * Whether or not Wasm detection has been run
107
- * for the desired feature set
108
- */
103
+ * Whether or not Wasm detection has been run
104
+ * for the desired feature set
105
+ */
109
106
  get isInitialized() {
110
107
  return this._isInitialized;
111
108
  }
112
109
  /**
113
- * Static creation & async initialization for use where
114
- * async instantiation is possible
115
- * @param desiredFeatures The desired feature set
116
- * @returns An initialized instance of the class with detection
117
- * for the desired feature set
118
- */
110
+ * Static creation & async initialization for use where
111
+ * async instantiation is possible
112
+ * @param desiredFeatures The desired feature set
113
+ * @returns An initialized instance of the class with detection
114
+ * for the desired feature set
115
+ */
119
116
  static async create(desiredFeatures) {
120
117
  const instance = new _WasmSupport(desiredFeatures);
121
118
  await instance.initialize();
122
119
  return instance;
123
120
  }
124
121
  /**
125
- * Checks for specific wasm features
126
- * @param features The list of features to check for
127
- * @returns True if all the features are supported, false otherwise
128
- */
122
+ * Checks for specific wasm features
123
+ * @param features The list of features to check for
124
+ * @returns True if all the features are supported, false otherwise
125
+ */
129
126
  async featureCheck(features) {
130
127
  const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
131
128
  return results.every(Boolean);
132
129
  }
133
130
  /**
134
- * Does feature detection for the desired feature set
135
- */
131
+ * Does feature detection for the desired feature set
132
+ */
136
133
  async initialize() {
137
134
  if (this._isInitialized)
138
135
  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;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,IAAM,cAAN,MAAM,aAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAevB,YAAsB,iBAAgC;AAAhC;AAAA,EAAiC;AAAA,EAd/C,aAAa;AAAA,EACb,kBAAyD,CAAC;AAAA,EAC1D,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,6BAA6B;AAAA;AAAA;AAAA;AAAA,EAerC,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAsB;AACxB;AAAA;AAAA,MAEE,KAAK;AAAA,MAEJ,KAAK,cAAc,CAAC,KAAK;AAAA,MAEzB,KAAK,cAAc,KAAK,kBAAkB,KAAK;AAAA;AAAA,EAEpD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,iBAAkE;AACpE,WAAO,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esContent":["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;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C;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"]}
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -45,39 +46,45 @@ var WasmFeatureDetectors = {
45
46
  tailCall: import_wasm_feature_detect.tailCall,
46
47
  threads: import_wasm_feature_detect.threads
47
48
  };
48
- var WasmSupport = class _WasmSupport {
49
+ var _WasmSupport = class _WasmSupport {
50
+ desiredFeatures;
51
+ _allowWasm;
52
+ _featureSupport;
53
+ _forceWasm;
54
+ _isInitialized;
55
+ _isWasmFeatureSetSupported;
49
56
  /**
50
- * Instance constructor for use where async instantiation
51
- * is not possible. Where possible, prefer the static
52
- * create method over use of this constructor directly
53
- * as no initialization (feature detection) is able to
54
- * be done here
55
- * @param desiredFeatures The desired feature set
56
- */
57
+ * Instance constructor for use where async instantiation
58
+ * is not possible. Where possible, prefer the static
59
+ * create method over use of this constructor directly
60
+ * as no initialization (feature detection) is able to
61
+ * be done here
62
+ * @param desiredFeatures The desired feature set
63
+ */
57
64
  constructor(desiredFeatures) {
58
65
  this.desiredFeatures = desiredFeatures;
66
+ this._allowWasm = true;
67
+ this._featureSupport = {};
68
+ this._forceWasm = false;
69
+ this._isInitialized = false;
70
+ this._isWasmFeatureSetSupported = false;
59
71
  }
60
- _allowWasm = true;
61
- _featureSupport = {};
62
- _forceWasm = false;
63
- _isInitialized = false;
64
- _isWasmFeatureSetSupported = false;
65
72
  /**
66
- * Is Wasm allowed
67
- */
73
+ * Is Wasm allowed
74
+ */
68
75
  get allowWasm() {
69
76
  return this._allowWasm;
70
77
  }
71
78
  /**
72
- * Whether or not to allow WASM usage
73
- */
79
+ * Whether or not to allow WASM usage
80
+ */
74
81
  set allowWasm(v) {
75
82
  this._allowWasm = v;
76
83
  }
77
84
  /**
78
- * Whether or not Wasm should be used based on the desired
79
- * feature set, initialization state, or force-use settings
80
- */
85
+ * Whether or not Wasm should be used based on the desired
86
+ * feature set, initialization state, or force-use settings
87
+ */
81
88
  get canUseWasm() {
82
89
  return (
83
90
  // Just force WASM
@@ -87,62 +94,64 @@ var WasmSupport = class _WasmSupport {
87
94
  );
88
95
  }
89
96
  /**
90
- * Returns a object containing a property for each desired wasm feature
91
- * with a boolean value indicating whether or not the feature is supported
92
- */
97
+ * Returns a object containing a property for each desired wasm feature
98
+ * with a boolean value indicating whether or not the feature is supported
99
+ */
93
100
  get featureSupport() {
94
- return { ...this._featureSupport };
101
+ return {
102
+ ...this._featureSupport
103
+ };
95
104
  }
96
105
  /**
97
- * Force use of Wasm
98
- */
106
+ * Force use of Wasm
107
+ */
99
108
  get forceWasm() {
100
109
  return this._forceWasm;
101
110
  }
102
111
  /**
103
- * Whether or not to force Wasm usage
104
- */
112
+ * Whether or not to force Wasm usage
113
+ */
105
114
  set forceWasm(v) {
106
115
  this._forceWasm = v;
107
116
  }
108
117
  /**
109
- * Whether or not Wasm is supported based
110
- * on the desired feature set
111
- */
118
+ * Whether or not Wasm is supported based
119
+ * on the desired feature set
120
+ */
112
121
  get isDesiredFeatureSetSupported() {
113
122
  return this._isWasmFeatureSetSupported;
114
123
  }
115
124
  /**
116
- * Whether or not Wasm detection has been run
117
- * for the desired feature set
118
- */
125
+ * Whether or not Wasm detection has been run
126
+ * for the desired feature set
127
+ */
119
128
  get isInitialized() {
120
129
  return this._isInitialized;
121
130
  }
122
131
  /**
123
- * Static creation & async initialization for use where
124
- * async instantiation is possible
125
- * @param desiredFeatures The desired feature set
126
- * @returns An initialized instance of the class with detection
127
- * for the desired feature set
128
- */
132
+ * Static creation & async initialization for use where
133
+ * async instantiation is possible
134
+ * @param desiredFeatures The desired feature set
135
+ * @returns An initialized instance of the class with detection
136
+ * for the desired feature set
137
+ */
129
138
  static async create(desiredFeatures) {
130
139
  const instance = new _WasmSupport(desiredFeatures);
131
140
  await instance.initialize();
132
141
  return instance;
133
142
  }
134
143
  /**
135
- * Checks for specific wasm features
136
- * @param features The list of features to check for
137
- * @returns True if all the features are supported, false otherwise
138
- */
144
+ * Checks for specific wasm features
145
+ * @param features The list of features to check for
146
+ * @returns True if all the features are supported, false otherwise
147
+ */
139
148
  async featureCheck(features) {
140
149
  const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
141
150
  return results.every(Boolean);
142
151
  }
143
152
  /**
144
- * Does feature detection for the desired feature set
145
- */
153
+ * Does feature detection for the desired feature set
154
+ */
146
155
  async initialize() {
147
156
  if (this._isInitialized)
148
157
  return;
@@ -159,6 +168,8 @@ var WasmSupport = class _WasmSupport {
159
168
  this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
160
169
  }
161
170
  };
171
+ __name(_WasmSupport, "WasmSupport");
172
+ var WasmSupport = _WasmSupport;
162
173
  // Annotate the CommonJS export names for ESM import in node:
163
174
  0 && (module.exports = {
164
175
  WasmFeatureDetectors,
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iCAiBO;AAEA,IAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,sBAAsB;AAAA,EACtB,UAAU;AAAA,EACV,SAAS;AACX;AAIO,IAAM,cAAN,MAAM,aAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAevB,YAAsB,iBAAgC;AAAhC;AAAA,EAAiC;AAAA,EAd/C,aAAa;AAAA,EACb,kBAAyD,CAAC;AAAA,EAC1D,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,6BAA6B;AAAA;AAAA;AAAA;AAAA,EAerC,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAsB;AACxB;AAAA;AAAA,MAEE,KAAK;AAAA,MAEJ,KAAK,cAAc,CAAC,KAAK;AAAA,MAEzB,KAAK,cAAc,KAAK,kBAAkB,KAAK;AAAA;AAAA,EAEpD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,iBAAkE;AACpE,WAAO,EAAE,GAAG,KAAK,gBAAgB;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,+BAAwC;AAC1C,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,gBAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAa,OAAO,iBAAsD;AACxE,UAAM,WAAW,IAAI,aAAY,eAAe;AAChD,UAAM,SAAS,WAAW;AAC1B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,UAA2C;AAC5D,UAAM,UAAU,MAAM,QAAQ,IAAI,SAAS,IAAI,CAAC,YAAY,qBAAqB,OAAO,CAAC,EAAE,IAAI,OAAO,aAAa,MAAM,SAAS,CAAC,CAAC;AACpI,WAAO,QAAQ,MAAM,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK;AAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AACtB;AAAA,EACF;AAAA,EAEA,MAAgB,wBAAuC;AACrD,aAAS,UAAU,GAAG,UAAU,KAAK,gBAAgB,QAAQ,WAAW;AACtE,YAAM,iBAAiB,KAAK,gBAAgB,OAAO;AACnD,YAAM,WAAW,qBAAqB,cAAc;AACpD,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\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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jB,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,22 +1,8 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
1
4
  // src/WasmSupport.ts
2
- import {
3
- bigInt,
4
- bulkMemory,
5
- exceptions,
6
- extendedConst,
7
- gc,
8
- memory64,
9
- multiValue,
10
- mutableGlobals,
11
- referenceTypes,
12
- relaxedSimd,
13
- saturatedFloatToInt,
14
- signExtensions,
15
- simd,
16
- streamingCompilation,
17
- tailCall,
18
- threads
19
- } from "wasm-feature-detect";
5
+ import { bigInt, bulkMemory, exceptions, extendedConst, gc, memory64, multiValue, mutableGlobals, referenceTypes, relaxedSimd, saturatedFloatToInt, signExtensions, simd, streamingCompilation, tailCall, threads } from "wasm-feature-detect";
20
6
  var WasmFeatureDetectors = {
21
7
  bigInt,
22
8
  bulkMemory,
@@ -35,39 +21,45 @@ var WasmFeatureDetectors = {
35
21
  tailCall,
36
22
  threads
37
23
  };
38
- var WasmSupport = class _WasmSupport {
24
+ var _WasmSupport = class _WasmSupport {
25
+ desiredFeatures;
26
+ _allowWasm;
27
+ _featureSupport;
28
+ _forceWasm;
29
+ _isInitialized;
30
+ _isWasmFeatureSetSupported;
39
31
  /**
40
- * Instance constructor for use where async instantiation
41
- * is not possible. Where possible, prefer the static
42
- * create method over use of this constructor directly
43
- * as no initialization (feature detection) is able to
44
- * be done here
45
- * @param desiredFeatures The desired feature set
46
- */
32
+ * Instance constructor for use where async instantiation
33
+ * is not possible. Where possible, prefer the static
34
+ * create method over use of this constructor directly
35
+ * as no initialization (feature detection) is able to
36
+ * be done here
37
+ * @param desiredFeatures The desired feature set
38
+ */
47
39
  constructor(desiredFeatures) {
48
40
  this.desiredFeatures = desiredFeatures;
41
+ this._allowWasm = true;
42
+ this._featureSupport = {};
43
+ this._forceWasm = false;
44
+ this._isInitialized = false;
45
+ this._isWasmFeatureSetSupported = false;
49
46
  }
50
- _allowWasm = true;
51
- _featureSupport = {};
52
- _forceWasm = false;
53
- _isInitialized = false;
54
- _isWasmFeatureSetSupported = false;
55
47
  /**
56
- * Is Wasm allowed
57
- */
48
+ * Is Wasm allowed
49
+ */
58
50
  get allowWasm() {
59
51
  return this._allowWasm;
60
52
  }
61
53
  /**
62
- * Whether or not to allow WASM usage
63
- */
54
+ * Whether or not to allow WASM usage
55
+ */
64
56
  set allowWasm(v) {
65
57
  this._allowWasm = v;
66
58
  }
67
59
  /**
68
- * Whether or not Wasm should be used based on the desired
69
- * feature set, initialization state, or force-use settings
70
- */
60
+ * Whether or not Wasm should be used based on the desired
61
+ * feature set, initialization state, or force-use settings
62
+ */
71
63
  get canUseWasm() {
72
64
  return (
73
65
  // Just force WASM
@@ -77,62 +69,64 @@ var WasmSupport = class _WasmSupport {
77
69
  );
78
70
  }
79
71
  /**
80
- * Returns a object containing a property for each desired wasm feature
81
- * with a boolean value indicating whether or not the feature is supported
82
- */
72
+ * Returns a object containing a property for each desired wasm feature
73
+ * with a boolean value indicating whether or not the feature is supported
74
+ */
83
75
  get featureSupport() {
84
- return { ...this._featureSupport };
76
+ return {
77
+ ...this._featureSupport
78
+ };
85
79
  }
86
80
  /**
87
- * Force use of Wasm
88
- */
81
+ * Force use of Wasm
82
+ */
89
83
  get forceWasm() {
90
84
  return this._forceWasm;
91
85
  }
92
86
  /**
93
- * Whether or not to force Wasm usage
94
- */
87
+ * Whether or not to force Wasm usage
88
+ */
95
89
  set forceWasm(v) {
96
90
  this._forceWasm = v;
97
91
  }
98
92
  /**
99
- * Whether or not Wasm is supported based
100
- * on the desired feature set
101
- */
93
+ * Whether or not Wasm is supported based
94
+ * on the desired feature set
95
+ */
102
96
  get isDesiredFeatureSetSupported() {
103
97
  return this._isWasmFeatureSetSupported;
104
98
  }
105
99
  /**
106
- * Whether or not Wasm detection has been run
107
- * for the desired feature set
108
- */
100
+ * Whether or not Wasm detection has been run
101
+ * for the desired feature set
102
+ */
109
103
  get isInitialized() {
110
104
  return this._isInitialized;
111
105
  }
112
106
  /**
113
- * Static creation & async initialization for use where
114
- * async instantiation is possible
115
- * @param desiredFeatures The desired feature set
116
- * @returns An initialized instance of the class with detection
117
- * for the desired feature set
118
- */
107
+ * Static creation & async initialization for use where
108
+ * async instantiation is possible
109
+ * @param desiredFeatures The desired feature set
110
+ * @returns An initialized instance of the class with detection
111
+ * for the desired feature set
112
+ */
119
113
  static async create(desiredFeatures) {
120
114
  const instance = new _WasmSupport(desiredFeatures);
121
115
  await instance.initialize();
122
116
  return instance;
123
117
  }
124
118
  /**
125
- * Checks for specific wasm features
126
- * @param features The list of features to check for
127
- * @returns True if all the features are supported, false otherwise
128
- */
119
+ * Checks for specific wasm features
120
+ * @param features The list of features to check for
121
+ * @returns True if all the features are supported, false otherwise
122
+ */
129
123
  async featureCheck(features) {
130
124
  const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
131
125
  return results.every(Boolean);
132
126
  }
133
127
  /**
134
- * Does feature detection for the desired feature set
135
- */
128
+ * Does feature detection for the desired feature set
129
+ */
136
130
  async initialize() {
137
131
  if (this._isInitialized)
138
132
  return;
@@ -149,6 +143,8 @@ var WasmSupport = class _WasmSupport {
149
143
  this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
150
144
  }
151
145
  };
146
+ __name(_WasmSupport, "WasmSupport");
147
+ var WasmSupport = _WasmSupport;
152
148
  export {
153
149
  WasmFeatureDetectors,
154
150
  WasmSupport
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/WasmSupport.ts"],"sourcesContent":["import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n referenceTypes,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: referenceTypes,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return 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;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,IAAM,cAAN,MAAM,aAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAevB,YAAsB,iBAAgC;AAAhC;AAAA,EAAiC;AAAA,EAd/C,aAAa;AAAA,EACb,kBAAyD,CAAC;AAAA,EAC1D,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,6BAA6B;AAAA;AAAA;AAAA;AAAA,EAerC,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAsB;AACxB;AAAA;AAAA,MAEE,KAAK;AAAA,MAEJ,KAAK,cAAc,CAAC,KAAK;AAAA,MAEzB,KAAK,cAAc,KAAK,kBAAkB,KAAK;AAAA;AAAA,EAEpD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,iBAAkE;AACpE,WAAO,EAAE,GAAG,KAAK,gBAAgB;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,+BAAwC;AAC1C,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,gBAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,aAAa,OAAO,iBAAsD;AACxE,UAAM,WAAW,IAAI,aAAY,eAAe;AAChD,UAAM,SAAS,WAAW;AAC1B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,UAA2C;AAC5D,UAAM,UAAU,MAAM,QAAQ,IAAI,SAAS,IAAI,CAAC,YAAY,qBAAqB,OAAO,CAAC,EAAE,IAAI,OAAO,aAAa,MAAM,SAAS,CAAC,CAAC;AACpI,WAAO,QAAQ,MAAM,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,QAAI,KAAK;AAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AACtB;AAAA,EACF;AAAA,EAEA,MAAgB,wBAAuC;AACrD,aAAS,UAAU,GAAG,UAAU,KAAK,gBAAgB,QAAQ,WAAW;AACtE,YAAM,iBAAiB,KAAK,gBAAgB,OAAO;AACnD,YAAM,WAAW,qBAAqB,cAAc;AACpD,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 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;;;;;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AAA;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
@@ -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.84.19",
59
+ "version": "2.85.0",
60
60
  "type": "module"
61
61
  }