@signaltree/core 9.5.2 → 10.0.0
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/dist/lib/internals/materialize-markers.js +11 -1
- package/dist/lib/signal-tree.js +2 -1
- package/package.json +1 -6
- package/dist/lib/rxjs-interop/rx-method.js +0 -50
- package/dist/rxjs-interop.js +0 -1
- package/src/lib/rxjs-interop/index.d.ts +0 -1
- package/src/lib/rxjs-interop/rx-method.d.ts +0 -11
- package/src/rxjs-interop.d.ts +0 -1
|
@@ -18,15 +18,25 @@ function isRegisteredMarker(value) {
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
function registerMarkerProcessor(check, create) {
|
|
21
|
+
if (typeof check !== 'function' || typeof create !== 'function') {
|
|
22
|
+
throw new TypeError("registerMarkerProcessor: both 'check' (type guard) and 'create' " + '(materializer) must be functions. Received check=' + typeof check + ', create=' + typeof create + '. ' + 'See https://signaltree.io/docs (custom markers section) for usage.');
|
|
23
|
+
}
|
|
21
24
|
const alreadyRegistered = MARKER_PROCESSORS.some(p => p.check === check);
|
|
22
25
|
if (alreadyRegistered) {
|
|
23
26
|
return;
|
|
24
27
|
}
|
|
28
|
+
if ((typeof ngDevMode === 'undefined' || ngDevMode) && treesConstructedCount > 0) {
|
|
29
|
+
console.warn('[SignalTree] registerMarkerProcessor() was called AFTER at least one ' + `signalTree() had already been constructed (${treesConstructedCount} trees so far). ` + 'Existing trees will NOT pick up this marker — only trees built after ' + 'this point will use it. To process your custom marker in existing ' + "trees, register it at module load time (before any signalTree() call), " + "or rebuild the tree after registration.");
|
|
30
|
+
}
|
|
25
31
|
MARKER_PROCESSORS.push({
|
|
26
32
|
check,
|
|
27
33
|
create: create
|
|
28
34
|
});
|
|
29
35
|
}
|
|
36
|
+
let treesConstructedCount = 0;
|
|
37
|
+
function _recordTreeConstruction() {
|
|
38
|
+
treesConstructedCount += 1;
|
|
39
|
+
}
|
|
30
40
|
function materializeMarkers(node, notifier, path = []) {
|
|
31
41
|
if (node == null) return;
|
|
32
42
|
if (typeof node !== 'object' && typeof node !== 'function') return;
|
|
@@ -69,4 +79,4 @@ function materializeMarkers(node, notifier, path = []) {
|
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
|
|
72
|
-
export { isRegisteredMarker, materializeMarkers, registerMarkerProcessor };
|
|
82
|
+
export { _recordTreeConstruction, isRegisteredMarker, materializeMarkers, registerMarkerProcessor };
|
package/dist/lib/signal-tree.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { signal, isSignal, untracked } from '@angular/core';
|
|
2
2
|
import { SIGNAL_TREE_MESSAGES, SIGNAL_TREE_CONSTANTS } from './constants.js';
|
|
3
3
|
import { batchScope } from './internals/batch-scope.js';
|
|
4
|
-
import { isRegisteredMarker, materializeMarkers } from './internals/materialize-markers.js';
|
|
4
|
+
import { isRegisteredMarker, materializeMarkers, _recordTreeConstruction } from './internals/materialize-markers.js';
|
|
5
5
|
import { applyDerivedFactories } from './internals/merge-derived.js';
|
|
6
6
|
import { isStatusMarker } from './markers/status.js';
|
|
7
7
|
import { isStoredMarker } from './markers/stored.js';
|
|
@@ -387,6 +387,7 @@ function createBuilder(baseTree) {
|
|
|
387
387
|
isFinalized = true;
|
|
388
388
|
materializeMarkers(baseTree.$);
|
|
389
389
|
materializeMarkers(baseTree.state);
|
|
390
|
+
_recordTreeConstruction();
|
|
390
391
|
if (derivedQueue.length > 0) {
|
|
391
392
|
applyDerivedFactories(baseTree.$, derivedQueue);
|
|
392
393
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signaltree/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Reactive JSON for Angular. JSON branches, reactive leaves. No actions. No reducers. No selectors.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,11 +29,6 @@
|
|
|
29
29
|
"import": "./dist/storage.js",
|
|
30
30
|
"default": "./dist/storage.js"
|
|
31
31
|
},
|
|
32
|
-
"./rxjs-interop": {
|
|
33
|
-
"types": "./src/rxjs-interop.d.ts",
|
|
34
|
-
"import": "./dist/rxjs-interop.js",
|
|
35
|
-
"default": "./dist/rxjs-interop.js"
|
|
36
|
-
},
|
|
37
32
|
"./package.json": "./package.json"
|
|
38
33
|
},
|
|
39
34
|
"peerDependencies": {
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { inject, DestroyRef, Injector, isSignal } from '@angular/core';
|
|
2
|
-
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
3
|
-
import { Subject } from '../../Subject.js';
|
|
4
|
-
import { Subscription } from '../../Subscription.js';
|
|
5
|
-
import { isObservable } from '../../isObservable.js';
|
|
6
|
-
|
|
7
|
-
function rxMethod(generator, options) {
|
|
8
|
-
const destroyRef = options?.destroyRef ?? inject(DestroyRef);
|
|
9
|
-
const injector = options?.injector ?? inject(Injector);
|
|
10
|
-
const trigger$ = new Subject();
|
|
11
|
-
const sourceSubs = new Set();
|
|
12
|
-
let isDestroyed = false;
|
|
13
|
-
const masterSub = generator(trigger$.asObservable()).pipe(takeUntilDestroyed(destroyRef)).subscribe();
|
|
14
|
-
const fn = input => {
|
|
15
|
-
if (isDestroyed) return Subscription.EMPTY;
|
|
16
|
-
if (input === undefined) {
|
|
17
|
-
trigger$.next(undefined);
|
|
18
|
-
return Subscription.EMPTY;
|
|
19
|
-
}
|
|
20
|
-
if (isSignal(input)) {
|
|
21
|
-
const sub = toObservable(input, {
|
|
22
|
-
injector
|
|
23
|
-
}).pipe(takeUntilDestroyed(destroyRef)).subscribe(value => trigger$.next(value));
|
|
24
|
-
sourceSubs.add(sub);
|
|
25
|
-
sub.add(() => sourceSubs.delete(sub));
|
|
26
|
-
return sub;
|
|
27
|
-
}
|
|
28
|
-
if (isObservable(input)) {
|
|
29
|
-
const sub = input.pipe(takeUntilDestroyed(destroyRef)).subscribe(value => trigger$.next(value));
|
|
30
|
-
sourceSubs.add(sub);
|
|
31
|
-
sub.add(() => sourceSubs.delete(sub));
|
|
32
|
-
return sub;
|
|
33
|
-
}
|
|
34
|
-
trigger$.next(input);
|
|
35
|
-
return Subscription.EMPTY;
|
|
36
|
-
};
|
|
37
|
-
const method = fn;
|
|
38
|
-
method.destroy = () => {
|
|
39
|
-
if (isDestroyed) return;
|
|
40
|
-
isDestroyed = true;
|
|
41
|
-
masterSub.unsubscribe();
|
|
42
|
-
sourceSubs.forEach(s => s.unsubscribe());
|
|
43
|
-
sourceSubs.clear();
|
|
44
|
-
trigger$.complete();
|
|
45
|
-
};
|
|
46
|
-
destroyRef.onDestroy(() => method.destroy());
|
|
47
|
-
return method;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { rxMethod };
|
package/dist/rxjs-interop.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rxMethod } from './lib/rxjs-interop/rx-method.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rxMethod, type RxMethod, type RxMethodInput, } from './rx-method';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DestroyRef, Injector, type Signal } from '@angular/core';
|
|
2
|
-
import { type Observable, Subscription } from 'rxjs';
|
|
3
|
-
export type RxMethodInput<T> = T | Signal<T> | Observable<T>;
|
|
4
|
-
export interface RxMethod<T> {
|
|
5
|
-
(...args: [T] extends [void] ? [] | [RxMethodInput<T>] : [RxMethodInput<T>]): Subscription;
|
|
6
|
-
destroy(): void;
|
|
7
|
-
}
|
|
8
|
-
export declare function rxMethod<T = void>(generator: (source$: Observable<T>) => Observable<unknown>, options?: {
|
|
9
|
-
destroyRef?: DestroyRef;
|
|
10
|
-
injector?: Injector;
|
|
11
|
-
}): RxMethod<T>;
|
package/src/rxjs-interop.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { rxMethod, type RxMethod, type RxMethodInput, } from './lib/rxjs-interop';
|