@lark.js/mvc 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/runtime.cjs CHANGED
@@ -24,9 +24,15 @@ __export(runtime_exports, {
24
24
  encQuote: () => encQuote,
25
25
  encUri: () => encUri,
26
26
  refFn: () => refFn,
27
- strSafe: () => strSafe
27
+ strSafe: () => strSafe2
28
28
  });
29
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
+ );
30
36
  var HTML_ENT_MAP = {
31
37
  "&": "amp",
32
38
  "<": "lt",
@@ -35,9 +41,16 @@ var HTML_ENT_MAP = {
35
41
  "'": "#39",
36
42
  "`": "#96"
37
43
  };
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] + ";");
44
+ var HTML_ENT_REGEXP = /[&<>"'`]/g;
45
+ function strSafe(v) {
46
+ return String(v == null ? "" : v);
47
+ }
48
+ function encodeHTML(v) {
49
+ return String(v == null ? "" : v).replace(
50
+ HTML_ENT_REGEXP,
51
+ (m) => "&" + HTML_ENT_MAP[m] + ";"
52
+ );
53
+ }
41
54
  var URI_ENT_MAP = {
42
55
  "!": "%21",
43
56
  "'": "%27",
@@ -46,11 +59,17 @@ var URI_ENT_MAP = {
46
59
  "*": "%2A"
47
60
  };
48
61
  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 = String.fromCharCode(30);
62
+ function encodeURIExtra(v) {
63
+ return encodeURIComponent(strSafe(v)).replace(
64
+ URI_ENT_REGEXP,
65
+ (m) => URI_ENT_MAP[m]
66
+ );
67
+ }
68
+ var QUOTE_ENT_REGEXP = /['"\\]/g;
69
+ function encodeQuote(v) {
70
+ return strSafe(v).replace(QUOTE_ENT_REGEXP, "\\$&");
71
+ }
72
+ function refFn(ref, value, key) {
54
73
  const counter = ref[SPLITTER];
55
74
  for (let i = counter; --i; ) {
56
75
  key = SPLITTER + i;
@@ -59,7 +78,13 @@ var refFn = (ref, value, key) => {
59
78
  key = SPLITTER + ref[SPLITTER]++;
60
79
  ref[key] = value;
61
80
  return key;
62
- };
81
+ }
82
+
83
+ // src/runtime.ts
84
+ var strSafe2 = strSafe;
85
+ var encHtml = encodeHTML;
86
+ var encUri = encodeURIExtra;
87
+ var encQuote = encodeQuote;
63
88
  // Annotate the CommonJS export names for ESM import in node:
64
89
  0 && (module.exports = {
65
90
  encHtml,
@@ -1,3 +1,17 @@
1
+ /** Null-safe String conversion */
2
+ declare function strSafe$1(v: unknown): string;
3
+ /** HTML entity encoding for safe output */
4
+ declare function encodeHTML(v: unknown): string;
5
+ /** URI-encode with extra character encoding */
6
+ declare function encodeURIExtra(v: unknown): string;
7
+ /** Quote-encode for attribute values */
8
+ declare function encodeQuote(v: unknown): string;
9
+ /**
10
+ * Template reference function for creating stable keys for objects.
11
+ * Stores objects in refData with SPLITTER-prefixed keys.
12
+ */
13
+ declare function refFn(ref: Record<string, unknown>, value: unknown, key: string): string;
14
+
1
15
  /**
2
16
  * Template runtime helpers.
3
17
  *
@@ -7,23 +21,18 @@
7
21
  *
8
22
  * The helpers below are aliased to `$strSafe / $encHtml / $encUri / $encQuote /
9
23
  * $refFn` inside the IIFE that the compiler produces — see `compiler.ts`.
24
+ *
25
+ * Canonical implementations live in `./common` so that dom.ts, runtime.ts,
26
+ * and updater.ts all share a single copy.
10
27
  */
28
+
11
29
  /** Null-safe `String(value)` — `null`/`undefined` become `""`. */
12
- declare const strSafe: (v: unknown) => string;
30
+ declare const strSafe: typeof strSafe$1;
13
31
  /** HTML-escape a value for safe embedding in markup. */
14
- declare const encHtml: (v: unknown) => string;
32
+ declare const encHtml: typeof encodeHTML;
15
33
  /** Percent-encode a value, with extra characters escaped for stricter URIs. */
16
- declare const encUri: (v: unknown) => string;
34
+ declare const encUri: typeof encodeURIExtra;
17
35
  /** 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;
36
+ declare const encQuote: typeof encodeQuote;
28
37
 
29
38
  export { encHtml, encQuote, encUri, refFn, strSafe };
package/dist/runtime.d.ts CHANGED
@@ -1,3 +1,17 @@
1
+ /** Null-safe String conversion */
2
+ declare function strSafe$1(v: unknown): string;
3
+ /** HTML entity encoding for safe output */
4
+ declare function encodeHTML(v: unknown): string;
5
+ /** URI-encode with extra character encoding */
6
+ declare function encodeURIExtra(v: unknown): string;
7
+ /** Quote-encode for attribute values */
8
+ declare function encodeQuote(v: unknown): string;
9
+ /**
10
+ * Template reference function for creating stable keys for objects.
11
+ * Stores objects in refData with SPLITTER-prefixed keys.
12
+ */
13
+ declare function refFn(ref: Record<string, unknown>, value: unknown, key: string): string;
14
+
1
15
  /**
2
16
  * Template runtime helpers.
3
17
  *
@@ -7,23 +21,18 @@
7
21
  *
8
22
  * The helpers below are aliased to `$strSafe / $encHtml / $encUri / $encQuote /
9
23
  * $refFn` inside the IIFE that the compiler produces — see `compiler.ts`.
24
+ *
25
+ * Canonical implementations live in `./common` so that dom.ts, runtime.ts,
26
+ * and updater.ts all share a single copy.
10
27
  */
28
+
11
29
  /** Null-safe `String(value)` — `null`/`undefined` become `""`. */
12
- declare const strSafe: (v: unknown) => string;
30
+ declare const strSafe: typeof strSafe$1;
13
31
  /** HTML-escape a value for safe embedding in markup. */
14
- declare const encHtml: (v: unknown) => string;
32
+ declare const encHtml: typeof encodeHTML;
15
33
  /** Percent-encode a value, with extra characters escaped for stricter URIs. */
16
- declare const encUri: (v: unknown) => string;
34
+ declare const encUri: typeof encodeURIExtra;
17
35
  /** 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;
36
+ declare const encQuote: typeof encodeQuote;
28
37
 
29
38
  export { encHtml, encQuote, encUri, refFn, strSafe };
package/dist/runtime.js CHANGED
@@ -1,41 +1,20 @@
1
+ import {
2
+ encodeHTML,
3
+ encodeQuote,
4
+ encodeURIExtra,
5
+ refFn,
6
+ strSafe
7
+ } from "./chunk-RIV4NK3K.js";
8
+
1
9
  // 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 = String.fromCharCode(30);
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
- };
10
+ var strSafe2 = strSafe;
11
+ var encHtml = encodeHTML;
12
+ var encUri = encodeURIExtra;
13
+ var encQuote = encodeQuote;
35
14
  export {
36
15
  encHtml,
37
16
  encQuote,
38
17
  encUri,
39
18
  refFn,
40
- strSafe
19
+ strSafe2 as strSafe
41
20
  };