@lark.js/mvc 0.0.4 → 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 +828 -451
- package/dist/{chunk-ANWA22AX.js → chunk-IIIY575B.js} +24 -25
- package/dist/index.cjs +1032 -569
- package/dist/index.d.cts +548 -111
- package/dist/index.d.ts +548 -111
- package/dist/index.js +1023 -567
- 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 +24 -25
- package/dist/vite.d.cts +3 -3
- package/dist/vite.d.ts +3 -3
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +24 -25
- package/dist/webpack.js +1 -1
- package/package.json +21 -8
- package/src/client.d.ts +80 -0
package/dist/runtime.cjs
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/runtime.ts
|
|
21
|
+
var runtime_exports = {};
|
|
22
|
+
__export(runtime_exports, {
|
|
23
|
+
encHtml: () => encHtml,
|
|
24
|
+
encQuote: () => encQuote,
|
|
25
|
+
encUri: () => encUri,
|
|
26
|
+
refFn: () => refFn,
|
|
27
|
+
strSafe: () => strSafe
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
30
|
+
var HTML_ENT_MAP = {
|
|
31
|
+
"&": "amp",
|
|
32
|
+
"<": "lt",
|
|
33
|
+
">": "gt",
|
|
34
|
+
'"': "#34",
|
|
35
|
+
"'": "#39",
|
|
36
|
+
"`": "#96"
|
|
37
|
+
};
|
|
38
|
+
var HTML_ENT_REGEXP = /[&<>"`']/g;
|
|
39
|
+
var strSafe = (v) => "" + (v == null ? "" : v);
|
|
40
|
+
var encHtml = (v) => strSafe(v).replace(HTML_ENT_REGEXP, (m) => "&" + HTML_ENT_MAP[m] + ";");
|
|
41
|
+
var URI_ENT_MAP = {
|
|
42
|
+
"!": "%21",
|
|
43
|
+
"'": "%27",
|
|
44
|
+
"(": "%28",
|
|
45
|
+
")": "%29",
|
|
46
|
+
"*": "%2A"
|
|
47
|
+
};
|
|
48
|
+
var URI_ENT_REGEXP = /[!')(*]/g;
|
|
49
|
+
var encUri = (v) => encodeURIComponent(strSafe(v)).replace(URI_ENT_REGEXP, (m) => URI_ENT_MAP[m]);
|
|
50
|
+
var QUOTE_REGEXP = /['"\\]/g;
|
|
51
|
+
var encQuote = (v) => strSafe(v).replace(QUOTE_REGEXP, "\\$&");
|
|
52
|
+
var refFn = (ref, value, key) => {
|
|
53
|
+
const SPLITTER = "";
|
|
54
|
+
const counter = ref[SPLITTER];
|
|
55
|
+
for (let i = counter; --i; ) {
|
|
56
|
+
key = SPLITTER + i;
|
|
57
|
+
if (ref[key] === value) return key;
|
|
58
|
+
}
|
|
59
|
+
key = SPLITTER + ref[SPLITTER]++;
|
|
60
|
+
ref[key] = value;
|
|
61
|
+
return key;
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
encHtml,
|
|
66
|
+
encQuote,
|
|
67
|
+
encUri,
|
|
68
|
+
refFn,
|
|
69
|
+
strSafe
|
|
70
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template runtime helpers.
|
|
3
|
+
*
|
|
4
|
+
* Compiled templates import these helpers from `@lark.js/mvc/runtime` instead
|
|
5
|
+
* of inlining the implementations. That keeps each compiled `.html` module
|
|
6
|
+
* small — no more ~400 bytes of duplicated helper code per template.
|
|
7
|
+
*
|
|
8
|
+
* The helpers below are aliased to `$strSafe / $encHtml / $encUri / $encQuote /
|
|
9
|
+
* $refFn` inside the IIFE that the compiler produces — see `compiler.ts`.
|
|
10
|
+
*/
|
|
11
|
+
/** Null-safe `String(value)` — `null`/`undefined` become `""`. */
|
|
12
|
+
declare const strSafe: (v: unknown) => string;
|
|
13
|
+
/** HTML-escape a value for safe embedding in markup. */
|
|
14
|
+
declare const encHtml: (v: unknown) => string;
|
|
15
|
+
/** Percent-encode a value, with extra characters escaped for stricter URIs. */
|
|
16
|
+
declare const encUri: (v: unknown) => string;
|
|
17
|
+
/** Backslash-escape quotes and backslashes for attribute string contents. */
|
|
18
|
+
declare const encQuote: (v: unknown) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Look up (or assign) a stable refData token for an object value.
|
|
21
|
+
*
|
|
22
|
+
* Templates use `{{@expr}}` to pass live JS values (objects/functions) through
|
|
23
|
+
* the DOM by writing the token into an attribute, then resolving it back to
|
|
24
|
+
* the original value when the event fires. `refData[SPLITTER]` holds the
|
|
25
|
+
* monotonic counter; `refData[SPLITTER + n]` holds the slot.
|
|
26
|
+
*/
|
|
27
|
+
declare const refFn: (ref: Record<string, unknown>, value: unknown, key: string) => string;
|
|
28
|
+
|
|
29
|
+
export { encHtml, encQuote, encUri, refFn, strSafe };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template runtime helpers.
|
|
3
|
+
*
|
|
4
|
+
* Compiled templates import these helpers from `@lark.js/mvc/runtime` instead
|
|
5
|
+
* of inlining the implementations. That keeps each compiled `.html` module
|
|
6
|
+
* small — no more ~400 bytes of duplicated helper code per template.
|
|
7
|
+
*
|
|
8
|
+
* The helpers below are aliased to `$strSafe / $encHtml / $encUri / $encQuote /
|
|
9
|
+
* $refFn` inside the IIFE that the compiler produces — see `compiler.ts`.
|
|
10
|
+
*/
|
|
11
|
+
/** Null-safe `String(value)` — `null`/`undefined` become `""`. */
|
|
12
|
+
declare const strSafe: (v: unknown) => string;
|
|
13
|
+
/** HTML-escape a value for safe embedding in markup. */
|
|
14
|
+
declare const encHtml: (v: unknown) => string;
|
|
15
|
+
/** Percent-encode a value, with extra characters escaped for stricter URIs. */
|
|
16
|
+
declare const encUri: (v: unknown) => string;
|
|
17
|
+
/** Backslash-escape quotes and backslashes for attribute string contents. */
|
|
18
|
+
declare const encQuote: (v: unknown) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Look up (or assign) a stable refData token for an object value.
|
|
21
|
+
*
|
|
22
|
+
* Templates use `{{@expr}}` to pass live JS values (objects/functions) through
|
|
23
|
+
* the DOM by writing the token into an attribute, then resolving it back to
|
|
24
|
+
* the original value when the event fires. `refData[SPLITTER]` holds the
|
|
25
|
+
* monotonic counter; `refData[SPLITTER + n]` holds the slot.
|
|
26
|
+
*/
|
|
27
|
+
declare const refFn: (ref: Record<string, unknown>, value: unknown, key: string) => string;
|
|
28
|
+
|
|
29
|
+
export { encHtml, encQuote, encUri, refFn, strSafe };
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/runtime.ts
|
|
2
|
+
var HTML_ENT_MAP = {
|
|
3
|
+
"&": "amp",
|
|
4
|
+
"<": "lt",
|
|
5
|
+
">": "gt",
|
|
6
|
+
'"': "#34",
|
|
7
|
+
"'": "#39",
|
|
8
|
+
"`": "#96"
|
|
9
|
+
};
|
|
10
|
+
var HTML_ENT_REGEXP = /[&<>"`']/g;
|
|
11
|
+
var strSafe = (v) => "" + (v == null ? "" : v);
|
|
12
|
+
var encHtml = (v) => strSafe(v).replace(HTML_ENT_REGEXP, (m) => "&" + HTML_ENT_MAP[m] + ";");
|
|
13
|
+
var URI_ENT_MAP = {
|
|
14
|
+
"!": "%21",
|
|
15
|
+
"'": "%27",
|
|
16
|
+
"(": "%28",
|
|
17
|
+
")": "%29",
|
|
18
|
+
"*": "%2A"
|
|
19
|
+
};
|
|
20
|
+
var URI_ENT_REGEXP = /[!')(*]/g;
|
|
21
|
+
var encUri = (v) => encodeURIComponent(strSafe(v)).replace(URI_ENT_REGEXP, (m) => URI_ENT_MAP[m]);
|
|
22
|
+
var QUOTE_REGEXP = /['"\\]/g;
|
|
23
|
+
var encQuote = (v) => strSafe(v).replace(QUOTE_REGEXP, "\\$&");
|
|
24
|
+
var refFn = (ref, value, key) => {
|
|
25
|
+
const SPLITTER = "";
|
|
26
|
+
const counter = ref[SPLITTER];
|
|
27
|
+
for (let i = counter; --i; ) {
|
|
28
|
+
key = SPLITTER + i;
|
|
29
|
+
if (ref[key] === value) return key;
|
|
30
|
+
}
|
|
31
|
+
key = SPLITTER + ref[SPLITTER]++;
|
|
32
|
+
ref[key] = value;
|
|
33
|
+
return key;
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
encHtml,
|
|
37
|
+
encQuote,
|
|
38
|
+
encUri,
|
|
39
|
+
refFn,
|
|
40
|
+
strSafe
|
|
41
|
+
};
|
package/dist/vite.cjs
CHANGED
|
@@ -14814,7 +14814,7 @@ function convertArtExpression(code, debug, lineNo, blockStack = []) {
|
|
|
14814
14814
|
return `${debugPrefix}<%for(${forExpr}){%>`;
|
|
14815
14815
|
}
|
|
14816
14816
|
const tokens = code.split(/\s+/);
|
|
14817
|
-
const keyword = tokens.shift();
|
|
14817
|
+
const keyword = tokens.shift() ?? "";
|
|
14818
14818
|
switch (keyword) {
|
|
14819
14819
|
case "if": {
|
|
14820
14820
|
blockStack.push({ ctrl: "if", line: lineNo });
|
|
@@ -15038,13 +15038,9 @@ function compileToFunction(source, debug, file) {
|
|
|
15038
15038
|
}
|
|
15039
15039
|
const viewIdRegExp = new RegExp(String.fromCharCode(31), "g");
|
|
15040
15040
|
funcSource = funcSource.replace(viewIdRegExp, `'+$viewId+'`);
|
|
15041
|
-
|
|
15042
|
-
const encode = `if(!$strSafe){let $entMap={'&':'amp','<':'lt','>':'gt','"':'#34','\\'':'#39','\`':'#96'},$entReg=/[&<>"'\`]/g,$entFn=m=>'&'+$entMap[m]+';';$strSafe=v=>''+(v==null?'':v);$encHtml=v=>$strSafe(v).replace($entReg,$entFn)}`;
|
|
15043
|
-
const encodeURIMore = `if(!$encUri){let $uriMap={'!':'%21','\\'':'%27','(':'%28',')':'%29','*':'%2A'},$uriFn=m=>$uriMap[m],$uriReg=/[!')(*]/g;$encUri=v=>encodeURIComponent($strSafe(v)).replace($uriReg,$uriFn)}`;
|
|
15044
|
-
const encodeQuote = `if(!$encQuote){let $qReg=/['"\\\\]/g;$encQuote=v=>$strSafe(v).replace($qReg,'\\\\$&')}`;
|
|
15041
|
+
void hasAtRule;
|
|
15045
15042
|
const refFallback = "if(!$refAlt)$refAlt=$data;";
|
|
15046
|
-
const
|
|
15047
|
-
const fullSource = `${fns}let $splitter='\\x1e',$tmp,$out=''{{VARS}};${funcSource}return $out`;
|
|
15043
|
+
const fullSource = `${refFallback}let $splitter='\\x1e',$tmp,$out=''{{VARS}};${funcSource}return $out`;
|
|
15048
15044
|
return `($data,$viewId,$refAlt,$encHtml,$strSafe,$encUri,$refFn,$encQuote)=>{${fullSource}}`;
|
|
15049
15045
|
}
|
|
15050
15046
|
function compileTemplate(source, options = {}) {
|
|
@@ -15056,15 +15052,12 @@ function compileTemplate(source, options = {}) {
|
|
|
15056
15052
|
const funcBody = compileToFunction(finalSource, debug, file);
|
|
15057
15053
|
const varDeclarations = globalVars.map((key) => `,${key}=$data.${key}`).join("");
|
|
15058
15054
|
const funcWithVars = funcBody.replace("{{VARS}}", () => varDeclarations);
|
|
15059
|
-
return `
|
|
15055
|
+
return `import { encHtml as __larkEncHtml, strSafe as __larkStrSafe, encUri as __larkEncUri, encQuote as __larkEncQuote, refFn as __larkRefFn } from "@lark.js/mvc/runtime";
|
|
15056
|
+
export default function(data, viewId, refData) {
|
|
15060
15057
|
let $data = data || {},
|
|
15061
|
-
$viewId =
|
|
15058
|
+
$viewId = viewId || '';
|
|
15062
15059
|
return (${funcWithVars})($data, $viewId, refData,
|
|
15063
|
-
|
|
15064
|
-
/* $strSafe */ v => String(v == null ? '' : v),
|
|
15065
|
-
/* $encUri */ null,
|
|
15066
|
-
/* $refFn */ null,
|
|
15067
|
-
/* $encQuote */ null
|
|
15060
|
+
__larkEncHtml, __larkStrSafe, __larkEncUri, __larkRefFn, __larkEncQuote
|
|
15068
15061
|
);
|
|
15069
15062
|
}`;
|
|
15070
15063
|
}
|
|
@@ -15189,31 +15182,37 @@ function walkAst(ast, visitors) {
|
|
|
15189
15182
|
if (visitors[type]) {
|
|
15190
15183
|
visitors[type](node);
|
|
15191
15184
|
}
|
|
15185
|
+
const bag = node;
|
|
15192
15186
|
for (const key of Object.keys(node)) {
|
|
15193
15187
|
if (key === "type" || key === "start" || key === "end" || key === "loc" || key === "range")
|
|
15194
15188
|
continue;
|
|
15195
|
-
if (type === "MemberExpression" && key === "property"
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
continue;
|
|
15189
|
+
if (type === "MemberExpression" && key === "property") {
|
|
15190
|
+
const me = node;
|
|
15191
|
+
if (!me.computed) continue;
|
|
15199
15192
|
}
|
|
15200
|
-
if (type === "
|
|
15201
|
-
|
|
15193
|
+
if (type === "ObjectProperty" && key === "key") {
|
|
15194
|
+
const op = node;
|
|
15195
|
+
if (!op.computed) continue;
|
|
15202
15196
|
}
|
|
15203
|
-
|
|
15197
|
+
if (type === "ObjectMethod" && key === "key") {
|
|
15198
|
+
const om = node;
|
|
15199
|
+
if (!om.computed) continue;
|
|
15200
|
+
}
|
|
15201
|
+
const child = bag[key];
|
|
15204
15202
|
if (Array.isArray(child)) {
|
|
15205
15203
|
for (const item of child) {
|
|
15206
|
-
if (item
|
|
15207
|
-
visit(item);
|
|
15208
|
-
}
|
|
15204
|
+
if (isAstNode(item)) visit(item);
|
|
15209
15205
|
}
|
|
15210
|
-
} else if (child
|
|
15206
|
+
} else if (isAstNode(child)) {
|
|
15211
15207
|
visit(child);
|
|
15212
15208
|
}
|
|
15213
15209
|
}
|
|
15214
15210
|
}
|
|
15215
15211
|
visit(ast);
|
|
15216
15212
|
}
|
|
15213
|
+
function isAstNode(v) {
|
|
15214
|
+
return !!v && typeof v === "object" && typeof v.type === "string";
|
|
15215
|
+
}
|
|
15217
15216
|
var BUILTIN_GLOBALS = {
|
|
15218
15217
|
// ─── Template runtime helpers (injected by compileToFunction) ───────
|
|
15219
15218
|
//
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @lark/
|
|
4
|
+
* @lark.js/mvc Vite Plugin for Template Compilation
|
|
5
5
|
*
|
|
6
|
-
* Compiles .html template files using @lark/
|
|
6
|
+
* Compiles .html template files using @lark.js/mvc template syntax
|
|
7
7
|
* into JS function modules at build/dev time.
|
|
8
8
|
*
|
|
9
9
|
* 0 configuration — just add the plugin and it works.
|
|
@@ -16,7 +16,7 @@ import { Plugin } from 'vite';
|
|
|
16
16
|
*
|
|
17
17
|
* Usage in vite.config.ts:
|
|
18
18
|
* ```ts
|
|
19
|
-
* import { larkMvcPlugin } from '@lark/
|
|
19
|
+
* import { larkMvcPlugin } from '@lark.js/mvc/vite';
|
|
20
20
|
*
|
|
21
21
|
* export default defineConfig({
|
|
22
22
|
* plugins: [larkMvcPlugin()],
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @lark/
|
|
4
|
+
* @lark.js/mvc Vite Plugin for Template Compilation
|
|
5
5
|
*
|
|
6
|
-
* Compiles .html template files using @lark/
|
|
6
|
+
* Compiles .html template files using @lark.js/mvc template syntax
|
|
7
7
|
* into JS function modules at build/dev time.
|
|
8
8
|
*
|
|
9
9
|
* 0 configuration — just add the plugin and it works.
|
|
@@ -16,7 +16,7 @@ import { Plugin } from 'vite';
|
|
|
16
16
|
*
|
|
17
17
|
* Usage in vite.config.ts:
|
|
18
18
|
* ```ts
|
|
19
|
-
* import { larkMvcPlugin } from '@lark/
|
|
19
|
+
* import { larkMvcPlugin } from '@lark.js/mvc/vite';
|
|
20
20
|
*
|
|
21
21
|
* export default defineConfig({
|
|
22
22
|
* plugins: [larkMvcPlugin()],
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -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 });
|
|
@@ -15036,13 +15036,9 @@ function compileToFunction(source, debug, file) {
|
|
|
15036
15036
|
}
|
|
15037
15037
|
const viewIdRegExp = new RegExp(String.fromCharCode(31), "g");
|
|
15038
15038
|
funcSource = funcSource.replace(viewIdRegExp, `'+$viewId+'`);
|
|
15039
|
-
|
|
15040
|
-
const encode = `if(!$strSafe){let $entMap={'&':'amp','<':'lt','>':'gt','"':'#34','\\'':'#39','\`':'#96'},$entReg=/[&<>"'\`]/g,$entFn=m=>'&'+$entMap[m]+';';$strSafe=v=>''+(v==null?'':v);$encHtml=v=>$strSafe(v).replace($entReg,$entFn)}`;
|
|
15041
|
-
const encodeURIMore = `if(!$encUri){let $uriMap={'!':'%21','\\'':'%27','(':'%28',')':'%29','*':'%2A'},$uriFn=m=>$uriMap[m],$uriReg=/[!')(*]/g;$encUri=v=>encodeURIComponent($strSafe(v)).replace($uriReg,$uriFn)}`;
|
|
15042
|
-
const encodeQuote = `if(!$encQuote){let $qReg=/['"\\\\]/g;$encQuote=v=>$strSafe(v).replace($qReg,'\\\\$&')}`;
|
|
15039
|
+
void hasAtRule;
|
|
15043
15040
|
const refFallback = "if(!$refAlt)$refAlt=$data;";
|
|
15044
|
-
const
|
|
15045
|
-
const fullSource = `${fns}let $splitter='\\x1e',$tmp,$out=''{{VARS}};${funcSource}return $out`;
|
|
15041
|
+
const fullSource = `${refFallback}let $splitter='\\x1e',$tmp,$out=''{{VARS}};${funcSource}return $out`;
|
|
15046
15042
|
return `($data,$viewId,$refAlt,$encHtml,$strSafe,$encUri,$refFn,$encQuote)=>{${fullSource}}`;
|
|
15047
15043
|
}
|
|
15048
15044
|
function compileTemplate(source, options = {}) {
|
|
@@ -15054,15 +15050,12 @@ function compileTemplate(source, options = {}) {
|
|
|
15054
15050
|
const funcBody = compileToFunction(finalSource, debug, file);
|
|
15055
15051
|
const varDeclarations = globalVars.map((key) => `,${key}=$data.${key}`).join("");
|
|
15056
15052
|
const funcWithVars = funcBody.replace("{{VARS}}", () => varDeclarations);
|
|
15057
|
-
return `
|
|
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) {
|
|
15058
15055
|
let $data = data || {},
|
|
15059
|
-
$viewId =
|
|
15056
|
+
$viewId = viewId || '';
|
|
15060
15057
|
return (${funcWithVars})($data, $viewId, refData,
|
|
15061
|
-
|
|
15062
|
-
/* $strSafe */ v => String(v == null ? '' : v),
|
|
15063
|
-
/* $encUri */ null,
|
|
15064
|
-
/* $refFn */ null,
|
|
15065
|
-
/* $encQuote */ null
|
|
15058
|
+
__larkEncHtml, __larkStrSafe, __larkEncUri, __larkRefFn, __larkEncQuote
|
|
15066
15059
|
);
|
|
15067
15060
|
}`;
|
|
15068
15061
|
}
|
|
@@ -15187,31 +15180,37 @@ 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
|
//
|
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
|
+
}
|