@xyo-network/core 2.57.6 → 2.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/cjs/Wasm/WasmSupport.js +153 -0
  2. package/dist/cjs/Wasm/WasmSupport.js.map +1 -0
  3. package/dist/cjs/Wasm/index.js +5 -0
  4. package/dist/cjs/Wasm/index.js.map +1 -0
  5. package/dist/cjs/index.js +1 -0
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/docs.json +1677 -143
  8. package/dist/esm/Wasm/WasmSupport.js +141 -0
  9. package/dist/esm/Wasm/WasmSupport.js.map +1 -0
  10. package/dist/esm/Wasm/index.js +2 -0
  11. package/dist/esm/Wasm/index.js.map +1 -0
  12. package/dist/esm/index.js +1 -0
  13. package/dist/esm/index.js.map +1 -1
  14. package/dist/types/Wasm/WasmSupport.d.ts +93 -0
  15. package/dist/types/Wasm/WasmSupport.d.ts.map +1 -0
  16. package/dist/types/Wasm/index.d.ts +2 -0
  17. package/dist/types/Wasm/index.d.ts.map +1 -0
  18. package/dist/types/index.d.ts +1 -0
  19. package/dist/types/index.d.ts.map +1 -1
  20. package/docs/assets/search.js +1 -1
  21. package/docs/classes/Base.html +7 -5
  22. package/docs/classes/Hasher.html +16 -14
  23. package/docs/classes/ObjectWrapper.html +6 -4
  24. package/docs/classes/WasmSupport.html +335 -0
  25. package/docs/classes/XyoAbstractData.html +11 -9
  26. package/docs/classes/XyoData.html +16 -14
  27. package/docs/classes/XyoObjectWrapper.html +6 -4
  28. package/docs/classes/XyoValidatorBase.html +7 -5
  29. package/docs/functions/deepBy.html +3 -1
  30. package/docs/functions/deepOmitUnderscoreFields.html +3 -1
  31. package/docs/functions/deepPickUnderscoreFields.html +3 -1
  32. package/docs/functions/dumpErrors.html +3 -1
  33. package/docs/functions/isBrowser.html +3 -1
  34. package/docs/functions/normalizeAddress.html +3 -1
  35. package/docs/functions/removeEmptyFields.html +3 -1
  36. package/docs/functions/sortFields.html +3 -1
  37. package/docs/functions/toUint8Array.html +3 -1
  38. package/docs/functions/toUint8ArrayOptional.html +3 -1
  39. package/docs/functions/trimAddressPrefix.html +3 -1
  40. package/docs/functions/uuid.html +3 -1
  41. package/docs/index.html +2 -0
  42. package/docs/interfaces/Logger.html +8 -6
  43. package/docs/interfaces/Validator.html +4 -2
  44. package/docs/modules.html +4 -0
  45. package/docs/types/AnyObject.html +3 -1
  46. package/docs/types/BaseParams.html +3 -1
  47. package/docs/types/BaseParamsFields.html +3 -1
  48. package/docs/types/DataLike.html +3 -1
  49. package/docs/types/EmptyObject.html +3 -1
  50. package/docs/types/LogFunction.html +3 -1
  51. package/docs/types/StringKeyObject.html +3 -1
  52. package/docs/types/WasmFeature.html +72 -0
  53. package/docs/types/WithAdditional.html +3 -1
  54. package/docs/variables/addressPrefix.html +3 -1
  55. package/package.json +5 -4
  56. package/src/Wasm/WasmSupport.ts +168 -0
  57. package/src/Wasm/index.ts +1 -0
  58. package/src/index.ts +1 -0
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WasmSupport = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const wasm_feature_detect_1 = require("wasm-feature-detect");
6
+ const WasmFeatureDetectors = {
7
+ bigInt: wasm_feature_detect_1.bigInt,
8
+ bulkMemory: wasm_feature_detect_1.bulkMemory,
9
+ exceptions: wasm_feature_detect_1.exceptions,
10
+ extendedConst: wasm_feature_detect_1.extendedConst,
11
+ gc: wasm_feature_detect_1.gc,
12
+ memory64: wasm_feature_detect_1.memory64,
13
+ multiValue: wasm_feature_detect_1.multiValue,
14
+ mutableGlobals: wasm_feature_detect_1.mutableGlobals,
15
+ referenceTypes: wasm_feature_detect_1.referenceTypes,
16
+ relaxedSimd: wasm_feature_detect_1.relaxedSimd,
17
+ saturatedFloatToInt: wasm_feature_detect_1.saturatedFloatToInt,
18
+ signExtensions: wasm_feature_detect_1.signExtensions,
19
+ simd: wasm_feature_detect_1.simd,
20
+ streamingCompilation: wasm_feature_detect_1.streamingCompilation,
21
+ tailCall: wasm_feature_detect_1.tailCall,
22
+ threads: wasm_feature_detect_1.threads,
23
+ };
24
+ class WasmSupport {
25
+ /**
26
+ * Instance constructor for use where async instantiation
27
+ * is not possible. Where possible, prefer the static
28
+ * create method over use of this constructor directly
29
+ * as no initialization (feature detection) is able to
30
+ * be done here
31
+ * @param desiredFeatures The desired feature set
32
+ */
33
+ constructor(desiredFeatures) {
34
+ this.desiredFeatures = desiredFeatures;
35
+ this._allowWasm = true;
36
+ this._featureSupport = {};
37
+ this._forceWasm = false;
38
+ this._isInitialized = false;
39
+ this._isWasmFeatureSetSupported = false;
40
+ }
41
+ /**
42
+ * Is Wasm allowed
43
+ */
44
+ get allowWasm() {
45
+ return this._allowWasm;
46
+ }
47
+ /**
48
+ * Whether or not to allow WASM usage
49
+ */
50
+ set allowWasm(v) {
51
+ this._allowWasm = v;
52
+ }
53
+ /**
54
+ * Whether or not Wasm should be used based on the desired
55
+ * feature set, initialization state, or force-use settings
56
+ */
57
+ get canUseWasm() {
58
+ return (
59
+ // Just force WASM
60
+ this._forceWasm ||
61
+ // Or if we haven't checked be optimistic
62
+ (this._allowWasm && !this._isInitialized) ||
63
+ // Or if we have checked and WASM is not supported, be realistic
64
+ (this._allowWasm && this._isInitialized && this._isWasmFeatureSetSupported));
65
+ }
66
+ /**
67
+ * Returns a object containing a property for each desired wasm feature
68
+ * with a boolean value indicating whether or not the feature is supported
69
+ */
70
+ get featureSupport() {
71
+ return Object.assign({}, this._featureSupport);
72
+ }
73
+ /**
74
+ * Force use of Wasm
75
+ */
76
+ get forceWasm() {
77
+ return this._forceWasm;
78
+ }
79
+ /**
80
+ * Whether or not to force Wasm usage
81
+ */
82
+ set forceWasm(v) {
83
+ this._forceWasm = v;
84
+ }
85
+ /**
86
+ * Whether or not Wasm is supported based
87
+ * on the desired feature set
88
+ */
89
+ get isDesiredFeatureSetSupported() {
90
+ return this._isWasmFeatureSetSupported;
91
+ }
92
+ /**
93
+ * Whether or not Wasm detection has been run
94
+ * for the desired feature set
95
+ */
96
+ get isInitialized() {
97
+ return this._isInitialized;
98
+ }
99
+ /**
100
+ * Static creation & async initialization for use where
101
+ * async instantiation is possible
102
+ * @param desiredFeatures The desired feature set
103
+ * @returns An initialized instance of the class with detection
104
+ * for the desired feature set
105
+ */
106
+ static create(desiredFeatures) {
107
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
108
+ const instance = new WasmSupport(desiredFeatures);
109
+ yield instance.initialize();
110
+ return Promise.resolve(instance);
111
+ });
112
+ }
113
+ /**
114
+ * Checks for specific wasm features
115
+ * @param features The list of features to check for
116
+ * @returns True if all the features are supported, false otherwise
117
+ */
118
+ featureCheck(features) {
119
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
120
+ const results = yield Promise.all(features.map((feature) => WasmFeatureDetectors[feature]).map((detector) => tslib_1.__awaiter(this, void 0, void 0, function* () { return yield detector(); })));
121
+ return results.every((result) => result);
122
+ });
123
+ }
124
+ /**
125
+ * Does feature detection for the desired feature set
126
+ */
127
+ initialize() {
128
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
129
+ if (this._isInitialized)
130
+ return;
131
+ yield this.detectDesiredFeatures();
132
+ this._isInitialized = true;
133
+ return;
134
+ });
135
+ }
136
+ detectDesiredFeatures() {
137
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
138
+ for (let feature = 0; feature < this.desiredFeatures.length; feature++) {
139
+ const desiredFeature = this.desiredFeatures[feature];
140
+ const detector = WasmFeatureDetectors[desiredFeature];
141
+ if (!(yield detector())) {
142
+ this._featureSupport[desiredFeature] = false;
143
+ }
144
+ else {
145
+ this._featureSupport[desiredFeature] = true;
146
+ }
147
+ }
148
+ this._isWasmFeatureSetSupported = Object.values(this._featureSupport).every((v) => v);
149
+ });
150
+ }
151
+ }
152
+ exports.WasmSupport = WasmSupport;
153
+ //# sourceMappingURL=WasmSupport.js.map
@@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GAAG,IAAI,CAAA;YAC1B,OAAM;QACR,CAAC;KAAA;IAEe,qBAAqB;;YACnC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;gBACtE,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;gBACpD,MAAM,QAAQ,GAAG,oBAAoB,CAAC,cAAc,CAAC,CAAA;gBACrD,IAAI,CAAC,CAAC,MAAM,QAAQ,EAAE,CAAC,EAAE;oBACvB,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,GAAG,KAAK,CAAA;iBAC7C;qBAAM;oBACL,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,GAAG,IAAI,CAAA;iBAC5C;aACF;YACD,IAAI,CAAC,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;QACvF,CAAC;KAAA;CACF;AA/HD,kCA+HC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./WasmSupport"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Wasm/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B"}
package/dist/cjs/index.js CHANGED
@@ -4,4 +4,5 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./Data"), exports);
5
5
  tslib_1.__exportStar(require("./Hasher"), exports);
6
6
  tslib_1.__exportStar(require("./lib"), exports);
7
+ tslib_1.__exportStar(require("./Wasm"), exports);
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,mDAAwB;AACxB,gDAAqB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,mDAAwB;AACxB,gDAAqB;AACrB,iDAAsB"}