@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.90.72",
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.17"
114
+ "type-fest": "4.18"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@mxssfd/typedoc-theme": "1.1",
118
- "@stylistic/eslint-plugin": "1.7",
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.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": "^7.1",
148
+ "minio": "^8.0",
149
149
  "mjml": "^4.15",
150
- "mongodb": "^6.5",
150
+ "mongodb": "^6.6",
151
151
  "nodemailer": "^6.9",
152
152
  "playwright": "^1.43",
153
- "preact": "^10.20",
153
+ "preact": "^10.21",
154
154
  "preact-render-to-string": "^6.4",
155
- "undici": "^6.14",
155
+ "undici": "^6.15",
156
156
  "urlpattern-polyfill": "^10.0"
157
157
  },
158
158
  "peerDependenciesMeta": {
@@ -44,7 +44,7 @@ export type TypeSchema<T = any> = {
44
44
  type: ValueType<T>;
45
45
  };
46
46
  export type NormalizedTypeSchema<T = any> = {
47
- foo: ResolvedValueType<T>;
47
+ type: ResolvedValueType<T>;
48
48
  };
49
49
  export type ValueSchema<T = unknown> = {
50
50
  [optimized]?: boolean;
@@ -66,7 +66,7 @@ function _normalizeValueSchema(schema) {
66
66
  }
67
67
  function _normalizeTypeSchema(schema) {
68
68
  const normalizedSchema = {
69
- foo: resolveValueType(schema.type)
69
+ type: resolveValueType(schema.type)
70
70
  };
71
71
  return normalizedSchema;
72
72
  }
@@ -1,6 +1,7 @@
1
1
  export * from './api.js';
2
2
  export * from './computed-with-dependencies.js';
3
3
  export * from './effect-with-dependencies.js';
4
+ export * from './notifier.js';
4
5
  export * from './operators/index.js';
5
6
  export * from './pipe.js';
6
7
  export * from './to-lazy-signal.js';
package/signals/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './api.js';
2
2
  export * from './computed-with-dependencies.js';
3
3
  export * from './effect-with-dependencies.js';
4
+ export * from './notifier.js';
4
5
  export * from './operators/index.js';
5
6
  export * from './pipe.js';
6
7
  export * from './to-lazy-signal.js';
@@ -0,0 +1,4 @@
1
+ export declare function createNotifier(): {
2
+ listen: import("./api.js").Signal<number>;
3
+ notify(): void;
4
+ };
@@ -0,0 +1,10 @@
1
+ import { signal } from './api.js';
2
+ export function createNotifier() {
3
+ const sourceSignal = signal(0);
4
+ return {
5
+ listen: sourceSignal.asReadonly(),
6
+ notify() {
7
+ sourceSignal.update((v) => v + 1);
8
+ },
9
+ };
10
+ }
@@ -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,4 +1,5 @@
1
1
  export * from './combine.js';
2
2
  export * from './defer.js';
3
+ export * from './derive-async.js';
3
4
  export * from './map.js';
4
- export * from './switch-map.js';
5
+ export * from './switchAll.js';
@@ -1,4 +1,5 @@
1
1
  export * from './combine.js';
2
2
  export * from './defer.js';
3
+ export * from './derive-async.js';
3
4
  export * from './map.js';
4
- export * from './switch-map.js';
5
+ export * from './switchAll.js';
@@ -0,0 +1,2 @@
1
+ import { type Signal } from '../api.js';
2
+ export declare function switchAll<T>(source: () => Signal<T>): Signal<T>;
@@ -1,5 +1,5 @@
1
1
  import { computed } from '../api.js';
2
- export function switchMap(source) {
2
+ export function switchAll(source) {
3
3
  const outerSource = computed(source);
4
4
  return computed(() => outerSource()());
5
5
  }
@@ -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 { switchMap } from '../signals/operators/switch-map.js';
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 switchMap(() => {
15
+ return switchAll(() => {
16
16
  const localizableText = localizableTextSignal();
17
17
  return isString(localizableText) ? computed(() => localizableText) : localizationService.localize(localizableText);
18
18
  });
@@ -1,2 +0,0 @@
1
- import { type Signal } from '../api.js';
2
- export declare function switchMap<T>(source: () => Signal<T>): Signal<T>;