@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/rspack.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) {
@@ -15167,336 +15167,10 @@ function compileToVDomFunction(source, debug, file) {
15167
15167
  return `($data,$viewId,$refAlt,$n,$refFn,$encUri,$encQuote)=>{${fullSource}}`;
15168
15168
  }
15169
15169
 
15170
- // src/compiler/swc/extract-global-vars.ts
15171
- init_cjs_shims();
15172
- var parseSyncFn = null;
15173
- var parseSyncLoadAttempted = false;
15174
- async function getParser() {
15175
- if (!parseSyncLoadAttempted) {
15176
- parseSyncLoadAttempted = true;
15177
- try {
15178
- const swc = await import("@swc/core");
15179
- parseSyncFn = swc.parseSync;
15180
- } catch (err) {
15181
- console.error("failed to load @swc/core", err);
15182
- }
15183
- }
15184
- return parseSyncFn;
15185
- }
15186
- async function extractGlobalVars(source) {
15187
- const { protectedSource, comments: _comments } = protectComments(source);
15188
- const viewEventProcessed = processViewEvents(protectedSource);
15189
- const converted = convertArtSyntax(viewEventProcessed, false);
15190
- const template = restoreComments(converted, _comments);
15191
- const templateCmdRegExp = /<%([@=!:])?([\s\S]*?)%>|$/g;
15192
- const fnParts = [];
15193
- const htmlStore = {};
15194
- let htmlIndex = 0;
15195
- let lastIndex = 0;
15196
- const htmlKey = String.fromCharCode(5);
15197
- template.replace(
15198
- templateCmdRegExp,
15199
- (match, operate, content, offset) => {
15200
- const start = operate ? 3 : 2;
15201
- const htmlText = template.substring(lastIndex, offset + start);
15202
- const key = htmlKey + htmlIndex++ + htmlKey;
15203
- htmlStore[key] = htmlText;
15204
- lastIndex = offset + match.length - 2;
15205
- if (operate && content.trim()) {
15206
- fnParts.push(';"' + key + '";', "[" + content + "]");
15207
- } else {
15208
- fnParts.push(';"' + key + '";', content || "");
15209
- }
15210
- return match;
15211
- }
15212
- );
15213
- let fn = fnParts.join("");
15214
- fn = `(function(){${fn}})`;
15215
- const parseSync = await getParser();
15216
- if (!parseSync) {
15217
- return fallbackExtractVariables(source);
15218
- }
15219
- let ast;
15220
- try {
15221
- ast = parseSync(fn, {
15222
- syntax: "ecmascript",
15223
- target: "es2022"
15224
- });
15225
- } catch {
15226
- return fallbackExtractVariables(source);
15227
- }
15228
- const globalExists = {};
15229
- for (const name of BUILTIN_GLOBALS) globalExists[name] = 1;
15230
- const globalVars = /* @__PURE__ */ Object.create(null);
15231
- const fnNodes = [];
15232
- walkSwcAst(ast, {
15233
- VariableDeclarator(node) {
15234
- if (node.id.type === "Identifier") {
15235
- const name = node.id.value;
15236
- globalExists[name] = node.init ? 3 : 2;
15237
- }
15238
- },
15239
- FunctionDeclaration(node) {
15240
- if (node.identifier) {
15241
- globalExists[node.identifier.value] = 3;
15242
- }
15243
- fnNodes.push(node);
15244
- },
15245
- FunctionExpression(node) {
15246
- fnNodes.push(node);
15247
- },
15248
- ArrowFunctionExpression(node) {
15249
- fnNodes.push(node);
15250
- },
15251
- CallExpression(node) {
15252
- if (node.callee.type === "Identifier") {
15253
- globalExists[node.callee.value] = 1;
15254
- }
15255
- }
15256
- });
15257
- const functionParams = /* @__PURE__ */ Object.create(null);
15258
- for (const fnNode of fnNodes) {
15259
- const patterns = getParamPatterns(fnNode);
15260
- for (const pat of patterns) {
15261
- if (pat.type === "Identifier") {
15262
- functionParams[pat.value] = 1;
15263
- } else if (pat.type === "AssignmentPattern" && pat.left.type === "Identifier") {
15264
- functionParams[pat.left.value] = 1;
15265
- } else if (pat.type === "RestElement" && pat.argument.type === "Identifier") {
15266
- functionParams[pat.argument.value] = 1;
15267
- }
15268
- }
15269
- }
15270
- walkSwcAst(ast, {
15271
- Identifier(node) {
15272
- const name = node.value;
15273
- if (globalExists[name]) return;
15274
- if (functionParams[name]) return;
15275
- globalVars[name] = 1;
15276
- },
15277
- AssignmentExpression(node) {
15278
- if (node.left.type === "Identifier") {
15279
- const name = node.left.value;
15280
- if (!globalExists[name] || globalExists[name] === 1) {
15281
- globalExists[name] = (globalExists[name] || 0) + 1;
15282
- }
15283
- }
15284
- }
15285
- });
15286
- return Object.keys(globalVars);
15287
- }
15288
- function getParamPatterns(fnNode) {
15289
- if (fnNode.type === "ArrowFunctionExpression") {
15290
- return fnNode.params;
15291
- }
15292
- return fnNode.params.map((p) => p.pat);
15293
- }
15294
- function fallbackExtractVariables(source) {
15295
- const vars = /* @__PURE__ */ new Set();
15296
- const outputRegExp = /\{\{[:=!@]\s*([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
15297
- let m;
15298
- while ((m = outputRegExp.exec(source)) !== null) {
15299
- vars.add(m[1]);
15300
- }
15301
- const eachRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
15302
- while ((m = eachRegExp.exec(source)) !== null) {
15303
- vars.add(m[1]);
15304
- }
15305
- const ifRegExp = /\{\{(?:else\s+)?if\s+([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
15306
- while ((m = ifRegExp.exec(source)) !== null) {
15307
- vars.add(m[1]);
15308
- }
15309
- return Array.from(vars).filter((v) => !BUILTIN_GLOBALS.has(v));
15310
- }
15311
- function walkSwcAst(ast, visitors) {
15312
- function visit(node) {
15313
- const type = node.type;
15314
- if (visitors[type]) {
15315
- visitors[type](node);
15316
- }
15317
- for (const key of Object.keys(node)) {
15318
- if (key === "type" || key === "span" || key === "ctxt") continue;
15319
- if (type === "MemberExpression" && key === "property") {
15320
- const me = node;
15321
- if (me.property.type !== "Computed") continue;
15322
- }
15323
- if (type === "KeyValueProperty" && key === "key") {
15324
- const kv = node;
15325
- if (kv.key.type !== "Computed") continue;
15326
- }
15327
- if (type === "MethodProperty" && key === "key") {
15328
- const mp = node;
15329
- if (mp.key.type !== "Computed") continue;
15330
- }
15331
- const child = Reflect.get(node, key);
15332
- if (Array.isArray(child)) {
15333
- for (const item of child) {
15334
- if (isSwcNode(item)) visit(item);
15335
- }
15336
- } else if (isSwcNode(child)) {
15337
- visit(child);
15338
- }
15339
- }
15340
- }
15341
- visit(ast);
15342
- }
15343
- function isSwcNode(v) {
15344
- return !!v && typeof v === "object" && typeof v.type === "string";
15345
- }
15346
- var BUILTIN_GLOBALS = /* @__PURE__ */ new Set([
15347
- // ─── Template runtime helpers (injected by compileToFunction) ───────
15348
- //
15349
- // These variables appear in the generated template function signature
15350
- // or body. They must be excluded from extractGlobalVars() so that
15351
- // they are not mistaken for user data variables and destructured from $data.
15352
- // SPLITTER character constant (same as \x1e), used as namespace separator
15353
- // for refData keys, event attribute encoding, and internal data structures.
15354
- // Declared as: let $splitter='\x1e'
15355
- "$splitter",
15356
- // Data — the data object passed from Updater to the template function.
15357
- // User variables are destructured from $data at the top of the function:
15358
- // let {name, age} = $data;
15359
- // This is the first parameter of the generated arrow function.
15360
- "$data",
15361
- // Null-safe toString: v => '' + (v == null ? '' : v)
15362
- // Converts null/undefined to empty string, otherwise calls toString().
15363
- // Wraps every {{!raw}} output to prevent "null" / "undefined" rendering.
15364
- "$strSafe",
15365
- // HTML entity encoder: v => $strSafe(v).replace(/[&<>"'`]/g, entityMap)
15366
- // Encodes &, <, >, ", ', ` to HTML entities (&amp; &lt; etc.)
15367
- // Applied to all {{=escaped}} and {{:binding}} outputs.
15368
- "$encHtml",
15369
- // HTML entity map — internal object used by $encHtml:
15370
- // {'&':'amp','<':'gt','>':'gt','"':'#34','\'':'#39','`':'#96'}
15371
- // Not a standalone function; referenced inside $encHtml's closure.
15372
- "$entMap",
15373
- // HTML entity RegExp — internal regexp used by $encHtml:
15374
- // /[&<>"'`]/g
15375
- "$entReg",
15376
- // HTML entity replacer function — internal helper used by $encHtml:
15377
- // m => '&' + $entMap[m] + ';'
15378
- // Maps matched character to its entity string.
15379
- "$entFn",
15380
- // Output buffer — the string accumulator for rendered HTML.
15381
- // All template output is appended via $out += '...'.
15382
- // Declared as: let $out = ''
15383
- "$out",
15384
- // Reference lookup: (refData, value) => key
15385
- // Finds or allocates a SPLITTER-prefixed key in refData for a given
15386
- // object reference. Used by {{@ref}} operator for passing object
15387
- // references to child views via v-lark attributes.
15388
- "$refFn",
15389
- // URI encoder: v => encodeURIComponent($strSafe(v)).replace(/[!')(*]/g, extraMap)
15390
- // Extends encodeURIComponent with encoding of ! ' ( ) *.
15391
- // Applied to values in @event URL parameters and {{!uri}} contexts.
15392
- "$encUri",
15393
- // URI encode map — internal object used by $encUri:
15394
- // {'!':'%21','\'':'%27','(':'%28',')':'%29','*':'%2A'}
15395
- "$uriMap",
15396
- // URI encode replacer — internal helper used by $encUri:
15397
- // m => $uriMap[m]
15398
- "$uriFn",
15399
- // URI encode regexp — internal regexp used by $encUri:
15400
- // /[!')(*]/g
15401
- "$uriReg",
15402
- // Quote encoder: v => $strSafe(v).replace(/['"\\]/g, '\\$&')
15403
- // Escapes quotes and backslashes for safe embedding in HTML attribute
15404
- // values (e.g. data-json='...').
15405
- "$encQuote",
15406
- // Quote encode regexp — internal regexp used by $encQuote:
15407
- // /['"\\]/g
15408
- "$qReg",
15409
- // View ID — the unique identifier of the owning View instance.
15410
- // Injected into @event attribute values at render time so that
15411
- // EventDelegator can dispatch events to the correct View handler.
15412
- // The \x1f placeholder in compiled output is replaced with '+$viewId+'.
15413
- "$viewId",
15414
- // Debug: current expression text — stores the template expression being
15415
- // evaluated, for error reporting. Only present in debug mode.
15416
- // e.g. $dbgExpr='<%=user.name%>'
15417
- "$dbgExpr",
15418
- // Debug: original art syntax — stores the {{}} template syntax before
15419
- // conversion, for error reporting. Only present in debug mode.
15420
- // e.g. $dbgArt='{{=user.name}}'
15421
- "$dbgArt",
15422
- // Debug: source line number — tracks the current line in the template
15423
- // source, for error reporting. Only present in debug mode.
15424
- "$dbgLine",
15425
- // RefData alias — fallback reference lookup table.
15426
- // Defaults to $data when no explicit $refAlt is provided.
15427
- // Ensures $refFn() does not crash when @ operator is used without refData.
15428
- "$refAlt",
15429
- // Temporary variable — used by the compiler for intermediate
15430
- // expression results in generated code (e.g. loop variables,
15431
- // conditional branches). Declared as: let $tmp
15432
- "$tmp",
15433
- // JS literals
15434
- "undefined",
15435
- "null",
15436
- "true",
15437
- "false",
15438
- "NaN",
15439
- "Infinity",
15440
- // JS built-in globals
15441
- "window",
15442
- "self",
15443
- "globalThis",
15444
- "document",
15445
- "console",
15446
- "JSON",
15447
- "Math",
15448
- "Intl",
15449
- "Promise",
15450
- "Symbol",
15451
- "Number",
15452
- "String",
15453
- "Boolean",
15454
- "Array",
15455
- "Object",
15456
- "Date",
15457
- "RegExp",
15458
- "Error",
15459
- "TypeError",
15460
- "RangeError",
15461
- "SyntaxError",
15462
- "Map",
15463
- "Set",
15464
- "WeakMap",
15465
- "WeakSet",
15466
- "Proxy",
15467
- "Reflect",
15468
- "ArrayBuffer",
15469
- "DataView",
15470
- "Float32Array",
15471
- "Float64Array",
15472
- "Int8Array",
15473
- "Int16Array",
15474
- "Int32Array",
15475
- "Uint8Array",
15476
- "Uint16Array",
15477
- "Uint32Array",
15478
- "Uint8ClampedArray",
15479
- // Functions
15480
- "parseInt",
15481
- "parseFloat",
15482
- "isNaN",
15483
- "isFinite",
15484
- "encodeURIComponent",
15485
- "decodeURIComponent",
15486
- "encodeURI",
15487
- "decodeURI",
15488
- // SWC helpers
15489
- "arguments",
15490
- "this",
15491
- "require",
15492
- // Lark framework
15493
- "Lark"
15494
- ]);
15495
-
15496
15170
  // src/compiler/extract-global-vars.ts
15497
15171
  init_cjs_shims();
15498
15172
  var import_parser = __toESM(require_lib(), 1);
15499
- async function extractGlobalVars2(source) {
15173
+ async function extractGlobalVars(source) {
15500
15174
  const { protectedSource, comments: _comments } = protectComments(source);
15501
15175
  const viewEventProcessed = processViewEvents(protectedSource);
15502
15176
  const converted = convertArtSyntax(viewEventProcessed, false);
@@ -15533,10 +15207,10 @@ async function extractGlobalVars2(source) {
15533
15207
  allowAwaitOutsideFunction: true
15534
15208
  });
15535
15209
  } catch {
15536
- return fallbackExtractVariables2(source);
15210
+ return fallbackExtractVariables(source);
15537
15211
  }
15538
15212
  const globalExists = {};
15539
- for (const name of BUILTIN_GLOBALS2) globalExists[name] = 1;
15213
+ for (const name of BUILTIN_GLOBALS) globalExists[name] = 1;
15540
15214
  const globalVars = /* @__PURE__ */ Object.create(null);
15541
15215
  const fnRange = [];
15542
15216
  walkAst(ast, {
@@ -15595,22 +15269,22 @@ async function extractGlobalVars2(source) {
15595
15269
  });
15596
15270
  return Object.keys(globalVars);
15597
15271
  }
15598
- function fallbackExtractVariables2(source) {
15272
+ function fallbackExtractVariables(source) {
15599
15273
  const vars = /* @__PURE__ */ new Set();
15600
15274
  const outputRegExp = /\{\{[:=!@]\s*([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
15601
15275
  let m;
15602
15276
  while ((m = outputRegExp.exec(source)) !== null) {
15603
15277
  vars.add(m[1]);
15604
15278
  }
15605
- const eachRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
15606
- while ((m = eachRegExp.exec(source)) !== null) {
15279
+ const forOfRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
15280
+ while ((m = forOfRegExp.exec(source)) !== null) {
15607
15281
  vars.add(m[1]);
15608
15282
  }
15609
15283
  const ifRegExp = /\{\{(?:else\s+)?if\s+([a-zA-Z_$][\w$]*)[^}]*\}\}/g;
15610
15284
  while ((m = ifRegExp.exec(source)) !== null) {
15611
15285
  vars.add(m[1]);
15612
15286
  }
15613
- return Array.from(vars).filter((v) => !BUILTIN_GLOBALS2.has(v));
15287
+ return Array.from(vars).filter((v) => !BUILTIN_GLOBALS.has(v));
15614
15288
  }
15615
15289
  function walkAst(ast, visitors) {
15616
15290
  function visit(node) {
@@ -15648,7 +15322,7 @@ function walkAst(ast, visitors) {
15648
15322
  function isAstNode(v) {
15649
15323
  return !!v && typeof v === "object" && typeof v.type === "string";
15650
15324
  }
15651
- var BUILTIN_GLOBALS2 = /* @__PURE__ */ new Set([
15325
+ var BUILTIN_GLOBALS = /* @__PURE__ */ new Set([
15652
15326
  // ─── Template runtime helpers (injected by compileToFunction) ───────
15653
15327
  //
15654
15328
  // These variables appear in the generated template function signature
@@ -15887,8 +15561,8 @@ function compileToFunction(source, debug, file) {
15887
15561
  return `($data,$viewId,$refAlt,$encHtml,$strSafe,$encUri,$refFn,$encQuote)=>{${fullSource}}`;
15888
15562
  }
15889
15563
  async function compileTemplate(source, options = {}) {
15890
- const { debug = false, file, virtualDom = false, useSwc = false } = options;
15891
- const globalVars = options.globalVars ?? await (useSwc ? extractGlobalVars(source) : extractGlobalVars2(source));
15564
+ const { debug = false, file, virtualDom = false } = options;
15565
+ const globalVars = options.globalVars ?? await extractGlobalVars(source);
15892
15566
  const { protectedSource, comments } = protectComments(source);
15893
15567
  const converted = convertArtSyntax(protectedSource, debug);
15894
15568
  const viewEventProcessed = processViewEvents(converted);
@@ -15925,13 +15599,12 @@ export default function(data, viewId, refData) {
15925
15599
  async function larkMvcLoader(source) {
15926
15600
  try {
15927
15601
  const options = this.getOptions();
15928
- const { debug = false, virtualDom = false, useSwc = false } = options;
15929
- const globalVars = await extractGlobalVars2(source);
15602
+ const { debug = false, virtualDom = false } = options;
15603
+ const globalVars = await extractGlobalVars(source);
15930
15604
  return await compileTemplate(source, {
15931
15605
  debug,
15932
15606
  globalVars,
15933
- virtualDom,
15934
- useSwc
15607
+ virtualDom
15935
15608
  });
15936
15609
  } catch (err) {
15937
15610
  console.error(err);
@@ -15944,7 +15617,6 @@ var LarkMvcPlugin = class {
15944
15617
  this.options = {
15945
15618
  debug: false,
15946
15619
  virtualDom: false,
15947
- useSwc: false,
15948
15620
  test: /\.html$/,
15949
15621
  exclude: /node_modules/,
15950
15622
  ...options
@@ -15955,7 +15627,7 @@ var LarkMvcPlugin = class {
15955
15627
  * Called by rspack when the plugin is applied.
15956
15628
  */
15957
15629
  apply(compiler) {
15958
- const { debug, virtualDom, useSwc, test, exclude } = this.options;
15630
+ const { debug, virtualDom, test, exclude } = this.options;
15959
15631
  compiler.options.module = compiler.options.module || {};
15960
15632
  compiler.options.module.rules = compiler.options.module.rules || [];
15961
15633
  compiler.options.module.rules.push({
@@ -15969,7 +15641,7 @@ var LarkMvcPlugin = class {
15969
15641
  // __filename is provided by tsup's ESM shim (shims: true) in ESM output,
15970
15642
  // and is a native CJS global in CJS output.
15971
15643
  loader: __filename,
15972
- options: { debug, virtualDom, useSwc }
15644
+ options: { debug, virtualDom }
15973
15645
  }
15974
15646
  ]
15975
15647
  });
package/dist/rspack.d.cts CHANGED
@@ -1,4 +1,8 @@
1
1
  import { RspackPluginInstance, Compiler } from '@rspack/core';
2
+ import { LarkMvcWebpackPluginOptions, LarkMvcWebpackLoaderOptions } from './webpack.cjs';
3
+ import './vite.cjs';
4
+ import 'vite';
5
+ import 'vite7';
2
6
 
3
7
  /**
4
8
  * @lark.js/mvc Rspack Integration for Template Compilation
@@ -20,7 +24,7 @@ import { RspackPluginInstance, Compiler } from '@rspack/core';
20
24
  * - $encUri (URI encoding), $encQuote (quote encoding), $refFn (reference lookup)
21
25
  * - Debug mode with line tracking
22
26
  * - View ID injection
23
- * - Auto variable extraction via AST analysis (Babel or SWC)
27
+ * - Auto variable extraction via AST analysis (Babel)
24
28
  * - Virtual DOM support (optional)
25
29
  *
26
30
  * Usage with Plugin (recommended):
@@ -32,7 +36,6 @@ import { RspackPluginInstance, Compiler } from '@rspack/core';
32
36
  * new LarkMvcPlugin({
33
37
  * debug: process.env.NODE_ENV !== 'production',
34
38
  * virtualDom: false,
35
- * useSwc: false,
36
39
  * }),
37
40
  * ],
38
41
  * };
@@ -45,7 +48,7 @@ import { RspackPluginInstance, Compiler } from '@rspack/core';
45
48
  * rules: [{
46
49
  * test: /\.html$/,
47
50
  * loader: '@lark.js/mvc/rspack',
48
- * options: { debug: false, virtualDom: false, useSwc: false },
51
+ * options: { debug: false, virtualDom: false },
49
52
  * }],
50
53
  * },
51
54
  * };
@@ -57,24 +60,7 @@ interface LoaderContext {
57
60
  /** Whether in development mode */
58
61
  dev?: boolean;
59
62
  /** Loader options */
60
- getOptions: () => {
61
- debug?: boolean;
62
- virtualDom?: boolean;
63
- useSwc?: boolean;
64
- };
65
- }
66
- /** Plugin options */
67
- interface LarkMvcPluginOptions {
68
- /** Enable debug mode with line tracking (default: false) */
69
- debug?: boolean;
70
- /** Enable virtual DOM output (default: false) */
71
- virtualDom?: boolean;
72
- /** Use SWC instead of Babel for AST analysis (default: false) */
73
- useSwc?: boolean;
74
- /** File extension to match (default: /\.html$/) */
75
- test?: RegExp;
76
- /** Exclude pattern (default: /node_modules/) */
77
- exclude?: RegExp;
63
+ getOptions: () => LarkMvcWebpackLoaderOptions;
78
64
  }
79
65
  /**
80
66
  * Rspack loader entry point.
@@ -103,7 +89,6 @@ declare function larkMvcLoader(this: LoaderContext, source: string): Promise<str
103
89
  * new LarkMvcPlugin({
104
90
  * debug: true,
105
91
  * virtualDom: false,
106
- * useSwc: false,
107
92
  * }),
108
93
  * ],
109
94
  * };
@@ -111,7 +96,7 @@ declare function larkMvcLoader(this: LoaderContext, source: string): Promise<str
111
96
  */
112
97
  declare class LarkMvcPlugin implements RspackPluginInstance {
113
98
  private options;
114
- constructor(options?: LarkMvcPluginOptions);
99
+ constructor(options?: LarkMvcWebpackPluginOptions);
115
100
  /**
116
101
  * Rspack plugin entry point.
117
102
  * Called by rspack when the plugin is applied.
@@ -119,4 +104,4 @@ declare class LarkMvcPlugin implements RspackPluginInstance {
119
104
  apply(compiler: Compiler): void;
120
105
  }
121
106
 
122
- export { LarkMvcPlugin, larkMvcLoader as default, larkMvcLoader };
107
+ export { LarkMvcPlugin, LarkMvcWebpackLoaderOptions, LarkMvcWebpackPluginOptions, larkMvcLoader as default, larkMvcLoader };
package/dist/rspack.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import { RspackPluginInstance, Compiler } from '@rspack/core';
2
+ import { LarkMvcWebpackPluginOptions, LarkMvcWebpackLoaderOptions } from './webpack.js';
3
+ import './vite.js';
4
+ import 'vite';
5
+ import 'vite7';
2
6
 
3
7
  /**
4
8
  * @lark.js/mvc Rspack Integration for Template Compilation
@@ -20,7 +24,7 @@ import { RspackPluginInstance, Compiler } from '@rspack/core';
20
24
  * - $encUri (URI encoding), $encQuote (quote encoding), $refFn (reference lookup)
21
25
  * - Debug mode with line tracking
22
26
  * - View ID injection
23
- * - Auto variable extraction via AST analysis (Babel or SWC)
27
+ * - Auto variable extraction via AST analysis (Babel)
24
28
  * - Virtual DOM support (optional)
25
29
  *
26
30
  * Usage with Plugin (recommended):
@@ -32,7 +36,6 @@ import { RspackPluginInstance, Compiler } from '@rspack/core';
32
36
  * new LarkMvcPlugin({
33
37
  * debug: process.env.NODE_ENV !== 'production',
34
38
  * virtualDom: false,
35
- * useSwc: false,
36
39
  * }),
37
40
  * ],
38
41
  * };
@@ -45,7 +48,7 @@ import { RspackPluginInstance, Compiler } from '@rspack/core';
45
48
  * rules: [{
46
49
  * test: /\.html$/,
47
50
  * loader: '@lark.js/mvc/rspack',
48
- * options: { debug: false, virtualDom: false, useSwc: false },
51
+ * options: { debug: false, virtualDom: false },
49
52
  * }],
50
53
  * },
51
54
  * };
@@ -57,24 +60,7 @@ interface LoaderContext {
57
60
  /** Whether in development mode */
58
61
  dev?: boolean;
59
62
  /** Loader options */
60
- getOptions: () => {
61
- debug?: boolean;
62
- virtualDom?: boolean;
63
- useSwc?: boolean;
64
- };
65
- }
66
- /** Plugin options */
67
- interface LarkMvcPluginOptions {
68
- /** Enable debug mode with line tracking (default: false) */
69
- debug?: boolean;
70
- /** Enable virtual DOM output (default: false) */
71
- virtualDom?: boolean;
72
- /** Use SWC instead of Babel for AST analysis (default: false) */
73
- useSwc?: boolean;
74
- /** File extension to match (default: /\.html$/) */
75
- test?: RegExp;
76
- /** Exclude pattern (default: /node_modules/) */
77
- exclude?: RegExp;
63
+ getOptions: () => LarkMvcWebpackLoaderOptions;
78
64
  }
79
65
  /**
80
66
  * Rspack loader entry point.
@@ -103,7 +89,6 @@ declare function larkMvcLoader(this: LoaderContext, source: string): Promise<str
103
89
  * new LarkMvcPlugin({
104
90
  * debug: true,
105
91
  * virtualDom: false,
106
- * useSwc: false,
107
92
  * }),
108
93
  * ],
109
94
  * };
@@ -111,7 +96,7 @@ declare function larkMvcLoader(this: LoaderContext, source: string): Promise<str
111
96
  */
112
97
  declare class LarkMvcPlugin implements RspackPluginInstance {
113
98
  private options;
114
- constructor(options?: LarkMvcPluginOptions);
99
+ constructor(options?: LarkMvcWebpackPluginOptions);
115
100
  /**
116
101
  * Rspack plugin entry point.
117
102
  * Called by rspack when the plugin is applied.
@@ -119,4 +104,4 @@ declare class LarkMvcPlugin implements RspackPluginInstance {
119
104
  apply(compiler: Compiler): void;
120
105
  }
121
106
 
122
- export { LarkMvcPlugin, larkMvcLoader as default, larkMvcLoader };
107
+ export { LarkMvcPlugin, LarkMvcWebpackLoaderOptions, LarkMvcWebpackPluginOptions, larkMvcLoader as default, larkMvcLoader };