@xyo-network/wasm 2.110.9 → 2.110.11
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
package/dist/node/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,
|
|
@@ -46,45 +45,39 @@ var WasmFeatureDetectors = {
|
|
|
46
45
|
tailCall: import_wasm_feature_detect.tailCall,
|
|
47
46
|
threads: import_wasm_feature_detect.threads
|
|
48
47
|
};
|
|
49
|
-
var
|
|
50
|
-
desiredFeatures;
|
|
51
|
-
_allowWasm;
|
|
52
|
-
_featureSupport;
|
|
53
|
-
_forceWasm;
|
|
54
|
-
_isInitialized;
|
|
55
|
-
_isWasmFeatureSetSupported;
|
|
48
|
+
var WasmSupport = class _WasmSupport {
|
|
56
49
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
*/
|
|
64
57
|
constructor(desiredFeatures) {
|
|
65
58
|
this.desiredFeatures = desiredFeatures;
|
|
66
|
-
this._allowWasm = true;
|
|
67
|
-
this._featureSupport = {};
|
|
68
|
-
this._forceWasm = false;
|
|
69
|
-
this._isInitialized = false;
|
|
70
|
-
this._isWasmFeatureSetSupported = false;
|
|
71
59
|
}
|
|
60
|
+
_allowWasm = true;
|
|
61
|
+
_featureSupport = {};
|
|
62
|
+
_forceWasm = false;
|
|
63
|
+
_isInitialized = false;
|
|
64
|
+
_isWasmFeatureSetSupported = false;
|
|
72
65
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
* Is Wasm allowed
|
|
67
|
+
*/
|
|
75
68
|
get allowWasm() {
|
|
76
69
|
return this._allowWasm;
|
|
77
70
|
}
|
|
78
71
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
* Whether or not to allow WASM usage
|
|
73
|
+
*/
|
|
81
74
|
set allowWasm(v) {
|
|
82
75
|
this._allowWasm = v;
|
|
83
76
|
}
|
|
84
77
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
* Whether or not Wasm should be used based on the desired
|
|
79
|
+
* feature set, initialization state, or force-use settings
|
|
80
|
+
*/
|
|
88
81
|
get canUseWasm() {
|
|
89
82
|
return (
|
|
90
83
|
// Just force WASM
|
|
@@ -94,69 +87,66 @@ var _WasmSupport = class _WasmSupport {
|
|
|
94
87
|
);
|
|
95
88
|
}
|
|
96
89
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
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
93
|
get featureSupport() {
|
|
101
|
-
return {
|
|
102
|
-
...this._featureSupport
|
|
103
|
-
};
|
|
94
|
+
return { ...this._featureSupport };
|
|
104
95
|
}
|
|
105
96
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
* Force use of Wasm
|
|
98
|
+
*/
|
|
108
99
|
get forceWasm() {
|
|
109
100
|
return this._forceWasm;
|
|
110
101
|
}
|
|
111
102
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
103
|
+
* Whether or not to force Wasm usage
|
|
104
|
+
*/
|
|
114
105
|
set forceWasm(v) {
|
|
115
106
|
this._forceWasm = v;
|
|
116
107
|
}
|
|
117
108
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
109
|
+
* Whether or not Wasm is supported based
|
|
110
|
+
* on the desired feature set
|
|
111
|
+
*/
|
|
121
112
|
get isDesiredFeatureSetSupported() {
|
|
122
113
|
return this._isWasmFeatureSetSupported;
|
|
123
114
|
}
|
|
124
115
|
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
* Whether or not Wasm detection has been run
|
|
117
|
+
* for the desired feature set
|
|
118
|
+
*/
|
|
128
119
|
get isInitialized() {
|
|
129
120
|
return this._isInitialized;
|
|
130
121
|
}
|
|
131
122
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
+
*/
|
|
138
129
|
static async create(desiredFeatures) {
|
|
139
130
|
const instance = new _WasmSupport(desiredFeatures);
|
|
140
131
|
await instance.initialize();
|
|
141
132
|
return instance;
|
|
142
133
|
}
|
|
143
134
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
+
*/
|
|
148
139
|
async featureCheck(features) {
|
|
149
140
|
const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
|
|
150
141
|
return results.every(Boolean);
|
|
151
142
|
}
|
|
152
143
|
/**
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
* Does feature detection for the desired feature set
|
|
145
|
+
*/
|
|
155
146
|
async initialize() {
|
|
156
147
|
if (this._isInitialized) return;
|
|
157
148
|
await this.detectDesiredFeatures();
|
|
158
149
|
this._isInitialized = true;
|
|
159
|
-
return;
|
|
160
150
|
}
|
|
161
151
|
async detectDesiredFeatures() {
|
|
162
152
|
for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
|
|
@@ -167,8 +157,6 @@ var _WasmSupport = class _WasmSupport {
|
|
|
167
157
|
this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
|
|
168
158
|
}
|
|
169
159
|
};
|
|
170
|
-
__name(_WasmSupport, "WasmSupport");
|
|
171
|
-
var WasmSupport = _WasmSupport;
|
|
172
160
|
// Annotate the CommonJS export names for ESM import in node:
|
|
173
161
|
0 && (module.exports = {
|
|
174
162
|
WasmFeatureDetectors,
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -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,EA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AAe;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/node/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,
|
|
@@ -21,45 +34,39 @@ var WasmFeatureDetectors = {
|
|
|
21
34
|
tailCall,
|
|
22
35
|
threads
|
|
23
36
|
};
|
|
24
|
-
var
|
|
25
|
-
desiredFeatures;
|
|
26
|
-
_allowWasm;
|
|
27
|
-
_featureSupport;
|
|
28
|
-
_forceWasm;
|
|
29
|
-
_isInitialized;
|
|
30
|
-
_isWasmFeatureSetSupported;
|
|
37
|
+
var WasmSupport = class _WasmSupport {
|
|
31
38
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
*/
|
|
39
46
|
constructor(desiredFeatures) {
|
|
40
47
|
this.desiredFeatures = desiredFeatures;
|
|
41
|
-
this._allowWasm = true;
|
|
42
|
-
this._featureSupport = {};
|
|
43
|
-
this._forceWasm = false;
|
|
44
|
-
this._isInitialized = false;
|
|
45
|
-
this._isWasmFeatureSetSupported = false;
|
|
46
48
|
}
|
|
49
|
+
_allowWasm = true;
|
|
50
|
+
_featureSupport = {};
|
|
51
|
+
_forceWasm = false;
|
|
52
|
+
_isInitialized = false;
|
|
53
|
+
_isWasmFeatureSetSupported = false;
|
|
47
54
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
* Is Wasm allowed
|
|
56
|
+
*/
|
|
50
57
|
get allowWasm() {
|
|
51
58
|
return this._allowWasm;
|
|
52
59
|
}
|
|
53
60
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
* Whether or not to allow WASM usage
|
|
62
|
+
*/
|
|
56
63
|
set allowWasm(v) {
|
|
57
64
|
this._allowWasm = v;
|
|
58
65
|
}
|
|
59
66
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
* Whether or not Wasm should be used based on the desired
|
|
68
|
+
* feature set, initialization state, or force-use settings
|
|
69
|
+
*/
|
|
63
70
|
get canUseWasm() {
|
|
64
71
|
return (
|
|
65
72
|
// Just force WASM
|
|
@@ -69,69 +76,66 @@ var _WasmSupport = class _WasmSupport {
|
|
|
69
76
|
);
|
|
70
77
|
}
|
|
71
78
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
*/
|
|
75
82
|
get featureSupport() {
|
|
76
|
-
return {
|
|
77
|
-
...this._featureSupport
|
|
78
|
-
};
|
|
83
|
+
return { ...this._featureSupport };
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
* Force use of Wasm
|
|
87
|
+
*/
|
|
83
88
|
get forceWasm() {
|
|
84
89
|
return this._forceWasm;
|
|
85
90
|
}
|
|
86
91
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
* Whether or not to force Wasm usage
|
|
93
|
+
*/
|
|
89
94
|
set forceWasm(v) {
|
|
90
95
|
this._forceWasm = v;
|
|
91
96
|
}
|
|
92
97
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
* Whether or not Wasm is supported based
|
|
99
|
+
* on the desired feature set
|
|
100
|
+
*/
|
|
96
101
|
get isDesiredFeatureSetSupported() {
|
|
97
102
|
return this._isWasmFeatureSetSupported;
|
|
98
103
|
}
|
|
99
104
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
* Whether or not Wasm detection has been run
|
|
106
|
+
* for the desired feature set
|
|
107
|
+
*/
|
|
103
108
|
get isInitialized() {
|
|
104
109
|
return this._isInitialized;
|
|
105
110
|
}
|
|
106
111
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
*/
|
|
113
118
|
static async create(desiredFeatures) {
|
|
114
119
|
const instance = new _WasmSupport(desiredFeatures);
|
|
115
120
|
await instance.initialize();
|
|
116
121
|
return instance;
|
|
117
122
|
}
|
|
118
123
|
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
+
*/
|
|
123
128
|
async featureCheck(features) {
|
|
124
129
|
const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
|
|
125
130
|
return results.every(Boolean);
|
|
126
131
|
}
|
|
127
132
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
* Does feature detection for the desired feature set
|
|
134
|
+
*/
|
|
130
135
|
async initialize() {
|
|
131
136
|
if (this._isInitialized) return;
|
|
132
137
|
await this.detectDesiredFeatures();
|
|
133
138
|
this._isInitialized = true;
|
|
134
|
-
return;
|
|
135
139
|
}
|
|
136
140
|
async detectDesiredFeatures() {
|
|
137
141
|
for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
|
|
@@ -142,8 +146,6 @@ var _WasmSupport = class _WasmSupport {
|
|
|
142
146
|
this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
|
|
143
147
|
}
|
|
144
148
|
};
|
|
145
|
-
__name(_WasmSupport, "WasmSupport");
|
|
146
|
-
var WasmSupport = _WasmSupport;
|
|
147
149
|
export {
|
|
148
150
|
WasmFeatureDetectors,
|
|
149
151
|
WasmSupport
|
package/dist/node/index.js.map
CHANGED
|
@@ -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,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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AW;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/package.json
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
18
|
-
"@xylabs/tsconfig": "^3.
|
|
17
|
+
"@xylabs/ts-scripts-yarn3": "^3.13.3",
|
|
18
|
+
"@xylabs/tsconfig": "^3.13.3",
|
|
19
19
|
"typescript": "^5.5.4"
|
|
20
20
|
},
|
|
21
21
|
"exports": {
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
57
57
|
},
|
|
58
58
|
"sideEffects": false,
|
|
59
|
-
"version": "2.110.
|
|
59
|
+
"version": "2.110.11",
|
|
60
60
|
"type": "module"
|
|
61
61
|
}
|