@kontsedal/olas-core 0.0.1 → 0.0.3
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/index.cjs +72 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +72 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +71 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{root-BCZDC5Fv.mjs → root-Cnkb3I--.mjs} +556 -28
- package/dist/root-Cnkb3I--.mjs.map +1 -0
- package/dist/{root-DXV1gVbQ.cjs → root-D_xAdcom.cjs} +556 -28
- package/dist/root-D_xAdcom.cjs.map +1 -0
- package/dist/testing.cjs +2 -1
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -1
- package/dist/testing.d.cts.map +1 -1
- package/dist/testing.d.mts +2 -1
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +2 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/{types-CffZ1QXt.d.cts → types-CRn4UoLn.d.mts} +196 -8
- package/dist/types-CRn4UoLn.d.mts.map +1 -0
- package/dist/{types-DSlDowpE.d.mts → types-r_TVaRkD.d.cts} +196 -8
- package/dist/types-r_TVaRkD.d.cts.map +1 -0
- package/package.json +1 -1
- package/src/controller/index.ts +6 -0
- package/src/controller/instance.ts +317 -3
- package/src/controller/types.ts +151 -0
- package/src/emitter.ts +34 -3
- package/src/forms/field.ts +42 -9
- package/src/forms/form-types.ts +37 -0
- package/src/forms/form.ts +165 -5
- package/src/forms/index.ts +12 -1
- package/src/forms/standard-schema.ts +37 -0
- package/src/forms/validators.ts +31 -0
- package/src/index.ts +20 -4
- package/src/query/entry.ts +10 -3
- package/src/query/infinite.ts +8 -1
- package/src/query/structural-share.ts +114 -0
- package/src/query/types.ts +15 -2
- package/src/query/use.ts +47 -13
- package/src/signals/readonly.ts +3 -3
- package/src/testing.ts +2 -0
- package/src/timing/debounced.ts +24 -4
- package/src/timing/throttled.ts +22 -3
- package/src/utils.ts +8 -4
- package/dist/root-BCZDC5Fv.mjs.map +0 -1
- package/dist/root-DXV1gVbQ.cjs.map +0 -1
- package/dist/types-CffZ1QXt.d.cts.map +0 -1
- package/dist/types-DSlDowpE.d.mts.map +0 -1
|
@@ -15,13 +15,27 @@ type Emitter<T> = {
|
|
|
15
15
|
once(handler: (value: T) => void): () => void; /** Tear down the emitter. Subsequent `emit` / `on` / `once` are no-ops. */
|
|
16
16
|
dispose(): void;
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Optional escape hatch for emit-time handler throws. If supplied, a thrown
|
|
20
|
+
* handler is reported here and emission continues with the remaining handlers
|
|
21
|
+
* (spec §20.6 — one throwing handler must not block the rest). If absent,
|
|
22
|
+
* the throw is logged via `console.error`.
|
|
23
|
+
*/
|
|
24
|
+
type EmitterErrorReporter = (err: unknown) => void;
|
|
18
25
|
/**
|
|
19
26
|
* Create a standalone emitter. Handlers persist until explicitly unsubscribed
|
|
20
27
|
* (or the emitter is disposed). Use this for emitters that live outside any
|
|
21
28
|
* single controller — typically in deps. Use `ctx.emitter()` for emitters that
|
|
22
29
|
* should auto-clean with a controller.
|
|
30
|
+
*
|
|
31
|
+
* Pass `onError` to receive emit-time handler throws (spec §20.6 — one
|
|
32
|
+
* throwing handler must not block the rest of the fan-out). `ctx.emitter()`
|
|
33
|
+
* wires this to the root's `onError` so deps-level emitters get isolation
|
|
34
|
+
* by default when constructed via `ctx`.
|
|
23
35
|
*/
|
|
24
|
-
declare function createEmitter<T = void>(
|
|
36
|
+
declare function createEmitter<T = void>(options?: {
|
|
37
|
+
onError?: EmitterErrorReporter;
|
|
38
|
+
}): Emitter<T>;
|
|
25
39
|
//#endregion
|
|
26
40
|
//#region src/errors.d.ts
|
|
27
41
|
/**
|
|
@@ -129,7 +143,21 @@ type Form<S extends FormSchema> = {
|
|
|
129
143
|
readonly isValid: ReadSignal<boolean>;
|
|
130
144
|
readonly isDirty: ReadSignal<boolean>;
|
|
131
145
|
readonly touched: ReadSignal<boolean>;
|
|
132
|
-
readonly isValidating: ReadSignal<boolean>;
|
|
146
|
+
readonly isValidating: ReadSignal<boolean>;
|
|
147
|
+
/**
|
|
148
|
+
* `true` while a `submit(...)` is in flight. Clears when the handler
|
|
149
|
+
* resolves, throws, or pre-submit validation fails.
|
|
150
|
+
*/
|
|
151
|
+
readonly isSubmitting: ReadSignal<boolean>; /** Number of times `submit(...)` has been called. Bumps before the handler runs. */
|
|
152
|
+
readonly submitCount: ReadSignal<number>;
|
|
153
|
+
/**
|
|
154
|
+
* The thrown value from the most recent failed submission, if any.
|
|
155
|
+
* Cleared at the start of each new `submit(...)` call and on `reset()`.
|
|
156
|
+
* Note that a validation failure ("submit blocked because the form is
|
|
157
|
+
* invalid") is NOT a thrown error — `submitError` stays whatever it
|
|
158
|
+
* was, and the returned promise resolves with `{ ok: false }`.
|
|
159
|
+
*/
|
|
160
|
+
readonly submitError: ReadSignal<unknown>; /** Deep-merge a partial value into the form, batched. */
|
|
133
161
|
set(partial: DeepPartial<FormValue<S>>): void;
|
|
134
162
|
/**
|
|
135
163
|
* Re-seat the form's leaves from `partial` as their new initials —
|
|
@@ -140,7 +168,29 @@ type Form<S extends FormSchema> = {
|
|
|
140
168
|
resetWithInitial(partial: DeepPartial<FormValue<S>>): void; /** Reset every leaf to its initial value. */
|
|
141
169
|
reset(): void; /** Mark every leaf as touched (so error messages appear). */
|
|
142
170
|
markAllTouched(): void; /** Re-run every leaf's validators. Resolves with true if all leaves are valid. */
|
|
143
|
-
validate(): Promise<boolean>;
|
|
171
|
+
validate(): Promise<boolean>;
|
|
172
|
+
/**
|
|
173
|
+
* Run a submission. Pre-validates the form (unless `validateBeforeSubmit: false`),
|
|
174
|
+
* then calls `handler(value)`. Maintains `isSubmitting` / `submitCount` /
|
|
175
|
+
* `submitError`. Returns `{ ok, data?, error? }` — see `FormImpl.submit`
|
|
176
|
+
* for the full contract.
|
|
177
|
+
*/
|
|
178
|
+
submit(handler: (value: FormValue<S>) => unknown | Promise<unknown>, options?: {
|
|
179
|
+
validateBeforeSubmit?: boolean;
|
|
180
|
+
resetOnSuccess?: boolean;
|
|
181
|
+
onError?: 'rethrow' | 'capture';
|
|
182
|
+
}): Promise<{
|
|
183
|
+
ok: boolean;
|
|
184
|
+
data?: unknown;
|
|
185
|
+
error?: unknown;
|
|
186
|
+
}>;
|
|
187
|
+
/**
|
|
188
|
+
* Pin externally-sourced errors on specific fields. Keys are dot-separated
|
|
189
|
+
* paths through nested forms / field arrays (numeric segments are array
|
|
190
|
+
* indices). Errors land in each field's `serverErrors` channel — kept
|
|
191
|
+
* separate from validator output and auto-cleared on the next user write.
|
|
192
|
+
*/
|
|
193
|
+
setErrors(errors: Record<string, ReadonlyArray<string>>): void; /** Idempotent. Called by the owning controller's dispose. */
|
|
144
194
|
dispose(): void;
|
|
145
195
|
};
|
|
146
196
|
/**
|
|
@@ -310,8 +360,12 @@ type Query<Args extends unknown[], T> = {
|
|
|
310
360
|
type QuerySubscription<T> = AsyncState<T>;
|
|
311
361
|
/**
|
|
312
362
|
* Options passed to `ctx.use(query, opts)` to control the subscription
|
|
313
|
-
* (reactive key, enabled-gating). The `key` thunk reads signals —
|
|
314
|
-
* when they change re-keys the subscription.
|
|
363
|
+
* (reactive key, enabled-gating). The `key` thunk reads signals —
|
|
364
|
+
* re-evaluating when they change re-keys the subscription.
|
|
365
|
+
*
|
|
366
|
+
* A `select` projection that maps the underlying data shape to a view
|
|
367
|
+
* shape is accepted via a dedicated overload on `Ctx.use` rather than this
|
|
368
|
+
* options bag — the overload threads `T → U` types through cleanly.
|
|
315
369
|
*/
|
|
316
370
|
type UseOptions<Args extends readonly unknown[]> = {
|
|
317
371
|
key?: () => Args;
|
|
@@ -754,6 +808,10 @@ interface AmbientDeps {
|
|
|
754
808
|
* `ctx.field(initial, validators?)`. Spec §8, §20.7.
|
|
755
809
|
*/
|
|
756
810
|
type Field<T> = ReadSignal<T> & {
|
|
811
|
+
/**
|
|
812
|
+
* All errors currently surfaced on this field — validator errors first,
|
|
813
|
+
* server errors after. See `setErrors` for the server-error channel.
|
|
814
|
+
*/
|
|
757
815
|
errors: ReadSignal<string[]>;
|
|
758
816
|
isValid: ReadSignal<boolean>;
|
|
759
817
|
isDirty: ReadSignal<boolean>;
|
|
@@ -770,7 +828,16 @@ type Field<T> = ReadSignal<T> & {
|
|
|
770
828
|
setAsInitial(value: T): void;
|
|
771
829
|
reset(): void;
|
|
772
830
|
markTouched(): void;
|
|
773
|
-
revalidate(): Promise<boolean>;
|
|
831
|
+
revalidate(): Promise<boolean>;
|
|
832
|
+
/**
|
|
833
|
+
* Pin externally-sourced errors on the field — typically server-side
|
|
834
|
+
* validation results returned from a failed submit. These errors live in
|
|
835
|
+
* a separate channel from validator output, so a re-run of local
|
|
836
|
+
* validators (triggered by a new value or `revalidate()`) does NOT clear
|
|
837
|
+
* them. They're cleared automatically the next time the user writes to
|
|
838
|
+
* the field (via `set`), or explicitly via `setErrors([])` / `reset()`.
|
|
839
|
+
*/
|
|
840
|
+
setErrors(errors: ReadonlyArray<string>): void; /** Idempotent. Called by the owning controller's dispose. */
|
|
774
841
|
dispose(): void;
|
|
775
842
|
};
|
|
776
843
|
/**
|
|
@@ -789,6 +856,76 @@ type ControllerDef<Props, Api> = {
|
|
|
789
856
|
type CtrlProps<C> = C extends ControllerDef<infer P, unknown> ? P : never;
|
|
790
857
|
/** Extract a controller's Api type. */
|
|
791
858
|
type CtrlApi<C> = C extends ControllerDef<unknown, infer A> ? A : never;
|
|
859
|
+
/**
|
|
860
|
+
* The reactive surface returned by `ctx.collection(...)`. `items` is the
|
|
861
|
+
* canonical ordered view (source-order, with any construction-failed items
|
|
862
|
+
* filtered out); `size` mirrors `items.length`; `get` / `has` are
|
|
863
|
+
* imperative key lookups. SPEC §11.1.
|
|
864
|
+
*/
|
|
865
|
+
type Collection<K, Api> = {
|
|
866
|
+
readonly items: ReadSignal<ReadonlyArray<{
|
|
867
|
+
readonly key: K;
|
|
868
|
+
readonly api: Api;
|
|
869
|
+
}>>;
|
|
870
|
+
readonly size: ReadSignal<number>;
|
|
871
|
+
get(key: K): Api | undefined;
|
|
872
|
+
has(key: K): boolean;
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* Homogeneous form of `ctx.collection`: one controller def for every item,
|
|
876
|
+
* with `propsOf` projecting each item to the controller's `Props`. Construct
|
|
877
|
+
* happens once per new key — `propsOf` is **not** re-applied for unchanged
|
|
878
|
+
* keys.
|
|
879
|
+
*/
|
|
880
|
+
type CollectionHomogeneousOptions<Item, K, Props, Api, TDeps = AmbientDeps> = {
|
|
881
|
+
readonly source: ReadSignal<readonly Item[]>;
|
|
882
|
+
readonly keyOf: (item: Item) => K;
|
|
883
|
+
readonly controller: ControllerDef<Props, Api>;
|
|
884
|
+
readonly propsOf: (item: Item) => Props;
|
|
885
|
+
readonly factory?: never;
|
|
886
|
+
readonly propsFor?: never;
|
|
887
|
+
readonly deps?: Partial<TDeps>;
|
|
888
|
+
};
|
|
889
|
+
/**
|
|
890
|
+
* Heterogeneous form of `ctx.collection`: a single `factory` decides per-item
|
|
891
|
+
* which controller + props to construct. When a key's factory result picks a
|
|
892
|
+
* *different* controller than last time, the existing child is disposed and
|
|
893
|
+
* the new one constructed (type-discriminant rebuild).
|
|
894
|
+
*
|
|
895
|
+
* `R` is the factory's *return type* (typically inferred as the union of the
|
|
896
|
+
* branches' `{ controller, props }` shapes). `Api` is then projected out as
|
|
897
|
+
* the union of every branch's controller Api via `CollectionFactoryApi<R>` —
|
|
898
|
+
* unlike a single `Api` generic, the union doesn't collapse to the first
|
|
899
|
+
* branch.
|
|
900
|
+
*/
|
|
901
|
+
type CollectionFactoryOptions<Item, K, R, TDeps = AmbientDeps> = {
|
|
902
|
+
readonly source: ReadSignal<readonly Item[]>;
|
|
903
|
+
readonly keyOf: (item: Item) => K;
|
|
904
|
+
readonly controller?: never;
|
|
905
|
+
readonly propsOf?: never;
|
|
906
|
+
readonly factory: (item: Item) => R;
|
|
907
|
+
readonly deps?: Partial<TDeps>;
|
|
908
|
+
};
|
|
909
|
+
/** Constraint for the factory form's return shape. */
|
|
910
|
+
type CollectionFactoryResult = {
|
|
911
|
+
controller: ControllerDef<any, any>;
|
|
912
|
+
props: any;
|
|
913
|
+
};
|
|
914
|
+
/** Extract the union of every branch's controller Api. Distributes over R. */
|
|
915
|
+
type CollectionFactoryApi<R> = R extends {
|
|
916
|
+
controller: ControllerDef<any, infer A>;
|
|
917
|
+
} ? A : never;
|
|
918
|
+
/**
|
|
919
|
+
* Handle returned by `ctx.lazyChild(...)`. `status` walks `idle → loading →
|
|
920
|
+
* (ready | error)`; `api` becomes defined once `status === 'ready'`. SPEC §16.5.
|
|
921
|
+
*/
|
|
922
|
+
type LazyChild<Api> = {
|
|
923
|
+
readonly status: ReadSignal<'idle' | 'loading' | 'ready' | 'error'>;
|
|
924
|
+
readonly api: ReadSignal<Api | undefined>;
|
|
925
|
+
readonly error: ReadSignal<unknown | undefined>;
|
|
926
|
+
load(): Promise<Api>;
|
|
927
|
+
dispose(): void;
|
|
928
|
+
};
|
|
792
929
|
/**
|
|
793
930
|
* `ctx` is the lifecycle-bound surface every controller factory receives.
|
|
794
931
|
* Every primitive constructed through `ctx` is owned by the controller and
|
|
@@ -806,6 +943,11 @@ type Ctx<TDeps = AmbientDeps> = {
|
|
|
806
943
|
}): LocalCache<T>;
|
|
807
944
|
use<Args extends unknown[], T>(source: Query<Args, T>, keyOrOptions?: (() => Args) | UseOptions<Args>): QuerySubscription<T>;
|
|
808
945
|
use<Args extends unknown[], TPage, TItem>(source: InfiniteQuery<Args, TPage, TItem>, keyOrOptions?: (() => Args) | UseOptions<Args>): InfiniteQuerySubscription<TPage, TItem>;
|
|
946
|
+
use<Args extends unknown[], T, U>(source: Query<Args, T>, options: {
|
|
947
|
+
key?: () => Args;
|
|
948
|
+
enabled?: () => boolean;
|
|
949
|
+
select: (data: T) => U;
|
|
950
|
+
}): QuerySubscription<U>;
|
|
809
951
|
mutation<V, R>(spec: MutationSpec<V, R>): Mutation<V, R>;
|
|
810
952
|
emitter<T = void>(): Emitter<T>;
|
|
811
953
|
field<T>(initial: T, validators?: ReadonlyArray<Validator<T>>): Field<T>;
|
|
@@ -840,6 +982,52 @@ type Ctx<TDeps = AmbientDeps> = {
|
|
|
840
982
|
suspend: () => void;
|
|
841
983
|
resume: () => void;
|
|
842
984
|
};
|
|
985
|
+
/**
|
|
986
|
+
* Ephemeral child controller bound to either (a) the explicit `dispose()`
|
|
987
|
+
* call returned in the tuple, or (b) the parent's disposal — whichever
|
|
988
|
+
* comes first. Same lifecycle semantics as `ctx.attach` minus suspend /
|
|
989
|
+
* resume (sessions are short-lived, not pause-able). Returns a `[api,
|
|
990
|
+
* dispose]` tuple so the api shape is exactly the controller's return
|
|
991
|
+
* type, with no wrapper to unpack.
|
|
992
|
+
*
|
|
993
|
+
* Use cases: modal forms, inline edit sessions, wizards, command palette.
|
|
994
|
+
* SPEC §11.1.
|
|
995
|
+
*/
|
|
996
|
+
session<Props, Api>(def: ControllerDef<Props, Api>, props: Props, options?: {
|
|
997
|
+
deps?: Partial<TDeps>;
|
|
998
|
+
}): readonly [api: Api, dispose: () => void];
|
|
999
|
+
/**
|
|
1000
|
+
* Diff-by-key set of child controllers driven by a reactive `source`.
|
|
1001
|
+
* On every change to `source`, the collection:
|
|
1002
|
+
* - **new keys** → construct a child via `controller` + `propsOf(item)`
|
|
1003
|
+
* (or `factory(item)` for the heterogeneous form);
|
|
1004
|
+
* - **removed keys** → dispose that child;
|
|
1005
|
+
* - **unchanged keys** → leave it alone (`propsOf` is NOT re-applied).
|
|
1006
|
+
*
|
|
1007
|
+
* For per-item type-discriminated children, use the `factory` form —
|
|
1008
|
+
* type changes for an existing key dispose and reconstruct.
|
|
1009
|
+
*
|
|
1010
|
+
* Construction errors (factory or controller throw) are routed to
|
|
1011
|
+
* `onError` with `kind: 'construction'` and the item is **skipped** —
|
|
1012
|
+
* the collection's surface shows one fewer entry. The diff loop does
|
|
1013
|
+
* not re-throw. SPEC §11.1, §12.1.6.
|
|
1014
|
+
*/
|
|
1015
|
+
collection<Item, K, Props, Api>(options: CollectionHomogeneousOptions<Item, K, Props, Api, TDeps>): Collection<K, Api>;
|
|
1016
|
+
collection<Item, K, R extends CollectionFactoryResult>(options: CollectionFactoryOptions<Item, K, R, TDeps>): Collection<K, CollectionFactoryApi<R>>;
|
|
1017
|
+
/**
|
|
1018
|
+
* Code-split child controller. The loader is invoked on `load()`
|
|
1019
|
+
* (idempotent), then the controller is constructed with the supplied
|
|
1020
|
+
* `props`. `status` / `api` / `error` are reactive signals; subscribe
|
|
1021
|
+
* via `use(child.api)` in your view layer.
|
|
1022
|
+
*
|
|
1023
|
+
* Parent disposal disposes the loaded child (if any) and flags any
|
|
1024
|
+
* in-flight load so its eventual settle is dropped on the floor.
|
|
1025
|
+
* Construction or import failures route through `onError` with
|
|
1026
|
+
* `kind: 'construction'`. SPEC §16.5.
|
|
1027
|
+
*/
|
|
1028
|
+
lazyChild<Props, Api>(loader: () => Promise<ControllerDef<Props, Api>>, props: Props, options?: {
|
|
1029
|
+
deps?: Partial<TDeps>;
|
|
1030
|
+
}): LazyChild<Api>;
|
|
843
1031
|
effect(fn: () => void | (() => void)): void;
|
|
844
1032
|
on<T>(emitter: Emitter<T>, handler: (value: T) => void): void;
|
|
845
1033
|
provide<T>(scope: Scope<T>, value: T): void;
|
|
@@ -884,5 +1072,5 @@ type Root<Api> = Api & {
|
|
|
884
1072
|
readonly __debug: DebugBus;
|
|
885
1073
|
};
|
|
886
1074
|
//#endregion
|
|
887
|
-
export {
|
|
888
|
-
//# sourceMappingURL=types-
|
|
1075
|
+
export { FormErrors as $, DebugEvent as A, QuerySpec as B, SetDataEvent as C, MutationSpec as D, MutationConcurrency as E, AsyncStatus as F, UseOptions as G, RetryDelay as H, DehydratedEntry as I, FieldArrayItemErrors as J, DeepPartial as K, DehydratedState as L, InfiniteQuerySpec as M, InfiniteQuerySubscription as N, DebugBus as O, AsyncState as P, Form as Q, LocalCache as R, RegisteredQuery as S, Mutation as T, RetryPolicy as U, QuerySubscription as V, Snapshot as W, FieldArrayValidator as X, FieldArrayOptions as Y, FieldArrayValue as Z, defineScope as _, CollectionFactoryResult as a, Validator as at, QueryClientPlugin as b, CtrlApi as c, Signal as ct, Field as d, EmitterErrorReporter as dt, FormOptions as et, LazyChild as f, createEmitter as ft, ScopeOptions as g, Scope as h, CollectionFactoryOptions as i, ItemInitial as it, InfiniteQuery as j, DebugCacheEntry as k, CtrlProps as l, ErrorContext as lt, RootOptions as m, Collection as n, FormValidator as nt, CollectionHomogeneousOptions as o, Computed as ot, Root as p, FieldArray as q, CollectionFactoryApi as r, FormValue as rt, ControllerDef as s, ReadSignal as st, AmbientDeps as t, FormSchema as tt, Ctx as u, Emitter as ut, GcEvent as v, lookupRegisteredQuery as w, QueryClientPluginApi as x, InvalidateEvent as y, Query as z };
|
|
1076
|
+
//# sourceMappingURL=types-r_TVaRkD.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-r_TVaRkD.d.cts","names":[],"sources":["../src/emitter.ts","../src/errors.ts","../src/signals/types.ts","../src/forms/types.ts","../src/forms/form-types.ts","../src/query/types.ts","../src/query/infinite.ts","../src/devtools.ts","../src/query/mutation.ts","../src/query/plugin.ts","../src/scope.ts","../src/controller/types.ts"],"mappings":";;AAUA;;;;;;;;;KAAY,OAAA;EACV,IAAA,GAAO,CAAA,iCAAkC,KAAA,EAAO,CAAA,WAAzC;EAEP,EAAA,CAAG,OAAA,GAAU,KAAA,EAAO,CAAA,wBAFqB;EAIzC,IAAA,CAAK,OAAA,GAAU,KAAA,EAAO,CAAA,wBAFF;EAIpB,OAAA;AAAA;;;;;;;KAWU,oBAAA,IAAwB,GAAY;AAAhD;;;;AAAgD;AAyEhD;;;;;;AAzEA,iBAyEgB,aAAA,UAAA,CAAwB,OAAA;EAAY,OAAA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
|
2
2
|
export { createRoot, createRootWithProps } from './root'
|
|
3
3
|
export type {
|
|
4
4
|
AmbientDeps,
|
|
5
|
+
Collection,
|
|
6
|
+
CollectionFactoryApi,
|
|
7
|
+
CollectionFactoryOptions,
|
|
8
|
+
CollectionFactoryResult,
|
|
9
|
+
CollectionHomogeneousOptions,
|
|
5
10
|
ControllerDef,
|
|
6
11
|
CtrlApi,
|
|
7
12
|
CtrlProps,
|
|
8
13
|
Ctx,
|
|
9
14
|
Field,
|
|
15
|
+
LazyChild,
|
|
10
16
|
Root,
|
|
11
17
|
RootOptions,
|
|
12
18
|
} from './types'
|
|
@@ -24,9 +24,19 @@ import { createMutation, type Mutation, type MutationSpec } from '../query/mutat
|
|
|
24
24
|
import type { LocalCache, Query } from '../query/types'
|
|
25
25
|
import { createInfiniteUse, createUse } from '../query/use'
|
|
26
26
|
import type { Scope } from '../scope'
|
|
27
|
-
import { effect as standaloneEffect } from '../signals'
|
|
27
|
+
import { computed, signal, effect as standaloneEffect } from '../signals'
|
|
28
28
|
import { getFactory, getName } from './define'
|
|
29
|
-
import type {
|
|
29
|
+
import type {
|
|
30
|
+
Collection,
|
|
31
|
+
CollectionFactoryApi,
|
|
32
|
+
CollectionFactoryOptions,
|
|
33
|
+
CollectionFactoryResult,
|
|
34
|
+
CollectionHomogeneousOptions,
|
|
35
|
+
ControllerDef,
|
|
36
|
+
Ctx,
|
|
37
|
+
Field,
|
|
38
|
+
LazyChild,
|
|
39
|
+
} from './types'
|
|
30
40
|
|
|
31
41
|
export type RootShared = {
|
|
32
42
|
readonly devtools: DevtoolsEmitter
|
|
@@ -342,7 +352,17 @@ export class ControllerInstance {
|
|
|
342
352
|
},
|
|
343
353
|
|
|
344
354
|
emitter<T>(): Emitter<T> {
|
|
345
|
-
const e = createEmitter<T>(
|
|
355
|
+
const e = createEmitter<T>({
|
|
356
|
+
// Spec §20.6: emit-time handler throws must not block sibling
|
|
357
|
+
// handlers. Route to the root's onError with kind: 'emitter' and
|
|
358
|
+
// this controller's path.
|
|
359
|
+
onError: (err) => {
|
|
360
|
+
dispatchError(self.rootShared.onError, err, {
|
|
361
|
+
kind: 'emitter',
|
|
362
|
+
controllerPath: self.path,
|
|
363
|
+
})
|
|
364
|
+
},
|
|
365
|
+
})
|
|
346
366
|
self.entries.push({ kind: 'cleanup', dispose: () => e.dispose() })
|
|
347
367
|
return e
|
|
348
368
|
},
|
|
@@ -535,6 +555,300 @@ export class ControllerInstance {
|
|
|
535
555
|
}
|
|
536
556
|
},
|
|
537
557
|
|
|
558
|
+
session<Props, Api>(
|
|
559
|
+
def: ControllerDef<Props, Api>,
|
|
560
|
+
props: Props,
|
|
561
|
+
options?: { deps?: Partial<Record<string, unknown>> },
|
|
562
|
+
): readonly [Api, () => void] {
|
|
563
|
+
const segment = self.makeChildSegment(getFactory(def), getName(def))
|
|
564
|
+
const override = options?.deps
|
|
565
|
+
const childDeps = override !== undefined ? { ...self.deps, ...override } : self.deps
|
|
566
|
+
const childInstance = new ControllerInstance(self, self.rootShared, segment, childDeps)
|
|
567
|
+
const api = childInstance.construct(getFactory(def), props)
|
|
568
|
+
const entry: LifecycleEntry = { kind: 'child', instance: childInstance }
|
|
569
|
+
self.entries.push(entry)
|
|
570
|
+
let disposed = false
|
|
571
|
+
const dispose = (): void => {
|
|
572
|
+
if (disposed) return
|
|
573
|
+
disposed = true
|
|
574
|
+
const idx = self.entries.indexOf(entry)
|
|
575
|
+
if (idx >= 0) self.entries.splice(idx, 1)
|
|
576
|
+
try {
|
|
577
|
+
childInstance.dispose()
|
|
578
|
+
} catch (err) {
|
|
579
|
+
dispatchError(self.rootShared.onError, err, {
|
|
580
|
+
kind: 'effect',
|
|
581
|
+
controllerPath: self.path,
|
|
582
|
+
})
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return [api, dispose] as const
|
|
586
|
+
},
|
|
587
|
+
|
|
588
|
+
collection<Item, K, Props, Api, R extends CollectionFactoryResult>(
|
|
589
|
+
options:
|
|
590
|
+
| CollectionHomogeneousOptions<Item, K, Props, Api>
|
|
591
|
+
| CollectionFactoryOptions<Item, K, R>,
|
|
592
|
+
): Collection<K, Api> | Collection<K, CollectionFactoryApi<R>> {
|
|
593
|
+
type ChildInfo = {
|
|
594
|
+
instance: ControllerInstance
|
|
595
|
+
api: Api
|
|
596
|
+
entry: LifecycleEntry
|
|
597
|
+
// For factory form: the controller def used to construct this child.
|
|
598
|
+
// A different def on a future render means "rebuild with new type".
|
|
599
|
+
def: ControllerDef<unknown, unknown>
|
|
600
|
+
}
|
|
601
|
+
const childMap = new Map<K, ChildInfo>()
|
|
602
|
+
const items$ = signal<ReadonlyArray<{ key: K; api: Api }>>([])
|
|
603
|
+
const size$ = computed(() => items$.value.length)
|
|
604
|
+
|
|
605
|
+
const isFactoryForm =
|
|
606
|
+
(options as CollectionFactoryOptions<Item, K, R>).factory !== undefined
|
|
607
|
+
|
|
608
|
+
const buildChild = (
|
|
609
|
+
item: Item,
|
|
610
|
+
): {
|
|
611
|
+
instance: ControllerInstance
|
|
612
|
+
api: Api
|
|
613
|
+
def: ControllerDef<unknown, unknown>
|
|
614
|
+
} | null => {
|
|
615
|
+
let def: ControllerDef<unknown, unknown>
|
|
616
|
+
let childProps: unknown
|
|
617
|
+
if (isFactoryForm) {
|
|
618
|
+
const factoryOpts = options as CollectionFactoryOptions<Item, K, R>
|
|
619
|
+
const result = factoryOpts.factory(item) as CollectionFactoryResult
|
|
620
|
+
def = result.controller as ControllerDef<unknown, unknown>
|
|
621
|
+
childProps = result.props
|
|
622
|
+
} else {
|
|
623
|
+
const homoOpts = options as CollectionHomogeneousOptions<Item, K, Props, Api>
|
|
624
|
+
def = homoOpts.controller as unknown as ControllerDef<unknown, unknown>
|
|
625
|
+
childProps = homoOpts.propsOf(item)
|
|
626
|
+
}
|
|
627
|
+
const segment = self.makeChildSegment(getFactory(def), getName(def))
|
|
628
|
+
const childDeps =
|
|
629
|
+
options.deps !== undefined ? { ...self.deps, ...options.deps } : self.deps
|
|
630
|
+
const instance = new ControllerInstance(self, self.rootShared, segment, childDeps)
|
|
631
|
+
try {
|
|
632
|
+
const api = instance.construct(
|
|
633
|
+
getFactory(def) as (ctx: Ctx, props: unknown) => Api,
|
|
634
|
+
childProps,
|
|
635
|
+
)
|
|
636
|
+
return { instance, api, def }
|
|
637
|
+
} catch (err) {
|
|
638
|
+
// SPEC §12.1.6: runtime construction errors in collection items
|
|
639
|
+
// route to onError; the bad item is skipped.
|
|
640
|
+
dispatchError(self.rootShared.onError, err, {
|
|
641
|
+
kind: 'construction',
|
|
642
|
+
controllerPath: self.path,
|
|
643
|
+
})
|
|
644
|
+
return null
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
const removeKey = (key: K): void => {
|
|
649
|
+
const info = childMap.get(key)
|
|
650
|
+
if (info === undefined) return
|
|
651
|
+
childMap.delete(key)
|
|
652
|
+
const idx = self.entries.indexOf(info.entry)
|
|
653
|
+
if (idx >= 0) self.entries.splice(idx, 1)
|
|
654
|
+
try {
|
|
655
|
+
info.instance.dispose()
|
|
656
|
+
} catch (err) {
|
|
657
|
+
dispatchError(self.rootShared.onError, err, {
|
|
658
|
+
kind: 'effect',
|
|
659
|
+
controllerPath: self.path,
|
|
660
|
+
})
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
const reconcile = (): void => {
|
|
665
|
+
const source = options.source.value
|
|
666
|
+
const itemByKey = new Map<K, Item>()
|
|
667
|
+
for (const item of source) {
|
|
668
|
+
const key = options.keyOf(item)
|
|
669
|
+
if (!itemByKey.has(key)) itemByKey.set(key, item)
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// Drop removed keys.
|
|
673
|
+
for (const key of [...childMap.keys()]) {
|
|
674
|
+
if (!itemByKey.has(key)) removeKey(key)
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// Add new keys + rebuild factory-form type changes.
|
|
678
|
+
for (const [key, item] of itemByKey) {
|
|
679
|
+
const existing = childMap.get(key)
|
|
680
|
+
if (existing !== undefined) {
|
|
681
|
+
if (isFactoryForm) {
|
|
682
|
+
const result = (options as CollectionFactoryOptions<Item, K, R>).factory(
|
|
683
|
+
item,
|
|
684
|
+
) as CollectionFactoryResult
|
|
685
|
+
if ((result.controller as unknown) !== existing.def) {
|
|
686
|
+
removeKey(key)
|
|
687
|
+
const built = buildChild(item)
|
|
688
|
+
if (built !== null) {
|
|
689
|
+
const entry: LifecycleEntry = { kind: 'child', instance: built.instance }
|
|
690
|
+
self.entries.push(entry)
|
|
691
|
+
childMap.set(key, { ...built, entry })
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
continue
|
|
696
|
+
}
|
|
697
|
+
const built = buildChild(item)
|
|
698
|
+
if (built !== null) {
|
|
699
|
+
const entry: LifecycleEntry = { kind: 'child', instance: built.instance }
|
|
700
|
+
self.entries.push(entry)
|
|
701
|
+
childMap.set(key, { ...built, entry })
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// Project to items signal in source order, deduped, skipping failures.
|
|
706
|
+
const next: Array<{ key: K; api: Api }> = []
|
|
707
|
+
const seen = new Set<K>()
|
|
708
|
+
for (const item of source) {
|
|
709
|
+
const key = options.keyOf(item)
|
|
710
|
+
if (seen.has(key)) continue
|
|
711
|
+
seen.add(key)
|
|
712
|
+
const info = childMap.get(key)
|
|
713
|
+
if (info !== undefined) next.push({ key, api: info.api })
|
|
714
|
+
}
|
|
715
|
+
items$.set(next)
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// Register the diff loop as an 'effect' entry so it pauses on suspend
|
|
719
|
+
// and re-runs on resume — mirrors how `ctx.effect` is wired.
|
|
720
|
+
const wrapped = (): void => {
|
|
721
|
+
try {
|
|
722
|
+
reconcile()
|
|
723
|
+
} catch (err) {
|
|
724
|
+
dispatchError(self.rootShared.onError, err, {
|
|
725
|
+
kind: 'effect',
|
|
726
|
+
controllerPath: self.path,
|
|
727
|
+
})
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
const effectEntry: LifecycleEntry = {
|
|
731
|
+
kind: 'effect',
|
|
732
|
+
factory: wrapped,
|
|
733
|
+
dispose: null,
|
|
734
|
+
}
|
|
735
|
+
if (self.state !== 'suspended') {
|
|
736
|
+
effectEntry.dispose = standaloneEffect(wrapped)
|
|
737
|
+
}
|
|
738
|
+
self.entries.push(effectEntry)
|
|
739
|
+
|
|
740
|
+
return {
|
|
741
|
+
items: items$,
|
|
742
|
+
size: size$,
|
|
743
|
+
get: (key: K) => childMap.get(key)?.api,
|
|
744
|
+
has: (key: K) => childMap.has(key),
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
|
|
748
|
+
lazyChild<Props, Api>(
|
|
749
|
+
loader: () => Promise<ControllerDef<Props, Api>>,
|
|
750
|
+
props: Props,
|
|
751
|
+
options?: { deps?: Partial<Record<string, unknown>> },
|
|
752
|
+
): LazyChild<Api> {
|
|
753
|
+
const status$ = signal<'idle' | 'loading' | 'ready' | 'error'>('idle')
|
|
754
|
+
const api$ = signal<Api | undefined>(undefined)
|
|
755
|
+
const error$ = signal<unknown | undefined>(undefined)
|
|
756
|
+
|
|
757
|
+
let childInstance: ControllerInstance | null = null
|
|
758
|
+
let childEntry: LifecycleEntry | null = null
|
|
759
|
+
let pendingLoad: Promise<Api> | null = null
|
|
760
|
+
let disposed = false
|
|
761
|
+
|
|
762
|
+
// Parent dispose flag; the child entry (when present) is disposed
|
|
763
|
+
// via the parent's normal cascade, so we don't double-tear-down.
|
|
764
|
+
const flagEntry: LifecycleEntry = {
|
|
765
|
+
kind: 'onDispose',
|
|
766
|
+
fn: () => {
|
|
767
|
+
disposed = true
|
|
768
|
+
},
|
|
769
|
+
}
|
|
770
|
+
self.entries.push(flagEntry)
|
|
771
|
+
|
|
772
|
+
const handleFailure = (err: unknown): void => {
|
|
773
|
+
status$.set('error')
|
|
774
|
+
error$.set(err)
|
|
775
|
+
dispatchError(self.rootShared.onError, err, {
|
|
776
|
+
kind: 'construction',
|
|
777
|
+
controllerPath: self.path,
|
|
778
|
+
})
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
const load = (): Promise<Api> => {
|
|
782
|
+
if (disposed) {
|
|
783
|
+
return Promise.reject(new Error('[olas] ctx.lazyChild: cannot load after dispose'))
|
|
784
|
+
}
|
|
785
|
+
if (pendingLoad !== null) return pendingLoad
|
|
786
|
+
status$.set('loading')
|
|
787
|
+
pendingLoad = loader().then(
|
|
788
|
+
(def) => {
|
|
789
|
+
if (disposed) {
|
|
790
|
+
throw new Error('[olas] ctx.lazyChild: disposed during load')
|
|
791
|
+
}
|
|
792
|
+
const segment = self.makeChildSegment(getFactory(def), getName(def))
|
|
793
|
+
const childDeps =
|
|
794
|
+
options?.deps !== undefined ? { ...self.deps, ...options.deps } : self.deps
|
|
795
|
+
const instance = new ControllerInstance(self, self.rootShared, segment, childDeps)
|
|
796
|
+
try {
|
|
797
|
+
const api = instance.construct(getFactory(def), props)
|
|
798
|
+
childInstance = instance
|
|
799
|
+
childEntry = { kind: 'child', instance }
|
|
800
|
+
self.entries.push(childEntry)
|
|
801
|
+
api$.set(api)
|
|
802
|
+
status$.set('ready')
|
|
803
|
+
return api
|
|
804
|
+
} catch (err) {
|
|
805
|
+
handleFailure(err)
|
|
806
|
+
throw err
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
(err) => {
|
|
810
|
+
if (disposed) throw err
|
|
811
|
+
handleFailure(err)
|
|
812
|
+
throw err
|
|
813
|
+
},
|
|
814
|
+
)
|
|
815
|
+
return pendingLoad
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
const dispose = (): void => {
|
|
819
|
+
if (disposed) return
|
|
820
|
+
disposed = true
|
|
821
|
+
if (childEntry !== null && childInstance !== null) {
|
|
822
|
+
const idx = self.entries.indexOf(childEntry)
|
|
823
|
+
if (idx >= 0) self.entries.splice(idx, 1)
|
|
824
|
+
try {
|
|
825
|
+
childInstance.dispose()
|
|
826
|
+
} catch (err) {
|
|
827
|
+
dispatchError(self.rootShared.onError, err, {
|
|
828
|
+
kind: 'effect',
|
|
829
|
+
controllerPath: self.path,
|
|
830
|
+
})
|
|
831
|
+
}
|
|
832
|
+
childInstance = null
|
|
833
|
+
childEntry = null
|
|
834
|
+
}
|
|
835
|
+
// Splice the parent-dispose flag entry too — its only job was to
|
|
836
|
+
// signal disposal to an in-flight loader, and `disposed` is now
|
|
837
|
+
// already true. Leaving it behind leaks one closure per ever-
|
|
838
|
+
// disposed lazyChild for the parent's remaining lifetime.
|
|
839
|
+
const flagIdx = self.entries.indexOf(flagEntry)
|
|
840
|
+
if (flagIdx >= 0) self.entries.splice(flagIdx, 1)
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
return {
|
|
844
|
+
status: status$,
|
|
845
|
+
api: api$,
|
|
846
|
+
error: error$,
|
|
847
|
+
load,
|
|
848
|
+
dispose,
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
|
|
538
852
|
onDispose(fn) {
|
|
539
853
|
self.entries.push({
|
|
540
854
|
kind: 'onDispose',
|