@lark.js/mvc 0.0.8 → 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/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: {{for-in obj as val [key]}}`
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 = { ...BUILTIN_GLOBALS };
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) => !BUILTIN_GLOBAL_SET.has(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: 1,
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: 1,
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: 1,
15219
+ "$strSafe",
15219
15220
  // HTML entity encoder: v => $strSafe(v).replace(/[&<>"'`]/g, entityMap)
15220
15221
  // Encodes &, <, >, ", ', ` to HTML entities (&amp; &lt; etc.)
15221
15222
  // Applied to all {{=escaped}} and {{:binding}} outputs.
15222
- $encHtml: 1,
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: 1,
15227
+ "$entMap",
15227
15228
  // HTML entity RegExp — internal regexp used by $encHtml:
15228
15229
  // /[&<>"'`]/g
15229
- $entReg: 1,
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: 1,
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: 1,
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: 1,
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: 1,
15247
+ "$encUri",
15247
15248
  // URI encode map — internal object used by $encUri:
15248
15249
  // {'!':'%21','\'':'%27','(':'%28',')':'%29','*':'%2A'}
15249
- $uriMap: 1,
15250
+ "$uriMap",
15250
15251
  // URI encode replacer — internal helper used by $encUri:
15251
15252
  // m => $uriMap[m]
15252
- $uriFn: 1,
15253
+ "$uriFn",
15253
15254
  // URI encode regexp — internal regexp used by $encUri:
15254
15255
  // /[!')(*]/g
15255
- $uriReg: 1,
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: 1,
15260
+ "$encQuote",
15260
15261
  // Quote encode regexp — internal regexp used by $encQuote:
15261
15262
  // /['"\\]/g
15262
- $qReg: 1,
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: 1,
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: 1,
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: 1,
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: 1,
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: 1,
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: 1,
15287
+ "$tmp",
15287
15288
  // JS literals
15288
- undefined: 1,
15289
- null: 1,
15290
- true: 1,
15291
- false: 1,
15292
- NaN: 1,
15293
- Infinity: 1,
15289
+ "undefined",
15290
+ "null",
15291
+ "true",
15292
+ "false",
15293
+ "NaN",
15294
+ "Infinity",
15294
15295
  // JS built-in globals
15295
- window: 1,
15296
- self: 1,
15297
- globalThis: 1,
15298
- document: 1,
15299
- console: 1,
15300
- JSON: 1,
15301
- Math: 1,
15302
- Intl: 1,
15303
- Promise: 1,
15304
- Symbol: 1,
15305
- Number: 1,
15306
- String: 1,
15307
- Boolean: 1,
15308
- Array: 1,
15309
- Object: 1,
15310
- Date: 1,
15311
- RegExp: 1,
15312
- Error: 1,
15313
- TypeError: 1,
15314
- RangeError: 1,
15315
- SyntaxError: 1,
15316
- Map: 1,
15317
- Set: 1,
15318
- WeakMap: 1,
15319
- WeakSet: 1,
15320
- Proxy: 1,
15321
- Reflect: 1,
15322
- ArrayBuffer: 1,
15323
- DataView: 1,
15324
- Float32Array: 1,
15325
- Float64Array: 1,
15326
- Int8Array: 1,
15327
- Int16Array: 1,
15328
- Int32Array: 1,
15329
- Uint8Array: 1,
15330
- Uint16Array: 1,
15331
- Uint32Array: 1,
15332
- Uint8ClampedArray: 1,
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: 1,
15335
- parseFloat: 1,
15336
- isNaN: 1,
15337
- isFinite: 1,
15338
- encodeURIComponent: 1,
15339
- decodeURIComponent: 1,
15340
- encodeURI: 1,
15341
- decodeURI: 1,
15335
+ "parseInt",
15336
+ "parseFloat",
15337
+ "isNaN",
15338
+ "isFinite",
15339
+ "encodeURIComponent",
15340
+ "decodeURIComponent",
15341
+ "encodeURI",
15342
+ "decodeURI",
15342
15343
  // Babel helpers
15343
- arguments: 1,
15344
- this: 1,
15345
- require: 1,
15344
+ "arguments",
15345
+ "this",
15346
+ "require",
15346
15347
  // Lark framework
15347
- Lark: 1
15348
- };
15349
- var BUILTIN_GLOBAL_SET = new Set(Object.keys(BUILTIN_GLOBALS));
15348
+ "Lark"
15349
+ ]);
15350
15350
  export {
15351
15351
  compileTemplate,
15352
15352
  extractGlobalVars