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