attaform 0.28.0 → 0.30.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.
Files changed (66) hide show
  1. package/dist/abstract.d.mts +5 -5
  2. package/dist/abstract.mjs +4 -4
  3. package/dist/dev/abstract.mjs +4 -4
  4. package/dist/dev/chunks/dev-key-collision-warnings.mjs +47 -8
  5. package/dist/dev/chunks/devtools.mjs +1 -1
  6. package/dist/dev/directive.mjs +1 -1
  7. package/dist/dev/history.mjs +1 -2
  8. package/dist/dev/index.mjs +5 -5
  9. package/dist/dev/runtime/plugins/attaform.mjs +3 -3
  10. package/dist/dev/shared/{attaform-dev.oYrkP9dj.mjs → attaform-dev.BK6Ge2qR.mjs} +80 -341
  11. package/dist/dev/shared/{attaform-dev.Dr2YzS5B.mjs → attaform-dev.BQc5QV3Y.mjs} +11 -19
  12. package/dist/dev/shared/{attaform-dev.BR8u0YOZ.mjs → attaform-dev.BcNtyOmf.mjs} +4 -4
  13. package/dist/{shared/attaform.h0i6LijT.mjs → dev/shared/attaform-dev.BcYT6tFh.mjs} +152 -20
  14. package/dist/dev/shared/{attaform-dev.6qxD-Yqo.mjs → attaform-dev.BisFstxh.mjs} +227 -88
  15. package/dist/dev/shared/{attaform-dev.WmuhD_CZ.mjs → attaform-dev.CQ2rJiAX.mjs} +833 -656
  16. package/dist/dev/shared/{attaform-dev.P7cseiEG.mjs → attaform-dev.D6CLvaQT.mjs} +20 -11
  17. package/dist/dev/shared/{attaform-dev.D2I8e_Mm.mjs → attaform-dev.DTrHonpc.mjs} +225 -238
  18. package/dist/dev/shared/{attaform-dev.BXE2cr0L.mjs → attaform-dev.DUZckyV8.mjs} +1 -3
  19. package/dist/dev/zod-v3.mjs +6 -6
  20. package/dist/dev/zod-v4.mjs +6 -6
  21. package/dist/dev/zod.mjs +5 -5
  22. package/dist/directive.d.mts +2 -2
  23. package/dist/directive.mjs +1 -1
  24. package/dist/history.d.mts +1 -1
  25. package/dist/history.mjs +1 -2
  26. package/dist/index.d.mts +9 -7
  27. package/dist/index.mjs +5 -5
  28. package/dist/nuxt.d.mts +11 -20
  29. package/dist/nuxt.mjs +0 -1
  30. package/dist/runtime/plugins/attaform.mjs +3 -3
  31. package/dist/shared/{attaform.uLbun31C.mjs → attaform.B3resMQ1.mjs} +19 -11
  32. package/dist/shared/{attaform.Cs2Rbdlo.mjs → attaform.BK0cgu2K.mjs} +123 -139
  33. package/dist/{dev/shared/attaform-dev.By4PRjt0.mjs → shared/attaform.BRDDQeHV.mjs} +136 -26
  34. package/dist/shared/{attaform.NLmerepI.mjs → attaform.BXneBxEj.mjs} +71 -334
  35. package/dist/shared/{attaform.D6DCnnQu.mjs → attaform.ByWP6kSx.mjs} +4 -4
  36. package/dist/shared/{attaform.CJP3RkGa.mjs → attaform.CJ8DpRGj.mjs} +223 -238
  37. package/dist/shared/{attaform.C09fpdLS.mjs → attaform.CUfrMK7t.mjs} +227 -88
  38. package/dist/shared/{attaform.wfY8XFvm.mjs → attaform.CdZIEf7_.mjs} +11 -19
  39. package/dist/shared/{attaform.JfSWdEcb.d.mts → attaform.Clz0ArIi.d.mts} +1 -1
  40. package/dist/shared/{attaform.B8k8JrmK.mjs → attaform.DNJOWjQw.mjs} +826 -612
  41. package/dist/shared/{attaform.B4VkS43-.d.mts → attaform.Rc9u4Vfw.d.mts} +1 -1
  42. package/dist/shared/{attaform.D5V4tZWq.d.mts → attaform.UGyOK83T.d.mts} +200 -218
  43. package/dist/shared/{attaform.Dq4vWxuG.mjs → attaform.WiGdIqgx.mjs} +1 -3
  44. package/dist/shared/{attaform.Cgu-hdSb.d.mts → attaform.bKLzMU0o.d.mts} +321 -523
  45. package/dist/transforms.d.mts +0 -22
  46. package/dist/transforms.mjs +1 -1
  47. package/dist/vite.d.mts +13 -4
  48. package/dist/vite.mjs +8 -2
  49. package/dist/zod-v3.d.mts +6 -4
  50. package/dist/zod-v3.mjs +6 -6
  51. package/dist/zod-v4.d.mts +18 -31
  52. package/dist/zod-v4.mjs +6 -6
  53. package/dist/zod.d.mts +4 -4
  54. package/dist/zod.mjs +5 -5
  55. package/package.json +19 -15
  56. package/skills/attaform/SKILL.md +6 -3
  57. package/skills/attaform/references/custom-components.md +8 -3
  58. package/skills/attaform/references/errors.md +8 -3
  59. package/skills/attaform/references/saving.md +77 -0
  60. package/skills/attaform/references/wizards.md +10 -8
  61. package/dist/chunks/fingerprint.mjs +0 -183
  62. package/dist/chunks/fingerprint2.mjs +0 -159
  63. package/dist/dev/chunks/fingerprint.mjs +0 -183
  64. package/dist/dev/chunks/fingerprint2.mjs +0 -159
  65. package/dist/dev/shared/attaform-dev.BJGA_UOS.mjs +0 -36
  66. package/dist/shared/attaform.BJGA_UOS.mjs +0 -36
@@ -1,4 +1,4 @@
1
- import { NodeTypes, createCompoundExpression, createSimpleExpression, ElementTypes, processExpression } from '@vue/compiler-core';
1
+ import { NodeTypes, ElementTypes, createCompoundExpression, createSimpleExpression, processExpression } from '@vue/compiler-core';
2
2
  import { S as SSR_COMPONENT_HOST_MODIFIER, V as V_REGISTER_COMPILED_MODIFIER } from './attaform.KvlEedlF.mjs';
3
3
 
4
4
  function getSummarizedProps(node) {
@@ -40,6 +40,10 @@ function removePropsByName(props, propNames) {
40
40
  props.splice(index, 1);
41
41
  }
42
42
  }
43
+ function toExpressionArray(value) {
44
+ if (value === void 0) return void 0;
45
+ return Array.isArray(value) ? value : [value];
46
+ }
43
47
  function isExactKey(summarizedKey, name) {
44
48
  return summarizedKey === name || summarizedKey === `"${name}"`;
45
49
  }
@@ -64,54 +68,13 @@ function flattenExpression(exp) {
64
68
  return out;
65
69
  }
66
70
 
67
- function generateEqualityExpression$1(selectValue, optionValue, previousOptionExpressions) {
68
- const multipleExpression = previousOptionExpressions?.[0];
69
- if (multipleExpression === void 0) {
70
- throw new Error(
71
- "Programming error: `multiple` expression for `select` node not generated while transforming AST"
72
- );
73
- }
74
- const optExpressions = previousOptionExpressions.slice(1);
75
- const noMultipleOptExpressions = optExpressions.reduce(
76
- (acc, curr, index) => {
77
- if (index === 0) {
78
- acc.push("(");
79
- }
80
- acc.push(...curr);
81
- if (index < optExpressions.length - 1) {
82
- acc.push(" || ");
83
- }
84
- if (index === optExpressions.length - 1) {
85
- acc.push(")");
86
- }
87
- return acc;
88
- },
89
- []
90
- );
71
+ function generateEqualityExpression$1(selectValue, optionValue, multipleExpression) {
91
72
  const selectValueArr = Array.isArray(selectValue) ? selectValue : [selectValue];
92
73
  const optionValueArr = Array.isArray(optionValue) ? optionValue : [optionValue];
93
74
  function getImplicitTrueMultipleExpression(expression) {
94
75
  if (expression.length === 1 && expression[0] === "") return [`true`];
95
76
  return expression;
96
77
  }
97
- previousOptionExpressions.push(["(", ...selectValueArr, ") === (", ...optionValueArr, ")"]);
98
- if (!noMultipleOptExpressions.length) {
99
- return [
100
- "(",
101
- ...getImplicitTrueMultipleExpression(multipleExpression),
102
- `) ? ((`,
103
- ...selectValueArr,
104
- `)?.innerRef?.value?.findIndex?.(el => el === (`,
105
- ...optionValueArr,
106
- `)) > -1) : (typeof (`,
107
- ...selectValueArr,
108
- `)?.innerRef?.value !== 'object' && String((`,
109
- ...selectValueArr,
110
- `)?.innerRef?.value) === String((`,
111
- ...optionValueArr,
112
- `)))`
113
- ];
114
- }
115
78
  return [
116
79
  "(",
117
80
  ...getImplicitTrueMultipleExpression(multipleExpression),
@@ -119,16 +82,13 @@ function generateEqualityExpression$1(selectValue, optionValue, previousOptionEx
119
82
  ...selectValueArr,
120
83
  `)?.innerRef?.value?.findIndex?.(el => el === (`,
121
84
  ...optionValueArr,
122
- `)) > -1) : ((`,
123
- ...noMultipleOptExpressions,
124
- // if true, we already found the relevant option
125
- `) ? false : (typeof (`,
85
+ `)) > -1) : (typeof (`,
126
86
  ...selectValueArr,
127
- `)?.innerRef?.value !== 'object' && String((`,
87
+ `)?.innerRef?.value !== 'object' && (`,
128
88
  ...selectValueArr,
129
- `)?.innerRef?.value) === String((`,
89
+ `)?.displayValue?.value === String((`,
130
90
  ...optionValueArr,
131
- `))))`
91
+ `)))`
132
92
  ];
133
93
  }
134
94
  function extractMultipleFromSelectSummarizedProps(props) {
@@ -143,7 +103,7 @@ function extractMultipleFromSelectSummarizedProps(props) {
143
103
  const value = props[priorityIndex]?.value;
144
104
  return typeof value === "string" ? value.replace(/'|"/g, "") : value ?? "true";
145
105
  }
146
- const RECURSABLE_NODE_TYPES$1 = /* @__PURE__ */ new Set([
106
+ const RECURSABLE_NODE_TYPES = /* @__PURE__ */ new Set([
147
107
  NodeTypes.ELEMENT,
148
108
  NodeTypes.FOR,
149
109
  NodeTypes.IF,
@@ -170,6 +130,57 @@ function inferOptionValueFromChildren(node) {
170
130
  const text = only.content.trim();
171
131
  return JSON.stringify(text);
172
132
  }
133
+ const pendingOptionBindings = /* @__PURE__ */ new WeakMap();
134
+ function applyPendingOptionBinding(node, pending) {
135
+ const optionProps = getSummarizedProps(node);
136
+ const valueIndex = optionProps.findIndex((p) => isExactKey(p.key, "value"));
137
+ let optionValueSummarizedProp;
138
+ if (valueIndex >= 0 && valueIndex < optionProps.length) {
139
+ optionValueSummarizedProp = optionProps[valueIndex];
140
+ } else {
141
+ const fallback = inferOptionValueFromChildren(node);
142
+ if (fallback === null) {
143
+ return;
144
+ }
145
+ optionValueSummarizedProp = { key: "value", value: fallback };
146
+ }
147
+ const props = node.props;
148
+ const snapshot = [...props];
149
+ try {
150
+ removePropsByName(props, ["selected"]);
151
+ const authorSelectedArr = toExpressionArray(
152
+ optionProps.find((p) => isExactKey(p.key, "selected"))?.value
153
+ );
154
+ const registerArr = toExpressionArray(pending.registerValue) ?? ["undefined"];
155
+ const boundExpression = generateEqualityExpression$1(
156
+ pending.registerValue,
157
+ optionValueSummarizedProp?.value ?? "undefined",
158
+ pending.multiple
159
+ );
160
+ props.push({
161
+ arg: createSimpleExpression("selected", true),
162
+ exp: createCompoundExpression(
163
+ authorSelectedArr === void 0 ? boundExpression : [
164
+ "((",
165
+ ...registerArr,
166
+ ") == null ? (",
167
+ ...authorSelectedArr,
168
+ ") : (",
169
+ ...boundExpression,
170
+ "))"
171
+ ]
172
+ ),
173
+ name: "bind",
174
+ modifiers: [],
175
+ type: NodeTypes.DIRECTIVE,
176
+ loc: node.loc
177
+ });
178
+ } catch (err) {
179
+ props.length = 0;
180
+ props.push(...snapshot);
181
+ console.error("[attaform] component-bridge transform: option binding failed, skipping:", err);
182
+ }
183
+ }
173
184
  const componentBridgeTransform = (node, context) => {
174
185
  const snapshots = [];
175
186
  const snapshotProps = (target) => {
@@ -177,51 +188,33 @@ const componentBridgeTransform = (node, context) => {
177
188
  snapshots.push({ target, snapshot: [...target] });
178
189
  };
179
190
  try {
180
- let traverseSelectNode = function(_node, previousOptionExpressions2) {
191
+ let traverseSelectNode = function(_node, multipleExpression2) {
181
192
  const isOption = _node.type === NodeTypes.ELEMENT && _node.tag === "option";
182
193
  if (!isOption) {
183
- if (!RECURSABLE_NODE_TYPES$1.has(_node.type)) return;
194
+ if (!RECURSABLE_NODE_TYPES.has(_node.type)) return;
184
195
  const hasChildren = "children" in _node;
185
196
  if (!hasChildren) return;
186
197
  for (const child of _node.children) {
187
198
  if (typeof child === "symbol" || typeof child === "string") continue;
188
199
  if (child.type === NodeTypes.SIMPLE_EXPRESSION) continue;
189
- traverseSelectNode(child, previousOptionExpressions2);
200
+ traverseSelectNode(child, multipleExpression2);
190
201
  }
191
202
  return;
192
203
  }
193
204
  hasSlottedOptions = true;
194
- const optionProps = getSummarizedProps(_node);
195
- const valueIndex = optionProps.findIndex((p) => isExactKey(p.key, "value"));
196
- let optionValueSummarizedProp;
197
- if (valueIndex >= 0 && valueIndex < optionProps.length) {
198
- optionValueSummarizedProp = optionProps[valueIndex];
199
- } else {
200
- const fallback = inferOptionValueFromChildren(_node);
201
- if (fallback === null) {
202
- return;
203
- }
204
- optionValueSummarizedProp = { key: "value", value: fallback };
205
- }
206
- const props = _node.props;
207
- snapshotProps(props);
208
- removePropsByName(props, ["selected"]);
209
- const newProp = {
210
- arg: createSimpleExpression("selected", true),
211
- exp: createCompoundExpression(
212
- generateEqualityExpression$1(
213
- registerSummarizedProp?.value ?? "undefined",
214
- optionValueSummarizedProp?.value ?? "undefined",
215
- previousOptionExpressions2
216
- )
217
- ),
218
- name: "bind",
219
- modifiers: [],
220
- type: NodeTypes.DIRECTIVE,
221
- loc: _node.loc
222
- };
223
- props.push(newProp);
205
+ pendingOptionBindings.set(_node, {
206
+ registerValue: registerSummarizedProp?.value ?? "undefined",
207
+ multiple: multipleExpression2
208
+ });
224
209
  };
210
+ if (node.type === NodeTypes.ELEMENT && node.tagType === ElementTypes.ELEMENT) {
211
+ const pending = pendingOptionBindings.get(node);
212
+ if (pending !== void 0) {
213
+ pendingOptionBindings.delete(node);
214
+ applyPendingOptionBinding(node, pending);
215
+ return;
216
+ }
217
+ }
225
218
  const isSelect = node.type === NodeTypes.ELEMENT && node.tag === "select";
226
219
  const isCustomComponent = node.type === NodeTypes.ELEMENT && node.tagType === ElementTypes.COMPONENT;
227
220
  const isKebabCustomElement = node.type === NodeTypes.ELEMENT && node.tagType === ElementTypes.ELEMENT && node.tag.includes("-") && !NATIVE_FORM_TAGS.has(node.tag);
@@ -233,25 +226,32 @@ const componentBridgeTransform = (node, context) => {
233
226
  const registerSummarizedProp = selectSummarizedProps[registerIndex];
234
227
  const selectLoc = node.loc;
235
228
  let hasSlottedOptions = false;
236
- const multipleExpression = extractMultipleFromSelectSummarizedProps(selectSummarizedProps);
237
- const previousOptionExpressions = typeof multipleExpression === "string" ? [[multipleExpression]] : [multipleExpression];
229
+ const rawMultipleExpression = extractMultipleFromSelectSummarizedProps(selectSummarizedProps);
230
+ const multipleExpression = typeof rawMultipleExpression === "string" ? [rawMultipleExpression] : rawMultipleExpression;
238
231
  for (const child of node.children) {
239
- traverseSelectNode(child, previousOptionExpressions);
232
+ traverseSelectNode(child, multipleExpression);
240
233
  }
241
- const isStaticallyNonMultiple = multipleExpression === "false";
234
+ const isStaticallyNonMultiple = rawMultipleExpression === "false";
242
235
  const isComponentHost = isCustomComponent || isKebabCustomElement;
243
236
  const isSelectLikeHost = isSelect || isComponentHost && hasSlottedOptions;
244
237
  const isPlainComponentHost = isComponentHost && !hasSlottedOptions;
245
238
  const selectProps = node.props;
239
+ const authorSelectValueArr = toExpressionArray(
240
+ selectSummarizedProps.find((p) => isExactKey(p.key, "value"))?.value
241
+ );
246
242
  snapshotProps(selectProps);
247
243
  removePropsByName(selectProps, ["value"]);
248
244
  if (isStaticallyNonMultiple && isSelectLikeHost) {
249
245
  const valuePropExpArray = Array.isArray(registerSummarizedProp?.value) ? registerSummarizedProp.value : [registerSummarizedProp?.value ?? "undefined"];
250
- const initExpression = createCompoundExpression([
251
- "(",
252
- ...valuePropExpArray,
253
- ")?.displayValue.value"
254
- ]);
246
+ const initExpression = createCompoundExpression(
247
+ authorSelectValueArr === void 0 ? ["(", ...valuePropExpArray, ")?.displayValue.value"] : [
248
+ "((",
249
+ ...valuePropExpArray,
250
+ ")?.displayValue.value ?? (",
251
+ ...authorSelectValueArr,
252
+ "))"
253
+ ]
254
+ );
255
255
  const simpleExpression = createSimpleExpression(flattenExpression(initExpression), false);
256
256
  let outputExp;
257
257
  try {
@@ -470,26 +470,41 @@ const inputTextAreaNodeTransform = (node) => {
470
470
  const isStaticRadio = typeProp !== void 0 && isStaticTypeOneOf(typeProp.value, ["radio"]);
471
471
  const isDynamicType = typeProp !== void 0 && isDynamicTypeValue(typeProp.value);
472
472
  const keepStaticValue = isStaticCheckbox || isStaticRadio || isDynamicType;
473
+ const authorCheckedProp = elementProps.find((p) => isExactKey(p.key, "checked"));
474
+ const authorValueProp = keepStaticValue ? void 0 : elementProps.find((p) => isExactKey(p.key, "value"));
473
475
  removePropsByName(props, keepStaticValue ? ["checked"] : ["checked", "value"]);
474
476
  const registerValueArr = Array.isArray(registerSummarizedProp2.value) ? registerSummarizedProp2.value : [registerSummarizedProp2.value];
475
- const valueExpression = createCompoundExpression([
476
- "(",
477
- ...registerValueArr,
478
- ")?.displayValue?.value"
479
- ]);
477
+ const authorValueArr = toExpressionArray(authorValueProp?.value);
478
+ const valueExpression = createCompoundExpression(
479
+ authorValueArr === void 0 ? ["(", ...registerValueArr, ")?.displayValue?.value"] : ["((", ...registerValueArr, ")?.displayValue?.value ?? (", ...authorValueArr, "))"]
480
+ );
480
481
  const trueValueIndex = elementProps.findIndex((p) => isExactKey(p.key, "true-value"));
481
482
  const trueValueProp = elementProps[trueValueIndex];
482
483
  const scalarTarget = isStaticCheckbox ? trueValueProp !== void 0 ? trueValueProp.value : "true" : elementValueSummarizedProp2.value;
483
- const coreExpression = [
484
- "(",
485
- ...elementSelectionLabelExpression.children,
486
- ") === 'checked' ? (",
487
- // resolves to a boolean
484
+ const authorCheckedArr = toExpressionArray(authorCheckedProp?.value);
485
+ const checkedExpression = authorCheckedArr === void 0 ? generateEqualityExpression(
486
+ registerSummarizedProp2.value,
487
+ elementValueSummarizedProp2.value,
488
+ scalarTarget
489
+ ) : [
490
+ "((",
491
+ ...registerValueArr,
492
+ ") == null ? (",
493
+ ...authorCheckedArr,
494
+ ") : (",
488
495
  ...generateEqualityExpression(
489
496
  registerSummarizedProp2.value,
490
497
  elementValueSummarizedProp2.value,
491
498
  scalarTarget
492
499
  ),
500
+ "))"
501
+ ];
502
+ const coreExpression = [
503
+ "(",
504
+ ...elementSelectionLabelExpression.children,
505
+ ") === 'checked' ? (",
506
+ // resolves to a boolean
507
+ ...checkedExpression,
493
508
  ") : (",
494
509
  // resolves to the provided register value
495
510
  ...valueExpression.children,
@@ -562,22 +577,10 @@ const inputTextAreaNodeTransform = (node) => {
562
577
  }
563
578
  };
564
579
 
565
- const RECURSABLE_NODE_TYPES = /* @__PURE__ */ new Set([
566
- NodeTypes.ELEMENT,
567
- NodeTypes.FOR,
568
- NodeTypes.IF,
569
- NodeTypes.IF_BRANCH
570
- ]);
571
- function findRedundantStateBinding(props, stateNames) {
580
+ function findRedundantStateBinding(props) {
572
581
  for (const prop of props) {
573
- if (prop.type === NodeTypes.ATTRIBUTE) {
574
- if (stateNames.includes(prop.name)) return prop.name;
575
- continue;
576
- }
582
+ if (prop.type === NodeTypes.ATTRIBUTE) continue;
577
583
  if (prop.name === "model") return "v-model";
578
- if (prop.name === "bind" && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic && stateNames.includes(prop.arg.content)) {
579
- return `:${prop.arg.content}`;
580
- }
581
584
  }
582
585
  return null;
583
586
  }
@@ -602,42 +605,23 @@ function emitRedundantWarning(tag, binding) {
602
605
  `[attaform] \`${binding}\` is redundant beside v-register on <${tag}>. v-register already drives this field's value, so keep v-register alone and drop \`${binding}\`. (An identity \`:value\` on a radio or <option> is expected and stays silent.)`
603
606
  );
604
607
  }
605
- function walkOptionsForSelected(selectNode) {
606
- const visit = (candidate) => {
607
- if (candidate.type === NodeTypes.ELEMENT && candidate.tag === "option") {
608
- const found = findRedundantStateBinding(candidate.props, ["selected"]);
609
- if (found !== null) emitRedundantWarning("option", found);
610
- return;
611
- }
612
- if (!RECURSABLE_NODE_TYPES.has(candidate.type)) return;
613
- if (!("children" in candidate)) return;
614
- for (const child of candidate.children) {
615
- if (typeof child === "string" || typeof child === "symbol") continue;
616
- if (child.type === NodeTypes.SIMPLE_EXPRESSION) continue;
617
- visit(child);
618
- }
619
- };
620
- for (const child of selectNode.children) visit(child);
621
- }
622
608
  function warnIfRedundant(node) {
623
609
  if (node.tagType !== ElementTypes.ELEMENT) return;
624
610
  const tag = node.tag;
625
611
  if (tag === "select") {
626
- const found2 = findRedundantStateBinding(node.props, ["value"]);
612
+ const found2 = findRedundantStateBinding(node.props);
627
613
  if (found2 !== null) emitRedundantWarning("select", found2);
628
- walkOptionsForSelected(node);
629
614
  return;
630
615
  }
631
616
  if (tag === "textarea") {
632
- const found2 = findRedundantStateBinding(node.props, ["value"]);
617
+ const found2 = findRedundantStateBinding(node.props);
633
618
  if (found2 !== null) emitRedundantWarning("textarea", found2);
634
619
  return;
635
620
  }
636
621
  if (tag !== "input") return;
637
622
  const kind = classifyInput(node.props);
638
623
  if (kind === "dynamic" || kind === "file") return;
639
- const stateNames = kind === "checkbox" || kind === "radio" ? ["checked"] : ["value"];
640
- const found = findRedundantStateBinding(node.props, stateNames);
624
+ const found = findRedundantStateBinding(node.props);
641
625
  if (found !== null) emitRedundantWarning("input", found);
642
626
  }
643
627
  const redundantBindingWarnTransform = (node) => {
@@ -1,4 +1,4 @@
1
- import { f as pathsEqual, i as isPathPrefix } from './attaform-dev.Dr2YzS5B.mjs';
1
+ import { m as mapSegmentKeys, f as pathsEqual, i as isPathPrefix } from './attaform.CdZIEf7_.mjs';
2
2
 
3
3
  const DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS = 0;
4
4
  const DEFAULT_HISTORY_MAX_SNAPSHOTS = 128;
@@ -7,15 +7,8 @@ const ANONYMOUS_FORM_KEY_PREFIX = `${RESERVED_KEY_PREFIX}anon:`;
7
7
  const ANONYMOUS_WIZARD_KEY_PREFIX = `${RESERVED_KEY_PREFIX}anon-wizard:`;
8
8
  const DEFAULT_MAX_RECURSION_DEPTH = 64;
9
9
  function normalizeNumericOption(config) {
10
- const { value, source, allowInfinity, min, defaultValue } = config;
11
- if (allowInfinity && value === Infinity) return Infinity;
12
- if (typeof value !== "number" || Number.isNaN(value) || value === Infinity || value === -Infinity) {
13
- {
14
- const acceptedDescription = allowInfinity ? "a non-negative integer or Infinity" : "a non-negative finite integer";
15
- console.warn(
16
- `[attaform] ${source} must be ${acceptedDescription}; got ${String(value)}. Falling back to ${String(defaultValue)}.`
17
- );
18
- }
10
+ const { value, source, min, defaultValue } = config;
11
+ if (typeof value !== "number" || !Number.isFinite(value)) {
19
12
  return defaultValue;
20
13
  }
21
14
  return Math.max(min, Math.floor(value));
@@ -28,6 +21,49 @@ function pickDefined(bag) {
28
21
  return out;
29
22
  }
30
23
 
24
+ function callConsumerSchemaFn(fn, fallback, site) {
25
+ try {
26
+ return fn();
27
+ } catch (err) {
28
+ return fallback;
29
+ }
30
+ }
31
+ function readConsumerProp(obj, key) {
32
+ try {
33
+ return obj[key];
34
+ } catch {
35
+ return void 0;
36
+ }
37
+ }
38
+ function consumerKeys(obj) {
39
+ try {
40
+ return Object.keys(obj);
41
+ } catch {
42
+ return [];
43
+ }
44
+ }
45
+ function readConsumerIndex(arr, i) {
46
+ try {
47
+ return arr[i];
48
+ } catch {
49
+ return void 0;
50
+ }
51
+ }
52
+ function consumerSymbolKeys(obj) {
53
+ try {
54
+ return Object.getOwnPropertySymbols(obj);
55
+ } catch {
56
+ return [];
57
+ }
58
+ }
59
+ function consumerHas(obj, key) {
60
+ try {
61
+ return key in obj;
62
+ } catch {
63
+ return false;
64
+ }
65
+ }
66
+
31
67
  function safeAssign(target, key, value) {
32
68
  if (key === "__proto__") {
33
69
  Object.defineProperty(target, key, {
@@ -40,24 +76,50 @@ function safeAssign(target, key, value) {
40
76
  }
41
77
  target[key] = value;
42
78
  }
79
+ const SHADOWED_KEYS = new Set(Object.getOwnPropertyNames(Object.prototype));
43
80
  function isShadowedKey(key) {
44
- return key in Object.prototype;
81
+ return SHADOWED_KEYS.has(key);
45
82
  }
46
83
  function safeOwnRead(target, key) {
47
84
  if (isShadowedKey(key)) {
48
85
  const desc = Object.getOwnPropertyDescriptor(target, key);
49
86
  if (desc === void 0) return void 0;
50
- return "value" in desc ? desc.value : target[key];
87
+ return "value" in desc ? desc.value : readConsumerProp(target, key);
51
88
  }
52
- return target[key];
89
+ return readConsumerProp(target, key);
53
90
  }
54
91
  function safeOwnHas(target, key) {
55
- return Object.prototype.hasOwnProperty.call(target, key);
92
+ try {
93
+ return Object.prototype.hasOwnProperty.call(target, key);
94
+ } catch {
95
+ return false;
96
+ }
97
+ }
98
+ function spreadConsumerRecord(src) {
99
+ try {
100
+ return { ...src };
101
+ } catch {
102
+ const out = {};
103
+ for (const key of Object.keys(src)) {
104
+ safeAssign(out, key, readConsumerProp(src, key));
105
+ }
106
+ return out;
107
+ }
108
+ }
109
+ function copyConsumerArray(src) {
110
+ try {
111
+ return src.slice();
112
+ } catch {
113
+ const out = new Array(src.length);
114
+ for (let i = 0; i < src.length; i++) out[i] = readConsumerIndex(src, i);
115
+ return out;
116
+ }
56
117
  }
57
118
 
58
119
  function isDescendable(value) {
59
120
  if (value === null || typeof value !== "object") return false;
60
121
  if (Array.isArray(value)) return true;
122
+ if (value instanceof Map) return mapSegmentKeys(value) !== null;
61
123
  const proto = Object.getPrototypeOf(value);
62
124
  return proto === null || proto === Object.prototype;
63
125
  }
@@ -83,6 +145,16 @@ function diffAndApply(oldValue, newValue, prefix, visit) {
83
145
  return;
84
146
  }
85
147
  if (oldIsDescendable && newIsDescendable) {
148
+ const oldIsMap = oldValue instanceof Map;
149
+ const newIsMap = newValue instanceof Map;
150
+ if (oldIsMap && newIsMap) {
151
+ diffMapsLockstep(oldValue, newValue, prefix, visit);
152
+ return;
153
+ }
154
+ if (oldIsMap !== newIsMap) {
155
+ visit({ kind: "changed", path: prefix, oldValue, newValue });
156
+ return;
157
+ }
86
158
  const oldIsArray = Array.isArray(oldValue);
87
159
  const newIsArray = Array.isArray(newValue);
88
160
  if (oldIsArray && newIsArray) {
@@ -122,46 +194,79 @@ function diffAndApply(oldValue, newValue, prefix, visit) {
122
194
  function walkNewDescendable(newValue, prefix, visit) {
123
195
  if (Array.isArray(newValue)) {
124
196
  for (let i = 0; i < newValue.length; i++) {
125
- diffAndApply(void 0, newValue[i], appendSegment(prefix, i), visit);
197
+ diffAndApply(void 0, readConsumerIndex(newValue, i), appendSegment(prefix, i), visit);
198
+ }
199
+ } else if (newValue instanceof Map) {
200
+ for (const [key, entry] of newValue) {
201
+ diffAndApply(void 0, entry, appendSegment(prefix, key), visit);
126
202
  }
127
203
  } else {
128
204
  const rec = newValue;
129
- for (const k of Object.keys(rec)) {
130
- diffAndApply(void 0, rec[k], appendSegment(prefix, k), visit);
205
+ for (const k of consumerKeys(rec)) {
206
+ diffAndApply(void 0, readConsumerProp(rec, k), appendSegment(prefix, k), visit);
131
207
  }
132
208
  }
133
209
  }
134
210
  function walkOldDescendable(oldValue, prefix, visit) {
135
211
  if (Array.isArray(oldValue)) {
136
212
  for (let i = 0; i < oldValue.length; i++) {
137
- diffAndApply(oldValue[i], void 0, appendSegment(prefix, i), visit);
213
+ diffAndApply(readConsumerIndex(oldValue, i), void 0, appendSegment(prefix, i), visit);
214
+ }
215
+ } else if (oldValue instanceof Map) {
216
+ for (const [key, entry] of oldValue) {
217
+ diffAndApply(entry, void 0, appendSegment(prefix, key), visit);
138
218
  }
139
219
  } else {
140
220
  const rec = oldValue;
141
- for (const k of Object.keys(rec)) {
142
- diffAndApply(rec[k], void 0, appendSegment(prefix, k), visit);
221
+ for (const k of consumerKeys(rec)) {
222
+ diffAndApply(readConsumerProp(rec, k), void 0, appendSegment(prefix, k), visit);
143
223
  }
144
224
  }
145
225
  }
226
+ function diffMapsLockstep(oldMap, newMap, prefix, visit) {
227
+ for (const [key, entry] of newMap) {
228
+ diffAndApply(oldMap.get(key), entry, appendSegment(prefix, key), visit);
229
+ }
230
+ for (const [key, entry] of oldMap) {
231
+ if (newMap.has(key)) continue;
232
+ diffAndApply(entry, void 0, appendSegment(prefix, key), visit);
233
+ }
234
+ }
146
235
  function diffArraysLockstep(oldArr, newArr, prefix, visit) {
147
236
  const max = Math.max(oldArr.length, newArr.length);
148
237
  for (let i = 0; i < max; i++) {
149
- diffAndApply(oldArr[i], newArr[i], appendSegment(prefix, i), visit);
238
+ diffAndApply(
239
+ readConsumerIndex(oldArr, i),
240
+ readConsumerIndex(newArr, i),
241
+ appendSegment(prefix, i),
242
+ visit
243
+ );
150
244
  }
151
245
  }
152
246
  function diffObjectsLockstep(oldRec, newRec, prefix, visit) {
153
247
  const seen = /* @__PURE__ */ new Set();
154
- for (const k of Object.keys(oldRec)) {
248
+ for (const k of consumerKeys(oldRec)) {
155
249
  seen.add(k);
156
- diffAndApply(oldRec[k], newRec[k], appendSegment(prefix, k), visit);
250
+ diffAndApply(
251
+ readConsumerProp(oldRec, k),
252
+ readConsumerProp(newRec, k),
253
+ appendSegment(prefix, k),
254
+ visit
255
+ );
157
256
  }
158
- for (const k of Object.keys(newRec)) {
257
+ for (const k of consumerKeys(newRec)) {
159
258
  if (seen.has(k)) continue;
160
- diffAndApply(oldRec[k], newRec[k], appendSegment(prefix, k), visit);
259
+ diffAndApply(
260
+ readConsumerProp(oldRec, k),
261
+ readConsumerProp(newRec, k),
262
+ appendSegment(prefix, k),
263
+ visit
264
+ );
161
265
  }
162
266
  }
163
267
  function applyChangedKeys(target, source, arrayOpPath, currentPath, patches) {
164
268
  if (!isDescendable(target) || !isDescendable(source)) return false;
269
+ if (target instanceof Map || source instanceof Map) return false;
165
270
  const targetIsArray = Array.isArray(target);
166
271
  const sourceIsArray = Array.isArray(source);
167
272
  if (targetIsArray !== sourceIsArray) return false;
@@ -230,6 +335,11 @@ function applyChangedKeys(target, source, arrayOpPath, currentPath, patches) {
230
335
  }
231
336
  function structuralSnapshot(value) {
232
337
  if (!isDescendable(value)) return value;
338
+ if (value instanceof Map) {
339
+ const out2 = /* @__PURE__ */ new Map();
340
+ for (const [k, v] of value) out2.set(k, structuralSnapshot(v));
341
+ return out2;
342
+ }
233
343
  if (Array.isArray(value)) {
234
344
  const out2 = new Array(value.length);
235
345
  for (let i = 0; i < value.length; i++) {
@@ -245,4 +355,4 @@ function structuralSnapshot(value) {
245
355
  return out;
246
356
  }
247
357
 
248
- export { ANONYMOUS_FORM_KEY_PREFIX as A, DEFAULT_HISTORY_MAX_SNAPSHOTS as D, RESERVED_KEY_PREFIX as R, safeOwnRead as a, safeAssign as b, safeOwnHas as c, diffAndApply as d, DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS as e, applyChangedKeys as f, DEFAULT_MAX_RECURSION_DEPTH as g, ANONYMOUS_WIZARD_KEY_PREFIX as h, isShadowedKey as i, normalizeNumericOption as n, pickDefined as p, structuralSnapshot as s };
358
+ export { ANONYMOUS_FORM_KEY_PREFIX as A, DEFAULT_HISTORY_MAX_SNAPSHOTS as D, RESERVED_KEY_PREFIX as R, safeOwnRead as a, safeAssign as b, callConsumerSchemaFn as c, safeOwnHas as d, consumerHas as e, spreadConsumerRecord as f, copyConsumerArray as g, consumerKeys as h, isShadowedKey as i, readConsumerProp as j, diffAndApply as k, DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS as l, consumerSymbolKeys as m, normalizeNumericOption as n, applyChangedKeys as o, pickDefined as p, DEFAULT_MAX_RECURSION_DEPTH as q, readConsumerIndex as r, structuralSnapshot as s, ANONYMOUS_WIZARD_KEY_PREFIX as t };