@tstdl/base 0.90.72 → 0.90.74
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 +8 -8
- package/schema/types/types.d.ts +1 -1
- package/schema/utils/schema.js +1 -1
- package/signals/index.d.ts +1 -0
- package/signals/index.js +1 -0
- package/signals/notifier.d.ts +4 -0
- package/signals/notifier.js +10 -0
- package/signals/operators/derive-async.d.ts +31 -0
- package/signals/operators/derive-async.js +29 -0
- package/signals/operators/index.d.ts +2 -1
- package/signals/operators/index.js +2 -1
- package/signals/operators/switchAll.d.ts +2 -0
- package/signals/operators/{switch-map.js → switchAll.js} +1 -1
- package/text/dynamic-text.model.js +2 -2
- package/signals/operators/switch-map.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.74",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -111,11 +111,11 @@
|
|
|
111
111
|
"luxon": "^3.4",
|
|
112
112
|
"reflect-metadata": "^0.2",
|
|
113
113
|
"rxjs": "^7.8",
|
|
114
|
-
"type-fest": "4.
|
|
114
|
+
"type-fest": "4.18"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
117
|
"@mxssfd/typedoc-theme": "1.1",
|
|
118
|
-
"@stylistic/eslint-plugin": "1.
|
|
118
|
+
"@stylistic/eslint-plugin": "1.8",
|
|
119
119
|
"@types/chroma-js": "2.4",
|
|
120
120
|
"@types/koa__router": "12.0",
|
|
121
121
|
"@types/luxon": "3.4",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"typedoc": "0.25",
|
|
133
133
|
"typedoc-plugin-missing-exports": "2.2",
|
|
134
134
|
"typescript": "5.4",
|
|
135
|
-
"typescript-eslint": "7.
|
|
135
|
+
"typescript-eslint": "7.8"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"@elastic/elasticsearch": "^8.13",
|
|
@@ -145,14 +145,14 @@
|
|
|
145
145
|
"chroma-js": "^2.4",
|
|
146
146
|
"handlebars": "^4.7",
|
|
147
147
|
"koa": "^2.15",
|
|
148
|
-
"minio": "^
|
|
148
|
+
"minio": "^8.0",
|
|
149
149
|
"mjml": "^4.15",
|
|
150
|
-
"mongodb": "^6.
|
|
150
|
+
"mongodb": "^6.6",
|
|
151
151
|
"nodemailer": "^6.9",
|
|
152
152
|
"playwright": "^1.43",
|
|
153
|
-
"preact": "^10.
|
|
153
|
+
"preact": "^10.21",
|
|
154
154
|
"preact-render-to-string": "^6.4",
|
|
155
|
-
"undici": "^6.
|
|
155
|
+
"undici": "^6.15",
|
|
156
156
|
"urlpattern-polyfill": "^10.0"
|
|
157
157
|
},
|
|
158
158
|
"peerDependenciesMeta": {
|
package/schema/types/types.d.ts
CHANGED
package/schema/utils/schema.js
CHANGED
package/signals/index.d.ts
CHANGED
package/signals/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { concatAll, exhaustAll, mergeAll, switchAll, type Observable } from 'rxjs';
|
|
2
|
+
import { type Signal, type ToSignalOptions } from '../api.js';
|
|
3
|
+
export type DeriveAsyncOptions = ToSignalOptions & {
|
|
4
|
+
behavior?: DeriveAsyncBehavior;
|
|
5
|
+
};
|
|
6
|
+
declare const operatorMap: {
|
|
7
|
+
merge: typeof mergeAll;
|
|
8
|
+
concat: typeof concatAll;
|
|
9
|
+
exhaust: typeof exhaustAll;
|
|
10
|
+
switch: typeof switchAll;
|
|
11
|
+
};
|
|
12
|
+
export type DeriveAsyncBehavior = keyof typeof operatorMap;
|
|
13
|
+
type DeriveAsyncSourceParameter<T> = () => (T | Promise<T> | Observable<T>);
|
|
14
|
+
export declare function deriveAsync<T>(source: DeriveAsyncSourceParameter<T>): Signal<T | undefined>;
|
|
15
|
+
export declare function deriveAsync<T>(source: DeriveAsyncSourceParameter<T>, options: DeriveAsyncOptions & {
|
|
16
|
+
initialValue?: undefined;
|
|
17
|
+
requireSync?: false;
|
|
18
|
+
}): Signal<T | undefined>;
|
|
19
|
+
export declare function deriveAsync<T>(source: DeriveAsyncSourceParameter<T>, options: DeriveAsyncOptions & {
|
|
20
|
+
initialValue?: null;
|
|
21
|
+
requireSync?: false;
|
|
22
|
+
}): Signal<T | null>;
|
|
23
|
+
export declare function deriveAsync<T>(source: DeriveAsyncSourceParameter<T>, options: DeriveAsyncOptions & {
|
|
24
|
+
initialValue?: undefined;
|
|
25
|
+
requireSync: true;
|
|
26
|
+
}): Signal<T>;
|
|
27
|
+
export declare function deriveAsync<T, const U extends T>(source: DeriveAsyncSourceParameter<T>, options: DeriveAsyncOptions & {
|
|
28
|
+
initialValue: U;
|
|
29
|
+
requireSync?: false;
|
|
30
|
+
}): Signal<T | U>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Subject, concatAll, exhaustAll, isObservable, mergeAll, of, switchAll, takeUntil } from 'rxjs';
|
|
2
|
+
import { registerFinalization } from '../../memory/finalization.js';
|
|
3
|
+
import { isPromise } from '../../utils/type-guards.js';
|
|
4
|
+
import { computed, toSignal, untracked } from '../api.js';
|
|
5
|
+
import { effect } from '../implementation/effect.js';
|
|
6
|
+
const operatorMap = {
|
|
7
|
+
merge: mergeAll,
|
|
8
|
+
concat: concatAll,
|
|
9
|
+
exhaust: exhaustAll,
|
|
10
|
+
switch: switchAll,
|
|
11
|
+
};
|
|
12
|
+
export function deriveAsync(source, options) {
|
|
13
|
+
const outerSource = computed(source);
|
|
14
|
+
const source$ = new Subject();
|
|
15
|
+
const destroy$ = new Subject();
|
|
16
|
+
const operator = operatorMap[options?.behavior ?? 'switch'];
|
|
17
|
+
const valueSource$ = source$.pipe(operator(), takeUntil(destroy$));
|
|
18
|
+
const result = toSignal(valueSource$, options);
|
|
19
|
+
const effectRef = effect(() => {
|
|
20
|
+
const rawSource = outerSource();
|
|
21
|
+
const observableInput = (isPromise(rawSource) || isObservable(rawSource)) ? rawSource : of(rawSource);
|
|
22
|
+
untracked(() => source$.next(observableInput));
|
|
23
|
+
});
|
|
24
|
+
registerFinalization(result, () => {
|
|
25
|
+
destroy$.next();
|
|
26
|
+
effectRef.destroy();
|
|
27
|
+
});
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isObservable } from 'rxjs';
|
|
2
2
|
import { inject } from '../injector/inject.js';
|
|
3
3
|
import { computed, isSignal, toObservable, toSignal, untracked } from '../signals/api.js';
|
|
4
|
-
import {
|
|
4
|
+
import { switchAll } from '../signals/index.js';
|
|
5
5
|
import { runInUntracked } from '../signals/untracked-operator.js';
|
|
6
6
|
import { isString } from '../utils/type-guards.js';
|
|
7
7
|
import { LocalizationService } from './localization.service.js';
|
|
@@ -12,7 +12,7 @@ export function resolveDynamicText(text, localizationService = inject(Localizati
|
|
|
12
12
|
: isObservable(text)
|
|
13
13
|
? untracked(() => toSignal(text.pipe(runInUntracked()), { initialValue: missingLocalizationKeyText }))
|
|
14
14
|
: computed(() => text);
|
|
15
|
-
return
|
|
15
|
+
return switchAll(() => {
|
|
16
16
|
const localizableText = localizableTextSignal();
|
|
17
17
|
return isString(localizableText) ? computed(() => localizableText) : localizationService.localize(localizableText);
|
|
18
18
|
});
|