@stemy/ngx-utils 13.2.4 → 13.3.1
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/esm2020/ngx-utils/common-types.mjs +2 -1
- package/esm2020/ngx-utils/ngx-utils.imports.mjs +5 -1
- package/esm2020/ngx-utils/ngx-utils.module.mjs +7 -2
- package/esm2020/ngx-utils/services/base-http.service.mjs +4 -1
- package/esm2020/ngx-utils/services/local-http.service.mjs +47 -0
- package/esm2020/ngx-utils/services/wasm.service.mjs +46 -0
- package/esm2020/ngx-utils/utils/jsonfn.mjs +45 -0
- package/esm2020/ngx-utils/utils/wasi.mjs +159 -0
- package/esm2020/ngx-utils/utils/wasm-worker-proxy.mjs +99 -0
- package/esm2020/public_api.mjs +5 -2
- package/fesm2015/stemy-ngx-utils.mjs +463 -69
- package/fesm2015/stemy-ngx-utils.mjs.map +1 -1
- package/fesm2020/stemy-ngx-utils.mjs +459 -67
- package/fesm2020/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/common-types.d.ts +29 -0
- package/ngx-utils/services/base-http.service.d.ts +1 -0
- package/ngx-utils/services/local-http.service.d.ts +14 -0
- package/ngx-utils/services/wasm.service.d.ts +25 -0
- package/ngx-utils/utils/jsonfn.d.ts +6 -0
- package/ngx-utils/utils/wasi.d.ts +26 -0
- package/ngx-utils/utils/wasm-worker-proxy.d.ts +17 -0
- package/package.json +1 -1
- package/public_api.d.ts +4 -1
|
@@ -343,6 +343,7 @@ var StorageMode;
|
|
|
343
343
|
})(StorageMode || (StorageMode = {}));
|
|
344
344
|
const TOASTER_SERVICE = new InjectionToken("toaster-service");
|
|
345
345
|
const PROMISE_SERVICE = new InjectionToken("promise-service");
|
|
346
|
+
const WASI_IMPLEMENTATION = new InjectionToken("wasi-implementation");
|
|
346
347
|
// --- Unordered list ---
|
|
347
348
|
class UnorederedListTemplate extends TemplateRef {
|
|
348
349
|
}
|
|
@@ -1175,6 +1176,51 @@ class Initializer {
|
|
|
1175
1176
|
}
|
|
1176
1177
|
}
|
|
1177
1178
|
|
|
1179
|
+
class JSONfn {
|
|
1180
|
+
static parse(text) {
|
|
1181
|
+
return JSON.parse(text, JSONfn.reviver);
|
|
1182
|
+
}
|
|
1183
|
+
static stringify(obj) {
|
|
1184
|
+
return JSON.stringify(obj, JSONfn.replacer);
|
|
1185
|
+
}
|
|
1186
|
+
static reviver(key, value) {
|
|
1187
|
+
const iso8061 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:.\d+)?(?:Z|[+-]\d\d:\d\d)$/;
|
|
1188
|
+
if (typeof value !== "string")
|
|
1189
|
+
return value;
|
|
1190
|
+
if (value.length < 8) {
|
|
1191
|
+
return value;
|
|
1192
|
+
}
|
|
1193
|
+
if (value.match(iso8061)) {
|
|
1194
|
+
return new Date(value);
|
|
1195
|
+
}
|
|
1196
|
+
const prefix = value.substring(0, 8);
|
|
1197
|
+
if (prefix === "function") {
|
|
1198
|
+
return new Function(`return ${value}`)();
|
|
1199
|
+
}
|
|
1200
|
+
if (prefix === "_NuFrRa_") {
|
|
1201
|
+
return new Function(`return ${value.slice(8)}`)();
|
|
1202
|
+
}
|
|
1203
|
+
if (prefix === "_PxEgEr_") {
|
|
1204
|
+
return new Function(`return ${value.slice(8)}`)();
|
|
1205
|
+
}
|
|
1206
|
+
return value;
|
|
1207
|
+
}
|
|
1208
|
+
static replacer(key, value) {
|
|
1209
|
+
if (value instanceof Function || typeof value === "function") {
|
|
1210
|
+
const fnBody = value.toString();
|
|
1211
|
+
if (fnBody.length < 8 || fnBody.substring(0, 8) !== "function") {
|
|
1212
|
+
// this is ES6 Arrow Function
|
|
1213
|
+
return "_NuFrRa_" + fnBody;
|
|
1214
|
+
}
|
|
1215
|
+
return fnBody;
|
|
1216
|
+
}
|
|
1217
|
+
if (value instanceof RegExp) {
|
|
1218
|
+
return "_PxEgEr_" + value;
|
|
1219
|
+
}
|
|
1220
|
+
return value;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1178
1224
|
class LoaderUtils {
|
|
1179
1225
|
static loadScript(src, async = false) {
|
|
1180
1226
|
this.scriptPromises[src] = this.scriptPromises[src] || new Promise((resolve, reject) => {
|
|
@@ -2083,83 +2129,105 @@ class Vector {
|
|
|
2083
2129
|
}
|
|
2084
2130
|
}
|
|
2085
2131
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
const
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2132
|
+
function workerFunction(JSONfn, logTimes) {
|
|
2133
|
+
let wasmResolve = null;
|
|
2134
|
+
const wasmInstance = new Promise(resolve => {
|
|
2135
|
+
wasmResolve = resolve;
|
|
2136
|
+
});
|
|
2137
|
+
self.onmessage = function (e) {
|
|
2138
|
+
const data = e.data;
|
|
2139
|
+
const { type, payload } = data;
|
|
2140
|
+
switch (type) {
|
|
2141
|
+
case "wasm":
|
|
2142
|
+
const { url, wasi } = payload;
|
|
2143
|
+
fetch(url).then(response => response.arrayBuffer()).then(bytes => {
|
|
2144
|
+
const wasiImpl = JSONfn.parse(wasi);
|
|
2145
|
+
return new wasiImpl().instantiate(bytes);
|
|
2146
|
+
}).then(instance => {
|
|
2147
|
+
wasmResolve(instance);
|
|
2148
|
+
const methods = Object.getOwnPropertyNames(instance).filter(key => typeof instance[key] === "function");
|
|
2149
|
+
self.postMessage({ type: "methods", payload: methods });
|
|
2150
|
+
});
|
|
2151
|
+
break;
|
|
2152
|
+
case "call":
|
|
2153
|
+
wasmInstance.then(instance => {
|
|
2154
|
+
const { name, id, args } = payload;
|
|
2155
|
+
if (logTimes) {
|
|
2156
|
+
console.time(id);
|
|
2157
|
+
console.timeLog(id, `Calling ${name} ...`);
|
|
2111
2158
|
}
|
|
2112
|
-
|
|
2113
|
-
|
|
2159
|
+
const func = instance[name];
|
|
2160
|
+
const result = func(...args);
|
|
2161
|
+
if (logTimes) {
|
|
2162
|
+
console.timeLog(id, `Called ${name}`);
|
|
2163
|
+
console.timeEnd(id);
|
|
2114
2164
|
}
|
|
2115
|
-
|
|
2116
|
-
}
|
|
2117
|
-
info.guard.getReturnState(info.route).then(returnState => {
|
|
2118
|
-
if (!returnState)
|
|
2119
|
-
return;
|
|
2120
|
-
this.state.navigate(returnState);
|
|
2165
|
+
self.postMessage({ type: "result", payload: { id, result } });
|
|
2121
2166
|
});
|
|
2122
|
-
|
|
2167
|
+
break;
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
class WasmWorkerProxy {
|
|
2172
|
+
constructor(wasmPath, wasi, logTimes = false) {
|
|
2173
|
+
this.methods = new Promise(resolve => {
|
|
2174
|
+
this.onMethods = resolve;
|
|
2123
2175
|
});
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2176
|
+
const lt = logTimes ? "true" : "false";
|
|
2177
|
+
const blob = new Blob([`${JSONfn.toString()} (${workerFunction.toString()})(JSONfn, ${lt})`], { type: 'application/javascript' });
|
|
2178
|
+
this.worker = new Worker(URL.createObjectURL(blob));
|
|
2179
|
+
this.worker.postMessage({
|
|
2180
|
+
type: "wasm",
|
|
2181
|
+
payload: { url: wasmPath, wasi: JSONfn.stringify(wasi), logTimes }
|
|
2182
|
+
});
|
|
2183
|
+
this.worker.onmessage = this.onMessage.bind(this);
|
|
2184
|
+
this.promises = new Map();
|
|
2185
|
+
return new Proxy(this, {
|
|
2186
|
+
get: (target, prop, receiver) => {
|
|
2187
|
+
const res = Reflect.get(target, prop, receiver);
|
|
2188
|
+
if (res) {
|
|
2189
|
+
return res;
|
|
2190
|
+
}
|
|
2191
|
+
return (...args) => {
|
|
2192
|
+
return this.call(prop.toString(), args);
|
|
2193
|
+
};
|
|
2131
2194
|
}
|
|
2132
2195
|
});
|
|
2133
2196
|
}
|
|
2134
|
-
|
|
2135
|
-
const
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2197
|
+
onMessage(e) {
|
|
2198
|
+
const data = e.data;
|
|
2199
|
+
const { type, payload } = data;
|
|
2200
|
+
switch (type) {
|
|
2201
|
+
case "methods":
|
|
2202
|
+
this.onMethods(payload);
|
|
2203
|
+
break;
|
|
2204
|
+
case "result":
|
|
2205
|
+
const { id, result } = payload;
|
|
2206
|
+
const promise = this.promises.get(id);
|
|
2207
|
+
if (promise) {
|
|
2208
|
+
promise.resolve(result);
|
|
2209
|
+
this.promises.delete(id);
|
|
2210
|
+
}
|
|
2211
|
+
break;
|
|
2148
2212
|
}
|
|
2149
|
-
info.component = this.state.component;
|
|
2150
|
-
return info;
|
|
2151
2213
|
}
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2214
|
+
call(method, args) {
|
|
2215
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2216
|
+
const methods = yield this.methods;
|
|
2217
|
+
if (!methods.includes(method)) {
|
|
2218
|
+
throw new Error(`Method ${method} not found`);
|
|
2219
|
+
}
|
|
2220
|
+
return new Promise((resolve, reject) => {
|
|
2221
|
+
const id = Math.random().toString(36).substring(2, 9);
|
|
2222
|
+
this.worker.postMessage({
|
|
2223
|
+
type: "call",
|
|
2224
|
+
payload: { name: method, id, args }
|
|
2225
|
+
});
|
|
2226
|
+
this.promises.set(id, { resolve, reject });
|
|
2227
|
+
});
|
|
2228
|
+
});
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2163
2231
|
|
|
2164
2232
|
class BaseHttpClient extends HttpClient {
|
|
2165
2233
|
constructor(handler) {
|
|
@@ -2258,6 +2326,7 @@ class BaseHttpService {
|
|
|
2258
2326
|
this.requestHeaders = {};
|
|
2259
2327
|
this.requestParams = {};
|
|
2260
2328
|
this.cache = {};
|
|
2329
|
+
this.initService();
|
|
2261
2330
|
}
|
|
2262
2331
|
get name() {
|
|
2263
2332
|
return "base";
|
|
@@ -2272,6 +2341,8 @@ class BaseHttpService {
|
|
|
2272
2341
|
get universal() {
|
|
2273
2342
|
return this.storage.universal;
|
|
2274
2343
|
}
|
|
2344
|
+
initService() {
|
|
2345
|
+
}
|
|
2275
2346
|
url(url) {
|
|
2276
2347
|
return url;
|
|
2277
2348
|
}
|
|
@@ -2539,6 +2610,170 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
2539
2610
|
}] }];
|
|
2540
2611
|
} });
|
|
2541
2612
|
|
|
2613
|
+
class LocalHttpService extends BaseHttpService {
|
|
2614
|
+
get name() {
|
|
2615
|
+
return "local-http";
|
|
2616
|
+
}
|
|
2617
|
+
get withCredentials() {
|
|
2618
|
+
return false;
|
|
2619
|
+
}
|
|
2620
|
+
initService() {
|
|
2621
|
+
this.images = {};
|
|
2622
|
+
}
|
|
2623
|
+
url(url) {
|
|
2624
|
+
if (!url)
|
|
2625
|
+
return url;
|
|
2626
|
+
const config = this.configs.config;
|
|
2627
|
+
const baseUrl = config.cdnUrl || config.baseUrl || "";
|
|
2628
|
+
return url.startsWith("data:") || url.startsWith("http") || url.startsWith("//")
|
|
2629
|
+
? url
|
|
2630
|
+
: `${baseUrl}${url}`;
|
|
2631
|
+
}
|
|
2632
|
+
get(url, options) {
|
|
2633
|
+
this.cache[url] = this.cache[url] || this.getPromise(url, options);
|
|
2634
|
+
return this.cache[url];
|
|
2635
|
+
}
|
|
2636
|
+
getImage(url) {
|
|
2637
|
+
if (this.universal.isServer)
|
|
2638
|
+
return Promise.resolve(null);
|
|
2639
|
+
if (!url)
|
|
2640
|
+
return Promise.resolve(new Image());
|
|
2641
|
+
this.images[url] = this.images[url] || new Promise((resolve, reject) => {
|
|
2642
|
+
const image = new Image();
|
|
2643
|
+
image.crossOrigin = "Anonymous";
|
|
2644
|
+
image.src = this.url(url);
|
|
2645
|
+
image.onload = () => resolve(image);
|
|
2646
|
+
image.onerror = reject;
|
|
2647
|
+
});
|
|
2648
|
+
return this.images[url];
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
LocalHttpService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: LocalHttpService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
2652
|
+
LocalHttpService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: LocalHttpService });
|
|
2653
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: LocalHttpService, decorators: [{
|
|
2654
|
+
type: Injectable
|
|
2655
|
+
}] });
|
|
2656
|
+
|
|
2657
|
+
/**
|
|
2658
|
+
* Use this service to load WebAssembly modules
|
|
2659
|
+
*/
|
|
2660
|
+
class WasmService {
|
|
2661
|
+
constructor(universal, http, wasi) {
|
|
2662
|
+
this.universal = universal;
|
|
2663
|
+
this.http = http;
|
|
2664
|
+
this.wasi = wasi.constructor;
|
|
2665
|
+
}
|
|
2666
|
+
getModule(name) {
|
|
2667
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2668
|
+
if (!this.universal.isBrowser || !name)
|
|
2669
|
+
return null;
|
|
2670
|
+
this.modules = this.modules || {};
|
|
2671
|
+
this.modules[name] = this.modules[name] || this.http.get(`wasm/${name}.wasm`, {
|
|
2672
|
+
responseType: "arraybuffer"
|
|
2673
|
+
}).then((bytes) => __awaiter(this, void 0, void 0, function* () {
|
|
2674
|
+
const wasi = new this.wasi();
|
|
2675
|
+
return yield wasi.instantiate(bytes);
|
|
2676
|
+
}));
|
|
2677
|
+
return this.modules[name];
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
getWorkerModule(name) {
|
|
2681
|
+
if (!this.universal.isBrowser || !name)
|
|
2682
|
+
return null;
|
|
2683
|
+
this.workerModules = this.workerModules || {};
|
|
2684
|
+
this.workerModules[name] = new WasmWorkerProxy(this.http.url(`wasm/${name}.wasm`), this.wasi);
|
|
2685
|
+
return this.workerModules[name];
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
WasmService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: WasmService, deps: [{ token: UniversalService }, { token: LocalHttpService }, { token: WASI_IMPLEMENTATION }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2689
|
+
WasmService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: WasmService });
|
|
2690
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: WasmService, decorators: [{
|
|
2691
|
+
type: Injectable
|
|
2692
|
+
}], ctorParameters: function () {
|
|
2693
|
+
return [{ type: UniversalService }, { type: LocalHttpService }, { type: undefined, decorators: [{
|
|
2694
|
+
type: Inject,
|
|
2695
|
+
args: [WASI_IMPLEMENTATION]
|
|
2696
|
+
}] }];
|
|
2697
|
+
} });
|
|
2698
|
+
|
|
2699
|
+
const emptyGuards = [];
|
|
2700
|
+
class AclService {
|
|
2701
|
+
constructor(injector, state, auth) {
|
|
2702
|
+
this.injector = injector;
|
|
2703
|
+
this.state = state;
|
|
2704
|
+
this.auth = auth;
|
|
2705
|
+
this.components = [];
|
|
2706
|
+
this.auth.userChanged.subscribe(() => {
|
|
2707
|
+
this.components.forEach(t => t.dirty = true);
|
|
2708
|
+
const info = this.getStateInfo();
|
|
2709
|
+
const check = info && info.guard instanceof AuthGuard ? info.guard.checkRoute(info.route) : Promise.resolve(true);
|
|
2710
|
+
check.then(result => {
|
|
2711
|
+
if (result) {
|
|
2712
|
+
if (!info || !info.dirty)
|
|
2713
|
+
return;
|
|
2714
|
+
info.dirty = false;
|
|
2715
|
+
const component = info.component;
|
|
2716
|
+
if (!info.component)
|
|
2717
|
+
return;
|
|
2718
|
+
if (info.first) {
|
|
2719
|
+
if (ObjectUtils.isFunction(component.onUserInitialized)) {
|
|
2720
|
+
component.onUserInitialized();
|
|
2721
|
+
}
|
|
2722
|
+
info.first = false;
|
|
2723
|
+
return;
|
|
2724
|
+
}
|
|
2725
|
+
if (ObjectUtils.isFunction(component.onUserChanged)) {
|
|
2726
|
+
component.onUserChanged();
|
|
2727
|
+
}
|
|
2728
|
+
return;
|
|
2729
|
+
}
|
|
2730
|
+
info.guard.getReturnState(info.route).then(returnState => {
|
|
2731
|
+
if (!returnState)
|
|
2732
|
+
return;
|
|
2733
|
+
this.state.navigate(returnState);
|
|
2734
|
+
});
|
|
2735
|
+
});
|
|
2736
|
+
});
|
|
2737
|
+
this.state.subscribe(() => {
|
|
2738
|
+
const info = this.getStateInfo();
|
|
2739
|
+
if (!(info === null || info === void 0 ? void 0 : info.component))
|
|
2740
|
+
return;
|
|
2741
|
+
const component = info.component;
|
|
2742
|
+
if (ObjectUtils.isFunction(component.onUserInitialized)) {
|
|
2743
|
+
component.onUserInitialized();
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
getStateInfo() {
|
|
2748
|
+
const route = this.state.route;
|
|
2749
|
+
if (!route)
|
|
2750
|
+
return null;
|
|
2751
|
+
let info = this.components.find(t => t.route == this.state.route);
|
|
2752
|
+
if (!info) {
|
|
2753
|
+
const guardType = (route.canActivate || emptyGuards)[0];
|
|
2754
|
+
info = {
|
|
2755
|
+
route: this.state.route,
|
|
2756
|
+
guard: guardType ? this.injector.get(guardType) : null,
|
|
2757
|
+
dirty: true,
|
|
2758
|
+
first: true
|
|
2759
|
+
};
|
|
2760
|
+
this.components.push(info);
|
|
2761
|
+
}
|
|
2762
|
+
info.component = this.state.component;
|
|
2763
|
+
return info;
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
AclService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AclService, deps: [{ token: i0.Injector }, { token: StateService }, { token: AUTH_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2767
|
+
AclService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AclService });
|
|
2768
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AclService, decorators: [{
|
|
2769
|
+
type: Injectable
|
|
2770
|
+
}], ctorParameters: function () {
|
|
2771
|
+
return [{ type: i0.Injector }, { type: StateService }, { type: undefined, decorators: [{
|
|
2772
|
+
type: Inject,
|
|
2773
|
+
args: [AUTH_SERVICE]
|
|
2774
|
+
}] }];
|
|
2775
|
+
} });
|
|
2776
|
+
|
|
2542
2777
|
class ApiService extends BaseHttpService {
|
|
2543
2778
|
get name() {
|
|
2544
2779
|
return "api";
|
|
@@ -5130,6 +5365,7 @@ const providers = [
|
|
|
5130
5365
|
GlobalTemplateService,
|
|
5131
5366
|
IconService,
|
|
5132
5367
|
LanguageService,
|
|
5368
|
+
LocalHttpService,
|
|
5133
5369
|
OpenApiService,
|
|
5134
5370
|
PromiseService,
|
|
5135
5371
|
StateService,
|
|
@@ -5138,6 +5374,7 @@ const providers = [
|
|
|
5138
5374
|
ConsoleToasterService,
|
|
5139
5375
|
TranslatedUrlSerializer,
|
|
5140
5376
|
UniversalService,
|
|
5377
|
+
WasmService,
|
|
5141
5378
|
DeviceDetectorService,
|
|
5142
5379
|
{
|
|
5143
5380
|
provide: EVENT_MANAGER_PLUGINS,
|
|
@@ -5162,6 +5399,159 @@ function loadConfig(config) {
|
|
|
5162
5399
|
return config.load;
|
|
5163
5400
|
}
|
|
5164
5401
|
|
|
5402
|
+
class Wasi {
|
|
5403
|
+
constructor() {
|
|
5404
|
+
this.env = {};
|
|
5405
|
+
this.instantiated = false;
|
|
5406
|
+
this.wasi = [
|
|
5407
|
+
"emscripten_notify_memory_growth",
|
|
5408
|
+
"proc_exit",
|
|
5409
|
+
"environ_get",
|
|
5410
|
+
"environ_sizes_get",
|
|
5411
|
+
"fd_close",
|
|
5412
|
+
"fd_write",
|
|
5413
|
+
"fd_read",
|
|
5414
|
+
"fd_seek",
|
|
5415
|
+
].reduce((res, key) => {
|
|
5416
|
+
if (typeof this[key] === "function") {
|
|
5417
|
+
res[key] = this[key].bind(this);
|
|
5418
|
+
}
|
|
5419
|
+
return res;
|
|
5420
|
+
}, {});
|
|
5421
|
+
}
|
|
5422
|
+
instantiate(bytes) {
|
|
5423
|
+
if (this.instantiated) {
|
|
5424
|
+
throw new Error("WASI already instantiated");
|
|
5425
|
+
}
|
|
5426
|
+
this.instantiated = true;
|
|
5427
|
+
return WebAssembly.instantiate(bytes, {
|
|
5428
|
+
wasi_snapshot_preview1: this.wasi,
|
|
5429
|
+
env: this.wasi
|
|
5430
|
+
}).then(module => {
|
|
5431
|
+
const exports = module.instance.exports;
|
|
5432
|
+
this.wasm = Object.assign(Object.assign({}, exports), { writeArrayToMemory: (array) => {
|
|
5433
|
+
const bytes = array.length * array.BYTES_PER_ELEMENT;
|
|
5434
|
+
const pointer = exports.malloc(bytes);
|
|
5435
|
+
const ctr = array.constructor;
|
|
5436
|
+
const heapArray = new ctr(this.wasm.memory.buffer, pointer, array.length);
|
|
5437
|
+
heapArray.set(array);
|
|
5438
|
+
return pointer;
|
|
5439
|
+
}, readArrayFromMemory: (pointer, array) => {
|
|
5440
|
+
const ctr = array.constructor;
|
|
5441
|
+
const heapArray = new ctr(this.wasm.memory.buffer, pointer, array.length);
|
|
5442
|
+
array.set(heapArray);
|
|
5443
|
+
return array;
|
|
5444
|
+
} });
|
|
5445
|
+
this.updateMemoryViews();
|
|
5446
|
+
return this.wasm;
|
|
5447
|
+
});
|
|
5448
|
+
}
|
|
5449
|
+
updateMemoryViews() {
|
|
5450
|
+
const buffer = this.wasm.memory.buffer;
|
|
5451
|
+
this.wasm.HEAP8 = new Int8Array(buffer);
|
|
5452
|
+
this.wasm.HEAP16 = new Int16Array(buffer);
|
|
5453
|
+
this.wasm.HEAP32 = new Int32Array(buffer);
|
|
5454
|
+
this.wasm.HEAPU8 = new Uint8Array(buffer);
|
|
5455
|
+
this.wasm.HEAPU16 = new Uint16Array(buffer);
|
|
5456
|
+
this.wasm.HEAPU32 = new Uint32Array(buffer);
|
|
5457
|
+
this.wasm.HEAPF32 = new Float32Array(buffer);
|
|
5458
|
+
this.wasm.HEAPF64 = new Float64Array(buffer);
|
|
5459
|
+
}
|
|
5460
|
+
getEnvStrings() {
|
|
5461
|
+
if (!this.envStrings) {
|
|
5462
|
+
let x;
|
|
5463
|
+
const env = {};
|
|
5464
|
+
for (x in this.env) {
|
|
5465
|
+
if (this.env[x] === undefined)
|
|
5466
|
+
delete env[x];
|
|
5467
|
+
else
|
|
5468
|
+
env[x] = this.env[x];
|
|
5469
|
+
}
|
|
5470
|
+
const strings = [];
|
|
5471
|
+
for (x in env) {
|
|
5472
|
+
strings.push(x + "=" + env[x]);
|
|
5473
|
+
}
|
|
5474
|
+
this.envStrings = strings;
|
|
5475
|
+
}
|
|
5476
|
+
return this.envStrings;
|
|
5477
|
+
}
|
|
5478
|
+
stringToAscii(str, buffer) {
|
|
5479
|
+
const HEAP8 = this.wasm.HEAP8;
|
|
5480
|
+
for (let i = 0; i < str.length; ++i) {
|
|
5481
|
+
HEAP8[buffer++ >> 0] = str.charCodeAt(i);
|
|
5482
|
+
}
|
|
5483
|
+
HEAP8[buffer >> 0] = 0;
|
|
5484
|
+
}
|
|
5485
|
+
emscripten_notify_memory_growth(memoryIndex) {
|
|
5486
|
+
this.updateMemoryViews();
|
|
5487
|
+
}
|
|
5488
|
+
proc_exit(rval) {
|
|
5489
|
+
console.log("proc_exit", rval);
|
|
5490
|
+
}
|
|
5491
|
+
environ_get(environ, environ_buf) {
|
|
5492
|
+
if (!this.wasm.HEAP8.byteLength) {
|
|
5493
|
+
this.emscripten_notify_memory_growth(0);
|
|
5494
|
+
}
|
|
5495
|
+
const HEAPU32 = this.wasm.HEAPU32;
|
|
5496
|
+
let bufSize = 0;
|
|
5497
|
+
this.getEnvStrings().forEach((str, i) => {
|
|
5498
|
+
const ptr = environ_buf + bufSize;
|
|
5499
|
+
HEAPU32[environ + i * 4 >> 2] = ptr;
|
|
5500
|
+
this.stringToAscii(str, ptr);
|
|
5501
|
+
bufSize += str.length + 1;
|
|
5502
|
+
});
|
|
5503
|
+
return 0;
|
|
5504
|
+
}
|
|
5505
|
+
environ_sizes_get(penviron_count, penviron_buf_size) {
|
|
5506
|
+
if (!this.wasm.HEAP8.byteLength) {
|
|
5507
|
+
this.emscripten_notify_memory_growth(0);
|
|
5508
|
+
}
|
|
5509
|
+
const HEAPU32 = this.wasm.HEAPU32;
|
|
5510
|
+
const strings = this.getEnvStrings();
|
|
5511
|
+
HEAPU32[penviron_count >> 2] = strings.length;
|
|
5512
|
+
let bufSize = 0;
|
|
5513
|
+
strings.forEach(function (string) {
|
|
5514
|
+
bufSize += string.length + 1;
|
|
5515
|
+
});
|
|
5516
|
+
HEAPU32[penviron_buf_size >> 2] = bufSize;
|
|
5517
|
+
// WASI_ESUCCESS
|
|
5518
|
+
return 0;
|
|
5519
|
+
}
|
|
5520
|
+
fd_close(fd) {
|
|
5521
|
+
// WASI_ESUCCESS
|
|
5522
|
+
return 0;
|
|
5523
|
+
}
|
|
5524
|
+
fd_write(fd, iovs, iovs_len, nwritten) {
|
|
5525
|
+
if (fd !== 1) {
|
|
5526
|
+
// WASI_EBADF
|
|
5527
|
+
return 8;
|
|
5528
|
+
}
|
|
5529
|
+
if (iovs_len !== 1) {
|
|
5530
|
+
// WASI_ENOSYS
|
|
5531
|
+
return 52;
|
|
5532
|
+
}
|
|
5533
|
+
this.wasm.HEAPU32[nwritten >> 2] = this.wasm.HEAPU32[iovs + 4 >> 2];
|
|
5534
|
+
// WASI_ESUCCESS
|
|
5535
|
+
return 0;
|
|
5536
|
+
}
|
|
5537
|
+
fd_read(fd, iovs, iovs_len, nread) {
|
|
5538
|
+
// WASI_EINVAL
|
|
5539
|
+
return 28;
|
|
5540
|
+
}
|
|
5541
|
+
fd_seek(fd, offset, whence, newOffset) {
|
|
5542
|
+
// WASI_EINVAL
|
|
5543
|
+
return 28;
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5546
|
+
Wasi.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: Wasi, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5547
|
+
Wasi.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: Wasi, providedIn: "root" });
|
|
5548
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: Wasi, decorators: [{
|
|
5549
|
+
type: Injectable,
|
|
5550
|
+
args: [{
|
|
5551
|
+
providedIn: "root"
|
|
5552
|
+
}]
|
|
5553
|
+
}], ctorParameters: function () { return []; } });
|
|
5554
|
+
|
|
5165
5555
|
function loadBaseUrl() {
|
|
5166
5556
|
if (typeof (document) === "undefined" || typeof (location) === "undefined")
|
|
5167
5557
|
return "/";
|
|
@@ -5232,6 +5622,10 @@ class NgxUtilsModule {
|
|
|
5232
5622
|
provide: GLOBAL_TEMPLATES,
|
|
5233
5623
|
useExisting: (!config ? null : config.globalTemplates) || GlobalTemplateService
|
|
5234
5624
|
},
|
|
5625
|
+
{
|
|
5626
|
+
provide: WASI_IMPLEMENTATION,
|
|
5627
|
+
useExisting: (!config ? null : config.wasiImplementation) || Wasi
|
|
5628
|
+
},
|
|
5235
5629
|
{
|
|
5236
5630
|
provide: APP_BASE_URL,
|
|
5237
5631
|
useFactory: (!config ? null : config.baseUrl) || loadBaseUrl,
|
|
@@ -5289,5 +5683,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
5289
5683
|
* Generated bundle index. Do not edit.
|
|
5290
5684
|
*/
|
|
5291
5685
|
|
|
5292
|
-
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AuthGuard, BASE_CONFIG, BackgroundDirective, BaseHttpClient, BaseHttpService, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChunkPipe, Circle, ConfigService, ConsoleToasterService, DateUtils, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FileSystemEntry, FileUtils, FilterPipe, FindPipe, FormatNumberPipe, FormatterService, GLOBAL_TEMPLATES, GenericValue, GetOffsetPipe, GetTypePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_SERVICE, IConfiguration, IconDirective, IconService, Initializer, IsTypePipe, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UnorederedListTemplate, ValuedPromise, ValuesPipe, Vector };
|
|
5686
|
+
export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AuthGuard, BASE_CONFIG, BackgroundDirective, BaseHttpClient, BaseHttpService, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChunkPipe, Circle, ConfigService, ConsoleToasterService, DateUtils, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FileSystemEntry, FileUtils, FilterPipe, FindPipe, FormatNumberPipe, FormatterService, GLOBAL_TEMPLATES, GenericValue, GetOffsetPipe, GetTypePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_SERVICE, IConfiguration, IconDirective, IconService, Initializer, IsTypePipe, JSONfn, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, UnorederedListTemplate, ValuedPromise, ValuesPipe, Vector, WASI_IMPLEMENTATION, WasmService };
|
|
5293
5687
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|