@xyo-network/wasm 2.110.10 → 2.110.12
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.
- package/dist/browser/WasmSupport.d.cts.map +1 -1
- package/dist/browser/WasmSupport.d.mts.map +1 -1
- package/dist/browser/WasmSupport.d.ts.map +1 -1
- package/dist/browser/index.cjs +46 -59
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +63 -62
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/WasmSupport.d.cts.map +1 -1
- package/dist/neutral/WasmSupport.d.mts.map +1 -1
- package/dist/neutral/WasmSupport.d.ts.map +1 -1
- package/dist/neutral/index.cjs +46 -59
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +63 -62
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/WasmSupport.d.cts.map +1 -1
- package/dist/node/WasmSupport.d.mts.map +1 -1
- package/dist/node/WasmSupport.d.ts.map +1 -1
- package/dist/node/index.cjs +47 -59
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +64 -62
- package/dist/node/index.js.map +1 -1
- package/package.json +3 -3
- package/src/WasmSupport.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WasmSupport.d.ts","sourceRoot":"","sources":["../../src/WasmSupport.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,oBAAoB;;;;;;;;;;iGAoCa,CAAC;;qEAmB7C,CAAA;;;;;;;;4EAdA,CAHF;;;;;;;;;;;;;;CArBU,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,oBAAoB,CAAA;AAE3D,qBAAa,WAAW;IAeV,SAAS,CAAC,eAAe,EAAE,WAAW,EAAE;IAdpD,OAAO,CAAC,UAAU,CAAO;IACzB,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,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CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAQvD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAMjB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAQvD"}
|
package/dist/browser/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@ 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 });
|
|
7
6
|
var __export = (target, all) => {
|
|
8
7
|
for (var name in all)
|
|
9
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -37,7 +36,7 @@ var WasmFeatureDetectors = {
|
|
|
37
36
|
memory64: import_wasm_feature_detect.memory64,
|
|
38
37
|
multiValue: import_wasm_feature_detect.multiValue,
|
|
39
38
|
mutableGlobals: import_wasm_feature_detect.mutableGlobals,
|
|
40
|
-
referenceTypes:
|
|
39
|
+
referenceTypes: () => Promise,
|
|
41
40
|
relaxedSimd: import_wasm_feature_detect.relaxedSimd,
|
|
42
41
|
saturatedFloatToInt: import_wasm_feature_detect.saturatedFloatToInt,
|
|
43
42
|
signExtensions: import_wasm_feature_detect.signExtensions,
|
|
@@ -47,47 +46,38 @@ var WasmFeatureDetectors = {
|
|
|
47
46
|
threads: import_wasm_feature_detect.threads
|
|
48
47
|
};
|
|
49
48
|
var WasmSupport = class _WasmSupport {
|
|
50
|
-
static {
|
|
51
|
-
__name(this, "WasmSupport");
|
|
52
|
-
}
|
|
53
|
-
desiredFeatures;
|
|
54
|
-
_allowWasm;
|
|
55
|
-
_featureSupport;
|
|
56
|
-
_forceWasm;
|
|
57
|
-
_isInitialized;
|
|
58
|
-
_isWasmFeatureSetSupported;
|
|
59
49
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
+
*/
|
|
67
57
|
constructor(desiredFeatures) {
|
|
68
58
|
this.desiredFeatures = desiredFeatures;
|
|
69
|
-
this._allowWasm = true;
|
|
70
|
-
this._featureSupport = {};
|
|
71
|
-
this._forceWasm = false;
|
|
72
|
-
this._isInitialized = false;
|
|
73
|
-
this._isWasmFeatureSetSupported = false;
|
|
74
59
|
}
|
|
60
|
+
_allowWasm = true;
|
|
61
|
+
_featureSupport = {};
|
|
62
|
+
_forceWasm = false;
|
|
63
|
+
_isInitialized = false;
|
|
64
|
+
_isWasmFeatureSetSupported = false;
|
|
75
65
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
* Is Wasm allowed
|
|
67
|
+
*/
|
|
78
68
|
get allowWasm() {
|
|
79
69
|
return this._allowWasm;
|
|
80
70
|
}
|
|
81
71
|
/**
|
|
82
|
-
|
|
83
|
-
|
|
72
|
+
* Whether or not to allow WASM usage
|
|
73
|
+
*/
|
|
84
74
|
set allowWasm(v) {
|
|
85
75
|
this._allowWasm = v;
|
|
86
76
|
}
|
|
87
77
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
* Whether or not Wasm should be used based on the desired
|
|
79
|
+
* feature set, initialization state, or force-use settings
|
|
80
|
+
*/
|
|
91
81
|
get canUseWasm() {
|
|
92
82
|
return (
|
|
93
83
|
// Just force WASM
|
|
@@ -97,69 +87,66 @@ var WasmSupport = class _WasmSupport {
|
|
|
97
87
|
);
|
|
98
88
|
}
|
|
99
89
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
*/
|
|
103
93
|
get featureSupport() {
|
|
104
|
-
return {
|
|
105
|
-
...this._featureSupport
|
|
106
|
-
};
|
|
94
|
+
return { ...this._featureSupport };
|
|
107
95
|
}
|
|
108
96
|
/**
|
|
109
|
-
|
|
110
|
-
|
|
97
|
+
* Force use of Wasm
|
|
98
|
+
*/
|
|
111
99
|
get forceWasm() {
|
|
112
100
|
return this._forceWasm;
|
|
113
101
|
}
|
|
114
102
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
103
|
+
* Whether or not to force Wasm usage
|
|
104
|
+
*/
|
|
117
105
|
set forceWasm(v) {
|
|
118
106
|
this._forceWasm = v;
|
|
119
107
|
}
|
|
120
108
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
109
|
+
* Whether or not Wasm is supported based
|
|
110
|
+
* on the desired feature set
|
|
111
|
+
*/
|
|
124
112
|
get isDesiredFeatureSetSupported() {
|
|
125
113
|
return this._isWasmFeatureSetSupported;
|
|
126
114
|
}
|
|
127
115
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
116
|
+
* Whether or not Wasm detection has been run
|
|
117
|
+
* for the desired feature set
|
|
118
|
+
*/
|
|
131
119
|
get isInitialized() {
|
|
132
120
|
return this._isInitialized;
|
|
133
121
|
}
|
|
134
122
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
+
*/
|
|
141
129
|
static async create(desiredFeatures) {
|
|
142
130
|
const instance = new _WasmSupport(desiredFeatures);
|
|
143
131
|
await instance.initialize();
|
|
144
132
|
return instance;
|
|
145
133
|
}
|
|
146
134
|
/**
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
+
*/
|
|
151
139
|
async featureCheck(features) {
|
|
152
140
|
const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
|
|
153
141
|
return results.every(Boolean);
|
|
154
142
|
}
|
|
155
143
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
144
|
+
* Does feature detection for the desired feature set
|
|
145
|
+
*/
|
|
158
146
|
async initialize() {
|
|
159
147
|
if (this._isInitialized) return;
|
|
160
148
|
await this.detectDesiredFeatures();
|
|
161
149
|
this._isInitialized = true;
|
|
162
|
-
return;
|
|
163
150
|
}
|
|
164
151
|
async detectDesiredFeatures() {
|
|
165
152
|
for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport.js'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: () => Promise<boolean>,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return instance\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every(Boolean)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport.js'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: () => Promise<boolean>,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return instance\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every(Boolean)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iCAgBO;AAEA,IAAM,uBAAuB;AAAA,EAClC,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,gBAAgB,MAAM;AAAA,EACtB,aAAa;AAAA,EACb,qBAAqB;AAAA,EACrB,gBAAgB;AAAA,EAChB,MAAM;AAAA,EACN,sBAAsB;AAAA,EACtB,UAAU;AAAA,EACV,SAAS;AACX;AAIO,IAAM,cAAN,MAAM,aAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAevB,YAAsB,iBAAgC;AAAhC;AAAA,EAAiC;AAAA,EAd/C,aAAa;AAAA,EACb,kBAAyD,CAAC;AAAA,EAC1D,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,6BAA6B;AAAA;AAAA;AAAA;AAAA,EAerC,IAAI,YAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAU,GAAY;AACxB,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,aAAsB;AACxB;AAAA;AAAA,MAEE,KAAK;AAAA,MAEJ,KAAK,cAAc,CAAC,KAAK;AAAA,MAEzB,KAAK,cAAc,KAAK,kBAAkB,KAAK;AAAA;AAAA,EAEpD;AAAA;AAAA;AAAA;AAAA;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,eAAgB;AACzB,UAAM,KAAK,sBAAsB;AACjC,SAAK,iBAAiB;AAAA,EACxB;AAAA,EAEA,MAAgB,wBAAuC;AACrD,aAAS,UAAU,GAAG,UAAU,KAAK,gBAAgB,QAAQ,WAAW;AACtE,YAAM,iBAAiB,KAAK,gBAAgB,OAAO;AACnD,YAAM,WAAW,qBAAqB,cAAc;AACpD,WAAK,gBAAgB,cAAc,IAAK,MAAM,SAAS,IAAK,OAAO;AAAA,IACrE;AACA,SAAK,6BAA6B,OAAO,OAAO,KAAK,eAAe,EAAE,MAAM,OAAO;AAAA,EACrF;AACF;","names":[]}
|
package/dist/browser/index.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/WasmSupport.ts
|
|
5
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
bigInt,
|
|
4
|
+
bulkMemory,
|
|
5
|
+
exceptions,
|
|
6
|
+
extendedConst,
|
|
7
|
+
gc,
|
|
8
|
+
memory64,
|
|
9
|
+
multiValue,
|
|
10
|
+
mutableGlobals,
|
|
11
|
+
relaxedSimd,
|
|
12
|
+
saturatedFloatToInt,
|
|
13
|
+
signExtensions,
|
|
14
|
+
simd,
|
|
15
|
+
streamingCompilation,
|
|
16
|
+
tailCall,
|
|
17
|
+
threads
|
|
18
|
+
} from "wasm-feature-detect";
|
|
6
19
|
var WasmFeatureDetectors = {
|
|
7
20
|
bigInt,
|
|
8
21
|
bulkMemory,
|
|
@@ -12,7 +25,7 @@ var WasmFeatureDetectors = {
|
|
|
12
25
|
memory64,
|
|
13
26
|
multiValue,
|
|
14
27
|
mutableGlobals,
|
|
15
|
-
referenceTypes:
|
|
28
|
+
referenceTypes: () => Promise,
|
|
16
29
|
relaxedSimd,
|
|
17
30
|
saturatedFloatToInt,
|
|
18
31
|
signExtensions,
|
|
@@ -22,47 +35,38 @@ var WasmFeatureDetectors = {
|
|
|
22
35
|
threads
|
|
23
36
|
};
|
|
24
37
|
var WasmSupport = class _WasmSupport {
|
|
25
|
-
static {
|
|
26
|
-
__name(this, "WasmSupport");
|
|
27
|
-
}
|
|
28
|
-
desiredFeatures;
|
|
29
|
-
_allowWasm;
|
|
30
|
-
_featureSupport;
|
|
31
|
-
_forceWasm;
|
|
32
|
-
_isInitialized;
|
|
33
|
-
_isWasmFeatureSetSupported;
|
|
34
38
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
* Instance constructor for use where async instantiation
|
|
40
|
+
* is not possible. Where possible, prefer the static
|
|
41
|
+
* create method over use of this constructor directly
|
|
42
|
+
* as no initialization (feature detection) is able to
|
|
43
|
+
* be done here
|
|
44
|
+
* @param desiredFeatures The desired feature set
|
|
45
|
+
*/
|
|
42
46
|
constructor(desiredFeatures) {
|
|
43
47
|
this.desiredFeatures = desiredFeatures;
|
|
44
|
-
this._allowWasm = true;
|
|
45
|
-
this._featureSupport = {};
|
|
46
|
-
this._forceWasm = false;
|
|
47
|
-
this._isInitialized = false;
|
|
48
|
-
this._isWasmFeatureSetSupported = false;
|
|
49
48
|
}
|
|
49
|
+
_allowWasm = true;
|
|
50
|
+
_featureSupport = {};
|
|
51
|
+
_forceWasm = false;
|
|
52
|
+
_isInitialized = false;
|
|
53
|
+
_isWasmFeatureSetSupported = false;
|
|
50
54
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
* Is Wasm allowed
|
|
56
|
+
*/
|
|
53
57
|
get allowWasm() {
|
|
54
58
|
return this._allowWasm;
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
* Whether or not to allow WASM usage
|
|
62
|
+
*/
|
|
59
63
|
set allowWasm(v) {
|
|
60
64
|
this._allowWasm = v;
|
|
61
65
|
}
|
|
62
66
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
* Whether or not Wasm should be used based on the desired
|
|
68
|
+
* feature set, initialization state, or force-use settings
|
|
69
|
+
*/
|
|
66
70
|
get canUseWasm() {
|
|
67
71
|
return (
|
|
68
72
|
// Just force WASM
|
|
@@ -72,69 +76,66 @@ var WasmSupport = class _WasmSupport {
|
|
|
72
76
|
);
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
* Returns a object containing a property for each desired wasm feature
|
|
80
|
+
* with a boolean value indicating whether or not the feature is supported
|
|
81
|
+
*/
|
|
78
82
|
get featureSupport() {
|
|
79
|
-
return {
|
|
80
|
-
...this._featureSupport
|
|
81
|
-
};
|
|
83
|
+
return { ...this._featureSupport };
|
|
82
84
|
}
|
|
83
85
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
* Force use of Wasm
|
|
87
|
+
*/
|
|
86
88
|
get forceWasm() {
|
|
87
89
|
return this._forceWasm;
|
|
88
90
|
}
|
|
89
91
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
* Whether or not to force Wasm usage
|
|
93
|
+
*/
|
|
92
94
|
set forceWasm(v) {
|
|
93
95
|
this._forceWasm = v;
|
|
94
96
|
}
|
|
95
97
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
* Whether or not Wasm is supported based
|
|
99
|
+
* on the desired feature set
|
|
100
|
+
*/
|
|
99
101
|
get isDesiredFeatureSetSupported() {
|
|
100
102
|
return this._isWasmFeatureSetSupported;
|
|
101
103
|
}
|
|
102
104
|
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
* Whether or not Wasm detection has been run
|
|
106
|
+
* for the desired feature set
|
|
107
|
+
*/
|
|
106
108
|
get isInitialized() {
|
|
107
109
|
return this._isInitialized;
|
|
108
110
|
}
|
|
109
111
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
* Static creation & async initialization for use where
|
|
113
|
+
* async instantiation is possible
|
|
114
|
+
* @param desiredFeatures The desired feature set
|
|
115
|
+
* @returns An initialized instance of the class with detection
|
|
116
|
+
* for the desired feature set
|
|
117
|
+
*/
|
|
116
118
|
static async create(desiredFeatures) {
|
|
117
119
|
const instance = new _WasmSupport(desiredFeatures);
|
|
118
120
|
await instance.initialize();
|
|
119
121
|
return instance;
|
|
120
122
|
}
|
|
121
123
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
* Checks for specific wasm features
|
|
125
|
+
* @param features The list of features to check for
|
|
126
|
+
* @returns True if all the features are supported, false otherwise
|
|
127
|
+
*/
|
|
126
128
|
async featureCheck(features) {
|
|
127
129
|
const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
|
|
128
130
|
return results.every(Boolean);
|
|
129
131
|
}
|
|
130
132
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
* Does feature detection for the desired feature set
|
|
134
|
+
*/
|
|
133
135
|
async initialize() {
|
|
134
136
|
if (this._isInitialized) return;
|
|
135
137
|
await this.detectDesiredFeatures();
|
|
136
138
|
this._isInitialized = true;
|
|
137
|
-
return;
|
|
138
139
|
}
|
|
139
140
|
async detectDesiredFeatures() {
|
|
140
141
|
for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
|
|
@@ -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 * 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
|
|
1
|
+
{"version":3,"sources":["../../src/WasmSupport.ts"],"sourcesContent":["import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: () => Promise<boolean>,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return instance\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every(Boolean)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,uBAA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