@lark.js/mvc 0.0.9 → 0.0.10
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 -22
- package/dist/{chunk-3HSA7OHB.js → chunk-SIQF4YLC.js} +83 -83
- package/dist/compiler.cjs +83 -83
- package/dist/compiler.js +83 -83
- package/dist/index.cjs +69 -184
- package/dist/index.d.cts +160 -407
- package/dist/index.d.ts +160 -407
- package/dist/index.js +69 -149
- package/dist/runtime.cjs +34 -9
- package/dist/runtime.d.cts +22 -13
- package/dist/runtime.d.ts +22 -13
- package/dist/runtime.js +33 -10
- package/dist/vite.cjs +83 -83
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +83 -83
- package/dist/webpack.js +1 -1
- package/package.json +1 -1
package/dist/compiler.js
CHANGED
|
@@ -14847,7 +14847,7 @@ function convertArtExpression(code, debug, lineNo, blockStack = []) {
|
|
|
14847
14847
|
const object = tokens[0];
|
|
14848
14848
|
if (tokens.length > 1 && tokens[1] !== "as") {
|
|
14849
14849
|
throw new Error(
|
|
14850
|
-
`[@lark.js/mvc error] bad forIn syntax: {{${code}}}. Expected "as" keyword, got "${tokens[1]}". Usage: {{
|
|
14850
|
+
`[@lark.js/mvc error] bad forIn syntax: {{${code}}}. Expected "as" keyword, got "${tokens[1]}". Usage: {{forIn obj as val [key]}}`
|
|
14851
14851
|
);
|
|
14852
14852
|
}
|
|
14853
14853
|
const restTokens2 = tokens.slice(2);
|
|
@@ -15084,7 +15084,8 @@ function extractGlobalVars(source) {
|
|
|
15084
15084
|
} catch {
|
|
15085
15085
|
return fallbackExtractVariables(source);
|
|
15086
15086
|
}
|
|
15087
|
-
const globalExists = {
|
|
15087
|
+
const globalExists = {};
|
|
15088
|
+
for (const name of BUILTIN_GLOBALS) globalExists[name] = 1;
|
|
15088
15089
|
const globalVars = /* @__PURE__ */ Object.create(null);
|
|
15089
15090
|
const fnRange = [];
|
|
15090
15091
|
walkAst(ast, {
|
|
@@ -15158,7 +15159,7 @@ function fallbackExtractVariables(source) {
|
|
|
15158
15159
|
while ((m = ifRegExp.exec(source)) !== null) {
|
|
15159
15160
|
vars.add(m[1]);
|
|
15160
15161
|
}
|
|
15161
|
-
return Array.from(vars).filter((v) => !
|
|
15162
|
+
return Array.from(vars).filter((v) => !BUILTIN_GLOBALS.has(v));
|
|
15162
15163
|
}
|
|
15163
15164
|
function walkAst(ast, visitors) {
|
|
15164
15165
|
function visit(node) {
|
|
@@ -15197,7 +15198,7 @@ function walkAst(ast, visitors) {
|
|
|
15197
15198
|
function isAstNode(v) {
|
|
15198
15199
|
return !!v && typeof v === "object" && typeof v.type === "string";
|
|
15199
15200
|
}
|
|
15200
|
-
var BUILTIN_GLOBALS =
|
|
15201
|
+
var BUILTIN_GLOBALS = /* @__PURE__ */ new Set([
|
|
15201
15202
|
// ─── Template runtime helpers (injected by compileToFunction) ───────
|
|
15202
15203
|
//
|
|
15203
15204
|
// These variables appear in the generated template function signature
|
|
@@ -15206,147 +15207,146 @@ var BUILTIN_GLOBALS = {
|
|
|
15206
15207
|
// SPLITTER character constant (same as \x1e), used as namespace separator
|
|
15207
15208
|
// for refData keys, event attribute encoding, and internal data structures.
|
|
15208
15209
|
// Declared as: let $splitter='\x1e'
|
|
15209
|
-
$splitter
|
|
15210
|
+
"$splitter",
|
|
15210
15211
|
// Data — the data object passed from Updater to the template function.
|
|
15211
15212
|
// User variables are destructured from $data at the top of the function:
|
|
15212
15213
|
// let {name, age} = $data;
|
|
15213
15214
|
// This is the first parameter of the generated arrow function.
|
|
15214
|
-
$data
|
|
15215
|
+
"$data",
|
|
15215
15216
|
// Null-safe toString: v => '' + (v == null ? '' : v)
|
|
15216
15217
|
// Converts null/undefined to empty string, otherwise calls toString().
|
|
15217
15218
|
// Wraps every {{!raw}} output to prevent "null" / "undefined" rendering.
|
|
15218
|
-
$strSafe
|
|
15219
|
+
"$strSafe",
|
|
15219
15220
|
// HTML entity encoder: v => $strSafe(v).replace(/[&<>"'`]/g, entityMap)
|
|
15220
15221
|
// Encodes &, <, >, ", ', ` to HTML entities (& < etc.)
|
|
15221
15222
|
// Applied to all {{=escaped}} and {{:binding}} outputs.
|
|
15222
|
-
$encHtml
|
|
15223
|
+
"$encHtml",
|
|
15223
15224
|
// HTML entity map — internal object used by $encHtml:
|
|
15224
15225
|
// {'&':'amp','<':'gt','>':'gt','"':'#34','\'':'#39','`':'#96'}
|
|
15225
15226
|
// Not a standalone function; referenced inside $encHtml's closure.
|
|
15226
|
-
$entMap
|
|
15227
|
+
"$entMap",
|
|
15227
15228
|
// HTML entity RegExp — internal regexp used by $encHtml:
|
|
15228
15229
|
// /[&<>"'`]/g
|
|
15229
|
-
$entReg
|
|
15230
|
+
"$entReg",
|
|
15230
15231
|
// HTML entity replacer function — internal helper used by $encHtml:
|
|
15231
15232
|
// m => '&' + $entMap[m] + ';'
|
|
15232
15233
|
// Maps matched character to its entity string.
|
|
15233
|
-
$entFn
|
|
15234
|
+
"$entFn",
|
|
15234
15235
|
// Output buffer — the string accumulator for rendered HTML.
|
|
15235
15236
|
// All template output is appended via $out += '...'.
|
|
15236
15237
|
// Declared as: let $out = ''
|
|
15237
|
-
$out
|
|
15238
|
+
"$out",
|
|
15238
15239
|
// Reference lookup: (refData, value) => key
|
|
15239
15240
|
// Finds or allocates a SPLITTER-prefixed key in refData for a given
|
|
15240
15241
|
// object reference. Used by {{@ref}} operator for passing object
|
|
15241
15242
|
// references to child views via v-lark attributes.
|
|
15242
|
-
$refFn
|
|
15243
|
+
"$refFn",
|
|
15243
15244
|
// URI encoder: v => encodeURIComponent($strSafe(v)).replace(/[!')(*]/g, extraMap)
|
|
15244
15245
|
// Extends encodeURIComponent with encoding of ! ' ( ) *.
|
|
15245
15246
|
// Applied to values in @event URL parameters and {{!uri}} contexts.
|
|
15246
|
-
$encUri
|
|
15247
|
+
"$encUri",
|
|
15247
15248
|
// URI encode map — internal object used by $encUri:
|
|
15248
15249
|
// {'!':'%21','\'':'%27','(':'%28',')':'%29','*':'%2A'}
|
|
15249
|
-
$uriMap
|
|
15250
|
+
"$uriMap",
|
|
15250
15251
|
// URI encode replacer — internal helper used by $encUri:
|
|
15251
15252
|
// m => $uriMap[m]
|
|
15252
|
-
$uriFn
|
|
15253
|
+
"$uriFn",
|
|
15253
15254
|
// URI encode regexp — internal regexp used by $encUri:
|
|
15254
15255
|
// /[!')(*]/g
|
|
15255
|
-
$uriReg
|
|
15256
|
+
"$uriReg",
|
|
15256
15257
|
// Quote encoder: v => $strSafe(v).replace(/['"\\]/g, '\\$&')
|
|
15257
15258
|
// Escapes quotes and backslashes for safe embedding in HTML attribute
|
|
15258
15259
|
// values (e.g. data-json='...').
|
|
15259
|
-
$encQuote
|
|
15260
|
+
"$encQuote",
|
|
15260
15261
|
// Quote encode regexp — internal regexp used by $encQuote:
|
|
15261
15262
|
// /['"\\]/g
|
|
15262
|
-
$qReg
|
|
15263
|
+
"$qReg",
|
|
15263
15264
|
// View ID — the unique identifier of the owning View instance.
|
|
15264
15265
|
// Injected into @event attribute values at render time so that
|
|
15265
15266
|
// EventDelegator can dispatch events to the correct View handler.
|
|
15266
15267
|
// The \x1f placeholder in compiled output is replaced with '+$viewId+'.
|
|
15267
|
-
$viewId
|
|
15268
|
+
"$viewId",
|
|
15268
15269
|
// Debug: current expression text — stores the template expression being
|
|
15269
15270
|
// evaluated, for error reporting. Only present in debug mode.
|
|
15270
15271
|
// e.g. $dbgExpr='<%=user.name%>'
|
|
15271
|
-
$dbgExpr
|
|
15272
|
+
"$dbgExpr",
|
|
15272
15273
|
// Debug: original art syntax — stores the {{}} template syntax before
|
|
15273
15274
|
// conversion, for error reporting. Only present in debug mode.
|
|
15274
15275
|
// e.g. $dbgArt='{{=user.name}}'
|
|
15275
|
-
$dbgArt
|
|
15276
|
+
"$dbgArt",
|
|
15276
15277
|
// Debug: source line number — tracks the current line in the template
|
|
15277
15278
|
// source, for error reporting. Only present in debug mode.
|
|
15278
|
-
$dbgLine
|
|
15279
|
+
"$dbgLine",
|
|
15279
15280
|
// RefData alias — fallback reference lookup table.
|
|
15280
15281
|
// Defaults to $data when no explicit $refAlt is provided.
|
|
15281
15282
|
// Ensures $refFn() does not crash when @ operator is used without refData.
|
|
15282
|
-
$refAlt
|
|
15283
|
+
"$refAlt",
|
|
15283
15284
|
// Temporary variable — used by the compiler for intermediate
|
|
15284
15285
|
// expression results in generated code (e.g. loop variables,
|
|
15285
15286
|
// conditional branches). Declared as: let $tmp
|
|
15286
|
-
$tmp
|
|
15287
|
+
"$tmp",
|
|
15287
15288
|
// JS literals
|
|
15288
|
-
undefined
|
|
15289
|
-
null
|
|
15290
|
-
true
|
|
15291
|
-
false
|
|
15292
|
-
NaN
|
|
15293
|
-
Infinity
|
|
15289
|
+
"undefined",
|
|
15290
|
+
"null",
|
|
15291
|
+
"true",
|
|
15292
|
+
"false",
|
|
15293
|
+
"NaN",
|
|
15294
|
+
"Infinity",
|
|
15294
15295
|
// JS built-in globals
|
|
15295
|
-
window
|
|
15296
|
-
self
|
|
15297
|
-
globalThis
|
|
15298
|
-
document
|
|
15299
|
-
console
|
|
15300
|
-
JSON
|
|
15301
|
-
Math
|
|
15302
|
-
Intl
|
|
15303
|
-
Promise
|
|
15304
|
-
Symbol
|
|
15305
|
-
Number
|
|
15306
|
-
String
|
|
15307
|
-
Boolean
|
|
15308
|
-
Array
|
|
15309
|
-
Object
|
|
15310
|
-
Date
|
|
15311
|
-
RegExp
|
|
15312
|
-
Error
|
|
15313
|
-
TypeError
|
|
15314
|
-
RangeError
|
|
15315
|
-
SyntaxError
|
|
15316
|
-
Map
|
|
15317
|
-
Set
|
|
15318
|
-
WeakMap
|
|
15319
|
-
WeakSet
|
|
15320
|
-
Proxy
|
|
15321
|
-
Reflect
|
|
15322
|
-
ArrayBuffer
|
|
15323
|
-
DataView
|
|
15324
|
-
Float32Array
|
|
15325
|
-
Float64Array
|
|
15326
|
-
Int8Array
|
|
15327
|
-
Int16Array
|
|
15328
|
-
Int32Array
|
|
15329
|
-
Uint8Array
|
|
15330
|
-
Uint16Array
|
|
15331
|
-
Uint32Array
|
|
15332
|
-
Uint8ClampedArray
|
|
15296
|
+
"window",
|
|
15297
|
+
"self",
|
|
15298
|
+
"globalThis",
|
|
15299
|
+
"document",
|
|
15300
|
+
"console",
|
|
15301
|
+
"JSON",
|
|
15302
|
+
"Math",
|
|
15303
|
+
"Intl",
|
|
15304
|
+
"Promise",
|
|
15305
|
+
"Symbol",
|
|
15306
|
+
"Number",
|
|
15307
|
+
"String",
|
|
15308
|
+
"Boolean",
|
|
15309
|
+
"Array",
|
|
15310
|
+
"Object",
|
|
15311
|
+
"Date",
|
|
15312
|
+
"RegExp",
|
|
15313
|
+
"Error",
|
|
15314
|
+
"TypeError",
|
|
15315
|
+
"RangeError",
|
|
15316
|
+
"SyntaxError",
|
|
15317
|
+
"Map",
|
|
15318
|
+
"Set",
|
|
15319
|
+
"WeakMap",
|
|
15320
|
+
"WeakSet",
|
|
15321
|
+
"Proxy",
|
|
15322
|
+
"Reflect",
|
|
15323
|
+
"ArrayBuffer",
|
|
15324
|
+
"DataView",
|
|
15325
|
+
"Float32Array",
|
|
15326
|
+
"Float64Array",
|
|
15327
|
+
"Int8Array",
|
|
15328
|
+
"Int16Array",
|
|
15329
|
+
"Int32Array",
|
|
15330
|
+
"Uint8Array",
|
|
15331
|
+
"Uint16Array",
|
|
15332
|
+
"Uint32Array",
|
|
15333
|
+
"Uint8ClampedArray",
|
|
15333
15334
|
// Functions
|
|
15334
|
-
parseInt
|
|
15335
|
-
parseFloat
|
|
15336
|
-
isNaN
|
|
15337
|
-
isFinite
|
|
15338
|
-
encodeURIComponent
|
|
15339
|
-
decodeURIComponent
|
|
15340
|
-
encodeURI
|
|
15341
|
-
decodeURI
|
|
15335
|
+
"parseInt",
|
|
15336
|
+
"parseFloat",
|
|
15337
|
+
"isNaN",
|
|
15338
|
+
"isFinite",
|
|
15339
|
+
"encodeURIComponent",
|
|
15340
|
+
"decodeURIComponent",
|
|
15341
|
+
"encodeURI",
|
|
15342
|
+
"decodeURI",
|
|
15342
15343
|
// Babel helpers
|
|
15343
|
-
arguments
|
|
15344
|
-
this
|
|
15345
|
-
require
|
|
15344
|
+
"arguments",
|
|
15345
|
+
"this",
|
|
15346
|
+
"require",
|
|
15346
15347
|
// Lark framework
|
|
15347
|
-
Lark
|
|
15348
|
-
|
|
15349
|
-
var BUILTIN_GLOBAL_SET = new Set(Object.keys(BUILTIN_GLOBALS));
|
|
15348
|
+
"Lark"
|
|
15349
|
+
]);
|
|
15350
15350
|
export {
|
|
15351
15351
|
compileTemplate,
|
|
15352
15352
|
extractGlobalVars
|