@fluixi/compiler 1.0.0-alpha.75 → 1.0.0-alpha.77
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/README.md +38 -2
- package/dist/analyze/intrinsics.cjs +1 -0
- package/dist/analyze/intrinsics.d.ts +67 -0
- package/dist/analyze/intrinsics.d.ts.map +1 -0
- package/dist/analyze/intrinsics.js +91 -0
- package/dist/analyze/intrinsics.mjs +1 -0
- package/dist/analyze/props-destructure.cjs +1 -0
- package/dist/analyze/props-destructure.d.ts +84 -0
- package/dist/analyze/props-destructure.d.ts.map +1 -0
- package/dist/analyze/props-destructure.js +272 -0
- package/dist/analyze/props-destructure.mjs +1 -0
- package/dist/analyze/reactive-bindings.cjs +1 -0
- package/dist/analyze/reactive-bindings.d.ts +43 -0
- package/dist/analyze/reactive-bindings.d.ts.map +1 -0
- package/dist/analyze/reactive-bindings.js +191 -0
- package/dist/analyze/reactive-bindings.mjs +1 -0
- package/dist/{babel-GXO3KAVI.mjs → babel-YQ42WUS3.mjs} +1 -1
- package/dist/chunk-545LMC5W.mjs +1 -0
- package/dist/{chunk-TIE4XNAM.mjs → chunk-L2QPV25P.mjs} +1 -1
- package/dist/frontend/babel/build-ir-lit.cjs +1 -1
- package/dist/frontend/babel/build-ir-lit.mjs +1 -1
- package/dist/frontend/babel/build-ir.cjs +1 -1
- package/dist/frontend/babel/build-ir.mjs +1 -1
- package/dist/frontend/babel/index.cjs +1 -1
- package/dist/frontend/babel/index.mjs +1 -1
- package/dist/frontend/babel/lower-template.cjs +1 -1
- package/dist/frontend/babel/lower-template.mjs +1 -1
- package/dist/frontend/babel/plugin.cjs +1 -1
- package/dist/frontend/babel/plugin.mjs +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.mjs +9 -9
- package/dist/integrations.cjs +19 -14
- package/dist/integrations.d.ts +13 -0
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +52 -2
- package/dist/integrations.mjs +11 -11
- package/dist/lower/compile-template.cjs +1 -1
- package/dist/lower/compile-template.mjs +1 -1
- package/dist/lower/template.cjs +1 -1
- package/dist/lower/template.d.ts.map +1 -1
- package/dist/lower/template.js +7 -5
- package/dist/lower/template.mjs +1 -1
- package/dist/resolve/component-globals.cjs +9 -9
- package/dist/resolve/component-globals.d.ts +8 -0
- package/dist/resolve/component-globals.d.ts.map +1 -1
- package/dist/resolve/component-globals.js +17 -3
- package/dist/resolve/component-globals.mjs +9 -9
- package/dist/resolve/write-globals.cjs +9 -9
- package/dist/resolve/write-globals.mjs +9 -9
- package/dist/transform/index.cjs +6 -1
- package/dist/transform/index.d.ts +4 -0
- package/dist/transform/index.d.ts.map +1 -1
- package/dist/transform/index.js +2 -0
- package/dist/transform/index.mjs +15 -10
- package/dist/transform/intrinsics.cjs +3 -0
- package/dist/transform/intrinsics.d.ts +22 -0
- package/dist/transform/intrinsics.d.ts.map +1 -0
- package/dist/transform/intrinsics.js +78 -0
- package/dist/transform/intrinsics.mjs +3 -0
- package/dist/transform/props.cjs +3 -0
- package/dist/transform/props.d.ts +46 -0
- package/dist/transform/props.d.ts.map +1 -0
- package/dist/transform/props.js +221 -0
- package/dist/transform/props.mjs +12 -0
- package/dist/transform/templates.cjs +5 -1
- package/dist/transform/templates.d.ts +36 -0
- package/dist/transform/templates.d.ts.map +1 -1
- package/dist/transform/templates.js +175 -7
- package/dist/transform/templates.mjs +14 -10
- package/dist/transform-ZGXUDFEZ.mjs +8 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/transform-PJX2GNSV.mjs +0 -3
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrite destructured component props into property reads.
|
|
3
|
+
*
|
|
4
|
+
* `function Card({ title, size = 'md' })` becomes `function Card(props)` with `title`
|
|
5
|
+
* rewritten to `props.title` wherever it's used, so the reads stay live. What can't be
|
|
6
|
+
* rewritten is left alone and reported — see analyze/props-destructure for the rules.
|
|
7
|
+
*
|
|
8
|
+
* Source in, source out, spans spliced with magic-string, so the author's formatting
|
|
9
|
+
* survives and the map comes out of the splice. It runs before templates are compiled,
|
|
10
|
+
* which is what makes JSX and html`` behave the same: both end up reading `props.title`
|
|
11
|
+
* from the same rewritten body, and neither one needs to know this happened.
|
|
12
|
+
*/
|
|
13
|
+
import { parse } from '@babel/parser';
|
|
14
|
+
import MagicString from 'magic-string';
|
|
15
|
+
import { planPropsDestructure, explainBail } from '../analyze/props-destructure.js';
|
|
16
|
+
import { moduleBindings } from './bindings.js';
|
|
17
|
+
/** Walk everything under a node. Skips TS annotations, where a name isn't a value. */
|
|
18
|
+
function walk(root, visit, parent = null) {
|
|
19
|
+
if (!root || typeof root !== 'object' || typeof root.type !== 'string')
|
|
20
|
+
return;
|
|
21
|
+
if (root.type.startsWith('TS'))
|
|
22
|
+
return;
|
|
23
|
+
if (visit(root, parent) === false)
|
|
24
|
+
return;
|
|
25
|
+
for (const key of Object.keys(root)) {
|
|
26
|
+
if (key === 'loc' || key === 'leadingComments' || key === 'trailingComments')
|
|
27
|
+
continue;
|
|
28
|
+
const value = root[key];
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
for (const item of value)
|
|
31
|
+
walk(item, visit, root);
|
|
32
|
+
}
|
|
33
|
+
else if (value && typeof value === 'object') {
|
|
34
|
+
walk(value, visit, root);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** A component by the same rule JSX uses: a capitalised name. */
|
|
39
|
+
function isComponentName(name) {
|
|
40
|
+
return !!name && name[0] >= 'A' && name[0] <= 'Z';
|
|
41
|
+
}
|
|
42
|
+
/** Component functions in a module, paired with the name they were declared under. */
|
|
43
|
+
function componentFunctions(program) {
|
|
44
|
+
const found = [];
|
|
45
|
+
walk(program, (node) => {
|
|
46
|
+
if (node.type === 'FunctionDeclaration' && isComponentName(node.id?.name)) {
|
|
47
|
+
found.push(node);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (node.type === 'VariableDeclarator' && isComponentName(node.id?.name)) {
|
|
51
|
+
const init = node.init;
|
|
52
|
+
if (init && (init.type === 'ArrowFunctionExpression' || init.type === 'FunctionExpression'))
|
|
53
|
+
found.push(init);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return found;
|
|
57
|
+
}
|
|
58
|
+
/** Names used anywhere in a function, so the parameter we introduce doesn't collide. */
|
|
59
|
+
function usedNames(fn) {
|
|
60
|
+
const names = new Set();
|
|
61
|
+
walk(fn, (node) => {
|
|
62
|
+
if (node.type === 'Identifier')
|
|
63
|
+
names.add(node.name);
|
|
64
|
+
});
|
|
65
|
+
return names;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Positions where an identifier isn't a reference to the binding: a property name, a
|
|
69
|
+
* non-computed object key, a label. A shorthand property is handled by the caller,
|
|
70
|
+
* since it needs the key written out.
|
|
71
|
+
*/
|
|
72
|
+
function isReferencePosition(node, parent) {
|
|
73
|
+
if (!parent)
|
|
74
|
+
return true;
|
|
75
|
+
switch (parent.type) {
|
|
76
|
+
case 'MemberExpression':
|
|
77
|
+
case 'OptionalMemberExpression':
|
|
78
|
+
return !(parent.property === node && !parent.computed);
|
|
79
|
+
case 'ObjectProperty':
|
|
80
|
+
case 'ObjectMethod':
|
|
81
|
+
case 'ClassProperty':
|
|
82
|
+
case 'ClassMethod':
|
|
83
|
+
return !(parent.key === node && !parent.computed);
|
|
84
|
+
case 'LabeledStatement':
|
|
85
|
+
case 'BreakStatement':
|
|
86
|
+
case 'ContinueStatement':
|
|
87
|
+
return parent.label !== node;
|
|
88
|
+
case 'ImportSpecifier':
|
|
89
|
+
case 'ExportSpecifier':
|
|
90
|
+
return false;
|
|
91
|
+
default:
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Work out the edits without applying them, so a caller that already has the source in a
|
|
97
|
+
* MagicString can fold them into its own. That's how the template transform picks this
|
|
98
|
+
* up: one string, one map, and holes get the rewrite because it slices them with the
|
|
99
|
+
* edits applied.
|
|
100
|
+
*/
|
|
101
|
+
export function collectPropsEdits(program, code, options = {}) {
|
|
102
|
+
const edits = [];
|
|
103
|
+
const diagnostics = [];
|
|
104
|
+
const used = new Set();
|
|
105
|
+
for (const fn of componentFunctions(program)) {
|
|
106
|
+
const pattern = fn.params?.[0];
|
|
107
|
+
if (pattern?.type !== 'ObjectPattern')
|
|
108
|
+
continue;
|
|
109
|
+
const plan = planPropsDestructure(pattern, fn.body);
|
|
110
|
+
for (const b of plan.bails) {
|
|
111
|
+
diagnostics.push({ name: b.name, reason: b.reason, message: explainBail(b.reason), start: pattern.start });
|
|
112
|
+
}
|
|
113
|
+
// Whole function or nothing: half a rewrite would read as if the rest were fine too.
|
|
114
|
+
if (plan.bails.length > 0)
|
|
115
|
+
continue;
|
|
116
|
+
if (plan.reads.length === 0 && !plan.rest)
|
|
117
|
+
continue;
|
|
118
|
+
const taken = usedNames(fn);
|
|
119
|
+
let parameter = options.parameterName ?? 'props';
|
|
120
|
+
while (taken.has(parameter))
|
|
121
|
+
parameter = `_${parameter}`;
|
|
122
|
+
const replacement = new Map();
|
|
123
|
+
for (const read of plan.reads) {
|
|
124
|
+
const access = `${parameter}.${read.path.join('.')}`;
|
|
125
|
+
const fallback = read.fallback;
|
|
126
|
+
// A default only applies to `undefined`, so this can't collapse to `??`.
|
|
127
|
+
replacement.set(read.name, fallback ? `(${access} === undefined ? ${code.slice(fallback.start, fallback.end)} : ${access})` : access);
|
|
128
|
+
}
|
|
129
|
+
// The pattern's range covers its type annotation, so overwriting the whole span
|
|
130
|
+
// would take `: { title: string }` with it. Stop at the annotation and the type
|
|
131
|
+
// stays exactly as written.
|
|
132
|
+
const annotation = pattern.typeAnnotation;
|
|
133
|
+
edits.push({ start: pattern.start, end: annotation?.start ?? pattern.end, code: parameter });
|
|
134
|
+
// `...rest` becomes the splitProps call the author would have written. splitProps
|
|
135
|
+
// carries the getters over instead of reading them, which is the whole reason a
|
|
136
|
+
// plain rest can't be rewritten — so this hands the job to the runtime helper that
|
|
137
|
+
// does it properly rather than refusing the pattern.
|
|
138
|
+
if (plan.rest) {
|
|
139
|
+
const keys = plan.rest.keys.map((k) => JSON.stringify(k)).join(', ');
|
|
140
|
+
const body = fn.body;
|
|
141
|
+
edits.push({
|
|
142
|
+
start: body.start + 1,
|
|
143
|
+
end: body.start + 1,
|
|
144
|
+
code: `\n const [, ${plan.rest.name}] = splitProps(${parameter}, [${keys}]);`,
|
|
145
|
+
});
|
|
146
|
+
used.add('splitProps');
|
|
147
|
+
}
|
|
148
|
+
// Collect first, rewrite after: turning a node into a member below gives it new
|
|
149
|
+
// children, and a walk still in progress would descend into them and match again.
|
|
150
|
+
const matches = [];
|
|
151
|
+
walk(fn.body, (node, parent) => {
|
|
152
|
+
if (node.type !== 'Identifier')
|
|
153
|
+
return undefined;
|
|
154
|
+
const text = replacement.get(node.name);
|
|
155
|
+
if (!text)
|
|
156
|
+
return undefined;
|
|
157
|
+
const shorthand = parent?.type === 'ObjectProperty' && parent.shorthand && parent.value === node;
|
|
158
|
+
if (!shorthand && !isReferencePosition(node, parent))
|
|
159
|
+
return undefined;
|
|
160
|
+
const path = plan.reads.find((r) => r.name === node.name).path;
|
|
161
|
+
matches.push({ node, parent: shorthand ? parent : null, text, property: path[path.length - 1] });
|
|
162
|
+
return undefined;
|
|
163
|
+
});
|
|
164
|
+
for (const match of matches) {
|
|
165
|
+
if (match.parent) {
|
|
166
|
+
// `{ name }` needs the key spelled out, or the result isn't an object literal.
|
|
167
|
+
edits.push({ start: match.parent.start, end: match.parent.end, code: `${match.node.name}: ${match.text}` });
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
edits.push({ start: match.node.start, end: match.node.end, code: match.text });
|
|
171
|
+
}
|
|
172
|
+
// Say it in the AST too, not only in the text. Whether a hole is wired reactively
|
|
173
|
+
// is decided from the expression's shape, and a bare identifier is not reactive —
|
|
174
|
+
// so leaving the node as an Identifier emits `props.text` read once, which is the
|
|
175
|
+
// bug this whole pass exists to remove. A member read is reactive, which is what
|
|
176
|
+
// the emitted code now is.
|
|
177
|
+
asMemberRead(match.node, parameter, match.property);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return { edits, diagnostics, used };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Rewrite an identifier node into `<parameter>.<property>` in place, keeping its span so
|
|
184
|
+
* the text it maps to is unchanged. The synthetic children are zero-width at the node's
|
|
185
|
+
* own edges: nothing slices them, and they exist so shape analysis sees a member.
|
|
186
|
+
*/
|
|
187
|
+
function asMemberRead(node, parameter, property) {
|
|
188
|
+
node.type = 'MemberExpression';
|
|
189
|
+
node.computed = false;
|
|
190
|
+
node.optional = false;
|
|
191
|
+
node.object = { type: 'Identifier', name: parameter, start: node.start, end: node.start };
|
|
192
|
+
node.property = { type: 'Identifier', name: property, start: node.end, end: node.end };
|
|
193
|
+
delete node['name'];
|
|
194
|
+
}
|
|
195
|
+
/** Run the rewrite on its own. The template transform folds the edits in instead. */
|
|
196
|
+
export function transformProps(code, filename = 'module.tsx', options = {}) {
|
|
197
|
+
const ast = parse(code, {
|
|
198
|
+
sourceType: 'module',
|
|
199
|
+
plugins: ['typescript', 'jsx'],
|
|
200
|
+
errorRecovery: true,
|
|
201
|
+
});
|
|
202
|
+
const { edits, diagnostics, used } = collectPropsEdits(ast.program, code, options);
|
|
203
|
+
const source = new MagicString(code);
|
|
204
|
+
for (const e of edits) {
|
|
205
|
+
if (e.start === e.end)
|
|
206
|
+
source.appendLeft(e.start, e.code);
|
|
207
|
+
else
|
|
208
|
+
source.overwrite(e.start, e.end, e.code);
|
|
209
|
+
}
|
|
210
|
+
// Standalone, there's no prologue to join, so the import goes in here — unless the
|
|
211
|
+
// module already has the name bound.
|
|
212
|
+
if (used.has('splitProps') && !moduleBindings(ast.program).has('splitProps')) {
|
|
213
|
+
source.prepend(`import { splitProps } from ${JSON.stringify(options.runtimeModule ?? '@fluixi/dom')};\n`);
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
code: source.toString(),
|
|
217
|
+
map: source.generateMap({ source: filename, includeContent: true, hires: true }),
|
|
218
|
+
diagnostics,
|
|
219
|
+
rewritten: edits.filter((e) => e.code !== (options.parameterName ?? 'props')).length,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{parse as se}from"@babel/parser";var W=44,z=59,_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",D=new Uint8Array(64),H=new Uint8Array(128);for(let s=0;s<_.length;s++){let e=_.charCodeAt(s);D[s]=e,H[e]=s}function b(s,e,t){let n=e-t;n=n<0?-n<<1|1:n<<1;do{let i=n&31;n>>>=5,n>0&&(i|=32),s.write(D[i])}while(n>0);return e}var j=1024*16,A=typeof TextDecoder<"u"?new TextDecoder:typeof Buffer<"u"?{decode(s){return Buffer.from(s.buffer,s.byteOffset,s.byteLength).toString()}}:{decode(s){let e="";for(let t=0;t<s.length;t++)e+=String.fromCharCode(s[t]);return e}},Y=class{constructor(){this.pos=0,this.out="",this.buffer=new Uint8Array(j)}write(s){let{buffer:e}=this;e[this.pos++]=s,this.pos===j&&(this.out+=A.decode(e),this.pos=0)}flush(){let{buffer:s,out:e,pos:t}=this;return t>0?e+A.decode(s.subarray(0,t)):e}};function $(s){let e=new Y,t=0,n=0,i=0,r=0;for(let o=0;o<s.length;o++){let a=s[o];if(o>0&&e.write(z),a.length===0)continue;let l=0;for(let u=0;u<a.length;u++){let h=a[u];u>0&&e.write(W),l=b(e,h[0],l),h.length!==1&&(t=b(e,h[1],t),n=b(e,h[2],n),i=b(e,h[3],i),h.length!==4&&(r=b(e,h[4],r)))}}return e.flush()}var C=class s{constructor(e){this.bits=e instanceof s?e.bits.slice():[]}add(e){this.bits[e>>5]|=1<<(e&31)}has(e){return!!(this.bits[e>>5]&1<<(e&31))}},x=class s{constructor(e,t,n){this.start=e,this.end=t,this.original=n,this.intro="",this.outro="",this.content=n,this.storeName=!1,this.edited=!1,this.previous=null,this.next=null}appendLeft(e){this.outro+=e}appendRight(e){this.intro=this.intro+e}clone(){let e=new s(this.start,this.end,this.original);return e.intro=this.intro,e.outro=this.outro,e.content=this.content,e.storeName=this.storeName,e.edited=this.edited,e}contains(e){return this.start<e&&e<this.end}eachNext(e){let t=this;for(;t;)e(t),t=t.next}eachPrevious(e){let t=this;for(;t;)e(t),t=t.previous}edit(e,t,n){return this.content=e,n||(this.intro="",this.outro=""),this.storeName=t,this.edited=!0,this}prependLeft(e){this.outro=e+this.outro}prependRight(e){this.intro=e+this.intro}reset(){this.intro="",this.outro="",this.edited&&(this.content=this.original,this.storeName=!1,this.edited=!1)}split(e){let t=e-this.start,n=this.original.slice(0,t),i=this.original.slice(t);this.original=n;let r=new s(e,this.end,i);return r.outro=this.outro,this.outro="",this.end=e,this.edited?(r.edit("",!1),this.content=""):this.content=n,r.next=this.next,r.next&&(r.next.previous=r),r.previous=this,this.next=r,r}toString(){return this.intro+this.content+this.outro}trimEnd(e){if(this.outro=this.outro.replace(e,""),this.outro.length)return!0;let t=this.content.replace(e,"");if(t.length)return t!==this.content&&(this.split(this.start+t.length).edit("",void 0,!0),this.edited&&this.edit(t,this.storeName,!0)),!0;if(this.edit("",void 0,!0),this.intro=this.intro.replace(e,""),this.intro.length)return!0}trimStart(e){if(this.intro=this.intro.replace(e,""),this.intro.length)return!0;let t=this.content.replace(e,"");if(t.length){if(t!==this.content){let n=this.split(this.end-t.length);this.edited&&n.edit(t,this.storeName,!0),this.edit("",void 0,!0)}return!0}else if(this.edit("",void 0,!0),this.outro=this.outro.replace(e,""),this.outro.length)return!0}};function Z(){return typeof globalThis<"u"&&typeof globalThis.btoa=="function"?s=>globalThis.btoa(unescape(encodeURIComponent(s))):typeof Buffer=="function"?s=>Buffer.from(s,"utf-8").toString("base64"):()=>{throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.")}}var K=Z(),k=class{constructor(e){this.version=3,this.file=e.file,this.sources=e.sources,this.sourcesContent=e.sourcesContent,this.names=e.names,this.mappings=$(e.mappings),typeof e.x_google_ignoreList<"u"&&(this.x_google_ignoreList=e.x_google_ignoreList),typeof e.debugId<"u"&&(this.debugId=e.debugId)}toString(){return JSON.stringify(this)}toUrl(){return"data:application/json;charset=utf-8;base64,"+K(this.toString())}};function Q(s){let e=s.split(`
|
|
2
|
+
`),t=e.filter(r=>/^\t+/.test(r)),n=e.filter(r=>/^ {2,}/.test(r));if(t.length===0&&n.length===0)return null;if(t.length>=n.length)return" ";let i=n.reduce((r,o)=>{let a=/^ +/.exec(o)[0].length;return Math.min(a,r)},1/0);return new Array(i+1).join(" ")}function X(s,e){let t=s.split(/[/\\]/),n=e.split(/[/\\]/);for(t.pop();t[0]===n[0];)t.shift(),n.shift();if(t.length){let i=t.length;for(;i--;)t[i]=".."}return t.concat(n).join("/")}var V=Object.prototype.toString;function ee(s){return V.call(s)==="[object Object]"}function B(s){let e=s.split(`
|
|
3
|
+
`),t=[];for(let n=0,i=0;n<e.length;n++)t.push(i),i+=e[n].length+1;return function(i){let r=0,o=t.length;for(;r<o;){let u=r+o>>1;i<t[u]?o=u:r=u+1}let a=r-1,l=i-t[a];return{line:a,column:l}}}var te=/\w/,L=class{constructor(e){this.hires=e,this.generatedCodeLine=0,this.generatedCodeColumn=0,this.raw=[],this.rawSegments=this.raw[this.generatedCodeLine]=[],this.pending=null}addEdit(e,t,n,i){if(t.length){let r=t.length-1,o=t.indexOf(`
|
|
4
|
+
`,0),a=-1;for(;o>=0&&r>o;){let u=[this.generatedCodeColumn,e,n.line,n.column];i>=0&&u.push(i),this.rawSegments.push(u),this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=o,o=t.indexOf(`
|
|
5
|
+
`,o+1)}let l=[this.generatedCodeColumn,e,n.line,n.column];i>=0&&l.push(i),this.rawSegments.push(l),this.advance(t.slice(a+1))}else this.pending&&(this.rawSegments.push(this.pending),this.advance(t));this.pending=null}addUneditedChunk(e,t,n,i,r){let o=t.start,a=!0,l=!1;for(;o<t.end;){if(n[o]===`
|
|
6
|
+
`)i.line+=1,i.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,a=!0,l=!1;else{if(this.hires||a||r.has(o)){let u=[this.generatedCodeColumn,e,i.line,i.column];this.hires==="boundary"?te.test(n[o])?l||(this.rawSegments.push(u),l=!0):(this.rawSegments.push(u),l=!1):this.rawSegments.push(u)}i.column+=1,this.generatedCodeColumn+=1,a=!1}o+=1}this.pending=null}advance(e){if(!e)return;let t=e.split(`
|
|
7
|
+
`);if(t.length>1){for(let n=0;n<t.length-1;n++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=t[t.length-1].length}},y=`
|
|
8
|
+
`,w={insertLeft:!1,insertRight:!1,storeName:!1},N=class s{constructor(e,t={}){let n=new x(0,e.length,e);Object.defineProperties(this,{original:{writable:!0,value:e},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:n},lastChunk:{writable:!0,value:n},lastSearchedChunk:{writable:!0,value:n},byStart:{writable:!0,value:{}},byEnd:{writable:!0,value:{}},filename:{writable:!0,value:t.filename},indentExclusionRanges:{writable:!0,value:t.indentExclusionRanges},sourcemapLocations:{writable:!0,value:new C},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:t.ignoreList},offset:{writable:!0,value:t.offset||0}}),this.byStart[0]=n,this.byEnd[e.length]=n}addSourcemapLocation(e){this.sourcemapLocations.add(e)}append(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.outro+=e,this}appendLeft(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let n=this.byEnd[e];return n?n.appendLeft(t):this.intro+=t,this}appendRight(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let n=this.byStart[e];return n?n.appendRight(t):this.outro+=t,this}clone(){let e=new s(this.original,{filename:this.filename,offset:this.offset}),t=this.firstChunk,n=e.firstChunk=e.lastSearchedChunk=t.clone();for(;t;){e.byStart[n.start]=n,e.byEnd[n.end]=n;let i=t.next,r=i&&i.clone();r&&(n.next=r,r.previous=n,n=r),t=i}return e.lastChunk=n,this.indentExclusionRanges&&(e.indentExclusionRanges=this.indentExclusionRanges.slice()),e.sourcemapLocations=new C(this.sourcemapLocations),e.intro=this.intro,e.outro=this.outro,e}generateDecodedMap(e){e=e||{};let t=0,n=Object.keys(this.storedNames),i=new L(e.hires),r=B(this.original);return this.intro&&i.advance(this.intro),this.firstChunk.eachNext(o=>{let a=r(o.start);o.intro.length&&i.advance(o.intro),o.edited?i.addEdit(t,o.content,a,o.storeName?n.indexOf(o.original):-1):i.addUneditedChunk(t,o,this.original,a,this.sourcemapLocations),o.outro.length&&i.advance(o.outro)}),this.outro&&i.advance(this.outro),{file:e.file?e.file.split(/[/\\]/).pop():void 0,sources:[e.source?X(e.file||"",e.source):e.file||""],sourcesContent:e.includeContent?[this.original]:void 0,names:n,mappings:i.raw,x_google_ignoreList:this.ignoreList?[t]:void 0}}generateMap(e){return new k(this.generateDecodedMap(e))}_ensureindentStr(){this.indentStr===void 0&&(this.indentStr=Q(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),this.indentStr===null?" ":this.indentStr}indent(e,t){let n=/^[^\r\n]/gm;if(ee(e)&&(t=e,e=void 0),e===void 0&&(this._ensureindentStr(),e=this.indentStr||" "),e==="")return this;t=t||{};let i={};t.exclude&&(typeof t.exclude[0]=="number"?[t.exclude]:t.exclude).forEach(h=>{for(let f=h[0];f<h[1];f+=1)i[f]=!0});let r=t.indentStart!==!1,o=u=>r?`${e}${u}`:(r=!0,u);this.intro=this.intro.replace(n,o);let a=0,l=this.firstChunk;for(;l;){let u=l.end;if(l.edited)i[a]||(l.content=l.content.replace(n,o),l.content.length&&(r=l.content[l.content.length-1]===`
|
|
9
|
+
`));else for(a=l.start;a<u;){if(!i[a]){let h=this.original[a];h===`
|
|
10
|
+
`?r=!0:h!=="\r"&&r&&(r=!1,a===l.start||(this._splitChunk(l,a),l=l.next),l.prependRight(e))}a+=1}a=l.end,l=l.next}return this.outro=this.outro.replace(n,o),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(e,t){return w.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),w.insertLeft=!0),this.appendLeft(e,t)}insertRight(e,t){return w.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),w.insertRight=!0),this.prependRight(e,t)}move(e,t,n){if(e=e+this.offset,t=t+this.offset,n=n+this.offset,n>=e&&n<=t)throw new Error("Cannot move a selection inside itself");this._split(e),this._split(t),this._split(n);let i=this.byStart[e],r=this.byEnd[t],o=i.previous,a=r.next,l=this.byStart[n];if(!l&&r===this.lastChunk)return this;let u=l?l.previous:this.lastChunk;return o&&(o.next=a),a&&(a.previous=o),u&&(u.next=i),l&&(l.previous=r),i.previous||(this.firstChunk=r.next),r.next||(this.lastChunk=i.previous,this.lastChunk.next=null),i.previous=u,r.next=l||null,u||(this.firstChunk=i),l||(this.lastChunk=r),this}overwrite(e,t,n,i){return i=i||{},this.update(e,t,n,{...i,overwrite:!i.contentOnly})}update(e,t,n,i){if(e=e+this.offset,t=t+this.offset,typeof n!="string")throw new TypeError("replacement content must be a string");if(this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(t>this.original.length)throw new Error("end is out of bounds");if(e===t)throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");this._split(e),this._split(t),i===!0&&(w.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),w.storeName=!0),i={storeName:!0});let r=i!==void 0?i.storeName:!1,o=i!==void 0?i.overwrite:!1;if(r){let u=this.original.slice(e,t);Object.defineProperty(this.storedNames,u,{writable:!0,value:!0,enumerable:!0})}let a=this.byStart[e],l=this.byEnd[t];if(a){let u=a;for(;u!==l;){if(u.next!==this.byStart[u.end])throw new Error("Cannot overwrite across a split point");u=u.next,u.edit("",!1)}a.edit(n,r,!o)}else{let u=new x(e,t,"").edit(n,r);l.next=u,u.previous=l}return this}prepend(e){if(typeof e!="string")throw new TypeError("outro content must be a string");return this.intro=e+this.intro,this}prependLeft(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let n=this.byEnd[e];return n?n.prependLeft(t):this.intro=t+this.intro,this}prependRight(e,t){if(e=e+this.offset,typeof t!="string")throw new TypeError("inserted content must be a string");this._split(e);let n=this.byStart[e];return n?n.prependRight(t):this.outro=t+this.outro,this}remove(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let n=this.byStart[e];for(;n;)n.intro="",n.outro="",n.edit(""),n=t>n.end?this.byStart[n.end]:null;return this}reset(e,t){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);let n=this.byStart[e];for(;n;)n.reset(),n=t>n.end?this.byStart[n.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let e=this.lastChunk;do{if(e.outro.length)return e.outro[e.outro.length-1];if(e.content.length)return e.content[e.content.length-1];if(e.intro.length)return e.intro[e.intro.length-1]}while(e=e.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let e=this.outro.lastIndexOf(y);if(e!==-1)return this.outro.substr(e+1);let t=this.outro,n=this.lastChunk;do{if(n.outro.length>0){if(e=n.outro.lastIndexOf(y),e!==-1)return n.outro.substr(e+1)+t;t=n.outro+t}if(n.content.length>0){if(e=n.content.lastIndexOf(y),e!==-1)return n.content.substr(e+1)+t;t=n.content+t}if(n.intro.length>0){if(e=n.intro.lastIndexOf(y),e!==-1)return n.intro.substr(e+1)+t;t=n.intro+t}}while(n=n.previous);return e=this.intro.lastIndexOf(y),e!==-1?this.intro.substr(e+1)+t:this.intro+t}slice(e=0,t=this.original.length-this.offset){if(e=e+this.offset,t=t+this.offset,this.original.length!==0){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length}let n="",i=this.firstChunk;for(;i&&(i.start>e||i.end<=e);){if(i.start<t&&i.end>=t)return n;i=i.next}if(i&&i.edited&&i.start!==e)throw new Error(`Cannot use replaced character ${e} as slice start anchor.`);let r=i;for(;i;){i.intro&&(r!==i||i.start===e)&&(n+=i.intro);let o=i.start<t&&i.end>=t;if(o&&i.edited&&i.end!==t)throw new Error(`Cannot use replaced character ${t} as slice end anchor.`);let a=r===i?e-i.start:0,l=o?i.content.length+t-i.end:i.content.length;if(n+=i.content.slice(a,l),i.outro&&(!o||i.end===t)&&(n+=i.outro),o)break;i=i.next}return n}snip(e,t){let n=this.clone();return n.remove(0,e),n.remove(t,n.original.length),n}_split(e){if(this.byStart[e]||this.byEnd[e])return;let t=this.lastSearchedChunk,n=t,i=e>t.end;for(;t;){if(t.contains(e))return this._splitChunk(t,e);if(t=i?this.byStart[t.end]:this.byEnd[t.start],t===n)return;n=t}}_splitChunk(e,t){if(e.edited&&e.content.length){let i=B(this.original)(t);throw new Error(`Cannot split a chunk that has already been edited (${i.line}:${i.column} – "${e.original}")`)}let n=e.split(t);return this.byEnd[t]=e,this.byStart[t]=n,this.byEnd[n.end]=n,e===this.lastChunk&&(this.lastChunk=n),this.lastSearchedChunk=e,!0}toString(){let e=this.intro,t=this.firstChunk;for(;t;)e+=t.toString(),t=t.next;return e+this.outro}isEmpty(){let e=this.firstChunk;do if(e.intro.length&&e.intro.trim()||e.content.length&&e.content.trim()||e.outro.length&&e.outro.trim())return!1;while(e=e.next);return!0}length(){let e=this.firstChunk,t=0;do t+=e.intro.length+e.content.length+e.outro.length;while(e=e.next);return t}trimLines(){return this.trim("[\\r\\n]")}trim(e){return this.trimStart(e).trimEnd(e)}trimEndAborted(e){let t=new RegExp((e||"\\s")+"+$");if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;let n=this.lastChunk;do{let i=n.end,r=n.trimEnd(t);if(n.end!==i&&(this.lastChunk===n&&(this.lastChunk=n.next),this.byEnd[n.end]=n,this.byStart[n.next.start]=n.next,this.byEnd[n.next.end]=n.next),r)return!0;n=n.previous}while(n);return!1}trimEnd(e){return this.trimEndAborted(e),this}trimStartAborted(e){let t=new RegExp("^"+(e||"\\s")+"+");if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;let n=this.firstChunk;do{let i=n.end,r=n.trimStart(t);if(n.end!==i&&(n===this.lastChunk&&(this.lastChunk=n.next),this.byEnd[n.end]=n,this.byStart[n.next.start]=n.next,this.byEnd[n.next.end]=n.next),r)return!0;n=n.next}while(n);return!1}trimStart(e){return this.trimStartAborted(e),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(e,t){function n(r,o){return typeof t=="string"?t.replace(/\$(\$|&|\d+)/g,(a,l)=>l==="$"?"$":l==="&"?r[0]:+l<r.length?r[+l]:`$${l}`):t(...r,r.index,o,r.groups)}function i(r,o){let a,l=[];for(;a=r.exec(o);)l.push(a);return l}if(e.global)i(e,this.original).forEach(o=>{if(o.index!=null){let a=n(o,this.original);a!==o[0]&&this.overwrite(o.index,o.index+o[0].length,a)}});else{let r=this.original.match(e);if(r&&r.index!=null){let o=n(r,this.original);o!==r[0]&&this.overwrite(r.index,r.index+r[0].length,o)}}return this}_replaceString(e,t){let{original:n}=this,i=n.indexOf(e);return i!==-1&&(typeof t=="function"&&(t=t(e,i,n)),e!==t&&this.overwrite(i,i+e.length,t)),this}replace(e,t){return typeof e=="string"?this._replaceString(e,t):this._replaceRegexp(e,t)}_replaceAllString(e,t){let{original:n}=this,i=e.length;for(let r=n.indexOf(e);r!==-1;r=n.indexOf(e,r+i)){let o=n.slice(r,r+i),a=t;typeof t=="function"&&(a=t(o,r,n)),o!==a&&this.overwrite(r,r+i,a)}return this}replaceAll(e,t){if(typeof e=="string")return this._replaceAllString(e,t);if(!e.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(e,t)}};function g(s,e){if(s)switch(s.type){case"Identifier":e.add(s.name);return;case"ObjectPattern":for(let t of s.properties)t.type==="RestElement"?g(t.argument,e):g(t.value,e);return;case"ArrayPattern":for(let t of s.elements)g(t,e);return;case"AssignmentPattern":g(s.left,e);return;case"RestElement":g(s.argument,e);return}}function R(s){switch(s.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"NullLiteral":case"BigIntLiteral":case"RegExpLiteral":case"Identifier":return!0;case"Literal":return!0;case"TemplateLiteral":return s.expressions.every(R);case"UnaryExpression":return R(s.argument);case"MemberExpression":return!1;default:return!1}}function v(s,e){if(!(!s||typeof s!="object")){e(s);for(let t of Object.keys(s)){if(t==="loc"||t==="range"||t==="leadingComments"||t==="trailingComments")continue;let n=s[t];if(Array.isArray(n))for(let i of n)i&&typeof i=="object"&&v(i,e);else n&&typeof n=="object"&&typeof n.type=="string"&&v(n,e)}}}function ne(s){let e=new Set;return v(s,t=>{if(t.type==="AssignmentExpression")g(t.left,e);else if(t.type==="UpdateExpression"){let n=t.argument;n?.type==="Identifier"&&e.add(n.name)}}),e}function ie(s,e){let t=new Set,n=i=>{let r=new Set;g(i,r);for(let o of r)e.has(o)&&t.add(o)};return v(s,i=>{switch(i.type){case"VariableDeclarator":n(i.id);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":n(i.id);for(let r of i.params??[])n(r);return;case"CatchClause":n(i.param);return;case"ClassDeclaration":case"ClassExpression":n(i.id);return}}),t}function M(s,e,t){for(let n of s.properties??[]){if(n.type==="RestElement"){let h=n.argument;if(h?.type!=="Identifier"||e.length>0){let f=new Set;g(h,f);for(let E of f)t.bails.push({name:E,reason:"rest"});continue}t.rest={name:h.name,keys:[]};continue}if(n.computed){let h=new Set;g(n.value,h);for(let f of h)t.bails.push({name:f,reason:"computed"});continue}let i=n.key,r=i.type==="Identifier"?i.name:i.value,o=n.value,a;o.type==="AssignmentPattern"&&(a=o.right,o=o.left);let l=[...e,r];if(o.type==="Identifier"){if(a&&!R(a)){t.bails.push({name:o.name,reason:"unsafe-default"});continue}t.reads.push({name:o.name,path:l,...a?{fallback:a}:{}});continue}if(o.type==="ObjectPattern"){if(a){let h=new Set;g(o,h);for(let f of h)t.bails.push({name:f,reason:"unsafe-default"});continue}M(o,l,t);continue}let u=new Set;g(o,u);for(let h of u)t.bails.push({name:h,reason:"computed"})}}function T(s,e){let t={reads:[],bails:[]};if(s?.type!=="ObjectPattern"||(M(s,[],t),t.rest&&(e?.type!=="BlockStatement"?(t.bails.push({name:t.rest.name,reason:"rest"}),delete t.rest):t.rest.keys=(s.properties??[]).filter(a=>a.type!=="RestElement"&&!a.computed).map(a=>{let l=a.key;return l.type==="Identifier"?l.name:l.value})),t.reads.length===0&&!t.rest))return t;let n=new Set(t.reads.map(a=>a.name));t.rest&&n.add(t.rest.name);let i=ne(e),r=ie(e,n),o=[];for(let a of t.reads)i.has(a.name)?t.bails.push({name:a.name,reason:"reassigned"}):r.has(a.name)?t.bails.push({name:a.name,reason:"shadowed"}):o.push(a);return t.reads=o,t.rest&&i.has(t.rest.name)?(t.bails.push({name:t.rest.name,reason:"reassigned"}),delete t.rest):t.rest&&r.has(t.rest.name)&&(t.bails.push({name:t.rest.name,reason:"shadowed"}),delete t.rest),t}function F(s){switch(s){case"rest":return"this rest element cannot be served by splitProps, and copying the props into a plain object would lose the getters";case"computed":return"the property is not known until it runs";case"reassigned":return"the binding is assigned to, and props are read-only";case"shadowed":return"an inner scope binds the same name";case"unsafe-default":return"the default would have to run again on every read"}}function m(s,e){if(s)switch(s.type){case"Identifier":e.add(s.name);return;case"ObjectPattern":for(let t of s.properties)t.type==="RestElement"?m(t.argument,e):m(t.value,e);return;case"ArrayPattern":for(let t of s.elements)m(t,e);return;case"AssignmentPattern":m(s.left,e);return;case"RestElement":m(s.argument,e);return}}function U(s,e){switch(s.type){case"ImportDeclaration":for(let t of s.specifiers)m(t.local,e);return;case"VariableDeclaration":for(let t of s.declarations)m(t.id,e);return;case"FunctionDeclaration":case"ClassDeclaration":m(s.id,e);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":s.declaration&&U(s.declaration,e);return}}function q(s){let e=new Set;for(let t of s.body)U(t,e);return e}function S(s,e,t=null){if(!(!s||typeof s!="object"||typeof s.type!="string")&&!s.type.startsWith("TS")&&e(s,t)!==!1)for(let n of Object.keys(s)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let i=s[n];if(Array.isArray(i))for(let r of i)S(r,e,s);else i&&typeof i=="object"&&S(i,e,s)}}function G(s){return!!s&&s[0]>="A"&&s[0]<="Z"}function re(s){let e=[];return S(s,t=>{if(t.type==="FunctionDeclaration"&&G(t.id?.name)){e.push(t);return}if(t.type==="VariableDeclarator"&&G(t.id?.name)){let n=t.init;n&&(n.type==="ArrowFunctionExpression"||n.type==="FunctionExpression")&&e.push(n)}}),e}function oe(s){let e=new Set;return S(s,t=>{t.type==="Identifier"&&e.add(t.name)}),e}function ae(s,e){if(!e)return!0;switch(e.type){case"MemberExpression":case"OptionalMemberExpression":return!(e.property===s&&!e.computed);case"ObjectProperty":case"ObjectMethod":case"ClassProperty":case"ClassMethod":return!(e.key===s&&!e.computed);case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return e.label!==s;case"ImportSpecifier":case"ExportSpecifier":return!1;default:return!0}}function le(s,e,t={}){let n=[],i=[],r=new Set;for(let o of re(s)){let a=o.params?.[0];if(a?.type!=="ObjectPattern")continue;let l=T(a,o.body);for(let c of l.bails)i.push({name:c.name,reason:c.reason,message:F(c.reason),start:a.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let u=oe(o),h=t.parameterName??"props";for(;u.has(h);)h=`_${h}`;let f=new Map;for(let c of l.reads){let d=`${h}.${c.path.join(".")}`,p=c.fallback;f.set(c.name,p?`(${d} === undefined ? ${e.slice(p.start,p.end)} : ${d})`:d)}let E=a.typeAnnotation;if(n.push({start:a.start,end:E?.start??a.end,code:h}),l.rest){let c=l.rest.keys.map(p=>JSON.stringify(p)).join(", "),d=o.body;n.push({start:d.start+1,end:d.start+1,code:`
|
|
11
|
+
const [, ${l.rest.name}] = splitProps(${h}, [${c}]);`}),r.add("splitProps")}let I=[];S(o.body,(c,d)=>{if(c.type!=="Identifier")return;let p=f.get(c.name);if(!p)return;let P=d?.type==="ObjectProperty"&&d.shorthand&&d.value===c;if(!P&&!ae(c,d))return;let O=l.reads.find(J=>J.name===c.name).path;I.push({node:c,parent:P?d:null,text:p,property:O[O.length-1]})});for(let c of I)c.parent?n.push({start:c.parent.start,end:c.parent.end,code:`${c.node.name}: ${c.text}`}):n.push({start:c.node.start,end:c.node.end,code:c.text}),ue(c.node,h,c.property)}return{edits:n,diagnostics:i,used:r}}function ue(s,e,t){s.type="MemberExpression",s.computed=!1,s.optional=!1,s.object={type:"Identifier",name:e,start:s.start,end:s.start},s.property={type:"Identifier",name:t,start:s.end,end:s.end},delete s.name}function Se(s,e="module.tsx",t={}){let n=se(s,{sourceType:"module",plugins:["typescript","jsx"],errorRecovery:!0}),{edits:i,diagnostics:r,used:o}=le(n.program,s,t),a=new N(s);for(let l of i)l.start===l.end?a.appendLeft(l.start,l.code):a.overwrite(l.start,l.end,l.code);return o.has("splitProps")&&!q(n.program).has("splitProps")&&a.prepend(`import { splitProps } from ${JSON.stringify(t.runtimeModule??"@fluixi/dom")};
|
|
12
|
+
`),{code:a.toString(),map:a.generateMap({source:e,includeContent:!0,hires:!0}),diagnostics:r,rewritten:i.filter(l=>l.code!==(t.parameterName??"props")).length}}export{le as collectPropsEdits,Se as transformProps};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
"use strict";var je=Object.create;var L=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Be=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var He=(e,t)=>{for(var n in t)L(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of _e(t))!Fe.call(e,r)&&r!==n&&L(e,r,{get:()=>t[r],enumerable:!(o=De(t,r))||o.enumerable});return e};var Xe=(e,t,n)=>(n=e!=null?je(Be(e)):{},se(t||!e||!e.__esModule?L(n,"default",{value:e,enumerable:!0}):n,e)),ze=e=>se(L({},"__esModule",{value:!0}),e);var jt={};He(jt,{transformTemplates:()=>At});module.exports=ze(jt);var Pe=require("@babel/parser"),Ae=Xe(require("magic-string"),1);function qe(e){switch(e.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return e.reactive?"reactive-prop":e.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function x(e){let t=[],n=new Map,o=r=>{switch(r.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of r.children)o(s);return!1;case"fragment":for(let s of r.children)o(s);return!1;case"element":{let s=!0;for(let a of r.children)o(a)||(s=!1);let i;for(let a of r.props)if(i=qe(a),i)break;return!i&&!s&&(i=Ve(r)),r.static=!i,i?n.set(r,i):t.push(r),r.static}default:return!1}};for(let r of Array.isArray(e)?e:[e])o(r);return{staticElements:t,reasons:n}}function Ve(e){for(let t of e.children){if(t.kind==="expr")return"expression-child";if(t.kind==="component")return"component-child";if(t.kind==="control")return"control-child";if(t.kind==="element"&&!t.static||t.kind==="fragment")return"expression-child"}return"expression-child"}var J={kind:"eager"},We=["pointerdown","focusin","keydown"],ae=new Set(["eager","idle","visible","interaction","media","never"]),v=class extends Error{};function U(e){return e.startsWith("load:")}function j(e,t){let n=e.slice(5);if(!ae.has(n))throw new v(`Unknown load strategy 'load:${n}'. Expected one of ${[...ae].join(", ")}.`);switch(n){case"eager":return J;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return t?{kind:"visible",rootMargin:t}:{kind:"visible"};case"interaction":return{kind:"interaction",events:t?Ue(t):[...We]};case"media":if(!t)throw new v(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:t};default:throw new v(`Unhandled load strategy '${n}'.`)}}function Ue(e){let t=e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(t.length===0)throw new v("'load:interaction' was given no event names.");return t}function D(e){return e.kind!=="eager"&&e.kind!=="never"}var b=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],C=["Suspense","SuspenseList","Await"],N=["Router","Outlet","Redirect","Link"],Ft=[...b,...C,...N],G=new Set([...b,...C]);function le(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:o="@fluixi/core/router-next"}=e,r={};for(let s of b)r[s]=t;for(let s of C)r[s]=n;for(let s of N)r[s]=o;return r}function _(e,t={}){let{resolver:n,isBound:o,modules:r,strategyFor:s}=t,i=le(r),a=new Map,l=new Set,c=d=>{let{name:p}=d;if(!p||p.includes(".")||o?.(p))return;let f=u(p);if(!f){l.add(p);return}let g=f.origin==="builtin"&&G.has(p)?J:s?.(d)??J;d.source={...f,loading:g},a.set(p,d.source)},u=d=>{if(G.has(d))return{module:i[d],export:d,origin:"builtin"};let p=n?.resolve(d);if(p)return{module:p.module,export:p.export,origin:"rule"};if(N.includes(d))return{module:i[d],export:d,origin:"builtin"}};return B(e,d=>{d.kind==="component"&&c(d)}),{resolved:a,unresolved:[...l]}}function B(e,t){let n=Array.isArray(e)?e:[e];for(let o of n){t(o);let r=o.children;r&&B(r,t)}}function F(e){let t=[];B(e,s=>{s.kind==="component"&&s.source&&t.push(s)});let n=new Set,o=new Set;for(let s of t){let{module:i,loading:a}=s.source;a.kind==="eager"&&n.add(i),a.kind==="never"&&o.add(i)}let r=new Map;for(let s of t){let i=s.source;D(i.loading)&&n.has(i.module)&&(i.loading={kind:"eager"},r.set(i.module,(r.get(i.module)??0)+1))}return{collapsed:r,conflicted:[...o].filter(s=>n.has(s))}}var Ge=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ce={className:"class",htmlFor:"for"},Ke=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),Ye=new Set(["script","style","textarea","title"]);function K(e){return Ye.has(e)}function pe(e){return ce[e]??e}function I(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!Ke.has(e.name)}function Y(e){if(!e.static||K(e.tag))return!1;for(let t of e.props)if(!I(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&Y(t)))return!1;return!0}function w(e){let t=e.props.map(Qe).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return Ge.has(e.tag)?n:`${n}${e.children.map(Ze).join("")}</${e.tag}>`}function Ze(e){if(e.kind==="text")return tt(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return w(e)}function Qe(e){let t=ce[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${et(String(n))}"`}function et(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function tt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var nt="<!--fx-->",rt="<!--fx/-->";function X(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function ot(e){return e.kind==="text"||e.kind==="element"&&ue(e)}function ue(e){return e.svg||K(e.tag)||!e.props.every(t=>I(t))?!1:e.children.every(t=>ot(t)||X(t))}function H(e){if(X(e))return!0;let t=e.children;return t?t.some(H):!1}function de(e){for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.kind==="text"&&(n.value===""||e.children[t+1]?.kind==="text"))return!1}return e.children.every(t=>t.kind!=="element"||de(t))}function me(e){if(!ue(e)||!de(e)||!e.children.some(H))return null;let t=[],n=[],o=0,r=i=>{let a=`_n$${o++}`;return t.push({ref:a,expr:i}),a};return s(e,"_el$"),{html:it(e),tag:e.tag,steps:t,holes:n};function s(i,a){let l=-1;i.children.forEach((u,d)=>{H(u)&&(l=d)});let c=null;for(let u=0;u<=l;u++){let d=i.children[u],p=c?`${c}.nextSibling`:`${a}.firstChild`;if(X(d)){let g=r(p),P=r(`holeEnd(${g})`);n.push({parentRef:a,startRef:g,endRef:P,node:d}),c=P;continue}let f=r(p);d.kind==="element"&&H(d)&&s(d,f),c=f}}}function it(e){return w(fe(e)).split(ge).join(nt+rt)}function fe(e){return{...e,children:e.children.map(t=>X(t)?{kind:"text",value:ge}:t.kind==="element"?fe(t):t)}}var ge="\0fx-hole\0";var Z={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},Zt={version:2,module:"@fluixi/dom",symbols:[...Z.symbols,"template","cloneTemplate","walk"]};var st={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function at(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function ve(e){return at(e)?e:JSON.stringify(e)}function lt(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function ct(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function pt(e,t,n){let o=e.filter(a=>a.kind==="spread"),s=e.filter(a=>a.kind!=="spread").map(a=>`${ve(a.name)}: ${lt(a)}`);t!=null&&s.push(`children: ${t}`);let i=`{ ${s.join(", ")} }`;return o.length>0?(n.add("mergeProps"),`mergeProps(${o.map(a=>a.expr).join(", ")}, ${i})`):i}function Re(e,t,n){return e.length===1?T(e[0],t,n):`[${e.map(o=>T(o,t,n)).join(", ")}]`}function he(e,t,n,o,r){o.add("createMemo"),o.add("createComponent");let s=t.filter(c=>c.kind==="spread"),a=t.filter(c=>c.kind!=="spread").map(c=>`get ${ve(c.name)}() { return ${ct(c)}; }`);n.length>0&&a.push(`get children() { return ${Re(n,o,r)}; }`);let l=`{ ${a.join(", ")} }`;return s.length>0&&(o.add("mergeProps"),l=`mergeProps(${s.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${e}, ${l}))`}function ut(e,t){let n=pe(t.name),o=t.literal;return o===!0||o===void 0?`${e}.setAttribute(${JSON.stringify(n)}, "");`:o===!1||o===null?"":`${e}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(o))});`}var ye=!1;function T(e,t,n){switch(e.kind){case"text":return JSON.stringify(e.value);case"expr":return e.reactive?`() => (${e.code})`:`(${e.code})`;case"fragment":return e.children.length===0?"null":Re(e.children,t,n);case"component":return he(e.name,e.props,e.children,t,n);case"control":{let o=st[e.control]??e.control;return t.add(o),he(o,e.props,e.children,t,n)}case"element":{if(n&&e.static&&!e.svg&&Y(e)){t.add("templateNode");let a=`_tmpl$${n.length}`;return n.push({id:a,html:w(e),tag:e.tag,svg:!1}),`templateNode(${a}, ${JSON.stringify(e.tag)})`}if(n&&ye){let a=me(e);if(a){t.add("templateNode"),t.add("insert"),t.add("holeEnd"),t.add("holeContent"),t.add("holeScope");let l=`_tmpl$${n.length}`;n.push({id:l,html:a.html,tag:a.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(a.tag)}, true);`];for(let u of a.steps)c.push(`const ${u.ref} = ${u.expr};`);for(let u of a.holes)c.push(`insert(${u.parentRef}, holeScope(${u.startRef}, () => (${T(u.node,t,n)})), ${u.endRef}, holeContent(${u.startRef}, ${u.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}t.add("createNativeElement");let o=JSON.stringify(e.tag),r="_el$",s=[],i=e.svg?`${o}, true`:o;if(s.push(`const ${r} = createNativeElement(${i});`),e.props.length>0)if(!e.svg&&e.props.every(I))for(let a of e.props)s.push(ut(r,a));else{t.add("spread");let a=e.svg?", isSVG: true":"";s.push(`spread({ element: ${r}, props: ${pt(e.props,null,t)}${a} });`)}for(let a of e.children){t.add("insert");let l=T(a,t,n),c=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(c?`insert(${r}, ${l}, null);`:`insert(${r}, ${l});`)}return s.push(`return ${r};`),`(() => { ${s.join(" ")} })()`}}}function z(e,t){if(!t||t.length===0)return e;let n=new Map(t.map(o=>[o.id,JSON.stringify(o.html)]));return e.replace(/_tmpl\$\d+/g,o=>n.get(o)??o)}var k={name:"imperative",contract:Z,emit(e,t){let n=new Set,o=t?.templateClone!==!1?[]:void 0;return ye=t?.partialTemplates===!0,{code:T(e,n,o),imports:Array.from(n),templates:o}}};var dt=e=>"components"in e;function xe(e,t){return e.replace(/\$(\d+)/g,(n,o)=>t[Number(o)]??n)}function mt(e,t){return typeof t=="string"?{module:t,export:e}:t}function q(e=[]){let t=new Map,n=[],o=[];for(let i of e){if(!dt(i)){o.push(i);continue}for(let[a,l]of Object.entries(i.components)){let c=mt(a,l),u=t.get(a);if(u&&u.module!==c.module){let d=n.find(p=>p.name===a);d?d.modules.push(c.module):n.push({name:a,modules:[u.module,c.module]});continue}t.set(a,c)}}let r=new Map;return{resolve:i=>{if(r.has(i))return r.get(i);let a=t.get(i);if(!a)for(let l of o){let c=i.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){a={module:xe(l.module,c),export:l.export?xe(l.export,c):i};break}}return r.set(i,a),a},names:()=>[...t.keys()],conflicts:()=>n}}var Ee=require("@fluixi/template-parser");function $(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let r=0;r<t.length;r++)/[^ \t]/.test(t[r])&&(n=r);let o="";for(let r=0;r<t.length;r++){let s=t[r].replace(/\t/g," ");r!==0&&(s=s.replace(/^ +/,"")),r!==t.length-1&&(s=s.replace(/ +$/,"")),s&&(r!==n&&(s+=" "),o+=s)}return o}var Ne=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function ft(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function ke(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Q=class{constructor(t,n){this.holes=t;this.used=n}hole(t){return this.holes[t]??{code:"undefined",reactive:!1}}emit(t){let{code:n,imports:o,templates:r}=k.emit(t,{});for(let s of o)this.used.add(s);return z(n,r)}lowerRoot(t){let n=this.lowerChildren(t);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(t){let n=[];for(let o=0;o<t.length;o++){let r=t[o];if(r.kind==="Element"||r.kind==="Component"){let i=r.attributes.find(a=>a.kind==="IfDirective");if(i&&i.kind==="IfDirective"){let a=o+1;a<t.length&&this.isBlankText(t[a])&&a++;let l=t[a],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(u=>u.kind==="ElseDirective");n.push(this.lowerIf(r,i.hole,c?l:null)),c&&(o=a);continue}if(r.attributes.some(a=>a.kind==="EachDirective")){n.push(this.lowerEach(r));continue}}let s=this.lowerNode(r);s&&n.push(s)}return n}isBlankText(t){return t.kind==="Text"&&!t.raw&&$(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let n=$(t.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(t.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(t.children)};case"Element":return this.lowerElement(t);case"Component":return this.lowerComponent(t);default:return null}}lowerElement(t){let n=t.attributes.find(o=>o.kind==="Attribute"&&o.name==="is");if(t.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let o=t.attributes.filter(s=>s!==n),r=this.lowerComponent({...t,kind:"Component",tag:"Dynamic",tagHole:null,attributes:o});return r.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),r}return{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:this.lowerAttributes(t.attributes),children:this.lowerChildren(t.children),static:!1}}lowerComponent(t){let n=t.tagHole!=null?this.hole(t.tagHole).code:t.tag,o=this.lowerAttributes(t.attributes),{slots:r,rest:s}=this.partitionSlots(t.children);for(let[l,c]of r){let u=c.length===1?c[0]:{kind:"fragment",children:c},d={name:l,kind:"attr",expr:this.emit(u),jsxElement:!0},p=o.findIndex(f=>f.name===l);p>=0?o[p]=d:o.push(d)}let i=t.attributes.find(l=>l.kind==="LoadDirective"),a=i?j(`load:${i.strategy}`,i.modifier):void 0;return{kind:"component",name:n,props:o,children:this.lowerChildren(s),...a?{load:a}:{}}}partitionSlots(t){let n=new Map,o=[];for(let r of t){if(r.kind==="Element"||r.kind==="Component"){let s=r.attributes.find(i=>i.kind==="Attribute"&&i.name==="slot");if(s&&s.value&&s.value.kind==="static"){let i={...r,attributes:r.attributes.filter(c=>c!==s)},a=i.kind==="Element"?this.lowerElement(i):this.lowerComponent(i),l=n.get(s.value.value)??[];l.push(a),n.set(s.value.value,l);continue}}o.push(r)}return{slots:n,rest:o}}lowerIf(t,n,o){let r=this.hole(n),s=[{name:"when",kind:"attr",expr:r.code,reactive:r.reactive}];if(o){let a=this.stripAndLower(o,l=>l.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(a),jsxElement:!0})}let i=this.stripAndLower(t,a=>a.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[i]}}lowerEach(t){let n=t.attributes.find(l=>l.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(t);let o=this.hole(n.hole),r=[{name:"each",kind:"attr",expr:o.code,reactive:o.reactive}];if(n.key){let l="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;r.push({name:"by",kind:"attr",expr:l})}let s=this.itemArrow(t),i;if(s){let l={kind:"expr",code:s.body,reactive:s.bodyReactive},c=this.rebuildWithChildren(t,[l]);i=`(${s.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(t,c=>c.kind==="EachDirective");i=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:r,children:[{kind:"expr",code:i,reactive:!1}]}}itemArrow(t){let n=t.children.filter(o=>!this.isBlankText(o));return n.length!==1||n[0].kind!=="Expression"?null:this.hole(n[0].hole).arrow??null}stripAndLower(t,n){let o={...t,attributes:t.attributes.filter(r=>!n(r))};return o.kind==="Element"?this.lowerElement(o):this.lowerComponent(o)}rebuildWithChildren(t,n){let o=this.lowerAttributes(t.attributes.filter(r=>r.kind!=="EachDirective"));return t.kind==="Element"?{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:o,children:n,static:!1}:{kind:"component",name:t.tag,props:o,children:n}}lowerAttributes(t){let n=[],o=[],r=!1,s=[],i=!1,a=[];for(let l of t)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(l));break;case"PropertyBinding":n.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":n.push(this.eventProp(l));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let c=this.hole(l.hole);o.push(`${JSON.stringify(l.name)}: ${c.code}`),r=r||c.reactive;break}case"StyleDirective":{let c=this.hole(l.hole);s.push(`${JSON.stringify(l.name)}: ${c.code}`),i=i||c.reactive;break}case"BindDirective":n.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let c=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!c)break;a.push(l.name!=null&&l.hole!=null?`[${c}, () => (${this.hole(l.hole).code})]`:`[${c}]`);break}}return o.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${o.join(", ")} }`,reactive:r}),s.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:i}),a.length>0&&n.push({name:"use",kind:"attr",expr:`[${a.join(", ")}]`}),n}eventProp(t){let n=t.name.toLowerCase(),o=this.hole(t.hole).code;if(!(t.syntax==="colon"||t.modifiers.length>0))return{name:"on"+ke(t.name),kind:"event",event:{name:n,delegated:Ne.has(n)},expr:o};let s=this.wrapHandler(o,t.modifiers),i=this.eventOptions(t.modifiers),a=i?`[${s}, ${i}]`:s;return{name:"on:"+n,kind:"attr",expr:a}}wrapHandler(t,n){let o=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",r=[];return n.includes("prevent")&&r.push("e.preventDefault();"),n.includes("stop")&&r.push("e.stopPropagation();"),!o&&r.length===0?t:`(e) => { ${o}${r.join(" ")} return (${t})(e); }`}eventOptions(t){let n=[];return t.includes("capture")&&n.push("capture: true"),t.includes("once")&&n.push("once: true"),t.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(t,n){let o=t==="checked",r=o?"change":"input",s=o?"checked":"value",i=`(${n})`;return[{name:t,kind:"attr",expr:`${i}[0]()`,reactive:!0},{name:"on"+ke(r),kind:"event",event:{name:r,delegated:Ne.has(r)},expr:`(e) => ${i}[1](e.target.${s})`}]}plainAttr(t){let n=t.value,o=t.name;t.name==="class"?o=n&&n.kind==="hole"&&this.hole(n.hole).object?"classList":"className":t.name==="html"&&(o="innerHTML");let s={name:o,kind:"attr"};if(n==null)return s.literal=!0,s;if(n.kind==="static")return s.literal=n.value,s;if(n.kind==="hole"){let l=this.hole(n.hole);return s.expr=l.code,s.reactive=l.reactive,s}let i=!1,a=n.parts.map(l=>{if("text"in l)return ft(l.text);let c=this.hole(l.hole);return i=i||c.reactive,"${"+c.code+"}"}).join("");return s.expr="`"+a+"`",s.reactive=i,s}};function Se(e,t,n,o={}){let{root:r}=(0,Ee.parseTemplate)(e,{svg:o.svg});return new Q(t,n).lowerRoot(r.children)}function be(e,t,n={}){let o=new Set,r=Se(e,[...t],o,{svg:n.svg});x(r),_(r,{resolver:q(n.resolve??[]),modules:{controlFlowModule:n.controlFlowModule??"@fluixi/dom",coreModule:n.coreModule??"@fluixi/core",routerModule:n.routerModule??"@fluixi/core/router-next"},strategyFor:l=>l.load}),F(r);let{code:s,imports:i,templates:a}=k.emit(r,{templateClone:n.templateClone,partialTemplates:n.partialTemplates});for(let l of i)o.add(l);return n.hoistTemplates?{code:s,imports:[...o],ir:r,templates:a}:{code:z(s,a),imports:[...o],ir:r}}var gt="children";function E(e){switch(e.kind){case"call":return!0;case"member":return e.property!==gt;case"compound":return e.parts.some(E);case"opaque":return!1}}var ht=new Set(["CallExpression","OptionalCallExpression"]),vt=new Set(["MemberExpression","OptionalMemberExpression"]);function S(e){if(!e)return{kind:"opaque"};if(ht.has(e.type))return{kind:"call"};if(vt.has(e.type)){let t=e.property;return{kind:"member",property:!(e.computed===!0)&&t?.type==="Identifier"?t.name:null}}return e.type==="ConditionalExpression"?{kind:"compound",parts:[e.test,e.consequent,e.alternate].map(M)}:e.type==="LogicalExpression"||e.type==="BinaryExpression"?{kind:"compound",parts:[e.left,e.right].map(M)}:e.type==="TemplateLiteral"?{kind:"compound",parts:e.expressions.map(M)}:e.type==="ObjectExpression"?{kind:"compound",parts:e.properties.filter(n=>(n.type==="ObjectProperty"||n.type==="Property")&&n.computed!==!0).map(n=>M(n.value))}:e.type==="ArrayExpression"?{kind:"compound",parts:e.elements.filter(n=>n!=null&&n.type!=="SpreadElement").map(M)}:{kind:"opaque"}}var M=e=>S(e);var Rt=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),yt=/^on[A-Z]/,xt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]),we=e=>E(S(e));function O(e){if(e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral"||e.type==="Literal"&&(typeof e.value=="string"||typeof e.value=="number"||typeof e.value=="boolean"))return e.value}var ee=e=>!!e&&typeof O(e)=="string";function Nt(e,t){return e.type==="JSXIdentifier"?{tag:e.name,component:e.name[0]!==e.name[0].toLowerCase()}:e.type==="JSXMemberExpression"?{tag:t.code(e),component:!0}:e.type==="JSXNamespacedName"?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function te(e){return e.type==="JSXIdentifier"?e.name==="class"?"className":e.name:e.type==="JSXNamespacedName"?`${e.namespace.name}:${e.name.name}`:"unknown"}function kt(e,t){let n=te(e.name),o=yt.test(n),r=o||n.startsWith("on:")||n==="ref",i={name:n,kind:o?"event":"attr"};if(o){let l=n.slice(2).toLowerCase();i.event={name:l,delegated:xt.has(l)}}let a=e.value;if(a==null)return i.literal=!0,i;if(ee(a))return i.literal=O(a),i;if(a.type==="JSXExpressionContainer"&&a.expression?.type!=="JSXEmptyExpression"){let l=a.expression,c=O(l);return c!==void 0?(i.literal=c,i):(i.expr=t.code(l),i.reactive=r?!1:we(l),(l.type==="JSXElement"||l.type==="JSXFragment")&&(i.jsxElement=!0),i)}return i.literal=!0,i}function Ce(e,t){let n=e.value;return n==null?null:ee(n)?JSON.stringify(O(n)):n.type==="JSXExpressionContainer"&&n.expression?.type!=="JSXEmptyExpression"?t.code(n.expression):null}function Et(e,t){let n=[],o=[];for(let r of e){if(r.type==="JSXSpreadAttribute"){n.push({name:"",kind:"spread",expr:t.code(r.argument)});continue}if(r.type!=="JSXAttribute"||U(te(r.name)))continue;let s=r.name.type==="JSXNamespacedName"?r.name.namespace.name:null;if(s==="use"){let i=r.name.name.name;t.used.add(i);let a=Ce(r,t);o.push(a!=null?`[${i}, () => (${a})]`:`[${i}]`);continue}if(s==="oncapture"){let i=r.name.name.name.toLowerCase(),a=Ce(r,t)??"undefined";n.push({name:"on:"+i,kind:"attr",expr:`[${a}, { capture: true }]`});continue}n.push(kt(r,t))}return o.length>0&&n.push({name:"use",kind:"attr",expr:`[${o.join(", ")}]`}),n}function Ie(e,t){let n=[];for(let o of e)if(o.type==="JSXText"){let r=$(o.value);r&&n.push({kind:"text",value:r})}else if(o.type==="JSXExpressionContainer"){if(o.expression?.type!=="JSXEmptyExpression"){let r=o.expression;n.push({kind:"expr",code:t.code(r),reactive:we(r)})}}else o.type==="JSXElement"||o.type==="JSXFragment"?n.push(Te(o,t)):o.type==="JSXSpreadChild"&&n.push({kind:"expr",code:t.code(o.expression),reactive:!1});return n}function St(e){for(let t of e){if(t.type!=="JSXAttribute")continue;let n=te(t.name);if(U(n)){if(t.value&&!ee(t.value))throw new v(`'${n}' needs a literal value, not an expression — the strategy is compile-time.`);return j(n,t.value?O(t.value):null)}}}function Te(e,t){if(e.type==="JSXFragment")return{kind:"fragment",children:Ie(e.children,t)};let{tag:n,component:o}=Nt(e.openingElement.name,t),r=Et(e.openingElement.attributes,t),s=Ie(e.children,t);if(o){let i=St(e.openingElement.attributes);return{kind:"component",name:n,props:r,children:s,...i?{load:i}:{}}}return{kind:"element",tag:n,svg:Rt.has(n),props:r,children:s,static:!1}}function $e(e,t){let n=Te(e,t);return x(n),n}function R(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties)n.type==="RestElement"?R(n.argument,t):R(n.value,t);return;case"ArrayPattern":for(let n of e.elements)R(n,t);return;case"AssignmentPattern":R(e.left,t);return;case"RestElement":R(e.argument,t);return}}function Me(e,t){switch(e.type){case"ImportDeclaration":for(let n of e.specifiers)R(n.local,t);return;case"VariableDeclaration":for(let n of e.declarations)R(n.id,t);return;case"FunctionDeclaration":case"ClassDeclaration":R(e.id,t);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":e.declaration&&Me(e.declaration,t);return}}function Oe(e){let t=new Set;for(let n of e.body)Me(n,t);return t}var bt=new Set(b),Ct=new Set(C),It=new Set(N),wt=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]);function ne(e,t,n=null,o=""){if(!(!e||typeof e!="object")){if(Array.isArray(e)){for(let r of e)ne(r,t,n,o);return}typeof e.type=="string"&&t(e,n,o);for(let r of Object.keys(e))r==="loc"||r==="leadingComments"||r==="trailingComments"||ne(e[r],t,typeof e.type=="string"?e:n,r)}}var re=e=>e.type==="JSXElement"||e.type==="JSXFragment";function Tt(e,t,n){return re(e)?!(t&&re(t)&&n==="children"):!1}function $t(e,t){return e.type==="TaggedTemplateExpression"&&e.tag?.type==="Identifier"&&(e.tag.name===t||e.tag.name==="svg")}function Le(e){return e.filter(t=>!e.some(n=>n!==t&&n.start<=t.start&&n.end>=t.end&&n.end-n.start>t.end-t.start))}function V(e,t,n,o){let r=Le(o.filter(i=>i.start>=t&&i.end<=n)).sort((i,a)=>a.start-i.start),s=e.slice(t,n);for(let i of r)s=s.slice(0,i.start-t)+i.code+s.slice(i.end-t);return s}function Mt(e,t,n){let o={code:V(e,t.start,t.end,n),reactive:E(S(t))};return t.type==="ArrowFunctionExpression"&&t.body?.type!=="BlockStatement"&&(o.arrow={params:t.params.map(r=>V(e,r.start,r.end,n)),body:V(e,t.body.start,t.body.end,n),bodyReactive:E(S(t.body))}),t.type==="ObjectExpression"&&(o.object=!0),o}function Je(e,t,n){if(!t||t.length===0)return e;let o=new Map;for(let r of t){let s=`${r.svg?"svg:":""}${r.html}`,i=n.get(s);i||(i=`_fxTmpl$${n.size}`,n.set(s,i)),o.set(r.id,i)}return e.replace(/_tmpl\$\d+/g,r=>o.get(r)??r)}function oe(e,t){if(e.kind==="component"&&e.source){let n=e.source;n.origin==="builtin"?t.builtins.add(e.name):D(n.loading)&&!t.resolved.has(e.name)?t.deferred.set(e.name,n):(t.deferred.delete(e.name),t.resolved.set(e.name,n))}if("props"in e&&e.props)for(let n of e.props)n.kind==="event"&&n.event?.delegated&&t.delegatedEvents.add(n.event.name);if("children"in e&&e.children)for(let n of e.children)oe(n,t)}function Ot(e){let t=[`kind: ${JSON.stringify(e.kind)}`];return e.kind==="visible"&&e.rootMargin&&t.push(`rootMargin: ${JSON.stringify(e.rootMargin)}`),e.kind==="interaction"&&t.push(`events: ${JSON.stringify(e.events)}`),e.kind==="media"&&t.push(`query: ${JSON.stringify(e.query)}`),`{ ${t.join(", ")} }`}function Pt(e){let t=[];return e.quasi.quasis.forEach((n,o)=>{if(t.push({kind:"static",text:n.value.cooked??n.value.raw,start:n.start}),o<e.quasi.expressions.length){let r=e.quasi.expressions[o];t.push({kind:"hole",index:o,start:r.start,end:r.end})}}),t}function At(e,t,n={}){let o=n.litTag??"html",r=n.format??"both",s=r!=="jsx",i=r!=="lit";if(!(s&&(e.includes(`${o}\``)||e.includes("svg`")))&&!(i&&e.includes("<")))return null;let l=(0,Pe.parse)(e,{sourceType:"module",plugins:["jsx","typescript"],errorRecovery:!0}),c=[];if(ne(l.program,(m,y,W)=>{(s&&$t(m,o)||i&&Tt(m,y,W))&&c.push(m)}),c.length===0)return null;c.sort((m,y)=>y.start-m.start||m.end-y.end);let u=new Set,d={builtins:new Set,resolved:new Map,deferred:new Map,delegatedEvents:new Set},p=new Map,f=[];for(let m of c){let y=c.some(h=>h!==m&&h.start<=m.start&&h.end>=m.end&&h.end-h.start>m.end-m.start);if(re(m)){f.push({start:m.start,end:m.end,code:Lt(e,m,f,y,u,d,p,n)});continue}let W=m.quasi.expressions.map(h=>Mt(e,h,f)),A=be(Pt(m),W,{...n,hoistTemplates:!0,templateClone:n.templateClone??!0,partialTemplates:y?!1:n.partialTemplates??!0,svg:m.tag.name==="svg"});for(let h of A.imports)u.add(h);oe(A.ir,d),f.push({start:m.start,end:m.end,code:Je(A.code,A.templates,p)})}let g=new Ae.default(e);for(let m of Le(f))g.overwrite(m.start,m.end,m.code);let P=Oe(l.program),ie=Jt(u,d,p,P,n);ie&&g.prepend(ie);for(let m of l.program.body)m.type==="ImportDeclaration"&&m.source?.value==="@fluixi/core/rx"&&g.overwrite(m.source.start,m.source.end,JSON.stringify("@fluixi/reactive"));return{code:g.toString(),map:g.generateMap({source:t,includeContent:!0,hires:!0})}}function Lt(e,t,n,o,r,s,i,a){let l=$e(t,{code:u=>V(e,u.start,u.end,n),used:r});x(l),_(l,{resolver:q(a.resolve??[]),modules:{controlFlowModule:a.controlFlowModule??a.runtimeModule??"@fluixi/dom",coreModule:a.coreModule??"@fluixi/core",routerModule:a.routerModule??"@fluixi/core/router-next"},strategyFor:u=>u.load}),F(l);let c=k.emit(l,{templateClone:a.templateClone??!0,partialTemplates:o?!1:a.partialTemplates??!0});for(let u of c.imports)r.add(u);return oe(l,s),Je(c.code,c.templates,i)}function Jt(e,t,n,o,r){let s=r.runtimeModule??"@fluixi/dom",i=r.coreModule??"@fluixi/core",a=new Map,l=(p,f)=>a.set(p,[...a.get(p)??[],f]),c=new Set(e);for(let p of t.builtins)c.add(p);t.delegatedEvents.size>0&&c.add("delegateEvents");for(let p of[...c].sort())o.has(p)||(wt.has(p)?l(r.reactiveModule??"@fluixi/reactive/signal",p):It.has(p)?l(r.routerModule??"@fluixi/core/router-next",p):Ct.has(p)?l(i,p):bt.has(p)?l(r.controlFlowModule??s,p):l(s,p));for(let[p,f]of t.resolved)o.has(p)||l(f.module,f.export==="default"?`default as ${p}`:p===f.export?p:`${f.export} as ${p}`);let u=[];for(let[p,f]of a)u.push(`import { ${f.join(", ")} } from ${JSON.stringify(p)};`);let d=[...t.deferred].filter(([p])=>!o.has(p));if(d.length>0){o.has("deferred")||u.push(`import { deferred } from ${JSON.stringify(i)};`);for(let[p,f]of d)u.push(`const ${p} = deferred(() => import(${JSON.stringify(f.module)}), { strategy: ${Ot(f.loading)}, export: ${JSON.stringify(f.export)} });`)}for(let[p,f]of n)u.push(`const ${f} = ${JSON.stringify(p.startsWith("svg:")?p.slice(4):p)};`);return t.delegatedEvents.size>0&&u.push(`delegateEvents(${JSON.stringify([...t.delegatedEvents])});`),u.length>0?u.join(`
|
|
1
|
+
"use strict";var ht=Object.create;var K=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var vt=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var Rt=(e,t)=>{for(var n in t)K(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Nt(t))!xt.call(e,o)&&o!==n&&K(e,o,{get:()=>t[o],enumerable:!(r=yt(t,o))||r.enumerable});return e};var Ee=(e,t,n)=>(n=e!=null?ht(vt(e)):{},Ie(t||!e||!e.__esModule?K(n,"default",{value:e,enumerable:!0}):n,e)),kt=e=>Ie(K({},"__esModule",{value:!0}),e);var Pn={};Rt(Pn,{transformTemplates:()=>Cn});module.exports=kt(Pn);var dt=require("@babel/parser"),ut=Ee(require("magic-string"),1);function bt(e){switch(e.kind){case"event":return"event";case"ref":return"ref";case"spread":return"spread";case"class":case"style":return"class-or-style-directive";case"attr":case"prop":return e.reactive?"reactive-prop":e.expr!==void 0?"expression-prop":void 0;default:return"expression-prop"}}function P(e){let t=[],n=new Map,r=o=>{switch(o.kind){case"text":return!0;case"expr":return!1;case"component":case"control":for(let s of o.children)r(s);return!1;case"fragment":for(let s of o.children)r(s);return!1;case"element":{let s=!0;for(let a of o.children)r(a)||(s=!1);let i;for(let a of o.props)if(i=bt(a),i)break;return!i&&!s&&(i=St(o)),o.static=!i,i?n.set(o,i):t.push(o),o.static}default:return!1}};for(let o of Array.isArray(e)?e:[e])r(o);return{staticElements:t,reasons:n}}function St(e){for(let t of e.children){if(t.kind==="expr")return"expression-child";if(t.kind==="component")return"component-child";if(t.kind==="control")return"control-child";if(t.kind==="element"&&!t.static||t.kind==="fragment")return"expression-child"}return"expression-child"}var G={kind:"eager"},It=["pointerdown","focusin","keydown"],we=new Set(["eager","idle","visible","interaction","media","never"]),E=class extends Error{};function le(e){return e.startsWith("load:")}function Z(e,t){let n=e.slice(5);if(!we.has(n))throw new E(`Unknown load strategy 'load:${n}'. Expected one of ${[...we].join(", ")}.`);switch(n){case"eager":return G;case"idle":return{kind:"idle"};case"never":return{kind:"never"};case"visible":return t?{kind:"visible",rootMargin:t}:{kind:"visible"};case"interaction":return{kind:"interaction",events:t?Et(t):[...It]};case"media":if(!t)throw new E(`'load:media' needs a query, e.g. load:media="(min-width: 1024px)".`);return{kind:"media",query:t};default:throw new E(`Unhandled load strategy '${n}'.`)}}function Et(e){let t=e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean);if(t.length===0)throw new E("'load:interaction' was given no event names.");return t}function L(e){return e.kind!=="eager"&&e.kind!=="never"}var j=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],J=["Suspense","SuspenseList","Await"],M=["Router","Outlet","Redirect","Link"],An=[...j,...J,...M],ce=new Set([...j,...J]);function Ce(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:n="@fluixi/core",routerModule:r="@fluixi/core/router-next"}=e,o={};for(let s of j)o[s]=t;for(let s of J)o[s]=n;for(let s of M)o[s]=r;return o}function Y(e,t={}){let{resolver:n,isBound:r,modules:o,strategyFor:s}=t,i=Ce(o),a=new Map,l=new Set,c=f=>{let{name:u}=f;if(!u||u.includes(".")||r?.(u))return;let g=p(u);if(!g){l.add(u);return}let m=g.origin==="builtin"&&ce.has(u)?G:s?.(f)??G;f.source={...g,loading:m},a.set(u,f.source)},p=f=>{if(ce.has(f))return{module:i[f],export:f,origin:"builtin"};let u=n?.resolve(f);if(u)return{module:u.module,export:u.export,origin:"rule"};if(M.includes(f))return{module:i[f],export:f,origin:"builtin"}};return Q(e,f=>{f.kind==="component"&&c(f)}),{resolved:a,unresolved:[...l]}}function Q(e,t){let n=Array.isArray(e)?e:[e];for(let r of n){t(r);let o=r.children;o&&Q(o,t)}}function ee(e){let t=[];Q(e,s=>{s.kind==="component"&&s.source&&t.push(s)});let n=new Set,r=new Set;for(let s of t){let{module:i,loading:a}=s.source;a.kind==="eager"&&n.add(i),a.kind==="never"&&r.add(i)}let o=new Map;for(let s of t){let i=s.source;L(i.loading)&&n.has(i.module)&&(i.loading={kind:"eager"},o.set(i.module,(o.get(i.module)??0)+1))}return{collapsed:o,conflicted:[...r].filter(s=>n.has(s))}}var wt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e={className:"class",htmlFor:"for"},Ct=new Set(["innerHTML","outerHTML","innerText","textContent","value","checked","selected","muted","defaultValue","defaultChecked","children","ref"]),$t=new Set(["script","style","textarea","title"]);function pe(e){return $t.has(e)}function Te(e){return $e[e]??e}function B(e){return e.kind!=="attr"||e.expr!==void 0||e.name.includes(":")?!1:!Ct.has(e.name)}function de(e){if(!e.static||pe(e.tag))return!1;for(let t of e.props)if(!B(t))return!1;for(let t of e.children)if(t.kind!=="text"&&!(t.kind==="element"&&de(t)))return!1;return!0}function _(e){let t=e.props.map(Pt).filter(Boolean).join(""),n=`<${e.tag}${t}>`;return wt.has(e.tag)?n:`${n}${e.children.map(Tt).join("")}</${e.tag}>`}function Tt(e){if(e.kind==="text")return Ot(e.value);if(e.kind!=="element")throw new Error(`serializeStatic: unexpected ${e.kind}`);return _(e)}function Pt(e){let t=$e[e.name]??e.name,n=e.literal;return n===!0||n===void 0?` ${t}`:n===!1||n===null?"":` ${t}="${Mt(String(n))}"`}function Mt(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ot(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var Dt="<!--fx-->",At="<!--fx/-->";function ne(e){return e.kind==="expr"||e.kind==="component"||e.kind==="control"}function Lt(e){return e.kind==="text"||e.kind==="element"&&Pe(e)}function Pe(e){return e.svg||pe(e.tag)||!e.props.every(t=>B(t))?!1:e.children.every(t=>Lt(t)||ne(t))}function te(e){if(ne(e))return!0;let t=e.children;return t?t.some(te):!1}function Me(e){for(let t=0;t<e.children.length;t++){let n=e.children[t];if(n.kind==="text"&&(n.value===""||e.children[t+1]?.kind==="text"))return!1}return e.children.every(t=>t.kind!=="element"||Me(t))}function Oe(e){if(!Pe(e)||!Me(e)||!e.children.some(te))return null;let t=[],n=[],r=0,o=i=>{let a=`_n$${r++}`;return t.push({ref:a,expr:i}),a};return s(e,"_el$"),{html:jt(e),tag:e.tag,steps:t,holes:n};function s(i,a){let l=-1;i.children.forEach((p,f)=>{te(p)&&(l=f)});let c=null;for(let p=0;p<=l;p++){let f=i.children[p],u=c?`${c}.nextSibling`:`${a}.firstChild`;if(ne(f)){let m=o(u),h=o(`holeEnd(${m})`);n.push({parentRef:a,startRef:m,endRef:h,node:f}),c=h;continue}let g=o(u);f.kind==="element"&&te(f)&&s(f,g),c=g}}}function jt(e){return _(De(e)).split(Ae).join(Dt+At)}function De(e){return{...e,children:e.children.map(t=>ne(t)?{kind:"text",value:Ae}:t.kind==="element"?De(t):t)}}var Ae="\0fx-hole\0";var ue={version:1,module:"@fluixi/dom",symbols:["createNativeElement","insert","spread","setAttribute","delegateEvents","createComponent","createMemo","untrack","Show","For","Index","Switch","Match","Dynamic","ErrorBoundary"]},zn={version:2,module:"@fluixi/dom",symbols:[...ue.symbols,"template","cloneTemplate","walk"]};var Jt={show:"Show",for:"For",index:"Index",switch:"Switch",match:"Match",dynamic:"Dynamic",errorBoundary:"ErrorBoundary",suspense:"Suspense"};function Bt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)}function je(e){return Bt(e)?e:JSON.stringify(e)}function _t(e){return e.expr!==void 0?e.reactive?`() => (${e.expr})`:`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ft(e){return e.expr!==void 0?`(${e.expr})`:JSON.stringify(e.literal??!0)}function Ht(e,t,n){let r=e.filter(a=>a.kind==="spread"),s=e.filter(a=>a.kind!=="spread").map(a=>`${je(a.name)}: ${_t(a)}`);t!=null&&s.push(`children: ${t}`);let i=`{ ${s.join(", ")} }`;return r.length>0?(n.add("mergeProps"),`mergeProps(${r.map(a=>a.expr).join(", ")}, ${i})`):i}function Je(e,t,n){return e.length===1?F(e[0],t,n):`[${e.map(r=>F(r,t,n)).join(", ")}]`}function Le(e,t,n,r,o){r.add("createMemo"),r.add("createComponent");let s=t.filter(c=>c.kind==="spread"),a=t.filter(c=>c.kind!=="spread").map(c=>`get ${je(c.name)}() { return ${Ft(c)}; }`);n.length>0&&a.push(`get children() { return ${Je(n,r,o)}; }`);let l=`{ ${a.join(", ")} }`;return s.length>0&&(r.add("mergeProps"),l=`mergeProps(${s.map(c=>c.expr).join(", ")}, ${l})`),`createMemo(() => createComponent(${e}, ${l}))`}function Vt(e,t){let n=Te(t.name),r=t.literal;return r===!0||r===void 0?`${e}.setAttribute(${JSON.stringify(n)}, "");`:r===!1||r===null?"":`${e}.setAttribute(${JSON.stringify(n)}, ${JSON.stringify(String(r))});`}var Be=!1;function F(e,t,n){switch(e.kind){case"text":return JSON.stringify(e.value);case"expr":return e.reactive?`() => (${e.code})`:`(${e.code})`;case"fragment":return e.children.length===0?"null":Je(e.children,t,n);case"component":return Le(e.name,e.props,e.children,t,n);case"control":{let r=Jt[e.control]??e.control;return t.add(r),Le(r,e.props,e.children,t,n)}case"element":{if(n&&e.static&&!e.svg&&de(e)){t.add("templateNode");let a=`_tmpl$${n.length}`;return n.push({id:a,html:_(e),tag:e.tag,svg:!1}),`templateNode(${a}, ${JSON.stringify(e.tag)})`}if(n&&Be){let a=Oe(e);if(a){t.add("templateNode"),t.add("insert"),t.add("holeEnd"),t.add("holeContent"),t.add("holeScope");let l=`_tmpl$${n.length}`;n.push({id:l,html:a.html,tag:a.tag,svg:!1});let c=[`const _el$ = templateNode(${l}, ${JSON.stringify(a.tag)}, true);`];for(let p of a.steps)c.push(`const ${p.ref} = ${p.expr};`);for(let p of a.holes)c.push(`insert(${p.parentRef}, holeScope(${p.startRef}, () => (${F(p.node,t,n)})), ${p.endRef}, holeContent(${p.startRef}, ${p.endRef}));`);return c.push("return _el$;"),`(() => { ${c.join(" ")} })()`}}t.add("createNativeElement");let r=JSON.stringify(e.tag),o="_el$",s=[],i=e.svg?`${r}, true`:r;if(s.push(`const ${o} = createNativeElement(${i});`),e.props.length>0)if(!e.svg&&e.props.every(B))for(let a of e.props)s.push(Vt(o,a));else{t.add("spread");let a=e.svg?", isSVG: true":"";s.push(`spread({ element: ${o}, props: ${Ht(e.props,null,t)}${a} });`)}for(let a of e.children){t.add("insert");let l=F(a,t,n),c=a.kind==="expr"&&a.reactive||a.kind==="component"||a.kind==="control";s.push(c?`insert(${o}, ${l}, null);`:`insert(${o}, ${l});`)}return s.push(`return ${o};`),`(() => { ${s.join(" ")} })()`}}}function re(e,t){if(!t||t.length===0)return e;let n=new Map(t.map(r=>[r.id,JSON.stringify(r.html)]));return e.replace(/_tmpl\$\d+/g,r=>n.get(r)??r)}var O={name:"imperative",contract:ue,emit(e,t){let n=new Set,r=t?.templateClone!==!1?[]:void 0;return Be=t?.partialTemplates===!0,{code:F(e,n,r),imports:Array.from(n),templates:r}}};var Xt=e=>"components"in e;function _e(e,t){return e.replace(/\$(\d+)/g,(n,r)=>t[Number(r)]??n)}function Ut(e,t){return typeof t=="string"?{module:t,export:e}:t}function oe(e=[]){let t=new Map,n=[],r=[];for(let i of e){if(!Xt(i)){r.push(i);continue}for(let[a,l]of Object.entries(i.components)){let c=Ut(a,l),p=t.get(a);if(p&&p.module!==c.module){let f=n.find(u=>u.name===a);f?f.modules.push(c.module):n.push({name:a,modules:[p.module,c.module]});continue}t.set(a,c)}}let o=new Map;return{resolve:i=>{if(o.has(i))return o.get(i);let a=t.get(i);if(!a)for(let l of r){let c=i.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){a={module:_e(l.module,c),export:l.export?_e(l.export,c):i};break}}return o.set(i,a),a},names:()=>[...t.keys()],conflicts:()=>n}}var Ve=require("@fluixi/template-parser");function H(e){let t=e.split(/\r\n|\n|\r/),n=0;for(let o=0;o<t.length;o++)/[^ \t]/.test(t[o])&&(n=o);let r="";for(let o=0;o<t.length;o++){let s=t[o].replace(/\t/g," ");o!==0&&(s=s.replace(/^ +/,"")),o!==t.length-1&&(s=s.replace(/ +$/,"")),s&&(o!==n&&(s+=" "),r+=s)}return r}var Fe=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]);function zt(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function He(e){return e.charAt(0).toUpperCase()+e.slice(1)}var fe=class{constructor(t,n){this.holes=t;this.used=n}hole(t){return this.holes[t]??{code:"undefined",reactive:!1}}emit(t){let{code:n,imports:r,templates:o}=O.emit(t,{});for(let s of r)this.used.add(s);return re(n,o)}lowerRoot(t){let n=this.lowerChildren(t);return n.length===1?n[0]:{kind:"fragment",children:n}}lowerChildren(t){let n=[];for(let r=0;r<t.length;r++){let o=t[r];if(o.kind==="Element"||o.kind==="Component"){let i=o.attributes.find(a=>a.kind==="IfDirective");if(i&&i.kind==="IfDirective"){let a=r+1;a<t.length&&this.isBlankText(t[a])&&a++;let l=t[a],c=l&&(l.kind==="Element"||l.kind==="Component")&&l.attributes.some(p=>p.kind==="ElseDirective");n.push(this.lowerIf(o,i.hole,c?l:null)),c&&(r=a);continue}if(o.attributes.some(a=>a.kind==="EachDirective")){n.push(this.lowerEach(o));continue}}let s=this.lowerNode(o);s&&n.push(s)}return n}isBlankText(t){return t.kind==="Text"&&!t.raw&&H(t.value)===""}lowerNode(t){switch(t.kind){case"Text":{if(t.raw)return{kind:"text",value:t.value};let n=H(t.value);return n?{kind:"text",value:n}:null}case"Comment":return null;case"Expression":{let n=this.hole(t.hole);return{kind:"expr",code:n.code,reactive:n.reactive}}case"Fragment":return{kind:"fragment",children:this.lowerChildren(t.children)};case"Element":return this.lowerElement(t);case"Component":return this.lowerComponent(t);default:return null}}lowerElement(t){let n=t.attributes.find(r=>r.kind==="Attribute"&&r.name==="is");if(t.tag==="component"&&n&&n.value&&n.value.kind==="hole"){let r=t.attributes.filter(s=>s!==n),o=this.lowerComponent({...t,kind:"Component",tag:"Dynamic",tagHole:null,attributes:r});return o.props.unshift({name:"component",kind:"attr",expr:`() => (${this.hole(n.value.hole).code})`}),o}return{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:this.lowerAttributes(t.attributes),children:this.lowerChildren(t.children),static:!1}}lowerComponent(t){let n=t.tagHole!=null?this.hole(t.tagHole).code:t.tag,r=this.lowerAttributes(t.attributes),{slots:o,rest:s}=this.partitionSlots(t.children);for(let[l,c]of o){let p=c.length===1?c[0]:{kind:"fragment",children:c},f={name:l,kind:"attr",expr:this.emit(p),jsxElement:!0},u=r.findIndex(g=>g.name===l);u>=0?r[u]=f:r.push(f)}let i=t.attributes.find(l=>l.kind==="LoadDirective"),a=i?Z(`load:${i.strategy}`,i.modifier):void 0;return{kind:"component",name:n,props:r,children:this.lowerChildren(s),...a?{load:a}:{}}}partitionSlots(t){let n=new Map,r=[];for(let o of t){if(o.kind==="Element"||o.kind==="Component"){let s=o.attributes.find(i=>i.kind==="Attribute"&&i.name==="slot");if(s&&s.value&&s.value.kind==="static"){let i={...o,attributes:o.attributes.filter(c=>c!==s)},a=i.kind==="Element"?this.lowerElement(i):this.lowerComponent(i),l=n.get(s.value.value)??[];l.push(a),n.set(s.value.value,l);continue}}r.push(o)}return{slots:n,rest:r}}lowerIf(t,n,r){let o=this.hole(n),s=[{name:"when",kind:"attr",expr:o.code,reactive:o.reactive}];if(r){let a=this.stripAndLower(r,l=>l.kind==="ElseDirective");s.push({name:"fallback",kind:"attr",expr:this.emit(a),jsxElement:!0})}let i=this.stripAndLower(t,a=>a.kind==="IfDirective");return{kind:"component",name:"Show",props:s,children:[i]}}lowerEach(t){let n=t.attributes.find(l=>l.kind==="EachDirective");if(!n||n.kind!=="EachDirective")return this.lowerNode(t);let r=this.hole(n.hole),o=[{name:"each",kind:"attr",expr:r.code,reactive:r.reactive}];if(n.key){let l="static"in n.key?`(item) => item[${JSON.stringify(n.key.static)}]`:this.hole(n.key.hole).code;o.push({name:"by",kind:"attr",expr:l})}let s=this.itemArrow(t),i;if(s){let l={kind:"expr",code:s.body,reactive:s.bodyReactive},c=this.rebuildWithChildren(t,[l]);i=`(${s.params.join(", ")}) => (${this.emit(c)})`}else{let l=this.stripAndLower(t,c=>c.kind==="EachDirective");i=`() => (${this.emit(l)})`}return{kind:"component",name:"For",props:o,children:[{kind:"expr",code:i,reactive:!1}]}}itemArrow(t){let n=t.children.filter(r=>!this.isBlankText(r));return n.length!==1||n[0].kind!=="Expression"?null:this.hole(n[0].hole).arrow??null}stripAndLower(t,n){let r={...t,attributes:t.attributes.filter(o=>!n(o))};return r.kind==="Element"?this.lowerElement(r):this.lowerComponent(r)}rebuildWithChildren(t,n){let r=this.lowerAttributes(t.attributes.filter(o=>o.kind!=="EachDirective"));return t.kind==="Element"?{kind:"element",tag:t.tag,svg:t.namespace==="svg",props:r,children:n,static:!1}:{kind:"component",name:t.tag,props:r,children:n}}lowerAttributes(t){let n=[],r=[],o=!1,s=[],i=!1,a=[];for(let l of t)switch(l.kind){case"IfDirective":case"EachDirective":case"ElseDirective":break;case"Attribute":n.push(this.plainAttr(l));break;case"PropertyBinding":n.push({name:l.name,kind:"prop",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"EventBinding":n.push(this.eventProp(l));break;case"RefBinding":n.push({name:"ref",kind:"ref",expr:this.hole(l.hole).code,reactive:this.hole(l.hole).reactive});break;case"Spread":n.push({name:"",kind:"spread",expr:this.hole(l.hole).code});break;case"ClassDirective":{let c=this.hole(l.hole);r.push(`${JSON.stringify(l.name)}: ${c.code}`),o=o||c.reactive;break}case"StyleDirective":{let c=this.hole(l.hole);s.push(`${JSON.stringify(l.name)}: ${c.code}`),i=i||c.reactive;break}case"BindDirective":n.push(...this.bindProps(l.name,this.hole(l.hole).code));break;case"UseDirective":{let c=l.name??(l.hole!=null?this.hole(l.hole).code:null);if(!c)break;a.push(l.name!=null&&l.hole!=null?`[${c}, () => (${this.hole(l.hole).code})]`:`[${c}]`);break}}return r.length>0&&n.push({name:"classList",kind:"attr",expr:`{ ${r.join(", ")} }`,reactive:o}),s.length>0&&n.push({name:"style",kind:"attr",expr:`{ ${s.join(", ")} }`,reactive:i}),a.length>0&&n.push({name:"use",kind:"attr",expr:`[${a.join(", ")}]`}),n}eventProp(t){let n=t.name.toLowerCase(),r=this.hole(t.hole).code;if(!(t.syntax==="colon"||t.modifiers.length>0))return{name:"on"+He(t.name),kind:"event",event:{name:n,delegated:Fe.has(n)},expr:r};let s=this.wrapHandler(r,t.modifiers),i=this.eventOptions(t.modifiers),a=i?`[${s}, ${i}]`:s;return{name:"on:"+n,kind:"attr",expr:a}}wrapHandler(t,n){let r=n.includes("self")?"if (e.target !== e.currentTarget) return; ":"",o=[];return n.includes("prevent")&&o.push("e.preventDefault();"),n.includes("stop")&&o.push("e.stopPropagation();"),!r&&o.length===0?t:`(e) => { ${r}${o.join(" ")} return (${t})(e); }`}eventOptions(t){let n=[];return t.includes("capture")&&n.push("capture: true"),t.includes("once")&&n.push("once: true"),t.includes("passive")&&n.push("passive: true"),n.length?`{ ${n.join(", ")} }`:null}bindProps(t,n){let r=t==="checked",o=r?"change":"input",s=r?"checked":"value";this.used.add("bindPair");let i=`bindPair(${n})`;return[{name:t,kind:"attr",expr:`${i}[0]()`,reactive:!0},{name:"on"+He(o),kind:"event",event:{name:o,delegated:Fe.has(o)},expr:`(e) => ${i}[1](e.target.${s})`}]}plainAttr(t){let n=t.value,r=t.name;t.name==="class"?r=n&&n.kind==="hole"&&this.hole(n.hole).object?"classList":"className":t.name==="html"&&(r="innerHTML");let s={name:r,kind:"attr"};if(n==null)return s.literal=!0,s;if(n.kind==="static")return s.literal=n.value,s;if(n.kind==="hole"){let l=this.hole(n.hole);return s.expr=l.code,s.reactive=l.reactive,s}let i=!1,a=n.parts.map(l=>{if("text"in l)return zt(l.text);let c=this.hole(l.hole);return i=i||c.reactive,"${"+c.code+"}"}).join("");return s.expr="`"+a+"`",s.reactive=i,s}};function Xe(e,t,n,r={}){let{root:o}=(0,Ve.parseTemplate)(e,{svg:r.svg});return new fe(t,n).lowerRoot(o.children)}function Ue(e,t,n={}){let r=new Set,o=Xe(e,[...t],r,{svg:n.svg});P(o),Y(o,{resolver:oe(n.resolve??[]),modules:{controlFlowModule:n.controlFlowModule??"@fluixi/dom",coreModule:n.coreModule??"@fluixi/core",routerModule:n.routerModule??"@fluixi/core/router-next"},strategyFor:l=>l.load}),ee(o);let{code:s,imports:i,templates:a}=O.emit(o,{templateClone:n.templateClone,partialTemplates:n.partialTemplates});for(let l of i)r.add(l);return n.hoistTemplates?{code:s,imports:[...r],ir:o,templates:a}:{code:re(s,a),imports:[...r],ir:o}}var Wt="children";function D(e){switch(e.kind){case"call":return!0;case"member":return e.property!==Wt;case"compound":return e.parts.some(D);case"opaque":return!1}}var qt=new Set(["CallExpression","OptionalCallExpression"]),Kt=new Set(["MemberExpression","OptionalMemberExpression"]);function A(e){if(!e)return{kind:"opaque"};if(qt.has(e.type))return{kind:"call"};if(Kt.has(e.type)){let t=e.property;return{kind:"member",property:!(e.computed===!0)&&t?.type==="Identifier"?t.name:null}}return e.type==="ConditionalExpression"?{kind:"compound",parts:[e.test,e.consequent,e.alternate].map(V)}:e.type==="LogicalExpression"||e.type==="BinaryExpression"?{kind:"compound",parts:[e.left,e.right].map(V)}:e.type==="TemplateLiteral"?{kind:"compound",parts:e.expressions.map(V)}:e.type==="ObjectExpression"?{kind:"compound",parts:e.properties.filter(n=>(n.type==="ObjectProperty"||n.type==="Property")&&n.computed!==!0).map(n=>V(n.value))}:e.type==="ArrayExpression"?{kind:"compound",parts:e.elements.filter(n=>n!=null&&n.type!=="SpreadElement").map(V)}:{kind:"opaque"}}var V=e=>A(e);var Gt=new Set(["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","clipPath","text"]),Zt=/^on[A-Z]/,Yt=new Set(["click","dblclick","input","change","submit","focus","blur","keydown","keyup","keypress","mousedown","mouseup"]),qe=e=>D(A(e));function X(e){if(e.type==="StringLiteral"||e.type==="NumericLiteral"||e.type==="BooleanLiteral"||e.type==="Literal"&&(typeof e.value=="string"||typeof e.value=="number"||typeof e.value=="boolean"))return e.value}var me=e=>!!e&&typeof X(e)=="string";function Qt(e,t){return e.type==="JSXIdentifier"?{tag:e.name,component:e.name[0]!==e.name[0].toLowerCase()}:e.type==="JSXMemberExpression"?{tag:t.code(e),component:!0}:e.type==="JSXNamespacedName"?{tag:`${e.namespace.name}:${e.name.name}`,component:!1}:{tag:"div",component:!1}}function ge(e){return e.type==="JSXIdentifier"?e.name==="class"?"className":e.name:e.type==="JSXNamespacedName"?`${e.namespace.name}:${e.name.name}`:"unknown"}function en(e,t){let n=ge(e.name),r=Zt.test(n),o=r||n.startsWith("on:")||n==="ref",i={name:n,kind:r?"event":"attr"};if(r){let l=n.slice(2).toLowerCase();i.event={name:l,delegated:Yt.has(l)}}let a=e.value;if(a==null)return i.literal=!0,i;if(me(a))return i.literal=X(a),i;if(a.type==="JSXExpressionContainer"&&a.expression?.type!=="JSXEmptyExpression"){let l=a.expression,c=X(l);return c!==void 0?(i.literal=c,i):(i.expr=t.code(l),i.reactive=o?!1:qe(l),(l.type==="JSXElement"||l.type==="JSXFragment")&&(i.jsxElement=!0),i)}return i.literal=!0,i}function ze(e,t){let n=e.value;return n==null?null:me(n)?JSON.stringify(X(n)):n.type==="JSXExpressionContainer"&&n.expression?.type!=="JSXEmptyExpression"?t.code(n.expression):null}function tn(e,t){let n=[],r=[];for(let o of e){if(o.type==="JSXSpreadAttribute"){n.push({name:"",kind:"spread",expr:t.code(o.argument)});continue}if(o.type!=="JSXAttribute"||le(ge(o.name)))continue;let s=o.name.type==="JSXNamespacedName"?o.name.namespace.name:null;if(s==="use"){let i=o.name.name.name;t.used.add(i);let a=ze(o,t);r.push(a!=null?`[${i}, () => (${a})]`:`[${i}]`);continue}if(s==="oncapture"){let i=o.name.name.name.toLowerCase(),a=ze(o,t)??"undefined";n.push({name:"on:"+i,kind:"attr",expr:`[${a}, { capture: true }]`});continue}n.push(en(o,t))}return r.length>0&&n.push({name:"use",kind:"attr",expr:`[${r.join(", ")}]`}),n}function We(e,t){let n=[];for(let r of e)if(r.type==="JSXText"){let o=H(r.value);o&&n.push({kind:"text",value:o})}else if(r.type==="JSXExpressionContainer"){if(r.expression?.type!=="JSXEmptyExpression"){let o=r.expression;n.push({kind:"expr",code:t.code(o),reactive:qe(o)})}}else r.type==="JSXElement"||r.type==="JSXFragment"?n.push(Ke(r,t)):r.type==="JSXSpreadChild"&&n.push({kind:"expr",code:t.code(r.expression),reactive:!1});return n}function nn(e){for(let t of e){if(t.type!=="JSXAttribute")continue;let n=ge(t.name);if(le(n)){if(t.value&&!me(t.value))throw new E(`'${n}' needs a literal value, not an expression — the strategy is compile-time.`);return Z(n,t.value?X(t.value):null)}}}function Ke(e,t){if(e.type==="JSXFragment")return{kind:"fragment",children:We(e.children,t)};let{tag:n,component:r}=Qt(e.openingElement.name,t),o=tn(e.openingElement.attributes,t),s=We(e.children,t);if(r){let i=nn(e.openingElement.attributes);return{kind:"component",name:n,props:o,children:s,...i?{load:i}:{}}}return{kind:"element",tag:n,svg:Gt.has(n),props:o,children:s,static:!1}}function Ge(e,t){let n=Ke(e,t);return P(n),n}function w(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties)n.type==="RestElement"?w(n.argument,t):w(n.value,t);return;case"ArrayPattern":for(let n of e.elements)w(n,t);return;case"AssignmentPattern":w(e.left,t);return;case"RestElement":w(e.argument,t);return}}function Ze(e,t){switch(e.type){case"ImportDeclaration":for(let n of e.specifiers)w(n.local,t);return;case"VariableDeclaration":for(let n of e.declarations)w(n.id,t);return;case"FunctionDeclaration":case"ClassDeclaration":w(e.id,t);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":e.declaration&&Ze(e.declaration,t);return}}function he(e){let t=new Set;for(let n of e.body)Ze(n,t);return t}var sn=require("@babel/parser"),an=Ee(require("magic-string"),1);function b(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties)n.type==="RestElement"?b(n.argument,t):b(n.value,t);return;case"ArrayPattern":for(let n of e.elements)b(n,t);return;case"AssignmentPattern":b(e.left,t);return;case"RestElement":b(e.argument,t);return}}function ye(e){switch(e.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"NullLiteral":case"BigIntLiteral":case"RegExpLiteral":case"Identifier":return!0;case"Literal":return!0;case"TemplateLiteral":return e.expressions.every(ye);case"UnaryExpression":return ye(e.argument);case"MemberExpression":return!1;default:return!1}}function se(e,t){if(!(!e||typeof e!="object")){t(e);for(let n of Object.keys(e)){if(n==="loc"||n==="range"||n==="leadingComments"||n==="trailingComments")continue;let r=e[n];if(Array.isArray(r))for(let o of r)o&&typeof o=="object"&&se(o,t);else r&&typeof r=="object"&&typeof r.type=="string"&&se(r,t)}}}function rn(e){let t=new Set;return se(e,n=>{if(n.type==="AssignmentExpression")b(n.left,t);else if(n.type==="UpdateExpression"){let r=n.argument;r?.type==="Identifier"&&t.add(r.name)}}),t}function on(e,t){let n=new Set,r=o=>{let s=new Set;b(o,s);for(let i of s)t.has(i)&&n.add(i)};return se(e,o=>{switch(o.type){case"VariableDeclarator":r(o.id);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":r(o.id);for(let s of o.params??[])r(s);return;case"CatchClause":r(o.param);return;case"ClassDeclaration":case"ClassExpression":r(o.id);return}}),n}function Ye(e,t,n){for(let r of e.properties??[]){if(r.type==="RestElement"){let p=r.argument;if(p?.type!=="Identifier"||t.length>0){let f=new Set;b(p,f);for(let u of f)n.bails.push({name:u,reason:"rest"});continue}n.rest={name:p.name,keys:[]};continue}if(r.computed){let p=new Set;b(r.value,p);for(let f of p)n.bails.push({name:f,reason:"computed"});continue}let o=r.key,s=o.type==="Identifier"?o.name:o.value,i=r.value,a;i.type==="AssignmentPattern"&&(a=i.right,i=i.left);let l=[...t,s];if(i.type==="Identifier"){if(a&&!ye(a)){n.bails.push({name:i.name,reason:"unsafe-default"});continue}n.reads.push({name:i.name,path:l,...a?{fallback:a}:{}});continue}if(i.type==="ObjectPattern"){if(a){let p=new Set;b(i,p);for(let f of p)n.bails.push({name:f,reason:"unsafe-default"});continue}Ye(i,l,n);continue}let c=new Set;b(i,c);for(let p of c)n.bails.push({name:p,reason:"computed"})}}function Qe(e,t){let n={reads:[],bails:[]};if(e?.type!=="ObjectPattern"||(Ye(e,[],n),n.rest&&(t?.type!=="BlockStatement"?(n.bails.push({name:n.rest.name,reason:"rest"}),delete n.rest):n.rest.keys=(e.properties??[]).filter(a=>a.type!=="RestElement"&&!a.computed).map(a=>{let l=a.key;return l.type==="Identifier"?l.name:l.value})),n.reads.length===0&&!n.rest))return n;let r=new Set(n.reads.map(a=>a.name));n.rest&&r.add(n.rest.name);let o=rn(t),s=on(t,r),i=[];for(let a of n.reads)o.has(a.name)?n.bails.push({name:a.name,reason:"reassigned"}):s.has(a.name)?n.bails.push({name:a.name,reason:"shadowed"}):i.push(a);return n.reads=i,n.rest&&o.has(n.rest.name)?(n.bails.push({name:n.rest.name,reason:"reassigned"}),delete n.rest):n.rest&&s.has(n.rest.name)&&(n.bails.push({name:n.rest.name,reason:"shadowed"}),delete n.rest),n}function et(e){switch(e){case"rest":return"this rest element cannot be served by splitProps, and copying the props into a plain object would lose the getters";case"computed":return"the property is not known until it runs";case"reassigned":return"the binding is assigned to, and props are read-only";case"shadowed":return"an inner scope binds the same name";case"unsafe-default":return"the default would have to run again on every read"}}function U(e,t,n=null){if(!(!e||typeof e!="object"||typeof e.type!="string")&&!e.type.startsWith("TS")&&t(e,n)!==!1)for(let r of Object.keys(e)){if(r==="loc"||r==="leadingComments"||r==="trailingComments")continue;let o=e[r];if(Array.isArray(o))for(let s of o)U(s,t,e);else o&&typeof o=="object"&&U(o,t,e)}}function tt(e){return!!e&&e[0]>="A"&&e[0]<="Z"}function ln(e){let t=[];return U(e,n=>{if(n.type==="FunctionDeclaration"&&tt(n.id?.name)){t.push(n);return}if(n.type==="VariableDeclarator"&&tt(n.id?.name)){let r=n.init;r&&(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")&&t.push(r)}}),t}function cn(e){let t=new Set;return U(e,n=>{n.type==="Identifier"&&t.add(n.name)}),t}function pn(e,t){if(!t)return!0;switch(t.type){case"MemberExpression":case"OptionalMemberExpression":return!(t.property===e&&!t.computed);case"ObjectProperty":case"ObjectMethod":case"ClassProperty":case"ClassMethod":return!(t.key===e&&!t.computed);case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return t.label!==e;case"ImportSpecifier":case"ExportSpecifier":return!1;default:return!0}}function nt(e,t,n={}){let r=[],o=[],s=new Set;for(let i of ln(e)){let a=i.params?.[0];if(a?.type!=="ObjectPattern")continue;let l=Qe(a,i.body);for(let m of l.bails)o.push({name:m.name,reason:m.reason,message:et(m.reason),start:a.start});if(l.bails.length>0||l.reads.length===0&&!l.rest)continue;let c=cn(i),p=n.parameterName??"props";for(;c.has(p);)p=`_${p}`;let f=new Map;for(let m of l.reads){let h=`${p}.${m.path.join(".")}`,v=m.fallback;f.set(m.name,v?`(${h} === undefined ? ${t.slice(v.start,v.end)} : ${h})`:h)}let u=a.typeAnnotation;if(r.push({start:a.start,end:u?.start??a.end,code:p}),l.rest){let m=l.rest.keys.map(v=>JSON.stringify(v)).join(", "),h=i.body;r.push({start:h.start+1,end:h.start+1,code:`
|
|
2
|
+
const [, ${l.rest.name}] = splitProps(${p}, [${m}]);`}),s.add("splitProps")}let g=[];U(i.body,(m,h)=>{if(m.type!=="Identifier")return;let v=f.get(m.name);if(!v)return;let S=h?.type==="ObjectProperty"&&h.shorthand&&h.value===m;if(!S&&!pn(m,h))return;let R=l.reads.find(C=>C.name===m.name).path;g.push({node:m,parent:S?h:null,text:v,property:R[R.length-1]})});for(let m of g)m.parent?r.push({start:m.parent.start,end:m.parent.end,code:`${m.node.name}: ${m.text}`}):r.push({start:m.node.start,end:m.node.end,code:m.text}),dn(m.node,p,m.property)}return{edits:r,diagnostics:o,used:s}}function dn(e,t,n){e.type="MemberExpression",e.computed=!1,e.optional=!1,e.object={type:"Identifier",name:t,start:e.start,end:e.start},e.property={type:"Identifier",name:n,start:e.end,end:e.end},delete e.name}var $="@fluixi/reactive/signal",T={$signal:{export:"signal",module:$,returns:"signal-handle"},$memo:{export:"memo",module:$,returns:"memo-handle"},$effect:{export:"effect",module:$,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:$,returns:"resource-handle"},$selector:{export:"createSelector",module:$,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:$,returns:"memo-accessor"},$untrack:{export:"untrack",module:$,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},rt={signal:"signal-handle",memo:"memo-handle",effect:"effect",store:"store-handle",createSignal:["signal-accessor","signal-setter"],createMemo:"memo-accessor",createEffect:"effect",createRenderEffect:"effect",createStore:"reactive-object",resource:"resource-handle",createResource:"reactive-object",createSelector:"memo-accessor",createDeferred:"memo-accessor"},un=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/signal-next","@fluixi/reactive/store","@fluixi/core","@fluixi/core/rx"],fn=new RegExp(`\\$(?:${Object.keys(T).map(e=>e.slice(1)).join("|")})\\s*\\(`);function ot(e){return fn.test(e)}function st(e){return Object.prototype.hasOwnProperty.call(T,e)}function it(e){return un.includes(e)}function y(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let n of e.properties??[])n.type==="RestElement"?y(n.argument,t):y(n.value,t);return;case"ArrayPattern":for(let n of e.elements??[])y(n,t);return;case"AssignmentPattern":y(e.left,t);return;case"RestElement":y(e.argument,t);return}}function z(e,t){if(!(!e||typeof e!="object"||typeof e.type!="string")){t(e);for(let n of Object.keys(e)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let r=e[n];if(Array.isArray(r))for(let o of r)z(o,t);else r&&typeof r=="object"&&z(r,t)}}}function mn(e,t){if(e.type!=="CallExpression")return;let n=e.callee;if(n?.type!=="Identifier")return;let r=n.name,o=t.primitives.get(r);if(o)return o;let s=T[r];if(s&&!t.shadowed.has(r))return s.returns}function gn(e,t,n){if(Array.isArray(t)){e.type==="ArrayPattern"&&e.elements.forEach((r,o)=>{let s=t[o];r?.type==="Identifier"&&s&&n.set(r.name,s)});return}e.type==="Identifier"&&n.set(e.name,t)}function at(e){let t=new Set;return z(e,n=>{switch(n.type){case"VariableDeclarator":y(n.id,t);return;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":y(n.id,t);for(let r of n.params??[])y(r,t);return;case"ClassDeclaration":case"ClassExpression":y(n.id,t);return;case"ImportSpecifier":case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":y(n.local,t);return;case"CatchClause":y(n.param,t);return}}),t}function lt(e){let t={kinds:new Map,primitives:new Map,shadowed:new Set},n=e;z(n,r=>{let o=new Set;if(r.type==="VariableDeclarator")y(r.id,o);else if(r.type==="FunctionDeclaration"||r.type==="ClassDeclaration")y(r.id,o);else if(r.type==="ImportDefaultSpecifier"||r.type==="ImportNamespaceSpecifier")y(r.local,o);else if(r.type==="ImportSpecifier")y(r.local,o);else if(r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression"||r.type==="FunctionDeclaration")for(let s of r.params??[])y(s,o);for(let s of o)T[s]&&t.shadowed.add(s)});for(let r of n.body??[])if(r.type==="ImportDeclaration"&&it(r.source?.value))for(let o of r.specifiers??[]){if(o.type!=="ImportSpecifier")continue;let s=o.imported,i=s.type==="Identifier"?s.name:s.value,a=rt[i];a&&t.primitives.set(o.local.name,a)}return z(n,r=>{if(r.type!=="VariableDeclarator"||!r.init)return;let o=mn(r.init,t);o&&gn(r.id,o,t.kinds)}),t}function Ne(e,t){if(!(!e||typeof e!="object"||typeof e.type!="string")){t(e);for(let n of Object.keys(e)){if(n==="loc"||n==="leadingComments"||n==="trailingComments")continue;let r=e[n];if(Array.isArray(r))for(let o of r)Ne(o,t);else r&&typeof r=="object"&&Ne(r,t)}}}function ct(e){let t=[],n=[],r=new Map,o=new Set,{shadowed:s}=lt(e);return Ne(e,i=>{if(i.type!=="CallExpression")return;let a=i.callee;if(a?.type!=="Identifier")return;let l=a.name;if(!st(l))return;if(s.has(l)){o.has(l)||(o.add(l),n.push({name:l,message:`${l} is reserved for the compiler, and this module binds it. The call keeps your binding's meaning; rename it to use the intrinsic.`,start:a.start}));return}let c=T[l];t.push({start:a.start,end:a.end,code:c.export});let p=r.get(c.module)??new Set;p.add(c.export),r.set(c.module,p)}),{edits:t,diagnostics:n,imports:r}}function pt(e,t){let n=[];for(let[r,o]of[...e.imports].sort(([s],[i])=>s.localeCompare(i))){let s=[...o].filter(i=>!t.has(i)).sort();s.length&&n.push(`import { ${s.join(", ")} } from ${JSON.stringify(r)};`)}return n.length?`${n.join(`
|
|
3
|
+
`)}
|
|
4
|
+
`:""}var hn=new Set(j),yn=new Set(J),Nn=new Set(M),vn=new Set(["createMemo","createEffect","createRenderEffect","createRoot","createSignal","onCleanup","batch","untrack"]);function ae(e,t,n=null,r=""){if(!(!e||typeof e!="object")){if(Array.isArray(e)){for(let o of e)ae(o,t,n,r);return}typeof e.type=="string"&&t(e,n,r);for(let o of Object.keys(e))o==="loc"||o==="leadingComments"||o==="trailingComments"||ae(e[o],t,typeof e.type=="string"?e:n,o)}}var ve=e=>e.type==="JSXElement"||e.type==="JSXFragment";function xn(e,t,n){return ve(e)?!(t&&ve(t)&&n==="children"):!1}function Rn(e,t){return e.type==="TaggedTemplateExpression"&&e.tag?.type==="Identifier"&&(e.tag.name===t||e.tag.name==="svg")}function ft(e){return e.filter(t=>!e.some(n=>n!==t&&n.start<=t.start&&n.end>=t.end&&n.end-n.start>t.end-t.start))}function ie(e,t,n,r){let o=ft(r.filter(i=>i.start>=t&&i.end<=n)).sort((i,a)=>a.start-i.start),s=e.slice(t,n);for(let i of o)s=s.slice(0,i.start-t)+i.code+s.slice(i.end-t);return s}function kn(e,t,n){let r={code:ie(e,t.start,t.end,n),reactive:D(A(t))};return t.type==="ArrowFunctionExpression"&&t.body?.type!=="BlockStatement"&&(r.arrow={params:t.params.map(o=>ie(e,o.start,o.end,n)),body:ie(e,t.body.start,t.body.end,n),bodyReactive:D(A(t.body))}),t.type==="ObjectExpression"&&(r.object=!0),r}function mt(e,t,n){if(!t||t.length===0)return e;let r=new Map;for(let o of t){let s=`${o.svg?"svg:":""}${o.html}`,i=n.get(s);i||(i=`_fxTmpl$${n.size}`,n.set(s,i)),r.set(o.id,i)}return e.replace(/_tmpl\$\d+/g,o=>r.get(o)??o)}function xe(e,t){if(e.kind==="component"&&e.load&&!e.source&&L(e.load)&&(t.ignoredLoad.has(e.name)||t.ignoredLoad.set(e.name,e.load)),e.kind==="component"&&e.source){let n=e.source;n.origin==="builtin"?t.builtins.add(e.name):L(n.loading)&&!t.resolved.has(e.name)?t.deferred.set(e.name,n):(t.deferred.delete(e.name),t.resolved.set(e.name,n))}if("props"in e&&e.props)for(let n of e.props)n.kind==="event"&&n.event?.delegated&&t.delegatedEvents.add(n.event.name);if("children"in e&&e.children)for(let n of e.children)xe(n,t)}function bn(e,t){for(let n of e.body??[])if(n.type==="ImportDeclaration")for(let r of n.specifiers??[]){if(r.local?.name!==t)continue;if(r.type==="ImportNamespaceSpecifier")return;let o=r.type==="ImportDefaultSpecifier"?"default":r.imported?.name??r.imported?.value;return{module:n.source.value,export:o,declaration:n,specifier:r}}}function Sn(e,t){for(let n of e.body??[])if(n.type==="ImportDeclaration"){for(let r of n.specifiers??[])if(r.type==="ImportNamespaceSpecifier"&&r.local?.name===t)return!0}return!1}function In(e,t,n){let r=!1;return ae(e,o=>{r||o.type!=="Identifier"||o.name!==t||o.start===n.local?.start&&o.end===n.local?.end||(r=!0)}),r}function En(e){let t=[`kind: ${JSON.stringify(e.kind)}`];return e.kind==="visible"&&e.rootMargin&&t.push(`rootMargin: ${JSON.stringify(e.rootMargin)}`),e.kind==="interaction"&&t.push(`events: ${JSON.stringify(e.events)}`),e.kind==="media"&&t.push(`query: ${JSON.stringify(e.query)}`),`{ ${t.join(", ")} }`}function wn(e){let t=[];return e.quasi.quasis.forEach((n,r)=>{if(t.push({kind:"static",text:n.value.cooked??n.value.raw,start:n.start}),r<e.quasi.expressions.length){let o=e.quasi.expressions[r];t.push({kind:"hole",index:r,start:o.start,end:o.end})}}),t}function Cn(e,t,n={}){let r=n.litTag??"html",o=n.format??"both",s=o!=="jsx",i=o!=="lit",a=s&&(e.includes(`${r}\``)||e.includes("svg`")),l=n.intrinsics!==!1&&ot(e);if(!a&&!(i&&e.includes("<"))&&!l)return null;let c=(0,dt.parse)(e,{sourceType:"module",plugins:["jsx","typescript"],errorRecovery:!0}),p=[];ae(c.program,(d,x,N)=>{(s&&Rn(d,r)||i&&xn(d,x,N))&&p.push(d)});let f=n.propsDestructure===!1?{edits:[],diagnostics:[],used:new Set}:nt(c.program,e,{runtimeModule:n.runtimeModule}),u=n.intrinsics===!1?{edits:[],diagnostics:[],imports:new Map}:ct(c.program);if(p.length===0&&f.edits.length===0&&u.edits.length===0&&u.diagnostics.length===0&&f.diagnostics.length===0)return null;p.sort((d,x)=>x.start-d.start||d.end-x.end);let m=new Set(f.used),h={builtins:new Set,resolved:new Map,deferred:new Map,delegatedEvents:new Set,ignoredLoad:new Map,unresolved:new Set,declared:at(c.program)},v=new Map,S=[...f.edits,...u.edits];for(let d of p){let x=p.some(k=>k!==d&&k.start<=d.start&&k.end>=d.end&&k.end-k.start>d.end-d.start);if(ve(d)){S.push({start:d.start,end:d.end,code:$n(e,d,S,x,m,h,v,n)});continue}let N=d.quasi.expressions.map(k=>kn(e,k,S)),I=Ue(wn(d),N,{...n,hoistTemplates:!0,templateClone:n.templateClone??!0,partialTemplates:x?!1:n.partialTemplates??!0,svg:d.tag.name==="svg"});for(let k of I.imports)m.add(k);xe(I.ir,h),S.push({start:d.start,end:d.end,code:mt(I.code,I.templates,v)})}let R=new ut.default(e);for(let d of ft(S))d.start===d.end?R.appendLeft(d.start,d.code):R.overwrite(d.start,d.end,d.code);let C=he(c.program),W=new Map;for(let[d]of h.ignoredLoad)C.has(d)||W.set(d,"unsupplied");for(let[d,x]of[...h.ignoredLoad]){if(!C.has(d))continue;let N=bn(c.program,d);if(!N){W.set(d,Sn(c.program,d)?"namespace":"local");continue}if(In(c.program,d,N.specifier)){W.set(d,"value");continue}let I=N.declaration.specifiers.filter(q=>q!==N.specifier),k=I.length===0&&e[N.declaration.end]===`
|
|
5
|
+
`?N.declaration.end+1:N.declaration.end;R.overwrite(N.declaration.start,k,I.length===0?"":`import { ${I.map(q=>e.slice(q.start,q.end)).join(", ")} } from ${JSON.stringify(N.declaration.source.value)};`),h.deferred.set(d,{module:N.module,export:N.export,origin:"rule",loading:x}),C.delete(d),h.ignoredLoad.delete(d)}let Re=Tn(m,h,v,C,n);Re&&R.prepend(Re);let ke=pt(u,C);ke&&R.prepend(ke);for(let d of c.program.body)d.type==="ImportDeclaration"&&d.source?.value==="@fluixi/core/rx"&&R.overwrite(d.source.start,d.source.end,JSON.stringify("@fluixi/reactive"));let gt={value:d=>`${d} is used as a value here, not only as a tag, so its import has to stay — deferring would hand those references a lazy wrapper instead of the component. Defer it at the point it is rendered, or keep it eager.`,namespace:d=>`${d} came in through a namespace import, which has no single export to defer. Import ${d} by name.`,local:d=>`${d} is declared in this file, so there is no module to load separately. Move it to its own file and import it.`,unsupplied:d=>`nothing supplies ${d}, so there is no import to defer. Import it, or add a \`resolve\` rule for it.`},be=[...h.ignoredLoad].map(([d,x])=>({name:d,strategy:x,message:`load:${x.kind} has no effect on <${d}>: ${gt[W.get(d)??"unsupplied"](d)}`})),Se=[...h.unresolved].map(d=>({name:d,message:`<${d}> is not defined: nothing imports it and no \`resolve\` rule supplies it. This compiles to a reference to a name that does not exist, so the component renders nothing. Import ${d}, or add a \`resolve\` rule for it.`}));return{code:R.toString(),map:R.generateMap({source:t,includeContent:!0,hires:!0}),...be.length?{loadDiagnostics:be}:{},...Se.length?{unresolvedDiagnostics:Se}:{},...f.diagnostics.length?{propsDiagnostics:f.diagnostics}:{},...u.diagnostics.length?{intrinsicDiagnostics:u.diagnostics}:{}}}function $n(e,t,n,r,o,s,i,a){let l=Ge(t,{code:f=>ie(e,f.start,f.end,n),used:o});P(l);let c=Y(l,{resolver:oe(a.resolve??[]),isBound:f=>s.declared.has(f),modules:{controlFlowModule:a.controlFlowModule??a.runtimeModule??"@fluixi/dom",coreModule:a.coreModule??"@fluixi/core",routerModule:a.routerModule??"@fluixi/core/router-next"},strategyFor:f=>f.load});for(let f of c.unresolved)s.unresolved.add(f);ee(l);let p=O.emit(l,{templateClone:a.templateClone??!0,partialTemplates:r?!1:a.partialTemplates??!0});for(let f of p.imports)o.add(f);return xe(l,s),mt(p.code,p.templates,i)}function Tn(e,t,n,r,o){let s=o.runtimeModule??"@fluixi/dom",i=o.coreModule??"@fluixi/core",a=new Map,l=(u,g)=>a.set(u,[...a.get(u)??[],g]),c=new Set(e);for(let u of t.builtins)c.add(u);t.delegatedEvents.size>0&&c.add("delegateEvents");for(let u of[...c].sort())r.has(u)||(vn.has(u)?l(o.reactiveModule??"@fluixi/reactive/signal",u):Nn.has(u)?l(o.routerModule??"@fluixi/core/router-next",u):yn.has(u)?l(i,u):hn.has(u)?l(o.controlFlowModule??s,u):l(s,u));for(let[u,g]of t.resolved)r.has(u)||l(g.module,g.export==="default"?`default as ${u}`:u===g.export?u:`${g.export} as ${u}`);let p=[];for(let[u,g]of a)p.push(`import { ${g.join(", ")} } from ${JSON.stringify(u)};`);let f=[...t.deferred].filter(([u])=>!r.has(u));if(f.length>0){r.has("deferred")||p.push(`import { deferred } from ${JSON.stringify(i)};`);for(let[u,g]of f)p.push(`const ${u} = deferred(() => import(${JSON.stringify(g.module)}), { strategy: ${En(g.loading)}, export: ${JSON.stringify(g.export)} });`)}for(let[u,g]of n)p.push(`const ${g} = ${JSON.stringify(u.startsWith("svg:")?u.slice(4):u)};`);return t.delegatedEvents.size>0&&p.push(`delegateEvents(${JSON.stringify([...t.delegatedEvents])});`),p.length>0?p.join(`
|
|
2
6
|
`)+`
|
|
3
7
|
`:null}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import MagicString from 'magic-string';
|
|
2
2
|
import { type CompileTemplateOptions } from '../lower/compile-template.js';
|
|
3
|
+
import type { IRLoadStrategy } from '../ir/nodes.js';
|
|
4
|
+
import { type PropsDiagnostic } from './props.js';
|
|
5
|
+
import { type IntrinsicDiagnostic } from './intrinsics.js';
|
|
3
6
|
export interface TransformOptions extends CompileTemplateOptions {
|
|
4
7
|
/**
|
|
5
8
|
* Which authoring syntaxes to compile. Both lower to the same IR, so this is
|
|
@@ -13,10 +16,43 @@ export interface TransformOptions extends CompileTemplateOptions {
|
|
|
13
16
|
runtimeModule?: string;
|
|
14
17
|
/** Where reactive primitives come from. @default '@fluixi/reactive/signal' */
|
|
15
18
|
reactiveModule?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Rewrite a component's destructured props into property reads, so
|
|
21
|
+
* `function Card({ title })` keeps updating instead of reading `title` once.
|
|
22
|
+
* The edits go into the same string as the template edits, so the map still points
|
|
23
|
+
* at what the author wrote.
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
propsDestructure?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Compile the `$` reactive intrinsics — `$signal`, `$memo`, `$effect`, `$store` — into
|
|
29
|
+
* the runtime calls they stand for, importing what they need.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
intrinsics?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface UnresolvedDiagnostic {
|
|
35
|
+
/** The tag nothing supplies. */
|
|
36
|
+
name: string;
|
|
37
|
+
message: string;
|
|
38
|
+
}
|
|
39
|
+
export interface LoadDiagnostic {
|
|
40
|
+
/** The component the directive was written on. */
|
|
41
|
+
name: string;
|
|
42
|
+
strategy: IRLoadStrategy;
|
|
43
|
+
message: string;
|
|
16
44
|
}
|
|
17
45
|
export interface TransformResult {
|
|
18
46
|
code: string;
|
|
19
47
|
map: ReturnType<MagicString['generateMap']>;
|
|
48
|
+
/** Props patterns the rewrite refused, when `propsDestructure` is on. */
|
|
49
|
+
propsDiagnostics?: PropsDiagnostic[];
|
|
50
|
+
/** `$` names the module bound itself, so the intrinsic did not fire. */
|
|
51
|
+
intrinsicDiagnostics?: IntrinsicDiagnostic[];
|
|
52
|
+
/** `load:` directives that could not take effect, and why. */
|
|
53
|
+
loadDiagnostics?: LoadDiagnostic[];
|
|
54
|
+
/** Capitalised tags nothing supplies — they compile to an undefined reference. */
|
|
55
|
+
unresolvedDiagnostics?: UnresolvedDiagnostic[];
|
|
20
56
|
}
|
|
21
57
|
/**
|
|
22
58
|
* Compile every template in `code`. Returns null when the module has none, so a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/transform/templates.ts"],"names":[],"mappings":"AASA,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/transform/templates.ts"],"names":[],"mappings":"AASA,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAG1F,OAAO,KAAK,EAAqB,cAAc,EAAU,MAAM,gBAAgB,CAAC;AAWhF,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAA2C,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAmBpG,MAAM,WAAW,gBAAiB,SAAQ,sBAAsB;IAC9D;;;;OAIG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAChC,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5C,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,wEAAwE;IACxE,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C,8DAA8D;IAC9D,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,kFAAkF;IAClF,qBAAqB,CAAC,EAAE,oBAAoB,EAAE,CAAC;CAChD;AAwQD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,gBAAqB,GAC7B,eAAe,GAAG,IAAI,CA+LxB"}
|