@lark.js/mvc 0.0.14 → 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.
Files changed (59) hide show
  1. package/README.md +4 -4
  2. package/dist/apply-style.d.ts +9 -0
  3. package/dist/cache.d.ts +69 -0
  4. package/dist/client.d.ts +87 -0
  5. package/dist/common.d.ts +64 -0
  6. package/dist/compiler/compile-template.d.ts +16 -0
  7. package/dist/compiler/compile-to-vdom-function.d.ts +13 -0
  8. package/dist/compiler/extract-global-vars.d.ts +17 -0
  9. package/dist/compiler/template-syntax.d.ts +61 -0
  10. package/dist/compiler.cjs +15847 -15482
  11. package/dist/compiler.js +15844 -15467
  12. package/dist/cross-site.d.ts +29 -0
  13. package/dist/devtool.cjs +4138 -3183
  14. package/dist/devtool.d.cts +2 -1
  15. package/dist/devtool.d.ts +2 -1
  16. package/dist/devtool.js +4164 -3125
  17. package/dist/dom.d.ts +45 -0
  18. package/dist/event-delegator.d.ts +28 -0
  19. package/dist/event-emitter.d.ts +38 -0
  20. package/dist/frame.d.ts +143 -0
  21. package/dist/framework.d.ts +9 -0
  22. package/dist/hmr.d.ts +53 -0
  23. package/dist/index.amd.js +6285 -0
  24. package/dist/index.cjs +5959 -4489
  25. package/dist/index.d.cts +9 -8
  26. package/dist/index.d.ts +9 -8
  27. package/dist/index.js +5920 -4425
  28. package/dist/index.umd.js +6272 -0
  29. package/dist/mark.d.ts +26 -0
  30. package/dist/module-loader.d.ts +20 -0
  31. package/dist/router.d.ts +14 -0
  32. package/dist/rspack.cjs +15931 -15553
  33. package/dist/rspack.d.cts +42 -5
  34. package/dist/rspack.d.ts +42 -5
  35. package/dist/rspack.js +15930 -15546
  36. package/dist/runtime.amd.js +94 -0
  37. package/dist/runtime.cjs +79 -82
  38. package/dist/runtime.js +85 -19
  39. package/dist/runtime.umd.js +98 -0
  40. package/dist/service.d.ts +173 -0
  41. package/dist/state.d.ts +8 -0
  42. package/dist/store.d.ts +60 -0
  43. package/dist/types.d.ts +1259 -0
  44. package/dist/updater.d.ts +90 -0
  45. package/dist/url-state.d.ts +32 -0
  46. package/dist/utils.d.ts +90 -0
  47. package/dist/vdom.d.ts +45 -0
  48. package/dist/view-registry.d.ts +20 -0
  49. package/dist/view.d.ts +214 -0
  50. package/dist/vite.cjs +15944 -15582
  51. package/dist/vite.d.cts +2 -1
  52. package/dist/vite.d.ts +2 -1
  53. package/dist/vite.js +15941 -15574
  54. package/dist/webpack.cjs +15981 -15553
  55. package/dist/webpack.d.cts +32 -4
  56. package/dist/webpack.d.ts +32 -4
  57. package/dist/webpack.js +15980 -15546
  58. package/package.json +2 -2
  59. package/dist/chunk-66OZBBSP.js +0 -108
@@ -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
- "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);
1
+ 'use strict';
19
2
 
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: () => strSafe2
28
- });
29
- module.exports = __toCommonJS(runtime_exports);
30
-
31
- // src/common.ts
32
- var SPLITTER = String.fromCharCode(30);
33
- var EVENT_METHOD_REGEXP = new RegExp(
34
- `(?:([\\w-]+)${SPLITTER})?([^(]+)\\(([\\s\\S]*?)?\\)`
35
- );
36
- var HTML_ENT_MAP = {
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
- var HTML_ENT_REGEXP = /[&<>"'`]/g;
45
- function strSafe(v) {
46
- return String(v == null ? "" : v);
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
- return String(v == null ? "" : v).replace(
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
- var URI_ENT_MAP = {
55
- "!": "%21",
56
- "'": "%27",
57
- "(": "%28",
58
- ")": "%29",
59
- "*": "%2A"
30
+ const URI_ENT_MAP = {
31
+ "!": "%21",
32
+ "'": "%27",
33
+ "(": "%28",
34
+ ")": "%29",
35
+ "*": "%2A",
60
36
  };
61
- var URI_ENT_REGEXP = /[!')(*]/g;
37
+ const URI_ENT_REGEXP = /[!')(*]/g;
38
+ /** URI-encode with extra character encoding */
62
39
  function encodeURIExtra(v) {
63
- return encodeURIComponent(strSafe(v)).replace(
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
- var QUOTE_ENT_REGEXP = /['"\\]/g;
42
+ const QUOTE_ENT_REGEXP = /['"\\]/g;
43
+ /** Quote-encode for attribute values */
69
44
  function encodeQuote(v) {
70
- return strSafe(v).replace(QUOTE_ENT_REGEXP, "\\$&");
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
- const counter = ref[SPLITTER];
74
- for (let i = counter; --i; ) {
75
- key = SPLITTER + i;
76
- if (ref[key] === value) return key;
77
- }
78
- key = SPLITTER + ref[SPLITTER]++;
79
- ref[key] = value;
80
- return 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;
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
- // src/runtime.ts
84
- var strSafe2 = strSafe;
85
- var encHtml = encodeHTML;
86
- var encUri = encodeURIExtra;
87
- var encQuote = encodeQuote;
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
- import {
2
- encodeHTML,
3
- encodeQuote,
4
- encodeURIExtra,
5
- refFn,
6
- strSafe
7
- } from "./chunk-66OZBBSP.js";
8
-
9
- // src/runtime.ts
10
- var strSafe2 = strSafe;
11
- var encHtml = encodeHTML;
12
- var encUri = encodeURIExtra;
13
- var encQuote = encodeQuote;
14
- export {
15
- encHtml,
16
- encQuote,
17
- encUri,
18
- refFn,
19
- strSafe2 as strSafe
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 {};
@@ -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;