@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/rspack.js
CHANGED
|
@@ -27,12 +27,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.43_@swc+helpers@0.5.23__jiti@2.7.0_postcss@8.5.15_tsx@4.22.4_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js
|
|
31
31
|
import path from "path";
|
|
32
32
|
import { fileURLToPath } from "url";
|
|
33
33
|
var getFilename, __filename;
|
|
34
34
|
var init_esm_shims = __esm({
|
|
35
|
-
"../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.
|
|
35
|
+
"../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.43_@swc+helpers@0.5.23__jiti@2.7.0_postcss@8.5.15_tsx@4.22.4_typescript@5.9.3_yaml@2.9.0/node_modules/tsup/assets/esm_shims.js"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
38
38
|
__filename = /* @__PURE__ */ getFilename();
|
|
@@ -14528,7 +14528,7 @@ var require_lib = __commonJS({
|
|
|
14528
14528
|
options = Object.assign({}, options);
|
|
14529
14529
|
try {
|
|
14530
14530
|
options.sourceType = "module";
|
|
14531
|
-
const parser =
|
|
14531
|
+
const parser = getParser(options, input);
|
|
14532
14532
|
const ast = parser.parse();
|
|
14533
14533
|
if (parser.sawUnambiguousESM) {
|
|
14534
14534
|
return ast;
|
|
@@ -14536,7 +14536,7 @@ var require_lib = __commonJS({
|
|
|
14536
14536
|
if (parser.ambiguousScriptDifferentAst) {
|
|
14537
14537
|
try {
|
|
14538
14538
|
options.sourceType = "script";
|
|
14539
|
-
return
|
|
14539
|
+
return getParser(options, input).parse();
|
|
14540
14540
|
} catch (_unused) {
|
|
14541
14541
|
}
|
|
14542
14542
|
} else {
|
|
@@ -14546,17 +14546,17 @@ var require_lib = __commonJS({
|
|
|
14546
14546
|
} catch (moduleError) {
|
|
14547
14547
|
try {
|
|
14548
14548
|
options.sourceType = "script";
|
|
14549
|
-
return
|
|
14549
|
+
return getParser(options, input).parse();
|
|
14550
14550
|
} catch (_unused2) {
|
|
14551
14551
|
}
|
|
14552
14552
|
throw moduleError;
|
|
14553
14553
|
}
|
|
14554
14554
|
} else {
|
|
14555
|
-
return
|
|
14555
|
+
return getParser(options, input).parse();
|
|
14556
14556
|
}
|
|
14557
14557
|
}
|
|
14558
14558
|
function parseExpression(input, options) {
|
|
14559
|
-
const parser =
|
|
14559
|
+
const parser = getParser(options, input);
|
|
14560
14560
|
if (parser.options.strictMode) {
|
|
14561
14561
|
parser.state.strict = true;
|
|
14562
14562
|
}
|
|
@@ -14570,7 +14570,7 @@ var require_lib = __commonJS({
|
|
|
14570
14570
|
return tokenTypes2;
|
|
14571
14571
|
}
|
|
14572
14572
|
var tokTypes = generateExportedTokenTypes(tt);
|
|
14573
|
-
function
|
|
14573
|
+
function getParser(options, input) {
|
|
14574
14574
|
let cls = Parser;
|
|
14575
14575
|
const pluginsMap = /* @__PURE__ */ new Map();
|
|
14576
14576
|
if (options != null && options.plugins) {
|
|
@@ -15159,336 +15159,10 @@ function compileToVDomFunction(source, debug, file) {
|
|
|
15159
15159
|
return `($data,$viewId,$refAlt,$n,$refFn,$encUri,$encQuote)=>{${fullSource}}`;
|
|
15160
15160
|
}
|
|
15161
15161
|
|
|
15162
|
-
// src/compiler/swc/extract-global-vars.ts
|
|
15163
|
-
init_esm_shims();
|
|
15164
|
-
var parseSyncFn = null;
|
|
15165
|
-
var parseSyncLoadAttempted = false;
|
|
15166
|
-
async function getParser() {
|
|
15167
|
-
if (!parseSyncLoadAttempted) {
|
|
15168
|
-
parseSyncLoadAttempted = true;
|
|
15169
|
-
try {
|
|
15170
|
-
const swc = await import("@swc/core");
|
|
15171
|
-
parseSyncFn = swc.parseSync;
|
|
15172
|
-
} catch (err) {
|
|
15173
|
-
console.error("failed to load @swc/core", err);
|
|
15174
|
-
}
|
|
15175
|
-
}
|
|
15176
|
-
return parseSyncFn;
|
|
15177
|
-
}
|
|
15178
|
-
async function extractGlobalVars(source) {
|
|
15179
|
-
const { protectedSource, comments: _comments } = protectComments(source);
|
|
15180
|
-
const viewEventProcessed = processViewEvents(protectedSource);
|
|
15181
|
-
const converted = convertArtSyntax(viewEventProcessed, false);
|
|
15182
|
-
const template = restoreComments(converted, _comments);
|
|
15183
|
-
const templateCmdRegExp = /<%([@=!:])?([\s\S]*?)%>|$/g;
|
|
15184
|
-
const fnParts = [];
|
|
15185
|
-
const htmlStore = {};
|
|
15186
|
-
let htmlIndex = 0;
|
|
15187
|
-
let lastIndex = 0;
|
|
15188
|
-
const htmlKey = String.fromCharCode(5);
|
|
15189
|
-
template.replace(
|
|
15190
|
-
templateCmdRegExp,
|
|
15191
|
-
(match, operate, content, offset) => {
|
|
15192
|
-
const start = operate ? 3 : 2;
|
|
15193
|
-
const htmlText = template.substring(lastIndex, offset + start);
|
|
15194
|
-
const key = htmlKey + htmlIndex++ + htmlKey;
|
|
15195
|
-
htmlStore[key] = htmlText;
|
|
15196
|
-
lastIndex = offset + match.length - 2;
|
|
15197
|
-
if (operate && content.trim()) {
|
|
15198
|
-
fnParts.push(';"' + key + '";', "[" + content + "]");
|
|
15199
|
-
} else {
|
|
15200
|
-
fnParts.push(';"' + key + '";', content || "");
|
|
15201
|
-
}
|
|
15202
|
-
return match;
|
|
15203
|
-
}
|
|
15204
|
-
);
|
|
15205
|
-
let fn = fnParts.join("");
|
|
15206
|
-
fn = `(function(){${fn}})`;
|
|
15207
|
-
const parseSync = await getParser();
|
|
15208
|
-
if (!parseSync) {
|
|
15209
|
-
return fallbackExtractVariables(source);
|
|
15210
|
-
}
|
|
15211
|
-
let ast;
|
|
15212
|
-
try {
|
|
15213
|
-
ast = parseSync(fn, {
|
|
15214
|
-
syntax: "ecmascript",
|
|
15215
|
-
target: "es2022"
|
|
15216
|
-
});
|
|
15217
|
-
} catch {
|
|
15218
|
-
return fallbackExtractVariables(source);
|
|
15219
|
-
}
|
|
15220
|
-
const globalExists = {};
|
|
15221
|
-
for (const name of BUILTIN_GLOBALS) globalExists[name] = 1;
|
|
15222
|
-
const globalVars = /* @__PURE__ */ Object.create(null);
|
|
15223
|
-
const fnNodes = [];
|
|
15224
|
-
walkSwcAst(ast, {
|
|
15225
|
-
VariableDeclarator(node) {
|
|
15226
|
-
if (node.id.type === "Identifier") {
|
|
15227
|
-
const name = node.id.value;
|
|
15228
|
-
globalExists[name] = node.init ? 3 : 2;
|
|
15229
|
-
}
|
|
15230
|
-
},
|
|
15231
|
-
FunctionDeclaration(node) {
|
|
15232
|
-
if (node.identifier) {
|
|
15233
|
-
globalExists[node.identifier.value] = 3;
|
|
15234
|
-
}
|
|
15235
|
-
fnNodes.push(node);
|
|
15236
|
-
},
|
|
15237
|
-
FunctionExpression(node) {
|
|
15238
|
-
fnNodes.push(node);
|
|
15239
|
-
},
|
|
15240
|
-
ArrowFunctionExpression(node) {
|
|
15241
|
-
fnNodes.push(node);
|
|
15242
|
-
},
|
|
15243
|
-
CallExpression(node) {
|
|
15244
|
-
if (node.callee.type === "Identifier") {
|
|
15245
|
-
globalExists[node.callee.value] = 1;
|
|
15246
|
-
}
|
|
15247
|
-
}
|
|
15248
|
-
});
|
|
15249
|
-
const functionParams = /* @__PURE__ */ Object.create(null);
|
|
15250
|
-
for (const fnNode of fnNodes) {
|
|
15251
|
-
const patterns = getParamPatterns(fnNode);
|
|
15252
|
-
for (const pat of patterns) {
|
|
15253
|
-
if (pat.type === "Identifier") {
|
|
15254
|
-
functionParams[pat.value] = 1;
|
|
15255
|
-
} else if (pat.type === "AssignmentPattern" && pat.left.type === "Identifier") {
|
|
15256
|
-
functionParams[pat.left.value] = 1;
|
|
15257
|
-
} else if (pat.type === "RestElement" && pat.argument.type === "Identifier") {
|
|
15258
|
-
functionParams[pat.argument.value] = 1;
|
|
15259
|
-
}
|
|
15260
|
-
}
|
|
15261
|
-
}
|
|
15262
|
-
walkSwcAst(ast, {
|
|
15263
|
-
Identifier(node) {
|
|
15264
|
-
const name = node.value;
|
|
15265
|
-
if (globalExists[name]) return;
|
|
15266
|
-
if (functionParams[name]) return;
|
|
15267
|
-
globalVars[name] = 1;
|
|
15268
|
-
},
|
|
15269
|
-
AssignmentExpression(node) {
|
|
15270
|
-
if (node.left.type === "Identifier") {
|
|
15271
|
-
const name = node.left.value;
|
|
15272
|
-
if (!globalExists[name] || globalExists[name] === 1) {
|
|
15273
|
-
globalExists[name] = (globalExists[name] || 0) + 1;
|
|
15274
|
-
}
|
|
15275
|
-
}
|
|
15276
|
-
}
|
|
15277
|
-
});
|
|
15278
|
-
return Object.keys(globalVars);
|
|
15279
|
-
}
|
|
15280
|
-
function getParamPatterns(fnNode) {
|
|
15281
|
-
if (fnNode.type === "ArrowFunctionExpression") {
|
|
15282
|
-
return fnNode.params;
|
|
15283
|
-
}
|
|
15284
|
-
return fnNode.params.map((p) => p.pat);
|
|
15285
|
-
}
|
|
15286
|
-
function fallbackExtractVariables(source) {
|
|
15287
|
-
const vars = /* @__PURE__ */ new Set();
|
|
15288
|
-
const outputRegExp = /\{\{[:=!@]\s*([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
|
|
15289
|
-
let m;
|
|
15290
|
-
while ((m = outputRegExp.exec(source)) !== null) {
|
|
15291
|
-
vars.add(m[1]);
|
|
15292
|
-
}
|
|
15293
|
-
const eachRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
|
|
15294
|
-
while ((m = eachRegExp.exec(source)) !== null) {
|
|
15295
|
-
vars.add(m[1]);
|
|
15296
|
-
}
|
|
15297
|
-
const ifRegExp = /\{\{(?:else\s+)?if\s+([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
|
|
15298
|
-
while ((m = ifRegExp.exec(source)) !== null) {
|
|
15299
|
-
vars.add(m[1]);
|
|
15300
|
-
}
|
|
15301
|
-
return Array.from(vars).filter((v) => !BUILTIN_GLOBALS.has(v));
|
|
15302
|
-
}
|
|
15303
|
-
function walkSwcAst(ast, visitors) {
|
|
15304
|
-
function visit(node) {
|
|
15305
|
-
const type = node.type;
|
|
15306
|
-
if (visitors[type]) {
|
|
15307
|
-
visitors[type](node);
|
|
15308
|
-
}
|
|
15309
|
-
for (const key of Object.keys(node)) {
|
|
15310
|
-
if (key === "type" || key === "span" || key === "ctxt") continue;
|
|
15311
|
-
if (type === "MemberExpression" && key === "property") {
|
|
15312
|
-
const me = node;
|
|
15313
|
-
if (me.property.type !== "Computed") continue;
|
|
15314
|
-
}
|
|
15315
|
-
if (type === "KeyValueProperty" && key === "key") {
|
|
15316
|
-
const kv = node;
|
|
15317
|
-
if (kv.key.type !== "Computed") continue;
|
|
15318
|
-
}
|
|
15319
|
-
if (type === "MethodProperty" && key === "key") {
|
|
15320
|
-
const mp = node;
|
|
15321
|
-
if (mp.key.type !== "Computed") continue;
|
|
15322
|
-
}
|
|
15323
|
-
const child = Reflect.get(node, key);
|
|
15324
|
-
if (Array.isArray(child)) {
|
|
15325
|
-
for (const item of child) {
|
|
15326
|
-
if (isSwcNode(item)) visit(item);
|
|
15327
|
-
}
|
|
15328
|
-
} else if (isSwcNode(child)) {
|
|
15329
|
-
visit(child);
|
|
15330
|
-
}
|
|
15331
|
-
}
|
|
15332
|
-
}
|
|
15333
|
-
visit(ast);
|
|
15334
|
-
}
|
|
15335
|
-
function isSwcNode(v) {
|
|
15336
|
-
return !!v && typeof v === "object" && typeof v.type === "string";
|
|
15337
|
-
}
|
|
15338
|
-
var BUILTIN_GLOBALS = /* @__PURE__ */ new Set([
|
|
15339
|
-
// ─── Template runtime helpers (injected by compileToFunction) ───────
|
|
15340
|
-
//
|
|
15341
|
-
// These variables appear in the generated template function signature
|
|
15342
|
-
// or body. They must be excluded from extractGlobalVars() so that
|
|
15343
|
-
// they are not mistaken for user data variables and destructured from $data.
|
|
15344
|
-
// SPLITTER character constant (same as \x1e), used as namespace separator
|
|
15345
|
-
// for refData keys, event attribute encoding, and internal data structures.
|
|
15346
|
-
// Declared as: let $splitter='\x1e'
|
|
15347
|
-
"$splitter",
|
|
15348
|
-
// Data — the data object passed from Updater to the template function.
|
|
15349
|
-
// User variables are destructured from $data at the top of the function:
|
|
15350
|
-
// let {name, age} = $data;
|
|
15351
|
-
// This is the first parameter of the generated arrow function.
|
|
15352
|
-
"$data",
|
|
15353
|
-
// Null-safe toString: v => '' + (v == null ? '' : v)
|
|
15354
|
-
// Converts null/undefined to empty string, otherwise calls toString().
|
|
15355
|
-
// Wraps every {{!raw}} output to prevent "null" / "undefined" rendering.
|
|
15356
|
-
"$strSafe",
|
|
15357
|
-
// HTML entity encoder: v => $strSafe(v).replace(/[&<>"'`]/g, entityMap)
|
|
15358
|
-
// Encodes &, <, >, ", ', ` to HTML entities (& < etc.)
|
|
15359
|
-
// Applied to all {{=escaped}} and {{:binding}} outputs.
|
|
15360
|
-
"$encHtml",
|
|
15361
|
-
// HTML entity map — internal object used by $encHtml:
|
|
15362
|
-
// {'&':'amp','<':'gt','>':'gt','"':'#34','\'':'#39','`':'#96'}
|
|
15363
|
-
// Not a standalone function; referenced inside $encHtml's closure.
|
|
15364
|
-
"$entMap",
|
|
15365
|
-
// HTML entity RegExp — internal regexp used by $encHtml:
|
|
15366
|
-
// /[&<>"'`]/g
|
|
15367
|
-
"$entReg",
|
|
15368
|
-
// HTML entity replacer function — internal helper used by $encHtml:
|
|
15369
|
-
// m => '&' + $entMap[m] + ';'
|
|
15370
|
-
// Maps matched character to its entity string.
|
|
15371
|
-
"$entFn",
|
|
15372
|
-
// Output buffer — the string accumulator for rendered HTML.
|
|
15373
|
-
// All template output is appended via $out += '...'.
|
|
15374
|
-
// Declared as: let $out = ''
|
|
15375
|
-
"$out",
|
|
15376
|
-
// Reference lookup: (refData, value) => key
|
|
15377
|
-
// Finds or allocates a SPLITTER-prefixed key in refData for a given
|
|
15378
|
-
// object reference. Used by {{@ref}} operator for passing object
|
|
15379
|
-
// references to child views via v-lark attributes.
|
|
15380
|
-
"$refFn",
|
|
15381
|
-
// URI encoder: v => encodeURIComponent($strSafe(v)).replace(/[!')(*]/g, extraMap)
|
|
15382
|
-
// Extends encodeURIComponent with encoding of ! ' ( ) *.
|
|
15383
|
-
// Applied to values in @event URL parameters and {{!uri}} contexts.
|
|
15384
|
-
"$encUri",
|
|
15385
|
-
// URI encode map — internal object used by $encUri:
|
|
15386
|
-
// {'!':'%21','\'':'%27','(':'%28',')':'%29','*':'%2A'}
|
|
15387
|
-
"$uriMap",
|
|
15388
|
-
// URI encode replacer — internal helper used by $encUri:
|
|
15389
|
-
// m => $uriMap[m]
|
|
15390
|
-
"$uriFn",
|
|
15391
|
-
// URI encode regexp — internal regexp used by $encUri:
|
|
15392
|
-
// /[!')(*]/g
|
|
15393
|
-
"$uriReg",
|
|
15394
|
-
// Quote encoder: v => $strSafe(v).replace(/['"\\]/g, '\\$&')
|
|
15395
|
-
// Escapes quotes and backslashes for safe embedding in HTML attribute
|
|
15396
|
-
// values (e.g. data-json='...').
|
|
15397
|
-
"$encQuote",
|
|
15398
|
-
// Quote encode regexp — internal regexp used by $encQuote:
|
|
15399
|
-
// /['"\\]/g
|
|
15400
|
-
"$qReg",
|
|
15401
|
-
// View ID — the unique identifier of the owning View instance.
|
|
15402
|
-
// Injected into @event attribute values at render time so that
|
|
15403
|
-
// EventDelegator can dispatch events to the correct View handler.
|
|
15404
|
-
// The \x1f placeholder in compiled output is replaced with '+$viewId+'.
|
|
15405
|
-
"$viewId",
|
|
15406
|
-
// Debug: current expression text — stores the template expression being
|
|
15407
|
-
// evaluated, for error reporting. Only present in debug mode.
|
|
15408
|
-
// e.g. $dbgExpr='<%=user.name%>'
|
|
15409
|
-
"$dbgExpr",
|
|
15410
|
-
// Debug: original art syntax — stores the {{}} template syntax before
|
|
15411
|
-
// conversion, for error reporting. Only present in debug mode.
|
|
15412
|
-
// e.g. $dbgArt='{{=user.name}}'
|
|
15413
|
-
"$dbgArt",
|
|
15414
|
-
// Debug: source line number — tracks the current line in the template
|
|
15415
|
-
// source, for error reporting. Only present in debug mode.
|
|
15416
|
-
"$dbgLine",
|
|
15417
|
-
// RefData alias — fallback reference lookup table.
|
|
15418
|
-
// Defaults to $data when no explicit $refAlt is provided.
|
|
15419
|
-
// Ensures $refFn() does not crash when @ operator is used without refData.
|
|
15420
|
-
"$refAlt",
|
|
15421
|
-
// Temporary variable — used by the compiler for intermediate
|
|
15422
|
-
// expression results in generated code (e.g. loop variables,
|
|
15423
|
-
// conditional branches). Declared as: let $tmp
|
|
15424
|
-
"$tmp",
|
|
15425
|
-
// JS literals
|
|
15426
|
-
"undefined",
|
|
15427
|
-
"null",
|
|
15428
|
-
"true",
|
|
15429
|
-
"false",
|
|
15430
|
-
"NaN",
|
|
15431
|
-
"Infinity",
|
|
15432
|
-
// JS built-in globals
|
|
15433
|
-
"window",
|
|
15434
|
-
"self",
|
|
15435
|
-
"globalThis",
|
|
15436
|
-
"document",
|
|
15437
|
-
"console",
|
|
15438
|
-
"JSON",
|
|
15439
|
-
"Math",
|
|
15440
|
-
"Intl",
|
|
15441
|
-
"Promise",
|
|
15442
|
-
"Symbol",
|
|
15443
|
-
"Number",
|
|
15444
|
-
"String",
|
|
15445
|
-
"Boolean",
|
|
15446
|
-
"Array",
|
|
15447
|
-
"Object",
|
|
15448
|
-
"Date",
|
|
15449
|
-
"RegExp",
|
|
15450
|
-
"Error",
|
|
15451
|
-
"TypeError",
|
|
15452
|
-
"RangeError",
|
|
15453
|
-
"SyntaxError",
|
|
15454
|
-
"Map",
|
|
15455
|
-
"Set",
|
|
15456
|
-
"WeakMap",
|
|
15457
|
-
"WeakSet",
|
|
15458
|
-
"Proxy",
|
|
15459
|
-
"Reflect",
|
|
15460
|
-
"ArrayBuffer",
|
|
15461
|
-
"DataView",
|
|
15462
|
-
"Float32Array",
|
|
15463
|
-
"Float64Array",
|
|
15464
|
-
"Int8Array",
|
|
15465
|
-
"Int16Array",
|
|
15466
|
-
"Int32Array",
|
|
15467
|
-
"Uint8Array",
|
|
15468
|
-
"Uint16Array",
|
|
15469
|
-
"Uint32Array",
|
|
15470
|
-
"Uint8ClampedArray",
|
|
15471
|
-
// Functions
|
|
15472
|
-
"parseInt",
|
|
15473
|
-
"parseFloat",
|
|
15474
|
-
"isNaN",
|
|
15475
|
-
"isFinite",
|
|
15476
|
-
"encodeURIComponent",
|
|
15477
|
-
"decodeURIComponent",
|
|
15478
|
-
"encodeURI",
|
|
15479
|
-
"decodeURI",
|
|
15480
|
-
// SWC helpers
|
|
15481
|
-
"arguments",
|
|
15482
|
-
"this",
|
|
15483
|
-
"require",
|
|
15484
|
-
// Lark framework
|
|
15485
|
-
"Lark"
|
|
15486
|
-
]);
|
|
15487
|
-
|
|
15488
15162
|
// src/compiler/extract-global-vars.ts
|
|
15489
15163
|
init_esm_shims();
|
|
15490
15164
|
var import_parser = __toESM(require_lib(), 1);
|
|
15491
|
-
async function
|
|
15165
|
+
async function extractGlobalVars(source) {
|
|
15492
15166
|
const { protectedSource, comments: _comments } = protectComments(source);
|
|
15493
15167
|
const viewEventProcessed = processViewEvents(protectedSource);
|
|
15494
15168
|
const converted = convertArtSyntax(viewEventProcessed, false);
|
|
@@ -15525,10 +15199,10 @@ async function extractGlobalVars2(source) {
|
|
|
15525
15199
|
allowAwaitOutsideFunction: true
|
|
15526
15200
|
});
|
|
15527
15201
|
} catch {
|
|
15528
|
-
return
|
|
15202
|
+
return fallbackExtractVariables(source);
|
|
15529
15203
|
}
|
|
15530
15204
|
const globalExists = {};
|
|
15531
|
-
for (const name of
|
|
15205
|
+
for (const name of BUILTIN_GLOBALS) globalExists[name] = 1;
|
|
15532
15206
|
const globalVars = /* @__PURE__ */ Object.create(null);
|
|
15533
15207
|
const fnRange = [];
|
|
15534
15208
|
walkAst(ast, {
|
|
@@ -15587,22 +15261,22 @@ async function extractGlobalVars2(source) {
|
|
|
15587
15261
|
});
|
|
15588
15262
|
return Object.keys(globalVars);
|
|
15589
15263
|
}
|
|
15590
|
-
function
|
|
15264
|
+
function fallbackExtractVariables(source) {
|
|
15591
15265
|
const vars = /* @__PURE__ */ new Set();
|
|
15592
15266
|
const outputRegExp = /\{\{[:=!@]\s*([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
|
|
15593
15267
|
let m;
|
|
15594
15268
|
while ((m = outputRegExp.exec(source)) !== null) {
|
|
15595
15269
|
vars.add(m[1]);
|
|
15596
15270
|
}
|
|
15597
|
-
const
|
|
15598
|
-
while ((m =
|
|
15271
|
+
const forOfRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
|
|
15272
|
+
while ((m = forOfRegExp.exec(source)) !== null) {
|
|
15599
15273
|
vars.add(m[1]);
|
|
15600
15274
|
}
|
|
15601
15275
|
const ifRegExp = /\{\{(?:else\s+)?if\s+([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
|
|
15602
15276
|
while ((m = ifRegExp.exec(source)) !== null) {
|
|
15603
15277
|
vars.add(m[1]);
|
|
15604
15278
|
}
|
|
15605
|
-
return Array.from(vars).filter((v) => !
|
|
15279
|
+
return Array.from(vars).filter((v) => !BUILTIN_GLOBALS.has(v));
|
|
15606
15280
|
}
|
|
15607
15281
|
function walkAst(ast, visitors) {
|
|
15608
15282
|
function visit(node) {
|
|
@@ -15640,7 +15314,7 @@ function walkAst(ast, visitors) {
|
|
|
15640
15314
|
function isAstNode(v) {
|
|
15641
15315
|
return !!v && typeof v === "object" && typeof v.type === "string";
|
|
15642
15316
|
}
|
|
15643
|
-
var
|
|
15317
|
+
var BUILTIN_GLOBALS = /* @__PURE__ */ new Set([
|
|
15644
15318
|
// ─── Template runtime helpers (injected by compileToFunction) ───────
|
|
15645
15319
|
//
|
|
15646
15320
|
// These variables appear in the generated template function signature
|
|
@@ -15879,8 +15553,8 @@ function compileToFunction(source, debug, file) {
|
|
|
15879
15553
|
return `($data,$viewId,$refAlt,$encHtml,$strSafe,$encUri,$refFn,$encQuote)=>{${fullSource}}`;
|
|
15880
15554
|
}
|
|
15881
15555
|
async function compileTemplate(source, options = {}) {
|
|
15882
|
-
const { debug = false, file, virtualDom = false
|
|
15883
|
-
const globalVars = options.globalVars ?? await
|
|
15556
|
+
const { debug = false, file, virtualDom = false } = options;
|
|
15557
|
+
const globalVars = options.globalVars ?? await extractGlobalVars(source);
|
|
15884
15558
|
const { protectedSource, comments } = protectComments(source);
|
|
15885
15559
|
const converted = convertArtSyntax(protectedSource, debug);
|
|
15886
15560
|
const viewEventProcessed = processViewEvents(converted);
|
|
@@ -15917,13 +15591,12 @@ export default function(data, viewId, refData) {
|
|
|
15917
15591
|
async function larkMvcLoader(source) {
|
|
15918
15592
|
try {
|
|
15919
15593
|
const options = this.getOptions();
|
|
15920
|
-
const { debug = false, virtualDom = false
|
|
15921
|
-
const globalVars = await
|
|
15594
|
+
const { debug = false, virtualDom = false } = options;
|
|
15595
|
+
const globalVars = await extractGlobalVars(source);
|
|
15922
15596
|
return await compileTemplate(source, {
|
|
15923
15597
|
debug,
|
|
15924
15598
|
globalVars,
|
|
15925
|
-
virtualDom
|
|
15926
|
-
useSwc
|
|
15599
|
+
virtualDom
|
|
15927
15600
|
});
|
|
15928
15601
|
} catch (err) {
|
|
15929
15602
|
console.error(err);
|
|
@@ -15936,7 +15609,6 @@ var LarkMvcPlugin = class {
|
|
|
15936
15609
|
this.options = {
|
|
15937
15610
|
debug: false,
|
|
15938
15611
|
virtualDom: false,
|
|
15939
|
-
useSwc: false,
|
|
15940
15612
|
test: /\.html$/,
|
|
15941
15613
|
exclude: /node_modules/,
|
|
15942
15614
|
...options
|
|
@@ -15947,7 +15619,7 @@ var LarkMvcPlugin = class {
|
|
|
15947
15619
|
* Called by rspack when the plugin is applied.
|
|
15948
15620
|
*/
|
|
15949
15621
|
apply(compiler) {
|
|
15950
|
-
const { debug, virtualDom,
|
|
15622
|
+
const { debug, virtualDom, test, exclude } = this.options;
|
|
15951
15623
|
compiler.options.module = compiler.options.module || {};
|
|
15952
15624
|
compiler.options.module.rules = compiler.options.module.rules || [];
|
|
15953
15625
|
compiler.options.module.rules.push({
|
|
@@ -15961,7 +15633,7 @@ var LarkMvcPlugin = class {
|
|
|
15961
15633
|
// __filename is provided by tsup's ESM shim (shims: true) in ESM output,
|
|
15962
15634
|
// and is a native CJS global in CJS output.
|
|
15963
15635
|
loader: __filename,
|
|
15964
|
-
options: { debug, virtualDom
|
|
15636
|
+
options: { debug, virtualDom }
|
|
15965
15637
|
}
|
|
15966
15638
|
]
|
|
15967
15639
|
});
|