@tstdl/base 0.85.11 → 0.85.13
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/package.json +1 -1
- package/rxjs/timing.js +4 -1
- package/text/dynamic-text.model.js +2 -1
- package/utils/equals.d.ts +1 -0
- package/utils/equals.js +5 -1
- package/utils/object/property-name.js +7 -3
package/package.json
CHANGED
package/rxjs/timing.js
CHANGED
|
@@ -41,7 +41,10 @@ const singleNextTick$ = singleCallback((callback) => process.nextTick(callback))
|
|
|
41
41
|
const nextTick$ = recursiveCallback((callback) => process.nextTick(callback));
|
|
42
42
|
function singleCallback(scheduler, canceller) {
|
|
43
43
|
return new import_rxjs.Observable((subscriber) => {
|
|
44
|
-
const handle = scheduler((value) =>
|
|
44
|
+
const handle = scheduler((value) => {
|
|
45
|
+
subscriber.next(value);
|
|
46
|
+
subscriber.complete();
|
|
47
|
+
});
|
|
45
48
|
return () => canceller?.(handle);
|
|
46
49
|
});
|
|
47
50
|
}
|
|
@@ -31,6 +31,7 @@ __export(dynamic_text_model_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(dynamic_text_model_exports);
|
|
32
32
|
var import_rxjs = require("rxjs");
|
|
33
33
|
var import_container = require("../container/index.js");
|
|
34
|
+
var import_timing = require("../rxjs/timing.js");
|
|
34
35
|
var import_api = require("../signals/api.js");
|
|
35
36
|
var import_switch_map = require("../signals/switch-map.js");
|
|
36
37
|
var import_type_guards = require("../utils/type-guards.js");
|
|
@@ -38,7 +39,7 @@ var import_localization_service = require("./localization.service.js");
|
|
|
38
39
|
const missingLocalizationKeyText = "[MISSING LOCALIZATION KEY]";
|
|
39
40
|
function resolveDynamicText(text, localizationService) {
|
|
40
41
|
const resolvedLocalizationService = localizationService ?? import_container.container.resolve(import_localization_service.LocalizationService);
|
|
41
|
-
const localizableTextSignal = (0, import_api.isSignal)(text) ? text : (0, import_rxjs.isObservable)(text) ? (0, import_api.toSignal)(text, { initialValue: missingLocalizationKeyText }) : (0, import_api.computed)(() => text);
|
|
42
|
+
const localizableTextSignal = (0, import_api.isSignal)(text) ? text : (0, import_rxjs.isObservable)(text) ? (0, import_api.toSignal)(text.pipe((0, import_rxjs.delayWhen)(() => import_timing.microtask$)), { initialValue: missingLocalizationKeyText }) : (0, import_api.computed)(() => text);
|
|
42
43
|
return (0, import_switch_map.switchMap)(() => {
|
|
43
44
|
const localizableText = localizableTextSignal();
|
|
44
45
|
return (0, import_type_guards.isString)(localizableText) ? (0, import_api.computed)(() => localizableText) : resolvedLocalizationService.localize(localizableText);
|
package/utils/equals.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type ArrayEqualsOptions<A, B> = {
|
|
|
12
12
|
sort?: Comparator<A | B>;
|
|
13
13
|
comparator?: ArrayEqualsComparator<A, B>;
|
|
14
14
|
};
|
|
15
|
+
export declare function strictEquals(a: any, b: any): boolean;
|
|
15
16
|
export declare function arrayEquals<A, B>(a: readonly A[], b: readonly B[], options?: ArrayEqualsOptions<A, B>): boolean;
|
|
16
17
|
export type EqualsOptions = {
|
|
17
18
|
deep?: boolean;
|
package/utils/equals.js
CHANGED
|
@@ -21,7 +21,8 @@ __export(equals_exports, {
|
|
|
21
21
|
Equals: () => Equals,
|
|
22
22
|
arrayEquals: () => arrayEquals,
|
|
23
23
|
binaryEquals: () => binaryEquals,
|
|
24
|
-
equals: () => equals
|
|
24
|
+
equals: () => equals,
|
|
25
|
+
strictEquals: () => strictEquals
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(equals_exports);
|
|
27
28
|
var import_array = require("./array/array.js");
|
|
@@ -33,6 +34,9 @@ const equalsSymbol = Symbol("equals");
|
|
|
33
34
|
const Equals = {
|
|
34
35
|
symbol: equalsSymbol
|
|
35
36
|
};
|
|
37
|
+
function strictEquals(a, b) {
|
|
38
|
+
return a === b;
|
|
39
|
+
}
|
|
36
40
|
function arrayEquals(a, b, options) {
|
|
37
41
|
const _sort = options?.sort ?? false;
|
|
38
42
|
const comparator = options?.comparator ?? equals;
|
|
@@ -39,6 +39,7 @@ function isPropertyName(value) {
|
|
|
39
39
|
const propertyNameProxy = Symbol("PropertyNameProxy");
|
|
40
40
|
function getPropertyNameProxy(options = {}) {
|
|
41
41
|
const { deep = true, flat = false, prefix } = options;
|
|
42
|
+
const cache = /* @__PURE__ */ new Map();
|
|
42
43
|
const proxy = new Proxy({ [propertyNameProxy]: prefix }, {
|
|
43
44
|
get: (_target, property) => {
|
|
44
45
|
if (property == propertyName) {
|
|
@@ -55,10 +56,13 @@ function getPropertyNameProxy(options = {}) {
|
|
|
55
56
|
if (ignore) {
|
|
56
57
|
return proxy;
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
const cached = cache.get(property);
|
|
60
|
+
if ((0, import_type_guards.isDefined)(cached)) {
|
|
61
|
+
return cached;
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
const newProxy = getPropertyNameProxy({ deep, flat, prefix: deep ? (0, import_type_guards.isUndefined)(prefix) ? property : `${prefix}.${property}` : property });
|
|
64
|
+
cache.set(property, newProxy);
|
|
65
|
+
return newProxy;
|
|
62
66
|
}
|
|
63
67
|
});
|
|
64
68
|
return proxy;
|