@xyo-network/wasm 5.3.20 → 5.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/wasm",
3
- "version": "5.3.20",
3
+ "version": "5.3.24",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,20 +30,24 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
33
  "!**/*.bench.*",
35
34
  "!**/*.spec.*",
36
- "!**/*.test.*"
35
+ "!**/*.test.*",
36
+ "README.md"
37
37
  ],
38
38
  "dependencies": {
39
39
  "wasm-feature-detect": "~1.8.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@xylabs/sdk-js": "^5.0.90",
43
- "@xylabs/tsconfig": "~7.5.6",
44
- "@xylabs/vitest-extended": "~5.0.90",
42
+ "@opentelemetry/api": "^1.9.1",
43
+ "@xylabs/sdk-js": "^5.0.93",
44
+ "@xylabs/tsconfig": "~7.6.16",
45
+ "@xylabs/vitest-extended": "~5.0.93",
46
+ "axios": "^1.14.0",
45
47
  "typescript": "~5.9.3",
48
+ "vite": "^8.0.3",
46
49
  "vitest": "~4.1.2",
50
+ "wasm-feature-detect": "~1.8.0",
47
51
  "zod": "^4.3.6"
48
52
  },
49
53
  "peerDependencies": {
@@ -53,4 +57,4 @@
53
57
  "publishConfig": {
54
58
  "access": "public"
55
59
  }
56
- }
60
+ }
@@ -1,170 +0,0 @@
1
- import {
2
- bigInt,
3
- bulkMemory,
4
- exceptions,
5
- extendedConst,
6
- gc,
7
- memory64,
8
- multiValue,
9
- mutableGlobals,
10
- relaxedSimd,
11
- saturatedFloatToInt,
12
- signExtensions,
13
- simd,
14
- streamingCompilation,
15
- tailCall,
16
- threads,
17
- } from 'wasm-feature-detect'
18
-
19
- export const WasmFeatureDetectors = {
20
- bigInt: bigInt,
21
- bulkMemory: bulkMemory,
22
- exceptions: exceptions,
23
- extendedConst: extendedConst,
24
- gc: gc,
25
- memory64: memory64,
26
- multiValue: multiValue,
27
- mutableGlobals: mutableGlobals,
28
- referenceTypes: () => Promise<boolean>,
29
- relaxedSimd: relaxedSimd,
30
- saturatedFloatToInt: saturatedFloatToInt,
31
- signExtensions: signExtensions,
32
- simd: simd,
33
- streamingCompilation: streamingCompilation,
34
- tailCall: tailCall,
35
- threads: threads,
36
- } as const
37
-
38
- import { isTruthy } from '@xylabs/sdk-js'
39
-
40
- export type WasmFeature = keyof typeof WasmFeatureDetectors
41
-
42
- export class WasmSupport {
43
- protected desiredFeatures: WasmFeature[]
44
-
45
- private _allowWasm = true
46
- private _featureSupport: Partial<Record<WasmFeature, boolean>> = {}
47
- private _forceWasm = false
48
- private _isInitialized = false
49
- private _isWasmFeatureSetSupported = false
50
-
51
- /**
52
- * Instance constructor for use where async instantiation
53
- * is not possible. Where possible, prefer the static
54
- * create method over use of this constructor directly
55
- * as no initialization (feature detection) is able to
56
- * be done here
57
- * @param desiredFeatures The desired feature set
58
- */
59
- constructor(desiredFeatures: WasmFeature[]) {
60
- this.desiredFeatures = desiredFeatures
61
- }
62
-
63
- /**
64
- * Is Wasm allowed
65
- */
66
- get allowWasm(): boolean {
67
- return this._allowWasm
68
- }
69
-
70
- /**
71
- * Whether or not to allow WASM usage
72
- */
73
- set allowWasm(v: boolean) {
74
- this._allowWasm = v
75
- }
76
-
77
- /**
78
- * Whether or not Wasm should be used based on the desired
79
- * feature set, initialization state, or force-use settings
80
- */
81
- get canUseWasm(): boolean {
82
- return (
83
- // Just force WASM
84
- this._forceWasm
85
- // Or if we haven't checked be optimistic
86
- || (this._allowWasm && !this._isInitialized)
87
- // Or if we have checked and WASM is not supported, be realistic
88
- || (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported)
89
- )
90
- }
91
-
92
- /**
93
- * Returns a object containing a property for each desired wasm feature
94
- * with a boolean value indicating whether or not the feature is supported
95
- */
96
- get featureSupport(): Readonly<Partial<Record<WasmFeature, boolean>>> {
97
- return { ...this._featureSupport }
98
- }
99
-
100
- /**
101
- * Force use of Wasm
102
- */
103
- get forceWasm(): boolean {
104
- return this._forceWasm
105
- }
106
-
107
- /**
108
- * Whether or not to force Wasm usage
109
- */
110
- set forceWasm(v: boolean) {
111
- this._forceWasm = v
112
- }
113
-
114
- /**
115
- * Whether or not Wasm is supported based
116
- * on the desired feature set
117
- */
118
- get isDesiredFeatureSetSupported(): boolean {
119
- return this._isWasmFeatureSetSupported
120
- }
121
-
122
- /**
123
- * Whether or not Wasm detection has been run
124
- * for the desired feature set
125
- */
126
- get isInitialized(): boolean {
127
- return this._isInitialized
128
- }
129
-
130
- /**
131
- * Static creation & async initialization for use where
132
- * async instantiation is possible
133
- * @param desiredFeatures The desired feature set
134
- * @returns An initialized instance of the class with detection
135
- * for the desired feature set
136
- */
137
- static async create(desiredFeatures: WasmFeature[]): Promise<WasmSupport> {
138
- const instance = new WasmSupport(desiredFeatures)
139
- await instance.initialize()
140
- return instance
141
- }
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: WasmFeature[]): Promise<boolean> {
149
- const results = await Promise.all(features.map(feature => WasmFeatureDetectors[feature]).map(async detector => await detector()))
150
- return results.every(Boolean)
151
- }
152
-
153
- /**
154
- * Does feature detection for the desired feature set
155
- */
156
- async initialize(): Promise<void> {
157
- if (this._isInitialized) return
158
- await this.detectDesiredFeatures()
159
- this._isInitialized = true
160
- }
161
-
162
- protected async detectDesiredFeatures(): Promise<void> {
163
- for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
164
- const desiredFeature = this.desiredFeatures[feature]
165
- const detector = WasmFeatureDetectors[desiredFeature]
166
- this._featureSupport[desiredFeature] = isTruthy(await detector())
167
- }
168
- this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every(Boolean)
169
- }
170
- }
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './WasmSupport.ts'