@jasonshimmy/custom-elements-runtime 1.1.1 → 1.2.0

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/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { useEmit, useOnConnected, useOnDisconnected, useOnAttributeChanged, useO
9
9
  export { ref, computed, watch } from "./runtime/reactive";
10
10
  export { html } from "./runtime/template-compiler";
11
11
  export { css } from "./runtime/style";
12
+ export { unsafeHTML, decodeEntities } from "./runtime/helpers";
12
13
  export { renderToString } from "./runtime/vdom";
13
14
  export type { VNode } from "./runtime/types";
14
15
  export * from "./directives";
@@ -23,6 +23,54 @@ export declare function getStringCacheStats(): {
23
23
  htmlEscapeCacheSize: number;
24
24
  };
25
25
  export declare function escapeHTML(str: string | number | boolean): string | number | boolean;
26
+ /**
27
+ * Decode HTML entities (named and numeric) into their character equivalents.
28
+ * - In browser: uses a DOM-based technique to decode entities while preserving
29
+ * existing raw tags.
30
+ * - In non-DOM (SSR) environments: handles numeric references and a conservative
31
+ * named-entity map for common entities.
32
+ *
33
+ * @param str - string containing HTML entities
34
+ * @returns decoded string
35
+ */
36
+ export declare function decodeEntities(str: string): string;
37
+ /**
38
+ * Dynamically load the full named-entity map (used in SSR). Exported for testing and
39
+ * to allow bundlers to exclude the JSON from client bundles when dynamic import
40
+ * is used behind a DOM check.
41
+ */
42
+ export declare function loadEntityMap(): Promise<Record<string, string>>;
43
+ /**
44
+ * Register a full named-entity map for SSR. Intended for server startup code to
45
+ * provide the authoritative HTML5 entity mapping. This keeps the client bundle
46
+ * small because the map is only injected on the server side.
47
+ *
48
+ * registerEntityMap should be called once at server startup prior to rendering.
49
+ */
50
+ export declare function registerEntityMap(map: Record<string, string>, options?: {
51
+ overwrite?: boolean;
52
+ }): void;
53
+ /**
54
+ * Clear any registered entity map. Useful for tests or restarting state.
55
+ */
56
+ export declare function clearRegisteredEntityMap(): void;
57
+ /**
58
+ * Wrap a string as raw HTML. This is intentionally unsafe — callers must
59
+ * sanitize untrusted input before using this. The returned object provides
60
+ * two property names to be compatible with different parts of the runtime.
61
+ */
62
+ export declare function unsafeHTML(html: string): {
63
+ __unsafeHTML: string;
64
+ __rawHTML: string;
65
+ };
66
+ /** Type-guard for unsafeHTML wrapper */
67
+ export declare function isUnsafeHTML(value: unknown): value is {
68
+ __unsafeHTML?: string;
69
+ __rawHTML?: string;
70
+ };
71
+ /**
72
+ * Get nested property value from object using dot notation
73
+ */
26
74
  export declare function getNestedValue(obj: any, path: string): any;
27
75
  /**
28
76
  * Set nested property value in object using dot notation
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Retrieve the stored node key for a Node.
3
+ *
4
+ * The lookup prefers a WeakMap-stored value. For compatibility it will also
5
+ * attempt to read legacy fallbacks: a `.key` property or the
6
+ * `data-anchor-key` attribute on Elements.
7
+ *
8
+ * @internal
9
+ */
10
+ export declare function getNodeKey(node: Node | null | undefined): string | undefined;
11
+ /**
12
+ * Store a node key on a Node.
13
+ *
14
+ * This sets a WeakMap entry and also writes defensive DOM fallbacks for
15
+ * compatibility with older consumers/tests. Errors are swallowed to avoid
16
+ * disrupting host environments that forbid property writes.
17
+ *
18
+ * @internal
19
+ */
20
+ export declare function setNodeKey(node: Node, key: string): void;
21
+ /**
22
+ * Retrieve transition-group metadata attached to an element.
23
+ *
24
+ * Prefers the WeakMap but falls back to a legacy `._transitionGroup` property
25
+ * if present.
26
+ *
27
+ * @internal
28
+ */
29
+ export declare function getElementTransition(el: HTMLElement | null | undefined): any;
30
+ /**
31
+ * Store transition-group metadata for an element.
32
+ *
33
+ * Writes to the WeakMap and a defensive legacy property for compatibility.
34
+ * Errors are swallowed to avoid breaking host environments.
35
+ *
36
+ * @internal
37
+ */
38
+ export declare function setElementTransition(el: HTMLElement, val: any): void;
39
+ declare const _default: {
40
+ getNodeKey: typeof getNodeKey;
41
+ setNodeKey: typeof setNodeKey;
42
+ getElementTransition: typeof getElementTransition;
43
+ setElementTransition: typeof setElementTransition;
44
+ };
45
+ export default _default;
@@ -25,6 +25,7 @@ export declare const containerVariants: MediaVariantMap;
25
25
  export declare const responsiveOrder: string[];
26
26
  export declare const containerOrder: string[];
27
27
  export declare function parseSpacing(className: string): string | null;
28
+ export declare function parseSpaceUtility(className: string): string | null;
28
29
  export declare function hexToRgb(hex: string): string;
29
30
  export declare function parseColorClass(className: string): string | null;
30
31
  export declare function parseOpacityModifier(className: string): {
@@ -75,6 +75,10 @@ export interface TransitionGroupOptions extends Omit<TransitionOptions, 'show'>
75
75
  moveClass?: string;
76
76
  /** Whether to show the group (defaults to true for TransitionGroup) */
77
77
  show?: boolean;
78
+ /** CSS classes to apply to the wrapper element (e.g., 'flex gap-4' or 'grid grid-cols-3') */
79
+ class?: string;
80
+ /** Inline styles to apply to the wrapper element */
81
+ style?: string | Record<string, string>;
78
82
  }
79
83
  /**
80
84
  * Pre-defined transition presets using JIT CSS classes
@@ -206,6 +210,7 @@ export declare function Transition(options: TransitionOptions, content: VNode |
206
210
  *
207
211
  * @example
208
212
  * ```ts
213
+ * // Basic usage
209
214
  * ${TransitionGroup({
210
215
  * preset: 'slide-right',
211
216
  * tag: 'ul',
@@ -213,6 +218,22 @@ export declare function Transition(options: TransitionOptions, content: VNode |
213
218
  * }, each(items.value, (item) => html`
214
219
  * <li key="${item.id}">${item.text}</li>
215
220
  * `))}
221
+ *
222
+ * // With flex layout
223
+ * ${TransitionGroup({
224
+ * preset: 'fade',
225
+ * class: 'flex gap-4 flex-wrap'
226
+ * }, each(items.value, (item) => html`
227
+ * <div key="${item.id}" class="flex-shrink-0">${item.text}</div>
228
+ * `))}
229
+ *
230
+ * // With grid layout
231
+ * ${TransitionGroup({
232
+ * preset: 'scale',
233
+ * class: 'grid grid-cols-3 gap-4'
234
+ * }, each(items.value, (item) => html`
235
+ * <div key="${item.id}">${item.text}</div>
236
+ * `))}
216
237
  * ```
217
238
  */
218
239
  export declare function TransitionGroup(options: TransitionGroupOptions, children: VNode[]): VNode;
package/entities.json ADDED
@@ -0,0 +1,211 @@
1
+ {
2
+ "lt": "<",
3
+ "gt": ">",
4
+ "amp": "&",
5
+ "quot": "\"",
6
+ "apos": "'",
7
+ "nbsp": "\u00A0",
8
+
9
+ "iexcl": "¡",
10
+ "cent": "¢",
11
+ "pound": "£",
12
+ "curren": "¤",
13
+ "yen": "¥",
14
+ "brvbar": "¦",
15
+ "sect": "§",
16
+ "uml": "¨",
17
+ "copy": "©",
18
+ "ordf": "ª",
19
+ "laquo": "«",
20
+ "not": "¬",
21
+ "shy": "\u00AD",
22
+ "reg": "®",
23
+ "macr": "¯",
24
+ "deg": "°",
25
+ "plusmn": "±",
26
+ "sup2": "²",
27
+ "sup3": "³",
28
+ "acute": "´",
29
+ "micro": "µ",
30
+ "para": "¶",
31
+ "middot": "·",
32
+ "cedil": "¸",
33
+ "sup1": "¹",
34
+ "ordm": "º",
35
+ "raquo": "»",
36
+ "frac14": "¼",
37
+ "frac12": "½",
38
+ "frac34": "¾",
39
+ "iquest": "¿",
40
+
41
+ "Agrave": "À",
42
+ "Aacute": "Á",
43
+ "Acirc": "Â",
44
+ "Atilde": "Ã",
45
+ "Auml": "Ä",
46
+ "Aring": "Å",
47
+ "AElig": "Æ",
48
+ "Ccedil": "Ç",
49
+ "Egrave": "È",
50
+ "Eacute": "É",
51
+ "Ecirc": "Ê",
52
+ "Euml": "Ë",
53
+ "Igrave": "Ì",
54
+ "Iacute": "Í",
55
+ "Icirc": "Î",
56
+ "Iuml": "Ï",
57
+ "ETH": "Ð",
58
+ "Ntilde": "Ñ",
59
+ "Ograve": "Ò",
60
+ "Oacute": "Ó",
61
+ "Ocirc": "Ô",
62
+ "Otilde": "Õ",
63
+ "Ouml": "Ö",
64
+ "times": "×",
65
+ "Oslash": "Ø",
66
+ "Ugrave": "Ù",
67
+ "Uacute": "Ú",
68
+ "Ucirc": "Û",
69
+ "Uuml": "Ü",
70
+ "Yacute": "Ý",
71
+ "THORN": "Þ",
72
+ "szlig": "ß",
73
+ "agrave": "à",
74
+ "aacute": "á",
75
+ "acirc": "â",
76
+ "atilde": "ã",
77
+ "auml": "ä",
78
+ "aring": "å",
79
+ "aelig": "æ",
80
+ "ccedil": "ç",
81
+ "egrave": "è",
82
+ "eacute": "é",
83
+ "ecirc": "ê",
84
+ "euml": "ë",
85
+ "igrave": "ì",
86
+ "iacute": "í",
87
+ "icirc": "î",
88
+ "iuml": "ï",
89
+ "eth": "ð",
90
+ "ntilde": "ñ",
91
+ "ograve": "ò",
92
+ "oacute": "ó",
93
+ "ocirc": "ô",
94
+ "otilde": "õ",
95
+ "ouml": "ö",
96
+ "divide": "÷",
97
+ "oslash": "ø",
98
+ "ugrave": "ù",
99
+ "uacute": "ú",
100
+ "ucirc": "û",
101
+ "uuml": "ü",
102
+ "yacute": "ý",
103
+ "thorn": "þ",
104
+ "yuml": "ÿ",
105
+
106
+ "euro": "€",
107
+ "trade": "™",
108
+ "mdash": "—",
109
+ "ndash": "–",
110
+ "hellip": "…",
111
+ "bull": "•",
112
+ "prime": "′",
113
+ "Prime": "″",
114
+ "permil": "‰",
115
+ "dagger": "†",
116
+ "Dagger": "‡",
117
+ "cedilla": "¸",
118
+ "oelig": "œ",
119
+ "scaron": "š",
120
+ "Yuml": "Ÿ",
121
+
122
+ "lsquo": "‘",
123
+ "rsquo": "’",
124
+ "ldquo": "“",
125
+ "rdquo": "”",
126
+
127
+ "sterling": "£",
128
+
129
+ "pi": "π",
130
+ "Pi": "Π",
131
+ "alpha": "α",
132
+ "beta": "β",
133
+ "gamma": "γ",
134
+ "Gamma": "Γ",
135
+ "delta": "δ",
136
+ "Delta": "Δ",
137
+ "epsilon": "ϵ",
138
+ "epsiv": "ε",
139
+ "zeta": "ζ",
140
+ "eta": "η",
141
+ "theta": "θ",
142
+ "Theta": "Θ",
143
+ "iota": "ι",
144
+ "kappa": "κ",
145
+ "lambda": "λ",
146
+ "Lambda": "Λ",
147
+ "mu": "μ",
148
+ "nu": "ν",
149
+ "xi": "ξ",
150
+ "Xi": "Ξ",
151
+ "omicron": "ο",
152
+ "rho": "ρ",
153
+ "sigma": "σ",
154
+ "Sigma": "Σ",
155
+ "tau": "τ",
156
+ "upsilon": "υ",
157
+ "phi": "φ",
158
+ "Phi": "Φ",
159
+ "chi": "χ",
160
+ "psi": "ψ",
161
+ "omega": "ω",
162
+ "Omega": "Ω",
163
+
164
+ "infty": "∞",
165
+ "sub": "⊂",
166
+ "sup": "⊃",
167
+ "nsub": "⊄",
168
+ "sube": "⊆",
169
+ "supe": "⊇",
170
+ "ne": "≠",
171
+ "le": "≤",
172
+ "ge": "≥",
173
+ "approx": "≈",
174
+ "cong": "≅",
175
+ "there4": "∴",
176
+ "forall": "∀",
177
+ "exist": "∃",
178
+ "empty": "∅",
179
+ "nabla": "∇",
180
+ "partial": "∂",
181
+ "sum": "∑",
182
+ "prod": "∏",
183
+ "int": "∫",
184
+ "lowast": "∗",
185
+ "radic": "√",
186
+ "real": "ℜ",
187
+ "image": "ℑ",
188
+ "ang": "∠",
189
+ "oplus": "⊕",
190
+ "otimes": "⊗",
191
+ "perp": "⊥",
192
+
193
+ "larr": "←",
194
+ "rarr": "→",
195
+ "uarr": "↑",
196
+ "darr": "↓",
197
+ "harr": "↔",
198
+ "lArr": "⇐",
199
+ "rArr": "⇒",
200
+ "uArr": "⇑",
201
+ "dArr": "⇓",
202
+ "hArr": "⇔",
203
+ "lceil": "⌈",
204
+ "rceil": "⌉",
205
+ "lfloor": "⌊",
206
+ "rfloor": "⌋",
207
+
208
+ "ampersand": "&",
209
+ "caret": "^",
210
+ "tilde": "~"
211
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jasonshimmy/custom-elements-runtime",
3
3
  "description": "A powerful, modern, and lightweight runtime for creating reactive web components with TypeScript",
4
- "version": "1.1.1",
4
+ "version": "1.2.0",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "web-components",
@@ -42,7 +42,8 @@
42
42
  "types": "dist/index.d.ts",
43
43
  "files": [
44
44
  "dist",
45
- "dist/index.d.ts"
45
+ "dist/index.d.ts",
46
+ "entities.json"
46
47
  ],
47
48
  "exports": {
48
49
  ".": {
@@ -50,7 +51,8 @@
50
51
  "import": "./dist/custom-elements-runtime.es.js",
51
52
  "require": "./dist/custom-elements-runtime.cjs.js",
52
53
  "default": "./dist/custom-elements-runtime.umd.js"
53
- }
54
+ },
55
+ "./entities.json": "./entities.json"
54
56
  },
55
57
  "publishConfig": {
56
58
  "access": "public"