@signaltree/core 9.6.0 → 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.
|
@@ -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
|
}
|