@stemy/ngx-utils 12.2.10 → 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.
Files changed (31) hide show
  1. package/bundles/stemy-ngx-utils.umd.js +3 -2
  2. package/bundles/stemy-ngx-utils.umd.js.map +1 -1
  3. package/esm2015/ngx-utils/services/formatter.service.js +4 -3
  4. package/esm2020/ngx-utils/common-types.mjs +2 -1
  5. package/esm2020/ngx-utils/ngx-utils.imports.mjs +5 -1
  6. package/esm2020/ngx-utils/ngx-utils.module.mjs +7 -2
  7. package/esm2020/ngx-utils/pipes/replace.pipe.mjs +3 -2
  8. package/esm2020/ngx-utils/services/base-http.service.mjs +9 -5
  9. package/esm2020/ngx-utils/services/local-http.service.mjs +47 -0
  10. package/esm2020/ngx-utils/services/state.service.mjs +2 -2
  11. package/esm2020/ngx-utils/services/universal.service.mjs +2 -2
  12. package/esm2020/ngx-utils/services/wasm.service.mjs +46 -0
  13. package/esm2020/ngx-utils/utils/date.utils.mjs +5 -4
  14. package/esm2020/ngx-utils/utils/jsonfn.mjs +45 -0
  15. package/esm2020/ngx-utils/utils/object.utils.mjs +3 -3
  16. package/esm2020/ngx-utils/utils/wasi.mjs +159 -0
  17. package/esm2020/ngx-utils/utils/wasm-worker-proxy.mjs +99 -0
  18. package/esm2020/public_api.mjs +5 -2
  19. package/fesm2015/stemy-ngx-utils.js +3 -2
  20. package/fesm2015/stemy-ngx-utils.js.map +1 -1
  21. package/fesm2015/stemy-ngx-utils.mjs +478 -81
  22. package/fesm2015/stemy-ngx-utils.mjs.map +1 -1
  23. package/fesm2020/stemy-ngx-utils.mjs +473 -79
  24. package/fesm2020/stemy-ngx-utils.mjs.map +1 -1
  25. package/ngx-utils/services/formatter.service.d.ts +1 -1
  26. package/ngx-utils/services/local-http.service.d.ts +14 -0
  27. package/ngx-utils/services/wasm.service.d.ts +25 -0
  28. package/ngx-utils/utils/jsonfn.d.ts +6 -0
  29. package/ngx-utils/utils/wasi.d.ts +26 -0
  30. package/ngx-utils/utils/wasm-worker-proxy.d.ts +17 -0
  31. package/package.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 * as moment from 'moment';
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';
@@ -21,8 +21,8 @@ import * as i4 from '@angular/forms';
21
21
  import { FormsModule } from '@angular/forms';
22
22
 
23
23
  const defaultPredicate = () => true;
24
- const hasBlob = typeof Blob !== "undefined";
25
- const hasFile = typeof File !== "undefined";
24
+ const hasBlob = typeof Blob !== "undefined" && !!Blob;
25
+ const hasFile = typeof File !== "undefined" && !!File;
26
26
  class ObjectUtils {
27
27
  static compare(a, b) {
28
28
  if ((a === null || b === null) || (typeof a != typeof b)) {
@@ -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
  }
@@ -487,13 +488,14 @@ class DateUtils {
487
488
  static add(date, amount, unit) {
488
489
  return moment(date).add(amount, unit).toDate();
489
490
  }
490
- static businessAdd(date, amount, unit) {
491
+ static businessAdd(date, amount, unit, freeDays = []) {
491
492
  const signal = amount < 0 ? -1 : 1;
493
+ const freeMoments = freeDays.map(d => moment(d));
492
494
  let remaining = Math.abs(amount);
493
495
  let day = date;
494
496
  while (remaining) {
495
497
  day = DateUtils.add(day, signal, unit);
496
- if (DateUtils.isBusinessDay(day)) {
498
+ if (DateUtils.isBusinessDay(day) && !freeMoments.some(m => m.isSame(day, "day"))) {
497
499
  remaining--;
498
500
  }
499
501
  }
@@ -1173,6 +1175,51 @@ class Initializer {
1173
1175
  }
1174
1176
  }
1175
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
+
1176
1223
  class LoaderUtils {
1177
1224
  static loadScript(src, async = false) {
1178
1225
  this.scriptPromises[src] = this.scriptPromises[src] || new Promise((resolve, reject) => {
@@ -1279,7 +1326,7 @@ class UniversalService {
1279
1326
  this.platformId = platformId;
1280
1327
  this.dds = dds;
1281
1328
  const info = this.dds.getDeviceInfo();
1282
- this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST)/gi.test(info.userAgent);
1329
+ this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST|PostmanRuntime)/gi.test(info.userAgent);
1283
1330
  }
1284
1331
  get isBrowser() {
1285
1332
  return isPlatformBrowser(this.platformId);
@@ -1361,7 +1408,7 @@ class StateService extends BehaviorSubject {
1361
1408
  return;
1362
1409
  const routerStateSnapshot = this.router.routerState.snapshot;
1363
1410
  let snapshot = routerStateSnapshot.root;
1364
- let context = this.contexts.getContext("primary");
1411
+ let context = this.contexts?.getContext("primary");
1365
1412
  let segments = snapshot.url;
1366
1413
  const components = [];
1367
1414
  const snapshots = [];
@@ -2060,81 +2107,103 @@ class Vector {
2060
2107
  }
2061
2108
  }
2062
2109
 
2063
- const emptyGuards = [];
2064
- class AclService {
2065
- constructor(injector, state, auth) {
2066
- this.injector = injector;
2067
- this.state = state;
2068
- this.auth = auth;
2069
- this.components = [];
2070
- this.auth.userChanged.subscribe(() => {
2071
- this.components.forEach(t => t.dirty = true);
2072
- const info = this.getStateInfo();
2073
- const check = info && info.guard instanceof AuthGuard ? info.guard.checkRoute(info.route) : Promise.resolve(true);
2074
- check.then(result => {
2075
- if (result) {
2076
- if (!info || !info.dirty)
2077
- return;
2078
- info.dirty = false;
2079
- const component = info.component;
2080
- if (!info.component)
2081
- return;
2082
- if (info.first) {
2083
- if (ObjectUtils.isFunction(component.onUserInitialized)) {
2084
- component.onUserInitialized();
2085
- }
2086
- info.first = false;
2087
- return;
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} ...`);
2088
2136
  }
2089
- if (ObjectUtils.isFunction(component.onUserChanged)) {
2090
- component.onUserChanged();
2137
+ const func = instance[name];
2138
+ const result = func(...args);
2139
+ if (logTimes) {
2140
+ console.timeLog(id, `Called ${name}`);
2141
+ console.timeEnd(id);
2091
2142
  }
2092
- return;
2093
- }
2094
- info.guard.getReturnState(info.route).then(returnState => {
2095
- if (!returnState)
2096
- return;
2097
- this.state.navigate(returnState);
2143
+ self.postMessage({ type: "result", payload: { id, result } });
2098
2144
  });
2099
- });
2145
+ break;
2146
+ }
2147
+ };
2148
+ }
2149
+ class WasmWorkerProxy {
2150
+ constructor(wasmPath, wasi, logTimes = false) {
2151
+ this.methods = new Promise(resolve => {
2152
+ this.onMethods = resolve;
2100
2153
  });
2101
- this.state.subscribe(() => {
2102
- const info = this.getStateInfo();
2103
- if (!info?.component)
2104
- return;
2105
- const component = info.component;
2106
- if (ObjectUtils.isFunction(component.onUserInitialized)) {
2107
- component.onUserInitialized();
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
+ };
2108
2172
  }
2109
2173
  });
2110
2174
  }
2111
- getStateInfo() {
2112
- const route = this.state.route;
2113
- if (!route)
2114
- return null;
2115
- let info = this.components.find(t => t.route == this.state.route);
2116
- if (!info) {
2117
- const guardType = (route.canActivate || emptyGuards)[0];
2118
- info = {
2119
- route: this.state.route,
2120
- guard: guardType ? this.injector.get(guardType) : null,
2121
- dirty: true,
2122
- first: true
2123
- };
2124
- this.components.push(info);
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;
2125
2190
  }
2126
- info.component = this.state.component;
2127
- return info;
2128
2191
  }
2129
- }
2130
- 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 });
2131
- AclService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AclService });
2132
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: AclService, decorators: [{
2133
- type: Injectable
2134
- }], ctorParameters: function () { return [{ type: i0.Injector }, { type: StateService }, { type: undefined, decorators: [{
2135
- type: Inject,
2136
- args: [AUTH_SERVICE]
2137
- }] }]; } });
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
+ }
2138
2207
 
2139
2208
  class BaseHttpClient extends HttpClient {
2140
2209
  constructor(handler) {
@@ -2233,6 +2302,7 @@ class BaseHttpService {
2233
2302
  this.requestHeaders = {};
2234
2303
  this.requestParams = {};
2235
2304
  this.cache = {};
2305
+ this.initService();
2236
2306
  }
2237
2307
  get name() {
2238
2308
  return "base";
@@ -2247,6 +2317,8 @@ class BaseHttpService {
2247
2317
  get universal() {
2248
2318
  return this.storage.universal;
2249
2319
  }
2320
+ initService() {
2321
+ }
2250
2322
  url(url) {
2251
2323
  return url;
2252
2324
  }
@@ -2410,15 +2482,16 @@ class BaseHttpService {
2410
2482
  }
2411
2483
  const headers = options.headers;
2412
2484
  const authKey = "Authorization";
2413
- // If an authorization header exists and we still have an Unauthorized response prompt the user to log in again
2485
+ // If an authorization header exists, and we still have an Unauthorized response prompt the user to log in again
2414
2486
  if (headers.has(authKey) && response.status == 401) {
2415
2487
  const pushed = this.pushFailedRequest(url, options, () => {
2416
2488
  options.headers = this.makeHeaders(options.originalHeaders);
2417
2489
  this.toPromise(url, options, listener).then(resolve, reject);
2418
2490
  });
2419
- if (pushed)
2491
+ if (pushed) {
2420
2492
  this.handleUnauthorizedError(absoluteUrl, options, () => reject(response));
2421
- return;
2493
+ return;
2494
+ }
2422
2495
  }
2423
2496
  reject(response);
2424
2497
  });
@@ -2426,7 +2499,7 @@ class BaseHttpService {
2426
2499
  });
2427
2500
  }
2428
2501
  pushFailedRequest(url, options, req) {
2429
- if (url.indexOf("tokens") >= 0)
2502
+ if (url.indexOf("token") >= 0 || url === "user")
2430
2503
  return false;
2431
2504
  BaseHttpService.failedRequests.push(req);
2432
2505
  return true;
@@ -2508,6 +2581,164 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
2508
2581
  args: [EXPRESS_REQUEST]
2509
2582
  }] }]; } });
2510
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
+
2511
2742
  class ApiService extends BaseHttpService {
2512
2743
  get name() {
2513
2744
  return "api";
@@ -3809,7 +4040,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
3809
4040
 
3810
4041
  class ReplacePipe {
3811
4042
  transform(value, from, to) {
3812
- return value ? value.replace(from, to) : value;
4043
+ return ObjectUtils.isDefined(value) ? `${value}`.replace(from, to) : ``;
3813
4044
  }
3814
4045
  }
3815
4046
  ReplacePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: ReplacePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
@@ -5057,6 +5288,7 @@ const providers = [
5057
5288
  GlobalTemplateService,
5058
5289
  IconService,
5059
5290
  LanguageService,
5291
+ LocalHttpService,
5060
5292
  OpenApiService,
5061
5293
  PromiseService,
5062
5294
  StateService,
@@ -5065,6 +5297,7 @@ const providers = [
5065
5297
  ConsoleToasterService,
5066
5298
  TranslatedUrlSerializer,
5067
5299
  UniversalService,
5300
+ WasmService,
5068
5301
  DeviceDetectorService,
5069
5302
  {
5070
5303
  provide: EVENT_MANAGER_PLUGINS,
@@ -5089,6 +5322,163 @@ function loadConfig(config) {
5089
5322
  return config.load;
5090
5323
  }
5091
5324
 
5325
+ class Wasi {
5326
+ constructor() {
5327
+ this.env = {};
5328
+ this.instantiated = false;
5329
+ this.wasi = [
5330
+ "emscripten_notify_memory_growth",
5331
+ "proc_exit",
5332
+ "environ_get",
5333
+ "environ_sizes_get",
5334
+ "fd_close",
5335
+ "fd_write",
5336
+ "fd_read",
5337
+ "fd_seek",
5338
+ ].reduce((res, key) => {
5339
+ if (typeof this[key] === "function") {
5340
+ res[key] = this[key].bind(this);
5341
+ }
5342
+ return res;
5343
+ }, {});
5344
+ }
5345
+ instantiate(bytes) {
5346
+ if (this.instantiated) {
5347
+ throw new Error("WASI already instantiated");
5348
+ }
5349
+ this.instantiated = true;
5350
+ return WebAssembly.instantiate(bytes, {
5351
+ wasi_snapshot_preview1: this.wasi,
5352
+ env: this.wasi
5353
+ }).then(module => {
5354
+ const exports = module.instance.exports;
5355
+ this.wasm = {
5356
+ ...exports,
5357
+ writeArrayToMemory: (array) => {
5358
+ const bytes = array.length * array.BYTES_PER_ELEMENT;
5359
+ const pointer = exports.malloc(bytes);
5360
+ const ctr = array.constructor;
5361
+ const heapArray = new ctr(this.wasm.memory.buffer, pointer, array.length);
5362
+ heapArray.set(array);
5363
+ return pointer;
5364
+ },
5365
+ readArrayFromMemory: (pointer, array) => {
5366
+ const ctr = array.constructor;
5367
+ const heapArray = new ctr(this.wasm.memory.buffer, pointer, array.length);
5368
+ array.set(heapArray);
5369
+ return array;
5370
+ }
5371
+ };
5372
+ this.updateMemoryViews();
5373
+ return this.wasm;
5374
+ });
5375
+ }
5376
+ updateMemoryViews() {
5377
+ const buffer = this.wasm.memory.buffer;
5378
+ this.wasm.HEAP8 = new Int8Array(buffer);
5379
+ this.wasm.HEAP16 = new Int16Array(buffer);
5380
+ this.wasm.HEAP32 = new Int32Array(buffer);
5381
+ this.wasm.HEAPU8 = new Uint8Array(buffer);
5382
+ this.wasm.HEAPU16 = new Uint16Array(buffer);
5383
+ this.wasm.HEAPU32 = new Uint32Array(buffer);
5384
+ this.wasm.HEAPF32 = new Float32Array(buffer);
5385
+ this.wasm.HEAPF64 = new Float64Array(buffer);
5386
+ }
5387
+ getEnvStrings() {
5388
+ if (!this.envStrings) {
5389
+ let x;
5390
+ const env = {};
5391
+ for (x in this.env) {
5392
+ if (this.env[x] === undefined)
5393
+ delete env[x];
5394
+ else
5395
+ env[x] = this.env[x];
5396
+ }
5397
+ const strings = [];
5398
+ for (x in env) {
5399
+ strings.push(x + "=" + env[x]);
5400
+ }
5401
+ this.envStrings = strings;
5402
+ }
5403
+ return this.envStrings;
5404
+ }
5405
+ stringToAscii(str, buffer) {
5406
+ const HEAP8 = this.wasm.HEAP8;
5407
+ for (let i = 0; i < str.length; ++i) {
5408
+ HEAP8[buffer++ >> 0] = str.charCodeAt(i);
5409
+ }
5410
+ HEAP8[buffer >> 0] = 0;
5411
+ }
5412
+ emscripten_notify_memory_growth(memoryIndex) {
5413
+ this.updateMemoryViews();
5414
+ }
5415
+ proc_exit(rval) {
5416
+ console.log("proc_exit", rval);
5417
+ }
5418
+ environ_get(environ, environ_buf) {
5419
+ if (!this.wasm.HEAP8.byteLength) {
5420
+ this.emscripten_notify_memory_growth(0);
5421
+ }
5422
+ const HEAPU32 = this.wasm.HEAPU32;
5423
+ let bufSize = 0;
5424
+ this.getEnvStrings().forEach((str, i) => {
5425
+ const ptr = environ_buf + bufSize;
5426
+ HEAPU32[environ + i * 4 >> 2] = ptr;
5427
+ this.stringToAscii(str, ptr);
5428
+ bufSize += str.length + 1;
5429
+ });
5430
+ return 0;
5431
+ }
5432
+ environ_sizes_get(penviron_count, penviron_buf_size) {
5433
+ if (!this.wasm.HEAP8.byteLength) {
5434
+ this.emscripten_notify_memory_growth(0);
5435
+ }
5436
+ const HEAPU32 = this.wasm.HEAPU32;
5437
+ const strings = this.getEnvStrings();
5438
+ HEAPU32[penviron_count >> 2] = strings.length;
5439
+ let bufSize = 0;
5440
+ strings.forEach(function (string) {
5441
+ bufSize += string.length + 1;
5442
+ });
5443
+ HEAPU32[penviron_buf_size >> 2] = bufSize;
5444
+ // WASI_ESUCCESS
5445
+ return 0;
5446
+ }
5447
+ fd_close(fd) {
5448
+ // WASI_ESUCCESS
5449
+ return 0;
5450
+ }
5451
+ fd_write(fd, iovs, iovs_len, nwritten) {
5452
+ if (fd !== 1) {
5453
+ // WASI_EBADF
5454
+ return 8;
5455
+ }
5456
+ if (iovs_len !== 1) {
5457
+ // WASI_ENOSYS
5458
+ return 52;
5459
+ }
5460
+ this.wasm.HEAPU32[nwritten >> 2] = this.wasm.HEAPU32[iovs + 4 >> 2];
5461
+ // WASI_ESUCCESS
5462
+ return 0;
5463
+ }
5464
+ fd_read(fd, iovs, iovs_len, nread) {
5465
+ // WASI_EINVAL
5466
+ return 28;
5467
+ }
5468
+ fd_seek(fd, offset, whence, newOffset) {
5469
+ // WASI_EINVAL
5470
+ return 28;
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
+
5092
5482
  function loadBaseUrl() {
5093
5483
  if (typeof (document) === "undefined" || typeof (location) === "undefined")
5094
5484
  return "/";
@@ -5159,6 +5549,10 @@ class NgxUtilsModule {
5159
5549
  provide: GLOBAL_TEMPLATES,
5160
5550
  useExisting: (!config ? null : config.globalTemplates) || GlobalTemplateService
5161
5551
  },
5552
+ {
5553
+ provide: WASI_IMPLEMENTATION,
5554
+ useExisting: (!config ? null : config.wasiImplementation) || Wasi
5555
+ },
5162
5556
  {
5163
5557
  provide: APP_BASE_URL,
5164
5558
  useFactory: (!config ? null : config.baseUrl) || loadBaseUrl,
@@ -5216,5 +5610,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImpor
5216
5610
  * Generated bundle index. Do not edit.
5217
5611
  */
5218
5612
 
5219
- 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 };
5220
5614
  //# sourceMappingURL=stemy-ngx-utils.mjs.map