@blac/core 2.0.16 → 2.0.18
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/README.md +7 -1
- package/dist/StateContainerRegistry-4Ljd9EJx.js +1018 -0
- package/dist/StateContainerRegistry-4Ljd9EJx.js.map +1 -0
- package/dist/StateContainerRegistry-B1GYx9Xo.js +975 -0
- package/dist/StateContainerRegistry-B1GYx9Xo.js.map +1 -0
- package/dist/StateContainerRegistry-CEWpc1bj.cjs +1113 -0
- package/dist/StateContainerRegistry-CEWpc1bj.cjs.map +1 -0
- package/dist/StateContainerRegistry-CSNm2Ws5.cjs +1085 -0
- package/dist/StateContainerRegistry-CSNm2Ws5.cjs.map +1 -0
- package/dist/StateContainerRegistry-CvBOhAT2.js +996 -0
- package/dist/StateContainerRegistry-CvBOhAT2.js.map +1 -0
- package/dist/StateContainerRegistry-DJQqLrli.cjs +1046 -0
- package/dist/StateContainerRegistry-DJQqLrli.cjs.map +1 -0
- package/dist/acquire-B1Wuqla6.cjs +46 -0
- package/dist/acquire-B1Wuqla6.cjs.map +1 -0
- package/dist/acquire-BP-ZfUH2.js +35 -0
- package/dist/acquire-BP-ZfUH2.js.map +1 -0
- package/dist/acquire-BZIs6tpN.cjs +46 -0
- package/dist/acquire-BZIs6tpN.cjs.map +1 -0
- package/dist/acquire-CbMz7gWs.cjs +46 -0
- package/dist/acquire-CbMz7gWs.cjs.map +1 -0
- package/dist/acquire-CwB083au.js +35 -0
- package/dist/acquire-CwB083au.js.map +1 -0
- package/dist/acquire-G8aB3GAx.js +35 -0
- package/dist/acquire-G8aB3GAx.js.map +1 -0
- package/dist/config-C7Ktkjh2.cjs +32 -0
- package/dist/config-C7Ktkjh2.cjs.map +1 -0
- package/dist/config-COT4Xkbc.js +16 -0
- package/dist/config-COT4Xkbc.js.map +1 -0
- package/dist/config-Dk1FxfXj.js +16 -0
- package/dist/config-Dk1FxfXj.js.map +1 -0
- package/dist/config-b2z51Y_C.cjs +32 -0
- package/dist/config-b2z51Y_C.cjs.map +1 -0
- package/dist/config-buwpT7l3.js +16 -0
- package/dist/config-buwpT7l3.js.map +1 -0
- package/dist/config-sCPKPYxZ.cjs +32 -0
- package/dist/config-sCPKPYxZ.cjs.map +1 -0
- package/dist/core/Cubit.d.ts +4 -4
- package/dist/core/StateContainer.d.ts +85 -48
- package/dist/core/StateContainerRegistry.d.ts +3 -3
- package/dist/core/meta.d.ts +73 -0
- package/dist/core/symbols.d.ts +10 -17
- package/dist/debug.cjs +3 -3
- package/dist/debug.js +3 -3
- package/dist/ensure-B9oOqpOB.cjs +558 -0
- package/dist/ensure-B9oOqpOB.cjs.map +1 -0
- package/dist/ensure-BfYnvAsI.js +709 -0
- package/dist/ensure-BfYnvAsI.js.map +1 -0
- package/dist/ensure-C1a8IFWy.js +535 -0
- package/dist/ensure-C1a8IFWy.js.map +1 -0
- package/dist/ensure-DEXSmA-N.js +526 -0
- package/dist/ensure-DEXSmA-N.js.map +1 -0
- package/dist/ensure-Dx86f80B.cjs +567 -0
- package/dist/ensure-Dx86f80B.cjs.map +1 -0
- package/dist/ensure-DzqGej43.js +526 -0
- package/dist/ensure-DzqGej43.js.map +1 -0
- package/dist/ensure-_Oh8XPm4.cjs +732 -0
- package/dist/ensure-_Oh8XPm4.cjs.map +1 -0
- package/dist/ensure-fsQMjaQL.cjs +567 -0
- package/dist/ensure-fsQMjaQL.cjs.map +1 -0
- package/dist/index.cjs +10 -9
- package/dist/index.d.cts +6 -9
- package/dist/index.d.ts +6 -9
- package/dist/index.js +7 -7
- package/dist/management-14vsHr4t.cjs +85 -0
- package/dist/management-14vsHr4t.cjs.map +1 -0
- package/dist/management-444tdCBG.js +38 -0
- package/dist/management-444tdCBG.js.map +1 -0
- package/dist/management-BqGBdL01.js +38 -0
- package/dist/management-BqGBdL01.js.map +1 -0
- package/dist/management-BvUAjril.js +38 -0
- package/dist/management-BvUAjril.js.map +1 -0
- package/dist/management-DAV9sN-k.cjs +85 -0
- package/dist/management-DAV9sN-k.cjs.map +1 -0
- package/dist/management-Df7Y2sF1.cjs +85 -0
- package/dist/management-Df7Y2sF1.cjs.map +1 -0
- package/dist/plugin/BlacPlugin.d.ts +11 -12
- package/dist/plugin/PluginManager.d.ts +3 -4
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/dist/testing.cjs +10 -15
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +4 -6
- package/dist/testing.d.ts +4 -6
- package/dist/testing.js +10 -14
- package/dist/testing.js.map +1 -1
- package/dist/watch-B91opmva.cjs +70 -0
- package/dist/watch-B91opmva.cjs.map +1 -0
- package/dist/watch-CfrSSrRY.js +59 -0
- package/dist/watch-CfrSSrRY.js.map +1 -0
- package/dist/watch-Cnh3PtQA.cjs +70 -0
- package/dist/watch-Cnh3PtQA.cjs.map +1 -0
- package/dist/watch-D8hwbFU1.js +59 -0
- package/dist/watch-D8hwbFU1.js.map +1 -0
- package/dist/watch-DPVUwPUY.js +59 -0
- package/dist/watch-DPVUwPUY.js.map +1 -0
- package/dist/watch-DVmvZBMD.cjs +70 -0
- package/dist/watch-DVmvZBMD.cjs.map +1 -0
- package/dist/watch-entry.cjs +1 -1
- package/dist/watch-entry.js +1 -1
- package/package.json +3 -3
package/dist/core/Cubit.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import { StateContainer } from './StateContainer';
|
|
|
4
4
|
* public mutation surface. Today it adds nothing structurally beyond
|
|
5
5
|
* `StateContainer` — both are inherited from the underlying
|
|
6
6
|
* `StructuralContainer<S>`. Kept as a real class (not a type alias) because
|
|
7
|
-
* downstream code does `instance instanceof Cubit` checks
|
|
7
|
+
* downstream code does `instance instanceof Cubit` checks.
|
|
8
8
|
*
|
|
9
9
|
* The class body is intentionally empty: a no-op `emit` override would
|
|
10
10
|
* still go through `applyState`, and `patch` is inherited from
|
|
11
|
-
* `StructuralContainer` (path-diffed, microtask-flushed).
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* `StructuralContainer` (path-diffed, microtask-flushed). A caller that
|
|
12
|
+
* wants "skip if no real change" patch semantics can wrap `patch`
|
|
13
|
+
* themselves or call `emit` after a manual equality check.
|
|
14
14
|
*/
|
|
15
15
|
export declare abstract class Cubit<S extends object = any, Args = void, Deps extends object = Record<string, never>> extends StateContainer<S, Args, Deps> {
|
|
16
16
|
}
|
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
import { StructuralContainer, type DeepPartial, type StructuralContainerOptions } from '@dirtytalk/structural';
|
|
2
|
-
import type { ExtractArgs, StateContainerConstructor } from '../types/utilities';
|
|
3
|
-
import { APPLY_DEPS,
|
|
2
|
+
import type { ExtractArgs, ExtractState, StateContainerConstructor } from '../types/utilities';
|
|
3
|
+
import { APPLY_DEPS, INIT_CONFIG, REMOVE_DEPS_OWNER } from './symbols';
|
|
4
|
+
import { type BlacMeta } from './meta';
|
|
5
|
+
/**
|
|
6
|
+
* Brand symbol carried (non-enumerable) on every handle returned by
|
|
7
|
+
* `depend()`. Framework adapters (`@blac/react`) use this to detect handles
|
|
8
|
+
* inside a tracked-proxy and swap in a session-bound wrapper.
|
|
9
|
+
*
|
|
10
|
+
* @internal — exported for `@blac/react`; not part of the public API.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEP_BRAND: unique symbol;
|
|
13
|
+
/**
|
|
14
|
+
* Per-access options for a {@link DepHandle}. `args` resolves the specific dep
|
|
15
|
+
* instance for this call; omit it to fall back to the default args passed to
|
|
16
|
+
* `depend()`. Args resolve at call time so they can derive from current state.
|
|
17
|
+
*/
|
|
18
|
+
export interface DepAccessOptions<T extends StateContainerConstructor> {
|
|
19
|
+
args?: ExtractArgs<T>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Branded handle returned by `StateContainer.depend()`. Two intention-revealing
|
|
23
|
+
* accessors, no callable surface:
|
|
24
|
+
*
|
|
25
|
+
* - `handle.track(options?)` — base impl: returns `[instance.state, instance]`
|
|
26
|
+
* live with no subscription. The React layer replaces `.track()` per-consumer
|
|
27
|
+
* so that cross-bloc state changes trigger re-renders of the reading component.
|
|
28
|
+
* - `handle.untracked(options?)` — returns the live dep instance with no
|
|
29
|
+
* tracking. Use for imperative calls (`.untracked().doThing()`) and one-off
|
|
30
|
+
* state reads that should not subscribe the reader.
|
|
31
|
+
* - `handle[DEP_BRAND]` — carries `{ Type, defaultArgs }` for framework use.
|
|
32
|
+
*/
|
|
33
|
+
export interface DepHandle<T extends StateContainerConstructor> {
|
|
34
|
+
track(options?: DepAccessOptions<T>): [ExtractState<T>, InstanceType<T>];
|
|
35
|
+
untracked(options?: DepAccessOptions<T>): InstanceType<T>;
|
|
36
|
+
readonly [DEP_BRAND]: {
|
|
37
|
+
Type: T;
|
|
38
|
+
defaultArgs?: ExtractArgs<T>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
4
41
|
export interface StateContainerConfig {
|
|
5
42
|
name?: string;
|
|
6
43
|
debug?: boolean;
|
|
@@ -9,7 +46,6 @@ export interface StateContainerConfig {
|
|
|
9
46
|
args?: unknown;
|
|
10
47
|
}
|
|
11
48
|
export type HydrationStatus = 'idle' | 'hydrating' | 'hydrated' | 'error';
|
|
12
|
-
type StateListener<S> = (state: S) => void;
|
|
13
49
|
export type SystemEvent = 'stateChanged' | 'dispose' | 'hydrationChanged';
|
|
14
50
|
export interface SystemEventPayloads<S> {
|
|
15
51
|
stateChanged: {
|
|
@@ -36,19 +72,15 @@ type SystemEventHandler<S, E extends SystemEvent> = (payload: SystemEventPayload
|
|
|
36
72
|
* - per-class `PathInterner`
|
|
37
73
|
*
|
|
38
74
|
* StateContainer layers on:
|
|
39
|
-
* - identity (
|
|
40
|
-
* -
|
|
41
|
-
* - hydration (`beginHydration` / `applyHydratedState` / `finishHydration` / `failHydration` / `waitForHydration`)
|
|
42
|
-
* - cross-bloc deps (`depend()`, `dependencies` getter)
|
|
75
|
+
* - identity / lifecycle / hydration (exposed via `$blac: BlacMeta`)
|
|
76
|
+
* - cross-bloc deps (`depend()`, `$blac.dependencies`)
|
|
43
77
|
* - per-consumer deps slices (`APPLY_DEPS` / `REMOVE_DEPS_OWNER` / `onDepsChanged`)
|
|
44
78
|
* - registry integration (config-driven equality, emit-rate circuit breaker)
|
|
45
79
|
*
|
|
46
80
|
* Subscribers can attach via:
|
|
47
|
-
* - `subscribe(listener)` — legacy state listener (back-compat); fires on
|
|
48
|
-
* every flush with the latest state.
|
|
49
81
|
* - `onSystemEvent('stateChanged' | 'dispose' | 'hydrationChanged', cb)` —
|
|
50
82
|
* coarse lifecycle events.
|
|
51
|
-
* - `this.channel.subscribe(interest, cb)` — path-scoped
|
|
83
|
+
* - `this.channel.subscribe(interest, cb)` — path-scoped.
|
|
52
84
|
*/
|
|
53
85
|
export declare abstract class StateContainer<S extends object = any, Args = void, Deps extends object = Record<string, never>> extends StructuralContainer<S> {
|
|
54
86
|
static __excludeFromDevTools: boolean;
|
|
@@ -87,31 +119,42 @@ export declare abstract class StateContainer<S extends object = any, Args = void
|
|
|
87
119
|
private _emitWindowStart;
|
|
88
120
|
private _emitCount;
|
|
89
121
|
private _emitRateWarned;
|
|
90
|
-
private readonly _listeners;
|
|
91
122
|
private readonly _systemEventHandlers;
|
|
92
123
|
private _dependencies;
|
|
93
124
|
private _pendingChange;
|
|
94
125
|
private _bridgeUnsub;
|
|
95
126
|
private _registry;
|
|
96
127
|
private _equalityFn;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
private _name;
|
|
129
|
+
private _debug;
|
|
130
|
+
private _instanceId;
|
|
131
|
+
private _createdAt;
|
|
132
|
+
/**
|
|
133
|
+
* Reserved meta namespace: identity (`name`/`id`/`debug`/`createdAt`),
|
|
134
|
+
* lifecycle (`disposed`/`dependencies`), and the `hydration` sub-surface.
|
|
135
|
+
* Own, frozen, branded data property — `buildTrackedProxy` only intercepts
|
|
136
|
+
* prototype getters, so this own property and its closure-based getters are
|
|
137
|
+
* proxy-safe. See {@link createMeta}.
|
|
138
|
+
*/
|
|
139
|
+
readonly $blac: BlacMeta<S>;
|
|
102
140
|
get args(): Args | undefined;
|
|
103
141
|
/**
|
|
104
|
-
* Declare a cross-bloc dependency. Returns a
|
|
105
|
-
*
|
|
106
|
-
*
|
|
142
|
+
* Declare a cross-bloc dependency. Returns a branded handle with two
|
|
143
|
+
* accessors — the dep instance is resolved against the registry on each call,
|
|
144
|
+
* which keeps the surface immune to dep-instance churn:
|
|
145
|
+
*
|
|
146
|
+
* - `handle.track(options?)` — reactive read. Returns `[state, instance]`.
|
|
147
|
+
* Inside a getter reached through the React proxy this subscribes the
|
|
148
|
+
* reading component to the dep's changes (base impl: live, no subscription).
|
|
149
|
+
* - `handle.untracked(options?)` — returns the live instance with no tracking,
|
|
150
|
+
* for imperative method calls and one-off reads.
|
|
107
151
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* limits the blast radius but a true mutual cycle is still a user bug.
|
|
152
|
+
* `defaultArgs` resolves the dep instance when an accessor is called without
|
|
153
|
+
* its own `args`; per-call `options.args` overrides it and can derive from
|
|
154
|
+
* current state. This does NOT auto-resubscribe outside the React proxy;
|
|
155
|
+
* non-React consumers needing updates should subscribe explicitly.
|
|
113
156
|
*/
|
|
114
|
-
protected depend<T extends StateContainerConstructor>(Type: T,
|
|
157
|
+
protected depend<T extends StateContainerConstructor>(Type: T, defaultArgs?: ExtractArgs<T>): DepHandle<T>;
|
|
115
158
|
constructor(initialState: S, options?: StructuralContainerOptions);
|
|
116
159
|
/**
|
|
117
160
|
* Called once after construction with the args passed at acquire time, before the first
|
|
@@ -119,43 +162,37 @@ export declare abstract class StateContainer<S extends object = any, Args = void
|
|
|
119
162
|
* this.emit(...)) or kick off loads.
|
|
120
163
|
*/
|
|
121
164
|
protected init(_args: Args): void;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
165
|
+
/**
|
|
166
|
+
* @internal Framework-only configuration entry point (registry + testing
|
|
167
|
+
* helpers). Writes the `_`-private identity fields directly, resolves
|
|
168
|
+
* per-class equality, emits the registry `created` event, and runs `init()`
|
|
169
|
+
* once. See {@link INIT_CONFIG}.
|
|
170
|
+
*/
|
|
171
|
+
[INIT_CONFIG](config: StateContainerConfig): void;
|
|
129
172
|
dispose(): void;
|
|
130
173
|
emit(next: S): void;
|
|
131
174
|
/**
|
|
132
175
|
* Override of `StructuralContainer.patch` that routes through the
|
|
133
176
|
* StateContainer concerns: disposed guard, dev-only emit-rate check,
|
|
134
|
-
* `_changedWhileHydrating` flag, pending-change capture (so
|
|
135
|
-
*
|
|
136
|
-
*
|
|
177
|
+
* `_changedWhileHydrating` flag, pending-change capture (so `stateChanged`
|
|
178
|
+
* system events see the merged prev/next), and the registry-level
|
|
179
|
+
* `stateChanged` notification. We still call
|
|
137
180
|
* `super.patch` so path-marking semantics (the whole point of patch) are
|
|
138
181
|
* preserved.
|
|
139
182
|
*/
|
|
140
183
|
patch(partial: DeepPartial<S>): void;
|
|
141
|
-
/**
|
|
142
|
-
* @internal @deprecated Symbol-keyed alias for `emit`. Kept only so legacy
|
|
143
|
-
* in-package tests that index with `[EMIT]` typecheck/run unchanged. C5
|
|
144
|
-
* removes this along with the `EMIT` symbol.
|
|
145
|
-
*/
|
|
146
|
-
protected [EMIT](next: S): void;
|
|
147
184
|
private applyState;
|
|
148
185
|
/**
|
|
149
186
|
* Called by the channel-bridge subscriber on each flush. Drains the
|
|
150
|
-
* pending change (if any) into
|
|
151
|
-
*
|
|
187
|
+
* pending change (if any) into the 'stateChanged' system event.
|
|
188
|
+
* No pending change == flush from a no-op patch == skip.
|
|
152
189
|
*/
|
|
153
190
|
private _drainPending;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
191
|
+
private _beginHydration;
|
|
192
|
+
private _applyHydratedState;
|
|
193
|
+
private _finishHydration;
|
|
194
|
+
private _failHydration;
|
|
195
|
+
private _waitForHydration;
|
|
159
196
|
private setHydrationStatus;
|
|
160
197
|
private ensureHydrationPromise;
|
|
161
198
|
private resolveHydration;
|
|
@@ -105,7 +105,7 @@ export declare class StateContainerRegistry {
|
|
|
105
105
|
* You must call `release()` with the same refId when done.
|
|
106
106
|
*
|
|
107
107
|
* @internal Internal key tier. Public callers use the args-based `acquire`
|
|
108
|
-
* wrapper; `useBloc
|
|
108
|
+
* wrapper; `useBloc` and `watch` address a pre-resolved key here.
|
|
109
109
|
* @param Type - The StateContainer class constructor
|
|
110
110
|
* @param instanceKey - Pre-resolved instance key (defaults to 'default')
|
|
111
111
|
* @param options - Acquisition options
|
|
@@ -114,7 +114,7 @@ export declare class StateContainerRegistry {
|
|
|
114
114
|
* @param options.refId - Named reference ID for debugging; auto-generated if omitted
|
|
115
115
|
* @returns The state container instance
|
|
116
116
|
*/
|
|
117
|
-
acquire<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string
|
|
117
|
+
acquire<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string, options?: {
|
|
118
118
|
canCreate?: boolean;
|
|
119
119
|
countRef?: boolean;
|
|
120
120
|
refId?: string;
|
|
@@ -162,7 +162,7 @@ export declare class StateContainerRegistry {
|
|
|
162
162
|
* @param args - Construction args; used for keying when no explicit key is given
|
|
163
163
|
* @returns The state container instance
|
|
164
164
|
*/
|
|
165
|
-
ensure<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string
|
|
165
|
+
ensure<T extends StateContainerConstructor = StateContainerConstructor>(Type: T, instanceKey?: string, args?: unknown): InstanceType<T>;
|
|
166
166
|
/**
|
|
167
167
|
* Release a reference to an instance.
|
|
168
168
|
* Removes the ref and disposes when refs is empty (unless keepAlive).
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `$blac` meta namespace for `StateContainer`.
|
|
3
|
+
*
|
|
4
|
+
* ──────────────────────────────────────────────────────────────────────────
|
|
5
|
+
* CONSTRAINT — NO ES `#private` FIELDS, ANYWHERE IN THIS FILE.
|
|
6
|
+
*
|
|
7
|
+
* `@blac/react`'s `buildTrackedProxy` invokes prototype getters with a
|
|
8
|
+
* `Proxy(instance)` as the `this`-receiver. Accessing an ES `#private` field
|
|
9
|
+
* through a proxy receiver throws (`#x` brand checks fail on the proxy). The
|
|
10
|
+
* whole point of this meta object is to be proxy-safe: every getter/method
|
|
11
|
+
* here closes over the *real* container instance captured at `createMeta`
|
|
12
|
+
* time, NEVER over a `this`-receiver. Do not "modernize" the `_`-prefixed
|
|
13
|
+
* TS-private reads below into `#private` access.
|
|
14
|
+
* ──────────────────────────────────────────────────────────────────────────
|
|
15
|
+
*/
|
|
16
|
+
import type { HydrationStatus } from './StateContainer';
|
|
17
|
+
import type { StateContainerConstructor } from '../types/utilities';
|
|
18
|
+
/**
|
|
19
|
+
* Hydration sub-surface of {@link BlacMeta}. Exposes the container's
|
|
20
|
+
* hydration state machine — the `begin`/`apply`/`finish`/`fail`/`wait`
|
|
21
|
+
* methods and the `status`/`error`/`isHydrated`/`changedWhileHydrating`
|
|
22
|
+
* getters — namespaced under `$blac`.
|
|
23
|
+
*/
|
|
24
|
+
export interface BlacHydration<S extends object> {
|
|
25
|
+
readonly status: HydrationStatus;
|
|
26
|
+
readonly error: Error | undefined;
|
|
27
|
+
readonly isHydrated: boolean;
|
|
28
|
+
readonly changedWhileHydrating: boolean;
|
|
29
|
+
begin(): void;
|
|
30
|
+
apply(next: S): boolean;
|
|
31
|
+
finish(): void;
|
|
32
|
+
fail(error: Error): void;
|
|
33
|
+
wait(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The reserved `$blac` instance member on every `StateContainer`. Gathers the
|
|
37
|
+
* container's identity/lifecycle/hydration surface (`name`, `id`, `debug`,
|
|
38
|
+
* `createdAt`, `disposed`, `dependencies`, and the hydration methods) under one
|
|
39
|
+
* namespace, keeping the generic names free for userland blocs.
|
|
40
|
+
*
|
|
41
|
+
* The object is allocated once per container, frozen, branded, and exposes
|
|
42
|
+
* live getters that read the container's current `_`-private fields — values
|
|
43
|
+
* are never snapshotted.
|
|
44
|
+
*/
|
|
45
|
+
export interface BlacMeta<S extends object = any> {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly debug: boolean;
|
|
49
|
+
readonly createdAt: number;
|
|
50
|
+
readonly disposed: boolean;
|
|
51
|
+
readonly dependencies: ReadonlyMap<StateContainerConstructor, string>;
|
|
52
|
+
readonly hydration: BlacHydration<S>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Non-enumerable brand carried on every `$blac` object produced by
|
|
56
|
+
* {@link createMeta}. Used by the clobber guard in `StateContainer` to detect
|
|
57
|
+
* a subclass class-field shadowing the base's own `$blac` property, and by the
|
|
58
|
+
* meta tests. Intentionally NOT re-exported from the package barrel.
|
|
59
|
+
*/
|
|
60
|
+
export declare const META_BRAND: unique symbol;
|
|
61
|
+
/**
|
|
62
|
+
* Build the frozen, branded `$blac` meta object for a container.
|
|
63
|
+
*
|
|
64
|
+
* Called from a `StateContainer` field initializer (`$blac = createMeta(this)`).
|
|
65
|
+
* Only the back-reference is captured at this point; every getter/method reads
|
|
66
|
+
* the container's `_`-private fields lazily on access, so field-initializer
|
|
67
|
+
* ordering relative to those private fields is irrelevant.
|
|
68
|
+
*
|
|
69
|
+
* The getters close over `container` (the real instance), never over a
|
|
70
|
+
* `this`-receiver — this is what keeps `$blac` reads safe through
|
|
71
|
+
* `buildTrackedProxy`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createMeta<S extends object>(container: object): BlacMeta<S>;
|
package/dist/core/symbols.d.ts
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal @deprecated Symbol-keyed mutation entry point on `StateContainer`.
|
|
3
|
-
*
|
|
4
|
-
* Per A2 audit (`plans/blac-core-migration/_audit.md`), this symbol has zero
|
|
5
|
-
* external consumers — only in-package tests still reference it. C0 keeps it
|
|
6
|
-
* as a thin alias for `emit()` so the existing test files typecheck and run
|
|
7
|
-
* unchanged; C5 will port those tests to use `emit()` directly and delete
|
|
8
|
-
* this symbol along with its `[EMIT]` method on `StateContainer`.
|
|
9
|
-
*
|
|
10
|
-
* Do not add new uses of this symbol.
|
|
11
|
-
*/
|
|
12
|
-
export declare const EMIT: unique symbol;
|
|
13
1
|
/**
|
|
14
2
|
* @internal Apply one owner's (consumer's) deps slice to an instance.
|
|
15
3
|
* Called by framework adapters (e.g. @blac/react useBloc) — not public API.
|
|
16
|
-
*
|
|
17
|
-
* Kept until D0 ports `useBloc` off the legacy adapter surface. See A2 audit
|
|
18
|
-
* (`plans/blac-core-migration/_audit.md`) for the consumer list.
|
|
19
4
|
*/
|
|
20
5
|
export declare const APPLY_DEPS: unique symbol;
|
|
21
6
|
/**
|
|
22
7
|
* @internal Withdraw one owner's entire deps slice (consumer unmounted).
|
|
23
8
|
* Called by framework adapters — not public API.
|
|
24
|
-
*
|
|
25
|
-
* Kept until D0 ports `useBloc`. See A2 audit for the consumer list.
|
|
26
9
|
*/
|
|
27
10
|
export declare const REMOVE_DEPS_OWNER: unique symbol;
|
|
11
|
+
/**
|
|
12
|
+
* @internal Symbol-keyed configuration entry point on `StateContainer`.
|
|
13
|
+
* Writes the instance's identity fields (`_name`/`_debug`/`_instanceId`),
|
|
14
|
+
* resolves per-class equality, emits the registry `created` event, and runs
|
|
15
|
+
* `init()` once.
|
|
16
|
+
*
|
|
17
|
+
* Framework-only — the registry (`StateContainerRegistry.ensure`) and testing
|
|
18
|
+
* helpers are the sole callers, mirroring the `APPLY_DEPS` precedent.
|
|
19
|
+
*/
|
|
20
|
+
export declare const INIT_CONFIG: unique symbol;
|
package/dist/debug.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_StateContainerRegistry = require("./StateContainerRegistry-
|
|
3
|
-
const require_config = require("./config-
|
|
4
|
-
const require_management = require("./management-
|
|
2
|
+
const require_StateContainerRegistry = require("./StateContainerRegistry-CSNm2Ws5.cjs");
|
|
3
|
+
const require_config = require("./config-C7Ktkjh2.cjs");
|
|
4
|
+
const require_management = require("./management-14vsHr4t.cjs");
|
|
5
5
|
exports.forEach = require_management.forEach;
|
|
6
6
|
exports.getAll = require_management.getAll;
|
|
7
7
|
exports.getRefCount = require_management.getRefCount;
|
package/dist/debug.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as globalRegistry } from "./StateContainerRegistry-
|
|
2
|
-
import { n as getStats, r as setRegistry, t as getRegistry } from "./config-
|
|
3
|
-
import { a as getAll, c as hasInstance, i as forEach, o as getRefCount, r as register, s as getRefIds } from "./management-
|
|
1
|
+
import { r as globalRegistry } from "./StateContainerRegistry-CvBOhAT2.js";
|
|
2
|
+
import { n as getStats, r as setRegistry, t as getRegistry } from "./config-buwpT7l3.js";
|
|
3
|
+
import { a as getAll, c as hasInstance, i as forEach, o as getRefCount, r as register, s as getRefIds } from "./management-BvUAjril.js";
|
|
4
4
|
export { forEach, getAll, getRefCount, getRefIds, getRegistry, getStats, globalRegistry, hasInstance, register, setRegistry };
|