attaform 0.18.2 → 0.20.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 (111) hide show
  1. package/README.md +3 -0
  2. package/dist/chunks/devtools.cjs +1 -1
  3. package/dist/chunks/devtools.mjs +1 -1
  4. package/dist/chunks/indexeddb.cjs +1 -1
  5. package/dist/chunks/indexeddb.mjs +1 -1
  6. package/dist/chunks/local-storage.cjs +1 -1
  7. package/dist/chunks/local-storage.mjs +1 -1
  8. package/dist/chunks/session-storage.cjs +1 -1
  9. package/dist/chunks/session-storage.mjs +1 -1
  10. package/dist/index.cjs +4 -7
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +77 -110
  13. package/dist/index.d.mts +77 -110
  14. package/dist/index.d.ts +77 -110
  15. package/dist/index.mjs +5 -5
  16. package/dist/nuxt.d.cts +1 -1
  17. package/dist/nuxt.d.mts +1 -1
  18. package/dist/nuxt.d.ts +1 -1
  19. package/dist/runtime/components/AttaformDevtoolsPanel.vue +2 -2
  20. package/dist/runtime/components/DevtoolsValueTree.d.vue.ts +1 -3
  21. package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +1 -3
  22. package/dist/runtime/plugins/attaform.cjs +2 -2
  23. package/dist/runtime/plugins/attaform.mjs +2 -2
  24. package/dist/shared/{attaform.CDmaxrt2.mjs → attaform.BKozEdTr.mjs} +305 -178
  25. package/dist/shared/attaform.BKozEdTr.mjs.map +1 -0
  26. package/dist/shared/{attaform.Bubm_slq.cjs → attaform.BM6YD9kZ.cjs} +212 -269
  27. package/dist/shared/attaform.BM6YD9kZ.cjs.map +1 -0
  28. package/dist/shared/{attaform.5UhpSVFI.cjs → attaform.BPxsYtTe.cjs} +2 -26
  29. package/dist/shared/attaform.BPxsYtTe.cjs.map +1 -0
  30. package/dist/shared/{attaform.BqK_L4gK.cjs → attaform.BPy-4qRx.cjs} +305 -180
  31. package/dist/shared/attaform.BPy-4qRx.cjs.map +1 -0
  32. package/dist/shared/attaform.BWgAFnsj.mjs +770 -0
  33. package/dist/shared/attaform.BWgAFnsj.mjs.map +1 -0
  34. package/dist/shared/{attaform.CGX1CNpz.d.ts → attaform.Bh3ACtts.d.ts} +152 -111
  35. package/dist/shared/{attaform.CXpzmj38.mjs → attaform.BupwXkj_.mjs} +213 -270
  36. package/dist/shared/attaform.BupwXkj_.mjs.map +1 -0
  37. package/dist/shared/{attaform.Dlk1jMuv.cjs → attaform.CIn4bMsD.cjs} +263 -799
  38. package/dist/shared/attaform.CIn4bMsD.cjs.map +1 -0
  39. package/dist/shared/{attaform.CZ-XtZt_.mjs → attaform.CKFbKFb6.mjs} +2265 -1509
  40. package/dist/shared/attaform.CKFbKFb6.mjs.map +1 -0
  41. package/dist/shared/{attaform.CuN7ZhBy.d.cts → attaform.D5-1XGQU.d.cts} +152 -111
  42. package/dist/shared/{attaform.-1GQTX2T.mjs → attaform.DEBvCjeH.mjs} +257 -793
  43. package/dist/shared/attaform.DEBvCjeH.mjs.map +1 -0
  44. package/dist/shared/{attaform.II89Pcf4.cjs → attaform.DL4CQ-oW.cjs} +2270 -1514
  45. package/dist/shared/attaform.DL4CQ-oW.cjs.map +1 -0
  46. package/dist/shared/{attaform.FnEwjhvX.d.ts → attaform.DSD85fHb.d.cts} +1 -19
  47. package/dist/shared/{attaform.CRmmNAYp.d.cts → attaform.DSD85fHb.d.mts} +1 -19
  48. package/dist/shared/{attaform.D9wuTGu9.d.mts → attaform.DSD85fHb.d.ts} +1 -19
  49. package/dist/shared/{attaform.B7rzpK1U.d.cts → attaform.DkA5J8NW.d.cts} +1 -17
  50. package/dist/shared/{attaform.B7rzpK1U.d.mts → attaform.DkA5J8NW.d.mts} +1 -17
  51. package/dist/shared/{attaform.B7rzpK1U.d.ts → attaform.DkA5J8NW.d.ts} +1 -17
  52. package/dist/shared/{attaform.B957T6NU.d.ts → attaform.Dl5kDY-A.d.ts} +1 -1
  53. package/dist/shared/attaform.Dmb6itxC.cjs +781 -0
  54. package/dist/shared/attaform.Dmb6itxC.cjs.map +1 -0
  55. package/dist/shared/{attaform.M-RanbyV.d.mts → attaform.DoKXru-a.d.mts} +1 -1
  56. package/dist/shared/attaform.DvA-CJJW.mjs +1876 -0
  57. package/dist/shared/attaform.DvA-CJJW.mjs.map +1 -0
  58. package/dist/shared/{attaform.D1gzu2GL.d.mts → attaform.EMzJcQci.d.mts} +152 -111
  59. package/dist/shared/attaform.EZG6fOFb.mjs +35 -0
  60. package/dist/shared/attaform.EZG6fOFb.mjs.map +1 -0
  61. package/dist/shared/{attaform.XDjA7sRz.d.cts → attaform.GbDo_lJi.d.cts} +1 -1
  62. package/dist/shared/{attaform.Ca5_6Ky-.d.mts → attaform.SfhU0OEY.d.cts} +499 -116
  63. package/dist/shared/{attaform.Ca5_6Ky-.d.cts → attaform.SfhU0OEY.d.mts} +499 -116
  64. package/dist/shared/{attaform.Ca5_6Ky-.d.ts → attaform.SfhU0OEY.d.ts} +499 -116
  65. package/dist/shared/attaform.jgzuNZVC.cjs +1882 -0
  66. package/dist/shared/attaform.jgzuNZVC.cjs.map +1 -0
  67. package/dist/transforms.cjs +2 -2
  68. package/dist/transforms.d.cts +22 -13
  69. package/dist/transforms.d.mts +22 -13
  70. package/dist/transforms.d.ts +22 -13
  71. package/dist/transforms.mjs +1 -1
  72. package/dist/vite.cjs +8 -7
  73. package/dist/vite.cjs.map +1 -1
  74. package/dist/vite.mjs +8 -7
  75. package/dist/vite.mjs.map +1 -1
  76. package/dist/zod-v3.cjs +3 -3
  77. package/dist/zod-v3.d.cts +32 -6
  78. package/dist/zod-v3.d.mts +32 -6
  79. package/dist/zod-v3.d.ts +32 -6
  80. package/dist/zod-v3.mjs +3 -3
  81. package/dist/zod-v4.cjs +3 -3
  82. package/dist/zod-v4.d.cts +12 -8
  83. package/dist/zod-v4.d.mts +12 -8
  84. package/dist/zod-v4.d.ts +12 -8
  85. package/dist/zod-v4.mjs +3 -3
  86. package/dist/zod.cjs +8 -8
  87. package/dist/zod.cjs.map +1 -1
  88. package/dist/zod.d.cts +6 -6
  89. package/dist/zod.d.mts +6 -6
  90. package/dist/zod.d.ts +6 -6
  91. package/dist/zod.mjs +6 -6
  92. package/package.json +2 -2
  93. package/dist/shared/attaform.-1GQTX2T.mjs.map +0 -1
  94. package/dist/shared/attaform.5UhpSVFI.cjs.map +0 -1
  95. package/dist/shared/attaform.BqK_L4gK.cjs.map +0 -1
  96. package/dist/shared/attaform.Bubm_slq.cjs.map +0 -1
  97. package/dist/shared/attaform.C8CyvYa_.cjs +0 -36
  98. package/dist/shared/attaform.C8CyvYa_.cjs.map +0 -1
  99. package/dist/shared/attaform.CDmaxrt2.mjs.map +0 -1
  100. package/dist/shared/attaform.CXpzmj38.mjs.map +0 -1
  101. package/dist/shared/attaform.CZ-XtZt_.mjs.map +0 -1
  102. package/dist/shared/attaform.D13GMFgK.mjs +0 -32
  103. package/dist/shared/attaform.D13GMFgK.mjs.map +0 -1
  104. package/dist/shared/attaform.DUHru0OF.cjs +0 -1600
  105. package/dist/shared/attaform.DUHru0OF.cjs.map +0 -1
  106. package/dist/shared/attaform.Df0tU0Ut.mjs +0 -1594
  107. package/dist/shared/attaform.Df0tU0Ut.mjs.map +0 -1
  108. package/dist/shared/attaform.Dl161U6E.mjs +0 -57
  109. package/dist/shared/attaform.Dl161U6E.mjs.map +0 -1
  110. package/dist/shared/attaform.Dlk1jMuv.cjs.map +0 -1
  111. package/dist/shared/attaform.II89Pcf4.cjs.map +0 -1
@@ -1,59 +1,32 @@
1
- import { createCompoundExpression, NodeTypes, createSimpleExpression, ElementTypes, processExpression } from '@vue/compiler-core';
1
+ import { NodeTypes, createCompoundExpression, createSimpleExpression, ElementTypes, processExpression } from '@vue/compiler-core';
2
2
 
3
- function getSummarizedProps$1(node) {
3
+ function getSummarizedProps(node) {
4
4
  if (!("props" in node)) return [];
5
5
  const props = node.props;
6
6
  const summarizedProps = props.reduce((acc, currProp) => {
7
7
  if (currProp.type === NodeTypes.ATTRIBUTE) {
8
8
  const key2 = currProp.name;
9
9
  const value2 = currProp.value?.content ?? "";
10
- return [...acc, { key: key2, value: renderAsStatic$1(value2, true) }];
10
+ return [...acc, { key: key2, value: renderAsStatic(value2, true) }];
11
11
  }
12
12
  if (currProp.exp === void 0) return acc;
13
- const key = currProp.arg ? getSummarizedPropValue$1(currProp.arg) : renderAsStatic$1(currProp.name, true);
13
+ const key = currProp.arg ? getSummarizedPropValue(currProp.arg) : renderAsStatic(currProp.name, true);
14
14
  if (typeof key !== "string") return acc;
15
- const value = getSummarizedPropValue$1(currProp.exp);
15
+ const value = getSummarizedPropValue(currProp.exp);
16
16
  return [...acc, { key, value }];
17
17
  }, []);
18
18
  return summarizedProps;
19
19
  }
20
- function renderAsStatic$1(val, isStatic) {
20
+ function renderAsStatic(val, isStatic) {
21
21
  return isStatic ? `"${val}"` : val;
22
22
  }
23
- function getSummarizedPropValue$1(exp) {
23
+ function getSummarizedPropValue(exp) {
24
24
  if (exp.type === NodeTypes.SIMPLE_EXPRESSION) {
25
- return renderAsStatic$1(exp.content, exp.isStatic);
25
+ return renderAsStatic(exp.content, exp.isStatic);
26
26
  }
27
27
  return exp.children;
28
28
  }
29
- function generateEqualityExpression$1(registerValue, optionValue, scalarTarget) {
30
- const registerValueArr = Array.isArray(registerValue) ? registerValue : [registerValue];
31
- const optionValueArr = Array.isArray(optionValue) ? optionValue : [optionValue];
32
- const scalarTargetArr = Array.isArray(scalarTarget) ? scalarTarget : [scalarTarget];
33
- return [
34
- "Array.isArray((",
35
- ...registerValueArr,
36
- ")?.innerRef?.value) ? ",
37
- "(",
38
- ...registerValueArr,
39
- ")?.innerRef?.value?.includes(",
40
- ...optionValueArr,
41
- ") : ",
42
- "(",
43
- ...registerValueArr,
44
- ")?.innerRef?.value instanceof Set ? (",
45
- ...registerValueArr,
46
- ")?.innerRef?.value?.has(",
47
- ...optionValueArr,
48
- ") : ",
49
- "((",
50
- ...registerValueArr,
51
- ")?.innerRef?.value === (",
52
- ...scalarTargetArr,
53
- "))"
54
- ];
55
- }
56
- function removePropsByName$1(props, propNames) {
29
+ function removePropsByName(props, propNames) {
57
30
  const removePropIndices = [];
58
31
  for (let index = 0; index < props.length; index++) {
59
32
  const prop = props[index];
@@ -66,182 +39,62 @@ function removePropsByName$1(props, propNames) {
66
39
  props.splice(index, 1);
67
40
  }
68
41
  }
69
- function isExactKey$1(summarizedKey, name) {
42
+ function isExactKey(summarizedKey, name) {
70
43
  return summarizedKey === name || summarizedKey === `"${name}"`;
71
44
  }
72
- function isStaticTypeOneOf(value, names) {
73
- if (Array.isArray(value)) return false;
74
- const trimmed = value.trim();
75
- const literalMatch = /^(["'`])(.*)\1$/.exec(trimmed);
76
- if (literalMatch === null) return false;
77
- const inner = literalMatch[2].toLowerCase();
78
- return names.includes(inner);
79
- }
80
- function couldResolveToFileType(value) {
81
- if (Array.isArray(value)) return true;
82
- const trimmed = value.trim();
83
- const literalMatch = /^(["'`])(.*)\1$/.exec(trimmed);
84
- if (literalMatch === null) return true;
85
- const quote = literalMatch[1];
86
- const inner = literalMatch[2];
87
- if (quote === "`" && inner.includes("${")) return true;
88
- return inner.toLowerCase() === "file";
89
- }
90
- const inputTextAreaNodeTransform = (node) => {
91
- try {
92
- let computeProps = function(_node, registerSummarizedProp2, elementValueSummarizedProp2) {
93
- const injectedLoc = _node.loc;
94
- const props = _node.props;
95
- const isStaticCheckbox = typeProp !== void 0 && isStaticTypeOneOf(typeProp.value, ["checkbox"]);
96
- const isStaticRadio = typeProp !== void 0 && isStaticTypeOneOf(typeProp.value, ["radio"]);
97
- const keepStaticValue = isStaticCheckbox || isStaticRadio;
98
- removePropsByName$1(props, keepStaticValue ? ["checked"] : ["checked", "value"]);
99
- const registerValueArr = Array.isArray(registerSummarizedProp2.value) ? registerSummarizedProp2.value : [registerSummarizedProp2.value];
100
- const valueExpression = createCompoundExpression([
101
- "(",
102
- ...registerValueArr,
103
- ")?.displayValue?.value"
104
- ]);
105
- const trueValueIndex = elementProps.findIndex((p) => isExactKey$1(p.key, "true-value"));
106
- const trueValueProp = elementProps[trueValueIndex];
107
- const scalarTarget = isStaticCheckbox ? trueValueProp !== void 0 ? trueValueProp.value : "true" : elementValueSummarizedProp2.value;
108
- const valueOrCheckedProp = {
109
- // reconstruct the `value` attribute based on the provided v-registerer, now that the computation is complete
110
- arg: elementSelectionLabelExpression,
111
- exp: createCompoundExpression([
112
- "(",
113
- ...elementSelectionLabelExpression.children,
114
- ") === 'checked' ? (",
115
- // resolves to a boolean
116
- ...generateEqualityExpression$1(
117
- registerSummarizedProp2.value,
118
- elementValueSummarizedProp2.value,
119
- scalarTarget
120
- ),
121
- ") : (",
122
- // resolves to the provided register value
123
- ...valueExpression.children,
124
- ")"
125
- ]),
126
- name: "bind",
127
- modifiers: [],
128
- type: NodeTypes.DIRECTIVE,
129
- loc: injectedLoc
130
- };
131
- props.push(valueOrCheckedProp);
132
- };
133
- if (node.type !== NodeTypes.ELEMENT) return;
134
- const isInput = node.tag === "input";
135
- const isTextArea = node.tag === "textarea";
136
- if (!isInput && !isTextArea) return;
137
- const elementProps = getSummarizedProps$1(node);
138
- const registerIndex = elementProps.findIndex((p) => isExactKey$1(p.key, "register"));
139
- const registerSummarizedProp = elementProps[registerIndex];
140
- if (!registerSummarizedProp) return;
141
- const typeIndex = elementProps.findIndex((p) => isExactKey$1(p.key, "type"));
142
- const typeProp = elementProps[typeIndex];
143
- if (typeProp !== void 0 && couldResolveToFileType(typeProp.value)) return;
144
- const valueIndex = elementProps.findIndex((p) => isExactKey$1(p.key, "value"));
145
- const elementValueSummarizedProp = elementProps?.[valueIndex] ?? {
146
- key: "value",
147
- value: "''"
148
- };
149
- const inputTypeIndex = typeIndex;
150
- const defaultSummarizedTextProp = { key: "type", value: "'text'" };
151
- const inputTypeSummarizedProp = inputTypeIndex === -1 ? defaultSummarizedTextProp : elementProps[inputTypeIndex] ?? defaultSummarizedTextProp;
152
- const inputTypeExpressionArray = typeof inputTypeSummarizedProp.value === "string" ? [inputTypeSummarizedProp.value] : inputTypeSummarizedProp.value;
153
- const elementSelectionLabelExpression = createCompoundExpression([
154
- "(",
155
- "String((",
156
- ...inputTypeExpressionArray,
157
- ")).toLowerCase()",
158
- " === 'checkbox' || ",
159
- "String((",
160
- ...inputTypeExpressionArray,
161
- ")).toLowerCase() === 'radio'",
162
- ") ? 'checked' : 'value'"
163
- ]);
164
- computeProps(node, registerSummarizedProp, elementValueSummarizedProp);
165
- } catch (err) {
166
- console.error("[attaform] input/textarea transform failed, skipping:", err);
167
- }
168
- };
169
-
170
- function getSummarizedProps(node) {
171
- if (!("props" in node)) return [];
172
- const props = node.props;
173
- const summarizedProps = props.reduce((acc, currProp) => {
174
- if (currProp.type === NodeTypes.ATTRIBUTE) {
175
- const key2 = currProp.name;
176
- const value2 = currProp.value?.content ?? "";
177
- return [...acc, { key: key2, value: renderAsStatic(value2, true) }];
45
+ function flattenExpression(exp) {
46
+ if (exp.type === NodeTypes.SIMPLE_EXPRESSION) return exp.content;
47
+ let out = "";
48
+ for (const child of exp.children) {
49
+ if (typeof child === "string") {
50
+ out += child;
51
+ continue;
52
+ }
53
+ if (typeof child === "symbol") continue;
54
+ const node = child;
55
+ if (node.type === NodeTypes.SIMPLE_EXPRESSION) {
56
+ out += node.content;
57
+ continue;
58
+ }
59
+ if (node.type === NodeTypes.COMPOUND_EXPRESSION) {
60
+ out += flattenExpression(node);
178
61
  }
179
- if (currProp.exp === void 0) return acc;
180
- const key = currProp.arg ? getSummarizedPropValue(currProp.arg) : renderAsStatic(currProp.name, true);
181
- if (typeof key !== "string") return acc;
182
- const value = getSummarizedPropValue(currProp.exp);
183
- return [...acc, { key, value }];
184
- }, []);
185
- return summarizedProps;
186
- }
187
- function renderAsStatic(val, isStatic) {
188
- return isStatic ? `"${val}"` : val;
189
- }
190
- function getSummarizedPropValue(exp) {
191
- if (exp.type === NodeTypes.SIMPLE_EXPRESSION) {
192
- return renderAsStatic(exp.content, exp.isStatic);
193
62
  }
194
- return exp.children;
63
+ return out;
195
64
  }
196
- function generateEqualityExpression(selectValue, optionValue, previousOptionExpressions) {
197
- function getExpressionNodeChildren(_selectValue, _optionValue, _previousOptionExpressions) {
198
- const multipleExpression = _previousOptionExpressions?.[0];
199
- if (multipleExpression === void 0) {
200
- throw new Error(
201
- "Programming error: `multiple` expression for `select` node not generated while transforming AST"
202
- );
203
- }
204
- const optExpressions = _previousOptionExpressions.slice(1);
205
- const noMultipleOptExpressions = optExpressions.reduce(
206
- (acc, curr, index) => {
207
- if (index === 0) {
208
- acc.push("(");
209
- }
210
- acc.push(...curr);
211
- if (index < optExpressions.length - 1) {
212
- acc.push(" || ");
213
- }
214
- if (index === optExpressions.length - 1) {
215
- acc.push(")");
216
- }
217
- return acc;
218
- },
219
- []
65
+
66
+ function generateEqualityExpression$1(selectValue, optionValue, previousOptionExpressions) {
67
+ const multipleExpression = previousOptionExpressions?.[0];
68
+ if (multipleExpression === void 0) {
69
+ throw new Error(
70
+ "Programming error: `multiple` expression for `select` node not generated while transforming AST"
220
71
  );
221
- const selectValueArr = Array.isArray(_selectValue) ? _selectValue : [_selectValue];
222
- const optionValueArr = Array.isArray(_optionValue) ? _optionValue : [_optionValue];
223
- function getImplicitTrueMultipleExpression(expression) {
224
- if (expression.length === 1 && expression[0] === "") return [`true`];
225
- return expression;
226
- }
227
- _previousOptionExpressions.push(["(", ...selectValueArr, ") === (", ...optionValueArr, ")"]);
228
- if (!noMultipleOptExpressions.length) {
229
- return [
230
- "(",
231
- ...getImplicitTrueMultipleExpression(multipleExpression),
232
- `) ? ((`,
233
- ...selectValueArr,
234
- `)?.innerRef?.value?.findIndex?.(el => el === (`,
235
- ...optionValueArr,
236
- `)) > -1) : (typeof (`,
237
- ...selectValueArr,
238
- `)?.innerRef?.value !== 'object' && String((`,
239
- ...selectValueArr,
240
- `)?.innerRef?.value) === String((`,
241
- ...optionValueArr,
242
- `)))`
243
- ];
244
- }
72
+ }
73
+ const optExpressions = previousOptionExpressions.slice(1);
74
+ const noMultipleOptExpressions = optExpressions.reduce(
75
+ (acc, curr, index) => {
76
+ if (index === 0) {
77
+ acc.push("(");
78
+ }
79
+ acc.push(...curr);
80
+ if (index < optExpressions.length - 1) {
81
+ acc.push(" || ");
82
+ }
83
+ if (index === optExpressions.length - 1) {
84
+ acc.push(")");
85
+ }
86
+ return acc;
87
+ },
88
+ []
89
+ );
90
+ const selectValueArr = Array.isArray(selectValue) ? selectValue : [selectValue];
91
+ const optionValueArr = Array.isArray(optionValue) ? optionValue : [optionValue];
92
+ function getImplicitTrueMultipleExpression(expression) {
93
+ if (expression.length === 1 && expression[0] === "") return [`true`];
94
+ return expression;
95
+ }
96
+ previousOptionExpressions.push(["(", ...selectValueArr, ") === (", ...optionValueArr, ")"]);
97
+ if (!noMultipleOptExpressions.length) {
245
98
  return [
246
99
  "(",
247
100
  ...getImplicitTrueMultipleExpression(multipleExpression),
@@ -249,19 +102,33 @@ function generateEqualityExpression(selectValue, optionValue, previousOptionExpr
249
102
  ...selectValueArr,
250
103
  `)?.innerRef?.value?.findIndex?.(el => el === (`,
251
104
  ...optionValueArr,
252
- `)) > -1) : ((`,
253
- ...noMultipleOptExpressions,
254
- // if true, we already found the relevant option
255
- `) ? false : (typeof (`,
105
+ `)) > -1) : (typeof (`,
256
106
  ...selectValueArr,
257
107
  `)?.innerRef?.value !== 'object' && String((`,
258
108
  ...selectValueArr,
259
109
  `)?.innerRef?.value) === String((`,
260
110
  ...optionValueArr,
261
- `))))`
111
+ `)))`
262
112
  ];
263
113
  }
264
- return getExpressionNodeChildren(selectValue, optionValue, previousOptionExpressions);
114
+ return [
115
+ "(",
116
+ ...getImplicitTrueMultipleExpression(multipleExpression),
117
+ `) ? ((`,
118
+ ...selectValueArr,
119
+ `)?.innerRef?.value?.findIndex?.(el => el === (`,
120
+ ...optionValueArr,
121
+ `)) > -1) : ((`,
122
+ ...noMultipleOptExpressions,
123
+ // if true, we already found the relevant option
124
+ `) ? false : (typeof (`,
125
+ ...selectValueArr,
126
+ `)?.innerRef?.value !== 'object' && String((`,
127
+ ...selectValueArr,
128
+ `)?.innerRef?.value) === String((`,
129
+ ...optionValueArr,
130
+ `))))`
131
+ ];
265
132
  }
266
133
  function extractMultipleFromSelectSummarizedProps(props) {
267
134
  const multipleDirectiveIndex = props.findIndex(
@@ -275,37 +142,6 @@ function extractMultipleFromSelectSummarizedProps(props) {
275
142
  const value = props[priorityIndex]?.value;
276
143
  return typeof value === "string" ? value.replace(/'|"/g, "") : value ?? "true";
277
144
  }
278
- function removePropsByName(props, propNames) {
279
- const removePropIndices = [];
280
- for (let index = 0; index < props.length; index++) {
281
- const prop = props[index];
282
- if (!prop) continue;
283
- if (propNames.includes(prop.name) || "arg" in prop && prop.arg && "content" in prop.arg && propNames.includes(prop.arg.content)) {
284
- removePropIndices.push(index);
285
- }
286
- }
287
- for (const index of removePropIndices.sort((a, z) => z - a)) {
288
- props.splice(index, 1);
289
- }
290
- }
291
- function flattenCompoundExpression(node) {
292
- let result = "";
293
- for (const child of node.children) {
294
- if (typeof child === "string") {
295
- result += child;
296
- } else if (typeof child === "symbol") {
297
- continue;
298
- } else if (child.type === NodeTypes.SIMPLE_EXPRESSION) {
299
- result += child.content;
300
- } else if (child.type === NodeTypes.COMPOUND_EXPRESSION) {
301
- result += flattenCompoundExpression(child);
302
- }
303
- }
304
- return result;
305
- }
306
- function isExactKey(summarizedKey, name) {
307
- return summarizedKey === name || summarizedKey === `"${name}"`;
308
- }
309
145
  const RECURSABLE_NODE_TYPES = /* @__PURE__ */ new Set([
310
146
  NodeTypes.ELEMENT,
311
147
  NodeTypes.FOR,
@@ -333,7 +169,7 @@ function inferOptionValueFromChildren(node) {
333
169
  const text = only.content.trim();
334
170
  return JSON.stringify(text);
335
171
  }
336
- const selectNodeTransform = (node, context) => {
172
+ const componentBridgeTransform = (node, context) => {
337
173
  const snapshots = [];
338
174
  const snapshotProps = (target) => {
339
175
  if (snapshots.some((entry) => entry.target === target)) return;
@@ -371,7 +207,7 @@ const selectNodeTransform = (node, context) => {
371
207
  const newProp = {
372
208
  arg: createSimpleExpression("selected", true),
373
209
  exp: createCompoundExpression(
374
- generateEqualityExpression(
210
+ generateEqualityExpression$1(
375
211
  registerSummarizedProp?.value ?? "undefined",
376
212
  optionValueSummarizedProp?.value ?? "undefined",
377
213
  previousOptionExpressions2
@@ -407,16 +243,13 @@ const selectNodeTransform = (node, context) => {
407
243
  ...valuePropExpArray,
408
244
  ")?.displayValue.value"
409
245
  ]);
410
- const simpleExpression = createSimpleExpression(
411
- flattenCompoundExpression(initExpression),
412
- false
413
- );
246
+ const simpleExpression = createSimpleExpression(flattenExpression(initExpression), false);
414
247
  let outputExp;
415
248
  try {
416
249
  outputExp = processExpression(simpleExpression, { ...context, prefixIdentifiers: false });
417
250
  } catch (err) {
418
251
  console.error(
419
- "[attaform] select transform: processExpression failed; falling back to the unprocessed expression.",
252
+ "[attaform] component-bridge transform: processExpression failed; falling back to the unprocessed expression.",
420
253
  err
421
254
  );
422
255
  outputExp = simpleExpression;
@@ -460,7 +293,134 @@ const selectNodeTransform = (node, context) => {
460
293
  for (const { target, snapshot } of snapshots.slice().reverse()) {
461
294
  target.splice(0, target.length, ...snapshot);
462
295
  }
463
- console.error("[attaform] select transform failed, skipping:", err);
296
+ console.error("[attaform] component-bridge transform failed, skipping:", err);
297
+ }
298
+ };
299
+
300
+ function generateEqualityExpression(registerValue, optionValue, scalarTarget) {
301
+ const registerValueArr = Array.isArray(registerValue) ? registerValue : [registerValue];
302
+ const optionValueArr = Array.isArray(optionValue) ? optionValue : [optionValue];
303
+ const scalarTargetArr = Array.isArray(scalarTarget) ? scalarTarget : [scalarTarget];
304
+ return [
305
+ "Array.isArray((",
306
+ ...registerValueArr,
307
+ ")?.innerRef?.value) ? ",
308
+ "(",
309
+ ...registerValueArr,
310
+ ")?.innerRef?.value?.includes(",
311
+ ...optionValueArr,
312
+ ") : ",
313
+ "(",
314
+ ...registerValueArr,
315
+ ")?.innerRef?.value instanceof Set ? (",
316
+ ...registerValueArr,
317
+ ")?.innerRef?.value?.has(",
318
+ ...optionValueArr,
319
+ ") : ",
320
+ "(typeof (",
321
+ ...registerValueArr,
322
+ ")?.innerRef?.value !== 'object' && String((",
323
+ ...registerValueArr,
324
+ ")?.innerRef?.value) === String((",
325
+ ...scalarTargetArr,
326
+ ")))"
327
+ ];
328
+ }
329
+ function parseStaticStringLiteral(text) {
330
+ const literalMatch = /^(["'`])(.*)\1$/.exec(text.trim());
331
+ if (literalMatch === null) return null;
332
+ return { quote: literalMatch[1], inner: literalMatch[2] };
333
+ }
334
+ function isStaticTypeOneOf(value, names) {
335
+ if (Array.isArray(value)) return false;
336
+ const parsed = parseStaticStringLiteral(value);
337
+ if (parsed === null) return false;
338
+ return names.includes(parsed.inner.toLowerCase());
339
+ }
340
+ function couldResolveToFileType(value) {
341
+ if (Array.isArray(value)) return true;
342
+ const parsed = parseStaticStringLiteral(value);
343
+ if (parsed === null) return true;
344
+ if (parsed.quote === "`" && parsed.inner.includes("${")) return true;
345
+ return parsed.inner.toLowerCase() === "file";
346
+ }
347
+ const inputTextAreaNodeTransform = (node) => {
348
+ try {
349
+ let computeProps = function(_node, registerSummarizedProp2, elementValueSummarizedProp2) {
350
+ const injectedLoc = _node.loc;
351
+ const props = _node.props;
352
+ const isStaticCheckbox = typeProp !== void 0 && isStaticTypeOneOf(typeProp.value, ["checkbox"]);
353
+ const isStaticRadio = typeProp !== void 0 && isStaticTypeOneOf(typeProp.value, ["radio"]);
354
+ const keepStaticValue = isStaticCheckbox || isStaticRadio;
355
+ removePropsByName(props, keepStaticValue ? ["checked"] : ["checked", "value"]);
356
+ const registerValueArr = Array.isArray(registerSummarizedProp2.value) ? registerSummarizedProp2.value : [registerSummarizedProp2.value];
357
+ const valueExpression = createCompoundExpression([
358
+ "(",
359
+ ...registerValueArr,
360
+ ")?.displayValue?.value"
361
+ ]);
362
+ const trueValueIndex = elementProps.findIndex((p) => isExactKey(p.key, "true-value"));
363
+ const trueValueProp = elementProps[trueValueIndex];
364
+ const scalarTarget = isStaticCheckbox ? trueValueProp !== void 0 ? trueValueProp.value : "true" : elementValueSummarizedProp2.value;
365
+ const valueOrCheckedProp = {
366
+ // reconstruct the `value` attribute based on the provided v-registerer, now that the computation is complete
367
+ arg: elementSelectionLabelExpression,
368
+ exp: createCompoundExpression([
369
+ "(",
370
+ ...elementSelectionLabelExpression.children,
371
+ ") === 'checked' ? (",
372
+ // resolves to a boolean
373
+ ...generateEqualityExpression(
374
+ registerSummarizedProp2.value,
375
+ elementValueSummarizedProp2.value,
376
+ scalarTarget
377
+ ),
378
+ ") : (",
379
+ // resolves to the provided register value
380
+ ...valueExpression.children,
381
+ ")"
382
+ ]),
383
+ name: "bind",
384
+ modifiers: [],
385
+ type: NodeTypes.DIRECTIVE,
386
+ loc: injectedLoc
387
+ };
388
+ props.push(valueOrCheckedProp);
389
+ };
390
+ if (node.type !== NodeTypes.ELEMENT) return;
391
+ const isInput = node.tag === "input";
392
+ const isTextArea = node.tag === "textarea";
393
+ if (!isInput && !isTextArea) return;
394
+ const elementProps = getSummarizedProps(node);
395
+ const registerIndex = elementProps.findIndex((p) => isExactKey(p.key, "register"));
396
+ const registerSummarizedProp = elementProps[registerIndex];
397
+ if (!registerSummarizedProp) return;
398
+ const typeIndex = elementProps.findIndex((p) => isExactKey(p.key, "type"));
399
+ const typeProp = elementProps[typeIndex];
400
+ if (typeProp !== void 0 && couldResolveToFileType(typeProp.value)) return;
401
+ const valueIndex = elementProps.findIndex((p) => isExactKey(p.key, "value"));
402
+ const elementValueSummarizedProp = elementProps?.[valueIndex] ?? {
403
+ key: "value",
404
+ value: "''"
405
+ };
406
+ const inputTypeIndex = typeIndex;
407
+ const defaultSummarizedTextProp = { key: "type", value: "'text'" };
408
+ const inputTypeSummarizedProp = inputTypeIndex === -1 ? defaultSummarizedTextProp : elementProps[inputTypeIndex] ?? defaultSummarizedTextProp;
409
+ const inputTypeExpressionArray = typeof inputTypeSummarizedProp.value === "string" ? [inputTypeSummarizedProp.value] : inputTypeSummarizedProp.value;
410
+ const elementSelectionLabelExpression = createCompoundExpression([
411
+ "(",
412
+ "String((",
413
+ ...inputTypeExpressionArray,
414
+ ")).toLowerCase()",
415
+ " === 'checkbox' || ",
416
+ "String((",
417
+ ...inputTypeExpressionArray,
418
+ ")).toLowerCase() === 'radio'",
419
+ ") ? 'checked' : 'value'"
420
+ ]);
421
+ computeProps(node, registerSummarizedProp, elementValueSummarizedProp);
422
+ } catch (err) {
423
+ console.error("[attaform] input/textarea transform failed, skipping:", err);
464
424
  }
465
425
  };
466
426
 
@@ -559,23 +519,6 @@ function hasVForDirective(node) {
559
519
  }
560
520
  return false;
561
521
  }
562
- function flattenExpression(exp) {
563
- if (exp.type === NodeTypes.SIMPLE_EXPRESSION) return exp.content;
564
- let out = "";
565
- for (const child of exp.children) {
566
- if (typeof child === "string") {
567
- out += child;
568
- continue;
569
- }
570
- if (typeof child === "symbol") continue;
571
- if ("content" in child) {
572
- out += child.content;
573
- continue;
574
- }
575
- out += flattenExpression(child);
576
- }
577
- return out;
578
- }
579
522
  function injectPreamble(element, captured) {
580
523
  if (hasPreamble(element)) return;
581
524
  const callList = captured.map((source) => `(()=>{try{(${source})?.markConnectedOptimistically?.()}catch{}})()`).join(", ");
@@ -613,5 +556,5 @@ function hasPreamble(element) {
613
556
  return false;
614
557
  }
615
558
 
616
- export { vRegisterPreambleTransform as a, inputTextAreaNodeTransform as i, selectNodeTransform as s, vRegisterHintTransform as v };
617
- //# sourceMappingURL=attaform.CXpzmj38.mjs.map
559
+ export { vRegisterPreambleTransform as a, componentBridgeTransform as c, inputTextAreaNodeTransform as i, vRegisterHintTransform as v };
560
+ //# sourceMappingURL=attaform.BupwXkj_.mjs.map