@stemy/ngx-utils 13.2.3 → 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/state.service.mjs +2 -2
- 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 +465 -70
- package/fesm2015/stemy-ngx-utils.mjs.map +1 -1
- package/fesm2020/stemy-ngx-utils.mjs +460 -68
- 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) => {
|
|
@@ -1362,11 +1408,12 @@ class StateService extends BehaviorSubject {
|
|
|
1362
1408
|
this.universal = universal;
|
|
1363
1409
|
this.router = router;
|
|
1364
1410
|
this.handleRouterEvent = (event) => {
|
|
1411
|
+
var _a;
|
|
1365
1412
|
if (!(event instanceof NavigationEnd))
|
|
1366
1413
|
return;
|
|
1367
1414
|
const routerStateSnapshot = this.router.routerState.snapshot;
|
|
1368
1415
|
let snapshot = routerStateSnapshot.root;
|
|
1369
|
-
let context = this.contexts.getContext("primary");
|
|
1416
|
+
let context = (_a = this.contexts) === null || _a === void 0 ? void 0 : _a.getContext("primary");
|
|
1370
1417
|
let segments = snapshot.url;
|
|
1371
1418
|
const components = [];
|
|
1372
1419
|
const snapshots = [];
|
|
@@ -2082,83 +2129,105 @@ class Vector {
|
|
|
2082
2129
|
}
|
|
2083
2130
|
}
|
|
2084
2131
|
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
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} ...`);
|
|
2110
2158
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2159
|
+
const func = instance[name];
|
|
2160
|
+
const result = func(...args);
|
|
2161
|
+
if (logTimes) {
|
|
2162
|
+
console.timeLog(id, `Called ${name}`);
|
|
2163
|
+
console.timeEnd(id);
|
|
2113
2164
|
}
|
|
2114
|
-
|
|
2115
|
-
}
|
|
2116
|
-
info.guard.getReturnState(info.route).then(returnState => {
|
|
2117
|
-
if (!returnState)
|
|
2118
|
-
return;
|
|
2119
|
-
this.state.navigate(returnState);
|
|
2165
|
+
self.postMessage({ type: "result", payload: { id, result } });
|
|
2120
2166
|
});
|
|
2121
|
-
|
|
2167
|
+
break;
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
class WasmWorkerProxy {
|
|
2172
|
+
constructor(wasmPath, wasi, logTimes = false) {
|
|
2173
|
+
this.methods = new Promise(resolve => {
|
|
2174
|
+
this.onMethods = resolve;
|
|
2122
2175
|
});
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
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
|
+
};
|
|
2130
2194
|
}
|
|
2131
2195
|
});
|
|
2132
2196
|
}
|
|
2133
|
-
|
|
2134
|
-
const
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
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;
|
|
2147
2212
|
}
|
|
2148
|
-
info.component = this.state.component;
|
|
2149
|
-
return info;
|
|
2150
2213
|
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
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
|
+
}
|
|
2162
2231
|
|
|
2163
2232
|
class BaseHttpClient extends HttpClient {
|
|
2164
2233
|
constructor(handler) {
|
|
@@ -2257,6 +2326,7 @@ class BaseHttpService {
|
|
|
2257
2326
|
this.requestHeaders = {};
|
|
2258
2327
|
this.requestParams = {};
|
|
2259
2328
|
this.cache = {};
|
|
2329
|
+
this.initService();
|
|
2260
2330
|
}
|
|
2261
2331
|
get name() {
|
|
2262
2332
|
return "base";
|
|
@@ -2271,6 +2341,8 @@ class BaseHttpService {
|
|
|
2271
2341
|
get universal() {
|
|
2272
2342
|
return this.storage.universal;
|
|
2273
2343
|
}
|
|
2344
|
+
initService() {
|
|
2345
|
+
}
|
|
2274
2346
|
url(url) {
|
|
2275
2347
|
return url;
|
|
2276
2348
|
}
|
|
@@ -2538,6 +2610,170 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
2538
2610
|
}] }];
|
|
2539
2611
|
} });
|
|
2540
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
|
+
|
|
2541
2777
|
class ApiService extends BaseHttpService {
|
|
2542
2778
|
get name() {
|
|
2543
2779
|
return "api";
|
|
@@ -5129,6 +5365,7 @@ const providers = [
|
|
|
5129
5365
|
GlobalTemplateService,
|
|
5130
5366
|
IconService,
|
|
5131
5367
|
LanguageService,
|
|
5368
|
+
LocalHttpService,
|
|
5132
5369
|
OpenApiService,
|
|
5133
5370
|
PromiseService,
|
|
5134
5371
|
StateService,
|
|
@@ -5137,6 +5374,7 @@ const providers = [
|
|
|
5137
5374
|
ConsoleToasterService,
|
|
5138
5375
|
TranslatedUrlSerializer,
|
|
5139
5376
|
UniversalService,
|
|
5377
|
+
WasmService,
|
|
5140
5378
|
DeviceDetectorService,
|
|
5141
5379
|
{
|
|
5142
5380
|
provide: EVENT_MANAGER_PLUGINS,
|
|
@@ -5161,6 +5399,159 @@ function loadConfig(config) {
|
|
|
5161
5399
|
return config.load;
|
|
5162
5400
|
}
|
|
5163
5401
|
|
|
5402
|
+
const WASI_ESUCCESS = 0;
|
|
5403
|
+
const WASI_EBADF = 8;
|
|
5404
|
+
const WASI_EINVAL = 28;
|
|
5405
|
+
const WASI_ENOSYS = 52;
|
|
5406
|
+
const WASI_STDOUT_FILENO = 1;
|
|
5407
|
+
const wasi_fns = [
|
|
5408
|
+
"emscripten_notify_memory_growth",
|
|
5409
|
+
"proc_exit",
|
|
5410
|
+
"environ_get",
|
|
5411
|
+
"environ_sizes_get",
|
|
5412
|
+
"fd_close",
|
|
5413
|
+
"fd_write",
|
|
5414
|
+
"fd_read",
|
|
5415
|
+
"fd_seek",
|
|
5416
|
+
];
|
|
5417
|
+
class Wasi {
|
|
5418
|
+
constructor() {
|
|
5419
|
+
this.env = {};
|
|
5420
|
+
this.instantiated = false;
|
|
5421
|
+
this.wasi = wasi_fns.reduce((res, key) => {
|
|
5422
|
+
if (typeof this[key] === "function") {
|
|
5423
|
+
res[key] = this[key].bind(this);
|
|
5424
|
+
}
|
|
5425
|
+
return res;
|
|
5426
|
+
}, {});
|
|
5427
|
+
}
|
|
5428
|
+
instantiate(bytes) {
|
|
5429
|
+
if (this.instantiated) {
|
|
5430
|
+
throw new Error("WASI already instantiated");
|
|
5431
|
+
}
|
|
5432
|
+
this.instantiated = true;
|
|
5433
|
+
return WebAssembly.instantiate(bytes, {
|
|
5434
|
+
wasi_snapshot_preview1: this.wasi,
|
|
5435
|
+
env: this.wasi
|
|
5436
|
+
}).then(module => {
|
|
5437
|
+
const exports = module.instance.exports;
|
|
5438
|
+
this.wasm = Object.assign(Object.assign({}, exports), { writeArrayToMemory: (array) => {
|
|
5439
|
+
const bytes = array.length * array.BYTES_PER_ELEMENT;
|
|
5440
|
+
const pointer = exports.malloc(bytes);
|
|
5441
|
+
const ctr = array.constructor;
|
|
5442
|
+
const heapArray = new ctr(this.wasm.memory.buffer, pointer, array.length);
|
|
5443
|
+
heapArray.set(array);
|
|
5444
|
+
return pointer;
|
|
5445
|
+
}, readArrayFromMemory: (pointer, array) => {
|
|
5446
|
+
const ctr = array.constructor;
|
|
5447
|
+
const heapArray = new ctr(this.wasm.memory.buffer, pointer, array.length);
|
|
5448
|
+
array.set(heapArray);
|
|
5449
|
+
return array;
|
|
5450
|
+
} });
|
|
5451
|
+
this.updateMemoryViews();
|
|
5452
|
+
return this.wasm;
|
|
5453
|
+
});
|
|
5454
|
+
}
|
|
5455
|
+
updateMemoryViews() {
|
|
5456
|
+
const buffer = this.wasm.memory.buffer;
|
|
5457
|
+
this.wasm.HEAP8 = new Int8Array(buffer);
|
|
5458
|
+
this.wasm.HEAP16 = new Int16Array(buffer);
|
|
5459
|
+
this.wasm.HEAP32 = new Int32Array(buffer);
|
|
5460
|
+
this.wasm.HEAPU8 = new Uint8Array(buffer);
|
|
5461
|
+
this.wasm.HEAPU16 = new Uint16Array(buffer);
|
|
5462
|
+
this.wasm.HEAPU32 = new Uint32Array(buffer);
|
|
5463
|
+
this.wasm.HEAPF32 = new Float32Array(buffer);
|
|
5464
|
+
this.wasm.HEAPF64 = new Float64Array(buffer);
|
|
5465
|
+
}
|
|
5466
|
+
getEnvStrings() {
|
|
5467
|
+
if (!this.envStrings) {
|
|
5468
|
+
let x;
|
|
5469
|
+
const env = {};
|
|
5470
|
+
for (x in this.env) {
|
|
5471
|
+
if (this.env[x] === undefined)
|
|
5472
|
+
delete env[x];
|
|
5473
|
+
else
|
|
5474
|
+
env[x] = this.env[x];
|
|
5475
|
+
}
|
|
5476
|
+
const strings = [];
|
|
5477
|
+
for (x in env) {
|
|
5478
|
+
strings.push(x + "=" + env[x]);
|
|
5479
|
+
}
|
|
5480
|
+
this.envStrings = strings;
|
|
5481
|
+
}
|
|
5482
|
+
return this.envStrings;
|
|
5483
|
+
}
|
|
5484
|
+
stringToAscii(str, buffer) {
|
|
5485
|
+
const HEAP8 = this.wasm.HEAP8;
|
|
5486
|
+
for (let i = 0; i < str.length; ++i) {
|
|
5487
|
+
HEAP8[buffer++ >> 0] = str.charCodeAt(i);
|
|
5488
|
+
}
|
|
5489
|
+
HEAP8[buffer >> 0] = 0;
|
|
5490
|
+
}
|
|
5491
|
+
emscripten_notify_memory_growth(memoryIndex) {
|
|
5492
|
+
this.updateMemoryViews();
|
|
5493
|
+
}
|
|
5494
|
+
proc_exit(rval) {
|
|
5495
|
+
console.log("proc_exit", rval);
|
|
5496
|
+
}
|
|
5497
|
+
environ_get(environ, environ_buf) {
|
|
5498
|
+
if (!this.wasm.HEAP8.byteLength) {
|
|
5499
|
+
this.emscripten_notify_memory_growth(0);
|
|
5500
|
+
}
|
|
5501
|
+
const HEAPU32 = this.wasm.HEAPU32;
|
|
5502
|
+
let bufSize = 0;
|
|
5503
|
+
this.getEnvStrings().forEach((str, i) => {
|
|
5504
|
+
const ptr = environ_buf + bufSize;
|
|
5505
|
+
HEAPU32[environ + i * 4 >> 2] = ptr;
|
|
5506
|
+
this.stringToAscii(str, ptr);
|
|
5507
|
+
bufSize += str.length + 1;
|
|
5508
|
+
});
|
|
5509
|
+
return 0;
|
|
5510
|
+
}
|
|
5511
|
+
environ_sizes_get(penviron_count, penviron_buf_size) {
|
|
5512
|
+
if (!this.wasm.HEAP8.byteLength) {
|
|
5513
|
+
this.emscripten_notify_memory_growth(0);
|
|
5514
|
+
}
|
|
5515
|
+
const HEAPU32 = this.wasm.HEAPU32;
|
|
5516
|
+
const strings = this.getEnvStrings();
|
|
5517
|
+
HEAPU32[penviron_count >> 2] = strings.length;
|
|
5518
|
+
let bufSize = 0;
|
|
5519
|
+
strings.forEach(function (string) {
|
|
5520
|
+
bufSize += string.length + 1;
|
|
5521
|
+
});
|
|
5522
|
+
HEAPU32[penviron_buf_size >> 2] = bufSize;
|
|
5523
|
+
return 0;
|
|
5524
|
+
}
|
|
5525
|
+
fd_close(fd) {
|
|
5526
|
+
return WASI_ESUCCESS;
|
|
5527
|
+
}
|
|
5528
|
+
fd_write(fd, iovs, iovs_len, nwritten) {
|
|
5529
|
+
if (fd !== WASI_STDOUT_FILENO) {
|
|
5530
|
+
return WASI_EBADF;
|
|
5531
|
+
}
|
|
5532
|
+
if (iovs_len !== 1) {
|
|
5533
|
+
return WASI_ENOSYS;
|
|
5534
|
+
}
|
|
5535
|
+
const len = this.wasm.HEAPU32[iovs + 4 >> 2];
|
|
5536
|
+
this.wasm.HEAPU32[nwritten >> 2] = len;
|
|
5537
|
+
return WASI_ESUCCESS;
|
|
5538
|
+
}
|
|
5539
|
+
fd_read(fd, iovs, iovs_len, nread) {
|
|
5540
|
+
return WASI_EINVAL;
|
|
5541
|
+
}
|
|
5542
|
+
fd_seek(fd, offset, whence, newOffset) {
|
|
5543
|
+
return WASI_EINVAL;
|
|
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
|
+
|
|
5164
5555
|
function loadBaseUrl() {
|
|
5165
5556
|
if (typeof (document) === "undefined" || typeof (location) === "undefined")
|
|
5166
5557
|
return "/";
|
|
@@ -5231,6 +5622,10 @@ class NgxUtilsModule {
|
|
|
5231
5622
|
provide: GLOBAL_TEMPLATES,
|
|
5232
5623
|
useExisting: (!config ? null : config.globalTemplates) || GlobalTemplateService
|
|
5233
5624
|
},
|
|
5625
|
+
{
|
|
5626
|
+
provide: WASI_IMPLEMENTATION,
|
|
5627
|
+
useExisting: (!config ? null : config.wasiImplementation) || Wasi
|
|
5628
|
+
},
|
|
5234
5629
|
{
|
|
5235
5630
|
provide: APP_BASE_URL,
|
|
5236
5631
|
useFactory: (!config ? null : config.baseUrl) || loadBaseUrl,
|
|
@@ -5288,5 +5683,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
5288
5683
|
* Generated bundle index. Do not edit.
|
|
5289
5684
|
*/
|
|
5290
5685
|
|
|
5291
|
-
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 };
|
|
5292
5687
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|