@tstdl/base 0.90.73 → 0.90.75

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.73",
3
+ "version": "0.90.75",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -147,7 +147,7 @@
147
147
  "koa": "^2.15",
148
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
153
  "preact": "^10.21",
@@ -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
  });
package/web-types.d.ts CHANGED
@@ -26,3 +26,18 @@ export type InputAttributes = {
26
26
  type?: InputType;
27
27
  value?: any;
28
28
  };
29
+ export type TextAreaAttributes = {
30
+ autocomplete?: InputAutocomplete;
31
+ autofocus?: boolean;
32
+ cols?: number;
33
+ rows?: number;
34
+ maxlength?: number;
35
+ minlength?: number;
36
+ name?: string;
37
+ disabled?: boolean;
38
+ id?: string;
39
+ placeholder?: string;
40
+ readonly?: boolean;
41
+ required?: boolean;
42
+ wrap?: 'hard' | 'soft' | 'off';
43
+ };
@@ -1,2 +0,0 @@
1
- import { type Signal } from '../api.js';
2
- export declare function switchMap<T>(source: () => Signal<T>): Signal<T>;