@jasonshimmy/custom-elements-runtime 2.8.2 → 3.1.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/README.md +223 -73
- package/dist/css-utils-Cg4o1MqY.js +643 -0
- package/dist/css-utils-Cg4o1MqY.js.map +1 -0
- package/dist/css-utils-RqkyBWft.cjs +576 -0
- package/dist/css-utils-RqkyBWft.cjs.map +1 -0
- package/dist/custom-elements-runtime.cjs.js +3 -3
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js +7 -0
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.dom-jit-css.es.js +136 -0
- package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -0
- package/dist/custom-elements-runtime.es.js +105 -97
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.es.js +62 -46
- package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
- package/dist/custom-elements-runtime.jit-css.cjs.js +2 -0
- package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.jit-css.es.js +37 -0
- package/dist/custom-elements-runtime.jit-css.es.js.map +1 -0
- package/dist/custom-elements-runtime.router.cjs.js +20 -20
- package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.router.es.js +472 -458
- package/dist/custom-elements-runtime.router.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js +2 -0
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.ssr-middleware.es.js +63 -0
- package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -0
- package/dist/custom-elements-runtime.ssr.cjs.js +3 -1
- package/dist/custom-elements-runtime.ssr.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.ssr.es.js +137 -24
- package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
- package/dist/custom-elements-runtime.store.cjs.js +1 -1
- package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.store.es.js +21 -16
- package/dist/custom-elements-runtime.store.es.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
- package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.es.js +279 -7
- package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
- package/dist/custom-elements-runtime.vite-plugin.cjs.js +2 -0
- package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.vite-plugin.es.js +105 -0
- package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -0
- package/dist/dom-jit-css.d.ts +66 -0
- package/dist/event-bus.d.ts +3 -1
- package/dist/hooks-B50HhrHh.cjs +6 -0
- package/dist/hooks-B50HhrHh.cjs.map +1 -0
- package/dist/hooks-Cze3o-F7.js +1462 -0
- package/dist/hooks-Cze3o-F7.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/jit-css.d.ts +30 -0
- package/dist/namespace-helpers-D4wC2-qA.js +61 -0
- package/dist/namespace-helpers-D4wC2-qA.js.map +1 -0
- package/dist/namespace-helpers-ckeEOxpR.cjs +2 -0
- package/dist/namespace-helpers-ckeEOxpR.cjs.map +1 -0
- package/dist/router/matcher.d.ts +14 -0
- package/dist/router/types.d.ts +4 -2
- package/dist/runtime/component/factory.d.ts +16 -2
- package/dist/runtime/css-utils.d.ts +33 -0
- package/dist/runtime/discovery-state.d.ts +3 -0
- package/dist/runtime/hooks.d.ts +78 -0
- package/dist/runtime/hydration.d.ts +33 -0
- package/dist/runtime/jit-hooks.d.ts +28 -0
- package/dist/runtime/render-bridge.d.ts +37 -0
- package/dist/runtime/scheduler.d.ts +3 -4
- package/dist/runtime/secure-expression-evaluator.d.ts +0 -1
- package/dist/runtime/ssr-context.d.ts +45 -0
- package/dist/runtime/style.d.ts +84 -26
- package/dist/runtime/template-compiler/lru-cache.d.ts +0 -3
- package/dist/runtime/types.d.ts +18 -0
- package/dist/runtime/vdom-helpers.d.ts +0 -1
- package/dist/runtime/vdom-ssr-dsd.d.ts +58 -0
- package/dist/ssr-middleware.d.ts +125 -0
- package/dist/ssr.d.ts +120 -16
- package/dist/{transitions-DMJXs_tY.js → style-BmyOIMcU.js} +904 -1344
- package/dist/style-BmyOIMcU.js.map +1 -0
- package/dist/style-D40DsIqJ.cjs +55 -0
- package/dist/style-D40DsIqJ.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/template-compiler-Cshhqxyd.cjs +23 -0
- package/dist/template-compiler-Cshhqxyd.cjs.map +1 -0
- package/dist/template-compiler-DtpNsqE-.js +3744 -0
- package/dist/template-compiler-DtpNsqE-.js.map +1 -0
- package/dist/variables.css +1 -1
- package/dist/vite-plugin.d.ts +142 -0
- package/package.json +60 -6
- package/dist/namespace-helpers-Ctd_h7j2.cjs +0 -5
- package/dist/namespace-helpers-Ctd_h7j2.cjs.map +0 -1
- package/dist/namespace-helpers-DhLBqt-7.js +0 -1009
- package/dist/namespace-helpers-DhLBqt-7.js.map +0 -1
- package/dist/template-compiler-Bvx02nAT.js +0 -4020
- package/dist/template-compiler-Bvx02nAT.js.map +0 -1
- package/dist/template-compiler-bj-MFC_Y.cjs +0 -23
- package/dist/template-compiler-bj-MFC_Y.cjs.map +0 -1
- package/dist/transitions-DMJXs_tY.js.map +0 -1
- package/dist/transitions-f4KfN29T.cjs +0 -330
- package/dist/transitions-f4KfN29T.cjs.map +0 -1
|
@@ -1,10 +1,282 @@
|
|
|
1
|
-
import "./custom-elements-runtime.directives.es.js";
|
|
2
|
-
import {
|
|
1
|
+
import { anchorBlock as O } from "./custom-elements-runtime.directives.es.js";
|
|
2
|
+
import { p as P } from "./css-utils-Cg4o1MqY.js";
|
|
3
|
+
const F = {
|
|
4
|
+
/** Simple fade in/out */
|
|
5
|
+
fade: {
|
|
6
|
+
enterFrom: "opacity-0",
|
|
7
|
+
enterActive: "transition-opacity duration-300 ease-out",
|
|
8
|
+
enterTo: "opacity-100",
|
|
9
|
+
leaveFrom: "opacity-100",
|
|
10
|
+
leaveActive: "transition-opacity duration-200 ease-in",
|
|
11
|
+
leaveTo: "opacity-0"
|
|
12
|
+
},
|
|
13
|
+
/** Slide in from right */
|
|
14
|
+
"slide-right": {
|
|
15
|
+
enterFrom: "translate-x-[100%] opacity-0",
|
|
16
|
+
enterActive: "transition-all duration-300 ease-out",
|
|
17
|
+
enterTo: "translate-x-[0%] opacity-100",
|
|
18
|
+
leaveFrom: "translate-x-[0%] opacity-100",
|
|
19
|
+
leaveActive: "transition-all duration-200 ease-in",
|
|
20
|
+
leaveTo: "translate-x-[100%] opacity-0"
|
|
21
|
+
},
|
|
22
|
+
/** Slide in from left */
|
|
23
|
+
"slide-left": {
|
|
24
|
+
enterFrom: "translate-x-[-100%] opacity-0",
|
|
25
|
+
enterActive: "transition-all duration-300 ease-out",
|
|
26
|
+
enterTo: "translate-x-[0%] opacity-100",
|
|
27
|
+
leaveFrom: "translate-x-[0%] opacity-100",
|
|
28
|
+
leaveActive: "transition-all duration-200 ease-in",
|
|
29
|
+
leaveTo: "translate-x-[-100%] opacity-0"
|
|
30
|
+
},
|
|
31
|
+
/** Slide up from bottom */
|
|
32
|
+
"slide-up": {
|
|
33
|
+
enterFrom: "translate-y-[100%] opacity-0",
|
|
34
|
+
enterActive: "transition-all duration-300 ease-out",
|
|
35
|
+
enterTo: "translate-y-[0%] opacity-100",
|
|
36
|
+
leaveFrom: "translate-y-[0%] opacity-100",
|
|
37
|
+
leaveActive: "transition-all duration-200 ease-in",
|
|
38
|
+
leaveTo: "translate-y-[100%] opacity-0"
|
|
39
|
+
},
|
|
40
|
+
/** Slide down from top */
|
|
41
|
+
"slide-down": {
|
|
42
|
+
enterFrom: "translate-y-[-100%] opacity-0",
|
|
43
|
+
enterActive: "transition-all duration-300 ease-out",
|
|
44
|
+
enterTo: "translate-y-[0%] opacity-100",
|
|
45
|
+
leaveFrom: "translate-y-[0%] opacity-100",
|
|
46
|
+
leaveActive: "transition-all duration-200 ease-in",
|
|
47
|
+
leaveTo: "translate-y-[-100%] opacity-0"
|
|
48
|
+
},
|
|
49
|
+
/** Scale up from center */
|
|
50
|
+
scale: {
|
|
51
|
+
enterFrom: "scale-95 opacity-0",
|
|
52
|
+
enterActive: "transition-all duration-200 ease-out",
|
|
53
|
+
enterTo: "scale-100 opacity-100",
|
|
54
|
+
leaveFrom: "scale-100 opacity-100",
|
|
55
|
+
leaveActive: "transition-all duration-150 ease-in",
|
|
56
|
+
leaveTo: "scale-95 opacity-0"
|
|
57
|
+
},
|
|
58
|
+
/** Scale down to center */
|
|
59
|
+
"scale-down": {
|
|
60
|
+
enterFrom: "scale-105 opacity-0",
|
|
61
|
+
enterActive: "transition-all duration-200 ease-out",
|
|
62
|
+
enterTo: "scale-100 opacity-100",
|
|
63
|
+
leaveFrom: "scale-100 opacity-100",
|
|
64
|
+
leaveActive: "transition-all duration-150 ease-in",
|
|
65
|
+
leaveTo: "scale-105 opacity-0"
|
|
66
|
+
},
|
|
67
|
+
/** Bounce effect */
|
|
68
|
+
bounce: {
|
|
69
|
+
enterFrom: "scale-0 opacity-0",
|
|
70
|
+
enterActive: "transition-all duration-500 ease-out",
|
|
71
|
+
enterTo: "scale-100 opacity-100",
|
|
72
|
+
leaveFrom: "scale-100 opacity-100",
|
|
73
|
+
leaveActive: "transition-all duration-200 ease-in",
|
|
74
|
+
leaveTo: "scale-0 opacity-0"
|
|
75
|
+
},
|
|
76
|
+
/** Zoom and fade */
|
|
77
|
+
zoom: {
|
|
78
|
+
enterFrom: "scale-0 opacity-0",
|
|
79
|
+
enterActive: "transition-all duration-300 ease-out",
|
|
80
|
+
enterTo: "scale-100 opacity-100",
|
|
81
|
+
leaveFrom: "scale-100 opacity-100",
|
|
82
|
+
leaveActive: "transition-all duration-200 ease-in",
|
|
83
|
+
leaveTo: "scale-0 opacity-0"
|
|
84
|
+
},
|
|
85
|
+
/** Flip in */
|
|
86
|
+
flip: {
|
|
87
|
+
enterFrom: "rotate-[90deg] opacity-0",
|
|
88
|
+
enterActive: "transition-all duration-400 ease-out",
|
|
89
|
+
enterTo: "rotate-[0deg] opacity-100",
|
|
90
|
+
leaveFrom: "rotate-[0deg] opacity-100",
|
|
91
|
+
leaveActive: "transition-all duration-300 ease-in",
|
|
92
|
+
leaveTo: "rotate-[90deg] opacity-0"
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
function H(t, l) {
|
|
96
|
+
const {
|
|
97
|
+
preset: o,
|
|
98
|
+
show: e,
|
|
99
|
+
mode: s = "default",
|
|
100
|
+
duration: k,
|
|
101
|
+
appear: x = !1,
|
|
102
|
+
css: E = !0,
|
|
103
|
+
name: L,
|
|
104
|
+
enterFrom: d,
|
|
105
|
+
enterActive: f,
|
|
106
|
+
enterTo: p,
|
|
107
|
+
leaveFrom: r,
|
|
108
|
+
leaveActive: c,
|
|
109
|
+
leaveTo: v,
|
|
110
|
+
onBeforeEnter: m,
|
|
111
|
+
onEnter: A,
|
|
112
|
+
onAfterEnter: T,
|
|
113
|
+
onEnterCancelled: h,
|
|
114
|
+
onBeforeLeave: b,
|
|
115
|
+
onLeave: j,
|
|
116
|
+
onAfterLeave: w,
|
|
117
|
+
onLeaveCancelled: B
|
|
118
|
+
} = t;
|
|
119
|
+
let a;
|
|
120
|
+
o && F[o] ? (a = { ...F[o] }, d && (a.enterFrom = d), f && (a.enterActive = f), p && (a.enterTo = p), r && (a.leaveFrom = r), c && (a.leaveActive = c), v && (a.leaveTo = v)) : a = {
|
|
121
|
+
enterFrom: d,
|
|
122
|
+
enterActive: f,
|
|
123
|
+
enterTo: p,
|
|
124
|
+
leaveFrom: r,
|
|
125
|
+
leaveActive: c,
|
|
126
|
+
leaveTo: v
|
|
127
|
+
};
|
|
128
|
+
const $ = e && typeof l == "function" ? l() : l, S = L || (o ? `transition-${o}` : "transition"), C = O(
|
|
129
|
+
e ? $ : [],
|
|
130
|
+
S
|
|
131
|
+
);
|
|
132
|
+
return C._transition = {
|
|
133
|
+
name: S,
|
|
134
|
+
classes: a,
|
|
135
|
+
mode: s,
|
|
136
|
+
duration: k,
|
|
137
|
+
appear: x,
|
|
138
|
+
css: E,
|
|
139
|
+
state: e ? "visible" : "hidden",
|
|
140
|
+
hooks: {
|
|
141
|
+
onBeforeEnter: m,
|
|
142
|
+
onEnter: A,
|
|
143
|
+
onAfterEnter: T,
|
|
144
|
+
onEnterCancelled: h,
|
|
145
|
+
onBeforeLeave: b,
|
|
146
|
+
onLeave: j,
|
|
147
|
+
onAfterLeave: w,
|
|
148
|
+
onLeaveCancelled: B
|
|
149
|
+
}
|
|
150
|
+
}, C;
|
|
151
|
+
}
|
|
152
|
+
function I(t, l) {
|
|
153
|
+
const {
|
|
154
|
+
tag: o = "div",
|
|
155
|
+
moveClass: e = "transition-transform duration-300",
|
|
156
|
+
preset: s,
|
|
157
|
+
show: k = !0,
|
|
158
|
+
mode: x = "default",
|
|
159
|
+
duration: E,
|
|
160
|
+
appear: L = !1,
|
|
161
|
+
css: d = !0,
|
|
162
|
+
name: f,
|
|
163
|
+
class: p,
|
|
164
|
+
style: r,
|
|
165
|
+
enterFrom: c,
|
|
166
|
+
enterActive: v,
|
|
167
|
+
enterTo: m,
|
|
168
|
+
leaveFrom: A,
|
|
169
|
+
leaveActive: T,
|
|
170
|
+
leaveTo: h,
|
|
171
|
+
onBeforeEnter: b,
|
|
172
|
+
onEnter: j,
|
|
173
|
+
onAfterEnter: w,
|
|
174
|
+
onEnterCancelled: B,
|
|
175
|
+
onBeforeLeave: a,
|
|
176
|
+
onLeave: $,
|
|
177
|
+
onAfterLeave: S,
|
|
178
|
+
onLeaveCancelled: C
|
|
179
|
+
} = t;
|
|
180
|
+
let i;
|
|
181
|
+
s && F[s] ? (i = { ...F[s] }, c && (i.enterFrom = c), v && (i.enterActive = v), m && (i.enterTo = m), A && (i.leaveFrom = A), T && (i.leaveActive = T), h && (i.leaveTo = h)) : i = {
|
|
182
|
+
enterFrom: c,
|
|
183
|
+
enterActive: v,
|
|
184
|
+
enterTo: m,
|
|
185
|
+
leaveFrom: A,
|
|
186
|
+
leaveActive: T,
|
|
187
|
+
leaveTo: h
|
|
188
|
+
};
|
|
189
|
+
const _ = f || (s ? `transition-group-${s}` : "transition-group"), g = [];
|
|
190
|
+
for (const n of k ? l : [])
|
|
191
|
+
if (n && typeof n == "object" && n.tag === "#anchor") {
|
|
192
|
+
const K = Array.isArray(n.children) ? n.children : [];
|
|
193
|
+
for (const u of K)
|
|
194
|
+
if (u && typeof u == "object") {
|
|
195
|
+
const N = {
|
|
196
|
+
...u,
|
|
197
|
+
key: n.key || u.key,
|
|
198
|
+
props: {
|
|
199
|
+
...u.props,
|
|
200
|
+
_anchorKey: n.key
|
|
201
|
+
// Preserve original anchor key
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
g.push(N);
|
|
205
|
+
} else
|
|
206
|
+
g.push(u);
|
|
207
|
+
} else
|
|
208
|
+
g.push(n);
|
|
209
|
+
const G = (() => {
|
|
210
|
+
if (r)
|
|
211
|
+
return typeof r == "string" ? r : Object.entries(r).map(([n, K]) => `${n}: ${K}`).join("; ");
|
|
212
|
+
})();
|
|
213
|
+
return {
|
|
214
|
+
tag: o,
|
|
215
|
+
children: g,
|
|
216
|
+
key: _,
|
|
217
|
+
props: {
|
|
218
|
+
attrs: {
|
|
219
|
+
...p ? { class: p } : {},
|
|
220
|
+
...G ? { style: G } : {}
|
|
221
|
+
},
|
|
222
|
+
_transitionGroup: {
|
|
223
|
+
name: _,
|
|
224
|
+
classes: i,
|
|
225
|
+
moveClass: e,
|
|
226
|
+
mode: x,
|
|
227
|
+
duration: E,
|
|
228
|
+
appear: L,
|
|
229
|
+
css: d,
|
|
230
|
+
hooks: {
|
|
231
|
+
onBeforeEnter: b,
|
|
232
|
+
onEnter: j,
|
|
233
|
+
onAfterEnter: w,
|
|
234
|
+
onEnterCancelled: B,
|
|
235
|
+
onBeforeLeave: a,
|
|
236
|
+
onLeave: $,
|
|
237
|
+
onAfterLeave: S,
|
|
238
|
+
onLeaveCancelled: C
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function J(t) {
|
|
245
|
+
return { ...t };
|
|
246
|
+
}
|
|
247
|
+
let y = null;
|
|
248
|
+
function V() {
|
|
249
|
+
if (!y) {
|
|
250
|
+
if (typeof CSSStyleSheet > "u")
|
|
251
|
+
return y = {
|
|
252
|
+
cssRules: [],
|
|
253
|
+
replaceSync: () => {
|
|
254
|
+
},
|
|
255
|
+
toString: () => ""
|
|
256
|
+
}, y;
|
|
257
|
+
const t = [];
|
|
258
|
+
Object.values(F).forEach((e) => {
|
|
259
|
+
e.enterFrom && t.push(e.enterFrom), e.enterActive && t.push(e.enterActive), e.enterTo && t.push(e.enterTo), e.leaveFrom && t.push(e.leaveFrom), e.leaveActive && t.push(e.leaveActive), e.leaveTo && t.push(e.leaveTo);
|
|
260
|
+
});
|
|
261
|
+
const l = `<div class="${t.join(" ")}"></div>`, o = P(l);
|
|
262
|
+
try {
|
|
263
|
+
y = new CSSStyleSheet(), y.replaceSync(o);
|
|
264
|
+
} catch {
|
|
265
|
+
y = {
|
|
266
|
+
cssRules: [],
|
|
267
|
+
replaceSync: () => {
|
|
268
|
+
},
|
|
269
|
+
toString: () => o || ""
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return y;
|
|
274
|
+
}
|
|
3
275
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
276
|
+
H as Transition,
|
|
277
|
+
I as TransitionGroup,
|
|
278
|
+
J as createTransitionPreset,
|
|
279
|
+
V as getTransitionStyleSheet,
|
|
280
|
+
F as transitionPresets
|
|
9
281
|
};
|
|
10
282
|
//# sourceMappingURL=custom-elements-runtime.transitions.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-elements-runtime.transitions.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
1
|
+
{"version":3,"file":"custom-elements-runtime.transitions.es.js","sources":["../src/lib/transitions.ts"],"sourcesContent":["/**\n * Transitions module (top-level). This file provides the public Transition\n * and TransitionGroup APIs. It is an explicit entry used by the build so\n * consumers can import transitions separately: `.../transitions`.\n */\n/**\n * Transitions Module\n * Vue-like transition system integrated with JIT CSS\n * Provides Transition and TransitionGroup components for enter/leave animations\n */\n\nimport { anchorBlock } from './directives';\nimport type { VNode } from './runtime/types';\nimport { processJITCSS } from './runtime/render-bridge';\n\n/* --- Types --- */\n\n/**\n * Transition class names for different animation phases\n * All values should be JIT CSS utility classes\n */\nexport interface TransitionClasses {\n /** Classes applied at the start of enter transition */\n enterFrom?: string;\n /** Classes applied during entire enter transition */\n enterActive?: string;\n /** Classes applied at the end of enter transition */\n enterTo?: string;\n /** Classes applied at the start of leave transition */\n leaveFrom?: string;\n /** Classes applied during entire leave transition */\n leaveActive?: string;\n /** Classes applied at the end of leave transition */\n leaveTo?: string;\n}\n\n/**\n * Lifecycle hooks for transition events\n */\nexport interface TransitionHooks {\n /** Called before enter transition starts */\n onBeforeEnter?: (el: HTMLElement) => void;\n /** Called during enter transition (with done callback for manual control) */\n onEnter?: (el: HTMLElement, done: () => void) => void;\n /** Called after enter transition completes */\n onAfterEnter?: (el: HTMLElement) => void;\n /** Called if enter transition is cancelled */\n onEnterCancelled?: (el: HTMLElement) => void;\n /** Called before leave transition starts */\n onBeforeLeave?: (el: HTMLElement) => void;\n /** Called during leave transition (with done callback for manual control) */\n onLeave?: (el: HTMLElement, done: () => void) => void;\n /** Called after leave transition completes */\n onAfterLeave?: (el: HTMLElement) => void;\n /** Called if leave transition is cancelled */\n onLeaveCancelled?: (el: HTMLElement) => void;\n}\n\n/**\n * Options for Transition component\n */\nexport interface TransitionOptions extends TransitionClasses, TransitionHooks {\n /** Preset name (fade, slide-right, scale, etc.) */\n preset?: keyof typeof transitionPresets;\n /** Whether to show the content */\n show: boolean;\n /** Transition mode: default, out-in (leave before enter), in-out (enter before leave) */\n mode?: 'default' | 'out-in' | 'in-out';\n /** Custom duration override (ms) */\n duration?: number | { enter: number; leave: number };\n /** Whether to apply transition on initial render */\n appear?: boolean;\n /** Whether to use CSS transitions (true) or JS-only hooks (false) */\n css?: boolean;\n /** Optional name for debugging */\n name?: string;\n}\n\n/**\n * Options for TransitionGroup component\n */\nexport interface TransitionGroupOptions extends Omit<\n TransitionOptions,\n 'show'\n> {\n /** HTML tag for the wrapper element */\n tag?: string;\n /** Class applied during move transitions (when items reorder) */\n moveClass?: string;\n /** Whether to show the group (defaults to true for TransitionGroup) */\n show?: boolean;\n /** CSS classes to apply to the wrapper element (e.g., 'flex gap-4' or 'grid grid-cols-3') */\n class?: string;\n /** Inline styles to apply to the wrapper element */\n style?: string | Record<string, string>;\n}\n\n/* --- Transition Presets --- */\n\n/**\n * Pre-defined transition presets using JIT CSS classes\n * Users can reference these by name or define custom classes\n */\nexport const transitionPresets = {\n /** Simple fade in/out */\n fade: {\n enterFrom: 'opacity-0',\n enterActive: 'transition-opacity duration-300 ease-out',\n enterTo: 'opacity-100',\n leaveFrom: 'opacity-100',\n leaveActive: 'transition-opacity duration-200 ease-in',\n leaveTo: 'opacity-0',\n },\n\n /** Slide in from right */\n 'slide-right': {\n enterFrom: 'translate-x-[100%] opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'translate-x-[0%] opacity-100',\n leaveFrom: 'translate-x-[0%] opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'translate-x-[100%] opacity-0',\n },\n\n /** Slide in from left */\n 'slide-left': {\n enterFrom: 'translate-x-[-100%] opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'translate-x-[0%] opacity-100',\n leaveFrom: 'translate-x-[0%] opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'translate-x-[-100%] opacity-0',\n },\n\n /** Slide up from bottom */\n 'slide-up': {\n enterFrom: 'translate-y-[100%] opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'translate-y-[0%] opacity-100',\n leaveFrom: 'translate-y-[0%] opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'translate-y-[100%] opacity-0',\n },\n\n /** Slide down from top */\n 'slide-down': {\n enterFrom: 'translate-y-[-100%] opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'translate-y-[0%] opacity-100',\n leaveFrom: 'translate-y-[0%] opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'translate-y-[-100%] opacity-0',\n },\n\n /** Scale up from center */\n scale: {\n enterFrom: 'scale-95 opacity-0',\n enterActive: 'transition-all duration-200 ease-out',\n enterTo: 'scale-100 opacity-100',\n leaveFrom: 'scale-100 opacity-100',\n leaveActive: 'transition-all duration-150 ease-in',\n leaveTo: 'scale-95 opacity-0',\n },\n\n /** Scale down to center */\n 'scale-down': {\n enterFrom: 'scale-105 opacity-0',\n enterActive: 'transition-all duration-200 ease-out',\n enterTo: 'scale-100 opacity-100',\n leaveFrom: 'scale-100 opacity-100',\n leaveActive: 'transition-all duration-150 ease-in',\n leaveTo: 'scale-105 opacity-0',\n },\n\n /** Bounce effect */\n bounce: {\n enterFrom: 'scale-0 opacity-0',\n enterActive: 'transition-all duration-500 ease-out',\n enterTo: 'scale-100 opacity-100',\n leaveFrom: 'scale-100 opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'scale-0 opacity-0',\n },\n\n /** Zoom and fade */\n zoom: {\n enterFrom: 'scale-0 opacity-0',\n enterActive: 'transition-all duration-300 ease-out',\n enterTo: 'scale-100 opacity-100',\n leaveFrom: 'scale-100 opacity-100',\n leaveActive: 'transition-all duration-200 ease-in',\n leaveTo: 'scale-0 opacity-0',\n },\n\n /** Flip in */\n flip: {\n enterFrom: 'rotate-[90deg] opacity-0',\n enterActive: 'transition-all duration-400 ease-out',\n enterTo: 'rotate-[0deg] opacity-100',\n leaveFrom: 'rotate-[0deg] opacity-100',\n leaveActive: 'transition-all duration-300 ease-in',\n leaveTo: 'rotate-[90deg] opacity-0',\n },\n} as const;\n\n/* --- Core Functions --- */\n\n/**\n * Transition component - wraps content with enter/leave animations\n *\n * @example\n * ```ts\n * // Using a preset\n * ${Transition({ preset: 'fade', show: isVisible.value }, html`<div>Content</div>`)}\n *\n * // Using custom JIT classes\n * ${Transition({\n * show: isVisible.value,\n * enterFrom: 'opacity-0 scale-95',\n * enterActive: 'transition-all duration-300',\n * enterTo: 'opacity-100 scale-100',\n * leaveFrom: 'opacity-100 scale-100',\n * leaveActive: 'transition-all duration-200',\n * leaveTo: 'opacity-0 scale-95'\n * }, html`<div>Content</div>`)}\n *\n * // With lifecycle hooks\n * ${Transition({\n * preset: 'slide-right',\n * show: isVisible.value,\n * onAfterEnter: (el) => console.log('Entered!'),\n * onAfterLeave: (el) => console.log('Left!')\n * }, html`<div>Content</div>`)}\n *\n * // Lazy factory — only evaluated when show is true (avoids constructing\n * // expensive VNode trees when the content is hidden)\n * ${Transition({ show: isVisible.value }, () => html`<div>Expensive content</div>`)}\n * ```\n */\nexport function Transition(\n options: TransitionOptions,\n content: VNode | VNode[] | (() => VNode | VNode[]),\n): VNode {\n const {\n preset,\n show,\n mode = 'default',\n duration,\n appear = false,\n css = true,\n name,\n enterFrom,\n enterActive,\n enterTo,\n leaveFrom,\n leaveActive,\n leaveTo,\n onBeforeEnter,\n onEnter,\n onAfterEnter,\n onEnterCancelled,\n onBeforeLeave,\n onLeave,\n onAfterLeave,\n onLeaveCancelled,\n } = options;\n\n // Resolve classes from preset or explicit values\n let transitionClasses: TransitionClasses;\n if (preset && transitionPresets[preset]) {\n transitionClasses = { ...transitionPresets[preset] };\n // Allow overriding preset classes\n if (enterFrom) transitionClasses.enterFrom = enterFrom;\n if (enterActive) transitionClasses.enterActive = enterActive;\n if (enterTo) transitionClasses.enterTo = enterTo;\n if (leaveFrom) transitionClasses.leaveFrom = leaveFrom;\n if (leaveActive) transitionClasses.leaveActive = leaveActive;\n if (leaveTo) transitionClasses.leaveTo = leaveTo;\n } else {\n transitionClasses = {\n enterFrom,\n enterActive,\n enterTo,\n leaveFrom,\n leaveActive,\n leaveTo,\n };\n }\n\n // Resolve content: only call the factory when show is true so that expensive\n // VNode trees (e.g. those that trigger calender builds or heavy computeds)\n // are never constructed while the transition is hidden. Leave animations\n // operate on existing DOM nodes and do not require the content VNode.\n const resolvedContent: VNode | VNode[] =\n show && typeof content === 'function'\n ? content()\n : (content as VNode | VNode[]);\n\n // Create anchor block with transition metadata\n const transitionKey =\n name || (preset ? `transition-${preset}` : 'transition');\n const transitionVNode = anchorBlock(\n show ? resolvedContent : [],\n transitionKey,\n );\n\n // Attach metadata for VDOM to consume during patching\n (transitionVNode as VNode & { _transition?: unknown })._transition = {\n name: transitionKey,\n classes: transitionClasses,\n mode,\n duration,\n appear,\n css,\n state: show ? 'visible' : 'hidden',\n hooks: {\n onBeforeEnter,\n onEnter,\n onAfterEnter,\n onEnterCancelled,\n onBeforeLeave,\n onLeave,\n onAfterLeave,\n onLeaveCancelled,\n },\n };\n\n return transitionVNode;\n}\n\n/**\n * TransitionGroup component - animates lists with enter/leave/move transitions\n *\n * @example\n * ```ts\n * // Basic usage\n * ${TransitionGroup({\n * preset: 'slide-right',\n * tag: 'ul',\n * moveClass: 'transition-transform duration-300'\n * }, each(items.value, (item) => html`\n * <li key=\"${item.id}\">${item.text}</li>\n * `))}\n *\n * // With flex layout\n * ${TransitionGroup({\n * preset: 'fade',\n * class: 'flex gap-4 flex-wrap'\n * }, each(items.value, (item) => html`\n * <div key=\"${item.id}\" class=\"shrink-0\">${item.text}</div>\n * `))}\n *\n * // With grid layout\n * ${TransitionGroup({\n * preset: 'scale',\n * class: 'grid grid-cols-3 gap-4'\n * }, each(items.value, (item) => html`\n * <div key=\"${item.id}\">${item.text}</div>\n * `))}\n * ```\n */\nexport function TransitionGroup(\n options: TransitionGroupOptions,\n children: VNode[],\n): VNode {\n const {\n tag = 'div',\n moveClass = 'transition-transform duration-300',\n preset,\n show = true,\n mode = 'default',\n duration,\n appear = false,\n css = true,\n name,\n class: className,\n style,\n enterFrom,\n enterActive,\n enterTo,\n leaveFrom,\n leaveActive,\n leaveTo,\n onBeforeEnter,\n onEnter,\n onAfterEnter,\n onEnterCancelled,\n onBeforeLeave,\n onLeave,\n onAfterLeave,\n onLeaveCancelled,\n } = options;\n\n // Resolve classes from preset or explicit values\n let transitionClasses: TransitionClasses;\n if (preset && transitionPresets[preset]) {\n transitionClasses = { ...transitionPresets[preset] };\n // Allow overriding preset classes\n if (enterFrom) transitionClasses.enterFrom = enterFrom;\n if (enterActive) transitionClasses.enterActive = enterActive;\n if (enterTo) transitionClasses.enterTo = enterTo;\n if (leaveFrom) transitionClasses.leaveFrom = leaveFrom;\n if (leaveActive) transitionClasses.leaveActive = leaveActive;\n if (leaveTo) transitionClasses.leaveTo = leaveTo;\n } else {\n transitionClasses = {\n enterFrom,\n enterActive,\n enterTo,\n leaveFrom,\n leaveActive,\n leaveTo,\n };\n }\n\n // Create wrapper element with transition group metadata\n const groupKey =\n name || (preset ? `transition-group-${preset}` : 'transition-group');\n\n // Flatten anchor block children to enable proper keyed diffing\n // When each() is used, it creates anchor blocks. We need to extract the actual elements\n // and give them keys from their anchor blocks for proper reordering\n const flattenedChildren: VNode[] = [];\n for (const child of show ? children : []) {\n if (child && typeof child === 'object' && child.tag === '#anchor') {\n // Extract children from anchor block\n const anchorChildren = Array.isArray(child.children)\n ? child.children\n : [];\n for (const anchorChild of anchorChildren) {\n if (anchorChild && typeof anchorChild === 'object') {\n // Use anchor block's key for the child element\n const keyedChild = {\n ...anchorChild,\n key: child.key || anchorChild.key,\n props: {\n ...anchorChild.props,\n _anchorKey: child.key, // Preserve original anchor key\n },\n };\n flattenedChildren.push(keyedChild);\n } else {\n flattenedChildren.push(anchorChild);\n }\n }\n } else {\n flattenedChildren.push(child);\n }\n }\n\n // Serialize style object to a CSS string for the attrs record so it matches\n // the expected primitive attribute value types.\n const styleAttr = (() => {\n if (!style) return undefined;\n if (typeof style === 'string') return style;\n return Object.entries(style)\n .map(([k, v]) => `${k}: ${v}`)\n .join('; ');\n })();\n\n return {\n tag,\n children: flattenedChildren,\n key: groupKey,\n props: {\n attrs: {\n ...(className ? { class: className } : {}),\n ...(styleAttr ? { style: styleAttr } : {}),\n },\n _transitionGroup: {\n name: groupKey,\n classes: transitionClasses,\n moveClass,\n mode,\n duration,\n appear,\n css,\n hooks: {\n onBeforeEnter,\n onEnter,\n onAfterEnter,\n onEnterCancelled,\n onBeforeLeave,\n onLeave,\n onAfterLeave,\n onLeaveCancelled,\n },\n },\n },\n };\n}\n\n/**\n * Helper to create custom transition presets\n *\n * @example\n * ```ts\n * const customFade = createTransitionPreset({\n * enterFrom: 'opacity-0',\n * enterActive: 'transition-opacity duration-500 ease-out',\n * enterTo: 'opacity-100',\n * leaveFrom: 'opacity-100',\n * leaveActive: 'transition-opacity duration-300 ease-in',\n * leaveTo: 'opacity-0'\n * });\n *\n * ${Transition({ ...customFade, show: visible.value }, content)}\n * ```\n */\nexport function createTransitionPreset(\n classes: TransitionClasses,\n): TransitionClasses {\n return { ...classes };\n}\n\n/**\n * Pre-generate CSS for all transition preset classes\n * This ensures the JIT CSS system has the styles ready when transitions are used\n */\nlet transitionStyleSheet: CSSStyleSheet | null = null;\n\n/**\n * Get the global transition stylesheet (creates it if needed)\n */\nexport function getTransitionStyleSheet(): CSSStyleSheet {\n if (!transitionStyleSheet) {\n // If constructable stylesheets aren't available (SSR / old browsers),\n // return a no-op stub to avoid throwing during import or server render.\n if (typeof CSSStyleSheet === 'undefined') {\n transitionStyleSheet = {\n cssRules: [],\n replaceSync: () => {},\n toString: () => '',\n } as unknown as CSSStyleSheet;\n return transitionStyleSheet;\n }\n\n const allClasses: string[] = [];\n\n // Collect all classes from presets\n Object.values(transitionPresets).forEach((preset) => {\n if (preset.enterFrom) allClasses.push(preset.enterFrom);\n if (preset.enterActive) allClasses.push(preset.enterActive);\n if (preset.enterTo) allClasses.push(preset.enterTo);\n if (preset.leaveFrom) allClasses.push(preset.leaveFrom);\n if (preset.leaveActive) allClasses.push(preset.leaveActive);\n if (preset.leaveTo) allClasses.push(preset.leaveTo);\n });\n\n // Create a fake HTML string with all transition classes\n const fakeHtml = `<div class=\"${allClasses.join(' ')}\"></div>`;\n\n // Trigger JIT CSS generation (no-op if JIT CSS engine is not loaded)\n const generatedCSS = processJITCSS(fakeHtml);\n\n // Create stylesheet\n try {\n transitionStyleSheet = new CSSStyleSheet();\n transitionStyleSheet.replaceSync(generatedCSS);\n } catch {\n // If creating a constructable stylesheet fails for any reason,\n // fallback to a stub to avoid breaking SSR or older environments.\n transitionStyleSheet = {\n cssRules: [],\n replaceSync: () => {},\n toString: () => generatedCSS || '',\n } as unknown as CSSStyleSheet;\n }\n }\n\n return transitionStyleSheet;\n}\n\n"],"names":["transitionPresets","Transition","options","content","preset","show","mode","duration","appear","css","name","enterFrom","enterActive","enterTo","leaveFrom","leaveActive","leaveTo","onBeforeEnter","onEnter","onAfterEnter","onEnterCancelled","onBeforeLeave","onLeave","onAfterLeave","onLeaveCancelled","transitionClasses","resolvedContent","transitionKey","transitionVNode","anchorBlock","TransitionGroup","children","tag","moveClass","className","style","groupKey","flattenedChildren","child","anchorChildren","anchorChild","keyedChild","styleAttr","k","v","createTransitionPreset","classes","transitionStyleSheet","getTransitionStyleSheet","allClasses","fakeHtml","generatedCSS","processJITCSS"],"mappings":";;AAuGO,MAAMA,IAAoB;AAAA;AAAA,EAE/B,MAAM;AAAA,IACJ,WAAW;AAAA,IACX,aAAa;AAAA,IACb,SAAS;AAAA,IACT,WAAW;AAAA,IACX,aAAa;AAAA,IACb,SAAS;AAAA,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AC;AAAA,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEJ;AAmBO,SAASqB,EACdC,GACmB;AACnB,SAAO,EAAE,GAAGA,EAAA;AACd;AAMA,IAAIC,IAA6C;AAK1C,SAASC,IAAyC;AACvD,MAAI,CAACD,GAAsB;AAGzB,QAAI,OAAO,gBAAkB;AAC3B,aAAAA,IAAuB;AAAA,QACrB,UAAU,CAAA;AAAA,QACV,aAAa,MAAM;AAAA,QAAC;AAAA,QACpB,UAAU,MAAM;AAAA,MAAA,GAEXA;AAGT,UAAME,IAAuB,CAAA;AAG7B,WAAO,OAAOjD,CAAiB,EAAE,QAAQ,CAACI,MAAW;AACnD,MAAIA,EAAO,aAAW6C,EAAW,KAAK7C,EAAO,SAAS,GAClDA,EAAO,eAAa6C,EAAW,KAAK7C,EAAO,WAAW,GACtDA,EAAO,WAAS6C,EAAW,KAAK7C,EAAO,OAAO,GAC9CA,EAAO,aAAW6C,EAAW,KAAK7C,EAAO,SAAS,GAClDA,EAAO,eAAa6C,EAAW,KAAK7C,EAAO,WAAW,GACtDA,EAAO,WAAS6C,EAAW,KAAK7C,EAAO,OAAO;AAAA,IACpD,CAAC;AAGD,UAAM8C,IAAW,eAAeD,EAAW,KAAK,GAAG,CAAC,YAG9CE,IAAeC,EAAcF,CAAQ;AAG3C,QAAI;AACF,MAAAH,IAAuB,IAAI,cAAA,GAC3BA,EAAqB,YAAYI,CAAY;AAAA,IAC/C,QAAQ;AAGN,MAAAJ,IAAuB;AAAA,QACrB,UAAU,CAAA;AAAA,QACV,aAAa,MAAM;AAAA,QAAC;AAAA,QACpB,UAAU,MAAMI,KAAgB;AAAA,MAAA;AAAA,IAEpC;AAAA,EACF;AAEA,SAAOJ;AACT;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("node:fs"),S=require("node:path"),h=require("./style-D40DsIqJ.cjs"),w="virtual:cer-jit-css",y="\0virtual:cer-jit-css";function m(e,r){r&&Object.keys(r).length>0&&h.enableJITCSS(r);const t=process.cwd(),n=[];for(const l of e){const o=d.globSync(l,{cwd:t}).map(i=>S.resolve(t,i));n.push(...o)}const c=[...new Set(n)],a=new Set;for(const l of c)try{const o=d.readFileSync(l,"utf-8"),i=h.extractClassesFromHTML(o);for(const s of i)a.add(s)}catch{}if(a.size===0)return"";const g=`<div class="${[...a].join(" ")}"></div>`;return h.jitCSS(g)}const b="virtual:cer-ssr-config",I="\0virtual:cer-ssr-config";function T(e){const r=[];if(e.content&&e.content.length>0&&r.push(p({content:e.content,output:e.output,virtualModule:e.virtualModule,extendedColors:e.extendedColors,customColors:e.customColors,disableVariants:e.disableVariants})),e.ssr){const t=e.ssr,n={dsd:t.dsd??!0,dsdPolyfill:t.dsdPolyfill??!0,...t.jit?{jit:t.jit}:{}};r.push({name:"cer-ssr-config",resolveId(c){if(c===b)return I},load(c){if(c===I)return`export default ${JSON.stringify(n)};`}})}return r}function p(e){const{content:r,output:t,virtualModule:n=!0,extendedColors:c,customColors:a,disableVariants:g}=e,l={extendedColors:c,customColors:a,disableVariants:g};let o="",i=null;return{name:"cer-jit-css",buildStart(){const s=process.cwd(),v=new Set;for(const f of r)d.globSync(f,{cwd:s}).forEach(u=>v.add(S.resolve(s,u)));if(i=v,o=m(r,l),t){const f=S.resolve(process.cwd(),t);d.mkdirSync(S.dirname(f),{recursive:!0}),d.writeFileSync(f,o,"utf-8")}},resolveId(s){if(n&&s===w)return y},load(s){if(s===y)return`export default ${JSON.stringify(o)};`},handleHotUpdate({file:s,server:v}){if(i?.has(s)??!1){if(o=m(r,l),t){const u=S.resolve(process.cwd(),t);d.writeFileSync(u,o,"utf-8")}if(n){const u=v,C=u.moduleGraph.getModuleById(y);C&&u.reloadModule(C)}}}}}exports.cerJITCSS=p;exports.cerPlugin=T;
|
|
2
|
+
//# sourceMappingURL=custom-elements-runtime.vite-plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-elements-runtime.vite-plugin.cjs.js","sources":["../src/lib/vite-plugin.ts"],"sourcesContent":["/**\n * Vite plugins for build-time JIT CSS generation and SSR configuration.\n *\n * Two plugins are exported:\n *\n * - **`cerJITCSS`** — Scans source files for utility class names and emits\n * pre-generated CSS, eliminating all runtime parsing cost for projects with\n * static class lists.\n *\n * - **`cerPlugin`** — All-in-one plugin combining `cerJITCSS` with SSR\n * configuration. Exposes a `virtual:cer-ssr-config` module containing the\n * resolved SSR render options so server entry files can import and use them\n * without duplication.\n *\n * @example cerJITCSS only\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { cerJITCSS } from '@jasonshimmy/custom-elements-runtime/vite-plugin';\n *\n * export default defineConfig({\n * plugins: [\n * cerJITCSS({\n * content: ['./src/**\\/*.{ts,tsx,html}'],\n * output: 'src/generated-jit.css',\n * extendedColors: true,\n * }),\n * ],\n * });\n * ```\n *\n * @example cerPlugin with SSR\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { cerPlugin } from '@jasonshimmy/custom-elements-runtime/vite-plugin';\n *\n * export default defineConfig({\n * plugins: [\n * cerPlugin({\n * content: ['./src/**\\/*.{ts,tsx,html}'],\n * ssr: {\n * dsd: true,\n * jit: { extendedColors: true },\n * },\n * }),\n * ],\n * });\n * ```\n *\n * Then in your server entry:\n * ```ts\n * import ssrConfig from 'virtual:cer-ssr-config';\n * import { renderToStringWithJITCSS } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, ssrConfig);\n * ```\n */\n\nimport type { Plugin } from 'vite';\nimport { readFileSync, writeFileSync, mkdirSync, globSync } from 'node:fs';\nimport { resolve, dirname } from 'node:path';\nimport {\n jitCSS,\n enableJITCSS,\n extractClassesFromHTML,\n type JITCSSOptions,\n} from './runtime/style';\n\n// --- Re-export extractClassesFromHTML for plugin consumers ---\n\n/**\n * Options for the `cerJITCSS` Vite plugin.\n */\nexport interface CerJITCSSPluginOptions extends JITCSSOptions {\n /**\n * Glob patterns (relative to `process.cwd()`) that identify which source\n * files the plugin should scan for utility class names.\n *\n * @example `['./src/**\\/*.{ts,html}', './index.html']`\n */\n content: string[];\n /**\n * File path (relative to `process.cwd()`) where the generated CSS will\n * be written. When omitted the plugin only emits a virtual module.\n */\n output?: string;\n /**\n * Whether to emit a virtual module `virtual:cer-jit-css` that resolves to\n * the generated CSS text. Defaults to `true`.\n */\n virtualModule?: boolean;\n}\n\nconst VIRTUAL_ID = 'virtual:cer-jit-css';\nconst RESOLVED_VIRTUAL_ID = '\\0virtual:cer-jit-css';\n\nfunction generateFromFiles(\n contentPatterns: string[],\n jitOptions: JITCSSOptions,\n): string {\n if (jitOptions && Object.keys(jitOptions).length > 0) {\n enableJITCSS(jitOptions);\n }\n\n const cwd = process.cwd();\n const files: string[] = [];\n\n for (const pattern of contentPatterns) {\n const matches = globSync(pattern, { cwd }).map((f) => resolve(cwd, f));\n files.push(...matches);\n }\n\n // Deduplicate files\n const uniqueFiles = [...new Set(files)];\n\n // Aggregate all class names across all files\n const allClasses = new Set<string>();\n\n for (const file of uniqueFiles) {\n try {\n const content = readFileSync(file, 'utf-8');\n const classes = extractClassesFromHTML(content);\n for (const cls of classes) allClasses.add(cls);\n } catch {\n // Skip unreadable files\n }\n }\n\n if (allClasses.size === 0) return '';\n\n // Build a fake HTML string containing all discovered classes so jitCSS()\n // can process the full set in one pass.\n const fakeHTML = `<div class=\"${[...allClasses].join(' ')}\"></div>`;\n return jitCSS(fakeHTML);\n}\n\n// ---------------------------------------------------------------------------\n// cerPlugin — combined JIT CSS + SSR configuration plugin\n// ---------------------------------------------------------------------------\n\n/**\n * SSR render options exposed via `virtual:cer-ssr-config`.\n */\nexport interface CerSSROptions {\n /**\n * Emit Declarative Shadow DOM output for registered custom elements.\n * @default true\n */\n dsd?: boolean;\n /**\n * Append the DSD polyfill `<script>` for browsers without native support.\n * @default true\n */\n dsdPolyfill?: boolean;\n /**\n * JIT CSS options forwarded to the SSR render pass.\n */\n jit?: JITCSSOptions;\n}\n\n/**\n * Options for the combined {@link cerPlugin}.\n */\nexport interface CerPluginOptions extends Partial<CerJITCSSPluginOptions> {\n /**\n * SSR configuration. When provided, a `virtual:cer-ssr-config` module is\n * registered so server entry files can import the resolved render options:\n *\n * ```ts\n * import ssrConfig from 'virtual:cer-ssr-config';\n * import { renderToStringWithJITCSS } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, ssrConfig);\n * ```\n */\n ssr?: CerSSROptions;\n}\n\nconst VIRTUAL_SSR_ID = 'virtual:cer-ssr-config';\nconst RESOLVED_VIRTUAL_SSR_ID = '\\0virtual:cer-ssr-config';\n\n/**\n * All-in-one Vite plugin combining build-time JIT CSS generation with SSR\n * configuration. Returns an array of plugins so it can be spread directly\n * into the `plugins` array without nesting.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * export default defineConfig({\n * plugins: [\n * cerPlugin({\n * content: ['./src/**\\/*.{ts,html}'],\n * ssr: { dsd: true, jit: { extendedColors: true } },\n * }),\n * ],\n * });\n * ```\n */\nexport function cerPlugin(options: CerPluginOptions): Plugin[] {\n const plugins: Plugin[] = [];\n\n // JIT CSS plugin — only added when a `content` glob is provided\n if (options.content && options.content.length > 0) {\n plugins.push(\n cerJITCSS({\n content: options.content,\n output: options.output,\n virtualModule: options.virtualModule,\n extendedColors: options.extendedColors,\n customColors: options.customColors,\n disableVariants: options.disableVariants,\n }),\n );\n }\n\n // SSR config virtual module — registered whenever `ssr` is provided\n if (options.ssr) {\n const ssrConfig = options.ssr;\n const resolvedConfig = {\n dsd: ssrConfig.dsd ?? true,\n dsdPolyfill: ssrConfig.dsdPolyfill ?? true,\n ...(ssrConfig.jit ? { jit: ssrConfig.jit } : {}),\n };\n\n plugins.push({\n name: 'cer-ssr-config',\n resolveId(id: string) {\n if (id === VIRTUAL_SSR_ID) return RESOLVED_VIRTUAL_SSR_ID;\n return undefined;\n },\n load(id: string) {\n if (id === RESOLVED_VIRTUAL_SSR_ID) {\n return `export default ${JSON.stringify(resolvedConfig)};`;\n }\n return undefined;\n },\n });\n }\n\n return plugins;\n}\n\n// ---------------------------------------------------------------------------\n// cerJITCSS — build-time JIT CSS plugin\n// ---------------------------------------------------------------------------\n\n/**\n * Vite plugin that performs a build-time scan of source files and emits\n * pre-generated JIT CSS as a file and/or `virtual:cer-jit-css` module.\n */\nexport function cerJITCSS(options: CerJITCSSPluginOptions): Plugin {\n const {\n content,\n output,\n virtualModule = true,\n extendedColors,\n customColors,\n disableVariants,\n } = options;\n\n const jitOptions: JITCSSOptions = {\n extendedColors,\n customColors,\n disableVariants,\n };\n\n let generatedCSS = '';\n // Resolved file set built in buildStart and reused in handleHotUpdate to\n // avoid re-running globSync for every HMR file-change event.\n let watchedFiles: Set<string> | null = null;\n\n return {\n name: 'cer-jit-css',\n\n buildStart() {\n const cwd = process.cwd();\n const resolved = new Set<string>();\n for (const pattern of content) {\n globSync(pattern, { cwd }).forEach((f) => resolved.add(resolve(cwd, f)));\n }\n watchedFiles = resolved;\n\n generatedCSS = generateFromFiles(content, jitOptions);\n\n if (output) {\n const outputPath = resolve(process.cwd(), output);\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, generatedCSS, 'utf-8');\n }\n },\n\n resolveId(id: string) {\n if (virtualModule && id === VIRTUAL_ID) {\n return RESOLVED_VIRTUAL_ID;\n }\n return undefined;\n },\n\n load(id: string) {\n if (id === RESOLVED_VIRTUAL_ID) {\n return `export default ${JSON.stringify(generatedCSS)};`;\n }\n return undefined;\n },\n\n handleHotUpdate({ file, server }: { file: string; server: unknown }) {\n // Re-generate when a watched source file changes.\n // Use the cached file set from buildStart to avoid re-globbing.\n const isWatched = watchedFiles?.has(file) ?? false;\n\n if (!isWatched) return;\n\n generatedCSS = generateFromFiles(content, jitOptions);\n\n if (output) {\n const outputPath = resolve(process.cwd(), output);\n writeFileSync(outputPath, generatedCSS, 'utf-8');\n }\n\n if (virtualModule) {\n // Invalidate the virtual module so HMR triggers a reload\n const viteServer = server as {\n moduleGraph: { getModuleById: (id: string) => unknown };\n reloadModule: (mod: unknown) => void;\n };\n const mod = viteServer.moduleGraph.getModuleById(RESOLVED_VIRTUAL_ID);\n if (mod) viteServer.reloadModule(mod);\n }\n },\n };\n}\n"],"names":["VIRTUAL_ID","RESOLVED_VIRTUAL_ID","generateFromFiles","contentPatterns","jitOptions","enableJITCSS","cwd","files","pattern","matches","globSync","f","resolve","uniqueFiles","allClasses","file","content","readFileSync","classes","extractClassesFromHTML","cls","fakeHTML","jitCSS","VIRTUAL_SSR_ID","RESOLVED_VIRTUAL_SSR_ID","cerPlugin","options","plugins","cerJITCSS","ssrConfig","resolvedConfig","id","output","virtualModule","extendedColors","customColors","disableVariants","generatedCSS","watchedFiles","resolved","outputPath","mkdirSync","dirname","writeFileSync","server","viteServer","mod"],"mappings":"oKA8FMA,EAAa,sBACbC,EAAsB,wBAE5B,SAASC,EACPC,EACAC,EACQ,CACJA,GAAc,OAAO,KAAKA,CAAU,EAAE,OAAS,GACjDC,EAAAA,aAAaD,CAAU,EAGzB,MAAME,EAAM,QAAQ,IAAA,EACdC,EAAkB,CAAA,EAExB,UAAWC,KAAWL,EAAiB,CACrC,MAAMM,EAAUC,EAAAA,SAASF,EAAS,CAAE,IAAAF,CAAA,CAAK,EAAE,IAAKK,GAAMC,EAAAA,QAAQN,EAAKK,CAAC,CAAC,EACrEJ,EAAM,KAAK,GAAGE,CAAO,CACvB,CAGA,MAAMI,EAAc,CAAC,GAAG,IAAI,IAAIN,CAAK,CAAC,EAGhCO,MAAiB,IAEvB,UAAWC,KAAQF,EACjB,GAAI,CACF,MAAMG,EAAUC,EAAAA,aAAaF,EAAM,OAAO,EACpCG,EAAUC,EAAAA,uBAAuBH,CAAO,EAC9C,UAAWI,KAAOF,EAASJ,EAAW,IAAIM,CAAG,CAC/C,MAAQ,CAER,CAGF,GAAIN,EAAW,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E,QAASK,GAAM4B,EAAS,IAAI3B,EAAAA,QAAQN,EAAKK,CAAC,CAAC,CAAC,EAMzE,GAJA2B,EAAeC,EAEfF,EAAenC,EAAkBc,EAASZ,CAAU,EAEhD4B,EAAQ,CACV,MAAMQ,EAAa5B,EAAAA,QAAQ,QAAQ,IAAA,EAAOoB,CAAM,EAChDS,EAAAA,UAAUC,EAAAA,QAAQF,CAAU,EAAG,CAAE,UAAW,GAAM,EAClDG,gBAAcH,EAAYH,EAAc,OAAO,CACjD,CACF,EAEA,UAAUN,EAAY,CACpB,GAAIE,GAAiBF,IAAO/B,EAC1B,OAAOC,CAGX,EAEA,KAAK8B,EAAY,CACf,GAAIA,IAAO9B,EACT,MAAO,kBAAkB,KAAK,UAAUoC,CAAY,CAAC,GAGzD,EAEA,gBAAgB,CAAE,KAAAtB,EAAM,OAAA6B,GAA6C,CAKnE,GAFkBN,GAAc,IAAIvB,CAAI,GAAK,GAM7C,IAFAsB,EAAenC,EAAkBc,EAASZ,CAAU,EAEhD4B,EAAQ,CACV,MAAMQ,EAAa5B,EAAAA,QAAQ,QAAQ,IAAA,EAAOoB,CAAM,EAChDW,gBAAcH,EAAYH,EAAc,OAAO,CACjD,CAEA,GAAIJ,EAAe,CAEjB,MAAMY,EAAaD,EAIbE,EAAMD,EAAW,YAAY,cAAc5C,CAAmB,EAChE6C,GAAKD,EAAW,aAAaC,CAAG,CACtC,EACF,CAAA,CAEJ"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { globSync as I, mkdirSync as w, writeFileSync as g, readFileSync as y } from "node:fs";
|
|
2
|
+
import { resolve as S, dirname as j } from "node:path";
|
|
3
|
+
import { e as V, b, j as L } from "./style-BmyOIMcU.js";
|
|
4
|
+
const R = "virtual:cer-jit-css", m = "\0virtual:cer-jit-css";
|
|
5
|
+
function p(t, r) {
|
|
6
|
+
r && Object.keys(r).length > 0 && V(r);
|
|
7
|
+
const e = process.cwd(), n = [];
|
|
8
|
+
for (const i of t) {
|
|
9
|
+
const o = I(i, { cwd: e }).map((l) => S(e, l));
|
|
10
|
+
n.push(...o);
|
|
11
|
+
}
|
|
12
|
+
const c = [...new Set(n)], d = /* @__PURE__ */ new Set();
|
|
13
|
+
for (const i of c)
|
|
14
|
+
try {
|
|
15
|
+
const o = y(i, "utf-8"), l = b(o);
|
|
16
|
+
for (const s of l) d.add(s);
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
if (d.size === 0) return "";
|
|
20
|
+
const v = `<div class="${[...d].join(" ")}"></div>`;
|
|
21
|
+
return L(v);
|
|
22
|
+
}
|
|
23
|
+
const T = "virtual:cer-ssr-config", C = "\0virtual:cer-ssr-config";
|
|
24
|
+
function D(t) {
|
|
25
|
+
const r = [];
|
|
26
|
+
if (t.content && t.content.length > 0 && r.push(
|
|
27
|
+
_({
|
|
28
|
+
content: t.content,
|
|
29
|
+
output: t.output,
|
|
30
|
+
virtualModule: t.virtualModule,
|
|
31
|
+
extendedColors: t.extendedColors,
|
|
32
|
+
customColors: t.customColors,
|
|
33
|
+
disableVariants: t.disableVariants
|
|
34
|
+
})
|
|
35
|
+
), t.ssr) {
|
|
36
|
+
const e = t.ssr, n = {
|
|
37
|
+
dsd: e.dsd ?? !0,
|
|
38
|
+
dsdPolyfill: e.dsdPolyfill ?? !0,
|
|
39
|
+
...e.jit ? { jit: e.jit } : {}
|
|
40
|
+
};
|
|
41
|
+
r.push({
|
|
42
|
+
name: "cer-ssr-config",
|
|
43
|
+
resolveId(c) {
|
|
44
|
+
if (c === T) return C;
|
|
45
|
+
},
|
|
46
|
+
load(c) {
|
|
47
|
+
if (c === C)
|
|
48
|
+
return `export default ${JSON.stringify(n)};`;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return r;
|
|
53
|
+
}
|
|
54
|
+
function _(t) {
|
|
55
|
+
const {
|
|
56
|
+
content: r,
|
|
57
|
+
output: e,
|
|
58
|
+
virtualModule: n = !0,
|
|
59
|
+
extendedColors: c,
|
|
60
|
+
customColors: d,
|
|
61
|
+
disableVariants: v
|
|
62
|
+
} = t, i = {
|
|
63
|
+
extendedColors: c,
|
|
64
|
+
customColors: d,
|
|
65
|
+
disableVariants: v
|
|
66
|
+
};
|
|
67
|
+
let o = "", l = null;
|
|
68
|
+
return {
|
|
69
|
+
name: "cer-jit-css",
|
|
70
|
+
buildStart() {
|
|
71
|
+
const s = process.cwd(), f = /* @__PURE__ */ new Set();
|
|
72
|
+
for (const a of r)
|
|
73
|
+
I(a, { cwd: s }).forEach((u) => f.add(S(s, u)));
|
|
74
|
+
if (l = f, o = p(r, i), e) {
|
|
75
|
+
const a = S(process.cwd(), e);
|
|
76
|
+
w(j(a), { recursive: !0 }), g(a, o, "utf-8");
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
resolveId(s) {
|
|
80
|
+
if (n && s === R)
|
|
81
|
+
return m;
|
|
82
|
+
},
|
|
83
|
+
load(s) {
|
|
84
|
+
if (s === m)
|
|
85
|
+
return `export default ${JSON.stringify(o)};`;
|
|
86
|
+
},
|
|
87
|
+
handleHotUpdate({ file: s, server: f }) {
|
|
88
|
+
if (l?.has(s) ?? !1) {
|
|
89
|
+
if (o = p(r, i), e) {
|
|
90
|
+
const u = S(process.cwd(), e);
|
|
91
|
+
g(u, o, "utf-8");
|
|
92
|
+
}
|
|
93
|
+
if (n) {
|
|
94
|
+
const u = f, h = u.moduleGraph.getModuleById(m);
|
|
95
|
+
h && u.reloadModule(h);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
_ as cerJITCSS,
|
|
103
|
+
D as cerPlugin
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=custom-elements-runtime.vite-plugin.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-elements-runtime.vite-plugin.es.js","sources":["../src/lib/vite-plugin.ts"],"sourcesContent":["/**\n * Vite plugins for build-time JIT CSS generation and SSR configuration.\n *\n * Two plugins are exported:\n *\n * - **`cerJITCSS`** — Scans source files for utility class names and emits\n * pre-generated CSS, eliminating all runtime parsing cost for projects with\n * static class lists.\n *\n * - **`cerPlugin`** — All-in-one plugin combining `cerJITCSS` with SSR\n * configuration. Exposes a `virtual:cer-ssr-config` module containing the\n * resolved SSR render options so server entry files can import and use them\n * without duplication.\n *\n * @example cerJITCSS only\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { cerJITCSS } from '@jasonshimmy/custom-elements-runtime/vite-plugin';\n *\n * export default defineConfig({\n * plugins: [\n * cerJITCSS({\n * content: ['./src/**\\/*.{ts,tsx,html}'],\n * output: 'src/generated-jit.css',\n * extendedColors: true,\n * }),\n * ],\n * });\n * ```\n *\n * @example cerPlugin with SSR\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite';\n * import { cerPlugin } from '@jasonshimmy/custom-elements-runtime/vite-plugin';\n *\n * export default defineConfig({\n * plugins: [\n * cerPlugin({\n * content: ['./src/**\\/*.{ts,tsx,html}'],\n * ssr: {\n * dsd: true,\n * jit: { extendedColors: true },\n * },\n * }),\n * ],\n * });\n * ```\n *\n * Then in your server entry:\n * ```ts\n * import ssrConfig from 'virtual:cer-ssr-config';\n * import { renderToStringWithJITCSS } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, ssrConfig);\n * ```\n */\n\nimport type { Plugin } from 'vite';\nimport { readFileSync, writeFileSync, mkdirSync, globSync } from 'node:fs';\nimport { resolve, dirname } from 'node:path';\nimport {\n jitCSS,\n enableJITCSS,\n extractClassesFromHTML,\n type JITCSSOptions,\n} from './runtime/style';\n\n// --- Re-export extractClassesFromHTML for plugin consumers ---\n\n/**\n * Options for the `cerJITCSS` Vite plugin.\n */\nexport interface CerJITCSSPluginOptions extends JITCSSOptions {\n /**\n * Glob patterns (relative to `process.cwd()`) that identify which source\n * files the plugin should scan for utility class names.\n *\n * @example `['./src/**\\/*.{ts,html}', './index.html']`\n */\n content: string[];\n /**\n * File path (relative to `process.cwd()`) where the generated CSS will\n * be written. When omitted the plugin only emits a virtual module.\n */\n output?: string;\n /**\n * Whether to emit a virtual module `virtual:cer-jit-css` that resolves to\n * the generated CSS text. Defaults to `true`.\n */\n virtualModule?: boolean;\n}\n\nconst VIRTUAL_ID = 'virtual:cer-jit-css';\nconst RESOLVED_VIRTUAL_ID = '\\0virtual:cer-jit-css';\n\nfunction generateFromFiles(\n contentPatterns: string[],\n jitOptions: JITCSSOptions,\n): string {\n if (jitOptions && Object.keys(jitOptions).length > 0) {\n enableJITCSS(jitOptions);\n }\n\n const cwd = process.cwd();\n const files: string[] = [];\n\n for (const pattern of contentPatterns) {\n const matches = globSync(pattern, { cwd }).map((f) => resolve(cwd, f));\n files.push(...matches);\n }\n\n // Deduplicate files\n const uniqueFiles = [...new Set(files)];\n\n // Aggregate all class names across all files\n const allClasses = new Set<string>();\n\n for (const file of uniqueFiles) {\n try {\n const content = readFileSync(file, 'utf-8');\n const classes = extractClassesFromHTML(content);\n for (const cls of classes) allClasses.add(cls);\n } catch {\n // Skip unreadable files\n }\n }\n\n if (allClasses.size === 0) return '';\n\n // Build a fake HTML string containing all discovered classes so jitCSS()\n // can process the full set in one pass.\n const fakeHTML = `<div class=\"${[...allClasses].join(' ')}\"></div>`;\n return jitCSS(fakeHTML);\n}\n\n// ---------------------------------------------------------------------------\n// cerPlugin — combined JIT CSS + SSR configuration plugin\n// ---------------------------------------------------------------------------\n\n/**\n * SSR render options exposed via `virtual:cer-ssr-config`.\n */\nexport interface CerSSROptions {\n /**\n * Emit Declarative Shadow DOM output for registered custom elements.\n * @default true\n */\n dsd?: boolean;\n /**\n * Append the DSD polyfill `<script>` for browsers without native support.\n * @default true\n */\n dsdPolyfill?: boolean;\n /**\n * JIT CSS options forwarded to the SSR render pass.\n */\n jit?: JITCSSOptions;\n}\n\n/**\n * Options for the combined {@link cerPlugin}.\n */\nexport interface CerPluginOptions extends Partial<CerJITCSSPluginOptions> {\n /**\n * SSR configuration. When provided, a `virtual:cer-ssr-config` module is\n * registered so server entry files can import the resolved render options:\n *\n * ```ts\n * import ssrConfig from 'virtual:cer-ssr-config';\n * import { renderToStringWithJITCSS } from '@jasonshimmy/custom-elements-runtime/ssr';\n *\n * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, ssrConfig);\n * ```\n */\n ssr?: CerSSROptions;\n}\n\nconst VIRTUAL_SSR_ID = 'virtual:cer-ssr-config';\nconst RESOLVED_VIRTUAL_SSR_ID = '\\0virtual:cer-ssr-config';\n\n/**\n * All-in-one Vite plugin combining build-time JIT CSS generation with SSR\n * configuration. Returns an array of plugins so it can be spread directly\n * into the `plugins` array without nesting.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * export default defineConfig({\n * plugins: [\n * cerPlugin({\n * content: ['./src/**\\/*.{ts,html}'],\n * ssr: { dsd: true, jit: { extendedColors: true } },\n * }),\n * ],\n * });\n * ```\n */\nexport function cerPlugin(options: CerPluginOptions): Plugin[] {\n const plugins: Plugin[] = [];\n\n // JIT CSS plugin — only added when a `content` glob is provided\n if (options.content && options.content.length > 0) {\n plugins.push(\n cerJITCSS({\n content: options.content,\n output: options.output,\n virtualModule: options.virtualModule,\n extendedColors: options.extendedColors,\n customColors: options.customColors,\n disableVariants: options.disableVariants,\n }),\n );\n }\n\n // SSR config virtual module — registered whenever `ssr` is provided\n if (options.ssr) {\n const ssrConfig = options.ssr;\n const resolvedConfig = {\n dsd: ssrConfig.dsd ?? true,\n dsdPolyfill: ssrConfig.dsdPolyfill ?? true,\n ...(ssrConfig.jit ? { jit: ssrConfig.jit } : {}),\n };\n\n plugins.push({\n name: 'cer-ssr-config',\n resolveId(id: string) {\n if (id === VIRTUAL_SSR_ID) return RESOLVED_VIRTUAL_SSR_ID;\n return undefined;\n },\n load(id: string) {\n if (id === RESOLVED_VIRTUAL_SSR_ID) {\n return `export default ${JSON.stringify(resolvedConfig)};`;\n }\n return undefined;\n },\n });\n }\n\n return plugins;\n}\n\n// ---------------------------------------------------------------------------\n// cerJITCSS — build-time JIT CSS plugin\n// ---------------------------------------------------------------------------\n\n/**\n * Vite plugin that performs a build-time scan of source files and emits\n * pre-generated JIT CSS as a file and/or `virtual:cer-jit-css` module.\n */\nexport function cerJITCSS(options: CerJITCSSPluginOptions): Plugin {\n const {\n content,\n output,\n virtualModule = true,\n extendedColors,\n customColors,\n disableVariants,\n } = options;\n\n const jitOptions: JITCSSOptions = {\n extendedColors,\n customColors,\n disableVariants,\n };\n\n let generatedCSS = '';\n // Resolved file set built in buildStart and reused in handleHotUpdate to\n // avoid re-running globSync for every HMR file-change event.\n let watchedFiles: Set<string> | null = null;\n\n return {\n name: 'cer-jit-css',\n\n buildStart() {\n const cwd = process.cwd();\n const resolved = new Set<string>();\n for (const pattern of content) {\n globSync(pattern, { cwd }).forEach((f) => resolved.add(resolve(cwd, f)));\n }\n watchedFiles = resolved;\n\n generatedCSS = generateFromFiles(content, jitOptions);\n\n if (output) {\n const outputPath = resolve(process.cwd(), output);\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, generatedCSS, 'utf-8');\n }\n },\n\n resolveId(id: string) {\n if (virtualModule && id === VIRTUAL_ID) {\n return RESOLVED_VIRTUAL_ID;\n }\n return undefined;\n },\n\n load(id: string) {\n if (id === RESOLVED_VIRTUAL_ID) {\n return `export default ${JSON.stringify(generatedCSS)};`;\n }\n return undefined;\n },\n\n handleHotUpdate({ file, server }: { file: string; server: unknown }) {\n // Re-generate when a watched source file changes.\n // Use the cached file set from buildStart to avoid re-globbing.\n const isWatched = watchedFiles?.has(file) ?? false;\n\n if (!isWatched) return;\n\n generatedCSS = generateFromFiles(content, jitOptions);\n\n if (output) {\n const outputPath = resolve(process.cwd(), output);\n writeFileSync(outputPath, generatedCSS, 'utf-8');\n }\n\n if (virtualModule) {\n // Invalidate the virtual module so HMR triggers a reload\n const viteServer = server as {\n moduleGraph: { getModuleById: (id: string) => unknown };\n reloadModule: (mod: unknown) => void;\n };\n const mod = viteServer.moduleGraph.getModuleById(RESOLVED_VIRTUAL_ID);\n if (mod) viteServer.reloadModule(mod);\n }\n },\n };\n}\n"],"names":["VIRTUAL_ID","RESOLVED_VIRTUAL_ID","generateFromFiles","contentPatterns","jitOptions","enableJITCSS","cwd","files","pattern","matches","globSync","f","resolve","uniqueFiles","allClasses","file","content","readFileSync","classes","extractClassesFromHTML","cls","fakeHTML","jitCSS","VIRTUAL_SSR_ID","RESOLVED_VIRTUAL_SSR_ID","cerPlugin","options","plugins","cerJITCSS","ssrConfig","resolvedConfig","id","output","virtualModule","extendedColors","customColors","disableVariants","generatedCSS","watchedFiles","resolved","outputPath","mkdirSync","dirname","writeFileSync","server","viteServer","mod"],"mappings":";;;AA8FA,MAAMA,IAAa,uBACbC,IAAsB;AAE5B,SAASC,EACPC,GACAC,GACQ;AACR,EAAIA,KAAc,OAAO,KAAKA,CAAU,EAAE,SAAS,KACjDC,EAAaD,CAAU;AAGzB,QAAME,IAAM,QAAQ,IAAA,GACdC,IAAkB,CAAA;AAExB,aAAWC,KAAWL,GAAiB;AACrC,UAAMM,IAAUC,EAASF,GAAS,EAAE,KAAAF,EAAA,CAAK,EAAE,IAAI,CAACK,MAAMC,EAAQN,GAAKK,CAAC,CAAC;AACrE,IAAAJ,EAAM,KAAK,GAAGE,CAAO;AAAA,EACvB;AAGA,QAAMI,IAAc,CAAC,GAAG,IAAI,IAAIN,CAAK,CAAC,GAGhCO,wBAAiB,IAAA;AAEvB,aAAWC,KAAQF;AACjB,QAAI;AACF,YAAMG,IAAUC,EAAaF,GAAM,OAAO,GACpCG,IAAUC,EAAuBH,CAAO;AAC9C,iBAAWI,KAAOF,EAAS,CAAAJ,EAAW,IAAIM,CAAG;AAAA,IAC/C,QAAQ;AAAA,IAER;AAGF,MAAIN,EAAW,SAAS,EAAG,QAAO;AAIlC,QAAMO,IAAW,eAAe,CAAC,GAAGP,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class changes and injects utility CSS into
|
|
5
|
+
* a shared `<style>` element (or constructable stylesheet) in the host document.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createDOMJITCSS } from '@jasonshimmy/custom-elements-runtime/dom-jit-css';
|
|
10
|
+
*
|
|
11
|
+
* // Watch the full document body
|
|
12
|
+
* const jit = createDOMJITCSS();
|
|
13
|
+
* jit.mount();
|
|
14
|
+
*
|
|
15
|
+
* // Watch a specific container element
|
|
16
|
+
* const jit = createDOMJITCSS({ root: document.getElementById('app')! });
|
|
17
|
+
* jit.mount();
|
|
18
|
+
*
|
|
19
|
+
* // Tear down when no longer needed
|
|
20
|
+
* jit.destroy();
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ## `data-jitcss` attribute semantics
|
|
24
|
+
*
|
|
25
|
+
* | Attribute value | Behaviour |
|
|
26
|
+
* | ------------------------------------------------------ | ----------------------------------------------------------------- |
|
|
27
|
+
* | `data-jitcss` (no value) or `data-jitcss="container"` | Scopes the observer to that element and its subtree |
|
|
28
|
+
* | `data-jitcss="self"` | Only processes classes on that exact element, not descendants |
|
|
29
|
+
* | `data-jitcss="global"` | Observer covers `document.body` (useful on `<html>` or `<body>`) |
|
|
30
|
+
*
|
|
31
|
+
* When `createDOMJITCSS()` is called with no `root`, it auto-detects all
|
|
32
|
+
* `[data-jitcss]` elements and registers an observer for each.
|
|
33
|
+
*/
|
|
34
|
+
import { type JITCSSOptions } from './runtime/style';
|
|
35
|
+
/**
|
|
36
|
+
* Options for `createDOMJITCSS()`.
|
|
37
|
+
*/
|
|
38
|
+
export interface DOMJITCSSOptions extends JITCSSOptions {
|
|
39
|
+
/**
|
|
40
|
+
* The root element to observe. Defaults to auto-detecting `[data-jitcss]`
|
|
41
|
+
* elements, then falling back to `document.body`.
|
|
42
|
+
*/
|
|
43
|
+
root?: Element | ShadowRoot | null;
|
|
44
|
+
/**
|
|
45
|
+
* ID of the `<style>` element injected into the document head.
|
|
46
|
+
* Defaults to `'cer-dom-jit-css'`.
|
|
47
|
+
*/
|
|
48
|
+
styleId?: string;
|
|
49
|
+
}
|
|
50
|
+
/** Public handle returned by `createDOMJITCSS()`. */
|
|
51
|
+
export interface DOMJITCSSHandle {
|
|
52
|
+
/** Start observing the DOM and injecting utility CSS. */
|
|
53
|
+
mount(): void;
|
|
54
|
+
/** Stop observing and remove the injected stylesheet. */
|
|
55
|
+
destroy(): void;
|
|
56
|
+
/** Get the number of unique classes processed so far. */
|
|
57
|
+
readonly processedCount: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a DOM JIT CSS instance that watches class attribute changes and
|
|
61
|
+
* injects CSS utility rules into the document.
|
|
62
|
+
*
|
|
63
|
+
* @param options - Configuration options.
|
|
64
|
+
* @returns A handle with `mount()` and `destroy()` methods.
|
|
65
|
+
*/
|
|
66
|
+
export declare function createDOMJITCSS(options?: DOMJITCSSOptions): DOMJITCSSHandle;
|
package/dist/event-bus.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare class GlobalEventBus extends EventTarget {
|
|
|
10
10
|
private handlers;
|
|
11
11
|
private static instance;
|
|
12
12
|
private eventCounters;
|
|
13
|
+
private nativeUnsubscribers;
|
|
14
|
+
private readonly MAX_EVENT_COUNTERS;
|
|
13
15
|
/**
|
|
14
16
|
* Returns the singleton instance of GlobalEventBus
|
|
15
17
|
*/
|
|
@@ -62,7 +64,7 @@ export declare class GlobalEventBus extends EventTarget {
|
|
|
62
64
|
*/
|
|
63
65
|
getActiveEvents(): string[];
|
|
64
66
|
/**
|
|
65
|
-
* Clear all event handlers (useful for testing or cleanup).
|
|
67
|
+
* Clear all event handlers and native EventTarget listeners (useful for testing or cleanup).
|
|
66
68
|
*/
|
|
67
69
|
clear(): void;
|
|
68
70
|
/**
|