@lark.js/mvc 0.0.13 → 0.0.14
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 +0 -1
- package/dist/compiler.cjs +18 -345
- package/dist/compiler.d.cts +1 -30
- package/dist/compiler.d.ts +1 -30
- package/dist/compiler.js +17 -343
- package/dist/devtool.cjs +38 -20
- package/dist/devtool.js +38 -20
- package/dist/index.cjs +38 -33
- package/dist/index.d.cts +1 -11
- package/dist/index.d.ts +1 -11
- package/dist/index.js +38 -33
- package/dist/rspack.cjs +23 -351
- package/dist/rspack.d.cts +9 -24
- package/dist/rspack.d.ts +9 -24
- package/dist/rspack.js +23 -351
- package/dist/vite.cjs +43 -363
- package/dist/vite.d.cts +10 -9
- package/dist/vite.d.ts +10 -9
- package/dist/vite.js +43 -363
- package/dist/webpack.cjs +23 -351
- package/dist/webpack.d.cts +9 -15
- package/dist/webpack.d.ts +9 -15
- package/dist/webpack.js +23 -351
- package/package.json +5 -4
- package/src/client.d.ts +0 -87
package/dist/compiler.js
CHANGED
|
@@ -14512,7 +14512,7 @@ var require_lib = __commonJS({
|
|
|
14512
14512
|
options = Object.assign({}, options);
|
|
14513
14513
|
try {
|
|
14514
14514
|
options.sourceType = "module";
|
|
14515
|
-
const parser =
|
|
14515
|
+
const parser = getParser(options, input);
|
|
14516
14516
|
const ast = parser.parse();
|
|
14517
14517
|
if (parser.sawUnambiguousESM) {
|
|
14518
14518
|
return ast;
|
|
@@ -14520,7 +14520,7 @@ var require_lib = __commonJS({
|
|
|
14520
14520
|
if (parser.ambiguousScriptDifferentAst) {
|
|
14521
14521
|
try {
|
|
14522
14522
|
options.sourceType = "script";
|
|
14523
|
-
return
|
|
14523
|
+
return getParser(options, input).parse();
|
|
14524
14524
|
} catch (_unused) {
|
|
14525
14525
|
}
|
|
14526
14526
|
} else {
|
|
@@ -14530,17 +14530,17 @@ var require_lib = __commonJS({
|
|
|
14530
14530
|
} catch (moduleError) {
|
|
14531
14531
|
try {
|
|
14532
14532
|
options.sourceType = "script";
|
|
14533
|
-
return
|
|
14533
|
+
return getParser(options, input).parse();
|
|
14534
14534
|
} catch (_unused2) {
|
|
14535
14535
|
}
|
|
14536
14536
|
throw moduleError;
|
|
14537
14537
|
}
|
|
14538
14538
|
} else {
|
|
14539
|
-
return
|
|
14539
|
+
return getParser(options, input).parse();
|
|
14540
14540
|
}
|
|
14541
14541
|
}
|
|
14542
14542
|
function parseExpression(input, options) {
|
|
14543
|
-
const parser =
|
|
14543
|
+
const parser = getParser(options, input);
|
|
14544
14544
|
if (parser.options.strictMode) {
|
|
14545
14545
|
parser.state.strict = true;
|
|
14546
14546
|
}
|
|
@@ -14554,7 +14554,7 @@ var require_lib = __commonJS({
|
|
|
14554
14554
|
return tokenTypes2;
|
|
14555
14555
|
}
|
|
14556
14556
|
var tokTypes = generateExportedTokenTypes(tt);
|
|
14557
|
-
function
|
|
14557
|
+
function getParser(options, input) {
|
|
14558
14558
|
let cls = Parser;
|
|
14559
14559
|
const pluginsMap = /* @__PURE__ */ new Map();
|
|
14560
14560
|
if (options != null && options.plugins) {
|
|
@@ -15132,334 +15132,9 @@ function compileToVDomFunction(source, debug, file) {
|
|
|
15132
15132
|
return `($data,$viewId,$refAlt,$n,$refFn,$encUri,$encQuote)=>{${fullSource}}`;
|
|
15133
15133
|
}
|
|
15134
15134
|
|
|
15135
|
-
// src/compiler/swc/extract-global-vars.ts
|
|
15136
|
-
var parseSyncFn = null;
|
|
15137
|
-
var parseSyncLoadAttempted = false;
|
|
15138
|
-
async function getParser() {
|
|
15139
|
-
if (!parseSyncLoadAttempted) {
|
|
15140
|
-
parseSyncLoadAttempted = true;
|
|
15141
|
-
try {
|
|
15142
|
-
const swc = await import("@swc/core");
|
|
15143
|
-
parseSyncFn = swc.parseSync;
|
|
15144
|
-
} catch (err) {
|
|
15145
|
-
console.error("failed to load @swc/core", err);
|
|
15146
|
-
}
|
|
15147
|
-
}
|
|
15148
|
-
return parseSyncFn;
|
|
15149
|
-
}
|
|
15150
|
-
async function extractGlobalVars(source) {
|
|
15151
|
-
const { protectedSource, comments: _comments } = protectComments(source);
|
|
15152
|
-
const viewEventProcessed = processViewEvents(protectedSource);
|
|
15153
|
-
const converted = convertArtSyntax(viewEventProcessed, false);
|
|
15154
|
-
const template = restoreComments(converted, _comments);
|
|
15155
|
-
const templateCmdRegExp = /<%([@=!:])?([\s\S]*?)%>|$/g;
|
|
15156
|
-
const fnParts = [];
|
|
15157
|
-
const htmlStore = {};
|
|
15158
|
-
let htmlIndex = 0;
|
|
15159
|
-
let lastIndex = 0;
|
|
15160
|
-
const htmlKey = String.fromCharCode(5);
|
|
15161
|
-
template.replace(
|
|
15162
|
-
templateCmdRegExp,
|
|
15163
|
-
(match, operate, content, offset) => {
|
|
15164
|
-
const start = operate ? 3 : 2;
|
|
15165
|
-
const htmlText = template.substring(lastIndex, offset + start);
|
|
15166
|
-
const key = htmlKey + htmlIndex++ + htmlKey;
|
|
15167
|
-
htmlStore[key] = htmlText;
|
|
15168
|
-
lastIndex = offset + match.length - 2;
|
|
15169
|
-
if (operate && content.trim()) {
|
|
15170
|
-
fnParts.push(';"' + key + '";', "[" + content + "]");
|
|
15171
|
-
} else {
|
|
15172
|
-
fnParts.push(';"' + key + '";', content || "");
|
|
15173
|
-
}
|
|
15174
|
-
return match;
|
|
15175
|
-
}
|
|
15176
|
-
);
|
|
15177
|
-
let fn = fnParts.join("");
|
|
15178
|
-
fn = `(function(){${fn}})`;
|
|
15179
|
-
const parseSync = await getParser();
|
|
15180
|
-
if (!parseSync) {
|
|
15181
|
-
return fallbackExtractVariables(source);
|
|
15182
|
-
}
|
|
15183
|
-
let ast;
|
|
15184
|
-
try {
|
|
15185
|
-
ast = parseSync(fn, {
|
|
15186
|
-
syntax: "ecmascript",
|
|
15187
|
-
target: "es2022"
|
|
15188
|
-
});
|
|
15189
|
-
} catch {
|
|
15190
|
-
return fallbackExtractVariables(source);
|
|
15191
|
-
}
|
|
15192
|
-
const globalExists = {};
|
|
15193
|
-
for (const name of BUILTIN_GLOBALS) globalExists[name] = 1;
|
|
15194
|
-
const globalVars = /* @__PURE__ */ Object.create(null);
|
|
15195
|
-
const fnNodes = [];
|
|
15196
|
-
walkSwcAst(ast, {
|
|
15197
|
-
VariableDeclarator(node) {
|
|
15198
|
-
if (node.id.type === "Identifier") {
|
|
15199
|
-
const name = node.id.value;
|
|
15200
|
-
globalExists[name] = node.init ? 3 : 2;
|
|
15201
|
-
}
|
|
15202
|
-
},
|
|
15203
|
-
FunctionDeclaration(node) {
|
|
15204
|
-
if (node.identifier) {
|
|
15205
|
-
globalExists[node.identifier.value] = 3;
|
|
15206
|
-
}
|
|
15207
|
-
fnNodes.push(node);
|
|
15208
|
-
},
|
|
15209
|
-
FunctionExpression(node) {
|
|
15210
|
-
fnNodes.push(node);
|
|
15211
|
-
},
|
|
15212
|
-
ArrowFunctionExpression(node) {
|
|
15213
|
-
fnNodes.push(node);
|
|
15214
|
-
},
|
|
15215
|
-
CallExpression(node) {
|
|
15216
|
-
if (node.callee.type === "Identifier") {
|
|
15217
|
-
globalExists[node.callee.value] = 1;
|
|
15218
|
-
}
|
|
15219
|
-
}
|
|
15220
|
-
});
|
|
15221
|
-
const functionParams = /* @__PURE__ */ Object.create(null);
|
|
15222
|
-
for (const fnNode of fnNodes) {
|
|
15223
|
-
const patterns = getParamPatterns(fnNode);
|
|
15224
|
-
for (const pat of patterns) {
|
|
15225
|
-
if (pat.type === "Identifier") {
|
|
15226
|
-
functionParams[pat.value] = 1;
|
|
15227
|
-
} else if (pat.type === "AssignmentPattern" && pat.left.type === "Identifier") {
|
|
15228
|
-
functionParams[pat.left.value] = 1;
|
|
15229
|
-
} else if (pat.type === "RestElement" && pat.argument.type === "Identifier") {
|
|
15230
|
-
functionParams[pat.argument.value] = 1;
|
|
15231
|
-
}
|
|
15232
|
-
}
|
|
15233
|
-
}
|
|
15234
|
-
walkSwcAst(ast, {
|
|
15235
|
-
Identifier(node) {
|
|
15236
|
-
const name = node.value;
|
|
15237
|
-
if (globalExists[name]) return;
|
|
15238
|
-
if (functionParams[name]) return;
|
|
15239
|
-
globalVars[name] = 1;
|
|
15240
|
-
},
|
|
15241
|
-
AssignmentExpression(node) {
|
|
15242
|
-
if (node.left.type === "Identifier") {
|
|
15243
|
-
const name = node.left.value;
|
|
15244
|
-
if (!globalExists[name] || globalExists[name] === 1) {
|
|
15245
|
-
globalExists[name] = (globalExists[name] || 0) + 1;
|
|
15246
|
-
}
|
|
15247
|
-
}
|
|
15248
|
-
}
|
|
15249
|
-
});
|
|
15250
|
-
return Object.keys(globalVars);
|
|
15251
|
-
}
|
|
15252
|
-
function getParamPatterns(fnNode) {
|
|
15253
|
-
if (fnNode.type === "ArrowFunctionExpression") {
|
|
15254
|
-
return fnNode.params;
|
|
15255
|
-
}
|
|
15256
|
-
return fnNode.params.map((p) => p.pat);
|
|
15257
|
-
}
|
|
15258
|
-
function fallbackExtractVariables(source) {
|
|
15259
|
-
const vars = /* @__PURE__ */ new Set();
|
|
15260
|
-
const outputRegExp = /\{\{[:=!@]\s*([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
|
|
15261
|
-
let m;
|
|
15262
|
-
while ((m = outputRegExp.exec(source)) !== null) {
|
|
15263
|
-
vars.add(m[1]);
|
|
15264
|
-
}
|
|
15265
|
-
const eachRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
|
|
15266
|
-
while ((m = eachRegExp.exec(source)) !== null) {
|
|
15267
|
-
vars.add(m[1]);
|
|
15268
|
-
}
|
|
15269
|
-
const ifRegExp = /\{\{(?:else\s+)?if\s+([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
|
|
15270
|
-
while ((m = ifRegExp.exec(source)) !== null) {
|
|
15271
|
-
vars.add(m[1]);
|
|
15272
|
-
}
|
|
15273
|
-
return Array.from(vars).filter((v) => !BUILTIN_GLOBALS.has(v));
|
|
15274
|
-
}
|
|
15275
|
-
function walkSwcAst(ast, visitors) {
|
|
15276
|
-
function visit(node) {
|
|
15277
|
-
const type = node.type;
|
|
15278
|
-
if (visitors[type]) {
|
|
15279
|
-
visitors[type](node);
|
|
15280
|
-
}
|
|
15281
|
-
for (const key of Object.keys(node)) {
|
|
15282
|
-
if (key === "type" || key === "span" || key === "ctxt") continue;
|
|
15283
|
-
if (type === "MemberExpression" && key === "property") {
|
|
15284
|
-
const me = node;
|
|
15285
|
-
if (me.property.type !== "Computed") continue;
|
|
15286
|
-
}
|
|
15287
|
-
if (type === "KeyValueProperty" && key === "key") {
|
|
15288
|
-
const kv = node;
|
|
15289
|
-
if (kv.key.type !== "Computed") continue;
|
|
15290
|
-
}
|
|
15291
|
-
if (type === "MethodProperty" && key === "key") {
|
|
15292
|
-
const mp = node;
|
|
15293
|
-
if (mp.key.type !== "Computed") continue;
|
|
15294
|
-
}
|
|
15295
|
-
const child = Reflect.get(node, key);
|
|
15296
|
-
if (Array.isArray(child)) {
|
|
15297
|
-
for (const item of child) {
|
|
15298
|
-
if (isSwcNode(item)) visit(item);
|
|
15299
|
-
}
|
|
15300
|
-
} else if (isSwcNode(child)) {
|
|
15301
|
-
visit(child);
|
|
15302
|
-
}
|
|
15303
|
-
}
|
|
15304
|
-
}
|
|
15305
|
-
visit(ast);
|
|
15306
|
-
}
|
|
15307
|
-
function isSwcNode(v) {
|
|
15308
|
-
return !!v && typeof v === "object" && typeof v.type === "string";
|
|
15309
|
-
}
|
|
15310
|
-
var BUILTIN_GLOBALS = /* @__PURE__ */ new Set([
|
|
15311
|
-
// ─── Template runtime helpers (injected by compileToFunction) ───────
|
|
15312
|
-
//
|
|
15313
|
-
// These variables appear in the generated template function signature
|
|
15314
|
-
// or body. They must be excluded from extractGlobalVars() so that
|
|
15315
|
-
// they are not mistaken for user data variables and destructured from $data.
|
|
15316
|
-
// SPLITTER character constant (same as \x1e), used as namespace separator
|
|
15317
|
-
// for refData keys, event attribute encoding, and internal data structures.
|
|
15318
|
-
// Declared as: let $splitter='\x1e'
|
|
15319
|
-
"$splitter",
|
|
15320
|
-
// Data — the data object passed from Updater to the template function.
|
|
15321
|
-
// User variables are destructured from $data at the top of the function:
|
|
15322
|
-
// let {name, age} = $data;
|
|
15323
|
-
// This is the first parameter of the generated arrow function.
|
|
15324
|
-
"$data",
|
|
15325
|
-
// Null-safe toString: v => '' + (v == null ? '' : v)
|
|
15326
|
-
// Converts null/undefined to empty string, otherwise calls toString().
|
|
15327
|
-
// Wraps every {{!raw}} output to prevent "null" / "undefined" rendering.
|
|
15328
|
-
"$strSafe",
|
|
15329
|
-
// HTML entity encoder: v => $strSafe(v).replace(/[&<>"'`]/g, entityMap)
|
|
15330
|
-
// Encodes &, <, >, ", ', ` to HTML entities (& < etc.)
|
|
15331
|
-
// Applied to all {{=escaped}} and {{:binding}} outputs.
|
|
15332
|
-
"$encHtml",
|
|
15333
|
-
// HTML entity map — internal object used by $encHtml:
|
|
15334
|
-
// {'&':'amp','<':'gt','>':'gt','"':'#34','\'':'#39','`':'#96'}
|
|
15335
|
-
// Not a standalone function; referenced inside $encHtml's closure.
|
|
15336
|
-
"$entMap",
|
|
15337
|
-
// HTML entity RegExp — internal regexp used by $encHtml:
|
|
15338
|
-
// /[&<>"'`]/g
|
|
15339
|
-
"$entReg",
|
|
15340
|
-
// HTML entity replacer function — internal helper used by $encHtml:
|
|
15341
|
-
// m => '&' + $entMap[m] + ';'
|
|
15342
|
-
// Maps matched character to its entity string.
|
|
15343
|
-
"$entFn",
|
|
15344
|
-
// Output buffer — the string accumulator for rendered HTML.
|
|
15345
|
-
// All template output is appended via $out += '...'.
|
|
15346
|
-
// Declared as: let $out = ''
|
|
15347
|
-
"$out",
|
|
15348
|
-
// Reference lookup: (refData, value) => key
|
|
15349
|
-
// Finds or allocates a SPLITTER-prefixed key in refData for a given
|
|
15350
|
-
// object reference. Used by {{@ref}} operator for passing object
|
|
15351
|
-
// references to child views via v-lark attributes.
|
|
15352
|
-
"$refFn",
|
|
15353
|
-
// URI encoder: v => encodeURIComponent($strSafe(v)).replace(/[!')(*]/g, extraMap)
|
|
15354
|
-
// Extends encodeURIComponent with encoding of ! ' ( ) *.
|
|
15355
|
-
// Applied to values in @event URL parameters and {{!uri}} contexts.
|
|
15356
|
-
"$encUri",
|
|
15357
|
-
// URI encode map — internal object used by $encUri:
|
|
15358
|
-
// {'!':'%21','\'':'%27','(':'%28',')':'%29','*':'%2A'}
|
|
15359
|
-
"$uriMap",
|
|
15360
|
-
// URI encode replacer — internal helper used by $encUri:
|
|
15361
|
-
// m => $uriMap[m]
|
|
15362
|
-
"$uriFn",
|
|
15363
|
-
// URI encode regexp — internal regexp used by $encUri:
|
|
15364
|
-
// /[!')(*]/g
|
|
15365
|
-
"$uriReg",
|
|
15366
|
-
// Quote encoder: v => $strSafe(v).replace(/['"\\]/g, '\\$&')
|
|
15367
|
-
// Escapes quotes and backslashes for safe embedding in HTML attribute
|
|
15368
|
-
// values (e.g. data-json='...').
|
|
15369
|
-
"$encQuote",
|
|
15370
|
-
// Quote encode regexp — internal regexp used by $encQuote:
|
|
15371
|
-
// /['"\\]/g
|
|
15372
|
-
"$qReg",
|
|
15373
|
-
// View ID — the unique identifier of the owning View instance.
|
|
15374
|
-
// Injected into @event attribute values at render time so that
|
|
15375
|
-
// EventDelegator can dispatch events to the correct View handler.
|
|
15376
|
-
// The \x1f placeholder in compiled output is replaced with '+$viewId+'.
|
|
15377
|
-
"$viewId",
|
|
15378
|
-
// Debug: current expression text — stores the template expression being
|
|
15379
|
-
// evaluated, for error reporting. Only present in debug mode.
|
|
15380
|
-
// e.g. $dbgExpr='<%=user.name%>'
|
|
15381
|
-
"$dbgExpr",
|
|
15382
|
-
// Debug: original art syntax — stores the {{}} template syntax before
|
|
15383
|
-
// conversion, for error reporting. Only present in debug mode.
|
|
15384
|
-
// e.g. $dbgArt='{{=user.name}}'
|
|
15385
|
-
"$dbgArt",
|
|
15386
|
-
// Debug: source line number — tracks the current line in the template
|
|
15387
|
-
// source, for error reporting. Only present in debug mode.
|
|
15388
|
-
"$dbgLine",
|
|
15389
|
-
// RefData alias — fallback reference lookup table.
|
|
15390
|
-
// Defaults to $data when no explicit $refAlt is provided.
|
|
15391
|
-
// Ensures $refFn() does not crash when @ operator is used without refData.
|
|
15392
|
-
"$refAlt",
|
|
15393
|
-
// Temporary variable — used by the compiler for intermediate
|
|
15394
|
-
// expression results in generated code (e.g. loop variables,
|
|
15395
|
-
// conditional branches). Declared as: let $tmp
|
|
15396
|
-
"$tmp",
|
|
15397
|
-
// JS literals
|
|
15398
|
-
"undefined",
|
|
15399
|
-
"null",
|
|
15400
|
-
"true",
|
|
15401
|
-
"false",
|
|
15402
|
-
"NaN",
|
|
15403
|
-
"Infinity",
|
|
15404
|
-
// JS built-in globals
|
|
15405
|
-
"window",
|
|
15406
|
-
"self",
|
|
15407
|
-
"globalThis",
|
|
15408
|
-
"document",
|
|
15409
|
-
"console",
|
|
15410
|
-
"JSON",
|
|
15411
|
-
"Math",
|
|
15412
|
-
"Intl",
|
|
15413
|
-
"Promise",
|
|
15414
|
-
"Symbol",
|
|
15415
|
-
"Number",
|
|
15416
|
-
"String",
|
|
15417
|
-
"Boolean",
|
|
15418
|
-
"Array",
|
|
15419
|
-
"Object",
|
|
15420
|
-
"Date",
|
|
15421
|
-
"RegExp",
|
|
15422
|
-
"Error",
|
|
15423
|
-
"TypeError",
|
|
15424
|
-
"RangeError",
|
|
15425
|
-
"SyntaxError",
|
|
15426
|
-
"Map",
|
|
15427
|
-
"Set",
|
|
15428
|
-
"WeakMap",
|
|
15429
|
-
"WeakSet",
|
|
15430
|
-
"Proxy",
|
|
15431
|
-
"Reflect",
|
|
15432
|
-
"ArrayBuffer",
|
|
15433
|
-
"DataView",
|
|
15434
|
-
"Float32Array",
|
|
15435
|
-
"Float64Array",
|
|
15436
|
-
"Int8Array",
|
|
15437
|
-
"Int16Array",
|
|
15438
|
-
"Int32Array",
|
|
15439
|
-
"Uint8Array",
|
|
15440
|
-
"Uint16Array",
|
|
15441
|
-
"Uint32Array",
|
|
15442
|
-
"Uint8ClampedArray",
|
|
15443
|
-
// Functions
|
|
15444
|
-
"parseInt",
|
|
15445
|
-
"parseFloat",
|
|
15446
|
-
"isNaN",
|
|
15447
|
-
"isFinite",
|
|
15448
|
-
"encodeURIComponent",
|
|
15449
|
-
"decodeURIComponent",
|
|
15450
|
-
"encodeURI",
|
|
15451
|
-
"decodeURI",
|
|
15452
|
-
// SWC helpers
|
|
15453
|
-
"arguments",
|
|
15454
|
-
"this",
|
|
15455
|
-
"require",
|
|
15456
|
-
// Lark framework
|
|
15457
|
-
"Lark"
|
|
15458
|
-
]);
|
|
15459
|
-
|
|
15460
15135
|
// src/compiler/extract-global-vars.ts
|
|
15461
15136
|
var import_parser = __toESM(require_lib(), 1);
|
|
15462
|
-
async function
|
|
15137
|
+
async function extractGlobalVars(source) {
|
|
15463
15138
|
const { protectedSource, comments: _comments } = protectComments(source);
|
|
15464
15139
|
const viewEventProcessed = processViewEvents(protectedSource);
|
|
15465
15140
|
const converted = convertArtSyntax(viewEventProcessed, false);
|
|
@@ -15496,10 +15171,10 @@ async function extractGlobalVars2(source) {
|
|
|
15496
15171
|
allowAwaitOutsideFunction: true
|
|
15497
15172
|
});
|
|
15498
15173
|
} catch {
|
|
15499
|
-
return
|
|
15174
|
+
return fallbackExtractVariables(source);
|
|
15500
15175
|
}
|
|
15501
15176
|
const globalExists = {};
|
|
15502
|
-
for (const name of
|
|
15177
|
+
for (const name of BUILTIN_GLOBALS) globalExists[name] = 1;
|
|
15503
15178
|
const globalVars = /* @__PURE__ */ Object.create(null);
|
|
15504
15179
|
const fnRange = [];
|
|
15505
15180
|
walkAst(ast, {
|
|
@@ -15558,22 +15233,22 @@ async function extractGlobalVars2(source) {
|
|
|
15558
15233
|
});
|
|
15559
15234
|
return Object.keys(globalVars);
|
|
15560
15235
|
}
|
|
15561
|
-
function
|
|
15236
|
+
function fallbackExtractVariables(source) {
|
|
15562
15237
|
const vars = /* @__PURE__ */ new Set();
|
|
15563
15238
|
const outputRegExp = /\{\{[:=!@]\s*([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
|
|
15564
15239
|
let m;
|
|
15565
15240
|
while ((m = outputRegExp.exec(source)) !== null) {
|
|
15566
15241
|
vars.add(m[1]);
|
|
15567
15242
|
}
|
|
15568
|
-
const
|
|
15569
|
-
while ((m =
|
|
15243
|
+
const forOfRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
|
|
15244
|
+
while ((m = forOfRegExp.exec(source)) !== null) {
|
|
15570
15245
|
vars.add(m[1]);
|
|
15571
15246
|
}
|
|
15572
15247
|
const ifRegExp = /\{\{(?:else\s+)?if\s+([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
|
|
15573
15248
|
while ((m = ifRegExp.exec(source)) !== null) {
|
|
15574
15249
|
vars.add(m[1]);
|
|
15575
15250
|
}
|
|
15576
|
-
return Array.from(vars).filter((v) => !
|
|
15251
|
+
return Array.from(vars).filter((v) => !BUILTIN_GLOBALS.has(v));
|
|
15577
15252
|
}
|
|
15578
15253
|
function walkAst(ast, visitors) {
|
|
15579
15254
|
function visit(node) {
|
|
@@ -15611,7 +15286,7 @@ function walkAst(ast, visitors) {
|
|
|
15611
15286
|
function isAstNode(v) {
|
|
15612
15287
|
return !!v && typeof v === "object" && typeof v.type === "string";
|
|
15613
15288
|
}
|
|
15614
|
-
var
|
|
15289
|
+
var BUILTIN_GLOBALS = /* @__PURE__ */ new Set([
|
|
15615
15290
|
// ─── Template runtime helpers (injected by compileToFunction) ───────
|
|
15616
15291
|
//
|
|
15617
15292
|
// These variables appear in the generated template function signature
|
|
@@ -15850,8 +15525,8 @@ function compileToFunction(source, debug, file) {
|
|
|
15850
15525
|
return `($data,$viewId,$refAlt,$encHtml,$strSafe,$encUri,$refFn,$encQuote)=>{${fullSource}}`;
|
|
15851
15526
|
}
|
|
15852
15527
|
async function compileTemplate(source, options = {}) {
|
|
15853
|
-
const { debug = false, file, virtualDom = false
|
|
15854
|
-
const globalVars = options.globalVars ?? await
|
|
15528
|
+
const { debug = false, file, virtualDom = false } = options;
|
|
15529
|
+
const globalVars = options.globalVars ?? await extractGlobalVars(source);
|
|
15855
15530
|
const { protectedSource, comments } = protectComments(source);
|
|
15856
15531
|
const converted = convertArtSyntax(protectedSource, debug);
|
|
15857
15532
|
const viewEventProcessed = processViewEvents(converted);
|
|
@@ -15885,6 +15560,5 @@ export default function(data, viewId, refData) {
|
|
|
15885
15560
|
}
|
|
15886
15561
|
export {
|
|
15887
15562
|
compileTemplate,
|
|
15888
|
-
|
|
15889
|
-
extractGlobalVars as extractGlobalVarsSwc
|
|
15563
|
+
extractGlobalVars
|
|
15890
15564
|
};
|
package/dist/devtool.cjs
CHANGED
|
@@ -832,6 +832,21 @@ function use(names, callback) {
|
|
|
832
832
|
return loadPromise;
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
+
// src/frame-registry.ts
|
|
836
|
+
var frameRegistry = /* @__PURE__ */ new Map();
|
|
837
|
+
function getFrame(id) {
|
|
838
|
+
return frameRegistry.get(id);
|
|
839
|
+
}
|
|
840
|
+
function getAllFrames() {
|
|
841
|
+
return frameRegistry;
|
|
842
|
+
}
|
|
843
|
+
function registerFrame(id, frame) {
|
|
844
|
+
frameRegistry.set(id, frame);
|
|
845
|
+
}
|
|
846
|
+
function removeFrame(id) {
|
|
847
|
+
frameRegistry.delete(id);
|
|
848
|
+
}
|
|
849
|
+
|
|
835
850
|
// src/dom.ts
|
|
836
851
|
var wrapMeta = {
|
|
837
852
|
option: [1, "<select multiple>"],
|
|
@@ -1542,7 +1557,7 @@ var Updater = class {
|
|
|
1542
1557
|
const changed = this.hasChangedFlag;
|
|
1543
1558
|
this.hasChangedFlag = 0;
|
|
1544
1559
|
this.changedKeys = /* @__PURE__ */ new Set();
|
|
1545
|
-
const frame =
|
|
1560
|
+
const frame = getFrame(this.viewId);
|
|
1546
1561
|
const view = frame?.view;
|
|
1547
1562
|
const node = getById(this.viewId);
|
|
1548
1563
|
if (changed && view && node && view.signature > 0 && frame) {
|
|
@@ -2088,7 +2103,7 @@ function invalidateViewClass(viewPath) {
|
|
|
2088
2103
|
|
|
2089
2104
|
// src/hmr.ts
|
|
2090
2105
|
function reloadViews(viewPath) {
|
|
2091
|
-
const allFrames =
|
|
2106
|
+
const allFrames = getAllFrames();
|
|
2092
2107
|
const toReload = [];
|
|
2093
2108
|
for (const [, frame] of allFrames) {
|
|
2094
2109
|
if (frame.viewPath) {
|
|
@@ -2109,9 +2124,13 @@ function acceptView(hot, viewPath) {
|
|
|
2109
2124
|
const NewViewClass = candidate;
|
|
2110
2125
|
registerViewClass(viewPath, NewViewClass);
|
|
2111
2126
|
reloadViews(viewPath);
|
|
2112
|
-
|
|
2113
|
-
|
|
2127
|
+
return;
|
|
2128
|
+
}
|
|
2129
|
+
if (getViewClass(viewPath)) {
|
|
2130
|
+
reloadViews(viewPath);
|
|
2131
|
+
return;
|
|
2114
2132
|
}
|
|
2133
|
+
hot.invalidate();
|
|
2115
2134
|
});
|
|
2116
2135
|
}
|
|
2117
2136
|
function disposeView(hot, viewPath) {
|
|
@@ -2753,7 +2772,6 @@ var View = class _View {
|
|
|
2753
2772
|
};
|
|
2754
2773
|
|
|
2755
2774
|
// src/frame.ts
|
|
2756
|
-
var frameRegistry = /* @__PURE__ */ new Map();
|
|
2757
2775
|
var rootFrame;
|
|
2758
2776
|
var globalAlter;
|
|
2759
2777
|
var MAX_FRAME_POOL = 64;
|
|
@@ -2805,7 +2823,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2805
2823
|
if (parentId) {
|
|
2806
2824
|
this._parentId = parentId;
|
|
2807
2825
|
}
|
|
2808
|
-
|
|
2826
|
+
registerFrame(id, this);
|
|
2809
2827
|
const element = document.getElementById(id);
|
|
2810
2828
|
if (element) {
|
|
2811
2829
|
element.frame = this;
|
|
@@ -2936,7 +2954,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2936
2954
|
*/
|
|
2937
2955
|
mountFrame(frameId, viewPath, viewInitParams) {
|
|
2938
2956
|
notifyAlter(this, { id: frameId });
|
|
2939
|
-
let childFrame =
|
|
2957
|
+
let childFrame = getFrame(frameId);
|
|
2940
2958
|
if (!childFrame) {
|
|
2941
2959
|
if (!this.childrenMap[frameId]) {
|
|
2942
2960
|
this.childrenCount++;
|
|
@@ -2957,17 +2975,17 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2957
2975
|
*/
|
|
2958
2976
|
unmountFrame(id) {
|
|
2959
2977
|
const targetId = id ? this.childrenMap[id] : this.id;
|
|
2960
|
-
const frame =
|
|
2978
|
+
const frame = getFrame(targetId);
|
|
2961
2979
|
if (!frame) return;
|
|
2962
2980
|
const wasCreated = frame.readyCount > 0;
|
|
2963
2981
|
const pId = frame.parentId;
|
|
2964
2982
|
frame.unmountView();
|
|
2965
|
-
|
|
2983
|
+
removeFrame2(targetId, wasCreated);
|
|
2966
2984
|
reInitFrameForCache(frame);
|
|
2967
2985
|
if (frameCache.length < MAX_FRAME_POOL) {
|
|
2968
2986
|
frameCache.push(frame);
|
|
2969
2987
|
}
|
|
2970
|
-
const parent =
|
|
2988
|
+
const parent = getFrame(pId || "");
|
|
2971
2989
|
if (parent && parent.childrenMap[targetId]) {
|
|
2972
2990
|
Reflect.deleteProperty(parent.childrenMap, targetId);
|
|
2973
2991
|
parent.childrenCount--;
|
|
@@ -3032,7 +3050,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
3032
3050
|
let currentPid = this.parentId;
|
|
3033
3051
|
let n = level >>> 0 || 1;
|
|
3034
3052
|
while (currentPid && n--) {
|
|
3035
|
-
frame =
|
|
3053
|
+
frame = getFrame(currentPid);
|
|
3036
3054
|
currentPid = frame?.parentId;
|
|
3037
3055
|
}
|
|
3038
3056
|
return frame;
|
|
@@ -3093,11 +3111,11 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
3093
3111
|
// ============================================================
|
|
3094
3112
|
/** Get frame by ID */
|
|
3095
3113
|
static get(id) {
|
|
3096
|
-
return
|
|
3114
|
+
return getFrame(id);
|
|
3097
3115
|
}
|
|
3098
3116
|
/** Get all frames */
|
|
3099
3117
|
static getAll() {
|
|
3100
|
-
return
|
|
3118
|
+
return getAllFrames();
|
|
3101
3119
|
}
|
|
3102
3120
|
/**
|
|
3103
3121
|
* Returns the existing root frame, or `undefined` if none has been created.
|
|
@@ -3147,10 +3165,10 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
3147
3165
|
function htmlElIsBound(element) {
|
|
3148
3166
|
return !!element.frameBound;
|
|
3149
3167
|
}
|
|
3150
|
-
function
|
|
3151
|
-
const frameInstance =
|
|
3168
|
+
function removeFrame2(id, wasCreated) {
|
|
3169
|
+
const frameInstance = getFrame(id);
|
|
3152
3170
|
if (!frameInstance) return;
|
|
3153
|
-
|
|
3171
|
+
removeFrame(id);
|
|
3154
3172
|
Frame.fire("remove", { frame: frameInstance, fcc: wasCreated });
|
|
3155
3173
|
const element = document.getElementById(id);
|
|
3156
3174
|
if (element) {
|
|
@@ -3167,7 +3185,7 @@ function notifyCreated(frameInstance) {
|
|
|
3167
3185
|
}
|
|
3168
3186
|
const pId = frameInstance.parentId;
|
|
3169
3187
|
if (pId) {
|
|
3170
|
-
const parent =
|
|
3188
|
+
const parent = getFrame(pId);
|
|
3171
3189
|
if (parent && !parent.readyMap.has(frameInstance.id)) {
|
|
3172
3190
|
parent.readyMap.add(frameInstance.id);
|
|
3173
3191
|
parent.readyCount++;
|
|
@@ -3183,7 +3201,7 @@ function notifyAlter(frameInstance, data) {
|
|
|
3183
3201
|
frameInstance.fire("alter", data);
|
|
3184
3202
|
const pId = frameInstance.parentId;
|
|
3185
3203
|
if (pId) {
|
|
3186
|
-
const parent =
|
|
3204
|
+
const parent = getFrame(pId);
|
|
3187
3205
|
if (parent && parent.readyMap.has(frameInstance.id)) {
|
|
3188
3206
|
parent.readyCount--;
|
|
3189
3207
|
parent.readyMap.delete(frameInstance.id);
|
|
@@ -3201,7 +3219,7 @@ function reInitFrame(frame, id, parentId) {
|
|
|
3201
3219
|
frame["signature"] = 1;
|
|
3202
3220
|
frame["readyMap"] = /* @__PURE__ */ new Set();
|
|
3203
3221
|
frame["invokeList"] = [];
|
|
3204
|
-
|
|
3222
|
+
registerFrame(id, frame);
|
|
3205
3223
|
}
|
|
3206
3224
|
function reInitFrameForCache(frame) {
|
|
3207
3225
|
Reflect.set(frame, "id", "");
|
|
@@ -3210,7 +3228,7 @@ function reInitFrameForCache(frame) {
|
|
|
3210
3228
|
frame["readyMap"] = /* @__PURE__ */ new Set();
|
|
3211
3229
|
}
|
|
3212
3230
|
function translateQuery(pId, src, params) {
|
|
3213
|
-
const parentFrame =
|
|
3231
|
+
const parentFrame = getFrame(pId);
|
|
3214
3232
|
const parentView = parentFrame?.view;
|
|
3215
3233
|
if (!parentView) return;
|
|
3216
3234
|
const parentRefData = parentView.updater.refData;
|