@stemy/ngx-utils 12.2.9 → 12.2.11
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/bundles/stemy-ngx-utils.umd.js +4 -3
- package/bundles/stemy-ngx-utils.umd.js.map +1 -1
- package/esm2015/ngx-utils/pipes/replace.pipe.js +3 -2
- package/esm2015/ngx-utils/services/formatter.service.js +4 -3
- 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/pipes/replace.pipe.mjs +3 -2
- package/esm2020/ngx-utils/services/base-http.service.mjs +9 -5
- 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/universal.service.mjs +2 -2
- package/esm2020/ngx-utils/services/wasm.service.mjs +46 -0
- package/esm2020/ngx-utils/utils/date.utils.mjs +5 -4
- package/esm2020/ngx-utils/utils/jsonfn.mjs +45 -0
- package/esm2020/ngx-utils/utils/object.utils.mjs +3 -3
- 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.js +4 -3
- package/fesm2015/stemy-ngx-utils.js.map +1 -1
- package/fesm2015/stemy-ngx-utils.mjs +478 -81
- package/fesm2015/stemy-ngx-utils.mjs.map +1 -1
- package/fesm2020/stemy-ngx-utils.mjs +473 -79
- package/fesm2020/stemy-ngx-utils.mjs.map +1 -1
- package/ngx-utils/services/formatter.service.d.ts +1 -1
- 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/stemy-ngx-utils.metadata.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, TemplateRef, PLATFORM_ID, Injectable, Inject, Optional, Injector, EventEmitter, isDevMode, ErrorHandler, NgZone, Pipe, Directive, Input, Output, HostBinding, HostListener, Component, ContentChildren, ViewChild, ContentChild, APP_INITIALIZER, NgModule } from '@angular/core';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
|
-
import
|
|
4
|
+
import moment from 'moment';
|
|
5
5
|
import { first, skipWhile, mergeMap, timeout, map } from 'rxjs/operators';
|
|
6
6
|
import { Subject, BehaviorSubject, Observable, Subscription, from, TimeoutError, combineLatest } from 'rxjs';
|
|
7
7
|
import { Invokable } from 'invokable';
|
|
@@ -22,8 +22,8 @@ import * as i4 from '@angular/forms';
|
|
|
22
22
|
import { FormsModule } from '@angular/forms';
|
|
23
23
|
|
|
24
24
|
const defaultPredicate = () => true;
|
|
25
|
-
const hasBlob = typeof Blob !== "undefined";
|
|
26
|
-
const hasFile = typeof File !== "undefined";
|
|
25
|
+
const hasBlob = typeof Blob !== "undefined" && !!Blob;
|
|
26
|
+
const hasFile = typeof File !== "undefined" && !!File;
|
|
27
27
|
class ObjectUtils {
|
|
28
28
|
static compare(a, b) {
|
|
29
29
|
if ((a === null || b === null) || (typeof a != typeof b)) {
|
|
@@ -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
|
}
|
|
@@ -488,13 +489,14 @@ class DateUtils {
|
|
|
488
489
|
static add(date, amount, unit) {
|
|
489
490
|
return moment(date).add(amount, unit).toDate();
|
|
490
491
|
}
|
|
491
|
-
static businessAdd(date, amount, unit) {
|
|
492
|
+
static businessAdd(date, amount, unit, freeDays = []) {
|
|
492
493
|
const signal = amount < 0 ? -1 : 1;
|
|
494
|
+
const freeMoments = freeDays.map(d => moment(d));
|
|
493
495
|
let remaining = Math.abs(amount);
|
|
494
496
|
let day = date;
|
|
495
497
|
while (remaining) {
|
|
496
498
|
day = DateUtils.add(day, signal, unit);
|
|
497
|
-
if (DateUtils.isBusinessDay(day)) {
|
|
499
|
+
if (DateUtils.isBusinessDay(day) && !freeMoments.some(m => m.isSame(day, "day"))) {
|
|
498
500
|
remaining--;
|
|
499
501
|
}
|
|
500
502
|
}
|
|
@@ -1174,6 +1176,51 @@ class Initializer {
|
|
|
1174
1176
|
}
|
|
1175
1177
|
}
|
|
1176
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
|
+
|
|
1177
1224
|
class LoaderUtils {
|
|
1178
1225
|
static loadScript(src, async = false) {
|
|
1179
1226
|
this.scriptPromises[src] = this.scriptPromises[src] || new Promise((resolve, reject) => {
|
|
@@ -1281,7 +1328,7 @@ class UniversalService {
|
|
|
1281
1328
|
this.platformId = platformId;
|
|
1282
1329
|
this.dds = dds;
|
|
1283
1330
|
const info = this.dds.getDeviceInfo();
|
|
1284
|
-
this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST)/gi.test(info.userAgent);
|
|
1331
|
+
this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST|PostmanRuntime)/gi.test(info.userAgent);
|
|
1285
1332
|
}
|
|
1286
1333
|
get isBrowser() {
|
|
1287
1334
|
return isPlatformBrowser(this.platformId);
|
|
@@ -1361,11 +1408,12 @@ class StateService extends BehaviorSubject {
|
|
|
1361
1408
|
this.universal = universal;
|
|
1362
1409
|
this.router = router;
|
|
1363
1410
|
this.handleRouterEvent = (event) => {
|
|
1411
|
+
var _a;
|
|
1364
1412
|
if (!(event instanceof NavigationEnd))
|
|
1365
1413
|
return;
|
|
1366
1414
|
const routerStateSnapshot = this.router.routerState.snapshot;
|
|
1367
1415
|
let snapshot = routerStateSnapshot.root;
|
|
1368
|
-
let context = this.contexts.getContext("primary");
|
|
1416
|
+
let context = (_a = this.contexts) === null || _a === void 0 ? void 0 : _a.getContext("primary");
|
|
1369
1417
|
let segments = snapshot.url;
|
|
1370
1418
|
const components = [];
|
|
1371
1419
|
const snapshots = [];
|
|
@@ -2081,83 +2129,105 @@ class Vector {
|
|
|
2081
2129
|
}
|
|
2082
2130
|
}
|
|
2083
2131
|
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
const
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
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} ...`);
|
|
2109
2158
|
}
|
|
2110
|
-
|
|
2111
|
-
|
|
2159
|
+
const func = instance[name];
|
|
2160
|
+
const result = func(...args);
|
|
2161
|
+
if (logTimes) {
|
|
2162
|
+
console.timeLog(id, `Called ${name}`);
|
|
2163
|
+
console.timeEnd(id);
|
|
2112
2164
|
}
|
|
2113
|
-
|
|
2114
|
-
}
|
|
2115
|
-
info.guard.getReturnState(info.route).then(returnState => {
|
|
2116
|
-
if (!returnState)
|
|
2117
|
-
return;
|
|
2118
|
-
this.state.navigate(returnState);
|
|
2165
|
+
self.postMessage({ type: "result", payload: { id, result } });
|
|
2119
2166
|
});
|
|
2120
|
-
|
|
2167
|
+
break;
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
class WasmWorkerProxy {
|
|
2172
|
+
constructor(wasmPath, wasi, logTimes = false) {
|
|
2173
|
+
this.methods = new Promise(resolve => {
|
|
2174
|
+
this.onMethods = resolve;
|
|
2121
2175
|
});
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
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
|
+
};
|
|
2129
2194
|
}
|
|
2130
2195
|
});
|
|
2131
2196
|
}
|
|
2132
|
-
|
|
2133
|
-
const
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
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;
|
|
2146
2212
|
}
|
|
2147
|
-
info.component = this.state.component;
|
|
2148
|
-
return info;
|
|
2149
2213
|
}
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
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
|
+
}
|
|
2161
2231
|
|
|
2162
2232
|
class BaseHttpClient extends HttpClient {
|
|
2163
2233
|
constructor(handler) {
|
|
@@ -2256,6 +2326,7 @@ class BaseHttpService {
|
|
|
2256
2326
|
this.requestHeaders = {};
|
|
2257
2327
|
this.requestParams = {};
|
|
2258
2328
|
this.cache = {};
|
|
2329
|
+
this.initService();
|
|
2259
2330
|
}
|
|
2260
2331
|
get name() {
|
|
2261
2332
|
return "base";
|
|
@@ -2270,6 +2341,8 @@ class BaseHttpService {
|
|
|
2270
2341
|
get universal() {
|
|
2271
2342
|
return this.storage.universal;
|
|
2272
2343
|
}
|
|
2344
|
+
initService() {
|
|
2345
|
+
}
|
|
2273
2346
|
url(url) {
|
|
2274
2347
|
return url;
|
|
2275
2348
|
}
|
|
@@ -2434,15 +2507,16 @@ class BaseHttpService {
|
|
|
2434
2507
|
}
|
|
2435
2508
|
const headers = options.headers;
|
|
2436
2509
|
const authKey = "Authorization";
|
|
2437
|
-
// If an authorization header exists and we still have an Unauthorized response prompt the user to log in again
|
|
2510
|
+
// If an authorization header exists, and we still have an Unauthorized response prompt the user to log in again
|
|
2438
2511
|
if (headers.has(authKey) && response.status == 401) {
|
|
2439
2512
|
const pushed = this.pushFailedRequest(url, options, () => {
|
|
2440
2513
|
options.headers = this.makeHeaders(options.originalHeaders);
|
|
2441
2514
|
this.toPromise(url, options, listener).then(resolve, reject);
|
|
2442
2515
|
});
|
|
2443
|
-
if (pushed)
|
|
2516
|
+
if (pushed) {
|
|
2444
2517
|
this.handleUnauthorizedError(absoluteUrl, options, () => reject(response));
|
|
2445
|
-
|
|
2518
|
+
return;
|
|
2519
|
+
}
|
|
2446
2520
|
}
|
|
2447
2521
|
reject(response);
|
|
2448
2522
|
});
|
|
@@ -2450,7 +2524,7 @@ class BaseHttpService {
|
|
|
2450
2524
|
});
|
|
2451
2525
|
}
|
|
2452
2526
|
pushFailedRequest(url, options, req) {
|
|
2453
|
-
if (url.indexOf("
|
|
2527
|
+
if (url.indexOf("token") >= 0 || url === "user")
|
|
2454
2528
|
return false;
|
|
2455
2529
|
BaseHttpService.failedRequests.push(req);
|
|
2456
2530
|
return true;
|
|
@@ -2536,6 +2610,170 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
2536
2610
|
}] }];
|
|
2537
2611
|
} });
|
|
2538
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
|
+
|
|
2539
2777
|
class ApiService extends BaseHttpService {
|
|
2540
2778
|
get name() {
|
|
2541
2779
|
return "api";
|
|
@@ -3869,7 +4107,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
3869
4107
|
|
|
3870
4108
|
class ReplacePipe {
|
|
3871
4109
|
transform(value, from, to) {
|
|
3872
|
-
return value ? value
|
|
4110
|
+
return ObjectUtils.isDefined(value) ? `${value}`.replace(from, to) : ``;
|
|
3873
4111
|
}
|
|
3874
4112
|
}
|
|
3875
4113
|
ReplacePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ReplacePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
@@ -5127,6 +5365,7 @@ const providers = [
|
|
|
5127
5365
|
GlobalTemplateService,
|
|
5128
5366
|
IconService,
|
|
5129
5367
|
LanguageService,
|
|
5368
|
+
LocalHttpService,
|
|
5130
5369
|
OpenApiService,
|
|
5131
5370
|
PromiseService,
|
|
5132
5371
|
StateService,
|
|
@@ -5135,6 +5374,7 @@ const providers = [
|
|
|
5135
5374
|
ConsoleToasterService,
|
|
5136
5375
|
TranslatedUrlSerializer,
|
|
5137
5376
|
UniversalService,
|
|
5377
|
+
WasmService,
|
|
5138
5378
|
DeviceDetectorService,
|
|
5139
5379
|
{
|
|
5140
5380
|
provide: EVENT_MANAGER_PLUGINS,
|
|
@@ -5159,6 +5399,159 @@ function loadConfig(config) {
|
|
|
5159
5399
|
return config.load;
|
|
5160
5400
|
}
|
|
5161
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
|
+
|
|
5162
5555
|
function loadBaseUrl() {
|
|
5163
5556
|
if (typeof (document) === "undefined" || typeof (location) === "undefined")
|
|
5164
5557
|
return "/";
|
|
@@ -5229,6 +5622,10 @@ class NgxUtilsModule {
|
|
|
5229
5622
|
provide: GLOBAL_TEMPLATES,
|
|
5230
5623
|
useExisting: (!config ? null : config.globalTemplates) || GlobalTemplateService
|
|
5231
5624
|
},
|
|
5625
|
+
{
|
|
5626
|
+
provide: WASI_IMPLEMENTATION,
|
|
5627
|
+
useExisting: (!config ? null : config.wasiImplementation) || Wasi
|
|
5628
|
+
},
|
|
5232
5629
|
{
|
|
5233
5630
|
provide: APP_BASE_URL,
|
|
5234
5631
|
useFactory: (!config ? null : config.baseUrl) || loadBaseUrl,
|
|
@@ -5286,5 +5683,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
|
|
|
5286
5683
|
* Generated bundle index. Do not edit.
|
|
5287
5684
|
*/
|
|
5288
5685
|
|
|
5289
|
-
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 };
|
|
5290
5687
|
//# sourceMappingURL=stemy-ngx-utils.mjs.map
|