@xyo-network/wasm 2.107.1 → 2.107.4

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.
@@ -1,2 +1,173 @@
1
- "use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(s,t)=>o(s,"name",{value:t,configurable:!0});var p=(s,t)=>{for(var a in t)o(s,a,{get:t[a],enumerable:!0})},h=(s,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of d(t))!c.call(s,r)&&r!==a&&o(s,r,{get:()=>t[r],enumerable:!(i=m(t,r))||i.enumerable});return s};var _=s=>h(o({},"__esModule",{value:!0}),s);var f={};p(f,{WasmFeatureDetectors:()=>l,WasmSupport:()=>n});module.exports=_(f);var e=require("wasm-feature-detect");var l={bigInt:e.bigInt,bulkMemory:e.bulkMemory,exceptions:e.exceptions,extendedConst:e.extendedConst,gc:e.gc,memory64:e.memory64,multiValue:e.multiValue,mutableGlobals:e.mutableGlobals,referenceTypes:e.referenceTypes,relaxedSimd:e.relaxedSimd,saturatedFloatToInt:e.saturatedFloatToInt,signExtensions:e.signExtensions,simd:e.simd,streamingCompilation:e.streamingCompilation,tailCall:e.tailCall,threads:e.threads},n=class s{static{u(this,"WasmSupport")}desiredFeatures;_allowWasm;_featureSupport;_forceWasm;_isInitialized;_isWasmFeatureSetSupported;constructor(t){this.desiredFeatures=t,this._allowWasm=!0,this._featureSupport={},this._forceWasm=!1,this._isInitialized=!1,this._isWasmFeatureSetSupported=!1}get allowWasm(){return this._allowWasm}set allowWasm(t){this._allowWasm=t}get canUseWasm(){return this._forceWasm||this._allowWasm&&!this._isInitialized||this._allowWasm&&this._isInitialized&&this._isWasmFeatureSetSupported}get featureSupport(){return{...this._featureSupport}}get forceWasm(){return this._forceWasm}set forceWasm(t){this._forceWasm=t}get isDesiredFeatureSetSupported(){return this._isWasmFeatureSetSupported}get isInitialized(){return this._isInitialized}static async create(t){let a=new s(t);return await a.initialize(),a}async featureCheck(t){return(await Promise.all(t.map(i=>l[i]).map(async i=>await i()))).every(Boolean)}async initialize(){this._isInitialized||(await this.detectDesiredFeatures(),this._isInitialized=!0)}async detectDesiredFeatures(){for(let t=0;t<this.desiredFeatures.length;t++){let a=this.desiredFeatures[t],i=l[a];this._featureSupport[a]=!!await i()}this._isWasmFeatureSetSupported=Object.values(this._featureSupport).every(Boolean)}};
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ WasmFeatureDetectors: () => WasmFeatureDetectors,
25
+ WasmSupport: () => WasmSupport
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/WasmSupport.ts
30
+ var import_wasm_feature_detect = require("wasm-feature-detect");
31
+ var WasmFeatureDetectors = {
32
+ bigInt: import_wasm_feature_detect.bigInt,
33
+ bulkMemory: import_wasm_feature_detect.bulkMemory,
34
+ exceptions: import_wasm_feature_detect.exceptions,
35
+ extendedConst: import_wasm_feature_detect.extendedConst,
36
+ gc: import_wasm_feature_detect.gc,
37
+ memory64: import_wasm_feature_detect.memory64,
38
+ multiValue: import_wasm_feature_detect.multiValue,
39
+ mutableGlobals: import_wasm_feature_detect.mutableGlobals,
40
+ referenceTypes: import_wasm_feature_detect.referenceTypes,
41
+ relaxedSimd: import_wasm_feature_detect.relaxedSimd,
42
+ saturatedFloatToInt: import_wasm_feature_detect.saturatedFloatToInt,
43
+ signExtensions: import_wasm_feature_detect.signExtensions,
44
+ simd: import_wasm_feature_detect.simd,
45
+ streamingCompilation: import_wasm_feature_detect.streamingCompilation,
46
+ tailCall: import_wasm_feature_detect.tailCall,
47
+ threads: import_wasm_feature_detect.threads
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;
59
+ /**
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
+ */
67
+ constructor(desiredFeatures) {
68
+ this.desiredFeatures = desiredFeatures;
69
+ this._allowWasm = true;
70
+ this._featureSupport = {};
71
+ this._forceWasm = false;
72
+ this._isInitialized = false;
73
+ this._isWasmFeatureSetSupported = false;
74
+ }
75
+ /**
76
+ * Is Wasm allowed
77
+ */
78
+ get allowWasm() {
79
+ return this._allowWasm;
80
+ }
81
+ /**
82
+ * Whether or not to allow WASM usage
83
+ */
84
+ set allowWasm(v) {
85
+ this._allowWasm = v;
86
+ }
87
+ /**
88
+ * Whether or not Wasm should be used based on the desired
89
+ * feature set, initialization state, or force-use settings
90
+ */
91
+ get canUseWasm() {
92
+ return (
93
+ // Just force WASM
94
+ this._forceWasm || // Or if we haven't checked be optimistic
95
+ this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
96
+ this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
97
+ );
98
+ }
99
+ /**
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
+ */
103
+ get featureSupport() {
104
+ return {
105
+ ...this._featureSupport
106
+ };
107
+ }
108
+ /**
109
+ * Force use of Wasm
110
+ */
111
+ get forceWasm() {
112
+ return this._forceWasm;
113
+ }
114
+ /**
115
+ * Whether or not to force Wasm usage
116
+ */
117
+ set forceWasm(v) {
118
+ this._forceWasm = v;
119
+ }
120
+ /**
121
+ * Whether or not Wasm is supported based
122
+ * on the desired feature set
123
+ */
124
+ get isDesiredFeatureSetSupported() {
125
+ return this._isWasmFeatureSetSupported;
126
+ }
127
+ /**
128
+ * Whether or not Wasm detection has been run
129
+ * for the desired feature set
130
+ */
131
+ get isInitialized() {
132
+ return this._isInitialized;
133
+ }
134
+ /**
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
+ */
141
+ static async create(desiredFeatures) {
142
+ const instance = new _WasmSupport(desiredFeatures);
143
+ await instance.initialize();
144
+ return instance;
145
+ }
146
+ /**
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
+ */
151
+ async featureCheck(features) {
152
+ const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
153
+ return results.every(Boolean);
154
+ }
155
+ /**
156
+ * Does feature detection for the desired feature set
157
+ */
158
+ async initialize() {
159
+ if (this._isInitialized) return;
160
+ await this.detectDesiredFeatures();
161
+ this._isInitialized = true;
162
+ return;
163
+ }
164
+ async detectDesiredFeatures() {
165
+ for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
166
+ const desiredFeature = this.desiredFeatures[feature];
167
+ const detector = WasmFeatureDetectors[desiredFeature];
168
+ this._featureSupport[desiredFeature] = await detector() ? true : false;
169
+ }
170
+ this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
171
+ }
172
+ };
2
173
  //# sourceMappingURL=index.cjs.map
@@ -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":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,gBAAAC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AAa,MAAMA,EAAAA,CAAAA,CAAAA,GAC1GC,MAAMC,OAAAA,CACvB,CAKA,MAAMT,YAA4B,CAC5B,KAAKb,iBACT,MAAM,KAAKuB,sBAAqB,EAChC,KAAKvB,eAAiB,GAExB,CAEA,MAAgBuB,uBAAuC,CACrD,QAASJ,EAAU,EAAGA,EAAU,KAAKhB,gBAAgBqB,OAAQL,IAAW,CACtE,IAAMM,EAAiB,KAAKtB,gBAAgBgB,CAAAA,EACtCC,EAAWzC,EAAqB8C,CAAAA,EACtC,KAAK3B,gBAAgB2B,CAAAA,EAAmB,QAAML,EAAAA,CAChD,CACA,KAAKnB,2BAA6ByB,OAAOC,OAAO,KAAK7B,eAAe,EAAEuB,MAAMC,OAAAA,CAC9E,CACF","names":["src_exports","__export","WasmFeatureDetectors","WasmSupport","__toCommonJS","import_wasm_feature_detect","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","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n referenceTypes,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: referenceTypes,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return instance\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every(Boolean)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n return\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACAA,iCAiBO;AAEA,IAAMA,uBAAuB;EAClCC,QAAQA;EACRC,YAAYA;EACZC,YAAYA;EACZC,eAAeA;EACfC,IAAIA;EACJC,UAAUA;EACVC,YAAYA;EACZC,gBAAgBA;EAChBC,gBAAgBA;EAChBC,aAAaA;EACbC,qBAAqBA;EACrBC,gBAAgBA;EAChBC,MAAMA;EACNC,sBAAsBA;EACtBC,UAAUA;EACVC,SAASA;AACX;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAxCb,OAwCaA;;;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BA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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,2 +1,152 @@
1
- var l=Object.defineProperty;var i=(a,e)=>l(a,"name",{value:e,configurable:!0});import{bigInt as n,bulkMemory as u,exceptions as m,extendedConst as d,gc as c,memory64 as p,multiValue as h,mutableGlobals as _,referenceTypes as f,relaxedSimd as W,saturatedFloatToInt as S,signExtensions as F,simd as g,streamingCompilation as w,tailCall as y,threads as I}from"wasm-feature-detect";var r={bigInt:n,bulkMemory:u,exceptions:m,extendedConst:d,gc:c,memory64:p,multiValue:h,mutableGlobals:_,referenceTypes:f,relaxedSimd:W,saturatedFloatToInt:S,signExtensions:F,simd:g,streamingCompilation:w,tailCall:y,threads:I},o=class a{static{i(this,"WasmSupport")}desiredFeatures;_allowWasm;_featureSupport;_forceWasm;_isInitialized;_isWasmFeatureSetSupported;constructor(e){this.desiredFeatures=e,this._allowWasm=!0,this._featureSupport={},this._forceWasm=!1,this._isInitialized=!1,this._isWasmFeatureSetSupported=!1}get allowWasm(){return this._allowWasm}set allowWasm(e){this._allowWasm=e}get canUseWasm(){return this._forceWasm||this._allowWasm&&!this._isInitialized||this._allowWasm&&this._isInitialized&&this._isWasmFeatureSetSupported}get featureSupport(){return{...this._featureSupport}}get forceWasm(){return this._forceWasm}set forceWasm(e){this._forceWasm=e}get isDesiredFeatureSetSupported(){return this._isWasmFeatureSetSupported}get isInitialized(){return this._isInitialized}static async create(e){let t=new a(e);return await t.initialize(),t}async featureCheck(e){return(await Promise.all(e.map(s=>r[s]).map(async s=>await s()))).every(Boolean)}async initialize(){this._isInitialized||(await this.detectDesiredFeatures(),this._isInitialized=!0)}async detectDesiredFeatures(){for(let e=0;e<this.desiredFeatures.length;e++){let t=this.desiredFeatures[e],s=r[t];this._featureSupport[t]=!!await s()}this._isWasmFeatureSetSupported=Object.values(this._featureSupport).every(Boolean)}};export{r as WasmFeatureDetectors,o as WasmSupport};
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/WasmSupport.ts
5
+ import { bigInt, bulkMemory, exceptions, extendedConst, gc, memory64, multiValue, mutableGlobals, referenceTypes, relaxedSimd, saturatedFloatToInt, signExtensions, simd, streamingCompilation, tailCall, threads } from "wasm-feature-detect";
6
+ var WasmFeatureDetectors = {
7
+ bigInt,
8
+ bulkMemory,
9
+ exceptions,
10
+ extendedConst,
11
+ gc,
12
+ memory64,
13
+ multiValue,
14
+ mutableGlobals,
15
+ referenceTypes,
16
+ relaxedSimd,
17
+ saturatedFloatToInt,
18
+ signExtensions,
19
+ simd,
20
+ streamingCompilation,
21
+ tailCall,
22
+ threads
23
+ };
24
+ var WasmSupport = class _WasmSupport {
25
+ static {
26
+ __name(this, "WasmSupport");
27
+ }
28
+ desiredFeatures;
29
+ _allowWasm;
30
+ _featureSupport;
31
+ _forceWasm;
32
+ _isInitialized;
33
+ _isWasmFeatureSetSupported;
34
+ /**
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
+ */
42
+ constructor(desiredFeatures) {
43
+ this.desiredFeatures = desiredFeatures;
44
+ this._allowWasm = true;
45
+ this._featureSupport = {};
46
+ this._forceWasm = false;
47
+ this._isInitialized = false;
48
+ this._isWasmFeatureSetSupported = false;
49
+ }
50
+ /**
51
+ * Is Wasm allowed
52
+ */
53
+ get allowWasm() {
54
+ return this._allowWasm;
55
+ }
56
+ /**
57
+ * Whether or not to allow WASM usage
58
+ */
59
+ set allowWasm(v) {
60
+ this._allowWasm = v;
61
+ }
62
+ /**
63
+ * Whether or not Wasm should be used based on the desired
64
+ * feature set, initialization state, or force-use settings
65
+ */
66
+ get canUseWasm() {
67
+ return (
68
+ // Just force WASM
69
+ this._forceWasm || // Or if we haven't checked be optimistic
70
+ this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
71
+ this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
72
+ );
73
+ }
74
+ /**
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
+ */
78
+ get featureSupport() {
79
+ return {
80
+ ...this._featureSupport
81
+ };
82
+ }
83
+ /**
84
+ * Force use of Wasm
85
+ */
86
+ get forceWasm() {
87
+ return this._forceWasm;
88
+ }
89
+ /**
90
+ * Whether or not to force Wasm usage
91
+ */
92
+ set forceWasm(v) {
93
+ this._forceWasm = v;
94
+ }
95
+ /**
96
+ * Whether or not Wasm is supported based
97
+ * on the desired feature set
98
+ */
99
+ get isDesiredFeatureSetSupported() {
100
+ return this._isWasmFeatureSetSupported;
101
+ }
102
+ /**
103
+ * Whether or not Wasm detection has been run
104
+ * for the desired feature set
105
+ */
106
+ get isInitialized() {
107
+ return this._isInitialized;
108
+ }
109
+ /**
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
+ */
116
+ static async create(desiredFeatures) {
117
+ const instance = new _WasmSupport(desiredFeatures);
118
+ await instance.initialize();
119
+ return instance;
120
+ }
121
+ /**
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
+ */
126
+ async featureCheck(features) {
127
+ const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
128
+ return results.every(Boolean);
129
+ }
130
+ /**
131
+ * Does feature detection for the desired feature set
132
+ */
133
+ async initialize() {
134
+ if (this._isInitialized) return;
135
+ await this.detectDesiredFeatures();
136
+ this._isInitialized = true;
137
+ return;
138
+ }
139
+ async detectDesiredFeatures() {
140
+ for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
141
+ const desiredFeature = this.desiredFeatures[feature];
142
+ const detector = WasmFeatureDetectors[desiredFeature];
143
+ this._featureSupport[desiredFeature] = await detector() ? true : false;
144
+ }
145
+ this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
146
+ }
147
+ };
148
+ export {
149
+ WasmFeatureDetectors,
150
+ WasmSupport
151
+ };
2
152
  //# sourceMappingURL=index.js.map
@@ -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":"+EAAA,OACEA,UAAAA,EACAC,cAAAA,EACAC,cAAAA,EACAC,iBAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,cAAAA,EACAC,kBAAAA,EACAC,kBAAAA,EACAC,eAAAA,EACAC,uBAAAA,EACAC,kBAAAA,EACAC,QAAAA,EACAC,wBAAAA,EACAC,YAAAA,EACAC,WAAAA,MACK,sBAEA,IAAMC,EAAuB,CAClCC,OAAQA,EACRC,WAAYA,EACZC,WAAYA,EACZC,cAAeA,EACfC,GAAIA,EACJC,SAAUA,EACVC,WAAYA,EACZC,eAAgBA,EAChBC,eAAgBA,EAChBC,YAAaA,EACbC,oBAAqBA,EACrBC,eAAgBA,EAChBC,KAAMA,EACNC,qBAAsBA,EACtBC,SAAUA,EACVC,QAASA,CACX,EAIaC,EAAN,MAAMA,CAAAA,CAxCb,MAwCaA,CAAAA,EAAAA,oCACHC,WACAC,gBACAC,WACAC,eACAC,2BAURC,YAAsBC,EAAgC,MAAhCA,gBAAAA,OAddN,WAAa,QACbC,gBAAyD,CAAC,OAC1DC,WAAa,QACbC,eAAiB,QACjBC,2BAA6B,EAUkB,CAKvD,IAAIG,WAAqB,CACvB,OAAO,KAAKP,UACd,CAIA,IAAIO,UAAUC,EAAY,CACxB,KAAKR,WAAaQ,CACpB,CAMA,IAAIC,YAAsB,CACxB,OAEE,KAAKP,YAEJ,KAAKF,YAAc,CAAC,KAAKG,gBAEzB,KAAKH,YAAc,KAAKG,gBAAkB,KAAKC,0BAEpD,CAMA,IAAIM,gBAAkE,CACpE,MAAO,CAAE,GAAG,KAAKT,eAAgB,CACnC,CAKA,IAAIU,WAAqB,CACvB,OAAO,KAAKT,UACd,CAIA,IAAIS,UAAUH,EAAY,CACxB,KAAKN,WAAaM,CACpB,CAMA,IAAII,8BAAwC,CAC1C,OAAO,KAAKR,0BACd,CAMA,IAAIS,eAAyB,CAC3B,OAAO,KAAKV,cACd,CASA,aAAaW,OAAOR,EAAsD,CACxE,IAAMS,EAAW,IAAIhB,EAAYO,CAAAA,EACjC,aAAMS,EAASC,WAAU,EAClBD,CACT,CAOA,MAAME,aAAaC,EAA2C,CAE5D,OADgB,MAAMC,QAAQC,IAAIF,EAASG,IAAKC,GAAYxC,EAAqBwC,CAAAA,CAAQ,EAAED,IAAI,MAAOE,GAAa,MAAMA,EAAAA,CAAAA,CAAAA,GAC1GC,MAAMC,OAAAA,CACvB,CAKA,MAAMT,YAA4B,CAC5B,KAAKb,iBACT,MAAM,KAAKuB,sBAAqB,EAChC,KAAKvB,eAAiB,GAExB,CAEA,MAAgBuB,uBAAuC,CACrD,QAASJ,EAAU,EAAGA,EAAU,KAAKhB,gBAAgBqB,OAAQL,IAAW,CACtE,IAAMM,EAAiB,KAAKtB,gBAAgBgB,CAAAA,EACtCC,EAAWzC,EAAqB8C,CAAAA,EACtC,KAAK3B,gBAAgB2B,CAAAA,EAAmB,QAAML,EAAAA,CAChD,CACA,KAAKnB,2BAA6ByB,OAAOC,OAAO,KAAK7B,eAAe,EAAEuB,MAAMC,OAAAA,CAC9E,CACF","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","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
1
+ {"version":3,"sources":["../../src/WasmSupport.ts"],"sourcesContent":["import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n referenceTypes,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: referenceTypes,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return instance\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every(Boolean)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n return\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;AAAA,SACEA,QACAC,YACAC,YACAC,eACAC,IACAC,UACAC,YACAC,gBACAC,gBACAC,aACAC,qBACAC,gBACAC,MACAC,sBACAC,UACAC,eACK;AAEA,IAAMC,uBAAuB;EAClCC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;AACF;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAxCb,OAwCaA;;;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb,eAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
@@ -1,2 +1,173 @@
1
- "use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(s,t)=>o(s,"name",{value:t,configurable:!0});var p=(s,t)=>{for(var a in t)o(s,a,{get:t[a],enumerable:!0})},h=(s,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of d(t))!c.call(s,r)&&r!==a&&o(s,r,{get:()=>t[r],enumerable:!(i=m(t,r))||i.enumerable});return s};var _=s=>h(o({},"__esModule",{value:!0}),s);var f={};p(f,{WasmFeatureDetectors:()=>l,WasmSupport:()=>n});module.exports=_(f);var e=require("wasm-feature-detect");var l={bigInt:e.bigInt,bulkMemory:e.bulkMemory,exceptions:e.exceptions,extendedConst:e.extendedConst,gc:e.gc,memory64:e.memory64,multiValue:e.multiValue,mutableGlobals:e.mutableGlobals,referenceTypes:e.referenceTypes,relaxedSimd:e.relaxedSimd,saturatedFloatToInt:e.saturatedFloatToInt,signExtensions:e.signExtensions,simd:e.simd,streamingCompilation:e.streamingCompilation,tailCall:e.tailCall,threads:e.threads},n=class s{static{u(this,"WasmSupport")}desiredFeatures;_allowWasm;_featureSupport;_forceWasm;_isInitialized;_isWasmFeatureSetSupported;constructor(t){this.desiredFeatures=t,this._allowWasm=!0,this._featureSupport={},this._forceWasm=!1,this._isInitialized=!1,this._isWasmFeatureSetSupported=!1}get allowWasm(){return this._allowWasm}set allowWasm(t){this._allowWasm=t}get canUseWasm(){return this._forceWasm||this._allowWasm&&!this._isInitialized||this._allowWasm&&this._isInitialized&&this._isWasmFeatureSetSupported}get featureSupport(){return{...this._featureSupport}}get forceWasm(){return this._forceWasm}set forceWasm(t){this._forceWasm=t}get isDesiredFeatureSetSupported(){return this._isWasmFeatureSetSupported}get isInitialized(){return this._isInitialized}static async create(t){let a=new s(t);return await a.initialize(),a}async featureCheck(t){return(await Promise.all(t.map(i=>l[i]).map(async i=>await i()))).every(Boolean)}async initialize(){this._isInitialized||(await this.detectDesiredFeatures(),this._isInitialized=!0)}async detectDesiredFeatures(){for(let t=0;t<this.desiredFeatures.length;t++){let a=this.desiredFeatures[t],i=l[a];this._featureSupport[a]=!!await i()}this._isWasmFeatureSetSupported=Object.values(this._featureSupport).every(Boolean)}};
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ WasmFeatureDetectors: () => WasmFeatureDetectors,
25
+ WasmSupport: () => WasmSupport
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/WasmSupport.ts
30
+ var import_wasm_feature_detect = require("wasm-feature-detect");
31
+ var WasmFeatureDetectors = {
32
+ bigInt: import_wasm_feature_detect.bigInt,
33
+ bulkMemory: import_wasm_feature_detect.bulkMemory,
34
+ exceptions: import_wasm_feature_detect.exceptions,
35
+ extendedConst: import_wasm_feature_detect.extendedConst,
36
+ gc: import_wasm_feature_detect.gc,
37
+ memory64: import_wasm_feature_detect.memory64,
38
+ multiValue: import_wasm_feature_detect.multiValue,
39
+ mutableGlobals: import_wasm_feature_detect.mutableGlobals,
40
+ referenceTypes: import_wasm_feature_detect.referenceTypes,
41
+ relaxedSimd: import_wasm_feature_detect.relaxedSimd,
42
+ saturatedFloatToInt: import_wasm_feature_detect.saturatedFloatToInt,
43
+ signExtensions: import_wasm_feature_detect.signExtensions,
44
+ simd: import_wasm_feature_detect.simd,
45
+ streamingCompilation: import_wasm_feature_detect.streamingCompilation,
46
+ tailCall: import_wasm_feature_detect.tailCall,
47
+ threads: import_wasm_feature_detect.threads
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;
59
+ /**
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
+ */
67
+ constructor(desiredFeatures) {
68
+ this.desiredFeatures = desiredFeatures;
69
+ this._allowWasm = true;
70
+ this._featureSupport = {};
71
+ this._forceWasm = false;
72
+ this._isInitialized = false;
73
+ this._isWasmFeatureSetSupported = false;
74
+ }
75
+ /**
76
+ * Is Wasm allowed
77
+ */
78
+ get allowWasm() {
79
+ return this._allowWasm;
80
+ }
81
+ /**
82
+ * Whether or not to allow WASM usage
83
+ */
84
+ set allowWasm(v) {
85
+ this._allowWasm = v;
86
+ }
87
+ /**
88
+ * Whether or not Wasm should be used based on the desired
89
+ * feature set, initialization state, or force-use settings
90
+ */
91
+ get canUseWasm() {
92
+ return (
93
+ // Just force WASM
94
+ this._forceWasm || // Or if we haven't checked be optimistic
95
+ this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
96
+ this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
97
+ );
98
+ }
99
+ /**
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
+ */
103
+ get featureSupport() {
104
+ return {
105
+ ...this._featureSupport
106
+ };
107
+ }
108
+ /**
109
+ * Force use of Wasm
110
+ */
111
+ get forceWasm() {
112
+ return this._forceWasm;
113
+ }
114
+ /**
115
+ * Whether or not to force Wasm usage
116
+ */
117
+ set forceWasm(v) {
118
+ this._forceWasm = v;
119
+ }
120
+ /**
121
+ * Whether or not Wasm is supported based
122
+ * on the desired feature set
123
+ */
124
+ get isDesiredFeatureSetSupported() {
125
+ return this._isWasmFeatureSetSupported;
126
+ }
127
+ /**
128
+ * Whether or not Wasm detection has been run
129
+ * for the desired feature set
130
+ */
131
+ get isInitialized() {
132
+ return this._isInitialized;
133
+ }
134
+ /**
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
+ */
141
+ static async create(desiredFeatures) {
142
+ const instance = new _WasmSupport(desiredFeatures);
143
+ await instance.initialize();
144
+ return instance;
145
+ }
146
+ /**
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
+ */
151
+ async featureCheck(features) {
152
+ const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
153
+ return results.every(Boolean);
154
+ }
155
+ /**
156
+ * Does feature detection for the desired feature set
157
+ */
158
+ async initialize() {
159
+ if (this._isInitialized) return;
160
+ await this.detectDesiredFeatures();
161
+ this._isInitialized = true;
162
+ return;
163
+ }
164
+ async detectDesiredFeatures() {
165
+ for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
166
+ const desiredFeature = this.desiredFeatures[feature];
167
+ const detector = WasmFeatureDetectors[desiredFeature];
168
+ this._featureSupport[desiredFeature] = await detector() ? true : false;
169
+ }
170
+ this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
171
+ }
172
+ };
2
173
  //# sourceMappingURL=index.cjs.map
@@ -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":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,gBAAAC,IAAA,eAAAC,EAAAJ,GCAA,IAAAK,EAiBO,+BAEA,IAAMC,EAAuB,CAClCC,OAAQA,SACRC,WAAYA,aACZC,WAAYA,aACZC,cAAeA,gBACfC,GAAIA,KACJC,SAAUA,WACVC,WAAYA,aACZC,eAAgBA,iBAChBC,eAAgBA,iBAChBC,YAAaA,cACbC,oBAAqBA,sBACrBC,eAAgBA,iBAChBC,KAAMA,OACNC,qBAAsBA,uBACtBC,SA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,CAAAA,EACtCC,EAAWzC,EAAqB8C,CAAAA,EACtC,KAAK3B,gBAAgB2B,CAAAA,EAAmB,QAAML,EAAAA,CAChD,CACA,KAAKnB,2BAA6ByB,OAAOC,OAAO,KAAK7B,eAAe,EAAEuB,MAAMC,OAAAA,CAC9E,CACF","names":["src_exports","__export","WasmFeatureDetectors","WasmSupport","__toCommonJS","import_wasm_feature_detect","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","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n referenceTypes,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: referenceTypes,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return instance\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every(Boolean)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n return\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACAA,iCAiBO;AAEA,IAAMA,uBAAuB;EAClCC,QAAQA;EACRC,YAAYA;EACZC,YAAYA;EACZC,eAAeA;EACfC,IAAIA;EACJC,UAAUA;EACVC,YAAYA;EACZC,gBAAgBA;EAChBC,gBAAgBA;EAChBC,aAAaA;EACbC,qBAAqBA;EACrBC,gBAAgBA;EAChBC,MAAMA;EACNC,sBAAsBA;EACtBC,UAAUA;EACVC,SAASA;AACX;AAIO,IAAMC,cAAN,MAAMA,aAAAA;EAxCb,OAwCaA;;;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb,eAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["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,2 +1,152 @@
1
- var l=Object.defineProperty;var i=(a,e)=>l(a,"name",{value:e,configurable:!0});import{bigInt as n,bulkMemory as u,exceptions as m,extendedConst as d,gc as c,memory64 as p,multiValue as h,mutableGlobals as _,referenceTypes as f,relaxedSimd as W,saturatedFloatToInt as S,signExtensions as F,simd as g,streamingCompilation as w,tailCall as y,threads as I}from"wasm-feature-detect";var r={bigInt:n,bulkMemory:u,exceptions:m,extendedConst:d,gc:c,memory64:p,multiValue:h,mutableGlobals:_,referenceTypes:f,relaxedSimd:W,saturatedFloatToInt:S,signExtensions:F,simd:g,streamingCompilation:w,tailCall:y,threads:I},o=class a{static{i(this,"WasmSupport")}desiredFeatures;_allowWasm;_featureSupport;_forceWasm;_isInitialized;_isWasmFeatureSetSupported;constructor(e){this.desiredFeatures=e,this._allowWasm=!0,this._featureSupport={},this._forceWasm=!1,this._isInitialized=!1,this._isWasmFeatureSetSupported=!1}get allowWasm(){return this._allowWasm}set allowWasm(e){this._allowWasm=e}get canUseWasm(){return this._forceWasm||this._allowWasm&&!this._isInitialized||this._allowWasm&&this._isInitialized&&this._isWasmFeatureSetSupported}get featureSupport(){return{...this._featureSupport}}get forceWasm(){return this._forceWasm}set forceWasm(e){this._forceWasm=e}get isDesiredFeatureSetSupported(){return this._isWasmFeatureSetSupported}get isInitialized(){return this._isInitialized}static async create(e){let t=new a(e);return await t.initialize(),t}async featureCheck(e){return(await Promise.all(e.map(s=>r[s]).map(async s=>await s()))).every(Boolean)}async initialize(){this._isInitialized||(await this.detectDesiredFeatures(),this._isInitialized=!0)}async detectDesiredFeatures(){for(let e=0;e<this.desiredFeatures.length;e++){let t=this.desiredFeatures[e],s=r[t];this._featureSupport[t]=!!await s()}this._isWasmFeatureSetSupported=Object.values(this._featureSupport).every(Boolean)}};export{r as WasmFeatureDetectors,o as WasmSupport};
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/WasmSupport.ts
5
+ import { bigInt, bulkMemory, exceptions, extendedConst, gc, memory64, multiValue, mutableGlobals, referenceTypes, relaxedSimd, saturatedFloatToInt, signExtensions, simd, streamingCompilation, tailCall, threads } from "wasm-feature-detect";
6
+ var WasmFeatureDetectors = {
7
+ bigInt,
8
+ bulkMemory,
9
+ exceptions,
10
+ extendedConst,
11
+ gc,
12
+ memory64,
13
+ multiValue,
14
+ mutableGlobals,
15
+ referenceTypes,
16
+ relaxedSimd,
17
+ saturatedFloatToInt,
18
+ signExtensions,
19
+ simd,
20
+ streamingCompilation,
21
+ tailCall,
22
+ threads
23
+ };
24
+ var WasmSupport = class _WasmSupport {
25
+ static {
26
+ __name(this, "WasmSupport");
27
+ }
28
+ desiredFeatures;
29
+ _allowWasm;
30
+ _featureSupport;
31
+ _forceWasm;
32
+ _isInitialized;
33
+ _isWasmFeatureSetSupported;
34
+ /**
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
+ */
42
+ constructor(desiredFeatures) {
43
+ this.desiredFeatures = desiredFeatures;
44
+ this._allowWasm = true;
45
+ this._featureSupport = {};
46
+ this._forceWasm = false;
47
+ this._isInitialized = false;
48
+ this._isWasmFeatureSetSupported = false;
49
+ }
50
+ /**
51
+ * Is Wasm allowed
52
+ */
53
+ get allowWasm() {
54
+ return this._allowWasm;
55
+ }
56
+ /**
57
+ * Whether or not to allow WASM usage
58
+ */
59
+ set allowWasm(v) {
60
+ this._allowWasm = v;
61
+ }
62
+ /**
63
+ * Whether or not Wasm should be used based on the desired
64
+ * feature set, initialization state, or force-use settings
65
+ */
66
+ get canUseWasm() {
67
+ return (
68
+ // Just force WASM
69
+ this._forceWasm || // Or if we haven't checked be optimistic
70
+ this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
71
+ this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
72
+ );
73
+ }
74
+ /**
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
+ */
78
+ get featureSupport() {
79
+ return {
80
+ ...this._featureSupport
81
+ };
82
+ }
83
+ /**
84
+ * Force use of Wasm
85
+ */
86
+ get forceWasm() {
87
+ return this._forceWasm;
88
+ }
89
+ /**
90
+ * Whether or not to force Wasm usage
91
+ */
92
+ set forceWasm(v) {
93
+ this._forceWasm = v;
94
+ }
95
+ /**
96
+ * Whether or not Wasm is supported based
97
+ * on the desired feature set
98
+ */
99
+ get isDesiredFeatureSetSupported() {
100
+ return this._isWasmFeatureSetSupported;
101
+ }
102
+ /**
103
+ * Whether or not Wasm detection has been run
104
+ * for the desired feature set
105
+ */
106
+ get isInitialized() {
107
+ return this._isInitialized;
108
+ }
109
+ /**
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
+ */
116
+ static async create(desiredFeatures) {
117
+ const instance = new _WasmSupport(desiredFeatures);
118
+ await instance.initialize();
119
+ return instance;
120
+ }
121
+ /**
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
+ */
126
+ async featureCheck(features) {
127
+ const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
128
+ return results.every(Boolean);
129
+ }
130
+ /**
131
+ * Does feature detection for the desired feature set
132
+ */
133
+ async initialize() {
134
+ if (this._isInitialized) return;
135
+ await this.detectDesiredFeatures();
136
+ this._isInitialized = true;
137
+ return;
138
+ }
139
+ async detectDesiredFeatures() {
140
+ for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
141
+ const desiredFeature = this.desiredFeatures[feature];
142
+ const detector = WasmFeatureDetectors[desiredFeature];
143
+ this._featureSupport[desiredFeature] = await detector() ? true : false;
144
+ }
145
+ this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
146
+ }
147
+ };
148
+ export {
149
+ WasmFeatureDetectors,
150
+ WasmSupport
151
+ };
2
152
  //# sourceMappingURL=index.js.map
@@ -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":"+EAAA,OACEA,UAAAA,EACAC,cAAAA,EACAC,cAAAA,EACAC,iBAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,cAAAA,EACAC,kBAAAA,EACAC,kBAAAA,EACAC,eAAAA,EACAC,uBAAAA,EACAC,kBAAAA,EACAC,QAAAA,EACAC,wBAAAA,EACAC,YAAAA,EACAC,WAAAA,MACK,sBAEA,IAAMC,EAAuB,CAClCC,OAAQA,EACRC,WAAYA,EACZC,WAAYA,EACZC,cAAeA,EACfC,GAAIA,EACJC,SAAUA,EACVC,WAAYA,EACZC,eAAgBA,EAChBC,eAAgBA,EAChBC,YAAaA,EACbC,oBAAqBA,EACrBC,eAAgBA,EAChBC,KAAMA,EACNC,qBAAsBA,EACtBC,SAAUA,EACVC,QAASA,CACX,EAIaC,EAAN,MAAMA,CAAAA,CAxCb,MAwCaA,CAAAA,EAAAA,oCACHC,WACAC,gBACAC,WACAC,eACAC,2BAURC,YAAsBC,EAAgC,MAAhCA,gBAAAA,OAddN,WAAa,QACbC,gBAAyD,CAAC,OAC1DC,WAAa,QACbC,eAAiB,QACjBC,2BAA6B,EAUkB,CAKvD,IAAIG,WAAqB,CACvB,OAAO,KAAKP,UACd,CAIA,IAAIO,UAAUC,EAAY,CACxB,KAAKR,WAAaQ,CACpB,CAMA,IAAIC,YAAsB,CACxB,OAEE,KAAKP,YAEJ,KAAKF,YAAc,CAAC,KAAKG,gBAEzB,KAAKH,YAAc,KAAKG,gBAAkB,KAAKC,0BAEpD,CAMA,IAAIM,gBAAkE,CACpE,MAAO,CAAE,GAAG,KAAKT,eAAgB,CACnC,CAKA,IAAIU,WAAqB,CACvB,OAAO,KAAKT,UACd,CAIA,IAAIS,UAAUH,EAAY,CACxB,KAAKN,WAAaM,CACpB,CAMA,IAAII,8BAAwC,CAC1C,OAAO,KAAKR,0BACd,CAMA,IAAIS,eAAyB,CAC3B,OAAO,KAAKV,cACd,CASA,aAAaW,OAAOR,EAAsD,CACxE,IAAMS,EAAW,IAAIhB,EAAYO,CAAAA,EACjC,aAAMS,EAASC,WAAU,EAClBD,CACT,CAOA,MAAME,aAAaC,EAA2C,CAE5D,OADgB,MAAMC,QAAQC,IAAIF,EAASG,IAAKC,GAAYxC,EAAqBwC,CAAAA,CAAQ,EAAED,IAAI,MAAOE,GAAa,MAAMA,EAAAA,CAAAA,CAAAA,GAC1GC,MAAMC,OAAAA,CACvB,CAKA,MAAMT,YAA4B,CAC5B,KAAKb,iBACT,MAAM,KAAKuB,sBAAqB,EAChC,KAAKvB,eAAiB,GAExB,CAEA,MAAgBuB,uBAAuC,CACrD,QAASJ,EAAU,EAAGA,EAAU,KAAKhB,gBAAgBqB,OAAQL,IAAW,CACtE,IAAMM,EAAiB,KAAKtB,gBAAgBgB,CAAAA,EACtCC,EAAWzC,EAAqB8C,CAAAA,EACtC,KAAK3B,gBAAgB2B,CAAAA,EAAmB,QAAML,EAAAA,CAChD,CACA,KAAKnB,2BAA6ByB,OAAOC,OAAO,KAAK7B,eAAe,EAAEuB,MAAMC,OAAAA,CAC9E,CACF","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","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
1
+ {"version":3,"sources":["../../src/WasmSupport.ts"],"sourcesContent":["import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n referenceTypes,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: referenceTypes,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return instance\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every(Boolean)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n return\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;AAAA,SACEA,QACAC,YACAC,YACAC,eACAC,IACAC,UACAC,YACAC,gBACAC,gBACAC,aACAC,qBACAC,gBACAC,MACAC,sBACAC,UACAC,eACK;AAEA,IAAMC,uBAAuB;EAClCC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACA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B,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;","names":["bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
@@ -1,2 +1,177 @@
1
- "use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(a,t)=>o(a,"name",{value:t,configurable:!0});var h=(a,t)=>{for(var s in t)o(a,s,{get:t[s],enumerable:!0})},_=(a,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of c(t))!p.call(a,r)&&r!==s&&o(a,r,{get:()=>t[r],enumerable:!(i=m(t,r))||i.enumerable});return a};var f=a=>_(o({},"__esModule",{value:!0}),a);var W={};h(W,{WasmFeatureDetectors:()=>n,WasmSupport:()=>u});module.exports=f(W);var e=require("wasm-feature-detect");var n={bigInt:e.bigInt,bulkMemory:e.bulkMemory,exceptions:e.exceptions,extendedConst:e.extendedConst,gc:e.gc,memory64:e.memory64,multiValue:e.multiValue,mutableGlobals:e.mutableGlobals,referenceTypes:e.referenceTypes,relaxedSimd:e.relaxedSimd,saturatedFloatToInt:e.saturatedFloatToInt,signExtensions:e.signExtensions,simd:e.simd,streamingCompilation:e.streamingCompilation,tailCall:e.tailCall,threads:e.threads},l=class l{desiredFeatures;_allowWasm;_featureSupport;_forceWasm;_isInitialized;_isWasmFeatureSetSupported;constructor(t){this.desiredFeatures=t,this._allowWasm=!0,this._featureSupport={},this._forceWasm=!1,this._isInitialized=!1,this._isWasmFeatureSetSupported=!1}get allowWasm(){return this._allowWasm}set allowWasm(t){this._allowWasm=t}get canUseWasm(){return this._forceWasm||this._allowWasm&&!this._isInitialized||this._allowWasm&&this._isInitialized&&this._isWasmFeatureSetSupported}get featureSupport(){return{...this._featureSupport}}get forceWasm(){return this._forceWasm}set forceWasm(t){this._forceWasm=t}get isDesiredFeatureSetSupported(){return this._isWasmFeatureSetSupported}get isInitialized(){return this._isInitialized}static async create(t){let s=new l(t);return await s.initialize(),s}async featureCheck(t){return(await Promise.all(t.map(i=>n[i]).map(async i=>await i()))).every(Boolean)}async initialize(){this._isInitialized||(await this.detectDesiredFeatures(),this._isInitialized=!0)}async detectDesiredFeatures(){for(let t=0;t<this.desiredFeatures.length;t++){let s=this.desiredFeatures[t],i=n[s];this._featureSupport[s]=!!await i()}this._isWasmFeatureSetSupported=Object.values(this._featureSupport).every(Boolean)}};d(l,"WasmSupport");var u=l;0&&(module.exports={WasmFeatureDetectors,WasmSupport});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ WasmFeatureDetectors: () => WasmFeatureDetectors,
25
+ WasmSupport: () => WasmSupport
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/WasmSupport.ts
30
+ var import_wasm_feature_detect = require("wasm-feature-detect");
31
+ var WasmFeatureDetectors = {
32
+ bigInt: import_wasm_feature_detect.bigInt,
33
+ bulkMemory: import_wasm_feature_detect.bulkMemory,
34
+ exceptions: import_wasm_feature_detect.exceptions,
35
+ extendedConst: import_wasm_feature_detect.extendedConst,
36
+ gc: import_wasm_feature_detect.gc,
37
+ memory64: import_wasm_feature_detect.memory64,
38
+ multiValue: import_wasm_feature_detect.multiValue,
39
+ mutableGlobals: import_wasm_feature_detect.mutableGlobals,
40
+ referenceTypes: import_wasm_feature_detect.referenceTypes,
41
+ relaxedSimd: import_wasm_feature_detect.relaxedSimd,
42
+ saturatedFloatToInt: import_wasm_feature_detect.saturatedFloatToInt,
43
+ signExtensions: import_wasm_feature_detect.signExtensions,
44
+ simd: import_wasm_feature_detect.simd,
45
+ streamingCompilation: import_wasm_feature_detect.streamingCompilation,
46
+ tailCall: import_wasm_feature_detect.tailCall,
47
+ threads: import_wasm_feature_detect.threads
48
+ };
49
+ var _WasmSupport = class _WasmSupport {
50
+ desiredFeatures;
51
+ _allowWasm;
52
+ _featureSupport;
53
+ _forceWasm;
54
+ _isInitialized;
55
+ _isWasmFeatureSetSupported;
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
+ */
64
+ constructor(desiredFeatures) {
65
+ this.desiredFeatures = desiredFeatures;
66
+ this._allowWasm = true;
67
+ this._featureSupport = {};
68
+ this._forceWasm = false;
69
+ this._isInitialized = false;
70
+ this._isWasmFeatureSetSupported = false;
71
+ }
72
+ /**
73
+ * Is Wasm allowed
74
+ */
75
+ get allowWasm() {
76
+ return this._allowWasm;
77
+ }
78
+ /**
79
+ * Whether or not to allow WASM usage
80
+ */
81
+ set allowWasm(v) {
82
+ this._allowWasm = v;
83
+ }
84
+ /**
85
+ * Whether or not Wasm should be used based on the desired
86
+ * feature set, initialization state, or force-use settings
87
+ */
88
+ get canUseWasm() {
89
+ return (
90
+ // Just force WASM
91
+ this._forceWasm || // Or if we haven't checked be optimistic
92
+ this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
93
+ this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
94
+ );
95
+ }
96
+ /**
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
+ */
100
+ get featureSupport() {
101
+ return {
102
+ ...this._featureSupport
103
+ };
104
+ }
105
+ /**
106
+ * Force use of Wasm
107
+ */
108
+ get forceWasm() {
109
+ return this._forceWasm;
110
+ }
111
+ /**
112
+ * Whether or not to force Wasm usage
113
+ */
114
+ set forceWasm(v) {
115
+ this._forceWasm = v;
116
+ }
117
+ /**
118
+ * Whether or not Wasm is supported based
119
+ * on the desired feature set
120
+ */
121
+ get isDesiredFeatureSetSupported() {
122
+ return this._isWasmFeatureSetSupported;
123
+ }
124
+ /**
125
+ * Whether or not Wasm detection has been run
126
+ * for the desired feature set
127
+ */
128
+ get isInitialized() {
129
+ return this._isInitialized;
130
+ }
131
+ /**
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
+ */
138
+ static async create(desiredFeatures) {
139
+ const instance = new _WasmSupport(desiredFeatures);
140
+ await instance.initialize();
141
+ return instance;
142
+ }
143
+ /**
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
+ */
148
+ async featureCheck(features) {
149
+ const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
150
+ return results.every(Boolean);
151
+ }
152
+ /**
153
+ * Does feature detection for the desired feature set
154
+ */
155
+ async initialize() {
156
+ if (this._isInitialized) return;
157
+ await this.detectDesiredFeatures();
158
+ this._isInitialized = true;
159
+ return;
160
+ }
161
+ async detectDesiredFeatures() {
162
+ for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
163
+ const desiredFeature = this.desiredFeatures[feature];
164
+ const detector = WasmFeatureDetectors[desiredFeature];
165
+ this._featureSupport[desiredFeature] = await detector() ? true : false;
166
+ }
167
+ this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
168
+ }
169
+ };
170
+ __name(_WasmSupport, "WasmSupport");
171
+ var WasmSupport = _WasmSupport;
172
+ // Annotate the CommonJS export names for ESM import in node:
173
+ 0 && (module.exports = {
174
+ WasmFeatureDetectors,
175
+ WasmSupport
176
+ });
2
177
  //# sourceMappingURL=index.cjs.map
@@ -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":"4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,gBAAAC,IAAA,eAAAC,EAAAJ,GCAA,IAAAK,EAiBO,+BAEA,IAAMC,EAAuB,CAClCC,OAAQA,SACRC,WAAYA,aACZC,WAAYA,aACZC,cAAeA,gBACfC,GAAIA,KACJC,SAAUA,WACVC,WAAYA,aACZC,eAAgBA,iBAChBC,eAAgBA,iBAChBC,YAAaA,cACbC,oBAAqBA,sBACrBC,eAAgBA,iBAChBC,KAAMA,OACNC,qBAAsBA,uBACtBC,SAAUA,WACVC,QAASA,SACX,EAIaC,EAAN,MAAMA,CAAAA,iBACHC,WACAC,gBACAC,WACAC,eACAC,2BAURC,YAAsBC,EAAgC,MAAhCA,gBAAAA,OAddN,WAAa,QAC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,OAAAA,CAC9E,CACF,EA3Ha1B,EAAAA,EAAAA,eAAN,IAAMA,EAANgC","names":["src_exports","__export","WasmFeatureDetectors","WasmSupport","__toCommonJS","import_wasm_feature_detect","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","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values","_WasmSupport"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/WasmSupport.ts"],"sourcesContent":["export * from './WasmSupport'\n","import {\n bigInt,\n bulkMemory,\n exceptions,\n extendedConst,\n gc,\n memory64,\n multiValue,\n mutableGlobals,\n referenceTypes,\n relaxedSimd,\n saturatedFloatToInt,\n signExtensions,\n simd,\n streamingCompilation,\n tailCall,\n threads,\n} from 'wasm-feature-detect'\n\nexport const WasmFeatureDetectors = {\n bigInt: bigInt,\n bulkMemory: bulkMemory,\n exceptions: exceptions,\n extendedConst: extendedConst,\n gc: gc,\n memory64: memory64,\n multiValue: multiValue,\n mutableGlobals: mutableGlobals,\n referenceTypes: referenceTypes,\n relaxedSimd: relaxedSimd,\n saturatedFloatToInt: saturatedFloatToInt,\n signExtensions: signExtensions,\n simd: simd,\n streamingCompilation: streamingCompilation,\n tailCall: tailCall,\n threads: threads,\n} as const\n\nexport type WasmFeature = keyof typeof WasmFeatureDetectors\n\nexport class WasmSupport {\n private _allowWasm = true\n private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}\n private _forceWasm = false\n private _isInitialized = false\n private _isWasmFeatureSetSupported = false\n\n /**\n * Instance constructor for use where async instantiation\n * is not possible. Where possible, prefer the static\n * create method over use of this constructor directly\n * as no initialization (feature detection) is able to\n * be done here\n * @param desiredFeatures The desired feature set\n */\n constructor(protected desiredFeatures: WasmFeature[]) {}\n\n /**\n * Is Wasm allowed\n */\n get allowWasm(): boolean {\n return this._allowWasm\n }\n /**\n * Whether or not to allow WASM usage\n */\n set allowWasm(v: boolean) {\n this._allowWasm = v\n }\n\n /**\n * Whether or not Wasm should be used based on the desired\n * feature set, initialization state, or force-use settings\n */\n get canUseWasm(): boolean {\n return (\n // Just force WASM\n this._forceWasm ||\n // Or if we haven't checked be optimistic\n (this._allowWasm && !this._isInitialized) ||\n // Or if we have checked and WASM is not supported, be realistic\n (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)\n )\n }\n\n /**\n * Returns a object containing a property for each desired wasm feature\n * with a boolean value indicating whether or not the feature is supported\n */\n get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {\n return { ...this._featureSupport }\n }\n\n /**\n * Force use of Wasm\n */\n get forceWasm(): boolean {\n return this._forceWasm\n }\n /**\n * Whether or not to force Wasm usage\n */\n set forceWasm(v: boolean) {\n this._forceWasm = v\n }\n\n /**\n * Whether or not Wasm is supported based\n * on the desired feature set\n */\n get isDesiredFeatureSetSupported(): boolean {\n return this._isWasmFeatureSetSupported\n }\n\n /**\n * Whether or not Wasm detection has been run\n * for the desired feature set\n */\n get isInitialized(): boolean {\n return this._isInitialized\n }\n\n /**\n * Static creation & async initialization for use where\n * async instantiation is possible\n * @param desiredFeatures The desired feature set\n * @returns An initialized instance of the class with detection\n * for the desired feature set\n */\n static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {\n const instance = new WasmSupport(desiredFeatures)\n await instance.initialize()\n return instance\n }\n\n /**\n * Checks for specific wasm features\n * @param features The list of features to check for\n * @returns True if all the features are supported, false otherwise\n */\n async featureCheck(features: WasmFeature[]): Promise<boolean> {\n const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()))\n return results.every(Boolean)\n }\n\n /**\n * Does feature detection for the desired feature set\n */\n async initialize(): Promise<void> {\n if (this._isInitialized) return\n await this.detectDesiredFeatures()\n this._isInitialized = true\n return\n }\n\n protected async detectDesiredFeatures(): Promise<void> {\n for (let feature = 0; feature < this.desiredFeatures.length; feature++) {\n const desiredFeature = this.desiredFeatures[feature]\n const detector = WasmFeatureDetectors[desiredFeature]\n this._featureSupport[desiredFeature] = (await detector()) ? true : false\n }\n this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACAA,iCAiBO;AAEA,IAAMA,uBAAuB;EAClCC,QAAQA;EACRC,YAAYA;EACZC,YAAYA;EACZC,eAAeA;EACfC,IAAIA;EACJC,UAAUA;EACVC,YAAYA;EACZC,gBAAgBA;EAChBC,gBAAgBA;EAChBC,aAAaA;EACbC,qBAAqBA;EACrBC,gBAAgBA;EAChBC,MAAMA;EACNC,sBAAsBA;EACtBC,UAAUA;EACVC,SAASA;AACX;AAIO,IAAMC,eAAN,MAAMA,aAAAA;;EACHC;EACAC;EACAC;EACAC;EACAC;;;;;;;;;EAURC,YAAsBC,iBAAgC;SAAhCA,kBAAAA;SAddN,aAAa;SACbC,kBAAyD,CAAC;SAC1DC,aAAa;SACbC,iBAAiB;SACjBC,6BAA6B;EAUkB;;;;EAKvD,IAAIG,YAAqB;AACvB,WAAO,KAAKP;EACd;;;;EAIA,IAAIO,UAAUC,GAAY;AACxB,SAAKR,aAAaQ;EACpB;;;;;EAMA,IAAIC,aAAsB;AACxB;;MAEE,KAAKP;MAEJ,KAAKF,cAAc,CAAC,KAAKG;MAEzB,KAAKH,cAAc,KAAKG,kBAAkB,KAAKC;;EAEpD;;;;;EAMA,IAAIM,iBAAkE;AACpE,WAAO;MAAE,GAAG,KAAKT;IAAgB;EACnC;;;;EAKA,IAAIU,YAAqB;AACvB,WAAO,KAAKT;EACd;;;;EAIA,IAAIS,UAAUH,GAAY;AACxB,SAAKN,aAAaM;EACpB;;;;;EAMA,IAAII,+BAAwC;AAC1C,WAAO,KAAKR;EACd;;;;;EAMA,IAAIS,gBAAyB;AAC3B,WAAO,KAAKV;EACd;;;;;;;;EASA,aAAaW,OAAOR,iBAAsD;AACxE,UAAMS,WAAW,IAAIhB,aAAYO,eAAAA;AACjC,UAAMS,SAASC,WAAU;AACzB,WAAOD;EACT;;;;;;EAOA,MAAME,aAAaC,UAA2C;AAC5D,UAAMC,UAAU,MAAMC,QAAQC,IAAIH,SAASI,IAAI,CAACC,YAAYzC,qBAAqByC,OAAAA,CAAQ,EAAED,IAAI,OAAOE,aAAa,MAAMA,SAAAA,CAAAA,CAAAA;AACzH,WAAOL,QAAQM,MAAMC,OAAAA;EACvB;;;;EAKA,MAAMV,aAA4B;AAChC,QAAI,KAAKb,eAAgB;AACzB,UAAM,KAAKwB,sBAAqB;AAChC,SAAKxB,iBAAiB;AACtB;EACF;EAEA,MAAgBwB,wBAAuC;AACrD,aAASJ,UAAU,GAAGA,UAAU,KAAKjB,gBAAgBsB,QAAQL,WAAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;AA3Ha3B;AAAN,IAAMA,cAAN;","names":["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,2 +1,151 @@
1
- var n=Object.defineProperty;var i=(l,e)=>n(l,"name",{value:e,configurable:!0});import{bigInt as u,bulkMemory as d,exceptions as m,extendedConst as c,gc as p,memory64 as h,multiValue as _,mutableGlobals as f,referenceTypes as W,relaxedSimd as S,saturatedFloatToInt as F,signExtensions as g,simd as w,streamingCompilation as y,tailCall as I,threads as x}from"wasm-feature-detect";var r={bigInt:u,bulkMemory:d,exceptions:m,extendedConst:c,gc:p,memory64:h,multiValue:_,mutableGlobals:f,referenceTypes:W,relaxedSimd:S,saturatedFloatToInt:F,signExtensions:g,simd:w,streamingCompilation:y,tailCall:I,threads:x},a=class a{desiredFeatures;_allowWasm;_featureSupport;_forceWasm;_isInitialized;_isWasmFeatureSetSupported;constructor(e){this.desiredFeatures=e,this._allowWasm=!0,this._featureSupport={},this._forceWasm=!1,this._isInitialized=!1,this._isWasmFeatureSetSupported=!1}get allowWasm(){return this._allowWasm}set allowWasm(e){this._allowWasm=e}get canUseWasm(){return this._forceWasm||this._allowWasm&&!this._isInitialized||this._allowWasm&&this._isInitialized&&this._isWasmFeatureSetSupported}get featureSupport(){return{...this._featureSupport}}get forceWasm(){return this._forceWasm}set forceWasm(e){this._forceWasm=e}get isDesiredFeatureSetSupported(){return this._isWasmFeatureSetSupported}get isInitialized(){return this._isInitialized}static async create(e){let t=new a(e);return await t.initialize(),t}async featureCheck(e){return(await Promise.all(e.map(s=>r[s]).map(async s=>await s()))).every(Boolean)}async initialize(){this._isInitialized||(await this.detectDesiredFeatures(),this._isInitialized=!0)}async detectDesiredFeatures(){for(let e=0;e<this.desiredFeatures.length;e++){let t=this.desiredFeatures[e],s=r[t];this._featureSupport[t]=!!await s()}this._isWasmFeatureSetSupported=Object.values(this._featureSupport).every(Boolean)}};i(a,"WasmSupport");var o=a;export{r as WasmFeatureDetectors,o as WasmSupport};
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/WasmSupport.ts
5
+ import { bigInt, bulkMemory, exceptions, extendedConst, gc, memory64, multiValue, mutableGlobals, referenceTypes, relaxedSimd, saturatedFloatToInt, signExtensions, simd, streamingCompilation, tailCall, threads } from "wasm-feature-detect";
6
+ var WasmFeatureDetectors = {
7
+ bigInt,
8
+ bulkMemory,
9
+ exceptions,
10
+ extendedConst,
11
+ gc,
12
+ memory64,
13
+ multiValue,
14
+ mutableGlobals,
15
+ referenceTypes,
16
+ relaxedSimd,
17
+ saturatedFloatToInt,
18
+ signExtensions,
19
+ simd,
20
+ streamingCompilation,
21
+ tailCall,
22
+ threads
23
+ };
24
+ var _WasmSupport = class _WasmSupport {
25
+ desiredFeatures;
26
+ _allowWasm;
27
+ _featureSupport;
28
+ _forceWasm;
29
+ _isInitialized;
30
+ _isWasmFeatureSetSupported;
31
+ /**
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
+ */
39
+ constructor(desiredFeatures) {
40
+ this.desiredFeatures = desiredFeatures;
41
+ this._allowWasm = true;
42
+ this._featureSupport = {};
43
+ this._forceWasm = false;
44
+ this._isInitialized = false;
45
+ this._isWasmFeatureSetSupported = false;
46
+ }
47
+ /**
48
+ * Is Wasm allowed
49
+ */
50
+ get allowWasm() {
51
+ return this._allowWasm;
52
+ }
53
+ /**
54
+ * Whether or not to allow WASM usage
55
+ */
56
+ set allowWasm(v) {
57
+ this._allowWasm = v;
58
+ }
59
+ /**
60
+ * Whether or not Wasm should be used based on the desired
61
+ * feature set, initialization state, or force-use settings
62
+ */
63
+ get canUseWasm() {
64
+ return (
65
+ // Just force WASM
66
+ this._forceWasm || // Or if we haven't checked be optimistic
67
+ this._allowWasm && !this._isInitialized || // Or if we have checked and WASM is not supported, be realistic
68
+ this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported
69
+ );
70
+ }
71
+ /**
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
+ */
75
+ get featureSupport() {
76
+ return {
77
+ ...this._featureSupport
78
+ };
79
+ }
80
+ /**
81
+ * Force use of Wasm
82
+ */
83
+ get forceWasm() {
84
+ return this._forceWasm;
85
+ }
86
+ /**
87
+ * Whether or not to force Wasm usage
88
+ */
89
+ set forceWasm(v) {
90
+ this._forceWasm = v;
91
+ }
92
+ /**
93
+ * Whether or not Wasm is supported based
94
+ * on the desired feature set
95
+ */
96
+ get isDesiredFeatureSetSupported() {
97
+ return this._isWasmFeatureSetSupported;
98
+ }
99
+ /**
100
+ * Whether or not Wasm detection has been run
101
+ * for the desired feature set
102
+ */
103
+ get isInitialized() {
104
+ return this._isInitialized;
105
+ }
106
+ /**
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
+ */
113
+ static async create(desiredFeatures) {
114
+ const instance = new _WasmSupport(desiredFeatures);
115
+ await instance.initialize();
116
+ return instance;
117
+ }
118
+ /**
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
+ */
123
+ async featureCheck(features) {
124
+ const results = await Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map(async (detector) => await detector()));
125
+ return results.every(Boolean);
126
+ }
127
+ /**
128
+ * Does feature detection for the desired feature set
129
+ */
130
+ async initialize() {
131
+ if (this._isInitialized) return;
132
+ await this.detectDesiredFeatures();
133
+ this._isInitialized = true;
134
+ return;
135
+ }
136
+ async detectDesiredFeatures() {
137
+ for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
138
+ const desiredFeature = this.desiredFeatures[feature];
139
+ const detector = WasmFeatureDetectors[desiredFeature];
140
+ this._featureSupport[desiredFeature] = await detector() ? true : false;
141
+ }
142
+ this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean);
143
+ }
144
+ };
145
+ __name(_WasmSupport, "WasmSupport");
146
+ var WasmSupport = _WasmSupport;
147
+ export {
148
+ WasmFeatureDetectors,
149
+ WasmSupport
150
+ };
2
151
  //# sourceMappingURL=index.js.map
@@ -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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A,EACjC,aAAMS,EAASC,WAAU,EAClBD,CACT,CAOA,MAAME,aAAaC,EAA2C,CAE5D,OADgB,MAAMC,QAAQC,IAAIF,EAASG,IAAKC,GAAYxC,EAAqBwC,CAAAA,CAAQ,EAAED,IAAI,MAAOE,GAAa,MAAMA,EAAAA,CAAAA,CAAAA,GAC1GC,MAAMC,OAAAA,CACvB,CAKA,MAAMT,YAA4B,CAC5B,KAAKb,iBACT,MAAM,KAAKuB,sBAAqB,EAChC,KAAKvB,eAAiB,GAExB,CAEA,MAAgBuB,uBAAuC,CACrD,QAASJ,EAAU,EAAGA,EAAU,KAAKhB,gBAAgBqB,OAAQL,IAAW,CACtE,IAAMM,EAAiB,KAAKtB,gBAAgBgB,CAAAA,EACtCC,EAAWzC,EAAqB8C,CAAAA,EACtC,KAAK3B,gBAAgB2B,CAAAA,EAAmB,QAAML,EAAAA,CAChD,CACA,KAAKnB,2BAA6ByB,OAAOC,OAAO,KAAK7B,eAAe,EAAEuB,MAAMC,OAAAA,CAC9E,CACF,EA3Ha1B,EAAAA,EAAAA,eAAN,IAAMA,EAANgC","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","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values","_WasmSupport"]}
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,MA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AAW;AACtE,YAAMM,iBAAiB,KAAKvB,gBAAgBiB,OAAAA;AAC5C,YAAMC,WAAW1C,qBAAqB+C,cAAAA;AACtC,WAAK5B,gBAAgB4B,cAAAA,IAAmB,MAAML,SAAAA,IAAc,OAAO;IACrE;AACA,SAAKpB,6BAA6B0B,OAAOC,OAAO,KAAK9B,eAAe,EAAEwB,MAAMC,OAAAA;EAC9E;AACF;AA3Ha3B;AAAN,IAAMA,cAAN;","names":["bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmFeatureDetectors","bigInt","bulkMemory","exceptions","extendedConst","gc","memory64","multiValue","mutableGlobals","referenceTypes","relaxedSimd","saturatedFloatToInt","signExtensions","simd","streamingCompilation","tailCall","threads","WasmSupport","_allowWasm","_featureSupport","_forceWasm","_isInitialized","_isWasmFeatureSetSupported","constructor","desiredFeatures","allowWasm","v","canUseWasm","featureSupport","forceWasm","isDesiredFeatureSetSupported","isInitialized","create","instance","initialize","featureCheck","features","results","Promise","all","map","feature","detector","every","Boolean","detectDesiredFeatures","length","desiredFeature","Object","values"]}
package/package.json CHANGED
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "description": "Primary SDK for using XYO Protocol 2.0",
16
16
  "devDependencies": {
17
- "@xylabs/ts-scripts-yarn3": "^3.11.9",
18
- "@xylabs/tsconfig": "^3.11.9",
17
+ "@xylabs/ts-scripts-yarn3": "^3.11.10",
18
+ "@xylabs/tsconfig": "^3.11.10",
19
19
  "typescript": "^5.5.2"
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.107.1",
59
+ "version": "2.107.4",
60
60
  "type": "module"
61
61
  }