@jasonshimmy/custom-elements-runtime 3.0.0 → 3.1.1

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 (68) hide show
  1. package/README.md +118 -81
  2. package/dist/custom-elements-runtime.cjs.js +3 -3
  3. package/dist/custom-elements-runtime.cjs.js.map +1 -1
  4. package/dist/custom-elements-runtime.es.js +77 -72
  5. package/dist/custom-elements-runtime.es.js.map +1 -1
  6. package/dist/custom-elements-runtime.jit-css.cjs.js +1 -1
  7. package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -1
  8. package/dist/custom-elements-runtime.jit-css.es.js +25 -26
  9. package/dist/custom-elements-runtime.jit-css.es.js.map +1 -1
  10. package/dist/custom-elements-runtime.router.cjs.js +8 -8
  11. package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
  12. package/dist/custom-elements-runtime.router.es.js +134 -134
  13. package/dist/custom-elements-runtime.router.es.js.map +1 -1
  14. package/dist/custom-elements-runtime.ssr-middleware.cjs.js +2 -0
  15. package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -0
  16. package/dist/custom-elements-runtime.ssr-middleware.es.js +69 -0
  17. package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -0
  18. package/dist/custom-elements-runtime.ssr.cjs.js +3 -1
  19. package/dist/custom-elements-runtime.ssr.cjs.js.map +1 -1
  20. package/dist/custom-elements-runtime.ssr.es.js +158 -39
  21. package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
  22. package/dist/custom-elements-runtime.vite-plugin.cjs.js +1 -1
  23. package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -1
  24. package/dist/custom-elements-runtime.vite-plugin.es.js +81 -49
  25. package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -1
  26. package/dist/hooks-x8M4knLc.cjs +6 -0
  27. package/dist/hooks-x8M4knLc.cjs.map +1 -0
  28. package/dist/hooks-xWZhQHco.js +1465 -0
  29. package/dist/hooks-xWZhQHco.js.map +1 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/namespace-helpers-D4wC2-qA.js +61 -0
  32. package/dist/namespace-helpers-D4wC2-qA.js.map +1 -0
  33. package/dist/namespace-helpers-ckeEOxpR.cjs +2 -0
  34. package/dist/namespace-helpers-ckeEOxpR.cjs.map +1 -0
  35. package/dist/router/matcher.d.ts +14 -0
  36. package/dist/runtime/component/factory.d.ts +16 -2
  37. package/dist/runtime/hydration.d.ts +33 -0
  38. package/dist/runtime/render.d.ts +0 -11
  39. package/dist/runtime/scheduler.d.ts +12 -0
  40. package/dist/runtime/ssr-context.d.ts +47 -0
  41. package/dist/runtime/ssr-utils.d.ts +9 -0
  42. package/dist/runtime/types.d.ts +18 -0
  43. package/dist/runtime/vdom-ssr-dsd.d.ts +82 -0
  44. package/dist/runtime/vdom-ssr.d.ts +2 -6
  45. package/dist/ssr-middleware.d.ts +125 -0
  46. package/dist/ssr.d.ts +95 -33
  47. package/dist/template-compiler-CTUhEHr8.cjs +22 -0
  48. package/dist/template-compiler-CTUhEHr8.cjs.map +1 -0
  49. package/dist/template-compiler-ZhSg1yPh.js +3724 -0
  50. package/dist/template-compiler-ZhSg1yPh.js.map +1 -0
  51. package/dist/vite-plugin.d.ts +94 -4
  52. package/package.json +6 -1
  53. package/dist/helpers-CweFZFWU.js +0 -987
  54. package/dist/helpers-CweFZFWU.js.map +0 -1
  55. package/dist/helpers-DeWjSmOl.cjs +0 -5
  56. package/dist/helpers-DeWjSmOl.cjs.map +0 -1
  57. package/dist/hooks-BrrLKSub.cjs +0 -3
  58. package/dist/hooks-BrrLKSub.cjs.map +0 -1
  59. package/dist/hooks-DyShDHKo.js +0 -403
  60. package/dist/hooks-DyShDHKo.js.map +0 -1
  61. package/dist/namespace-helpers-CnpZ5__p.js +0 -45
  62. package/dist/namespace-helpers-CnpZ5__p.js.map +0 -1
  63. package/dist/namespace-helpers-CyIDtI97.cjs +0 -2
  64. package/dist/namespace-helpers-CyIDtI97.cjs.map +0 -1
  65. package/dist/template-compiler-B5uN1EQw.js +0 -3731
  66. package/dist/template-compiler-B5uN1EQw.js.map +0 -1
  67. package/dist/template-compiler-Cx623BSB.cjs +0 -23
  68. package/dist/template-compiler-Cx623BSB.cjs.map +0 -1
@@ -1,10 +1,18 @@
1
1
  /**
2
- * Vite plugin for build-time JIT CSS generation.
2
+ * Vite plugins for build-time JIT CSS generation and SSR configuration.
3
3
  *
4
- * Scans source files for utility class names and emits pre-generated CSS,
5
- * eliminating all runtime parsing cost for projects with static class lists.
4
+ * Two plugins are exported:
6
5
  *
7
- * @example
6
+ * - **`cerJITCSS`** — Scans source files for utility class names and emits
7
+ * pre-generated CSS, eliminating all runtime parsing cost for projects with
8
+ * static class lists.
9
+ *
10
+ * - **`cerPlugin`** — All-in-one plugin combining `cerJITCSS` with SSR
11
+ * configuration. Exposes a `virtual:cer-ssr-config` module containing the
12
+ * resolved SSR render options so server entry files can import and use them
13
+ * without duplication.
14
+ *
15
+ * @example cerJITCSS only
8
16
  * ```ts
9
17
  * // vite.config.ts
10
18
  * import { defineConfig } from 'vite';
@@ -20,6 +28,33 @@
20
28
  * ],
21
29
  * });
22
30
  * ```
31
+ *
32
+ * @example cerPlugin with SSR
33
+ * ```ts
34
+ * // vite.config.ts
35
+ * import { defineConfig } from 'vite';
36
+ * import { cerPlugin } from '@jasonshimmy/custom-elements-runtime/vite-plugin';
37
+ *
38
+ * export default defineConfig({
39
+ * plugins: [
40
+ * cerPlugin({
41
+ * content: ['./src/**\/*.{ts,tsx,html}'],
42
+ * ssr: {
43
+ * dsd: true,
44
+ * jit: { extendedColors: true },
45
+ * },
46
+ * }),
47
+ * ],
48
+ * });
49
+ * ```
50
+ *
51
+ * Then in your server entry:
52
+ * ```ts
53
+ * import ssrConfig from 'virtual:cer-ssr-config';
54
+ * import { renderToStringWithJITCSS } from '@jasonshimmy/custom-elements-runtime/ssr';
55
+ *
56
+ * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, ssrConfig);
57
+ * ```
23
58
  */
24
59
  import type { Plugin } from 'vite';
25
60
  import { type JITCSSOptions } from './runtime/style';
@@ -45,6 +80,61 @@ export interface CerJITCSSPluginOptions extends JITCSSOptions {
45
80
  */
46
81
  virtualModule?: boolean;
47
82
  }
83
+ /**
84
+ * SSR render options exposed via `virtual:cer-ssr-config`.
85
+ */
86
+ export interface CerSSROptions {
87
+ /**
88
+ * Emit Declarative Shadow DOM output for registered custom elements.
89
+ * @default true
90
+ */
91
+ dsd?: boolean;
92
+ /**
93
+ * Append the DSD polyfill `<script>` for browsers without native support.
94
+ * @default true
95
+ */
96
+ dsdPolyfill?: boolean;
97
+ /**
98
+ * JIT CSS options forwarded to the SSR render pass.
99
+ */
100
+ jit?: JITCSSOptions;
101
+ }
102
+ /**
103
+ * Options for the combined {@link cerPlugin}.
104
+ */
105
+ export interface CerPluginOptions extends Partial<CerJITCSSPluginOptions> {
106
+ /**
107
+ * SSR configuration. When provided, a `virtual:cer-ssr-config` module is
108
+ * registered so server entry files can import the resolved render options:
109
+ *
110
+ * ```ts
111
+ * import ssrConfig from 'virtual:cer-ssr-config';
112
+ * import { renderToStringWithJITCSS } from '@jasonshimmy/custom-elements-runtime/ssr';
113
+ *
114
+ * const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, ssrConfig);
115
+ * ```
116
+ */
117
+ ssr?: CerSSROptions;
118
+ }
119
+ /**
120
+ * All-in-one Vite plugin combining build-time JIT CSS generation with SSR
121
+ * configuration. Returns an array of plugins so it can be spread directly
122
+ * into the `plugins` array without nesting.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * // vite.config.ts
127
+ * export default defineConfig({
128
+ * plugins: [
129
+ * cerPlugin({
130
+ * content: ['./src/**\/*.{ts,html}'],
131
+ * ssr: { dsd: true, jit: { extendedColors: true } },
132
+ * }),
133
+ * ],
134
+ * });
135
+ * ```
136
+ */
137
+ export declare function cerPlugin(options: CerPluginOptions): Plugin[];
48
138
  /**
49
139
  * Vite plugin that performs a build-time scan of source files and emits
50
140
  * pre-generated JIT CSS as a file and/or `virtual:cer-jit-css` module.
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": "3.0.0",
4
+ "version": "3.1.1",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "web-components",
@@ -164,6 +164,11 @@
164
164
  "types": "./dist/vite-plugin.d.ts",
165
165
  "import": "./dist/custom-elements-runtime.vite-plugin.es.js",
166
166
  "require": "./dist/custom-elements-runtime.vite-plugin.cjs.js"
167
+ },
168
+ "./ssr-middleware": {
169
+ "types": "./dist/ssr-middleware.d.ts",
170
+ "import": "./dist/custom-elements-runtime.ssr-middleware.es.js",
171
+ "require": "./dist/custom-elements-runtime.ssr-middleware.cjs.js"
167
172
  }
168
173
  },
169
174
  "publishConfig": {