attaform 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -11
- package/dist/chunks/devtools.cjs +4 -4
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +2 -2
- package/dist/chunks/indexeddb.cjs +4 -4
- package/dist/chunks/indexeddb.cjs.map +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +2 -2
- package/dist/chunks/local-storage.cjs.map +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/session-storage.cjs +2 -2
- package/dist/chunks/session-storage.cjs.map +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +23 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -71
- package/dist/index.d.mts +76 -71
- package/dist/index.d.ts +76 -71
- package/dist/index.mjs +6 -6
- package/dist/nuxt.cjs +5 -11
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.cts +8 -0
- package/dist/nuxt.d.mts +8 -0
- package/dist/nuxt.d.ts +8 -0
- package/dist/nuxt.mjs +6 -12
- package/dist/nuxt.mjs.map +1 -1
- package/dist/runtime/plugins/attaform.cjs +3 -2
- package/dist/runtime/plugins/attaform.cjs.map +1 -1
- package/dist/runtime/plugins/attaform.mjs +2 -1
- package/dist/runtime/plugins/attaform.mjs.map +1 -1
- package/dist/shared/{attaform.BwaYWtMs.d.cts → attaform.B7rzpK1U.d.cts} +34 -5
- package/dist/shared/{attaform.BwaYWtMs.d.mts → attaform.B7rzpK1U.d.mts} +34 -5
- package/dist/shared/{attaform.BwaYWtMs.d.ts → attaform.B7rzpK1U.d.ts} +34 -5
- package/dist/shared/attaform.BAuJTWuT.d.mts +84 -0
- package/dist/shared/{attaform.CRk8NhlD.mjs → attaform.BfMxsfmE.mjs} +428 -49
- package/dist/shared/attaform.BfMxsfmE.mjs.map +1 -0
- package/dist/shared/attaform.Bp1c-uGF.cjs +1561 -0
- package/dist/shared/attaform.Bp1c-uGF.cjs.map +1 -0
- package/dist/shared/{attaform.CDJVeoJU.cjs → attaform.C9Ph2SMx.cjs} +49 -42
- package/dist/shared/{attaform.qxyip_aN.mjs.map → attaform.C9Ph2SMx.cjs.map} +1 -1
- package/dist/shared/attaform.CINUMjPq.mjs +29 -0
- package/dist/shared/attaform.CINUMjPq.mjs.map +1 -0
- package/dist/shared/attaform.CJttVxRj.cjs +32 -0
- package/dist/shared/attaform.CJttVxRj.cjs.map +1 -0
- package/dist/shared/{attaform.CPx7zTgS.d.mts → attaform.CVv9Oh0a.d.mts} +9 -7
- package/dist/shared/{attaform.riAENZQM.d.ts → attaform.CWCx2r0x.d.ts} +9 -7
- package/dist/shared/attaform.CvOXSpCb.mjs +1908 -0
- package/dist/shared/attaform.CvOXSpCb.mjs.map +1 -0
- package/dist/shared/{attaform.qxyip_aN.mjs → attaform.DILbdvfo.mjs} +12 -5
- package/dist/shared/{attaform.CDJVeoJU.cjs.map → attaform.DILbdvfo.mjs.map} +1 -1
- package/dist/shared/attaform.DdnithOf.mjs +1555 -0
- package/dist/shared/attaform.DdnithOf.mjs.map +1 -0
- package/dist/shared/attaform.DfrYByDj.cjs +1916 -0
- package/dist/shared/attaform.DfrYByDj.cjs.map +1 -0
- package/dist/shared/{attaform.D-eHWfVx.d.cts → attaform.Dq5BabH1.d.cts} +9 -7
- package/dist/shared/{attaform.BOi138GE.cjs → attaform.c_NzdRyc.cjs} +4 -4
- package/dist/shared/{attaform.BOi138GE.cjs.map → attaform.c_NzdRyc.cjs.map} +1 -1
- package/dist/shared/{attaform.DXye3JKf.mjs → attaform.jrxE_xZw.mjs} +2 -2
- package/dist/shared/{attaform.DXye3JKf.mjs.map → attaform.jrxE_xZw.mjs.map} +1 -1
- package/dist/shared/attaform.ls_7jBYc.d.ts +84 -0
- package/dist/shared/{attaform.BgYBU8gV.cjs → attaform.rIRYSUI1.cjs} +461 -61
- package/dist/shared/attaform.rIRYSUI1.cjs.map +1 -0
- package/dist/shared/attaform.xIcmqscx.d.cts +84 -0
- package/dist/vite.cjs +62 -9
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +23 -32
- package/dist/vite.d.mts +23 -32
- package/dist/vite.d.ts +23 -32
- package/dist/vite.mjs +62 -9
- package/dist/vite.mjs.map +1 -1
- package/dist/zod-v3.cjs +9 -1553
- package/dist/zod-v3.cjs.map +1 -1
- package/dist/zod-v3.d.cts +1 -1
- package/dist/zod-v3.d.mts +1 -1
- package/dist/zod-v3.d.ts +1 -1
- package/dist/zod-v3.mjs +3 -1553
- package/dist/zod-v3.mjs.map +1 -1
- package/dist/zod-v4.cjs +21 -0
- package/dist/zod-v4.cjs.map +1 -0
- package/dist/zod-v4.d.cts +104 -0
- package/dist/zod-v4.d.mts +104 -0
- package/dist/zod-v4.d.ts +104 -0
- package/dist/zod-v4.mjs +4 -0
- package/dist/zod-v4.mjs.map +1 -0
- package/dist/zod.cjs +19 -1900
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +28 -156
- package/dist/zod.d.mts +28 -156
- package/dist/zod.d.ts +28 -156
- package/dist/zod.mjs +19 -1896
- package/dist/zod.mjs.map +1 -1
- package/package.json +6 -2
- package/dist/shared/attaform.BgYBU8gV.cjs.map +0 -1
- package/dist/shared/attaform.CRk8NhlD.mjs.map +0 -1
- package/dist/shared/attaform.RypIkgVy.cjs +0 -417
- package/dist/shared/attaform.RypIkgVy.cjs.map +0 -1
- package/dist/shared/attaform.a99dQV7Q.mjs +0 -392
- package/dist/shared/attaform.a99dQV7Q.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
|
-
const paths = require('./attaform.
|
|
5
|
-
const
|
|
4
|
+
const paths = require('./attaform.c_NzdRyc.cjs');
|
|
5
|
+
const plugin = require('./attaform.rIRYSUI1.cjs');
|
|
6
6
|
|
|
7
7
|
function isDescendable(value) {
|
|
8
8
|
if (value === null || typeof value !== "object") return false;
|
|
@@ -1002,7 +1002,7 @@ function readPersistedPayload(value) {
|
|
|
1002
1002
|
if (envelope.data === void 0 || typeof envelope.data !== "object") return null;
|
|
1003
1003
|
return envelope;
|
|
1004
1004
|
}
|
|
1005
|
-
const warnedVersions =
|
|
1005
|
+
const warnedVersions = plugin.__DEV__ ? /* @__PURE__ */ new Set() : null;
|
|
1006
1006
|
function warnVersionMismatch(observedVersion) {
|
|
1007
1007
|
if (warnedVersions === null) return;
|
|
1008
1008
|
if (warnedVersions.has(observedVersion)) return;
|
|
@@ -1175,7 +1175,7 @@ const AttaformErrorCode = {
|
|
|
1175
1175
|
PathNotFound: "atta:path-not-found"
|
|
1176
1176
|
};
|
|
1177
1177
|
|
|
1178
|
-
const warnedNoScopeStores =
|
|
1178
|
+
const warnedNoScopeStores = plugin.__DEV__ ? /* @__PURE__ */ new WeakSet() : null;
|
|
1179
1179
|
function buildProcessForm(state, formInstanceId, options = {}) {
|
|
1180
1180
|
const invalidPolicy = options.onInvalidSubmit ?? "none";
|
|
1181
1181
|
function validate(pathInput) {
|
|
@@ -1227,7 +1227,7 @@ function buildProcessForm(state, formInstanceId, options = {}) {
|
|
|
1227
1227
|
});
|
|
1228
1228
|
if (vue.getCurrentScope() !== void 0) {
|
|
1229
1229
|
vue.onScopeDispose(stop);
|
|
1230
|
-
} else if (
|
|
1230
|
+
} else if (plugin.__DEV__ && warnedNoScopeStores !== null && !warnedNoScopeStores.has(state)) {
|
|
1231
1231
|
warnedNoScopeStores.add(state);
|
|
1232
1232
|
console.warn(
|
|
1233
1233
|
"[attaform] validate() called outside a Vue effect scope; its reactive watcher will leak until the form is garbage-collected. Fix: call validate() inside setup() / a child component, or wrap the call in `effectScope().run(...)`."
|
|
@@ -1295,7 +1295,7 @@ function buildProcessForm(state, formInstanceId, options = {}) {
|
|
|
1295
1295
|
try {
|
|
1296
1296
|
await onError(merged.errors);
|
|
1297
1297
|
} catch (cause) {
|
|
1298
|
-
throw new
|
|
1298
|
+
throw new plugin.SubmitErrorHandlerError("User-provided onError threw", { cause });
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
1301
|
return;
|
|
@@ -1392,7 +1392,7 @@ function extractSchemaFields(schema) {
|
|
|
1392
1392
|
return [];
|
|
1393
1393
|
}
|
|
1394
1394
|
|
|
1395
|
-
const warnedRejections =
|
|
1395
|
+
const warnedRejections = plugin.__DEV__ ? /* @__PURE__ */ new WeakMap() : null;
|
|
1396
1396
|
function shouldWarnOnce$1(store, key) {
|
|
1397
1397
|
if (warnedRejections === null) return false;
|
|
1398
1398
|
let set = warnedRejections.get(store);
|
|
@@ -1464,7 +1464,7 @@ function walk$1(schema, store, path, value) {
|
|
|
1464
1464
|
return true;
|
|
1465
1465
|
}
|
|
1466
1466
|
function reportRejection(store, path, kind, accepted) {
|
|
1467
|
-
if (!
|
|
1467
|
+
if (!plugin.__DEV__) return;
|
|
1468
1468
|
const dotted = path.map((s) => String(s)).join(".") || "(root)";
|
|
1469
1469
|
const key = `${dotted}::${kind}`;
|
|
1470
1470
|
if (!shouldWarnOnce$1(store, key)) return;
|
|
@@ -1538,13 +1538,13 @@ function indexRules(rules) {
|
|
|
1538
1538
|
for (const entry of rules) {
|
|
1539
1539
|
const candidate = entry;
|
|
1540
1540
|
if (candidate === null || typeof candidate !== "object" || typeof candidate.transform !== "function") {
|
|
1541
|
-
if (
|
|
1541
|
+
if (plugin.__DEV__) {
|
|
1542
1542
|
console.warn("[attaform] coercion entry missing or invalid `transform` \u2014 skipped.");
|
|
1543
1543
|
}
|
|
1544
1544
|
continue;
|
|
1545
1545
|
}
|
|
1546
1546
|
const key = `${entry.input}->${entry.output}`;
|
|
1547
|
-
if (idx.has(key) &&
|
|
1547
|
+
if (idx.has(key) && plugin.__DEV__) {
|
|
1548
1548
|
console.warn(`[attaform] duplicate coercion rule for '${key}' \u2014 last entry wins.`);
|
|
1549
1549
|
}
|
|
1550
1550
|
idx.set(key, entry);
|
|
@@ -1573,7 +1573,7 @@ function pickScalarTarget(accepted) {
|
|
|
1573
1573
|
if (accepted.has("bigint")) return "bigint";
|
|
1574
1574
|
return null;
|
|
1575
1575
|
}
|
|
1576
|
-
const warnedCoerce =
|
|
1576
|
+
const warnedCoerce = plugin.__DEV__ ? /* @__PURE__ */ new WeakMap() : null;
|
|
1577
1577
|
const sharedWarnStore = {};
|
|
1578
1578
|
function shouldWarnOnce(key) {
|
|
1579
1579
|
if (warnedCoerce === null) return false;
|
|
@@ -1598,7 +1598,7 @@ function coerceScalar(value, accepted, index) {
|
|
|
1598
1598
|
try {
|
|
1599
1599
|
result = entry.transform(value);
|
|
1600
1600
|
} catch (err) {
|
|
1601
|
-
if (
|
|
1601
|
+
if (plugin.__DEV__ && shouldWarnOnce(`${entry.input}->${entry.output}::throw`)) {
|
|
1602
1602
|
console.warn(
|
|
1603
1603
|
`[attaform] coercion '${entry.input}->${entry.output}' threw \u2014 write passes through.`,
|
|
1604
1604
|
err
|
|
@@ -1609,7 +1609,7 @@ function coerceScalar(value, accepted, index) {
|
|
|
1609
1609
|
if (!result.coerced) return value;
|
|
1610
1610
|
const returnedKind = slimKindOf(result.value);
|
|
1611
1611
|
if (returnedKind !== entry.output) {
|
|
1612
|
-
if (
|
|
1612
|
+
if (plugin.__DEV__ && shouldWarnOnce(`${entry.input}->${entry.output}::wrong-kind:${returnedKind}`)) {
|
|
1613
1613
|
console.warn(
|
|
1614
1614
|
`[attaform] coercion '${entry.input}->${entry.output}' produced a ${returnedKind} \u2014 write passes through.`
|
|
1615
1615
|
);
|
|
@@ -1617,7 +1617,7 @@ function coerceScalar(value, accepted, index) {
|
|
|
1617
1617
|
return value;
|
|
1618
1618
|
}
|
|
1619
1619
|
if (entry.output === "number" && !Number.isFinite(result.value)) {
|
|
1620
|
-
if (
|
|
1620
|
+
if (plugin.__DEV__ && shouldWarnOnce(`${entry.input}->${entry.output}::nan`)) {
|
|
1621
1621
|
console.warn(
|
|
1622
1622
|
`[attaform] coercion '${entry.input}->${entry.output}' produced a non-finite number \u2014 write passes through.`
|
|
1623
1623
|
);
|
|
@@ -1713,10 +1713,10 @@ function buildRegister(state, formInstanceId) {
|
|
|
1713
1713
|
state.coerceIndex
|
|
1714
1714
|
);
|
|
1715
1715
|
if (persist && !state.ssr && !state.modules.has(PERSISTENCE_MODULE_KEY)) {
|
|
1716
|
-
throw new
|
|
1716
|
+
throw new plugin.AnonPersistError({
|
|
1717
1717
|
cause: "register-without-config",
|
|
1718
1718
|
schemaFields: extractSchemaFields(state.schema),
|
|
1719
|
-
callSite:
|
|
1719
|
+
callSite: plugin.captureUserCallSite()
|
|
1720
1720
|
});
|
|
1721
1721
|
}
|
|
1722
1722
|
const internalRv = {
|
|
@@ -1906,7 +1906,7 @@ function isNumericPrimitive(value) {
|
|
|
1906
1906
|
const t = typeof value;
|
|
1907
1907
|
return t === "number" || t === "bigint";
|
|
1908
1908
|
}
|
|
1909
|
-
const warnedNonPrimitivePaths =
|
|
1909
|
+
const warnedNonPrimitivePaths = plugin.__DEV__ ? /* @__PURE__ */ new Set() : null;
|
|
1910
1910
|
function warnNonPrimitiveLeaf(segments, slim) {
|
|
1911
1911
|
if (warnedNonPrimitivePaths === null) return;
|
|
1912
1912
|
const dotted = segments.map(String).join(".");
|
|
@@ -1956,7 +1956,7 @@ function buildValuesProxy(form) {
|
|
|
1956
1956
|
// TypeError in strict-mode consumers, surprising users who
|
|
1957
1957
|
// assigned through the proxy and expected it to be ignored.
|
|
1958
1958
|
set(_, key) {
|
|
1959
|
-
if (
|
|
1959
|
+
if (plugin.__DEV__) {
|
|
1960
1960
|
console.warn(
|
|
1961
1961
|
`[attaform] form.values is read-only \u2014 write to "${String(key)}" was ignored. Use form.setValue / the directive / field-array helpers instead.`
|
|
1962
1962
|
);
|
|
@@ -1964,7 +1964,7 @@ function buildValuesProxy(form) {
|
|
|
1964
1964
|
return true;
|
|
1965
1965
|
},
|
|
1966
1966
|
deleteProperty(_, key) {
|
|
1967
|
-
if (
|
|
1967
|
+
if (plugin.__DEV__) {
|
|
1968
1968
|
console.warn(
|
|
1969
1969
|
`[attaform] form.values is read-only \u2014 delete of "${String(key)}" was ignored.`
|
|
1970
1970
|
);
|
|
@@ -2196,7 +2196,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2196
2196
|
};
|
|
2197
2197
|
const persist = async (pathInput, options2) => {
|
|
2198
2198
|
const segments = paths.canonicalizePath(pathInput).segments;
|
|
2199
|
-
|
|
2199
|
+
plugin.enforceSensitiveCheck(segments, options2?.acknowledgeSensitive === true);
|
|
2200
2200
|
if (persistence === void 0) return;
|
|
2201
2201
|
await persistence.writePathImmediately(segments);
|
|
2202
2202
|
};
|
|
@@ -2286,7 +2286,7 @@ function isHydratedValidationErrorArray(value) {
|
|
|
2286
2286
|
return true;
|
|
2287
2287
|
}
|
|
2288
2288
|
function warnMalformedHydration(formKey, kind, rawKey) {
|
|
2289
|
-
if (!
|
|
2289
|
+
if (!plugin.__DEV__) return;
|
|
2290
2290
|
console.warn(
|
|
2291
2291
|
`[attaform] hydration: skipping malformed ${kind} entry at key '${rawKey}' on form '${formKey}'. This usually means the SSR bundle is on a different version than the client (rolling deploy / stale cache).`
|
|
2292
2292
|
);
|
|
@@ -2310,7 +2310,7 @@ function createFormStore(options) {
|
|
|
2310
2310
|
const formChangeListeners = /* @__PURE__ */ new Set();
|
|
2311
2311
|
const submitSuccessListeners = /* @__PURE__ */ new Set();
|
|
2312
2312
|
const resetListeners = /* @__PURE__ */ new Set();
|
|
2313
|
-
const persistOptIns =
|
|
2313
|
+
const persistOptIns = plugin.createPersistOptInRegistry();
|
|
2314
2314
|
const coerceIndex = resolveCoercionIndex(options.coerce);
|
|
2315
2315
|
const cleanupHooks = [];
|
|
2316
2316
|
const modules = /* @__PURE__ */ new Map();
|
|
@@ -3203,19 +3203,24 @@ function hashStableString(input, seed = 0) {
|
|
|
3203
3203
|
}
|
|
3204
3204
|
|
|
3205
3205
|
function useAbstractForm(configuration) {
|
|
3206
|
+
if (configuration === void 0 || configuration === null || configuration.schema === void 0) {
|
|
3207
|
+
throw new plugin.InvalidUseFormConfigError();
|
|
3208
|
+
}
|
|
3206
3209
|
const key = resolveFormKey(configuration.key);
|
|
3207
3210
|
const resolvedSchema = getComputedSchema(key, configuration.schema);
|
|
3208
3211
|
if (configuration.persist !== void 0 && configuration.key === void 0) {
|
|
3209
|
-
throw new
|
|
3212
|
+
throw new plugin.AnonPersistError({
|
|
3210
3213
|
cause: "no-key",
|
|
3211
3214
|
schemaFields: extractSchemaFields(resolvedSchema),
|
|
3212
|
-
callSite:
|
|
3215
|
+
callSite: plugin.captureUserCallSite()
|
|
3213
3216
|
});
|
|
3214
3217
|
}
|
|
3215
|
-
const
|
|
3218
|
+
const instance = vue.getCurrentInstance();
|
|
3219
|
+
if (instance !== null) plugin.ensureAttaformInstalled(instance.appContext.app);
|
|
3220
|
+
const registry = plugin.useRegistry();
|
|
3216
3221
|
const merged = mergeWithDefaults(registry.defaults, configuration);
|
|
3217
3222
|
const existing = registry.forms.get(key);
|
|
3218
|
-
if (
|
|
3223
|
+
if (plugin.__DEV__ && existing !== void 0) {
|
|
3219
3224
|
warnOnSchemaFingerprintMismatch(key, existing.schema, resolvedSchema);
|
|
3220
3225
|
}
|
|
3221
3226
|
const state = existing ?? buildFreshState(key, resolvedSchema, merged, registry);
|
|
@@ -3244,11 +3249,11 @@ function useAbstractForm(configuration) {
|
|
|
3244
3249
|
}
|
|
3245
3250
|
if (configuration.key === void 0) {
|
|
3246
3251
|
recordAmbientProvide(registry.ssr);
|
|
3247
|
-
vue.provide(
|
|
3252
|
+
vue.provide(plugin.kFormContext, state);
|
|
3248
3253
|
}
|
|
3249
3254
|
const formInstanceId = vue.getCurrentInstance() !== null ? vue.useId() : `atta:form-instance:${formInstanceCounter++}`;
|
|
3250
3255
|
if (vue.getCurrentInstance() !== null) {
|
|
3251
|
-
vue.provide(
|
|
3256
|
+
vue.provide(plugin.kFormInstanceId, formInstanceId);
|
|
3252
3257
|
}
|
|
3253
3258
|
const apiOptions = {};
|
|
3254
3259
|
if (merged.onInvalidSubmit !== void 0) {
|
|
@@ -3310,14 +3315,14 @@ function buildFreshState(key, schema, configuration, registry) {
|
|
|
3310
3315
|
}
|
|
3311
3316
|
let anonCounter = 0;
|
|
3312
3317
|
let formInstanceCounter = 0;
|
|
3313
|
-
const ambientProvideHistory =
|
|
3318
|
+
const ambientProvideHistory = plugin.__DEV__ ? /* @__PURE__ */ new WeakMap() : null;
|
|
3314
3319
|
function recordAmbientProvide(ssr) {
|
|
3315
|
-
if (!
|
|
3320
|
+
if (!plugin.__DEV__ || ssr || ambientProvideHistory === null) return;
|
|
3316
3321
|
const instance = vue.getCurrentInstance();
|
|
3317
3322
|
if (instance === null) return;
|
|
3318
3323
|
const instanceKey = instance;
|
|
3319
3324
|
const entry = {
|
|
3320
|
-
source:
|
|
3325
|
+
source: plugin.captureUserCallSite()
|
|
3321
3326
|
};
|
|
3322
3327
|
const existing = ambientProvideHistory.get(instanceKey);
|
|
3323
3328
|
if (existing === void 0) {
|
|
@@ -3329,7 +3334,7 @@ function recordAmbientProvide(ssr) {
|
|
|
3329
3334
|
function resolveFormKey(key) {
|
|
3330
3335
|
if (key !== void 0 && key !== null && key !== "") {
|
|
3331
3336
|
if (key.startsWith(RESERVED_KEY_PREFIX)) {
|
|
3332
|
-
throw new
|
|
3337
|
+
throw new plugin.ReservedFormKeyError(key);
|
|
3333
3338
|
}
|
|
3334
3339
|
return key;
|
|
3335
3340
|
}
|
|
@@ -3576,10 +3581,10 @@ function isEmptyContainer(value) {
|
|
|
3576
3581
|
const warnedAnonPersistKeys = /* @__PURE__ */ new Set();
|
|
3577
3582
|
function enforceAnonPersistRule(formKey, ssr) {
|
|
3578
3583
|
if (!formKey.startsWith(ANONYMOUS_FORM_KEY_PREFIX)) return false;
|
|
3579
|
-
if (
|
|
3580
|
-
throw new
|
|
3584
|
+
if (plugin.__DEV__)
|
|
3585
|
+
throw new plugin.AnonPersistError({
|
|
3581
3586
|
cause: "no-key",
|
|
3582
|
-
callSite:
|
|
3587
|
+
callSite: plugin.captureUserCallSite()
|
|
3583
3588
|
});
|
|
3584
3589
|
if (!ssr && !warnedAnonPersistKeys.has(formKey)) {
|
|
3585
3590
|
warnedAnonPersistKeys.add(formKey);
|
|
@@ -3619,7 +3624,9 @@ function isDescendantPathKey(candidate, ancestor) {
|
|
|
3619
3624
|
|
|
3620
3625
|
let injectedInstanceCounter = 0;
|
|
3621
3626
|
function injectForm(key) {
|
|
3622
|
-
const
|
|
3627
|
+
const instance = vue.getCurrentInstance();
|
|
3628
|
+
if (instance !== null) plugin.ensureAttaformInstalled(instance.appContext.app);
|
|
3629
|
+
const registry = plugin.useRegistry();
|
|
3623
3630
|
const state = resolveState(key, registry);
|
|
3624
3631
|
if (state === null) return null;
|
|
3625
3632
|
if (vue.getCurrentScope() !== void 0) {
|
|
@@ -3631,7 +3638,7 @@ function injectForm(key) {
|
|
|
3631
3638
|
if (history !== void 0) {
|
|
3632
3639
|
apiOptions.history = history;
|
|
3633
3640
|
}
|
|
3634
|
-
const ambientInstanceId = vue.getCurrentInstance() !== null ? vue.inject(
|
|
3641
|
+
const ambientInstanceId = vue.getCurrentInstance() !== null ? vue.inject(plugin.kFormInstanceId, null) : null;
|
|
3635
3642
|
const formInstanceId = ambientInstanceId ?? (vue.getCurrentInstance() !== null ? vue.useId() : `atta:form-instance-injected:${injectedInstanceCounter++}`);
|
|
3636
3643
|
return buildFormApi(state, formInstanceId, apiOptions);
|
|
3637
3644
|
}
|
|
@@ -3644,7 +3651,7 @@ function resolveState(key, registry) {
|
|
|
3644
3651
|
}
|
|
3645
3652
|
return stored;
|
|
3646
3653
|
}
|
|
3647
|
-
const ambient = vue.inject(
|
|
3654
|
+
const ambient = vue.inject(plugin.kFormContext, null);
|
|
3648
3655
|
if (ambient === null) {
|
|
3649
3656
|
warnMiss("no ambient form context", registry.ssr);
|
|
3650
3657
|
return null;
|
|
@@ -3653,14 +3660,14 @@ function resolveState(key, registry) {
|
|
|
3653
3660
|
return ambient;
|
|
3654
3661
|
}
|
|
3655
3662
|
function warnMiss(detail, ssr) {
|
|
3656
|
-
if (!
|
|
3657
|
-
const frame =
|
|
3663
|
+
if (!plugin.__DEV__ || ssr) return;
|
|
3664
|
+
const frame = plugin.captureUserCallSite();
|
|
3658
3665
|
console.warn(
|
|
3659
3666
|
`[attaform] injectForm: ${detail}. Returning null.` + (frame !== void 0 ? ` ${frame}` : "")
|
|
3660
3667
|
);
|
|
3661
3668
|
}
|
|
3662
3669
|
function warnIfAmbientProviderHadDuplicates() {
|
|
3663
|
-
if (!
|
|
3670
|
+
if (!plugin.__DEV__ || ambientProvideHistory === null) return;
|
|
3664
3671
|
let ancestor = vue.getCurrentInstance()?.parent ?? null;
|
|
3665
3672
|
while (ancestor !== null) {
|
|
3666
3673
|
const history = ambientProvideHistory.get(ancestor);
|
|
@@ -3689,4 +3696,4 @@ exports.setAtPath = setAtPath;
|
|
|
3689
3696
|
exports.slimKindOf = slimKindOf;
|
|
3690
3697
|
exports.unset = unset;
|
|
3691
3698
|
exports.useAbstractForm = useAbstractForm;
|
|
3692
|
-
//# sourceMappingURL=attaform.
|
|
3699
|
+
//# sourceMappingURL=attaform.C9Ph2SMx.cjs.map
|