@stemy/ngx-utils 13.2.4 → 13.3.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.
- 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
|
@@ -342,6 +342,7 @@ var StorageMode;
|
|
|
342
342
|
})(StorageMode || (StorageMode = {}));
|
|
343
343
|
const TOASTER_SERVICE = new InjectionToken("toaster-service");
|
|
344
344
|
const PROMISE_SERVICE = new InjectionToken("promise-service");
|
|
345
|
+
const WASI_IMPLEMENTATION = new InjectionToken("wasi-implementation");
|
|
345
346
|
// --- Unordered list ---
|
|
346
347
|
class UnorederedListTemplate extends TemplateRef {
|
|
347
348
|
}
|
|
@@ -1174,6 +1175,51 @@ class Initializer {
|
|
|
1174
1175
|
}
|
|
1175
1176
|
}
|
|
1176
1177
|
|
|
1178
|
+
class JSONfn {
|
|
1179
|
+
static parse(text) {
|
|
1180
|
+
return JSON.parse(text, JSONfn.reviver);
|
|
1181
|
+
}
|
|
1182
|
+
static stringify(obj) {
|
|
1183
|
+
return JSON.stringify(obj, JSONfn.replacer);
|
|
1184
|
+
}
|
|
1185
|
+
static reviver(key, value) {
|
|
1186
|
+
const iso8061 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:.\d+)?(?:Z|[+-]\d\d:\d\d)$/;
|
|
1187
|
+
if (typeof value !== "string")
|
|
1188
|
+
return value;
|
|
1189
|
+
if (value.length < 8) {
|
|
1190
|
+
return value;
|
|
1191
|
+
}
|
|
1192
|
+
if (value.match(iso8061)) {
|
|
1193
|
+
return new Date(value);
|
|
1194
|
+
}
|
|
1195
|
+
const prefix = value.substring(0, 8);
|
|
1196
|
+
if (prefix === "function") {
|
|
1197
|
+
return new Function(`return ${value}`)();
|
|
1198
|
+
}
|
|
1199
|
+
if (prefix === "_NuFrRa_") {
|
|
1200
|
+
return new Function(`return ${value.slice(8)}`)();
|
|
1201
|
+
}
|
|
1202
|
+
if (prefix === "_PxEgEr_") {
|
|
1203
|
+
return new Function(`return ${value.slice(8)}`)();
|
|
1204
|
+
}
|
|
1205
|
+
return value;
|
|
1206
|
+
}
|
|
1207
|
+
static replacer(key, value) {
|
|
1208
|
+
if (value instanceof Function || typeof value === "function") {
|
|
1209
|
+
const fnBody = value.toString();
|
|
1210
|
+
if (fnBody.length < 8 || fnBody.substring(0, 8) !== "function") {
|
|
1211
|
+
// this is ES6 Arrow Function
|
|
1212
|
+
return "_NuFrRa_" + fnBody;
|
|
1213
|
+
}
|
|
1214
|
+
return fnBody;
|
|
1215
|
+
}
|
|
1216
|
+
if (value instanceof RegExp) {
|
|
1217
|
+
return "_PxEgEr_" + value;
|
|
1218
|
+
}
|
|
1219
|
+
return value;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1177
1223
|
class LoaderUtils {
|
|
1178
1224
|
static loadScript(src, async = false) {
|
|
1179
1225
|
this.scriptPromises[src] = this.scriptPromises[src] || new Promise((resolve, reject) => {
|
|
@@ -2061,81 +2107,103 @@ class Vector {
|
|
|
2061
2107
|
}
|
|
2062
2108
|
}
|
|
2063
2109
|
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
const
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2110
|
+
function workerFunction(JSONfn, logTimes) {
|
|
2111
|
+
let wasmResolve = null;
|
|
2112
|
+
const wasmInstance = new Promise(resolve => {
|
|
2113
|
+
wasmResolve = resolve;
|
|
2114
|
+
});
|
|
2115
|
+
self.onmessage = function (e) {
|
|
2116
|
+
const data = e.data;
|
|
2117
|
+
const { type, payload } = data;
|
|
2118
|
+
switch (type) {
|
|
2119
|
+
case "wasm":
|
|
2120
|
+
const { url, wasi } = payload;
|
|
2121
|
+
fetch(url).then(response => response.arrayBuffer()).then(bytes => {
|
|
2122
|
+
const wasiImpl = JSONfn.parse(wasi);
|
|
2123
|
+
return new wasiImpl().instantiate(bytes);
|
|
2124
|
+
}).then(instance => {
|
|
2125
|
+
wasmResolve(instance);
|
|
2126
|
+
const methods = Object.getOwnPropertyNames(instance).filter(key => typeof instance[key] === "function");
|
|
2127
|
+
self.postMessage({ type: "methods", payload: methods });
|
|
2128
|
+
});
|
|
2129
|
+
break;
|
|
2130
|
+
case "call":
|
|
2131
|
+
wasmInstance.then(instance => {
|
|
2132
|
+
const { name, id, args } = payload;
|
|
2133
|
+
if (logTimes) {
|
|
2134
|
+
console.time(id);
|
|
2135
|
+
console.timeLog(id, `Calling ${name} ...`);
|
|
2089
2136
|
}
|
|
2090
|
-
|
|
2091
|
-
|
|
2137
|
+
const func = instance[name];
|
|
2138
|
+
const result = func(...args);
|
|
2139
|
+
if (logTimes) {
|
|
2140
|
+
console.timeLog(id, `Called ${name}`);
|
|
2141
|
+
console.timeEnd(id);
|
|
2092
2142
|
}
|
|
2093
|
-
|
|
2094
|
-
}
|
|
2095
|
-
info.guard.getReturnState(info.route).then(returnState => {
|
|
2096
|
-
if (!returnState)
|
|
2097
|
-
return;
|
|
2098
|
-
this.state.navigate(returnState);
|
|
2143
|
+
self.postMessage({ type: "result", payload: { id, result } });
|
|
2099
2144
|
});
|
|
2100
|
-
|
|
2145
|
+
break;
|
|
2146
|
+
}
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
class WasmWorkerProxy {
|
|
2150
|
+
constructor(wasmPath, wasi, logTimes = false) {
|
|
2151
|
+
this.methods = new Promise(resolve => {
|
|
2152
|
+
this.onMethods = resolve;
|
|
2101
2153
|
});
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2154
|
+
const lt = logTimes ? "true" : "false";
|
|
2155
|
+
const blob = new Blob([`${JSONfn.toString()} (${workerFunction.toString()})(JSONfn, ${lt})`], { type: 'application/javascript' });
|
|
2156
|
+
this.worker = new Worker(URL.createObjectURL(blob));
|
|
2157
|
+
this.worker.postMessage({
|
|
2158
|
+
type: "wasm",
|
|
2159
|
+
payload: { url: wasmPath, wasi: JSONfn.stringify(wasi), logTimes }
|
|
2160
|
+
});
|
|
2161
|
+
this.worker.onmessage = this.onMessage.bind(this);
|
|
2162
|
+
this.promises = new Map();
|
|
2163
|
+
return new Proxy(this, {
|
|
2164
|
+
get: (target, prop, receiver) => {
|
|
2165
|
+
const res = Reflect.get(target, prop, receiver);
|
|
2166
|
+
if (res) {
|
|
2167
|
+
return res;
|
|
2168
|
+
}
|
|
2169
|
+
return (...args) => {
|
|
2170
|
+
return this.call(prop.toString(), args);
|
|
2171
|
+
};
|
|
2109
2172
|
}
|
|
2110
2173
|
});
|
|
2111
2174
|
}
|
|
2112
|
-
|
|
2113
|
-
const
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2175
|
+
onMessage(e) {
|
|
2176
|
+
const data = e.data;
|
|
2177
|
+
const { type, payload } = data;
|
|
2178
|
+
switch (type) {
|
|
2179
|
+
case "methods":
|
|
2180
|
+
this.onMethods(payload);
|
|
2181
|
+
break;
|
|
2182
|
+
case "result":
|
|
2183
|
+
const { id, result } = payload;
|
|
2184
|
+
const promise = this.promises.get(id);
|
|
2185
|
+
if (promise) {
|
|
2186
|
+
promise.resolve(result);
|
|
2187
|
+
this.promises.delete(id);
|
|
2188
|
+
}
|
|
2189
|
+
break;
|
|
2126
2190
|
}
|
|
2127
|
-
info.component = this.state.component;
|
|
2128
|
-
return info;
|
|
2129
2191
|
}
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2192
|
+
async call(method, args) {
|
|
2193
|
+
const methods = await this.methods;
|
|
2194
|
+
if (!methods.includes(method)) {
|
|
2195
|
+
throw new Error(`Method ${method} not found`);
|
|
2196
|
+
}
|
|
2197
|
+
return new Promise((resolve, reject) => {
|
|
2198
|
+
const id = Math.random().toString(36).substring(2, 9);
|
|
2199
|
+
this.worker.postMessage({
|
|
2200
|
+
type: "call",
|
|
2201
|
+
payload: { name: method, id, args }
|
|
2202
|
+
});
|
|
2203
|
+
this.promises.set(id, { resolve, reject });
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2139
2207
|
|
|
2140
2208
|
class BaseHttpClient extends HttpClient {
|
|
2141
2209
|
constructor(handler) {
|
|
@@ -2234,6 +2302,7 @@ class BaseHttpService {
|
|
|
2234
2302
|
this.requestHeaders = {};
|
|
2235
2303
|
this.requestParams = {};
|
|
2236
2304
|
this.cache = {};
|
|
2305
|
+
this.initService();
|
|
2237
2306
|
}
|
|
2238
2307
|
get name() {
|
|
2239
2308
|
return "base";
|
|
@@ -2248,6 +2317,8 @@ class BaseHttpService {
|
|
|
2248
2317
|
get universal() {
|
|
2249
2318
|
return this.storage.universal;
|
|
2250
2319
|
}
|
|
2320
|
+
initService() {
|
|
2321
|
+
}
|
|
2251
2322
|
url(url) {
|
|
2252
2323
|
return url;
|
|
2253
2324
|
}
|
|
@@ -2510,6 +2581,164 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
2510
2581
|
args: [EXPRESS_REQUEST]
|
|
2511
2582
|
}] }]; } });
|
|
2512
2583
|
|
|
2584
|
+
class LocalHttpService extends BaseHttpService {
|
|
2585
|
+
get name() {
|
|
2586
|
+
return "local-http";
|
|
2587
|
+
}
|
|
2588
|
+
get withCredentials() {
|
|
2589
|
+
return false;
|
|
2590
|
+
}
|
|
2591
|
+
initService() {
|
|
2592
|
+
this.images = {};
|
|
2593
|
+
}
|
|
2594
|
+
url(url) {
|
|
2595
|
+
if (!url)
|
|
2596
|
+
return url;
|
|
2597
|
+
const config = this.configs.config;
|
|
2598
|
+
const baseUrl = config.cdnUrl || config.baseUrl || "";
|
|
2599
|
+
return url.startsWith("data:") || url.startsWith("http") || url.startsWith("//")
|
|
2600
|
+
? url
|
|
2601
|
+
: `${baseUrl}${url}`;
|
|
2602
|
+
}
|
|
2603
|
+
get(url, options) {
|
|
2604
|
+
this.cache[url] = this.cache[url] || this.getPromise(url, options);
|
|
2605
|
+
return this.cache[url];
|
|
2606
|
+
}
|
|
2607
|
+
getImage(url) {
|
|
2608
|
+
if (this.universal.isServer)
|
|
2609
|
+
return Promise.resolve(null);
|
|
2610
|
+
if (!url)
|
|
2611
|
+
return Promise.resolve(new Image());
|
|
2612
|
+
this.images[url] = this.images[url] || new Promise((resolve, reject) => {
|
|
2613
|
+
const image = new Image();
|
|
2614
|
+
image.crossOrigin = "Anonymous";
|
|
2615
|
+
image.src = this.url(url);
|
|
2616
|
+
image.onload = () => resolve(image);
|
|
2617
|
+
image.onerror = reject;
|
|
2618
|
+
});
|
|
2619
|
+
return this.images[url];
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
LocalHttpService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: LocalHttpService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
2623
|
+
LocalHttpService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: LocalHttpService });
|
|
2624
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: LocalHttpService, decorators: [{
|
|
2625
|
+
type: Injectable
|
|
2626
|
+
}] });
|
|
2627
|
+
|
|
2628
|
+
/**
|
|
2629
|
+
* Use this service to load WebAssembly modules
|
|
2630
|
+
*/
|
|
2631
|
+
class WasmService {
|
|
2632
|
+
constructor(universal, http, wasi) {
|
|
2633
|
+
this.universal = universal;
|
|
2634
|
+
this.http = http;
|
|
2635
|
+
this.wasi = wasi.constructor;
|
|
2636
|
+
}
|
|
2637
|
+
async getModule(name) {
|
|
2638
|
+
if (!this.universal.isBrowser || !name)
|
|
2639
|
+
return null;
|
|
2640
|
+
this.modules = this.modules || {};
|
|
2641
|
+
this.modules[name] = this.modules[name] || this.http.get(`wasm/${name}.wasm`, {
|
|
2642
|
+
responseType: "arraybuffer"
|
|
2643
|
+
}).then(async (bytes) => {
|
|
2644
|
+
const wasi = new this.wasi();
|
|
2645
|
+
return await wasi.instantiate(bytes);
|
|
2646
|
+
});
|
|
2647
|
+
return this.modules[name];
|
|
2648
|
+
}
|
|
2649
|
+
getWorkerModule(name) {
|
|
2650
|
+
if (!this.universal.isBrowser || !name)
|
|
2651
|
+
return null;
|
|
2652
|
+
this.workerModules = this.workerModules || {};
|
|
2653
|
+
this.workerModules[name] = new WasmWorkerProxy(this.http.url(`wasm/${name}.wasm`), this.wasi);
|
|
2654
|
+
return this.workerModules[name];
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
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 });
|
|
2658
|
+
WasmService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: WasmService });
|
|
2659
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: WasmService, decorators: [{
|
|
2660
|
+
type: Injectable
|
|
2661
|
+
}], ctorParameters: function () { return [{ type: UniversalService }, { type: LocalHttpService }, { type: undefined, decorators: [{
|
|
2662
|
+
type: Inject,
|
|
2663
|
+
args: [WASI_IMPLEMENTATION]
|
|
2664
|
+
}] }]; } });
|
|
2665
|
+
|
|
2666
|
+
const emptyGuards = [];
|
|
2667
|
+
class AclService {
|
|
2668
|
+
constructor(injector, state, auth) {
|
|
2669
|
+
this.injector = injector;
|
|
2670
|
+
this.state = state;
|
|
2671
|
+
this.auth = auth;
|
|
2672
|
+
this.components = [];
|
|
2673
|
+
this.auth.userChanged.subscribe(() => {
|
|
2674
|
+
this.components.forEach(t => t.dirty = true);
|
|
2675
|
+
const info = this.getStateInfo();
|
|
2676
|
+
const check = info && info.guard instanceof AuthGuard ? info.guard.checkRoute(info.route) : Promise.resolve(true);
|
|
2677
|
+
check.then(result => {
|
|
2678
|
+
if (result) {
|
|
2679
|
+
if (!info || !info.dirty)
|
|
2680
|
+
return;
|
|
2681
|
+
info.dirty = false;
|
|
2682
|
+
const component = info.component;
|
|
2683
|
+
if (!info.component)
|
|
2684
|
+
return;
|
|
2685
|
+
if (info.first) {
|
|
2686
|
+
if (ObjectUtils.isFunction(component.onUserInitialized)) {
|
|
2687
|
+
component.onUserInitialized();
|
|
2688
|
+
}
|
|
2689
|
+
info.first = false;
|
|
2690
|
+
return;
|
|
2691
|
+
}
|
|
2692
|
+
if (ObjectUtils.isFunction(component.onUserChanged)) {
|
|
2693
|
+
component.onUserChanged();
|
|
2694
|
+
}
|
|
2695
|
+
return;
|
|
2696
|
+
}
|
|
2697
|
+
info.guard.getReturnState(info.route).then(returnState => {
|
|
2698
|
+
if (!returnState)
|
|
2699
|
+
return;
|
|
2700
|
+
this.state.navigate(returnState);
|
|
2701
|
+
});
|
|
2702
|
+
});
|
|
2703
|
+
});
|
|
2704
|
+
this.state.subscribe(() => {
|
|
2705
|
+
const info = this.getStateInfo();
|
|
2706
|
+
if (!info?.component)
|
|
2707
|
+
return;
|
|
2708
|
+
const component = info.component;
|
|
2709
|
+
if (ObjectUtils.isFunction(component.onUserInitialized)) {
|
|
2710
|
+
component.onUserInitialized();
|
|
2711
|
+
}
|
|
2712
|
+
});
|
|
2713
|
+
}
|
|
2714
|
+
getStateInfo() {
|
|
2715
|
+
const route = this.state.route;
|
|
2716
|
+
if (!route)
|
|
2717
|
+
return null;
|
|
2718
|
+
let info = this.components.find(t => t.route == this.state.route);
|
|
2719
|
+
if (!info) {
|
|
2720
|
+
const guardType = (route.canActivate || emptyGuards)[0];
|
|
2721
|
+
info = {
|
|
2722
|
+
route: this.state.route,
|
|
2723
|
+
guard: guardType ? this.injector.get(guardType) : null,
|
|
2724
|
+
dirty: true,
|
|
2725
|
+
first: true
|
|
2726
|
+
};
|
|
2727
|
+
this.components.push(info);
|
|
2728
|
+
}
|
|
2729
|
+
info.component = this.state.component;
|
|
2730
|
+
return info;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
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 });
|
|
2734
|
+
AclService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AclService });
|
|
2735
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AclService, decorators: [{
|
|
2736
|
+
type: Injectable
|
|
2737
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: StateService }, { type: undefined, decorators: [{
|
|
2738
|
+
type: Inject,
|
|
2739
|
+
args: [AUTH_SERVICE]
|
|
2740
|
+
}] }]; } });
|
|
2741
|
+
|
|
2513
2742
|
class ApiService extends BaseHttpService {
|
|
2514
2743
|
get name() {
|
|
2515
2744
|
return "api";
|
|
@@ -5059,6 +5288,7 @@ const providers = [
|
|
|
5059
5288
|
GlobalTemplateService,
|
|
5060
5289
|
IconService,
|
|
5061
5290
|
LanguageService,
|
|
5291
|
+
LocalHttpService,
|
|
5062
5292
|
OpenApiService,
|
|
5063
5293
|
PromiseService,
|
|
5064
5294
|
StateService,
|
|
@@ -5067,6 +5297,7 @@ const providers = [
|
|
|
5067
5297
|
ConsoleToasterService,
|
|
5068
5298
|
TranslatedUrlSerializer,
|
|
5069
5299
|
UniversalService,
|
|
5300
|
+
WasmService,
|
|
5070
5301
|
DeviceDetectorService,
|
|
5071
5302
|
{
|
|
5072
5303
|
provide: EVENT_MANAGER_PLUGINS,
|
|
@@ -5091,6 +5322,163 @@ function loadConfig(config) {
|
|
|
5091
5322
|
return config.load;
|
|
5092
5323
|
}
|
|
5093
5324
|
|
|
5325
|
+
const WASI_ESUCCESS = 0;
|
|
5326
|
+
const WASI_EBADF = 8;
|
|
5327
|
+
const WASI_EINVAL = 28;
|
|
5328
|
+
const WASI_ENOSYS = 52;
|
|
5329
|
+
const WASI_STDOUT_FILENO = 1;
|
|
5330
|
+
const wasi_fns = [
|
|
5331
|
+
"emscripten_notify_memory_growth",
|
|
5332
|
+
"proc_exit",
|
|
5333
|
+
"environ_get",
|
|
5334
|
+
"environ_sizes_get",
|
|
5335
|
+
"fd_close",
|
|
5336
|
+
"fd_write",
|
|
5337
|
+
"fd_read",
|
|
5338
|
+
"fd_seek",
|
|
5339
|
+
];
|
|
5340
|
+
class Wasi {
|
|
5341
|
+
constructor() {
|
|
5342
|
+
this.env = {};
|
|
5343
|
+
this.instantiated = false;
|
|
5344
|
+
this.wasi = wasi_fns.reduce((res, key) => {
|
|
5345
|
+
if (typeof this[key] === "function") {
|
|
5346
|
+
res[key] = this[key].bind(this);
|
|
5347
|
+
}
|
|
5348
|
+
return res;
|
|
5349
|
+
}, {});
|
|
5350
|
+
}
|
|
5351
|
+
instantiate(bytes) {
|
|
5352
|
+
if (this.instantiated) {
|
|
5353
|
+
throw new Error("WASI already instantiated");
|
|
5354
|
+
}
|
|
5355
|
+
this.instantiated = true;
|
|
5356
|
+
return WebAssembly.instantiate(bytes, {
|
|
5357
|
+
wasi_snapshot_preview1: this.wasi,
|
|
5358
|
+
env: this.wasi
|
|
5359
|
+
}).then(module => {
|
|
5360
|
+
const exports = module.instance.exports;
|
|
5361
|
+
this.wasm = {
|
|
5362
|
+
...exports,
|
|
5363
|
+
writeArrayToMemory: (array) => {
|
|
5364
|
+
const bytes = array.length * array.BYTES_PER_ELEMENT;
|
|
5365
|
+
const pointer = exports.malloc(bytes);
|
|
5366
|
+
const ctr = array.constructor;
|
|
5367
|
+
const heapArray = new ctr(this.wasm.memory.buffer, pointer, array.length);
|
|
5368
|
+
heapArray.set(array);
|
|
5369
|
+
return pointer;
|
|
5370
|
+
},
|
|
5371
|
+
readArrayFromMemory: (pointer, array) => {
|
|
5372
|
+
const ctr = array.constructor;
|
|
5373
|
+
const heapArray = new ctr(this.wasm.memory.buffer, pointer, array.length);
|
|
5374
|
+
array.set(heapArray);
|
|
5375
|
+
return array;
|
|
5376
|
+
}
|
|
5377
|
+
};
|
|
5378
|
+
this.updateMemoryViews();
|
|
5379
|
+
return this.wasm;
|
|
5380
|
+
});
|
|
5381
|
+
}
|
|
5382
|
+
updateMemoryViews() {
|
|
5383
|
+
const buffer = this.wasm.memory.buffer;
|
|
5384
|
+
this.wasm.HEAP8 = new Int8Array(buffer);
|
|
5385
|
+
this.wasm.HEAP16 = new Int16Array(buffer);
|
|
5386
|
+
this.wasm.HEAP32 = new Int32Array(buffer);
|
|
5387
|
+
this.wasm.HEAPU8 = new Uint8Array(buffer);
|
|
5388
|
+
this.wasm.HEAPU16 = new Uint16Array(buffer);
|
|
5389
|
+
this.wasm.HEAPU32 = new Uint32Array(buffer);
|
|
5390
|
+
this.wasm.HEAPF32 = new Float32Array(buffer);
|
|
5391
|
+
this.wasm.HEAPF64 = new Float64Array(buffer);
|
|
5392
|
+
}
|
|
5393
|
+
getEnvStrings() {
|
|
5394
|
+
if (!this.envStrings) {
|
|
5395
|
+
let x;
|
|
5396
|
+
const env = {};
|
|
5397
|
+
for (x in this.env) {
|
|
5398
|
+
if (this.env[x] === undefined)
|
|
5399
|
+
delete env[x];
|
|
5400
|
+
else
|
|
5401
|
+
env[x] = this.env[x];
|
|
5402
|
+
}
|
|
5403
|
+
const strings = [];
|
|
5404
|
+
for (x in env) {
|
|
5405
|
+
strings.push(x + "=" + env[x]);
|
|
5406
|
+
}
|
|
5407
|
+
this.envStrings = strings;
|
|
5408
|
+
}
|
|
5409
|
+
return this.envStrings;
|
|
5410
|
+
}
|
|
5411
|
+
stringToAscii(str, buffer) {
|
|
5412
|
+
const HEAP8 = this.wasm.HEAP8;
|
|
5413
|
+
for (let i = 0; i < str.length; ++i) {
|
|
5414
|
+
HEAP8[buffer++ >> 0] = str.charCodeAt(i);
|
|
5415
|
+
}
|
|
5416
|
+
HEAP8[buffer >> 0] = 0;
|
|
5417
|
+
}
|
|
5418
|
+
emscripten_notify_memory_growth(memoryIndex) {
|
|
5419
|
+
this.updateMemoryViews();
|
|
5420
|
+
}
|
|
5421
|
+
proc_exit(rval) {
|
|
5422
|
+
console.log("proc_exit", rval);
|
|
5423
|
+
}
|
|
5424
|
+
environ_get(environ, environ_buf) {
|
|
5425
|
+
if (!this.wasm.HEAP8.byteLength) {
|
|
5426
|
+
this.emscripten_notify_memory_growth(0);
|
|
5427
|
+
}
|
|
5428
|
+
const HEAPU32 = this.wasm.HEAPU32;
|
|
5429
|
+
let bufSize = 0;
|
|
5430
|
+
this.getEnvStrings().forEach((str, i) => {
|
|
5431
|
+
const ptr = environ_buf + bufSize;
|
|
5432
|
+
HEAPU32[environ + i * 4 >> 2] = ptr;
|
|
5433
|
+
this.stringToAscii(str, ptr);
|
|
5434
|
+
bufSize += str.length + 1;
|
|
5435
|
+
});
|
|
5436
|
+
return 0;
|
|
5437
|
+
}
|
|
5438
|
+
environ_sizes_get(penviron_count, penviron_buf_size) {
|
|
5439
|
+
if (!this.wasm.HEAP8.byteLength) {
|
|
5440
|
+
this.emscripten_notify_memory_growth(0);
|
|
5441
|
+
}
|
|
5442
|
+
const HEAPU32 = this.wasm.HEAPU32;
|
|
5443
|
+
const strings = this.getEnvStrings();
|
|
5444
|
+
HEAPU32[penviron_count >> 2] = strings.length;
|
|
5445
|
+
let bufSize = 0;
|
|
5446
|
+
strings.forEach(function (string) {
|
|
5447
|
+
bufSize += string.length + 1;
|
|
5448
|
+
});
|
|
5449
|
+
HEAPU32[penviron_buf_size >> 2] = bufSize;
|
|
5450
|
+
return 0;
|
|
5451
|
+
}
|
|
5452
|
+
fd_close(fd) {
|
|
5453
|
+
return WASI_ESUCCESS;
|
|
5454
|
+
}
|
|
5455
|
+
fd_write(fd, iovs, iovs_len, nwritten) {
|
|
5456
|
+
if (fd !== WASI_STDOUT_FILENO) {
|
|
5457
|
+
return WASI_EBADF;
|
|
5458
|
+
}
|
|
5459
|
+
if (iovs_len !== 1) {
|
|
5460
|
+
return WASI_ENOSYS;
|
|
5461
|
+
}
|
|
5462
|
+
const len = this.wasm.HEAPU32[iovs + 4 >> 2];
|
|
5463
|
+
this.wasm.HEAPU32[nwritten >> 2] = len;
|
|
5464
|
+
return WASI_ESUCCESS;
|
|
5465
|
+
}
|
|
5466
|
+
fd_read(fd, iovs, iovs_len, nread) {
|
|
5467
|
+
return WASI_EINVAL;
|
|
5468
|
+
}
|
|
5469
|
+
fd_seek(fd, offset, whence, newOffset) {
|
|
5470
|
+
return WASI_EINVAL;
|
|
5471
|
+
}
|
|
5472
|
+
}
|
|
5473
|
+
Wasi.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: Wasi, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5474
|
+
Wasi.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: Wasi, providedIn: "root" });
|
|
5475
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: Wasi, decorators: [{
|
|
5476
|
+
type: Injectable,
|
|
5477
|
+
args: [{
|
|
5478
|
+
providedIn: "root"
|
|
5479
|
+
}]
|
|
5480
|
+
}], ctorParameters: function () { return []; } });
|
|
5481
|
+
|
|
5094
5482
|
function loadBaseUrl() {
|
|
5095
5483
|
if (typeof (document) === "undefined" || typeof (location) === "undefined")
|
|
5096
5484
|
return "/";
|
|
@@ -5161,6 +5549,10 @@ class NgxUtilsModule {
|
|
|
5161
5549
|
provide: GLOBAL_TEMPLATES,
|
|
5162
5550
|
useExisting: (!config ? null : config.globalTemplates) || GlobalTemplateService
|
|
5163
5551
|
},
|
|
5552
|
+
{
|
|
5553
|
+
provide: WASI_IMPLEMENTATION,
|
|
5554
|
+
useExisting: (!config ? null : config.wasiImplementation) || Wasi
|
|
5555
|
+
},
|
|
5164
5556
|
{
|
|
5165
5557
|
provide: APP_BASE_URL,
|
|
5166
5558
|
useFactory: (!config ? null : config.baseUrl) || loadBaseUrl,
|
|
@@ -5218,5 +5610,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
5218
5610
|
* Generated bundle index. Do not edit.
|
|
5219
5611
|
*/
|
|
5220
5612
|
|
|
5221
|
-
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 };
|
|
5613
|
+
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 };
|
|
5222
5614
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|