attaform 0.20.2 → 0.21.1
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/chunks/dev-key-collision-warnings.cjs +58 -0
- package/dist/chunks/dev-key-collision-warnings.cjs.map +1 -0
- package/dist/chunks/dev-key-collision-warnings.mjs +55 -0
- package/dist/chunks/dev-key-collision-warnings.mjs.map +1 -0
- package/dist/chunks/devtools.cjs +1 -1
- package/dist/chunks/devtools.mjs +1 -1
- package/dist/chunks/fingerprint.cjs +186 -0
- package/dist/chunks/fingerprint.cjs.map +1 -0
- package/dist/chunks/fingerprint.mjs +184 -0
- package/dist/chunks/fingerprint.mjs.map +1 -0
- package/dist/chunks/fingerprint2.cjs +162 -0
- package/dist/chunks/fingerprint2.cjs.map +1 -0
- package/dist/chunks/fingerprint2.mjs +160 -0
- package/dist/chunks/fingerprint2.mjs.map +1 -0
- package/dist/chunks/indexeddb.cjs +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/multi-tab-sync.cjs +367 -0
- package/dist/chunks/multi-tab-sync.cjs.map +1 -0
- package/dist/chunks/multi-tab-sync.mjs +364 -0
- package/dist/chunks/multi-tab-sync.mjs.map +1 -0
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/chunks/wire-persistence.cjs +396 -0
- package/dist/chunks/wire-persistence.cjs.map +1 -0
- package/dist/chunks/wire-persistence.mjs +394 -0
- package/dist/chunks/wire-persistence.mjs.map +1 -0
- package/dist/esbuild.cjs +28 -0
- package/dist/esbuild.cjs.map +1 -0
- package/dist/esbuild.d.cts +56 -0
- package/dist/esbuild.d.mts +56 -0
- package/dist/esbuild.d.ts +56 -0
- package/dist/esbuild.mjs +26 -0
- package/dist/esbuild.mjs.map +1 -0
- package/dist/index.cjs +5 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -70
- package/dist/index.d.mts +66 -70
- package/dist/index.d.ts +66 -70
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/rollup.cjs +24 -0
- package/dist/rollup.cjs.map +1 -0
- package/dist/rollup.d.cts +35 -0
- package/dist/rollup.d.mts +35 -0
- package/dist/rollup.d.ts +35 -0
- package/dist/rollup.mjs +22 -0
- package/dist/rollup.mjs.map +1 -0
- package/dist/rspack.cjs +10 -0
- package/dist/rspack.cjs.map +1 -0
- package/dist/rspack.d.cts +40 -0
- package/dist/rspack.d.mts +40 -0
- package/dist/rspack.d.ts +40 -0
- package/dist/rspack.mjs +8 -0
- package/dist/rspack.mjs.map +1 -0
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/attaform.BJGA_UOS.mjs +37 -0
- package/dist/shared/attaform.BJGA_UOS.mjs.map +1 -0
- package/dist/shared/attaform.BRGIpZo4.cjs +26 -0
- package/dist/shared/attaform.BRGIpZo4.cjs.map +1 -0
- package/dist/shared/{attaform.DAKrGhxc.cjs → attaform.BSkvn43g.cjs} +101 -417
- package/dist/shared/attaform.BSkvn43g.cjs.map +1 -0
- package/dist/shared/{attaform.sWm8B15V.d.mts → attaform.BWfliRIK.d.cts} +172 -2
- package/dist/shared/{attaform.BGk8cfw2.mjs → attaform.Be8NZG9M.mjs} +178 -21
- package/dist/shared/attaform.Be8NZG9M.mjs.map +1 -0
- package/dist/shared/{attaform.D2SCCd4O.cjs → attaform.Bq5sX7TF.cjs} +2 -2
- package/dist/shared/{attaform.D2SCCd4O.cjs.map → attaform.Bq5sX7TF.cjs.map} +1 -1
- package/dist/shared/{attaform.ceGEAEMk.d.ts → attaform.Bv7dRDWK.d.ts} +172 -2
- package/dist/shared/attaform.C3Doa9Pt.mjs +24 -0
- package/dist/shared/attaform.C3Doa9Pt.mjs.map +1 -0
- package/dist/shared/{attaform.B_hph5AE.cjs → attaform.CICFZ1iS.cjs} +178 -20
- package/dist/shared/attaform.CICFZ1iS.cjs.map +1 -0
- package/dist/shared/attaform.CQN9R62B.cjs +39 -0
- package/dist/shared/attaform.CQN9R62B.cjs.map +1 -0
- package/dist/shared/{attaform.CwLjUqmQ.cjs → attaform.ClXwitZj.cjs} +735 -960
- package/dist/shared/attaform.ClXwitZj.cjs.map +1 -0
- package/dist/shared/{attaform.99cfHcIt.d.cts → attaform.D0dWZsJt.d.cts} +349 -77
- package/dist/shared/{attaform.99cfHcIt.d.mts → attaform.D0dWZsJt.d.mts} +349 -77
- package/dist/shared/{attaform.99cfHcIt.d.ts → attaform.D0dWZsJt.d.ts} +349 -77
- package/dist/shared/{attaform.z5j3LwJz.cjs → attaform.D32WwKk6.cjs} +216 -35
- package/dist/shared/attaform.D32WwKk6.cjs.map +1 -0
- package/dist/shared/{attaform.C5aYC_T8.mjs → attaform.DMEP_ENr.mjs} +39 -392
- package/dist/shared/attaform.DMEP_ENr.mjs.map +1 -0
- package/dist/shared/{attaform.tiWEVznj.mjs → attaform.DR6RmxWZ.mjs} +725 -962
- package/dist/shared/attaform.DR6RmxWZ.mjs.map +1 -0
- package/dist/shared/{attaform.Dt7dEcHk.mjs → attaform.DozgVlCE.mjs} +89 -405
- package/dist/shared/attaform.DozgVlCE.mjs.map +1 -0
- package/dist/shared/{attaform.DN5CvZrg.d.ts → attaform.Duecg2NO.d.mts} +2 -2
- package/dist/shared/attaform.DuzQYscR.d.cts +41 -0
- package/dist/shared/attaform.DuzQYscR.d.mts +41 -0
- package/dist/shared/attaform.DuzQYscR.d.ts +41 -0
- package/dist/shared/{attaform.BXinSW2T.d.mts → attaform.FudOcHaa.d.cts} +2 -2
- package/dist/shared/attaform.LEWUFqUw.cjs +54 -0
- package/dist/shared/attaform.LEWUFqUw.cjs.map +1 -0
- package/dist/shared/{attaform.CywE4y8x.d.cts → attaform.MtrpT6Ki.d.ts} +2 -2
- package/dist/shared/{attaform.DbRgDFa7.d.cts → attaform.NQ8mybyW.d.mts} +172 -2
- package/dist/shared/{attaform.Cd4AOfwu.cjs → attaform.S-pYLSo4.cjs} +68 -402
- package/dist/shared/attaform.S-pYLSo4.cjs.map +1 -0
- package/dist/shared/{attaform.CnrxbkB6.mjs → attaform.Y1ZGhM4k.mjs} +2 -2
- package/dist/shared/{attaform.CnrxbkB6.mjs.map → attaform.Y1ZGhM4k.mjs.map} +1 -1
- package/dist/shared/{attaform.QG5TG8lB.mjs → attaform.pmtahXKy.mjs} +216 -36
- package/dist/shared/attaform.pmtahXKy.mjs.map +1 -0
- package/dist/shared/attaform.sHkHv_98.mjs +51 -0
- package/dist/shared/attaform.sHkHv_98.mjs.map +1 -0
- package/dist/vite.cjs +9 -45
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +36 -0
- package/dist/vite.d.mts +36 -0
- package/dist/vite.d.ts +36 -0
- package/dist/vite.mjs +8 -44
- package/dist/vite.mjs.map +1 -1
- package/dist/webpack.cjs +10 -0
- package/dist/webpack.cjs.map +1 -0
- package/dist/webpack.d.cts +37 -0
- package/dist/webpack.d.mts +37 -0
- package/dist/webpack.d.ts +37 -0
- package/dist/webpack.mjs +8 -0
- package/dist/webpack.mjs.map +1 -0
- package/dist/zod-v3.cjs +3 -3
- package/dist/zod-v3.d.cts +3 -3
- package/dist/zod-v3.d.mts +3 -3
- package/dist/zod-v3.d.ts +3 -3
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +3 -3
- package/dist/zod-v4.d.cts +4 -4
- package/dist/zod-v4.d.mts +4 -4
- package/dist/zod-v4.d.ts +4 -4
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +8 -8
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +52 -10
- package/dist/zod.d.mts +52 -10
- package/dist/zod.d.ts +52 -10
- package/dist/zod.mjs +6 -6
- package/dist/zod.mjs.map +1 -1
- package/package.json +19 -5
- package/dist/shared/attaform.BGk8cfw2.mjs.map +0 -1
- package/dist/shared/attaform.B_hph5AE.cjs.map +0 -1
- package/dist/shared/attaform.C5aYC_T8.mjs.map +0 -1
- package/dist/shared/attaform.Cd4AOfwu.cjs.map +0 -1
- package/dist/shared/attaform.CwLjUqmQ.cjs.map +0 -1
- package/dist/shared/attaform.DAKrGhxc.cjs.map +0 -1
- package/dist/shared/attaform.Dt7dEcHk.mjs.map +0 -1
- package/dist/shared/attaform.QG5TG8lB.mjs.map +0 -1
- package/dist/shared/attaform.tiWEVznj.mjs.map +0 -1
- package/dist/shared/attaform.z5j3LwJz.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as FormKey, V as PathKey, m as DisplayCtx, z as GetDisplayState, n as DisplayMachine, ag as SlimPrimitiveKind, C as CoercionEntry, g as CoercionRegistry, G as GenericForm, U as Path, ap as ValidationError, A as AbstractSchema, at as WriteMeta, D as DeepPartial, au as WriteShape, aj as TransformAbortHolder, an as ValidateOn, _ as PersistOptInRegistry, f as AttaformDefaults, am as UseFormReturnType, aa as RegisterValue } from './attaform.D0dWZsJt.cjs';
|
|
2
2
|
import { Ref, ComputedRef, App, InjectionKey } from 'vue';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -414,6 +414,13 @@ type WizardForms<S> = FormsRecordOf<S> & Readonly<Record<FormKey, AnyForm>>;
|
|
|
414
414
|
* - `submissionAttempts` — count of `wizard.handleSubmit` invocations
|
|
415
415
|
* (success or failure). Always bumps, including on
|
|
416
416
|
* noop-form steps.
|
|
417
|
+
* - `submitError` — the error thrown by the most recent
|
|
418
|
+
* `wizard.handleSubmit` callback (or its `onError`),
|
|
419
|
+
* coerced to a real `Error`. Mirrors
|
|
420
|
+
* `form.meta.submitError`: cleared at submit entry and
|
|
421
|
+
* by `reset()`, parked here rather than re-thrown, so
|
|
422
|
+
* the handler resolves and never manufactures a
|
|
423
|
+
* `window` unhandledrejection. `null` on success.
|
|
417
424
|
* - `visited` — append-only breadcrumb of navigated step keys.
|
|
418
425
|
* `back()` does not pop; the trail is the audit
|
|
419
426
|
* log, not the back-stack.
|
|
@@ -447,6 +454,7 @@ type UseWizardReturnType<S extends ReadonlyArray<StepSlot> = ReadonlyArray<StepS
|
|
|
447
454
|
readonly done: boolean;
|
|
448
455
|
readonly submitting: boolean;
|
|
449
456
|
readonly submissionAttempts: number;
|
|
457
|
+
readonly submitError: Error | null;
|
|
450
458
|
readonly visited: readonly FormKey[];
|
|
451
459
|
readonly next: () => Promise<void>;
|
|
452
460
|
readonly back: () => void;
|
|
@@ -455,6 +463,68 @@ type UseWizardReturnType<S extends ReadonlyArray<StepSlot> = ReadonlyArray<StepS
|
|
|
455
463
|
readonly reset: () => void;
|
|
456
464
|
};
|
|
457
465
|
|
|
466
|
+
/**
|
|
467
|
+
* Per-form display engine: owns the clock and the timers that the pure
|
|
468
|
+
* `getDisplayState` reducer policy needs, so the reducer itself stays a
|
|
469
|
+
* deterministic `(prev, ctx) => next` function.
|
|
470
|
+
*
|
|
471
|
+
* It keeps a `Map` of the machines that are still *active* (a spinner is
|
|
472
|
+
* showing, a verdict is being held, or a `reviewAt` deadline is pending),
|
|
473
|
+
* a single reactive `tick` ref, and a single `setTimeout` aimed at the
|
|
474
|
+
* nearest `reviewAt` across every active field. When a field-state
|
|
475
|
+
* computed reads `resolve`, it subscribes to `tick`; when the timer
|
|
476
|
+
* fires, `tick` bumps and every dependent computed re-runs the reducer,
|
|
477
|
+
* so a field whose deadline elapsed transitions (verdict → spinner, or
|
|
478
|
+
* spinner → settled verdict) without any per-field watcher.
|
|
479
|
+
*
|
|
480
|
+
* Eviction: a machine is dropped once it reaches a terminal *idle* state
|
|
481
|
+
* with no pending review. Error / success / pending machines are retained
|
|
482
|
+
* so the reducer can hold the prior verdict under the show-delay window of
|
|
483
|
+
* the *next* validation streak (no success → idle → success flicker). The
|
|
484
|
+
* retained set is bounded by the rendered non-idle fields; none of them
|
|
485
|
+
* arm a timer, so retention costs memory, never CPU.
|
|
486
|
+
*
|
|
487
|
+
* Untrusted reducer: `getDisplayState` is consumer-overridable, so the
|
|
488
|
+
* engine treats the returned `reviewAt` as untrusted. A non-finite deadline
|
|
489
|
+
* (NaN / ±Infinity from a custom predicate's bad arithmetic) is ignored
|
|
490
|
+
* rather than handed to `setTimeout`, where it coerces to 0 and spins; an
|
|
491
|
+
* over-large finite deadline is clamped below the 32-bit `setTimeout`
|
|
492
|
+
* overflow; and the timer refuses to re-arm for the exact deadline it just
|
|
493
|
+
* fired, so a predicate re-emitting a fixed or past `reviewAt` can't drive an
|
|
494
|
+
* infinite fire loop. None of these arise from the library default, which
|
|
495
|
+
* always advances its deadline or drops it.
|
|
496
|
+
*
|
|
497
|
+
* Background tabs: `setTimeout` is throttled to >= 1s while a tab is hidden,
|
|
498
|
+
* so a min-visible hold can overshoot. A `visibilitychange` listener bumps
|
|
499
|
+
* the clock on return to the foreground, so any overdue deadline resolves at
|
|
500
|
+
* once instead of lingering.
|
|
501
|
+
*
|
|
502
|
+
* SSR: no clock, no timers, no listener. With `now` frozen and nothing
|
|
503
|
+
* validating at render, the reducer returns the plain verdict (never
|
|
504
|
+
* pending) and the engine stores nothing, so the server HTML and the
|
|
505
|
+
* client's first render agree — no hydration mismatch on the display
|
|
506
|
+
* projection.
|
|
507
|
+
*/
|
|
508
|
+
type DisplayEngine = {
|
|
509
|
+
/**
|
|
510
|
+
* Resolve a path's next `DisplayMachine`. Subscribes the calling
|
|
511
|
+
* computed to the engine clock, threads the path's previous machine
|
|
512
|
+
* through `reducer`, persists or evicts the result, and re-arms the
|
|
513
|
+
* single timer to the nearest deadline.
|
|
514
|
+
*/
|
|
515
|
+
resolve(key: PathKey, ctx: DisplayCtx, reducer: GetDisplayState): DisplayMachine;
|
|
516
|
+
/** Drop every retained machine and cancel the timer (used by `reset()`). */
|
|
517
|
+
clear(): void;
|
|
518
|
+
/** Tear down for good: `clear()` plus detaching the visibility listener. */
|
|
519
|
+
dispose(): void;
|
|
520
|
+
/** Introspection for tests: count of retained machines. */
|
|
521
|
+
size(): number;
|
|
522
|
+
/** Introspection for tests: whether a path currently has a retained machine. */
|
|
523
|
+
has(key: PathKey): boolean;
|
|
524
|
+
/** Introspection for tests: whether a deadline timer is currently armed. */
|
|
525
|
+
hasTimer(): boolean;
|
|
526
|
+
};
|
|
527
|
+
|
|
458
528
|
/**
|
|
459
529
|
* Schema-driven coercion of user-typed DOM values at the v-register
|
|
460
530
|
* directive layer. When the slim schema declares a numeric or
|
|
@@ -669,6 +739,16 @@ type FormStore<F extends GenericForm, G extends GenericForm = F> = {
|
|
|
669
739
|
* read.
|
|
670
740
|
*/
|
|
671
741
|
readonly getDisplayState: GetDisplayState;
|
|
742
|
+
/**
|
|
743
|
+
* Per-form display engine: owns the clock and the single timer the timed
|
|
744
|
+
* `getDisplayState` reducer policy needs, keeping the reducer itself a
|
|
745
|
+
* pure `(prev, ctx) => next` function. The field-state computeds route
|
|
746
|
+
* every `displayState` read through `displayEngine.resolve(...)`, which
|
|
747
|
+
* threads the path's previous machine, persists or evicts the result, and
|
|
748
|
+
* re-arms the nearest-deadline timer. Constructed once at form
|
|
749
|
+
* construction; torn down via `registerCleanup` on store eviction.
|
|
750
|
+
*/
|
|
751
|
+
readonly displayEngine: DisplayEngine;
|
|
672
752
|
readonly submitting: Ref<boolean>;
|
|
673
753
|
readonly activeSubmissions: Ref<number>;
|
|
674
754
|
readonly submissionAttempts: Ref<number>;
|
|
@@ -679,7 +759,7 @@ type FormStore<F extends GenericForm, G extends GenericForm = F> = {
|
|
|
679
759
|
* alongside the rest of the submission surface.
|
|
680
760
|
*/
|
|
681
761
|
readonly submitted: Ref<boolean>;
|
|
682
|
-
readonly submitError: Ref<
|
|
762
|
+
readonly submitError: Ref<Error | null>;
|
|
683
763
|
readonly departAttempts: Ref<number>;
|
|
684
764
|
/**
|
|
685
765
|
* `true` while a function-form `defaultValues` factory is in flight.
|
|
@@ -838,6 +918,61 @@ type FormStore<F extends GenericForm, G extends GenericForm = F> = {
|
|
|
838
918
|
* computed only re-runs when the count for ITS key changes.
|
|
839
919
|
*/
|
|
840
920
|
readonly fieldValidationCounts: Map<PathKey, number>;
|
|
921
|
+
/**
|
|
922
|
+
* Per-path `Date.now()` stamp marking when the field's LATEST validation
|
|
923
|
+
* run started, re-anchored on every run start (every increment), deleted
|
|
924
|
+
* on the `→ 0` edge. The display reducer reads it as `ctx.validatingSince`
|
|
925
|
+
* to time the anti-flash spinner, which measures `now - validatingSince`:
|
|
926
|
+
* re-anchoring on each run means a burst of keystrokes (each aborting the
|
|
927
|
+
* prior run and starting a new one) keeps pushing the stamp forward, so the
|
|
928
|
+
* spinner stays suppressed until the user pauses rather than surfacing
|
|
929
|
+
* mid-typing. Anchoring only at the streak start would pin it to the first
|
|
930
|
+
* keystroke, because with `debounceMs: 0` the aborted run's decrement lands
|
|
931
|
+
* after the next run's increment and the count never returns to 0 between
|
|
932
|
+
* fast keystrokes. The field-state container walk takes the descendant-min
|
|
933
|
+
* so a row spinner anchors at its earliest still-active leaf. Runtime-only,
|
|
934
|
+
* never hydrated, like the counts. REACTIVE: the display computed reads this
|
|
935
|
+
* (as `ctx.validatingSince`) but not the `validating` flag, and a long
|
|
936
|
+
* validation that settles with an unchanged verdict (same error, still
|
|
937
|
+
* invalid) leaves `errors` / `valid` untouched — so a non-reactive map would
|
|
938
|
+
* leave a held `pending` spinner stranded after the run ends, until some
|
|
939
|
+
* unrelated reactive change happened to re-run the computed. Reactivity ties
|
|
940
|
+
* the computed to both the streak start (set) and end (delete).
|
|
941
|
+
*/
|
|
942
|
+
readonly fieldValidatingSince: Map<PathKey, number>;
|
|
943
|
+
/**
|
|
944
|
+
* Per-path counter of in-flight async-transform runs (the async
|
|
945
|
+
* branch of the `register({ transforms })` pipeline). `> 0` drives
|
|
946
|
+
* `field.transforming` / `field.busy`. Counter, not flag, for the
|
|
947
|
+
* same overlap reason as `fieldValidationCounts`, except a superseding
|
|
948
|
+
* input releases the prior run synchronously before incrementing the
|
|
949
|
+
* new one — so the count is the live in-flight depth at the path
|
|
950
|
+
* (effectively 0 or 1). Reactive Map, like the validation counters.
|
|
951
|
+
*/
|
|
952
|
+
readonly fieldTransformCounts: Map<PathKey, number>;
|
|
953
|
+
/**
|
|
954
|
+
* Per-path `ssr ? 0 : Date.now()` stamp marking when the path's latest
|
|
955
|
+
* async transform opened; the display reducer reads it (as
|
|
956
|
+
* `ctx.transformingSince`) to time the gated busy spinner. Mirrors
|
|
957
|
+
* `fieldValidatingSince` exactly: re-anchored on each run start,
|
|
958
|
+
* deleted on the `→ 0` edge, reactive for the held-spinner reason.
|
|
959
|
+
*/
|
|
960
|
+
readonly fieldTransformingSince: Map<PathKey, number>;
|
|
961
|
+
/**
|
|
962
|
+
* Per-path latest async-transform failure (a rejected transform, or a
|
|
963
|
+
* resolved value the write gate refused), surfaced as
|
|
964
|
+
* `field.transformError`. Cleared when a fresh run opens at the path
|
|
965
|
+
* and on `reset()`. A channel separate from validation `errors`.
|
|
966
|
+
*/
|
|
967
|
+
readonly transformErrors: Map<PathKey, Error | null>;
|
|
968
|
+
/**
|
|
969
|
+
* Form-wide count of in-flight async-transform runs. Drives the
|
|
970
|
+
* `settleTransforms` quiescence guard and the `handleSubmit` drain
|
|
971
|
+
* barrier. `Math.max(0, …)`-clamped on release so a doubled decrement
|
|
972
|
+
* (a run's own `endTransform` after a synchronous cancel release)
|
|
973
|
+
* can't drive it negative.
|
|
974
|
+
*/
|
|
975
|
+
readonly activeTransforms: Ref<number>;
|
|
841
976
|
/**
|
|
842
977
|
* Replace the form value wholesale. Optional `meta` is forwarded to
|
|
843
978
|
* every `onFormChange` listener so they can decide whether THIS write
|
|
@@ -1005,6 +1140,41 @@ type FormStore<F extends GenericForm, G extends GenericForm = F> = {
|
|
|
1005
1140
|
* at entry (submit validation is authoritative) and by `reset()`.
|
|
1006
1141
|
*/
|
|
1007
1142
|
cancelFieldValidation(): void;
|
|
1143
|
+
/**
|
|
1144
|
+
* Open an async-transform run at `key` — bump the run token, increment
|
|
1145
|
+
* the in-flight counters, stamp `transformingSince`, clear any prior
|
|
1146
|
+
* `transformError`, register `holder` for later abort. Returns the run
|
|
1147
|
+
* token. See `InternalRegisterValue.beginTransform`.
|
|
1148
|
+
*/
|
|
1149
|
+
beginTransform(key: PathKey, holder: TransformAbortHolder): number;
|
|
1150
|
+
/** `true` while `token` is the live async-transform run at `key`. */
|
|
1151
|
+
isCurrentTransform(key: PathKey, token: number): boolean;
|
|
1152
|
+
/**
|
|
1153
|
+
* Close the run `token` at `key`: release the counters (no-op if the
|
|
1154
|
+
* run was already released by a supersede / cancel) and flush settled
|
|
1155
|
+
* `settleTransforms` waiters.
|
|
1156
|
+
*/
|
|
1157
|
+
endTransform(key: PathKey, token: number): void;
|
|
1158
|
+
/** Record a per-field normalization failure at `key` (`field.transformError`). */
|
|
1159
|
+
setTransformError(key: PathKey, err: Error): void;
|
|
1160
|
+
/**
|
|
1161
|
+
* Abort + release every in-flight async-transform run (all paths) and
|
|
1162
|
+
* clear `transformErrors`. Mirrors `cancelFieldValidation`; called by
|
|
1163
|
+
* `reset()` and store teardown.
|
|
1164
|
+
*/
|
|
1165
|
+
cancelTransforms(): void;
|
|
1166
|
+
/**
|
|
1167
|
+
* Path-scoped counterpart to `cancelTransforms`: abort + release only
|
|
1168
|
+
* the runs at-or-under `prefix`, clearing their `transformError`.
|
|
1169
|
+
* Called by `resetField`.
|
|
1170
|
+
*/
|
|
1171
|
+
cancelTransformsUnder(prefix: Path): void;
|
|
1172
|
+
/**
|
|
1173
|
+
* Resolve once async transforms are quiescent — globally (`path`
|
|
1174
|
+
* omitted) or at-or-under `path`. Resolve-never-reject. See
|
|
1175
|
+
* `UseFormReturnType.settleTransforms`.
|
|
1176
|
+
*/
|
|
1177
|
+
settleTransforms(path?: string | Path): Promise<void>;
|
|
1008
1178
|
/**
|
|
1009
1179
|
* Kick off (or schedule) a field-level validation run for `path`. Pass
|
|
1010
1180
|
* `path = []` to cover the whole form; `applySchemaErrorsForSubtree`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AttaformErrorCode,
|
|
2
|
-
import { j as canonicalizePath } from './attaform.
|
|
1
|
+
import { A as AttaformErrorCode, m as isPlainRecord, v as safeOwnRead, u as safeAssign, x as slimKindOf } from './attaform.DR6RmxWZ.mjs';
|
|
2
|
+
import { j as canonicalizePath } from './attaform.pmtahXKy.mjs';
|
|
3
3
|
|
|
4
4
|
const PATH_SEPARATOR = ".";
|
|
5
5
|
function createAbstractSchema(rootSchema, intro, services, formKey, options) {
|
|
@@ -90,6 +90,12 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
|
|
|
90
90
|
if (kind === "array") return null;
|
|
91
91
|
return void 0;
|
|
92
92
|
},
|
|
93
|
+
isFixedObjectAtPath(path) {
|
|
94
|
+
if (path.length === 0) return true;
|
|
95
|
+
const resolved = services.getNestedSchemasAtPath(rootSchema, path, maxRecursionDepth);
|
|
96
|
+
if (resolved.length === 0) return false;
|
|
97
|
+
return resolved.every((s) => intro.kindOf(services.peelAllWrappers(s)) === "object");
|
|
98
|
+
},
|
|
93
99
|
getSchemasAtPath(path) {
|
|
94
100
|
const resolved = services.getNestedSchemasInSlimMode(rootSchema, path, maxRecursionDepth);
|
|
95
101
|
if (resolved.length === 0) return [];
|
|
@@ -271,6 +277,23 @@ function createAbstractSchema(rootSchema, intro, services, formKey, options) {
|
|
|
271
277
|
return abstractSchema;
|
|
272
278
|
}
|
|
273
279
|
|
|
280
|
+
function mergeDeep(base, override) {
|
|
281
|
+
if (override === void 0) return base;
|
|
282
|
+
if (!isPlainRecord(override)) return override;
|
|
283
|
+
if (!isPlainRecord(base)) return override;
|
|
284
|
+
const result = { ...base };
|
|
285
|
+
for (const key of Object.keys(override)) {
|
|
286
|
+
const oVal = safeOwnRead(override, key);
|
|
287
|
+
const bVal = safeOwnRead(base, key);
|
|
288
|
+
if (isPlainRecord(oVal) && isPlainRecord(bVal)) {
|
|
289
|
+
safeAssign(result, key, mergeDeep(bVal, oVal));
|
|
290
|
+
} else {
|
|
291
|
+
safeAssign(result, key, oVal);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
|
|
274
297
|
function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
|
|
275
298
|
if (segments.length === 0) return [schema];
|
|
276
299
|
const [head, ...rest] = segments;
|
|
@@ -358,23 +381,6 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
|
|
|
358
381
|
}
|
|
359
382
|
}
|
|
360
383
|
|
|
361
|
-
function mergeDeep(base, override) {
|
|
362
|
-
if (override === void 0) return base;
|
|
363
|
-
if (!isPlainRecord(override)) return override;
|
|
364
|
-
if (!isPlainRecord(base)) return override;
|
|
365
|
-
const result = { ...base };
|
|
366
|
-
for (const key of Object.keys(override)) {
|
|
367
|
-
const oVal = safeOwnRead(override, key);
|
|
368
|
-
const bVal = safeOwnRead(base, key);
|
|
369
|
-
if (isPlainRecord(oVal) && isPlainRecord(bVal)) {
|
|
370
|
-
safeAssign(result, key, mergeDeep(bVal, oVal));
|
|
371
|
-
} else {
|
|
372
|
-
safeAssign(result, key, oVal);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
return result;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
384
|
const NO_EMBEDDED_DEFAULT = Symbol("atta:no-embedded-default");
|
|
379
385
|
function peelEmbeddedDefault(schema, intro) {
|
|
380
386
|
let current = schema;
|
|
@@ -770,5 +776,156 @@ function slimPrimitivesWalk(schema, intro, maxDepth, lazyDepth = 0) {
|
|
|
770
776
|
}
|
|
771
777
|
}
|
|
772
778
|
|
|
773
|
-
|
|
774
|
-
|
|
779
|
+
const pathMetaCache = /* @__PURE__ */ new WeakMap();
|
|
780
|
+
function getFieldMetaPathMap(rootSchema, services) {
|
|
781
|
+
const cached = pathMetaCache.get(rootSchema);
|
|
782
|
+
if (cached !== void 0) return cached;
|
|
783
|
+
const map = /* @__PURE__ */ new Map();
|
|
784
|
+
const counters = /* @__PURE__ */ new Map();
|
|
785
|
+
const lastPathPerSchema = /* @__PURE__ */ new Map();
|
|
786
|
+
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
787
|
+
walkForMeta(rootSchema, [], map, counters, lastPathPerSchema, inProgress, services);
|
|
788
|
+
for (const [schema, lastPath] of lastPathPerSchema) {
|
|
789
|
+
const list = services.getFieldMetaList(schema);
|
|
790
|
+
const consumed = counters.get(schema) ?? 0;
|
|
791
|
+
if (list.length <= consumed) continue;
|
|
792
|
+
const surplus = list.slice(consumed).reduce((acc, p) => ({ ...acc, ...p }), {});
|
|
793
|
+
const existing = map.get(lastPath) ?? {};
|
|
794
|
+
map.set(lastPath, { ...existing, ...surplus });
|
|
795
|
+
}
|
|
796
|
+
pathMetaCache.set(rootSchema, map);
|
|
797
|
+
return map;
|
|
798
|
+
}
|
|
799
|
+
function consumePayload(schema, counters, getFieldMetaList) {
|
|
800
|
+
const list = getFieldMetaList(schema);
|
|
801
|
+
if (list.length === 0) return void 0;
|
|
802
|
+
const idx = counters.get(schema) ?? 0;
|
|
803
|
+
const payload = list[Math.min(idx, list.length - 1)];
|
|
804
|
+
counters.set(schema, idx + 1);
|
|
805
|
+
return payload;
|
|
806
|
+
}
|
|
807
|
+
function walkForMeta(schema, path, map, counters, lastPathPerSchema, inProgress, services) {
|
|
808
|
+
if (inProgress.has(schema)) return;
|
|
809
|
+
inProgress.add(schema);
|
|
810
|
+
try {
|
|
811
|
+
const { intro, peelAllWrappers, getFieldMetaList } = services;
|
|
812
|
+
const pathKey = canonicalizePath(path).key;
|
|
813
|
+
if (!map.has(pathKey)) {
|
|
814
|
+
const payload = consumePayload(schema, counters, getFieldMetaList);
|
|
815
|
+
if (payload !== void 0) {
|
|
816
|
+
map.set(pathKey, payload);
|
|
817
|
+
lastPathPerSchema.set(schema, pathKey);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
const peeled = peelAllWrappers(schema);
|
|
821
|
+
if (peeled !== schema && !map.has(pathKey)) {
|
|
822
|
+
const payload = consumePayload(peeled, counters, getFieldMetaList);
|
|
823
|
+
if (payload !== void 0) {
|
|
824
|
+
map.set(pathKey, payload);
|
|
825
|
+
lastPathPerSchema.set(peeled, pathKey);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
const kind = intro.kindOf(schema);
|
|
829
|
+
switch (kind) {
|
|
830
|
+
case "object": {
|
|
831
|
+
for (const [key, child] of Object.entries(intro.getObjectShape(schema))) {
|
|
832
|
+
walkForMeta(child, [...path, key], map, counters, lastPathPerSchema, inProgress, services);
|
|
833
|
+
}
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
case "array": {
|
|
837
|
+
const inner = intro.getArrayElement(schema);
|
|
838
|
+
if (inner !== void 0)
|
|
839
|
+
walkForMeta(inner, [...path, 0], map, counters, lastPathPerSchema, inProgress, services);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
case "tuple": {
|
|
843
|
+
const items = intro.getTupleItems(schema);
|
|
844
|
+
for (let i = 0; i < items.length; i++) {
|
|
845
|
+
const item = items[i];
|
|
846
|
+
if (item !== void 0)
|
|
847
|
+
walkForMeta(item, [...path, i], map, counters, lastPathPerSchema, inProgress, services);
|
|
848
|
+
}
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
case "set": {
|
|
852
|
+
const inner = intro.getSetValueType(schema);
|
|
853
|
+
if (inner !== void 0)
|
|
854
|
+
walkForMeta(inner, [...path, 0], map, counters, lastPathPerSchema, inProgress, services);
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
case "record": {
|
|
858
|
+
const inner = intro.getRecordValueType(schema);
|
|
859
|
+
if (inner !== void 0)
|
|
860
|
+
walkForMeta(inner, [...path, "*"], map, counters, lastPathPerSchema, inProgress, services);
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
case "union": {
|
|
864
|
+
for (const opt of intro.getUnionOptions(schema)) {
|
|
865
|
+
walkForMeta(opt, path, map, counters, lastPathPerSchema, inProgress, services);
|
|
866
|
+
}
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
case "discriminated-union": {
|
|
870
|
+
for (const opt of intro.getDiscriminatedOptions(schema)) {
|
|
871
|
+
walkForMeta(opt, path, map, counters, lastPathPerSchema, inProgress, services);
|
|
872
|
+
}
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
case "optional":
|
|
876
|
+
case "nullable":
|
|
877
|
+
case "default":
|
|
878
|
+
case "readonly":
|
|
879
|
+
case "catch": {
|
|
880
|
+
const inner = intro.unwrapInner(schema);
|
|
881
|
+
if (inner !== void 0)
|
|
882
|
+
walkForMeta(inner, path, map, counters, lastPathPerSchema, inProgress, services);
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
case "pipe":
|
|
886
|
+
case "pipeline": {
|
|
887
|
+
const inner = intro.unwrapPipeIn(schema);
|
|
888
|
+
if (inner !== void 0)
|
|
889
|
+
walkForMeta(inner, path, map, counters, lastPathPerSchema, inProgress, services);
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
case "effects": {
|
|
893
|
+
const inner = intro.unwrapEffectsSource(schema);
|
|
894
|
+
if (inner !== void 0)
|
|
895
|
+
walkForMeta(inner, path, map, counters, lastPathPerSchema, inProgress, services);
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
case "branded": {
|
|
899
|
+
const inner = intro.unwrapBranded(schema);
|
|
900
|
+
if (inner !== void 0)
|
|
901
|
+
walkForMeta(inner, path, map, counters, lastPathPerSchema, inProgress, services);
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
case "lazy": {
|
|
905
|
+
try {
|
|
906
|
+
const inner = intro.unwrapLazy(schema);
|
|
907
|
+
if (inner !== void 0)
|
|
908
|
+
walkForMeta(inner, path, map, counters, lastPathPerSchema, inProgress, services);
|
|
909
|
+
} catch {
|
|
910
|
+
}
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
case "intersection": {
|
|
914
|
+
const left = intro.getIntersectionLeft(schema);
|
|
915
|
+
const right = intro.getIntersectionRight(schema);
|
|
916
|
+
if (left !== void 0)
|
|
917
|
+
walkForMeta(left, path, map, counters, lastPathPerSchema, inProgress, services);
|
|
918
|
+
if (right !== void 0)
|
|
919
|
+
walkForMeta(right, path, map, counters, lastPathPerSchema, inProgress, services);
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
default:
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
} finally {
|
|
926
|
+
inProgress.delete(schema);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
export { NO_EMBEDDED_DEFAULT as N, getFieldMetaListForSchema as a, getFieldMetaPathMap as b, createAbstractSchema as c, deriveDefaultWalk as d, fieldMetaStore as f, getFieldMetaForSchema as g, mergeDeep as m, peelEmbeddedDefault as p, slimPrimitivesWalk as s, walkPathSegments as w };
|
|
931
|
+
//# sourceMappingURL=attaform.Be8NZG9M.mjs.map
|