attaform 0.19.0 → 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.
- package/dist/chunks/devtools.cjs +1 -1
- package/dist/chunks/devtools.mjs +1 -1
- package/dist/chunks/indexeddb.cjs +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +3 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -40
- package/dist/index.d.mts +14 -40
- package/dist/index.d.ts +14 -40
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +2 -2
- package/dist/runtime/components/DevtoolsValueTree.d.vue.ts +1 -3
- package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +1 -3
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.CrpjyXdO.mjs → attaform.BKozEdTr.mjs} +275 -266
- package/dist/shared/attaform.BKozEdTr.mjs.map +1 -0
- package/dist/shared/{attaform.Bubm_slq.cjs → attaform.BM6YD9kZ.cjs} +212 -269
- package/dist/shared/attaform.BM6YD9kZ.cjs.map +1 -0
- package/dist/shared/{attaform.CoxJ8Qm8.cjs → attaform.BPxsYtTe.cjs} +2 -26
- package/dist/shared/attaform.BPxsYtTe.cjs.map +1 -0
- package/dist/shared/{attaform.BqEfHpVB.cjs → attaform.BPy-4qRx.cjs} +275 -268
- package/dist/shared/attaform.BPy-4qRx.cjs.map +1 -0
- package/dist/shared/attaform.BWgAFnsj.mjs +770 -0
- package/dist/shared/attaform.BWgAFnsj.mjs.map +1 -0
- package/dist/shared/{attaform.BTpuvGec.d.ts → attaform.Bh3ACtts.d.ts} +109 -101
- package/dist/shared/{attaform.CXpzmj38.mjs → attaform.BupwXkj_.mjs} +213 -270
- package/dist/shared/attaform.BupwXkj_.mjs.map +1 -0
- package/dist/shared/{attaform.JBx8cfMA.cjs → attaform.CIn4bMsD.cjs} +263 -799
- package/dist/shared/attaform.CIn4bMsD.cjs.map +1 -0
- package/dist/shared/{attaform.BTi-PsHr.mjs → attaform.CKFbKFb6.mjs} +1818 -1472
- package/dist/shared/attaform.CKFbKFb6.mjs.map +1 -0
- package/dist/shared/{attaform.ePUcKxId.d.cts → attaform.D5-1XGQU.d.cts} +109 -101
- package/dist/shared/{attaform.a3uBo-gw.mjs → attaform.DEBvCjeH.mjs} +257 -793
- package/dist/shared/attaform.DEBvCjeH.mjs.map +1 -0
- package/dist/shared/{attaform.C1msmO2v.cjs → attaform.DL4CQ-oW.cjs} +1823 -1477
- package/dist/shared/attaform.DL4CQ-oW.cjs.map +1 -0
- package/dist/shared/{attaform.D4I63aBV.d.ts → attaform.DSD85fHb.d.cts} +1 -19
- package/dist/shared/{attaform.CBjmobqk.d.cts → attaform.DSD85fHb.d.mts} +1 -19
- package/dist/shared/{attaform.DXYHL99q.d.mts → attaform.DSD85fHb.d.ts} +1 -19
- package/dist/shared/{attaform.B7rzpK1U.d.cts → attaform.DkA5J8NW.d.cts} +1 -17
- package/dist/shared/{attaform.B7rzpK1U.d.mts → attaform.DkA5J8NW.d.mts} +1 -17
- package/dist/shared/{attaform.B7rzpK1U.d.ts → attaform.DkA5J8NW.d.ts} +1 -17
- package/dist/shared/{attaform.CJ-e9gYI.d.ts → attaform.Dl5kDY-A.d.ts} +1 -1
- package/dist/shared/attaform.Dmb6itxC.cjs +781 -0
- package/dist/shared/attaform.Dmb6itxC.cjs.map +1 -0
- package/dist/shared/{attaform.CRNA0vrd.d.mts → attaform.DoKXru-a.d.mts} +1 -1
- package/dist/shared/attaform.DvA-CJJW.mjs +1876 -0
- package/dist/shared/attaform.DvA-CJJW.mjs.map +1 -0
- package/dist/shared/{attaform.BtBmfLQN.d.mts → attaform.EMzJcQci.d.mts} +109 -101
- package/dist/shared/attaform.EZG6fOFb.mjs +35 -0
- package/dist/shared/attaform.EZG6fOFb.mjs.map +1 -0
- package/dist/shared/{attaform.QvygsFGh.d.cts → attaform.GbDo_lJi.d.cts} +1 -1
- package/dist/shared/{attaform.C0uGZQ4M.d.ts → attaform.SfhU0OEY.d.cts} +134 -30
- package/dist/shared/{attaform.C0uGZQ4M.d.cts → attaform.SfhU0OEY.d.mts} +134 -30
- package/dist/shared/{attaform.C0uGZQ4M.d.mts → attaform.SfhU0OEY.d.ts} +134 -30
- package/dist/shared/attaform.jgzuNZVC.cjs +1882 -0
- package/dist/shared/attaform.jgzuNZVC.cjs.map +1 -0
- package/dist/transforms.cjs +2 -2
- package/dist/transforms.d.cts +22 -13
- package/dist/transforms.d.mts +22 -13
- package/dist/transforms.d.ts +22 -13
- package/dist/transforms.mjs +1 -1
- package/dist/vite.cjs +8 -7
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +8 -7
- package/dist/vite.mjs.map +1 -1
- package/dist/zod-v3.cjs +3 -3
- package/dist/zod-v3.d.cts +32 -6
- package/dist/zod-v3.d.mts +32 -6
- package/dist/zod-v3.d.ts +32 -6
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +3 -3
- package/dist/zod-v4.d.cts +12 -8
- package/dist/zod-v4.d.mts +12 -8
- package/dist/zod-v4.d.ts +12 -8
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +8 -8
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +6 -6
- package/dist/zod.d.mts +6 -6
- package/dist/zod.d.ts +6 -6
- package/dist/zod.mjs +6 -6
- package/package.json +1 -1
- package/dist/shared/attaform.BTi-PsHr.mjs.map +0 -1
- package/dist/shared/attaform.BqEfHpVB.cjs.map +0 -1
- package/dist/shared/attaform.Bubm_slq.cjs.map +0 -1
- package/dist/shared/attaform.C1msmO2v.cjs.map +0 -1
- package/dist/shared/attaform.C8CyvYa_.cjs +0 -36
- package/dist/shared/attaform.C8CyvYa_.cjs.map +0 -1
- package/dist/shared/attaform.CXpzmj38.mjs.map +0 -1
- package/dist/shared/attaform.Cghpuav8.mjs +0 -57
- package/dist/shared/attaform.Cghpuav8.mjs.map +0 -1
- package/dist/shared/attaform.CiMqJHDm.mjs +0 -1594
- package/dist/shared/attaform.CiMqJHDm.mjs.map +0 -1
- package/dist/shared/attaform.CoxJ8Qm8.cjs.map +0 -1
- package/dist/shared/attaform.CrpjyXdO.mjs.map +0 -1
- package/dist/shared/attaform.D13GMFgK.mjs +0 -32
- package/dist/shared/attaform.D13GMFgK.mjs.map +0 -1
- package/dist/shared/attaform.JBx8cfMA.cjs.map +0 -1
- package/dist/shared/attaform.OznWyOPy.cjs +0 -1600
- package/dist/shared/attaform.OznWyOPy.cjs.map +0 -1
- package/dist/shared/attaform.a3uBo-gw.mjs.map +0 -1
|
@@ -1,59 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NodeTypes, createCompoundExpression, createSimpleExpression, ElementTypes, processExpression } from '@vue/compiler-core';
|
|
2
2
|
|
|
3
|
-
function getSummarizedProps
|
|
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
|
|
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
|
|
13
|
+
const key = currProp.arg ? getSummarizedPropValue(currProp.arg) : renderAsStatic(currProp.name, true);
|
|
14
14
|
if (typeof key !== "string") return acc;
|
|
15
|
-
const value = getSummarizedPropValue
|
|
15
|
+
const value = getSummarizedPropValue(currProp.exp);
|
|
16
16
|
return [...acc, { key, value }];
|
|
17
17
|
}, []);
|
|
18
18
|
return summarizedProps;
|
|
19
19
|
}
|
|
20
|
-
function renderAsStatic
|
|
20
|
+
function renderAsStatic(val, isStatic) {
|
|
21
21
|
return isStatic ? `"${val}"` : val;
|
|
22
22
|
}
|
|
23
|
-
function getSummarizedPropValue
|
|
23
|
+
function getSummarizedPropValue(exp) {
|
|
24
24
|
if (exp.type === NodeTypes.SIMPLE_EXPRESSION) {
|
|
25
|
-
return renderAsStatic
|
|
25
|
+
return renderAsStatic(exp.content, exp.isStatic);
|
|
26
26
|
}
|
|
27
27
|
return exp.children;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
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
|
|
42
|
+
function isExactKey(summarizedKey, name) {
|
|
70
43
|
return summarizedKey === name || summarizedKey === `"${name}"`;
|
|
71
44
|
}
|
|
72
|
-
function
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
|
63
|
+
return out;
|
|
195
64
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
|
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
|
|
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]
|
|
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]
|
|
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,
|
|
617
|
-
//# sourceMappingURL=attaform.
|
|
559
|
+
export { vRegisterPreambleTransform as a, componentBridgeTransform as c, inputTextAreaNodeTransform as i, vRegisterHintTransform as v };
|
|
560
|
+
//# sourceMappingURL=attaform.BupwXkj_.mjs.map
|