@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/dist/vite.cjs CHANGED
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.41_@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/cjs_shims.js
36
+ // ../../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/cjs_shims.js
37
37
  var init_cjs_shims = __esm({
38
- "../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.41_@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/cjs_shims.js"() {
38
+ "../../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/cjs_shims.js"() {
39
39
  "use strict";
40
40
  }
41
41
  });
@@ -14529,7 +14529,7 @@ var require_lib = __commonJS({
14529
14529
  options = Object.assign({}, options);
14530
14530
  try {
14531
14531
  options.sourceType = "module";
14532
- const parser = getParser2(options, input);
14532
+ const parser = getParser(options, input);
14533
14533
  const ast = parser.parse();
14534
14534
  if (parser.sawUnambiguousESM) {
14535
14535
  return ast;
@@ -14537,7 +14537,7 @@ var require_lib = __commonJS({
14537
14537
  if (parser.ambiguousScriptDifferentAst) {
14538
14538
  try {
14539
14539
  options.sourceType = "script";
14540
- return getParser2(options, input).parse();
14540
+ return getParser(options, input).parse();
14541
14541
  } catch (_unused) {
14542
14542
  }
14543
14543
  } else {
@@ -14547,17 +14547,17 @@ var require_lib = __commonJS({
14547
14547
  } catch (moduleError) {
14548
14548
  try {
14549
14549
  options.sourceType = "script";
14550
- return getParser2(options, input).parse();
14550
+ return getParser(options, input).parse();
14551
14551
  } catch (_unused2) {
14552
14552
  }
14553
14553
  throw moduleError;
14554
14554
  }
14555
14555
  } else {
14556
- return getParser2(options, input).parse();
14556
+ return getParser(options, input).parse();
14557
14557
  }
14558
14558
  }
14559
14559
  function parseExpression(input, options) {
14560
- const parser = getParser2(options, input);
14560
+ const parser = getParser(options, input);
14561
14561
  if (parser.options.strictMode) {
14562
14562
  parser.state.strict = true;
14563
14563
  }
@@ -14571,7 +14571,7 @@ var require_lib = __commonJS({
14571
14571
  return tokenTypes2;
14572
14572
  }
14573
14573
  var tokTypes = generateExportedTokenTypes(tt);
14574
- function getParser2(options, input) {
14574
+ function getParser(options, input) {
14575
14575
  let cls = Parser;
14576
14576
  const pluginsMap = /* @__PURE__ */ new Map();
14577
14577
  if (options != null && options.plugins) {
@@ -14627,8 +14627,8 @@ __export(vite_exports, {
14627
14627
  });
14628
14628
  module.exports = __toCommonJS(vite_exports);
14629
14629
  init_cjs_shims();
14630
- var import_path = __toESM(require("path"), 1);
14631
- var import_fs = __toESM(require("fs"), 1);
14630
+ var import_path = require("path");
14631
+ var import_fs = require("fs");
14632
14632
 
14633
14633
  // src/compiler.ts
14634
14634
  init_cjs_shims();
@@ -15171,336 +15171,10 @@ function compileToVDomFunction(source, debug, file) {
15171
15171
  return `($data,$viewId,$refAlt,$n,$refFn,$encUri,$encQuote)=>{${fullSource}}`;
15172
15172
  }
15173
15173
 
15174
- // src/compiler/swc/extract-global-vars.ts
15175
- init_cjs_shims();
15176
- var parseSyncFn = null;
15177
- var parseSyncLoadAttempted = false;
15178
- async function getParser() {
15179
- if (!parseSyncLoadAttempted) {
15180
- parseSyncLoadAttempted = true;
15181
- try {
15182
- const swc = await import("@swc/core");
15183
- parseSyncFn = swc.parseSync;
15184
- } catch (err) {
15185
- console.error("failed to load @swc/core", err);
15186
- }
15187
- }
15188
- return parseSyncFn;
15189
- }
15190
- async function extractGlobalVars(source) {
15191
- const { protectedSource, comments: _comments } = protectComments(source);
15192
- const viewEventProcessed = processViewEvents(protectedSource);
15193
- const converted = convertArtSyntax(viewEventProcessed, false);
15194
- const template = restoreComments(converted, _comments);
15195
- const templateCmdRegExp = /<%([@=!:])?([\s\S]*?)%>|$/g;
15196
- const fnParts = [];
15197
- const htmlStore = {};
15198
- let htmlIndex = 0;
15199
- let lastIndex = 0;
15200
- const htmlKey = String.fromCharCode(5);
15201
- template.replace(
15202
- templateCmdRegExp,
15203
- (match, operate, content, offset) => {
15204
- const start = operate ? 3 : 2;
15205
- const htmlText = template.substring(lastIndex, offset + start);
15206
- const key = htmlKey + htmlIndex++ + htmlKey;
15207
- htmlStore[key] = htmlText;
15208
- lastIndex = offset + match.length - 2;
15209
- if (operate && content.trim()) {
15210
- fnParts.push(';"' + key + '";', "[" + content + "]");
15211
- } else {
15212
- fnParts.push(';"' + key + '";', content || "");
15213
- }
15214
- return match;
15215
- }
15216
- );
15217
- let fn = fnParts.join("");
15218
- fn = `(function(){${fn}})`;
15219
- const parseSync = await getParser();
15220
- if (!parseSync) {
15221
- return fallbackExtractVariables(source);
15222
- }
15223
- let ast;
15224
- try {
15225
- ast = parseSync(fn, {
15226
- syntax: "ecmascript",
15227
- target: "es2022"
15228
- });
15229
- } catch {
15230
- return fallbackExtractVariables(source);
15231
- }
15232
- const globalExists = {};
15233
- for (const name of BUILTIN_GLOBALS) globalExists[name] = 1;
15234
- const globalVars = /* @__PURE__ */ Object.create(null);
15235
- const fnNodes = [];
15236
- walkSwcAst(ast, {
15237
- VariableDeclarator(node) {
15238
- if (node.id.type === "Identifier") {
15239
- const name = node.id.value;
15240
- globalExists[name] = node.init ? 3 : 2;
15241
- }
15242
- },
15243
- FunctionDeclaration(node) {
15244
- if (node.identifier) {
15245
- globalExists[node.identifier.value] = 3;
15246
- }
15247
- fnNodes.push(node);
15248
- },
15249
- FunctionExpression(node) {
15250
- fnNodes.push(node);
15251
- },
15252
- ArrowFunctionExpression(node) {
15253
- fnNodes.push(node);
15254
- },
15255
- CallExpression(node) {
15256
- if (node.callee.type === "Identifier") {
15257
- globalExists[node.callee.value] = 1;
15258
- }
15259
- }
15260
- });
15261
- const functionParams = /* @__PURE__ */ Object.create(null);
15262
- for (const fnNode of fnNodes) {
15263
- const patterns = getParamPatterns(fnNode);
15264
- for (const pat of patterns) {
15265
- if (pat.type === "Identifier") {
15266
- functionParams[pat.value] = 1;
15267
- } else if (pat.type === "AssignmentPattern" && pat.left.type === "Identifier") {
15268
- functionParams[pat.left.value] = 1;
15269
- } else if (pat.type === "RestElement" && pat.argument.type === "Identifier") {
15270
- functionParams[pat.argument.value] = 1;
15271
- }
15272
- }
15273
- }
15274
- walkSwcAst(ast, {
15275
- Identifier(node) {
15276
- const name = node.value;
15277
- if (globalExists[name]) return;
15278
- if (functionParams[name]) return;
15279
- globalVars[name] = 1;
15280
- },
15281
- AssignmentExpression(node) {
15282
- if (node.left.type === "Identifier") {
15283
- const name = node.left.value;
15284
- if (!globalExists[name] || globalExists[name] === 1) {
15285
- globalExists[name] = (globalExists[name] || 0) + 1;
15286
- }
15287
- }
15288
- }
15289
- });
15290
- return Object.keys(globalVars);
15291
- }
15292
- function getParamPatterns(fnNode) {
15293
- if (fnNode.type === "ArrowFunctionExpression") {
15294
- return fnNode.params;
15295
- }
15296
- return fnNode.params.map((p) => p.pat);
15297
- }
15298
- function fallbackExtractVariables(source) {
15299
- const vars = /* @__PURE__ */ new Set();
15300
- const outputRegExp = /\{\{[:=!@]\s*([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
15301
- let m;
15302
- while ((m = outputRegExp.exec(source)) !== null) {
15303
- vars.add(m[1]);
15304
- }
15305
- const eachRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
15306
- while ((m = eachRegExp.exec(source)) !== null) {
15307
- vars.add(m[1]);
15308
- }
15309
- const ifRegExp = /\{\{(?:else\s+)?if\s+([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
15310
- while ((m = ifRegExp.exec(source)) !== null) {
15311
- vars.add(m[1]);
15312
- }
15313
- return Array.from(vars).filter((v) => !BUILTIN_GLOBALS.has(v));
15314
- }
15315
- function walkSwcAst(ast, visitors) {
15316
- function visit(node) {
15317
- const type = node.type;
15318
- if (visitors[type]) {
15319
- visitors[type](node);
15320
- }
15321
- for (const key of Object.keys(node)) {
15322
- if (key === "type" || key === "span" || key === "ctxt") continue;
15323
- if (type === "MemberExpression" && key === "property") {
15324
- const me = node;
15325
- if (me.property.type !== "Computed") continue;
15326
- }
15327
- if (type === "KeyValueProperty" && key === "key") {
15328
- const kv = node;
15329
- if (kv.key.type !== "Computed") continue;
15330
- }
15331
- if (type === "MethodProperty" && key === "key") {
15332
- const mp = node;
15333
- if (mp.key.type !== "Computed") continue;
15334
- }
15335
- const child = Reflect.get(node, key);
15336
- if (Array.isArray(child)) {
15337
- for (const item of child) {
15338
- if (isSwcNode(item)) visit(item);
15339
- }
15340
- } else if (isSwcNode(child)) {
15341
- visit(child);
15342
- }
15343
- }
15344
- }
15345
- visit(ast);
15346
- }
15347
- function isSwcNode(v) {
15348
- return !!v && typeof v === "object" && typeof v.type === "string";
15349
- }
15350
- var BUILTIN_GLOBALS = /* @__PURE__ */ new Set([
15351
- // ─── Template runtime helpers (injected by compileToFunction) ───────
15352
- //
15353
- // These variables appear in the generated template function signature
15354
- // or body. They must be excluded from extractGlobalVars() so that
15355
- // they are not mistaken for user data variables and destructured from $data.
15356
- // SPLITTER character constant (same as \x1e), used as namespace separator
15357
- // for refData keys, event attribute encoding, and internal data structures.
15358
- // Declared as: let $splitter='\x1e'
15359
- "$splitter",
15360
- // Data — the data object passed from Updater to the template function.
15361
- // User variables are destructured from $data at the top of the function:
15362
- // let {name, age} = $data;
15363
- // This is the first parameter of the generated arrow function.
15364
- "$data",
15365
- // Null-safe toString: v => '' + (v == null ? '' : v)
15366
- // Converts null/undefined to empty string, otherwise calls toString().
15367
- // Wraps every {{!raw}} output to prevent "null" / "undefined" rendering.
15368
- "$strSafe",
15369
- // HTML entity encoder: v => $strSafe(v).replace(/[&<>"'`]/g, entityMap)
15370
- // Encodes &, <, >, ", ', ` to HTML entities (&amp; &lt; etc.)
15371
- // Applied to all {{=escaped}} and {{:binding}} outputs.
15372
- "$encHtml",
15373
- // HTML entity map — internal object used by $encHtml:
15374
- // {'&':'amp','<':'gt','>':'gt','"':'#34','\'':'#39','`':'#96'}
15375
- // Not a standalone function; referenced inside $encHtml's closure.
15376
- "$entMap",
15377
- // HTML entity RegExp — internal regexp used by $encHtml:
15378
- // /[&<>"'`]/g
15379
- "$entReg",
15380
- // HTML entity replacer function — internal helper used by $encHtml:
15381
- // m => '&' + $entMap[m] + ';'
15382
- // Maps matched character to its entity string.
15383
- "$entFn",
15384
- // Output buffer — the string accumulator for rendered HTML.
15385
- // All template output is appended via $out += '...'.
15386
- // Declared as: let $out = ''
15387
- "$out",
15388
- // Reference lookup: (refData, value) => key
15389
- // Finds or allocates a SPLITTER-prefixed key in refData for a given
15390
- // object reference. Used by {{@ref}} operator for passing object
15391
- // references to child views via v-lark attributes.
15392
- "$refFn",
15393
- // URI encoder: v => encodeURIComponent($strSafe(v)).replace(/[!')(*]/g, extraMap)
15394
- // Extends encodeURIComponent with encoding of ! ' ( ) *.
15395
- // Applied to values in @event URL parameters and {{!uri}} contexts.
15396
- "$encUri",
15397
- // URI encode map — internal object used by $encUri:
15398
- // {'!':'%21','\'':'%27','(':'%28',')':'%29','*':'%2A'}
15399
- "$uriMap",
15400
- // URI encode replacer — internal helper used by $encUri:
15401
- // m => $uriMap[m]
15402
- "$uriFn",
15403
- // URI encode regexp — internal regexp used by $encUri:
15404
- // /[!')(*]/g
15405
- "$uriReg",
15406
- // Quote encoder: v => $strSafe(v).replace(/['"\\]/g, '\\$&')
15407
- // Escapes quotes and backslashes for safe embedding in HTML attribute
15408
- // values (e.g. data-json='...').
15409
- "$encQuote",
15410
- // Quote encode regexp — internal regexp used by $encQuote:
15411
- // /['"\\]/g
15412
- "$qReg",
15413
- // View ID — the unique identifier of the owning View instance.
15414
- // Injected into @event attribute values at render time so that
15415
- // EventDelegator can dispatch events to the correct View handler.
15416
- // The \x1f placeholder in compiled output is replaced with '+$viewId+'.
15417
- "$viewId",
15418
- // Debug: current expression text — stores the template expression being
15419
- // evaluated, for error reporting. Only present in debug mode.
15420
- // e.g. $dbgExpr='<%=user.name%>'
15421
- "$dbgExpr",
15422
- // Debug: original art syntax — stores the {{}} template syntax before
15423
- // conversion, for error reporting. Only present in debug mode.
15424
- // e.g. $dbgArt='{{=user.name}}'
15425
- "$dbgArt",
15426
- // Debug: source line number — tracks the current line in the template
15427
- // source, for error reporting. Only present in debug mode.
15428
- "$dbgLine",
15429
- // RefData alias — fallback reference lookup table.
15430
- // Defaults to $data when no explicit $refAlt is provided.
15431
- // Ensures $refFn() does not crash when @ operator is used without refData.
15432
- "$refAlt",
15433
- // Temporary variable — used by the compiler for intermediate
15434
- // expression results in generated code (e.g. loop variables,
15435
- // conditional branches). Declared as: let $tmp
15436
- "$tmp",
15437
- // JS literals
15438
- "undefined",
15439
- "null",
15440
- "true",
15441
- "false",
15442
- "NaN",
15443
- "Infinity",
15444
- // JS built-in globals
15445
- "window",
15446
- "self",
15447
- "globalThis",
15448
- "document",
15449
- "console",
15450
- "JSON",
15451
- "Math",
15452
- "Intl",
15453
- "Promise",
15454
- "Symbol",
15455
- "Number",
15456
- "String",
15457
- "Boolean",
15458
- "Array",
15459
- "Object",
15460
- "Date",
15461
- "RegExp",
15462
- "Error",
15463
- "TypeError",
15464
- "RangeError",
15465
- "SyntaxError",
15466
- "Map",
15467
- "Set",
15468
- "WeakMap",
15469
- "WeakSet",
15470
- "Proxy",
15471
- "Reflect",
15472
- "ArrayBuffer",
15473
- "DataView",
15474
- "Float32Array",
15475
- "Float64Array",
15476
- "Int8Array",
15477
- "Int16Array",
15478
- "Int32Array",
15479
- "Uint8Array",
15480
- "Uint16Array",
15481
- "Uint32Array",
15482
- "Uint8ClampedArray",
15483
- // Functions
15484
- "parseInt",
15485
- "parseFloat",
15486
- "isNaN",
15487
- "isFinite",
15488
- "encodeURIComponent",
15489
- "decodeURIComponent",
15490
- "encodeURI",
15491
- "decodeURI",
15492
- // SWC helpers
15493
- "arguments",
15494
- "this",
15495
- "require",
15496
- // Lark framework
15497
- "Lark"
15498
- ]);
15499
-
15500
15174
  // src/compiler/extract-global-vars.ts
15501
15175
  init_cjs_shims();
15502
15176
  var import_parser = __toESM(require_lib(), 1);
15503
- async function extractGlobalVars2(source) {
15177
+ async function extractGlobalVars(source) {
15504
15178
  const { protectedSource, comments: _comments } = protectComments(source);
15505
15179
  const viewEventProcessed = processViewEvents(protectedSource);
15506
15180
  const converted = convertArtSyntax(viewEventProcessed, false);
@@ -15537,10 +15211,10 @@ async function extractGlobalVars2(source) {
15537
15211
  allowAwaitOutsideFunction: true
15538
15212
  });
15539
15213
  } catch {
15540
- return fallbackExtractVariables2(source);
15214
+ return fallbackExtractVariables(source);
15541
15215
  }
15542
15216
  const globalExists = {};
15543
- for (const name of BUILTIN_GLOBALS2) globalExists[name] = 1;
15217
+ for (const name of BUILTIN_GLOBALS) globalExists[name] = 1;
15544
15218
  const globalVars = /* @__PURE__ */ Object.create(null);
15545
15219
  const fnRange = [];
15546
15220
  walkAst(ast, {
@@ -15599,22 +15273,22 @@ async function extractGlobalVars2(source) {
15599
15273
  });
15600
15274
  return Object.keys(globalVars);
15601
15275
  }
15602
- function fallbackExtractVariables2(source) {
15276
+ function fallbackExtractVariables(source) {
15603
15277
  const vars = /* @__PURE__ */ new Set();
15604
15278
  const outputRegExp = /\{\{[:=!@]\s*([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
15605
15279
  let m;
15606
15280
  while ((m = outputRegExp.exec(source)) !== null) {
15607
15281
  vars.add(m[1]);
15608
15282
  }
15609
- const eachRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
15610
- while ((m = eachRegExp.exec(source)) !== null) {
15283
+ const forOfRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
15284
+ while ((m = forOfRegExp.exec(source)) !== null) {
15611
15285
  vars.add(m[1]);
15612
15286
  }
15613
15287
  const ifRegExp = /\{\{(?:else\s+)?if\s+([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
15614
15288
  while ((m = ifRegExp.exec(source)) !== null) {
15615
15289
  vars.add(m[1]);
15616
15290
  }
15617
- return Array.from(vars).filter((v) => !BUILTIN_GLOBALS2.has(v));
15291
+ return Array.from(vars).filter((v) => !BUILTIN_GLOBALS.has(v));
15618
15292
  }
15619
15293
  function walkAst(ast, visitors) {
15620
15294
  function visit(node) {
@@ -15652,7 +15326,7 @@ function walkAst(ast, visitors) {
15652
15326
  function isAstNode(v) {
15653
15327
  return !!v && typeof v === "object" && typeof v.type === "string";
15654
15328
  }
15655
- var BUILTIN_GLOBALS2 = /* @__PURE__ */ new Set([
15329
+ var BUILTIN_GLOBALS = /* @__PURE__ */ new Set([
15656
15330
  // ─── Template runtime helpers (injected by compileToFunction) ───────
15657
15331
  //
15658
15332
  // These variables appear in the generated template function signature
@@ -15891,8 +15565,8 @@ function compileToFunction(source, debug, file) {
15891
15565
  return `($data,$viewId,$refAlt,$encHtml,$strSafe,$encUri,$refFn,$encQuote)=>{${fullSource}}`;
15892
15566
  }
15893
15567
  async function compileTemplate(source, options = {}) {
15894
- const { debug = false, file, virtualDom = false, useSwc = false } = options;
15895
- const globalVars = options.globalVars ?? await (useSwc ? extractGlobalVars(source) : extractGlobalVars2(source));
15568
+ const { debug = false, file, virtualDom = false } = options;
15569
+ const globalVars = options.globalVars ?? await extractGlobalVars(source);
15896
15570
  const { protectedSource, comments } = protectComments(source);
15897
15571
  const converted = convertArtSyntax(protectedSource, debug);
15898
15572
  const viewEventProcessed = processViewEvents(converted);
@@ -15928,7 +15602,7 @@ export default function(data, viewId, refData) {
15928
15602
  // src/vite.ts
15929
15603
  var LARK_TEMPLATE_SUFFIX = "?lark-template";
15930
15604
  function larkMvcPlugin(options = {}) {
15931
- const { debug = false, virtualDom = false, useSwc = false } = options;
15605
+ const { debug = false, virtualDom = false } = options;
15932
15606
  let root = __dirname;
15933
15607
  return {
15934
15608
  name: "lark-template",
@@ -15940,10 +15614,13 @@ function larkMvcPlugin(options = {}) {
15940
15614
  const sourcePath = source.split("?")[0];
15941
15615
  if (sourcePath.endsWith(".html") && importer) {
15942
15616
  const importerPath = importer.split("?")[0];
15943
- let resolved = import_path.default.resolve(import_path.default.dirname(importerPath), sourcePath);
15944
- if (!import_fs.default.existsSync(resolved)) {
15945
- const rootResolved = import_path.default.join(root, resolved);
15946
- if (import_fs.default.existsSync(rootResolved)) {
15617
+ let resolved = (0, import_path.resolve)((0, import_path.dirname)(importerPath), sourcePath);
15618
+ if (resolved.startsWith("/@fs")) {
15619
+ resolved = resolved.slice("/@fs".length);
15620
+ }
15621
+ if (!(0, import_path.isAbsolute)(resolved) || !(0, import_fs.existsSync)(resolved)) {
15622
+ const rootResolved = (0, import_path.join)(root, resolved);
15623
+ if ((0, import_fs.existsSync)(rootResolved)) {
15947
15624
  resolved = rootResolved;
15948
15625
  }
15949
15626
  }
@@ -15956,16 +15633,19 @@ function larkMvcPlugin(options = {}) {
15956
15633
  const query = qIdx >= 0 ? id.slice(qIdx + 1) : "";
15957
15634
  if (query.split("&").includes("lark-template")) {
15958
15635
  let filePath = qIdx >= 0 ? id.slice(0, qIdx) : id;
15959
- if (!import_fs.default.existsSync(filePath)) {
15960
- const rootResolved = import_path.default.join(root, filePath);
15961
- if (import_fs.default.existsSync(rootResolved)) {
15636
+ if (filePath.startsWith("/@fs")) {
15637
+ filePath = filePath.slice(4);
15638
+ }
15639
+ if (!(0, import_path.isAbsolute)(filePath) || !(0, import_fs.existsSync)(filePath)) {
15640
+ const rootResolved = (0, import_path.join)(root, filePath);
15641
+ if ((0, import_fs.existsSync)(rootResolved)) {
15962
15642
  filePath = rootResolved;
15963
15643
  }
15964
15644
  }
15965
- if (!import_fs.default.existsSync(filePath)) return void 0;
15966
- const raw = import_fs.default.readFileSync(filePath, "utf-8");
15967
- const globalVars = await extractGlobalVars2(raw);
15968
- return compileTemplate(raw, { debug, globalVars, virtualDom, useSwc });
15645
+ if (!(0, import_fs.existsSync)(filePath)) return void 0;
15646
+ const raw = (0, import_fs.readFileSync)(filePath, "utf-8");
15647
+ const globalVars = await extractGlobalVars(raw);
15648
+ return compileTemplate(raw, { debug, globalVars, virtualDom });
15969
15649
  }
15970
15650
  return void 0;
15971
15651
  }
@@ -15973,22 +15653,22 @@ function larkMvcPlugin(options = {}) {
15973
15653
  }
15974
15654
  var vite_default = larkMvcPlugin;
15975
15655
  function larkMvcPluginLegacy(options = {}) {
15976
- const { virtualDom = false, useSwc = false } = options;
15656
+ const { debug = false, virtualDom = false } = options;
15977
15657
  return {
15978
15658
  name: "lark-template",
15979
15659
  enforce: "pre",
15980
15660
  resolveId(source, importer) {
15981
15661
  if (source.endsWith(".html") && importer) {
15982
- return import_path.default.resolve(import_path.default.dirname(importer), source) + LARK_TEMPLATE_SUFFIX;
15662
+ return (0, import_path.resolve)((0, import_path.dirname)(importer), source) + LARK_TEMPLATE_SUFFIX;
15983
15663
  }
15984
15664
  return void 0;
15985
15665
  },
15986
15666
  async load(id) {
15987
15667
  if (id.endsWith(LARK_TEMPLATE_SUFFIX)) {
15988
15668
  const filePath = id.slice(0, -LARK_TEMPLATE_SUFFIX.length);
15989
- const raw = import_fs.default.readFileSync(filePath, "utf-8");
15990
- const globalVars = await extractGlobalVars2(raw);
15991
- return compileTemplate(raw, { globalVars, virtualDom, useSwc });
15669
+ const raw = (0, import_fs.readFileSync)(filePath, "utf-8");
15670
+ const globalVars = await extractGlobalVars(raw);
15671
+ return compileTemplate(raw, { debug, globalVars, virtualDom });
15992
15672
  }
15993
15673
  return void 0;
15994
15674
  }
package/dist/vite.d.cts CHANGED
@@ -25,6 +25,12 @@ import { Plugin as Plugin$1 } from 'vite7';
25
25
  * ```
26
26
  */
27
27
 
28
+ interface LarkMvcVitePluginOptions {
29
+ /** Enable debug mode with line tracking (default: false) */
30
+ debug?: boolean;
31
+ /** Enable virtual DOM output (default: false) */
32
+ virtualDom?: boolean;
33
+ }
28
34
  /**
29
35
  * Create a Vite plugin that compiles .html template files.
30
36
  *
@@ -32,24 +38,19 @@ import { Plugin as Plugin$1 } from 'vite7';
32
38
  * @param options.virtualDom - Generate VDOM output instead of HTML string (default: false)
33
39
  * @returns Vite plugin instance
34
40
  */
35
- declare function larkMvcPlugin(options?: {
36
- debug?: boolean;
37
- virtualDom?: boolean;
38
- useSwc?: boolean;
39
- }): Plugin;
41
+ declare function larkMvcPlugin(options?: LarkMvcVitePluginOptions): Plugin;
40
42
 
41
43
  declare function larkMvcPluginLegacy(options?: {
44
+ debug?: boolean;
42
45
  virtualDom?: boolean;
43
- useSwc?: boolean;
44
46
  }): Plugin;
45
47
  declare function larkMvcPlugin7(options?: {
46
48
  debug?: boolean;
47
49
  virtualDom?: boolean;
48
- useSwc?: boolean;
49
50
  }): Plugin$1;
50
51
  declare function larkMvcPluginLegacy7(options?: {
52
+ debug?: boolean;
51
53
  virtualDom?: boolean;
52
- useSwc?: boolean;
53
54
  }): Plugin$1;
54
55
 
55
- export { larkMvcPlugin as default, larkMvcPlugin, larkMvcPlugin7, larkMvcPluginLegacy, larkMvcPluginLegacy7 };
56
+ export { type LarkMvcVitePluginOptions, larkMvcPlugin as default, larkMvcPlugin, larkMvcPlugin7, larkMvcPluginLegacy, larkMvcPluginLegacy7 };
package/dist/vite.d.ts CHANGED
@@ -25,6 +25,12 @@ import { Plugin as Plugin$1 } from 'vite7';
25
25
  * ```
26
26
  */
27
27
 
28
+ interface LarkMvcVitePluginOptions {
29
+ /** Enable debug mode with line tracking (default: false) */
30
+ debug?: boolean;
31
+ /** Enable virtual DOM output (default: false) */
32
+ virtualDom?: boolean;
33
+ }
28
34
  /**
29
35
  * Create a Vite plugin that compiles .html template files.
30
36
  *
@@ -32,24 +38,19 @@ import { Plugin as Plugin$1 } from 'vite7';
32
38
  * @param options.virtualDom - Generate VDOM output instead of HTML string (default: false)
33
39
  * @returns Vite plugin instance
34
40
  */
35
- declare function larkMvcPlugin(options?: {
36
- debug?: boolean;
37
- virtualDom?: boolean;
38
- useSwc?: boolean;
39
- }): Plugin;
41
+ declare function larkMvcPlugin(options?: LarkMvcVitePluginOptions): Plugin;
40
42
 
41
43
  declare function larkMvcPluginLegacy(options?: {
44
+ debug?: boolean;
42
45
  virtualDom?: boolean;
43
- useSwc?: boolean;
44
46
  }): Plugin;
45
47
  declare function larkMvcPlugin7(options?: {
46
48
  debug?: boolean;
47
49
  virtualDom?: boolean;
48
- useSwc?: boolean;
49
50
  }): Plugin$1;
50
51
  declare function larkMvcPluginLegacy7(options?: {
52
+ debug?: boolean;
51
53
  virtualDom?: boolean;
52
- useSwc?: boolean;
53
54
  }): Plugin$1;
54
55
 
55
- export { larkMvcPlugin as default, larkMvcPlugin, larkMvcPlugin7, larkMvcPluginLegacy, larkMvcPluginLegacy7 };
56
+ export { type LarkMvcVitePluginOptions, larkMvcPlugin as default, larkMvcPlugin, larkMvcPlugin7, larkMvcPluginLegacy, larkMvcPluginLegacy7 };