@lark.js/mvc 0.0.3 → 0.0.5
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 +872 -727
- package/dist/{chunk-Y72BUONO.js → chunk-IIIY575B.js} +108 -97
- package/dist/index.cjs +1718 -1115
- package/dist/index.d.cts +1857 -731
- package/dist/index.d.ts +1857 -731
- package/dist/index.js +1708 -1111
- package/dist/runtime.cjs +70 -0
- package/dist/runtime.d.cts +29 -0
- package/dist/runtime.d.ts +29 -0
- package/dist/runtime.js +41 -0
- package/dist/vite.cjs +108 -97
- package/dist/vite.d.cts +3 -3
- package/dist/vite.d.ts +3 -3
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +108 -97
- package/dist/webpack.js +1 -1
- package/package.json +21 -8
- package/src/client.d.ts +80 -0
package/dist/webpack.cjs
CHANGED
|
@@ -14735,7 +14735,7 @@ function convertArtSyntax(source, debug) {
|
|
|
14735
14735
|
}
|
|
14736
14736
|
if (blockStack.length > 0) {
|
|
14737
14737
|
const unclosed = blockStack.map((b) => `"${b.ctrl}" at line ${b.line}`).join(", ");
|
|
14738
|
-
throw new Error(`[@lark/mvc error] unclosed block(s): ${unclosed}`);
|
|
14738
|
+
throw new Error(`[@lark.js/mvc error] unclosed block(s): ${unclosed}`);
|
|
14739
14739
|
}
|
|
14740
14740
|
return result.join("");
|
|
14741
14741
|
}
|
|
@@ -14812,7 +14812,7 @@ function convertArtExpression(code, debug, lineNo, blockStack = []) {
|
|
|
14812
14812
|
return `${debugPrefix}<%for(${forExpr}){%>`;
|
|
14813
14813
|
}
|
|
14814
14814
|
const tokens = code.split(/\s+/);
|
|
14815
|
-
const keyword = tokens.shift();
|
|
14815
|
+
const keyword = tokens.shift() ?? "";
|
|
14816
14816
|
switch (keyword) {
|
|
14817
14817
|
case "if": {
|
|
14818
14818
|
blockStack.push({ ctrl: "if", line: lineNo });
|
|
@@ -14829,12 +14829,12 @@ function convertArtExpression(code, debug, lineNo, blockStack = []) {
|
|
|
14829
14829
|
}
|
|
14830
14830
|
return `${debugPrefix}<%}else{%>`;
|
|
14831
14831
|
}
|
|
14832
|
-
case "
|
|
14833
|
-
blockStack.push({ ctrl: "
|
|
14832
|
+
case "forOf": {
|
|
14833
|
+
blockStack.push({ ctrl: "forOf", line: lineNo });
|
|
14834
14834
|
const object = tokens[0];
|
|
14835
14835
|
if (tokens.length > 1 && tokens[1] !== "as") {
|
|
14836
14836
|
throw new Error(
|
|
14837
|
-
`[@lark/mvc error] bad
|
|
14837
|
+
`[@lark.js/mvc error] bad forOf syntax: {{${code}}}. Expected "as" keyword, got "${tokens[1]}". Usage: {{forOf list as item [index]}}`
|
|
14838
14838
|
);
|
|
14839
14839
|
}
|
|
14840
14840
|
const restTokens = tokens.slice(2);
|
|
@@ -14856,12 +14856,12 @@ function convertArtExpression(code, debug, lineNo, blockStack = []) {
|
|
|
14856
14856
|
}
|
|
14857
14857
|
return `${debugPrefix}<%for(let ${index}=0${refExpr},${refObjCount}=${refObj}.length${lastCount};${index}<${refObjCount};${index}++){${firstAndLast}${valueDecl}%>`;
|
|
14858
14858
|
}
|
|
14859
|
-
case "
|
|
14860
|
-
blockStack.push({ ctrl: "
|
|
14859
|
+
case "forIn": {
|
|
14860
|
+
blockStack.push({ ctrl: "forIn", line: lineNo });
|
|
14861
14861
|
const object = tokens[0];
|
|
14862
14862
|
if (tokens.length > 1 && tokens[1] !== "as") {
|
|
14863
14863
|
throw new Error(
|
|
14864
|
-
`[@lark/mvc error] bad
|
|
14864
|
+
`[@lark.js/mvc error] bad forIn syntax: {{${code}}}. Expected "as" keyword, got "${tokens[1]}". Usage: {{for-in obj as val [key]}}`
|
|
14865
14865
|
);
|
|
14866
14866
|
}
|
|
14867
14867
|
const restTokens2 = tokens.slice(2);
|
|
@@ -14881,19 +14881,19 @@ function convertArtExpression(code, debug, lineNo, blockStack = []) {
|
|
|
14881
14881
|
case "set":
|
|
14882
14882
|
return `${debugPrefix}<%let ${tokens.join(" ")};%>`;
|
|
14883
14883
|
case "/if":
|
|
14884
|
-
case "/
|
|
14885
|
-
case "/
|
|
14884
|
+
case "/forOf":
|
|
14885
|
+
case "/forIn":
|
|
14886
14886
|
case "/for": {
|
|
14887
14887
|
const expectedCtrl = keyword.substring(1);
|
|
14888
14888
|
const last = blockStack.pop();
|
|
14889
14889
|
if (!last) {
|
|
14890
14890
|
throw new Error(
|
|
14891
|
-
`[@lark/mvc error] unexpected {{${code}}}: no matching open block`
|
|
14891
|
+
`[@lark.js/mvc error] unexpected {{${code}}}: no matching open block`
|
|
14892
14892
|
);
|
|
14893
14893
|
}
|
|
14894
14894
|
if (last.ctrl !== expectedCtrl) {
|
|
14895
14895
|
throw new Error(
|
|
14896
|
-
`[@lark/mvc error] unexpected {{${code}}}: expected {{/${last.ctrl}}} to close block opened at line ${last.line}`
|
|
14896
|
+
`[@lark.js/mvc error] unexpected {{${code}}}: expected {{/${last.ctrl}}} to close block opened at line ${last.line}`
|
|
14897
14897
|
);
|
|
14898
14898
|
}
|
|
14899
14899
|
return `${debugPrefix}<%}%>`;
|
|
@@ -14957,7 +14957,7 @@ function parseAsExpr(expr) {
|
|
|
14957
14957
|
function compileToFunction(source, debug, file) {
|
|
14958
14958
|
const matcher = /<%([@=!:])?([\s\S]*?)%>|$/g;
|
|
14959
14959
|
let index = 0;
|
|
14960
|
-
let funcSource = `$
|
|
14960
|
+
let funcSource = `$out+='`;
|
|
14961
14961
|
let hasAtRule = false;
|
|
14962
14962
|
const escapeSlashRegExp = /\\|'/g;
|
|
14963
14963
|
const escapeBreakReturnRegExp = /\r|\n/g;
|
|
@@ -14983,17 +14983,17 @@ function compileToFunction(source, debug, file) {
|
|
|
14983
14983
|
}
|
|
14984
14984
|
if (operate === "@") {
|
|
14985
14985
|
hasAtRule = true;
|
|
14986
|
-
funcSource += `'+($
|
|
14986
|
+
funcSource += `'+($dbgExpr='<%${operate + expr}%>',$refFn($refAlt,${content}))+'`;
|
|
14987
14987
|
} else if (operate === "=" || operate === ":") {
|
|
14988
|
-
funcSource += `'+($
|
|
14988
|
+
funcSource += `'+($dbgExpr='<%${operate + expr}%>',$encHtml(${content}))+'`;
|
|
14989
14989
|
} else if (operate === "!") {
|
|
14990
|
-
if (!content.startsWith("$
|
|
14991
|
-
content = `$
|
|
14990
|
+
if (!content.startsWith("$encUri(") || !content.endsWith(")")) {
|
|
14991
|
+
content = `$strSafe(${content})`;
|
|
14992
14992
|
}
|
|
14993
|
-
funcSource += `'+($
|
|
14993
|
+
funcSource += `'+($dbgExpr='<%${operate + expr}%>',${content})+'`;
|
|
14994
14994
|
} else if (content) {
|
|
14995
14995
|
if (line > -1) {
|
|
14996
|
-
funcSource += `';$
|
|
14996
|
+
funcSource += `';$dbgLine=${line};$dbgArt='${art}';`;
|
|
14997
14997
|
content = "";
|
|
14998
14998
|
} else {
|
|
14999
14999
|
funcSource += `';`;
|
|
@@ -15002,19 +15002,19 @@ function compileToFunction(source, debug, file) {
|
|
|
15002
15002
|
funcSource = funcSource.substring(0, funcSource.length - 4) + ";";
|
|
15003
15003
|
}
|
|
15004
15004
|
if (expr) {
|
|
15005
|
-
funcSource += `$
|
|
15005
|
+
funcSource += `$dbgExpr='<%${expr}%>';`;
|
|
15006
15006
|
}
|
|
15007
|
-
funcSource += content + `;$
|
|
15007
|
+
funcSource += content + `;$out+='`;
|
|
15008
15008
|
}
|
|
15009
15009
|
} else {
|
|
15010
15010
|
if (operate === "@") {
|
|
15011
15011
|
hasAtRule = true;
|
|
15012
|
-
funcSource += `'+$
|
|
15012
|
+
funcSource += `'+$refFn($refAlt,${content})+'`;
|
|
15013
15013
|
} else if (operate === "=" || operate === ":") {
|
|
15014
|
-
funcSource += `'+$
|
|
15014
|
+
funcSource += `'+$encHtml(${content})+'`;
|
|
15015
15015
|
} else if (operate === "!") {
|
|
15016
|
-
if (!content.startsWith("$
|
|
15017
|
-
content = `$
|
|
15016
|
+
if (!content.startsWith("$encUri(") || !content.endsWith(")")) {
|
|
15017
|
+
content = `$strSafe(${content})`;
|
|
15018
15018
|
}
|
|
15019
15019
|
funcSource += `'+${content}+'`;
|
|
15020
15020
|
} else if (content) {
|
|
@@ -15022,28 +15022,24 @@ function compileToFunction(source, debug, file) {
|
|
|
15022
15022
|
if (funcSource.endsWith(`+'';`)) {
|
|
15023
15023
|
funcSource = funcSource.substring(0, funcSource.length - 4) + ";";
|
|
15024
15024
|
}
|
|
15025
|
-
funcSource += `${content};$
|
|
15025
|
+
funcSource += `${content};$out+='`;
|
|
15026
15026
|
}
|
|
15027
15027
|
}
|
|
15028
15028
|
return match;
|
|
15029
15029
|
});
|
|
15030
15030
|
funcSource += `';`;
|
|
15031
|
-
funcSource = funcSource.replace(/\$
|
|
15032
|
-
funcSource = funcSource.replace(/\$
|
|
15031
|
+
funcSource = funcSource.replace(/\$out\+='';/g, "");
|
|
15032
|
+
funcSource = funcSource.replace(/\$out\+=''\+/g, "$out+=");
|
|
15033
15033
|
if (debug) {
|
|
15034
15034
|
const filePart = file ? `\\r\\n\\tat file:${file}` : "";
|
|
15035
|
-
funcSource = `let $
|
|
15035
|
+
funcSource = `let $dbgExpr,$dbgArt,$dbgLine;try{${funcSource}}catch(ex){let msg='render view error:'+(ex.message||ex);if($dbgArt)msg+='\\r\\n\\tsrc art:{{'+$dbgArt+'}}\\r\\n\\tat line:'+$dbgLine;msg+='\\r\\n\\t'+($dbgArt?'translate to:':'expr:');msg+=$dbgExpr+'${filePart}';throw msg;}`;
|
|
15036
15036
|
}
|
|
15037
15037
|
const viewIdRegExp = new RegExp(String.fromCharCode(31), "g");
|
|
15038
15038
|
funcSource = funcSource.replace(viewIdRegExp, `'+$viewId+'`);
|
|
15039
|
-
|
|
15040
|
-
const
|
|
15041
|
-
const
|
|
15042
|
-
|
|
15043
|
-
const refFallback = "if(!$$ref)$$ref=$$;";
|
|
15044
|
-
const fns = `${refFallback}${encode}${encodeURIMore}${encodeQuote}${atRule};`;
|
|
15045
|
-
const fullSource = `${fns}let $g='\\x1e',$_temp,$p=''{{VARS}};${funcSource}return $p`;
|
|
15046
|
-
return `($$,$viewId,$$ref,$e,$n,$eu,$i,$eq)=>{${fullSource}}`;
|
|
15039
|
+
void hasAtRule;
|
|
15040
|
+
const refFallback = "if(!$refAlt)$refAlt=$data;";
|
|
15041
|
+
const fullSource = `${refFallback}let $splitter='\\x1e',$tmp,$out=''{{VARS}};${funcSource}return $out`;
|
|
15042
|
+
return `($data,$viewId,$refAlt,$encHtml,$strSafe,$encUri,$refFn,$encQuote)=>{${fullSource}}`;
|
|
15047
15043
|
}
|
|
15048
15044
|
function compileTemplate(source, options = {}) {
|
|
15049
15045
|
const { debug = false, globalVars = [], file } = options;
|
|
@@ -15052,17 +15048,14 @@ function compileTemplate(source, options = {}) {
|
|
|
15052
15048
|
const viewEventProcessed = processViewEvents(converted);
|
|
15053
15049
|
const finalSource = restoreComments(viewEventProcessed, comments);
|
|
15054
15050
|
const funcBody = compileToFunction(finalSource, debug, file);
|
|
15055
|
-
const varDeclarations = globalVars.map((key) => `,${key}
|
|
15051
|
+
const varDeclarations = globalVars.map((key) => `,${key}=$data.${key}`).join("");
|
|
15056
15052
|
const funcWithVars = funcBody.replace("{{VARS}}", () => varDeclarations);
|
|
15057
|
-
return `
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
/* $eu */ null,
|
|
15064
|
-
/* $i */ null,
|
|
15065
|
-
/* $eq */ null
|
|
15053
|
+
return `import { encHtml as __larkEncHtml, strSafe as __larkStrSafe, encUri as __larkEncUri, encQuote as __larkEncQuote, refFn as __larkRefFn } from "@lark.js/mvc/runtime";
|
|
15054
|
+
export default function(data, viewId, refData) {
|
|
15055
|
+
let $data = data || {},
|
|
15056
|
+
$viewId = viewId || '';
|
|
15057
|
+
return (${funcWithVars})($data, $viewId, refData,
|
|
15058
|
+
__larkEncHtml, __larkStrSafe, __larkEncUri, __larkRefFn, __larkEncQuote
|
|
15066
15059
|
);
|
|
15067
15060
|
}`;
|
|
15068
15061
|
}
|
|
@@ -15171,7 +15164,7 @@ function fallbackExtractVariables(source) {
|
|
|
15171
15164
|
while ((m = outputRegExp.exec(source)) !== null) {
|
|
15172
15165
|
vars.add(m[1]);
|
|
15173
15166
|
}
|
|
15174
|
-
const eachRegExp = /\{\{
|
|
15167
|
+
const eachRegExp = /\{\{forOf\s+([a-zA-Z_$][\w$]*)\s+as/g;
|
|
15175
15168
|
while ((m = eachRegExp.exec(source)) !== null) {
|
|
15176
15169
|
vars.add(m[1]);
|
|
15177
15170
|
}
|
|
@@ -15187,82 +15180,100 @@ function walkAst(ast, visitors) {
|
|
|
15187
15180
|
if (visitors[type]) {
|
|
15188
15181
|
visitors[type](node);
|
|
15189
15182
|
}
|
|
15183
|
+
const bag = node;
|
|
15190
15184
|
for (const key of Object.keys(node)) {
|
|
15191
15185
|
if (key === "type" || key === "start" || key === "end" || key === "loc" || key === "range")
|
|
15192
15186
|
continue;
|
|
15193
|
-
if (type === "MemberExpression" && key === "property"
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
continue;
|
|
15187
|
+
if (type === "MemberExpression" && key === "property") {
|
|
15188
|
+
const me = node;
|
|
15189
|
+
if (!me.computed) continue;
|
|
15197
15190
|
}
|
|
15198
|
-
if (type === "
|
|
15199
|
-
|
|
15191
|
+
if (type === "ObjectProperty" && key === "key") {
|
|
15192
|
+
const op = node;
|
|
15193
|
+
if (!op.computed) continue;
|
|
15200
15194
|
}
|
|
15201
|
-
|
|
15195
|
+
if (type === "ObjectMethod" && key === "key") {
|
|
15196
|
+
const om = node;
|
|
15197
|
+
if (!om.computed) continue;
|
|
15198
|
+
}
|
|
15199
|
+
const child = bag[key];
|
|
15202
15200
|
if (Array.isArray(child)) {
|
|
15203
15201
|
for (const item of child) {
|
|
15204
|
-
if (item
|
|
15205
|
-
visit(item);
|
|
15206
|
-
}
|
|
15202
|
+
if (isAstNode(item)) visit(item);
|
|
15207
15203
|
}
|
|
15208
|
-
} else if (child
|
|
15204
|
+
} else if (isAstNode(child)) {
|
|
15209
15205
|
visit(child);
|
|
15210
15206
|
}
|
|
15211
15207
|
}
|
|
15212
15208
|
}
|
|
15213
15209
|
visit(ast);
|
|
15214
15210
|
}
|
|
15211
|
+
function isAstNode(v) {
|
|
15212
|
+
return !!v && typeof v === "object" && typeof v.type === "string";
|
|
15213
|
+
}
|
|
15215
15214
|
var BUILTIN_GLOBALS = {
|
|
15216
15215
|
// ─── Template runtime helpers (injected by compileToFunction) ───────
|
|
15217
15216
|
//
|
|
15218
15217
|
// These variables appear in the generated template function signature
|
|
15219
15218
|
// or body. They must be excluded from extractGlobalVars() so that
|
|
15220
|
-
// they are not mistaken for user data variables and destructured from
|
|
15219
|
+
// they are not mistaken for user data variables and destructured from $data.
|
|
15221
15220
|
// SPLITTER character constant (same as \x1e), used as namespace separator
|
|
15222
15221
|
// for refData keys, event attribute encoding, and internal data structures.
|
|
15223
|
-
// Declared as: let $
|
|
15224
|
-
$
|
|
15225
|
-
//
|
|
15226
|
-
// User variables are destructured from
|
|
15227
|
-
// let {name, age} =
|
|
15222
|
+
// Declared as: let $splitter='\x1e'
|
|
15223
|
+
$splitter: 1,
|
|
15224
|
+
// Data — the data object passed from Updater to the template function.
|
|
15225
|
+
// User variables are destructured from $data at the top of the function:
|
|
15226
|
+
// let {name, age} = $data;
|
|
15228
15227
|
// This is the first parameter of the generated arrow function.
|
|
15229
|
-
|
|
15228
|
+
$data: 1,
|
|
15230
15229
|
// Null-safe toString: v => '' + (v == null ? '' : v)
|
|
15231
15230
|
// Converts null/undefined to empty string, otherwise calls toString().
|
|
15232
15231
|
// Wraps every {{!raw}} output to prevent "null" / "undefined" rendering.
|
|
15233
|
-
$
|
|
15234
|
-
// HTML entity encoder: v => $
|
|
15232
|
+
$strSafe: 1,
|
|
15233
|
+
// HTML entity encoder: v => $strSafe(v).replace(/[&<>"'`]/g, entityMap)
|
|
15235
15234
|
// Encodes &, <, >, ", ', ` to HTML entities (& < etc.)
|
|
15236
15235
|
// Applied to all {{=escaped}} and {{:binding}} outputs.
|
|
15237
|
-
$
|
|
15238
|
-
// HTML entity map — internal object used by $
|
|
15236
|
+
$encHtml: 1,
|
|
15237
|
+
// HTML entity map — internal object used by $encHtml:
|
|
15239
15238
|
// {'&':'amp','<':'gt','>':'gt','"':'#34','\'':'#39','`':'#96'}
|
|
15240
|
-
// Not a standalone function; referenced inside $
|
|
15241
|
-
$
|
|
15242
|
-
// HTML entity RegExp — internal regexp used by $
|
|
15239
|
+
// Not a standalone function; referenced inside $encHtml's closure.
|
|
15240
|
+
$entMap: 1,
|
|
15241
|
+
// HTML entity RegExp — internal regexp used by $encHtml:
|
|
15243
15242
|
// /[&<>"'`]/g
|
|
15244
|
-
$
|
|
15245
|
-
// HTML entity replacer function — internal helper used by $
|
|
15246
|
-
// m => '&' + $
|
|
15247
|
-
// Maps
|
|
15248
|
-
$
|
|
15243
|
+
$entReg: 1,
|
|
15244
|
+
// HTML entity replacer function — internal helper used by $encHtml:
|
|
15245
|
+
// m => '&' + $entMap[m] + ';'
|
|
15246
|
+
// Maps matched character to its entity string.
|
|
15247
|
+
$entFn: 1,
|
|
15249
15248
|
// Output buffer — the string accumulator for rendered HTML.
|
|
15250
|
-
// All template output is appended via $
|
|
15251
|
-
// Declared as: let $
|
|
15252
|
-
$
|
|
15249
|
+
// All template output is appended via $out += '...'.
|
|
15250
|
+
// Declared as: let $out = ''
|
|
15251
|
+
$out: 1,
|
|
15253
15252
|
// Reference lookup: (refData, value) => key
|
|
15254
15253
|
// Finds or allocates a SPLITTER-prefixed key in refData for a given
|
|
15255
15254
|
// object reference. Used by {{@ref}} operator for passing object
|
|
15256
15255
|
// references to child views via v-lark attributes.
|
|
15257
|
-
$
|
|
15258
|
-
// URI encoder: v => encodeURIComponent($
|
|
15256
|
+
$refFn: 1,
|
|
15257
|
+
// URI encoder: v => encodeURIComponent($strSafe(v)).replace(/[!')(*]/g, extraMap)
|
|
15259
15258
|
// Extends encodeURIComponent with encoding of ! ' ( ) *.
|
|
15260
15259
|
// Applied to values in @event URL parameters and {{!uri}} contexts.
|
|
15261
|
-
$
|
|
15262
|
-
//
|
|
15260
|
+
$encUri: 1,
|
|
15261
|
+
// URI encode map — internal object used by $encUri:
|
|
15262
|
+
// {'!':'%21','\'':'%27','(':'%28',')':'%29','*':'%2A'}
|
|
15263
|
+
$uriMap: 1,
|
|
15264
|
+
// URI encode replacer — internal helper used by $encUri:
|
|
15265
|
+
// m => $uriMap[m]
|
|
15266
|
+
$uriFn: 1,
|
|
15267
|
+
// URI encode regexp — internal regexp used by $encUri:
|
|
15268
|
+
// /[!')(*]/g
|
|
15269
|
+
$uriReg: 1,
|
|
15270
|
+
// Quote encoder: v => $strSafe(v).replace(/['"\\]/g, '\\$&')
|
|
15263
15271
|
// Escapes quotes and backslashes for safe embedding in HTML attribute
|
|
15264
15272
|
// values (e.g. data-json='...').
|
|
15265
|
-
$
|
|
15273
|
+
$encQuote: 1,
|
|
15274
|
+
// Quote encode regexp — internal regexp used by $encQuote:
|
|
15275
|
+
// /['"\\]/g
|
|
15276
|
+
$qReg: 1,
|
|
15266
15277
|
// View ID — the unique identifier of the owning View instance.
|
|
15267
15278
|
// Injected into @event attribute values at render time so that
|
|
15268
15279
|
// EventDelegator can dispatch events to the correct View handler.
|
|
@@ -15270,23 +15281,23 @@ var BUILTIN_GLOBALS = {
|
|
|
15270
15281
|
$viewId: 1,
|
|
15271
15282
|
// Debug: current expression text — stores the template expression being
|
|
15272
15283
|
// evaluated, for error reporting. Only present in debug mode.
|
|
15273
|
-
// e.g. $
|
|
15274
|
-
$
|
|
15284
|
+
// e.g. $dbgExpr='<%=user.name%>'
|
|
15285
|
+
$dbgExpr: 1,
|
|
15275
15286
|
// Debug: original art syntax — stores the {{}} template syntax before
|
|
15276
15287
|
// conversion, for error reporting. Only present in debug mode.
|
|
15277
|
-
// e.g. $
|
|
15278
|
-
$
|
|
15288
|
+
// e.g. $dbgArt='{{=user.name}}'
|
|
15289
|
+
$dbgArt: 1,
|
|
15279
15290
|
// Debug: source line number — tracks the current line in the template
|
|
15280
15291
|
// source, for error reporting. Only present in debug mode.
|
|
15281
|
-
$
|
|
15282
|
-
//
|
|
15283
|
-
// Defaults to
|
|
15284
|
-
// Ensures $
|
|
15285
|
-
|
|
15292
|
+
$dbgLine: 1,
|
|
15293
|
+
// RefData alias — fallback reference lookup table.
|
|
15294
|
+
// Defaults to $data when no explicit $refAlt is provided.
|
|
15295
|
+
// Ensures $refFn() does not crash when @ operator is used without refData.
|
|
15296
|
+
$refAlt: 1,
|
|
15286
15297
|
// Temporary variable — used by the compiler for intermediate
|
|
15287
15298
|
// expression results in generated code (e.g. loop variables,
|
|
15288
|
-
// conditional branches). Declared as: let $
|
|
15289
|
-
$
|
|
15299
|
+
// conditional branches). Declared as: let $tmp
|
|
15300
|
+
$tmp: 1,
|
|
15290
15301
|
// JS literals
|
|
15291
15302
|
undefined: 1,
|
|
15292
15303
|
null: 1,
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark.js/mvc",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "@lark.js/mvc - TypeScript MVC framework",
|
|
5
5
|
"files": [
|
|
6
|
-
"dist"
|
|
6
|
+
"dist",
|
|
7
|
+
"src/client.d.ts",
|
|
8
|
+
"README.md"
|
|
7
9
|
],
|
|
8
10
|
"exports": {
|
|
9
11
|
".": {
|
|
@@ -35,12 +37,23 @@
|
|
|
35
37
|
"types": "./dist/webpack.d.cts",
|
|
36
38
|
"default": "./dist/webpack.cjs"
|
|
37
39
|
}
|
|
40
|
+
},
|
|
41
|
+
"./runtime": {
|
|
42
|
+
"import": {
|
|
43
|
+
"types": "./dist/runtime.d.ts",
|
|
44
|
+
"default": "./dist/runtime.js"
|
|
45
|
+
},
|
|
46
|
+
"require": {
|
|
47
|
+
"types": "./dist/runtime.d.cts",
|
|
48
|
+
"default": "./dist/runtime.cjs"
|
|
49
|
+
}
|
|
38
50
|
}
|
|
39
51
|
},
|
|
40
52
|
"main": "dist/index.cjs",
|
|
41
53
|
"module": "dist/index.js",
|
|
42
54
|
"types": "dist/index.d.ts",
|
|
43
55
|
"scripts": {
|
|
56
|
+
"prepublish": "pnpm build",
|
|
44
57
|
"build": "pnpm build:tsup",
|
|
45
58
|
"build:rollup": "rollup -c rollup.config.mjs",
|
|
46
59
|
"build:tsup": "tsup",
|
|
@@ -60,16 +73,16 @@
|
|
|
60
73
|
"license": "ISC",
|
|
61
74
|
"packageManager": "pnpm@10.33.0",
|
|
62
75
|
"devDependencies": {
|
|
63
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
76
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
64
77
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
65
78
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
66
79
|
"@vitest/coverage-v8": "4.1.6",
|
|
67
|
-
"rollup": "^4.
|
|
80
|
+
"rollup": "^4.61.0",
|
|
68
81
|
"rollup-plugin-dts": "^6.4.1",
|
|
69
82
|
"tsup": "^8.5.1",
|
|
70
|
-
"typescript": "^5.
|
|
71
|
-
"vite": "^8.0.
|
|
72
|
-
"vitest": "^4.1.
|
|
83
|
+
"typescript": "^5.9.3",
|
|
84
|
+
"vite": "^8.0.16",
|
|
85
|
+
"vitest": "^4.1.8"
|
|
73
86
|
},
|
|
74
87
|
"lint-staged": {
|
|
75
88
|
"*.{json,jsonc,js,cjs,mjs,jsx,ts,cts,mts,tsx,html,vue,css,scss,md,mdx}": [
|
package/src/client.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FrameInterface,
|
|
3
|
+
FrameworkInterface,
|
|
4
|
+
StateInterface,
|
|
5
|
+
RouterInterface,
|
|
6
|
+
} from "./types";
|
|
7
|
+
import type { Frame } from "./frame";
|
|
8
|
+
import type { View } from "./view";
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
/** Whether lark debug mode is enabled */
|
|
12
|
+
__lark_Debug: boolean;
|
|
13
|
+
/** Lark Framework object */
|
|
14
|
+
__lark_Framework?: FrameworkInterface;
|
|
15
|
+
/** Lark State object */
|
|
16
|
+
__lark_State?: StateInterface;
|
|
17
|
+
/** Lark Router object */
|
|
18
|
+
__lark_Router?: RouterInterface;
|
|
19
|
+
/** Lark Frame class */
|
|
20
|
+
__lark_Frame?: typeof Frame;
|
|
21
|
+
/** Lark View class */
|
|
22
|
+
__lark_View?: typeof View;
|
|
23
|
+
/** Invalidate a view class from the registry (HMR support) */
|
|
24
|
+
__lark_invalidateViewClass?: (viewPath: string) => void;
|
|
25
|
+
/** Get the view class registry (HMR/debug support) */
|
|
26
|
+
__lark_getViewClassRegistry?: () => Record<string, typeof View>;
|
|
27
|
+
/** Register a view class (HMR support) */
|
|
28
|
+
__lark_registerViewClass?: (
|
|
29
|
+
viewPath: string,
|
|
30
|
+
ViewClass: typeof View,
|
|
31
|
+
) => void;
|
|
32
|
+
/** Cross-site configuration injected by build tools */
|
|
33
|
+
crossConfigs?: CrossSiteConfig[];
|
|
34
|
+
scheduler?: Scheduler;
|
|
35
|
+
}
|
|
36
|
+
interface HTMLElement {
|
|
37
|
+
/** Bound frame instance */
|
|
38
|
+
frame?: FrameInterface | undefined;
|
|
39
|
+
/** Whether frame is bound to this element (1 = bound) */
|
|
40
|
+
frameBound?: number;
|
|
41
|
+
/** Whether auto-generated ID was assigned */
|
|
42
|
+
autoId?: number;
|
|
43
|
+
/** View rendered flag for selector matching */
|
|
44
|
+
viewRendered?: number;
|
|
45
|
+
/** Range frame ID for event delegation */
|
|
46
|
+
rangeFrameId?: string;
|
|
47
|
+
/** Range element guid for event delegation */
|
|
48
|
+
rangeElementGuid?: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface Element {
|
|
52
|
+
/** VDOM diff cached compare key flag */
|
|
53
|
+
compareKeyCached?: number | undefined;
|
|
54
|
+
/** VDOM diff cached compare key */
|
|
55
|
+
cachedCompareKey?: string | undefined;
|
|
56
|
+
"v-lark"?: string | undefined;
|
|
57
|
+
|
|
58
|
+
// @lark.js/sentry
|
|
59
|
+
"s-lark-ev"?: string | undefined;
|
|
60
|
+
"s-lark-msg"?: string | undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// CSS module type declarations
|
|
65
|
+
declare module "*.css" {
|
|
66
|
+
const content: string;
|
|
67
|
+
export default content;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// HTML template module declarations (Lark templates - compiled to functions)
|
|
71
|
+
declare module "*.html" {
|
|
72
|
+
// const template: (
|
|
73
|
+
// data: unknown,
|
|
74
|
+
// viewId: string,
|
|
75
|
+
// refData: unknown,
|
|
76
|
+
// ) => string;
|
|
77
|
+
// export default template;
|
|
78
|
+
const content: string;
|
|
79
|
+
export default content;
|
|
80
|
+
}
|