@lark.js/mvc 0.0.13 → 0.0.15
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 +4 -5
- package/dist/apply-style.d.ts +9 -0
- package/dist/cache.d.ts +69 -0
- package/dist/common.d.ts +64 -0
- package/dist/compiler/compile-template.d.ts +16 -0
- package/dist/compiler/compile-to-vdom-function.d.ts +13 -0
- package/dist/compiler/extract-global-vars.d.ts +17 -0
- package/dist/compiler/template-syntax.d.ts +61 -0
- package/dist/compiler.cjs +15843 -15805
- package/dist/compiler.d.cts +1 -30
- package/dist/compiler.d.ts +1 -30
- package/dist/compiler.js +15840 -15789
- package/dist/cross-site.d.ts +29 -0
- package/dist/devtool.cjs +4139 -3166
- package/dist/devtool.d.cts +2 -1
- package/dist/devtool.d.ts +2 -1
- package/dist/devtool.js +4149 -3092
- package/dist/dom.d.ts +45 -0
- package/dist/event-delegator.d.ts +28 -0
- package/dist/event-emitter.d.ts +38 -0
- package/dist/frame.d.ts +143 -0
- package/dist/framework.d.ts +9 -0
- package/dist/hmr.d.ts +53 -0
- package/dist/index.amd.js +6285 -0
- package/dist/index.cjs +5959 -4484
- package/dist/index.d.cts +10 -19
- package/dist/index.d.ts +10 -19
- package/dist/index.js +5919 -4419
- package/dist/index.umd.js +6272 -0
- package/dist/mark.d.ts +26 -0
- package/dist/module-loader.d.ts +20 -0
- package/dist/router.d.ts +14 -0
- package/dist/rspack.cjs +15927 -15877
- package/dist/rspack.d.cts +45 -23
- package/dist/rspack.d.ts +45 -23
- package/dist/rspack.js +15926 -15870
- package/dist/runtime.amd.js +94 -0
- package/dist/runtime.cjs +79 -82
- package/dist/runtime.js +85 -19
- package/dist/runtime.umd.js +98 -0
- package/dist/service.d.ts +173 -0
- package/dist/state.d.ts +8 -0
- package/dist/store.d.ts +60 -0
- package/dist/types.d.ts +1259 -0
- package/dist/updater.d.ts +90 -0
- package/dist/url-state.d.ts +32 -0
- package/dist/utils.d.ts +90 -0
- package/dist/vdom.d.ts +45 -0
- package/dist/view-registry.d.ts +20 -0
- package/dist/view.d.ts +214 -0
- package/dist/vite.cjs +15940 -15898
- package/dist/vite.d.cts +10 -8
- package/dist/vite.d.ts +10 -8
- package/dist/vite.js +15937 -15890
- package/dist/webpack.cjs +15977 -15877
- package/dist/webpack.d.cts +36 -14
- package/dist/webpack.d.ts +36 -14
- package/dist/webpack.js +15976 -15870
- package/package.json +6 -5
- package/dist/chunk-66OZBBSP.js +0 -108
- /package/{src → dist}/client.d.ts +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
define('lark-mvc/runtime', ['exports'], (function (exports) { 'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Lark framework constants.
|
|
5
|
+
*/
|
|
6
|
+
/** Global counter for generating unique IDs */
|
|
7
|
+
/** Internal splitter character (U+001E Record Separator, invisible, used as namespace separator).
|
|
8
|
+
* Uses String.fromCharCode to survive bundlers that strip control-char literals. */
|
|
9
|
+
const SPLITTER = String.fromCharCode(0x1e);
|
|
10
|
+
// ============================================================
|
|
11
|
+
// Encoding helpers (shared by dom.ts, runtime.ts, updater.ts)
|
|
12
|
+
// ============================================================
|
|
13
|
+
const HTML_ENT_MAP = {
|
|
14
|
+
"&": "amp",
|
|
15
|
+
"<": "lt",
|
|
16
|
+
">": "gt",
|
|
17
|
+
'"': "#34",
|
|
18
|
+
"'": "#39",
|
|
19
|
+
"`": "#96",
|
|
20
|
+
};
|
|
21
|
+
const HTML_ENT_REGEXP = /[&<>"'`]/g;
|
|
22
|
+
/** Null-safe String conversion */
|
|
23
|
+
function strSafe$1(v) {
|
|
24
|
+
return String(v == null ? "" : v);
|
|
25
|
+
}
|
|
26
|
+
/** HTML entity encoding for safe output */
|
|
27
|
+
function encodeHTML(v) {
|
|
28
|
+
return String(v == null ? "" : v).replace(HTML_ENT_REGEXP, (m) => "&" + HTML_ENT_MAP[m] + ";");
|
|
29
|
+
}
|
|
30
|
+
const URI_ENT_MAP = {
|
|
31
|
+
"!": "%21",
|
|
32
|
+
"'": "%27",
|
|
33
|
+
"(": "%28",
|
|
34
|
+
")": "%29",
|
|
35
|
+
"*": "%2A",
|
|
36
|
+
};
|
|
37
|
+
const URI_ENT_REGEXP = /[!')(*]/g;
|
|
38
|
+
/** URI-encode with extra character encoding */
|
|
39
|
+
function encodeURIExtra(v) {
|
|
40
|
+
return encodeURIComponent(strSafe$1(v)).replace(URI_ENT_REGEXP, (m) => URI_ENT_MAP[m]);
|
|
41
|
+
}
|
|
42
|
+
const QUOTE_ENT_REGEXP = /['"\\]/g;
|
|
43
|
+
/** Quote-encode for attribute values */
|
|
44
|
+
function encodeQuote(v) {
|
|
45
|
+
return strSafe$1(v).replace(QUOTE_ENT_REGEXP, "\\$&");
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Template reference function for creating stable keys for objects.
|
|
49
|
+
* Stores objects in refData with SPLITTER-prefixed keys.
|
|
50
|
+
*/
|
|
51
|
+
function refFn(ref, value, key) {
|
|
52
|
+
const counter = ref[SPLITTER];
|
|
53
|
+
for (let i = counter; --i;) {
|
|
54
|
+
key = SPLITTER + i;
|
|
55
|
+
if (ref[key] === value)
|
|
56
|
+
return key;
|
|
57
|
+
}
|
|
58
|
+
key = SPLITTER + ref[SPLITTER]++;
|
|
59
|
+
ref[key] = value;
|
|
60
|
+
return key;
|
|
61
|
+
}
|
|
62
|
+
// export function isCjs(): boolean {
|
|
63
|
+
// return typeof module !== "undefined" && typeof module.exports !== "undefined";
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Template runtime helpers.
|
|
68
|
+
*
|
|
69
|
+
* Compiled templates import these helpers from `@lark.js/mvc/runtime` instead
|
|
70
|
+
* of inlining the implementations. That keeps each compiled `.html` module
|
|
71
|
+
* small — no more ~400 bytes of duplicated helper code per template.
|
|
72
|
+
*
|
|
73
|
+
* The helpers below are aliased to `$strSafe / $encHtml / $encUri / $encQuote /
|
|
74
|
+
* $refFn` inside the IIFE that the compiler produces — see `compiler.ts`.
|
|
75
|
+
*
|
|
76
|
+
* Canonical implementations live in `./common` so that dom.ts, runtime.ts,
|
|
77
|
+
* and updater.ts all share a single copy.
|
|
78
|
+
*/
|
|
79
|
+
/** Null-safe `String(value)` — `null`/`undefined` become `""`. */
|
|
80
|
+
const strSafe = strSafe$1;
|
|
81
|
+
/** HTML-escape a value for safe embedding in markup. */
|
|
82
|
+
const encHtml = encodeHTML;
|
|
83
|
+
/** Percent-encode a value, with extra characters escaped for stricter URIs. */
|
|
84
|
+
const encUri = encodeURIExtra;
|
|
85
|
+
/** Backslash-escape quotes and backslashes for attribute string contents. */
|
|
86
|
+
const encQuote = encodeQuote;
|
|
87
|
+
|
|
88
|
+
exports.encHtml = encHtml;
|
|
89
|
+
exports.encQuote = encQuote;
|
|
90
|
+
exports.encUri = encUri;
|
|
91
|
+
exports.refFn = refFn;
|
|
92
|
+
exports.strSafe = strSafe;
|
|
93
|
+
|
|
94
|
+
}));
|
package/dist/runtime.cjs
CHANGED
|
@@ -1,95 +1,92 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"&": "amp",
|
|
38
|
-
"<": "lt",
|
|
39
|
-
">": "gt",
|
|
40
|
-
'"': "#34",
|
|
41
|
-
"'": "#39",
|
|
42
|
-
"`": "#96"
|
|
3
|
+
/**
|
|
4
|
+
* Lark framework constants.
|
|
5
|
+
*/
|
|
6
|
+
/** Global counter for generating unique IDs */
|
|
7
|
+
/** Internal splitter character (U+001E Record Separator, invisible, used as namespace separator).
|
|
8
|
+
* Uses String.fromCharCode to survive bundlers that strip control-char literals. */
|
|
9
|
+
const SPLITTER = String.fromCharCode(0x1e);
|
|
10
|
+
// ============================================================
|
|
11
|
+
// Encoding helpers (shared by dom.ts, runtime.ts, updater.ts)
|
|
12
|
+
// ============================================================
|
|
13
|
+
const HTML_ENT_MAP = {
|
|
14
|
+
"&": "amp",
|
|
15
|
+
"<": "lt",
|
|
16
|
+
">": "gt",
|
|
17
|
+
'"': "#34",
|
|
18
|
+
"'": "#39",
|
|
19
|
+
"`": "#96",
|
|
43
20
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
21
|
+
const HTML_ENT_REGEXP = /[&<>"'`]/g;
|
|
22
|
+
/** Null-safe String conversion */
|
|
23
|
+
function strSafe$1(v) {
|
|
24
|
+
return String(v == null ? "" : v);
|
|
47
25
|
}
|
|
26
|
+
/** HTML entity encoding for safe output */
|
|
48
27
|
function encodeHTML(v) {
|
|
49
|
-
|
|
50
|
-
HTML_ENT_REGEXP,
|
|
51
|
-
(m) => "&" + HTML_ENT_MAP[m] + ";"
|
|
52
|
-
);
|
|
28
|
+
return String(v == null ? "" : v).replace(HTML_ENT_REGEXP, (m) => "&" + HTML_ENT_MAP[m] + ";");
|
|
53
29
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
30
|
+
const URI_ENT_MAP = {
|
|
31
|
+
"!": "%21",
|
|
32
|
+
"'": "%27",
|
|
33
|
+
"(": "%28",
|
|
34
|
+
")": "%29",
|
|
35
|
+
"*": "%2A",
|
|
60
36
|
};
|
|
61
|
-
|
|
37
|
+
const URI_ENT_REGEXP = /[!')(*]/g;
|
|
38
|
+
/** URI-encode with extra character encoding */
|
|
62
39
|
function encodeURIExtra(v) {
|
|
63
|
-
|
|
64
|
-
URI_ENT_REGEXP,
|
|
65
|
-
(m) => URI_ENT_MAP[m]
|
|
66
|
-
);
|
|
40
|
+
return encodeURIComponent(strSafe$1(v)).replace(URI_ENT_REGEXP, (m) => URI_ENT_MAP[m]);
|
|
67
41
|
}
|
|
68
|
-
|
|
42
|
+
const QUOTE_ENT_REGEXP = /['"\\]/g;
|
|
43
|
+
/** Quote-encode for attribute values */
|
|
69
44
|
function encodeQuote(v) {
|
|
70
|
-
|
|
45
|
+
return strSafe$1(v).replace(QUOTE_ENT_REGEXP, "\\$&");
|
|
71
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Template reference function for creating stable keys for objects.
|
|
49
|
+
* Stores objects in refData with SPLITTER-prefixed keys.
|
|
50
|
+
*/
|
|
72
51
|
function refFn(ref, value, key) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
52
|
+
const counter = ref[SPLITTER];
|
|
53
|
+
for (let i = counter; --i;) {
|
|
54
|
+
key = SPLITTER + i;
|
|
55
|
+
if (ref[key] === value)
|
|
56
|
+
return key;
|
|
57
|
+
}
|
|
58
|
+
key = SPLITTER + ref[SPLITTER]++;
|
|
59
|
+
ref[key] = value;
|
|
60
|
+
return key;
|
|
81
61
|
}
|
|
62
|
+
// export function isCjs(): boolean {
|
|
63
|
+
// return typeof module !== "undefined" && typeof module.exports !== "undefined";
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Template runtime helpers.
|
|
68
|
+
*
|
|
69
|
+
* Compiled templates import these helpers from `@lark.js/mvc/runtime` instead
|
|
70
|
+
* of inlining the implementations. That keeps each compiled `.html` module
|
|
71
|
+
* small — no more ~400 bytes of duplicated helper code per template.
|
|
72
|
+
*
|
|
73
|
+
* The helpers below are aliased to `$strSafe / $encHtml / $encUri / $encQuote /
|
|
74
|
+
* $refFn` inside the IIFE that the compiler produces — see `compiler.ts`.
|
|
75
|
+
*
|
|
76
|
+
* Canonical implementations live in `./common` so that dom.ts, runtime.ts,
|
|
77
|
+
* and updater.ts all share a single copy.
|
|
78
|
+
*/
|
|
79
|
+
/** Null-safe `String(value)` — `null`/`undefined` become `""`. */
|
|
80
|
+
const strSafe = strSafe$1;
|
|
81
|
+
/** HTML-escape a value for safe embedding in markup. */
|
|
82
|
+
const encHtml = encodeHTML;
|
|
83
|
+
/** Percent-encode a value, with extra characters escaped for stricter URIs. */
|
|
84
|
+
const encUri = encodeURIExtra;
|
|
85
|
+
/** Backslash-escape quotes and backslashes for attribute string contents. */
|
|
86
|
+
const encQuote = encodeQuote;
|
|
82
87
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
-
0 && (module.exports = {
|
|
90
|
-
encHtml,
|
|
91
|
-
encQuote,
|
|
92
|
-
encUri,
|
|
93
|
-
refFn,
|
|
94
|
-
strSafe
|
|
95
|
-
});
|
|
88
|
+
exports.encHtml = encHtml;
|
|
89
|
+
exports.encQuote = encQuote;
|
|
90
|
+
exports.encUri = encUri;
|
|
91
|
+
exports.refFn = refFn;
|
|
92
|
+
exports.strSafe = strSafe;
|
package/dist/runtime.js
CHANGED
|
@@ -1,20 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Lark framework constants.
|
|
3
|
+
*/
|
|
4
|
+
/** Global counter for generating unique IDs */
|
|
5
|
+
/** Internal splitter character (U+001E Record Separator, invisible, used as namespace separator).
|
|
6
|
+
* Uses String.fromCharCode to survive bundlers that strip control-char literals. */
|
|
7
|
+
const SPLITTER = String.fromCharCode(0x1e);
|
|
8
|
+
// ============================================================
|
|
9
|
+
// Encoding helpers (shared by dom.ts, runtime.ts, updater.ts)
|
|
10
|
+
// ============================================================
|
|
11
|
+
const HTML_ENT_MAP = {
|
|
12
|
+
"&": "amp",
|
|
13
|
+
"<": "lt",
|
|
14
|
+
">": "gt",
|
|
15
|
+
'"': "#34",
|
|
16
|
+
"'": "#39",
|
|
17
|
+
"`": "#96",
|
|
18
|
+
};
|
|
19
|
+
const HTML_ENT_REGEXP = /[&<>"'`]/g;
|
|
20
|
+
/** Null-safe String conversion */
|
|
21
|
+
function strSafe$1(v) {
|
|
22
|
+
return String(v == null ? "" : v);
|
|
23
|
+
}
|
|
24
|
+
/** HTML entity encoding for safe output */
|
|
25
|
+
function encodeHTML(v) {
|
|
26
|
+
return String(v == null ? "" : v).replace(HTML_ENT_REGEXP, (m) => "&" + HTML_ENT_MAP[m] + ";");
|
|
27
|
+
}
|
|
28
|
+
const URI_ENT_MAP = {
|
|
29
|
+
"!": "%21",
|
|
30
|
+
"'": "%27",
|
|
31
|
+
"(": "%28",
|
|
32
|
+
")": "%29",
|
|
33
|
+
"*": "%2A",
|
|
20
34
|
};
|
|
35
|
+
const URI_ENT_REGEXP = /[!')(*]/g;
|
|
36
|
+
/** URI-encode with extra character encoding */
|
|
37
|
+
function encodeURIExtra(v) {
|
|
38
|
+
return encodeURIComponent(strSafe$1(v)).replace(URI_ENT_REGEXP, (m) => URI_ENT_MAP[m]);
|
|
39
|
+
}
|
|
40
|
+
const QUOTE_ENT_REGEXP = /['"\\]/g;
|
|
41
|
+
/** Quote-encode for attribute values */
|
|
42
|
+
function encodeQuote(v) {
|
|
43
|
+
return strSafe$1(v).replace(QUOTE_ENT_REGEXP, "\\$&");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Template reference function for creating stable keys for objects.
|
|
47
|
+
* Stores objects in refData with SPLITTER-prefixed keys.
|
|
48
|
+
*/
|
|
49
|
+
function refFn(ref, value, key) {
|
|
50
|
+
const counter = ref[SPLITTER];
|
|
51
|
+
for (let i = counter; --i;) {
|
|
52
|
+
key = SPLITTER + i;
|
|
53
|
+
if (ref[key] === value)
|
|
54
|
+
return key;
|
|
55
|
+
}
|
|
56
|
+
key = SPLITTER + ref[SPLITTER]++;
|
|
57
|
+
ref[key] = value;
|
|
58
|
+
return key;
|
|
59
|
+
}
|
|
60
|
+
// export function isCjs(): boolean {
|
|
61
|
+
// return typeof module !== "undefined" && typeof module.exports !== "undefined";
|
|
62
|
+
// }
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Template runtime helpers.
|
|
66
|
+
*
|
|
67
|
+
* Compiled templates import these helpers from `@lark.js/mvc/runtime` instead
|
|
68
|
+
* of inlining the implementations. That keeps each compiled `.html` module
|
|
69
|
+
* small — no more ~400 bytes of duplicated helper code per template.
|
|
70
|
+
*
|
|
71
|
+
* The helpers below are aliased to `$strSafe / $encHtml / $encUri / $encQuote /
|
|
72
|
+
* $refFn` inside the IIFE that the compiler produces — see `compiler.ts`.
|
|
73
|
+
*
|
|
74
|
+
* Canonical implementations live in `./common` so that dom.ts, runtime.ts,
|
|
75
|
+
* and updater.ts all share a single copy.
|
|
76
|
+
*/
|
|
77
|
+
/** Null-safe `String(value)` — `null`/`undefined` become `""`. */
|
|
78
|
+
const strSafe = strSafe$1;
|
|
79
|
+
/** HTML-escape a value for safe embedding in markup. */
|
|
80
|
+
const encHtml = encodeHTML;
|
|
81
|
+
/** Percent-encode a value, with extra characters escaped for stricter URIs. */
|
|
82
|
+
const encUri = encodeURIExtra;
|
|
83
|
+
/** Backslash-escape quotes and backslashes for attribute string contents. */
|
|
84
|
+
const encQuote = encodeQuote;
|
|
85
|
+
|
|
86
|
+
export { encHtml, encQuote, encUri, refFn, strSafe };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LarkMvc = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Lark framework constants.
|
|
9
|
+
*/
|
|
10
|
+
/** Global counter for generating unique IDs */
|
|
11
|
+
/** Internal splitter character (U+001E Record Separator, invisible, used as namespace separator).
|
|
12
|
+
* Uses String.fromCharCode to survive bundlers that strip control-char literals. */
|
|
13
|
+
const SPLITTER = String.fromCharCode(0x1e);
|
|
14
|
+
// ============================================================
|
|
15
|
+
// Encoding helpers (shared by dom.ts, runtime.ts, updater.ts)
|
|
16
|
+
// ============================================================
|
|
17
|
+
const HTML_ENT_MAP = {
|
|
18
|
+
"&": "amp",
|
|
19
|
+
"<": "lt",
|
|
20
|
+
">": "gt",
|
|
21
|
+
'"': "#34",
|
|
22
|
+
"'": "#39",
|
|
23
|
+
"`": "#96",
|
|
24
|
+
};
|
|
25
|
+
const HTML_ENT_REGEXP = /[&<>"'`]/g;
|
|
26
|
+
/** Null-safe String conversion */
|
|
27
|
+
function strSafe$1(v) {
|
|
28
|
+
return String(v == null ? "" : v);
|
|
29
|
+
}
|
|
30
|
+
/** HTML entity encoding for safe output */
|
|
31
|
+
function encodeHTML(v) {
|
|
32
|
+
return String(v == null ? "" : v).replace(HTML_ENT_REGEXP, (m) => "&" + HTML_ENT_MAP[m] + ";");
|
|
33
|
+
}
|
|
34
|
+
const URI_ENT_MAP = {
|
|
35
|
+
"!": "%21",
|
|
36
|
+
"'": "%27",
|
|
37
|
+
"(": "%28",
|
|
38
|
+
")": "%29",
|
|
39
|
+
"*": "%2A",
|
|
40
|
+
};
|
|
41
|
+
const URI_ENT_REGEXP = /[!')(*]/g;
|
|
42
|
+
/** URI-encode with extra character encoding */
|
|
43
|
+
function encodeURIExtra(v) {
|
|
44
|
+
return encodeURIComponent(strSafe$1(v)).replace(URI_ENT_REGEXP, (m) => URI_ENT_MAP[m]);
|
|
45
|
+
}
|
|
46
|
+
const QUOTE_ENT_REGEXP = /['"\\]/g;
|
|
47
|
+
/** Quote-encode for attribute values */
|
|
48
|
+
function encodeQuote(v) {
|
|
49
|
+
return strSafe$1(v).replace(QUOTE_ENT_REGEXP, "\\$&");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Template reference function for creating stable keys for objects.
|
|
53
|
+
* Stores objects in refData with SPLITTER-prefixed keys.
|
|
54
|
+
*/
|
|
55
|
+
function refFn(ref, value, key) {
|
|
56
|
+
const counter = ref[SPLITTER];
|
|
57
|
+
for (let i = counter; --i;) {
|
|
58
|
+
key = SPLITTER + i;
|
|
59
|
+
if (ref[key] === value)
|
|
60
|
+
return key;
|
|
61
|
+
}
|
|
62
|
+
key = SPLITTER + ref[SPLITTER]++;
|
|
63
|
+
ref[key] = value;
|
|
64
|
+
return key;
|
|
65
|
+
}
|
|
66
|
+
// export function isCjs(): boolean {
|
|
67
|
+
// return typeof module !== "undefined" && typeof module.exports !== "undefined";
|
|
68
|
+
// }
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Template runtime helpers.
|
|
72
|
+
*
|
|
73
|
+
* Compiled templates import these helpers from `@lark.js/mvc/runtime` instead
|
|
74
|
+
* of inlining the implementations. That keeps each compiled `.html` module
|
|
75
|
+
* small — no more ~400 bytes of duplicated helper code per template.
|
|
76
|
+
*
|
|
77
|
+
* The helpers below are aliased to `$strSafe / $encHtml / $encUri / $encQuote /
|
|
78
|
+
* $refFn` inside the IIFE that the compiler produces — see `compiler.ts`.
|
|
79
|
+
*
|
|
80
|
+
* Canonical implementations live in `./common` so that dom.ts, runtime.ts,
|
|
81
|
+
* and updater.ts all share a single copy.
|
|
82
|
+
*/
|
|
83
|
+
/** Null-safe `String(value)` — `null`/`undefined` become `""`. */
|
|
84
|
+
const strSafe = strSafe$1;
|
|
85
|
+
/** HTML-escape a value for safe embedding in markup. */
|
|
86
|
+
const encHtml = encodeHTML;
|
|
87
|
+
/** Percent-encode a value, with extra characters escaped for stricter URIs. */
|
|
88
|
+
const encUri = encodeURIExtra;
|
|
89
|
+
/** Backslash-escape quotes and backslashes for attribute string contents. */
|
|
90
|
+
const encQuote = encodeQuote;
|
|
91
|
+
|
|
92
|
+
exports.encHtml = encHtml;
|
|
93
|
+
exports.encQuote = encQuote;
|
|
94
|
+
exports.encUri = encUri;
|
|
95
|
+
exports.refFn = refFn;
|
|
96
|
+
exports.strSafe = strSafe;
|
|
97
|
+
|
|
98
|
+
}));
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Cache } from "./cache";
|
|
2
|
+
import { EventEmitter } from "./event-emitter";
|
|
3
|
+
import type { AnyFunc, ServiceMetaEntry, ServiceCacheInfo, PendingCacheEntry, PayloadInterface, EventEmitterInterface } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Payload wraps API response data with convenient access methods.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Payload implements PayloadInterface {
|
|
8
|
+
/** Payload data */
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
/** Internal cache info */
|
|
11
|
+
cacheInfo?: ServiceCacheInfo;
|
|
12
|
+
constructor(data?: Record<string, unknown>);
|
|
13
|
+
/** Get a value from payload data */
|
|
14
|
+
get<T = unknown>(key: string): T;
|
|
15
|
+
/** Set a value in payload data */
|
|
16
|
+
set(keyOrData: string | Record<string, unknown> | ServiceMetaEntry, value?: unknown): PayloadInterface;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Minimal interface describing what serviceSend actually uses
|
|
20
|
+
* from a service instance. This avoids coupling to the full
|
|
21
|
+
* ServiceInterface which mixes instance and static methods.
|
|
22
|
+
*/
|
|
23
|
+
interface ServiceSendTarget {
|
|
24
|
+
destroyed: number;
|
|
25
|
+
busy: number;
|
|
26
|
+
internals: {
|
|
27
|
+
metaList: Record<string, ServiceMetaEntry>;
|
|
28
|
+
payloadCache: Cache<Payload>;
|
|
29
|
+
pendingCacheKeys: Record<string, PendingCacheEntry>;
|
|
30
|
+
syncFn: (payload: Payload, callback: () => void) => void;
|
|
31
|
+
staticEmitter: EventEmitter;
|
|
32
|
+
};
|
|
33
|
+
type: {
|
|
34
|
+
get(attrs: Record<string, unknown>, createNew?: boolean): {
|
|
35
|
+
entity: Payload;
|
|
36
|
+
needsUpdate: boolean;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
enqueue(callback: AnyFunc): unknown;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Service: API request management with caching, deduplication, and queue.
|
|
43
|
+
*
|
|
44
|
+
* - Service.extend(syncFn, cacheMax?, cacheBuffer?): creates subclass with sync function
|
|
45
|
+
* - Service.add(attrs): registers API endpoint metadata
|
|
46
|
+
* - new Service().all(attrs, done): fetch all, use cache when available
|
|
47
|
+
* - new Service().one(attrs, done): fetch all, callback on each completion
|
|
48
|
+
* - new Service().save(attrs, done): fetch all, skip cache (always request)
|
|
49
|
+
* - enqueue/dequeue: task queue for sequential async operations
|
|
50
|
+
* - destroy: cancel pending requests
|
|
51
|
+
*
|
|
52
|
+
* Per-type state (metaList, payloadCache, pendingCacheKeys, syncFn, staticEmitter)
|
|
53
|
+
* is stored as static class properties. When extend() creates a subclass,
|
|
54
|
+
* each subclass gets its own copies of these static properties, ensuring
|
|
55
|
+
* isolation between different Service types.
|
|
56
|
+
*/
|
|
57
|
+
export declare class Service {
|
|
58
|
+
/** Service instance ID */
|
|
59
|
+
id: string;
|
|
60
|
+
/** Whether service is busy (1 = busy) */
|
|
61
|
+
busy: number;
|
|
62
|
+
/** Whether service is destroyed (1 = destroyed) */
|
|
63
|
+
destroyed: number;
|
|
64
|
+
/** Task queue for sequential operations */
|
|
65
|
+
taskQueue: AnyFunc[];
|
|
66
|
+
/** Previous dequeue arguments */
|
|
67
|
+
prevArgs: unknown[];
|
|
68
|
+
/** Instance event emitter */
|
|
69
|
+
private _emitter;
|
|
70
|
+
constructor();
|
|
71
|
+
/** Instance event emitter (public accessor) */
|
|
72
|
+
get emitter(): EventEmitterInterface;
|
|
73
|
+
/**
|
|
74
|
+
* Get internals object for serviceSend compatibility.
|
|
75
|
+
* References per-type static state from the current class.
|
|
76
|
+
*/
|
|
77
|
+
get internals(): ServiceSendTarget["internals"];
|
|
78
|
+
/**
|
|
79
|
+
* Get type reference (the constructor) for serviceSend compatibility.
|
|
80
|
+
* Static methods like get/create are accessible via the constructor.
|
|
81
|
+
*/
|
|
82
|
+
get type(): ServiceSendTarget["type"];
|
|
83
|
+
/**
|
|
84
|
+
* Fetch all endpoints, callback when all complete.
|
|
85
|
+
* Uses cache when available.
|
|
86
|
+
*/
|
|
87
|
+
all(attrs: string | Record<string, unknown> | (string | Record<string, unknown>)[], done: AnyFunc): this;
|
|
88
|
+
/**
|
|
89
|
+
* Fetch all endpoints, callback on each completion.
|
|
90
|
+
*/
|
|
91
|
+
one(attrs: string | Record<string, unknown> | (string | Record<string, unknown>)[], done: AnyFunc): this;
|
|
92
|
+
/**
|
|
93
|
+
* Fetch all endpoints, skip cache (always request).
|
|
94
|
+
*/
|
|
95
|
+
save(attrs: string | Record<string, unknown> | (string | Record<string, unknown>)[], done: AnyFunc): this;
|
|
96
|
+
/**
|
|
97
|
+
* Enqueue a task for sequential execution.
|
|
98
|
+
*/
|
|
99
|
+
enqueue(callback: AnyFunc): this;
|
|
100
|
+
/**
|
|
101
|
+
* Dequeue and execute the next task in queue.
|
|
102
|
+
*/
|
|
103
|
+
dequeue(...args: unknown[]): void;
|
|
104
|
+
/**
|
|
105
|
+
* Destroy the service instance.
|
|
106
|
+
* After destruction, no new requests can be sent.
|
|
107
|
+
*/
|
|
108
|
+
destroy(): void;
|
|
109
|
+
on(event: string, handler: AnyFunc): this;
|
|
110
|
+
off(event: string, handler?: AnyFunc): this;
|
|
111
|
+
fire(event: string, data?: Record<string, unknown>): this;
|
|
112
|
+
/** Per-type metadata registry */
|
|
113
|
+
static _metaList: Record<string, ServiceMetaEntry>;
|
|
114
|
+
/** Per-type payload cache (LFU with frequency eviction) */
|
|
115
|
+
static _payloadCache: Cache<Payload>;
|
|
116
|
+
/** Per-type pending cache keys for deduplication */
|
|
117
|
+
static _pendingCacheKeys: Record<string, PendingCacheEntry>;
|
|
118
|
+
/** Per-type sync function */
|
|
119
|
+
static _syncFn: (payload: Payload, callback: () => void) => void;
|
|
120
|
+
/** Per-type static event emitter */
|
|
121
|
+
static _staticEmitter: EventEmitter<unknown>;
|
|
122
|
+
/** Per-type cache max size */
|
|
123
|
+
static _cacheMax: number;
|
|
124
|
+
/** Per-type cache buffer size */
|
|
125
|
+
static _cacheBuffer: number;
|
|
126
|
+
/**
|
|
127
|
+
* Register API endpoint metadata.
|
|
128
|
+
*/
|
|
129
|
+
static add(attrs: ServiceMetaEntry | ServiceMetaEntry[]): void;
|
|
130
|
+
/**
|
|
131
|
+
* Get metadata for an API endpoint.
|
|
132
|
+
*/
|
|
133
|
+
static meta(attrs: string | Record<string, unknown>): ServiceMetaEntry;
|
|
134
|
+
/**
|
|
135
|
+
* Create a Payload for an API request.
|
|
136
|
+
*/
|
|
137
|
+
static create(attrs: Record<string, unknown>): Payload;
|
|
138
|
+
/**
|
|
139
|
+
* Get or create a Payload for an API request.
|
|
140
|
+
*/
|
|
141
|
+
static get(attrs: Record<string, unknown>, createNew?: boolean): {
|
|
142
|
+
entity: Payload;
|
|
143
|
+
needsUpdate: boolean;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Get cached Payload if available and not expired.
|
|
147
|
+
*/
|
|
148
|
+
static cached(attrs: Record<string, unknown>): Payload | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Clear cached payloads by endpoint name.
|
|
151
|
+
*/
|
|
152
|
+
static clear(names: string | string[]): void;
|
|
153
|
+
static on(event: string, handler: AnyFunc): void;
|
|
154
|
+
static off(event: string, handler?: AnyFunc): void;
|
|
155
|
+
static fire(event: string, data?: Record<string, unknown>): void;
|
|
156
|
+
/**
|
|
157
|
+
* Create a new Service subclass with a custom sync function.
|
|
158
|
+
*
|
|
159
|
+
* Each subclass gets its OWN copies of every per-type static field
|
|
160
|
+
* (`_metaList`, `_payloadCache`, `_pendingCacheKeys`, `_syncFn`,
|
|
161
|
+
* `_staticEmitter`, `_cacheMax`, `_cacheBuffer`) via `static override`.
|
|
162
|
+
* This is intentional: it ensures that endpoint metadata, cache state,
|
|
163
|
+
* in-flight dedup keys, and event subscribers are fully isolated between
|
|
164
|
+
* different Service types, even when one extends another.
|
|
165
|
+
*
|
|
166
|
+
* **Do not refactor these `static override` declarations away** — sharing
|
|
167
|
+
* them through prototype inheritance would let endpoints registered on one
|
|
168
|
+
* subclass leak into another, and the LFU cache evictions of one type
|
|
169
|
+
* would race with those of another.
|
|
170
|
+
*/
|
|
171
|
+
static extend(this: typeof Service, newSyncFn: (payload: Payload, callback: () => void) => void, newCacheMax?: number, newCacheBuffer?: number): typeof Service;
|
|
172
|
+
}
|
|
173
|
+
export {};
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StateInterface } from "./types";
|
|
2
|
+
/** Mark framework as booted (called from Framework.boot) */
|
|
3
|
+
export declare function markBooted(): void;
|
|
4
|
+
/**
|
|
5
|
+
* Observable in-memory data object.
|
|
6
|
+
* Provides get/set/digest/diff/clean methods for cross-view data sharing.
|
|
7
|
+
*/
|
|
8
|
+
export declare const State: StateInterface;
|