nexa-compiler 0.1.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/codegen/render.d.ts +21 -0
- package/dist/codegen/render.d.ts.map +1 -0
- package/dist/codegen/render.js +209 -0
- package/dist/codegen/render.js.map +1 -0
- package/dist/codegen/sourcemap.d.ts +2 -0
- package/dist/codegen/sourcemap.d.ts.map +1 -0
- package/dist/codegen/sourcemap.js +62 -0
- package/dist/codegen/sourcemap.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/parse/index.d.ts +5 -0
- package/dist/parse/index.d.ts.map +1 -0
- package/dist/parse/index.js +3 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/sfc.d.ts +24 -0
- package/dist/parse/sfc.d.ts.map +1 -0
- package/dist/parse/sfc.js +32 -0
- package/dist/parse/sfc.js.map +1 -0
- package/dist/parse/template.d.ts +49 -0
- package/dist/parse/template.d.ts.map +1 -0
- package/dist/parse/template.js +123 -0
- package/dist/parse/template.js.map +1 -0
- package/dist/transform/index.d.ts +4 -0
- package/dist/transform/index.d.ts.map +1 -0
- package/dist/transform/index.js +3 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/transform/style.d.ts +6 -0
- package/dist/transform/style.d.ts.map +1 -0
- package/dist/transform/style.js +33 -0
- package/dist/transform/style.js.map +1 -0
- package/dist/transform/template.d.ts +42 -0
- package/dist/transform/template.d.ts.map +1 -0
- package/dist/transform/template.js +98 -0
- package/dist/transform/template.js.map +1 -0
- package/package.json +25 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type GenerateOptions = {
|
|
2
|
+
filename?: string;
|
|
3
|
+
sourceMap?: boolean;
|
|
4
|
+
source?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function generateComponentCode(sfc: {
|
|
7
|
+
template: string | null;
|
|
8
|
+
script: string | null;
|
|
9
|
+
style: string | null;
|
|
10
|
+
scoped: boolean;
|
|
11
|
+
}): string;
|
|
12
|
+
export declare function generateComponentCodeWithSourceMap(sfc: {
|
|
13
|
+
template: string | null;
|
|
14
|
+
script: string | null;
|
|
15
|
+
style: string | null;
|
|
16
|
+
scoped: boolean;
|
|
17
|
+
}, options?: GenerateOptions): {
|
|
18
|
+
code: string;
|
|
19
|
+
map: string | null;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/codegen/render.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE;IACzC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,EAAE,OAAO,CAAA;CAChB,GAAG,MAAM,CAiFT;AAED,wBAAgB,kCAAkC,CAChD,GAAG,EAAE;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,EAAE,OAAO,CAAA;CAChB,EACD,OAAO,GAAE,eAAoB,GAC5B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAgBtC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { parseTemplate } from '../parse/template.js';
|
|
2
|
+
import { transformTemplate } from '../transform/template.js';
|
|
3
|
+
import { transformStyle } from '../transform/style.js';
|
|
4
|
+
import { generateSourceMap } from './sourcemap.js';
|
|
5
|
+
export function generateComponentCode(sfc) {
|
|
6
|
+
const lines = [];
|
|
7
|
+
const scriptContent = sfc.script || '';
|
|
8
|
+
const importLines = [];
|
|
9
|
+
const setupLines = [];
|
|
10
|
+
for (const line of scriptContent.split('\n')) {
|
|
11
|
+
if (line.trim().startsWith('import ')) {
|
|
12
|
+
importLines.push(line);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
setupLines.push(line);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
for (const imp of importLines) {
|
|
19
|
+
lines.push(imp);
|
|
20
|
+
}
|
|
21
|
+
if (!importLines.some(l => l.includes('from \'nexa\'') || l.includes('from "nexa"'))) {
|
|
22
|
+
lines.push('import { h, hText, effect } from \'nexa\'');
|
|
23
|
+
}
|
|
24
|
+
const { scopeId, styleCode } = transformStyle(sfc.style, sfc.scoped, sfc.template);
|
|
25
|
+
const fullScript = setupLines.join('\n');
|
|
26
|
+
const propsDef = parseDefineProps(fullScript);
|
|
27
|
+
const emitsDef = parseDefineEmits(fullScript);
|
|
28
|
+
const cleanSetup = stripMacroLines(fullScript);
|
|
29
|
+
const bindings = extractBindings(cleanSetup);
|
|
30
|
+
lines.push('');
|
|
31
|
+
lines.push('export default defineComponent({');
|
|
32
|
+
if (scopeId) {
|
|
33
|
+
lines.push(` __scopeId: '${scopeId}',`);
|
|
34
|
+
}
|
|
35
|
+
if (propsDef) {
|
|
36
|
+
lines.push(' props: {');
|
|
37
|
+
for (const [key, val] of Object.entries(propsDef)) {
|
|
38
|
+
lines.push(` ${key}: ${val},`);
|
|
39
|
+
}
|
|
40
|
+
lines.push(' },');
|
|
41
|
+
}
|
|
42
|
+
if (emitsDef) {
|
|
43
|
+
lines.push(` emits: [${emitsDef.map(e => `'${e}'`).join(', ')}],`);
|
|
44
|
+
}
|
|
45
|
+
const returnStmt = bindings.join(', ');
|
|
46
|
+
lines.push(' setup(props, { emit, slots }) {');
|
|
47
|
+
for (const line of cleanSetup.split('\n')) {
|
|
48
|
+
const trimmed = line.trim();
|
|
49
|
+
if (trimmed && !trimmed.startsWith('import ')) {
|
|
50
|
+
lines.push(` ${line}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (returnStmt) {
|
|
54
|
+
lines.push(` return { ${returnStmt} }`);
|
|
55
|
+
}
|
|
56
|
+
lines.push(' },');
|
|
57
|
+
if (sfc.template) {
|
|
58
|
+
lines.push(' render(ctx) {');
|
|
59
|
+
if (bindings.length > 0) {
|
|
60
|
+
lines.push(` const { ${bindings.join(', ')} } = ctx`);
|
|
61
|
+
}
|
|
62
|
+
lines.push(generateRenderCode(sfc.template));
|
|
63
|
+
lines.push(' },');
|
|
64
|
+
}
|
|
65
|
+
lines.push('})');
|
|
66
|
+
if (styleCode) {
|
|
67
|
+
lines.push('');
|
|
68
|
+
lines.push(`const __style = \`${styleCode}\``);
|
|
69
|
+
}
|
|
70
|
+
return lines.join('\n');
|
|
71
|
+
}
|
|
72
|
+
export function generateComponentCodeWithSourceMap(sfc, options = {}) {
|
|
73
|
+
const code = generateComponentCode(sfc);
|
|
74
|
+
if (!options.sourceMap || !options.filename || !options.source) {
|
|
75
|
+
return { code, map: null };
|
|
76
|
+
}
|
|
77
|
+
const scriptLines = (options.source.split('\n<script')[0].match(/\n/g) || []).length + 2;
|
|
78
|
+
const map = generateSourceMap(options.filename, code, options.source, scriptLines);
|
|
79
|
+
return { code, map };
|
|
80
|
+
}
|
|
81
|
+
function generateRenderCode(template) {
|
|
82
|
+
const ast = parseTemplate(template);
|
|
83
|
+
const transformed = transformTemplate(ast);
|
|
84
|
+
const children = transformed.children;
|
|
85
|
+
if (children.length === 0) {
|
|
86
|
+
return ' return null';
|
|
87
|
+
}
|
|
88
|
+
if (children.length === 1) {
|
|
89
|
+
return ' return ' + genNode(children[0]);
|
|
90
|
+
}
|
|
91
|
+
const items = children.map(child => genNode(child)).join(',\n ');
|
|
92
|
+
return ` return h('div', null, [\n ${items}\n ])`;
|
|
93
|
+
}
|
|
94
|
+
function genNode(node) {
|
|
95
|
+
switch (node.type) {
|
|
96
|
+
case 'text':
|
|
97
|
+
return JSON.stringify(node.content);
|
|
98
|
+
case 'expression':
|
|
99
|
+
return node.content;
|
|
100
|
+
case 'element':
|
|
101
|
+
return genElement(node);
|
|
102
|
+
case 'slot':
|
|
103
|
+
return genSlot(node);
|
|
104
|
+
case 'comment':
|
|
105
|
+
return 'null';
|
|
106
|
+
default:
|
|
107
|
+
return 'null';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function genElement(node) {
|
|
111
|
+
const { tag, props, children } = node;
|
|
112
|
+
const childStr = genChildren(children);
|
|
113
|
+
const elementCode = buildElementCode(tag, props, childStr);
|
|
114
|
+
if (node.vFor) {
|
|
115
|
+
const { item, index, list } = node.vFor;
|
|
116
|
+
return `${list}.map((${item}, ${index}) =>\n ${elementCode}\n )`;
|
|
117
|
+
}
|
|
118
|
+
if (node.vIf) {
|
|
119
|
+
return `${node.vIf} ? ${elementCode} : null`;
|
|
120
|
+
}
|
|
121
|
+
return elementCode;
|
|
122
|
+
}
|
|
123
|
+
function buildElementCode(tag, propStr, childStr) {
|
|
124
|
+
if (propStr && childStr) {
|
|
125
|
+
return `h('${tag}', { ${propStr} }, [\n ${childStr}\n ])`;
|
|
126
|
+
}
|
|
127
|
+
if (propStr) {
|
|
128
|
+
return `h('${tag}', { ${propStr} })`;
|
|
129
|
+
}
|
|
130
|
+
if (childStr) {
|
|
131
|
+
return `h('${tag}', null, [\n ${childStr}\n ])`;
|
|
132
|
+
}
|
|
133
|
+
return `h('${tag}')`;
|
|
134
|
+
}
|
|
135
|
+
function genChildren(children) {
|
|
136
|
+
if (!children || children.length === 0)
|
|
137
|
+
return '';
|
|
138
|
+
return children.map(child => genNode(child)).join(',\n ');
|
|
139
|
+
}
|
|
140
|
+
function genSlot(node) {
|
|
141
|
+
const propsCall = node.slotProps ? `{ ${node.slotProps} }` : '';
|
|
142
|
+
const args = node.slotProps ? `(${propsCall})` : '()';
|
|
143
|
+
if (node.name === 'default') {
|
|
144
|
+
return `ctx.$slots.default ? ctx.$slots.default${args} : null`;
|
|
145
|
+
}
|
|
146
|
+
return `ctx.$slots.${node.name} ? ctx.$slots.${node.name}${args} : null`;
|
|
147
|
+
}
|
|
148
|
+
const typeMap = {
|
|
149
|
+
string: 'String',
|
|
150
|
+
number: 'Number',
|
|
151
|
+
boolean: 'Boolean',
|
|
152
|
+
array: 'Array',
|
|
153
|
+
object: 'Object',
|
|
154
|
+
date: 'Date',
|
|
155
|
+
function: 'Function',
|
|
156
|
+
symbol: 'Symbol',
|
|
157
|
+
};
|
|
158
|
+
function parseDefineProps(script) {
|
|
159
|
+
const match = script.match(/defineProps\s*<\s*\{\s*([^}]+)\s*\}\s*>\s*\(\)/);
|
|
160
|
+
if (!match)
|
|
161
|
+
return null;
|
|
162
|
+
const props = {};
|
|
163
|
+
const pairs = match[1].split(';');
|
|
164
|
+
for (const pair of pairs) {
|
|
165
|
+
const trimmed = pair.trim();
|
|
166
|
+
if (!trimmed)
|
|
167
|
+
continue;
|
|
168
|
+
const [key, type] = trimmed.split(':').map(s => s.trim());
|
|
169
|
+
if (key && type) {
|
|
170
|
+
props[key] = typeMap[type.toLowerCase()] || 'null';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return Object.keys(props).length > 0 ? props : null;
|
|
174
|
+
}
|
|
175
|
+
function parseDefineEmits(script) {
|
|
176
|
+
const match = script.match(/defineEmits\s*<\s*\{\s*([^}]+)\s*\}\s*>\s*\(\)/);
|
|
177
|
+
if (!match)
|
|
178
|
+
return null;
|
|
179
|
+
const emits = [];
|
|
180
|
+
const pairs = match[1].split(';');
|
|
181
|
+
for (const pair of pairs) {
|
|
182
|
+
const trimmed = pair.trim();
|
|
183
|
+
if (!trimmed)
|
|
184
|
+
continue;
|
|
185
|
+
const [key] = trimmed.split(':').map(s => s.trim());
|
|
186
|
+
if (key)
|
|
187
|
+
emits.push(key);
|
|
188
|
+
}
|
|
189
|
+
return emits.length > 0 ? emits : null;
|
|
190
|
+
}
|
|
191
|
+
function stripMacroLines(script) {
|
|
192
|
+
return script
|
|
193
|
+
.split('\n')
|
|
194
|
+
.filter(line => !line.trim().startsWith('const props = defineProps') && !line.trim().startsWith('const emit = defineEmits'))
|
|
195
|
+
.join('\n');
|
|
196
|
+
}
|
|
197
|
+
function extractBindings(script) {
|
|
198
|
+
const bindings = [];
|
|
199
|
+
const declRegex = /(?:const|let|var)\s+(\w+)\s*=/g;
|
|
200
|
+
let match;
|
|
201
|
+
while ((match = declRegex.exec(script)) !== null) {
|
|
202
|
+
const name = match[1];
|
|
203
|
+
if (name !== 'props' && name !== 'emit') {
|
|
204
|
+
bindings.push(name);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return bindings;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/codegen/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAwB,MAAM,0BAA0B,CAAA;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAQlD,MAAM,UAAU,qBAAqB,CAAC,GAKrC;IACC,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAA;IACtC,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,MAAM,UAAU,GAAa,EAAE,CAAA;IAE/B,KAAK,MAAM,IAAI,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAA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AAC,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACrB,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACxC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourcemap.d.ts","sourceRoot":"","sources":["../../src/codegen/sourcemap.ts"],"names":[],"mappings":"AA8DA,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,MAAM,CAaR"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const VLQ_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
2
|
+
function encodeVLQ(value) {
|
|
3
|
+
let result = '';
|
|
4
|
+
let abs = Math.abs(value);
|
|
5
|
+
const sign = value < 0 ? 1 : 0;
|
|
6
|
+
let needsMore = true;
|
|
7
|
+
while (needsMore) {
|
|
8
|
+
let digit = abs & 0x1f;
|
|
9
|
+
abs >>= 5;
|
|
10
|
+
needsMore = abs > 0;
|
|
11
|
+
if (result.length === 0) {
|
|
12
|
+
digit = (digit << 1) | sign;
|
|
13
|
+
}
|
|
14
|
+
if (needsMore)
|
|
15
|
+
digit |= 0x20;
|
|
16
|
+
result += VLQ_CHARS[digit];
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
function encodeMappings(generatedLines, scriptLines, _templateLineStart) {
|
|
21
|
+
let result = '';
|
|
22
|
+
let lastGenCol = 0;
|
|
23
|
+
let lastSrcIdx = 0;
|
|
24
|
+
let lastSrcLine = 0;
|
|
25
|
+
let lastSrcCol = 0;
|
|
26
|
+
for (let genLine = 0; genLine < generatedLines; genLine++) {
|
|
27
|
+
if (genLine > 0)
|
|
28
|
+
result += ';';
|
|
29
|
+
if (genLine < scriptLines) {
|
|
30
|
+
const srcLine = genLine;
|
|
31
|
+
const genCol = 0;
|
|
32
|
+
const srcCol = 0;
|
|
33
|
+
const srcIdx = 0;
|
|
34
|
+
const dGenCol = genCol - lastGenCol;
|
|
35
|
+
const dSrcIdx = srcIdx - lastSrcIdx;
|
|
36
|
+
const dSrcLine = srcLine - lastSrcLine;
|
|
37
|
+
const dSrcCol = srcCol - lastSrcCol;
|
|
38
|
+
result += encodeVLQ(dGenCol);
|
|
39
|
+
result += encodeVLQ(dSrcIdx);
|
|
40
|
+
result += encodeVLQ(dSrcLine);
|
|
41
|
+
result += encodeVLQ(dSrcCol);
|
|
42
|
+
lastGenCol = genCol;
|
|
43
|
+
lastSrcIdx = srcIdx;
|
|
44
|
+
lastSrcLine = srcLine;
|
|
45
|
+
lastSrcCol = srcCol;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
export function generateSourceMap(filename, code, source, scriptLineCount) {
|
|
51
|
+
const generatedLines = code.split('\n').length;
|
|
52
|
+
const map = {
|
|
53
|
+
version: 3,
|
|
54
|
+
file: filename.replace(/\.nexa$/, '.js'),
|
|
55
|
+
sources: [filename],
|
|
56
|
+
sourcesContent: [source],
|
|
57
|
+
names: [],
|
|
58
|
+
mappings: encodeMappings(generatedLines, scriptLineCount, 0),
|
|
59
|
+
};
|
|
60
|
+
return JSON.stringify(map);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=sourcemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourcemap.js","sourceRoot":"","sources":["../../src/codegen/sourcemap.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,kEAA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
|
+
export type { SFCDescriptor, TemplateAST } from './parse/index.js';
|
|
3
|
+
export { transformTemplate, transformStyle } from './transform/index.js';
|
|
4
|
+
export { generateComponentCode, generateComponentCodeWithSourceMap } from './codegen/render.js';
|
|
5
|
+
export type { GenerateOptions } from './codegen/render.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC1D,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAE,qBAAqB,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAA;AAC/F,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAE1D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAE,qBAAqB,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { parseSFC } from './sfc.js';
|
|
2
|
+
export { parseTemplate } from './template.js';
|
|
3
|
+
export type { SFCDescriptor, SFCTemplateBlock, SFCScriptBlock, SFCStyleBlock } from './sfc.js';
|
|
4
|
+
export type { TemplateAST, TemplateNode, ElementNode, TextNode, ExpressionNode } from './template.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC9F,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type SFCDescriptor = {
|
|
2
|
+
template: SFCTemplateBlock | null;
|
|
3
|
+
script: SFCScriptBlock | null;
|
|
4
|
+
styles: SFCStyleBlock[];
|
|
5
|
+
};
|
|
6
|
+
export type SFCTemplateBlock = {
|
|
7
|
+
content: string;
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
};
|
|
11
|
+
export type SFCScriptBlock = {
|
|
12
|
+
content: string;
|
|
13
|
+
setup: boolean;
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
};
|
|
17
|
+
export type SFCStyleBlock = {
|
|
18
|
+
content: string;
|
|
19
|
+
scoped: boolean;
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
};
|
|
23
|
+
export declare function parseSFC(source: string): SFCDescriptor;
|
|
24
|
+
//# sourceMappingURL=sfc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sfc.d.ts","sourceRoot":"","sources":["../../src/parse/sfc.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAA;IACjC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAA;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAkCtD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function parseSFC(source) {
|
|
2
|
+
const descriptor = {
|
|
3
|
+
template: null,
|
|
4
|
+
script: null,
|
|
5
|
+
styles: [],
|
|
6
|
+
};
|
|
7
|
+
const sectionRegex = /<(\w+)([^>]*)>([\s\S]*?)<\/\1>/g;
|
|
8
|
+
let match;
|
|
9
|
+
while ((match = sectionRegex.exec(source)) !== null) {
|
|
10
|
+
const [, tag, attrsString, content] = match;
|
|
11
|
+
const start = match.index;
|
|
12
|
+
const end = start + match[0].length;
|
|
13
|
+
switch (tag) {
|
|
14
|
+
case 'template': {
|
|
15
|
+
descriptor.template = { content: content.trim(), start, end };
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case 'script': {
|
|
19
|
+
const setup = /\bsetup\b/.test(attrsString);
|
|
20
|
+
descriptor.script = { content, setup, start, end };
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case 'style': {
|
|
24
|
+
const scoped = /\bscoped\b/.test(attrsString);
|
|
25
|
+
descriptor.styles.push({ content, scoped, start, end });
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return descriptor;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=sfc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sfc.js","sourceRoot":"","sources":["../../src/parse/sfc.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,MAAM,UAAU,GAAkB;QAChC,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,EAAE;KACX,CAAA;IAED,MAAM,YAAY,GAAG,iCAAiC,CAAA;IACtD,IAAI,KAA6B,CAAA;IAEjC,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACpD,MAAM,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,KAAK,CAAA;QAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QACzB,MAAM,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QAEnC,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,UAAU,CAAC,CAAC,CAAC;gBAChB,UAAU,CAAC,QAAQ,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;gBAC7D,MAAK;YACP,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;gBAC3C,UAAU,CAAC,MAAM,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;gBAClD,MAAK;YACP,CAAC;YACD,KAAK,OAAO,CAAC,CAAC,CAAC;gBACb,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;gBAC7C,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;gBACvD,MAAK;YACP,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type TemplateAST = {
|
|
2
|
+
type: 'root';
|
|
3
|
+
children: TemplateNode[];
|
|
4
|
+
};
|
|
5
|
+
export type TemplateNode = ElementNode | TextNode | ExpressionNode | CommentNode | SlotNode | IfNode | ForNode;
|
|
6
|
+
export type ElementNode = {
|
|
7
|
+
type: 'element';
|
|
8
|
+
tag: string;
|
|
9
|
+
attrs: Attr[];
|
|
10
|
+
children: TemplateNode[];
|
|
11
|
+
isSelfClosing: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type Attr = {
|
|
14
|
+
name: string;
|
|
15
|
+
value: string | true;
|
|
16
|
+
dynamic: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type TextNode = {
|
|
19
|
+
type: 'text';
|
|
20
|
+
content: string;
|
|
21
|
+
};
|
|
22
|
+
export type ExpressionNode = {
|
|
23
|
+
type: 'expression';
|
|
24
|
+
content: string;
|
|
25
|
+
};
|
|
26
|
+
export type CommentNode = {
|
|
27
|
+
type: 'comment';
|
|
28
|
+
content: string;
|
|
29
|
+
};
|
|
30
|
+
export type SlotNode = {
|
|
31
|
+
type: 'slot';
|
|
32
|
+
name: string;
|
|
33
|
+
attrs: Attr[];
|
|
34
|
+
};
|
|
35
|
+
export type IfNode = {
|
|
36
|
+
type: 'if';
|
|
37
|
+
condition: string;
|
|
38
|
+
then: TemplateNode[];
|
|
39
|
+
else_: TemplateNode[] | null;
|
|
40
|
+
};
|
|
41
|
+
export type ForNode = {
|
|
42
|
+
type: 'for';
|
|
43
|
+
item: string;
|
|
44
|
+
index: string;
|
|
45
|
+
list: string;
|
|
46
|
+
children: TemplateNode[];
|
|
47
|
+
};
|
|
48
|
+
export declare function parseTemplate(template: string): TemplateAST;
|
|
49
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/parse/template.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,YAAY,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,QAAQ,GACR,cAAc,GACd,WAAW,GACX,QAAQ,GACR,MAAM,GACN,OAAO,CAAA;AAEX,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,SAAS,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,QAAQ,EAAE,YAAY,EAAE,CAAA;IACxB,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,YAAY,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,IAAI,EAAE,CAAA;CACd,CAAA;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,IAAI,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,YAAY,EAAE,CAAA;IACpB,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,YAAY,EAAE,CAAA;CACzB,CAAA;AAMD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAuE3D"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const tagRegex = /<(\/?)(\w[\w-]*)((?:\s+(?:[^>"']+|"[^"]*"|'[^']*')*)?)(\s*\/?\s*)>/g;
|
|
2
|
+
const attrRegex = /([@:]?\w[\w-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g;
|
|
3
|
+
const mustacheRegex = /\{\{(.*?)\}\}/g;
|
|
4
|
+
export function parseTemplate(template) {
|
|
5
|
+
const root = { type: 'root', children: [] };
|
|
6
|
+
const stack = [root.children];
|
|
7
|
+
let lastIndex = 0;
|
|
8
|
+
let match;
|
|
9
|
+
tagRegex.lastIndex = 0;
|
|
10
|
+
while ((match = tagRegex.exec(template)) !== null) {
|
|
11
|
+
const [, isClose, tag, attrsStr, selfClose] = match;
|
|
12
|
+
const matchStart = match.index;
|
|
13
|
+
// Process text between tags
|
|
14
|
+
if (matchStart > lastIndex) {
|
|
15
|
+
const text = template.slice(lastIndex, matchStart);
|
|
16
|
+
const nodes = parseText(text);
|
|
17
|
+
for (const node of nodes) {
|
|
18
|
+
stack[stack.length - 1].push(node);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (isClose) {
|
|
22
|
+
// Closing tag
|
|
23
|
+
if (stack.length > 1) {
|
|
24
|
+
stack.pop();
|
|
25
|
+
}
|
|
26
|
+
lastIndex = tagRegex.lastIndex;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const attrs = parseAttrs(attrsStr.trim());
|
|
30
|
+
const isSelfClosing = selfClose.trim() === '/' || isVoidElement(tag);
|
|
31
|
+
const node = {
|
|
32
|
+
type: 'element',
|
|
33
|
+
tag,
|
|
34
|
+
attrs,
|
|
35
|
+
children: [],
|
|
36
|
+
isSelfClosing: isSelfClosing || hasChildren(attrs),
|
|
37
|
+
};
|
|
38
|
+
const isSlot = tag === 'slot';
|
|
39
|
+
if (isSlot) {
|
|
40
|
+
const slotNode = {
|
|
41
|
+
type: 'slot',
|
|
42
|
+
name: attrs.find(a => a.name === 'name')?.value || 'default',
|
|
43
|
+
attrs,
|
|
44
|
+
};
|
|
45
|
+
stack[stack.length - 1].push(slotNode);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
stack[stack.length - 1].push(node);
|
|
49
|
+
}
|
|
50
|
+
if (!isSelfClosing) {
|
|
51
|
+
stack.push(node.children);
|
|
52
|
+
}
|
|
53
|
+
lastIndex = tagRegex.lastIndex;
|
|
54
|
+
}
|
|
55
|
+
// Process remaining text
|
|
56
|
+
if (lastIndex < template.length) {
|
|
57
|
+
const text = template.slice(lastIndex);
|
|
58
|
+
const nodes = parseText(text);
|
|
59
|
+
for (const node of nodes) {
|
|
60
|
+
stack[stack.length - 1].push(node);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return root;
|
|
64
|
+
}
|
|
65
|
+
function parseAttrs(attrsStr) {
|
|
66
|
+
if (!attrsStr)
|
|
67
|
+
return [];
|
|
68
|
+
const attrs = [];
|
|
69
|
+
attrRegex.lastIndex = 0;
|
|
70
|
+
let match;
|
|
71
|
+
while ((match = attrRegex.exec(attrsStr)) !== null) {
|
|
72
|
+
let rawName = match[1];
|
|
73
|
+
const quotedValue = match[2] ?? match[3] ?? match[4];
|
|
74
|
+
const isDynamic = rawName.startsWith(':') || rawName.startsWith('@');
|
|
75
|
+
let name;
|
|
76
|
+
if (rawName.startsWith(':')) {
|
|
77
|
+
name = rawName.slice(1);
|
|
78
|
+
}
|
|
79
|
+
else if (rawName.startsWith('@')) {
|
|
80
|
+
name = `on${rawName.slice(1, 2).toUpperCase()}${rawName.slice(2)}`;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
name = rawName;
|
|
84
|
+
}
|
|
85
|
+
let value;
|
|
86
|
+
if (quotedValue === undefined) {
|
|
87
|
+
value = true;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
value = quotedValue;
|
|
91
|
+
}
|
|
92
|
+
attrs.push({ name, value, dynamic: isDynamic });
|
|
93
|
+
}
|
|
94
|
+
return attrs;
|
|
95
|
+
}
|
|
96
|
+
function parseText(text) {
|
|
97
|
+
const nodes = [];
|
|
98
|
+
let lastIdx = 0;
|
|
99
|
+
mustacheRegex.lastIndex = 0;
|
|
100
|
+
let match;
|
|
101
|
+
while ((match = mustacheRegex.exec(text)) !== null) {
|
|
102
|
+
if (match.index > lastIdx) {
|
|
103
|
+
nodes.push({ type: 'text', content: text.slice(lastIdx, match.index) });
|
|
104
|
+
}
|
|
105
|
+
nodes.push({ type: 'expression', content: match[1].trim() });
|
|
106
|
+
lastIdx = mustacheRegex.lastIndex;
|
|
107
|
+
}
|
|
108
|
+
if (lastIdx < text.length) {
|
|
109
|
+
nodes.push({ type: 'text', content: text.slice(lastIdx) });
|
|
110
|
+
}
|
|
111
|
+
return nodes;
|
|
112
|
+
}
|
|
113
|
+
function hasChildren(attrs) {
|
|
114
|
+
return attrs.some(a => a.name === 'v-if' || a.name === 'v-for');
|
|
115
|
+
}
|
|
116
|
+
const voidElements = new Set([
|
|
117
|
+
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
|
|
118
|
+
'link', 'meta', 'param', 'source', 'track', 'wbr',
|
|
119
|
+
]);
|
|
120
|
+
function isVoidElement(tag) {
|
|
121
|
+
return voidElements.has(tag);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/parse/template.ts"],"names":[],"mappings":"AAgEA,MAAM,QAAQ,GAAG,qEAAqE,CAAA;AACtF,MAAM,SAAS,GAAG,iEAAiE,CAAA;AACnF,MAAM,aAAa,GAAG,gBAAgB,CAAA;AAEtC,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,IAAI,GAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;IACxD,MAAM,KAAK,GAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/C,IAAI,SAAS,GAAG,CAAC,CAAA;IAEjB,IAAI,KAA6B,CAAA;IACjC,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAA;IAEtB,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAClD,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAA;QACnD,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAA;QAE9B,4BAA4B;QAC5B,IAAI,UAAU,GAAG,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;YAClD,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;YAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,KAAK,CAAC,KAAK,C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AK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAC5D,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAA;AACjE,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO;IAC1D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK;CAClD,CAAC,CAAA;AAEF,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transform/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/transform/style.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB,CAAA;AAED,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,oBAAoB,CAqB1H"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function transformStyle(styleContent, scoped, template) {
|
|
2
|
+
if (!scoped || !styleContent) {
|
|
3
|
+
return { scopeId: null, styleCode: styleContent };
|
|
4
|
+
}
|
|
5
|
+
const scopeId = `data-v-${hashCode(template || '')}`;
|
|
6
|
+
const scopedCss = styleContent
|
|
7
|
+
.split('\n')
|
|
8
|
+
.map(line => {
|
|
9
|
+
const trimmed = line.trim();
|
|
10
|
+
if (!trimmed || trimmed.startsWith('{') || trimmed.startsWith('}') || trimmed.startsWith('/*'))
|
|
11
|
+
return line;
|
|
12
|
+
if (trimmed.startsWith('.'))
|
|
13
|
+
return ` ${trimmed}.[${scopeId}]`;
|
|
14
|
+
if (trimmed.startsWith('#'))
|
|
15
|
+
return ` ${trimmed}.[${scopeId}]`;
|
|
16
|
+
const tagMatch = trimmed.match(/^(\w[\w-]*)\b(.*)$/);
|
|
17
|
+
if (tagMatch)
|
|
18
|
+
return ` ${tagMatch[1]}[${scopeId}]${tagMatch[2]}`;
|
|
19
|
+
return line;
|
|
20
|
+
})
|
|
21
|
+
.join('\n');
|
|
22
|
+
return { scopeId, styleCode: scopedCss };
|
|
23
|
+
}
|
|
24
|
+
function hashCode(str) {
|
|
25
|
+
let hash = 0;
|
|
26
|
+
for (let i = 0; i < str.length; i++) {
|
|
27
|
+
const char = str.charCodeAt(i);
|
|
28
|
+
hash = ((hash << 5) - hash) + char;
|
|
29
|
+
hash |= 0;
|
|
30
|
+
}
|
|
31
|
+
return Math.abs(hash).toString(16);
|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O,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA;AAC1C,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAC9B,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;QAClC,IAAI,IAAI,CAAC,CAAA;IACX,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { TemplateAST } from '../parse/template.js';
|
|
2
|
+
export type TransformedAST = {
|
|
3
|
+
type: 'root';
|
|
4
|
+
children: TransformedNode[];
|
|
5
|
+
};
|
|
6
|
+
export type TransformedNode = {
|
|
7
|
+
type: 'element';
|
|
8
|
+
tag: string;
|
|
9
|
+
props: string;
|
|
10
|
+
children: TransformedNode[];
|
|
11
|
+
vIf?: string;
|
|
12
|
+
vFor?: {
|
|
13
|
+
item: string;
|
|
14
|
+
index: string;
|
|
15
|
+
list: string;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
type: 'text';
|
|
19
|
+
content: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'expression';
|
|
22
|
+
content: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'slot';
|
|
25
|
+
name: string;
|
|
26
|
+
slotProps?: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'comment';
|
|
29
|
+
} | {
|
|
30
|
+
type: 'if';
|
|
31
|
+
condition: string;
|
|
32
|
+
then: TransformedNode[];
|
|
33
|
+
else_: TransformedNode[] | null;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'for';
|
|
36
|
+
item: string;
|
|
37
|
+
index: string;
|
|
38
|
+
list: string;
|
|
39
|
+
children: TransformedNode[];
|
|
40
|
+
};
|
|
41
|
+
export declare function transformTemplate(ast: TemplateAST): TransformedAST;
|
|
42
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/transform/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,eAAe,EAAE,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAChJ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,eAAe,EAAE,CAAC;IAAC,KAAK,EAAE,eAAe,EAAE,GAAG,IAAI,CAAA;CAAE,GAC3F;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,eAAe,EAAE,CAAA;CAAE,CAAA;AA8F3F,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CAKlE"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function transformNode(node) {
|
|
2
|
+
switch (node.type) {
|
|
3
|
+
case 'text':
|
|
4
|
+
return { type: 'text', content: node.content };
|
|
5
|
+
case 'expression':
|
|
6
|
+
return { type: 'expression', content: node.content };
|
|
7
|
+
case 'comment':
|
|
8
|
+
return { type: 'comment' };
|
|
9
|
+
case 'element': {
|
|
10
|
+
const vForAttr = node.attrs.find(a => a.name === 'v-for');
|
|
11
|
+
const vIfAttr = node.attrs.find(a => a.name === 'v-if');
|
|
12
|
+
const filteredAttrs = node.attrs.filter(a => a.name !== 'v-if' && a.name !== 'v-for');
|
|
13
|
+
const props = genProps(filteredAttrs);
|
|
14
|
+
const result = {
|
|
15
|
+
type: 'element',
|
|
16
|
+
tag: node.tag,
|
|
17
|
+
props,
|
|
18
|
+
children: node.children.map(transformNode),
|
|
19
|
+
};
|
|
20
|
+
if (vIfAttr && typeof vIfAttr.value === 'string') {
|
|
21
|
+
result.vIf = vIfAttr.value;
|
|
22
|
+
}
|
|
23
|
+
if (vForAttr && typeof vForAttr.value === 'string') {
|
|
24
|
+
const parsed = parseForExpression(vForAttr.value);
|
|
25
|
+
if (parsed) {
|
|
26
|
+
result.vFor = parsed;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
case 'slot': {
|
|
32
|
+
const dynamicAttrs = node.attrs.filter(a => a.dynamic && a.name !== 'name');
|
|
33
|
+
const slotProps = dynamicAttrs.length > 0
|
|
34
|
+
? dynamicAttrs.map(a => `${a.name}: ${a.value}`).join(', ')
|
|
35
|
+
: undefined;
|
|
36
|
+
return { type: 'slot', name: node.name, slotProps };
|
|
37
|
+
}
|
|
38
|
+
case 'if': {
|
|
39
|
+
const then = node.then.map(transformNode);
|
|
40
|
+
const else_ = node.else_ ? node.else_.map(transformNode) : null;
|
|
41
|
+
return { type: 'if', condition: node.condition, then, else_ };
|
|
42
|
+
}
|
|
43
|
+
case 'for': {
|
|
44
|
+
return { type: 'for', item: node.item, index: node.index, list: node.list, children: node.children.map(transformNode) };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function genProps(attrs) {
|
|
49
|
+
const parts = [];
|
|
50
|
+
for (const attr of attrs) {
|
|
51
|
+
if (attr.name === 'v-show' && typeof attr.value === 'string') {
|
|
52
|
+
parts.push(`vShow: ${attr.value}`);
|
|
53
|
+
}
|
|
54
|
+
else if (attr.name === 'v-model' && typeof attr.value === 'string') {
|
|
55
|
+
parts.push(`value: ${attr.value}.value`);
|
|
56
|
+
parts.push(`onInput: ($event) => { ${attr.value}.value = $event.target.value }`);
|
|
57
|
+
}
|
|
58
|
+
else if (attr.name.startsWith('on')) {
|
|
59
|
+
const isIdentifier = /^\w+$/.test(attr.value);
|
|
60
|
+
if (isIdentifier) {
|
|
61
|
+
parts.push(`${attr.name}: ${attr.value}`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
parts.push(`${attr.name}: ($event) => { ${attr.value} }`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (attr.dynamic) {
|
|
68
|
+
parts.push(`${attr.name}: ${attr.value}`);
|
|
69
|
+
}
|
|
70
|
+
else if (typeof attr.value === 'string') {
|
|
71
|
+
parts.push(`${attr.name}: ${JSON.stringify(attr.value)}`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
parts.push(`${attr.name}: true`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return parts.join(', ');
|
|
78
|
+
}
|
|
79
|
+
function parseForExpression(expr) {
|
|
80
|
+
const match = expr.match(/^\s*(?:\(?\s*(\w+)\s*(?:,\s*(\w+))?\s*\)?\s+in\s+|(\w+)\s+of\s+)(.+)$/);
|
|
81
|
+
if (!match) {
|
|
82
|
+
const simpleMatch = expr.match(/^(\w+)\s+in\s+(.+)$/);
|
|
83
|
+
if (!simpleMatch)
|
|
84
|
+
return null;
|
|
85
|
+
return { item: simpleMatch[1], index: 'index', list: simpleMatch[2] };
|
|
86
|
+
}
|
|
87
|
+
const item = match[1] || match[3];
|
|
88
|
+
const index = match[2] || 'index';
|
|
89
|
+
const list = match[4];
|
|
90
|
+
return { item, index, list };
|
|
91
|
+
}
|
|
92
|
+
export function transformTemplate(ast) {
|
|
93
|
+
return {
|
|
94
|
+
type: 'root',
|
|
95
|
+
children: ast.children.map(transformNode),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/transform/template.ts"],"names":[],"mappings":"AAgBA,SAAS,aAAa,CAAC,IAA8C;IACnE,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAA;QAChD,KAAK,YAAY;YACf,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAA;QACtD,KAAK,SAAS;YACZ,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;QAC5B,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAA;YACzD,MAAM,OAAO,GAAG,I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,CAAC,KAAK,CAAC,uEAAuE,CAAC,CAAA;IACjG,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACrD,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAA;QAC7B,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;IACvE,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAA;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,OAAO,CAAA;IACjC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IACrB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AAC9B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAgB;IAChD,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC;KAC1C,CAAA;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nexa-compiler",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"clean": "rm -rf dist"
|
|
24
|
+
}
|
|
25
|
+
}
|