@jasonshimmy/custom-elements-runtime 3.4.0 → 3.6.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 +28 -7
- package/dist/css-utils-Bn-dO44e.js +203 -0
- package/dist/{css-utils-CC43BbEy.js.map → css-utils-Bn-dO44e.js.map} +1 -1
- package/dist/{css-utils-CC43BbEy.js → css-utils-CFeP8SK1.cjs} +5 -71
- package/dist/{css-utils-mgjmH8qX.cjs.map → css-utils-CFeP8SK1.cjs.map} +1 -1
- package/dist/custom-elements-runtime.cjs.js +3 -4
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.colors.cjs.js +1 -2
- package/dist/custom-elements-runtime.colors.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.colors.es.js +277 -277
- package/dist/custom-elements-runtime.colors.es.js.map +1 -1
- package/dist/custom-elements-runtime.directive-enhancements.cjs.js +1 -2
- package/dist/custom-elements-runtime.directive-enhancements.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.directive-enhancements.es.js +106 -122
- package/dist/custom-elements-runtime.directive-enhancements.es.js.map +1 -1
- package/dist/custom-elements-runtime.directives.cjs.js +1 -2
- package/dist/custom-elements-runtime.directives.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.directives.es.js +60 -65
- package/dist/custom-elements-runtime.directives.es.js.map +1 -1
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js +1 -7
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.dom-jit-css.es.js +103 -115
- package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -1
- package/dist/custom-elements-runtime.es.js +206 -253
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js +1 -2
- package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.es.js +102 -108
- package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
- package/dist/custom-elements-runtime.jit-css.cjs.js +1 -2
- package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.jit-css.es.js +14 -32
- package/dist/custom-elements-runtime.jit-css.es.js.map +1 -1
- package/dist/custom-elements-runtime.router.cjs.js +20 -21
- package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.router.es.js +866 -926
- package/dist/custom-elements-runtime.router.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js +3 -4
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.es.js +67 -73
- package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
- package/dist/custom-elements-runtime.ssr.es.js +3 -14
- package/dist/custom-elements-runtime.store.cjs.js +1 -2
- package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.store.es.js +32 -33
- package/dist/custom-elements-runtime.store.es.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.cjs.js +1 -2
- package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.es.js +200 -210
- package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
- package/dist/custom-elements-runtime.vite-plugin.cjs.js +4 -2
- package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.vite-plugin.es.js +155 -78
- package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -1
- package/dist/helpers-7zLtbh_q.cjs +5 -0
- package/dist/helpers-7zLtbh_q.cjs.map +1 -0
- package/dist/helpers-kOWgceUQ.js +696 -0
- package/dist/helpers-kOWgceUQ.js.map +1 -0
- package/dist/hooks-BY_35J9Y.cjs +2 -0
- package/dist/hooks-BY_35J9Y.cjs.map +1 -0
- package/dist/hooks-Dj1xwqpK.js +407 -0
- package/dist/hooks-Dj1xwqpK.js.map +1 -0
- package/dist/logger-DIJ0UH3R.js +36 -0
- package/dist/{logger-L25axmB-.js.map → logger-DIJ0UH3R.js.map} +1 -1
- package/dist/logger-Dkht1dCX.cjs +2 -0
- package/dist/{logger-BYIN7ysT.cjs.map → logger-Dkht1dCX.cjs.map} +1 -1
- package/dist/namespace-helpers-CIUkG8Mn.js +56 -0
- package/dist/{namespace-helpers-BucDdgz_.js.map → namespace-helpers-CIUkG8Mn.js.map} +1 -1
- package/dist/namespace-helpers-yYIb7INq.cjs +2 -0
- package/dist/{namespace-helpers-Bf7rm9JV.cjs.map → namespace-helpers-yYIb7INq.cjs.map} +1 -1
- package/dist/runtime/tag-utils.d.ts +11 -0
- package/dist/ssr-Bg9jYXYv.js +171 -0
- package/dist/{ssr-H9GDwbTy.js.map → ssr-Bg9jYXYv.js.map} +1 -1
- package/dist/ssr-CucZ-Iwz.cjs +4 -0
- package/dist/{ssr-DRsGduIK.cjs.map → ssr-CucZ-Iwz.cjs.map} +1 -1
- package/dist/ssr.d.ts +2 -0
- package/dist/style-A8l3aQ52.cjs +55 -0
- package/dist/{style-Bjn8zDiZ.cjs.map → style-A8l3aQ52.cjs.map} +1 -1
- package/dist/style-DSSoCbC9.js +1877 -0
- package/dist/{style-DuDoj_xK.js.map → style-DSSoCbC9.js.map} +1 -1
- package/dist/tag-utils-Dg0vRKq9.js +10 -0
- package/dist/tag-utils-Dg0vRKq9.js.map +1 -0
- package/dist/tag-utils-ZOoyzCm9.cjs +2 -0
- package/dist/tag-utils-ZOoyzCm9.cjs.map +1 -0
- package/dist/template-compiler-BJRZoRzZ.js +3044 -0
- package/dist/{template-compiler-Cs5axmn4.js.map → template-compiler-BJRZoRzZ.js.map} +1 -1
- package/dist/template-compiler-C0SkzB_f.cjs +19 -0
- package/dist/{template-compiler-BB4JJdqk.cjs.map → template-compiler-C0SkzB_f.cjs.map} +1 -1
- package/dist/vite-plugin.d.ts +96 -2
- package/package.json +8 -8
- package/dist/css-utils-mgjmH8qX.cjs +0 -577
- package/dist/hooks-_3xP4G2N.js +0 -1189
- package/dist/hooks-_3xP4G2N.js.map +0 -1
- package/dist/hooks-fYQgZk2g.cjs +0 -7
- package/dist/hooks-fYQgZk2g.cjs.map +0 -1
- package/dist/logger-BYIN7ysT.cjs +0 -3
- package/dist/logger-L25axmB-.js +0 -41
- package/dist/namespace-helpers-Bf7rm9JV.cjs +0 -3
- package/dist/namespace-helpers-BucDdgz_.js +0 -61
- package/dist/ssr-DRsGduIK.cjs +0 -5
- package/dist/ssr-H9GDwbTy.js +0 -172
- package/dist/style-Bjn8zDiZ.cjs +0 -56
- package/dist/style-DuDoj_xK.js +0 -1972
- package/dist/template-compiler-BB4JJdqk.cjs +0 -23
- package/dist/template-compiler-Cs5axmn4.js +0 -3236
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vite plugins for build-time JIT CSS generation
|
|
2
|
+
* Vite plugins for build-time JIT CSS generation, SSR configuration, and
|
|
3
|
+
* per-page component code splitting.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
+
* Three plugins are exported:
|
|
5
6
|
*
|
|
6
7
|
* - **`cerJITCSS`** — Scans source files for utility class names and emits
|
|
7
8
|
* pre-generated CSS, eliminating all runtime parsing cost for projects with
|
|
@@ -12,6 +13,18 @@
|
|
|
12
13
|
* resolved SSR render options so server entry files can import and use them
|
|
13
14
|
* without duplication.
|
|
14
15
|
*
|
|
16
|
+
* - **`cerComponentImports`** — Transform plugin that scans each app file for
|
|
17
|
+
* custom element tags used in `html\`` template literals and injects static
|
|
18
|
+
* `import` statements pointing to the corresponding component source files.
|
|
19
|
+
* This gives Rollup the module graph edges it needs to automatically
|
|
20
|
+
* code-split components per page chunk.
|
|
21
|
+
*
|
|
22
|
+
* Three build-time utilities are also exported:
|
|
23
|
+
*
|
|
24
|
+
* - **`resolveTagName`** — Normalize a component name to its registered tag name.
|
|
25
|
+
* - **`extractTemplateTagNames`** — Extract hyphenated tag names from `html\`` sources.
|
|
26
|
+
* - **`extractComponentRegistrations`** — Extract registered tag names from `component()` calls.
|
|
27
|
+
*
|
|
15
28
|
* @example cerJITCSS only
|
|
16
29
|
* ```ts
|
|
17
30
|
* // vite.config.ts
|
|
@@ -55,9 +68,26 @@
|
|
|
55
68
|
*
|
|
56
69
|
* const { htmlWithStyles } = renderToStringWithJITCSS(appVNode, ssrConfig);
|
|
57
70
|
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example cerComponentImports for per-page code splitting
|
|
73
|
+
* ```ts
|
|
74
|
+
* // vite.config.ts
|
|
75
|
+
* import { defineConfig } from 'vite';
|
|
76
|
+
* import { cerComponentImports } from '@jasonshimmy/custom-elements-runtime/vite-plugin';
|
|
77
|
+
*
|
|
78
|
+
* export default defineConfig({
|
|
79
|
+
* plugins: [
|
|
80
|
+
* cerComponentImports({
|
|
81
|
+
* componentsDir: '/absolute/path/to/app/components',
|
|
82
|
+
* appRoot: '/absolute/path/to/app',
|
|
83
|
+
* }),
|
|
84
|
+
* ],
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
58
87
|
*/
|
|
59
88
|
import type { Plugin } from 'vite';
|
|
60
89
|
import { type JITCSSOptions } from './runtime/style';
|
|
90
|
+
import { resolveTagName as _resolveTagName } from './runtime/tag-utils';
|
|
61
91
|
/**
|
|
62
92
|
* Options for the `cerJITCSS` Vite plugin.
|
|
63
93
|
*/
|
|
@@ -140,3 +170,67 @@ export declare function cerPlugin(options: CerPluginOptions): Plugin[];
|
|
|
140
170
|
* pre-generated JIT CSS as a file and/or `virtual:cer-jit-css` module.
|
|
141
171
|
*/
|
|
142
172
|
export declare function cerJITCSS(options: CerJITCSSPluginOptions): Plugin;
|
|
173
|
+
/**
|
|
174
|
+
* Resolves a component() tag argument to the actual registered tag name.
|
|
175
|
+
* Re-exported from runtime/tag-utils so consumers have a single import surface.
|
|
176
|
+
*
|
|
177
|
+
* Rules:
|
|
178
|
+
* camelCase → kebab-case (myButton → my-button)
|
|
179
|
+
* no hyphen → cer- prefix (app → cer-app)
|
|
180
|
+
* has hyphen → unchanged (ks-badge → ks-badge)
|
|
181
|
+
*/
|
|
182
|
+
export declare const resolveTagName: typeof _resolveTagName;
|
|
183
|
+
/**
|
|
184
|
+
* Scan TypeScript source text for all custom element tag names referenced
|
|
185
|
+
* in html`` template literals.
|
|
186
|
+
*
|
|
187
|
+
* Strips line (//) and block (/* *\/) comments first to avoid false
|
|
188
|
+
* positives from commented-out code.
|
|
189
|
+
*
|
|
190
|
+
* Returns a Set of already-hyphenated tag names as they appear in the source
|
|
191
|
+
* (e.g. "ks-badge", "cer-app"). Single-word names that would receive a
|
|
192
|
+
* "cer-" prefix at runtime never appear as bare tags in templates — they
|
|
193
|
+
* always appear as "cer-something" — so no normalization is needed here.
|
|
194
|
+
*
|
|
195
|
+
* Closing tags (</ks-badge>) do NOT match because the regex requires the
|
|
196
|
+
* first character after < to be [a-z], not /.
|
|
197
|
+
*/
|
|
198
|
+
export declare function extractTemplateTagNames(source: string): Set<string>;
|
|
199
|
+
/**
|
|
200
|
+
* Extract all component tag names registered in a component source file.
|
|
201
|
+
* Handles files that call component() more than once (returns all of them).
|
|
202
|
+
*
|
|
203
|
+
* Uses \bcomponent\( so it matches the standalone function name but not
|
|
204
|
+
* names like importComponent( or registerComponent(.
|
|
205
|
+
*
|
|
206
|
+
* Returns resolved (normalized) tag names, ready to match against the output
|
|
207
|
+
* of extractTemplateTagNames().
|
|
208
|
+
*/
|
|
209
|
+
export declare function extractComponentRegistrations(source: string): string[];
|
|
210
|
+
/**
|
|
211
|
+
* Options for the {@link cerComponentImports} Vite plugin.
|
|
212
|
+
*/
|
|
213
|
+
export interface CerComponentImportsOptions {
|
|
214
|
+
/**
|
|
215
|
+
* Absolute path to the directory containing component files.
|
|
216
|
+
* Every .ts file found here is scanned for component() registrations.
|
|
217
|
+
*/
|
|
218
|
+
componentsDir: string;
|
|
219
|
+
/**
|
|
220
|
+
* Absolute path to the app source root. The transform is restricted to
|
|
221
|
+
* files under this directory so node_modules and generated files are skipped.
|
|
222
|
+
*/
|
|
223
|
+
appRoot: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Vite plugin that injects static `import` statements for custom element
|
|
227
|
+
* components used in each page/layout/component file.
|
|
228
|
+
*
|
|
229
|
+
* Replaces the eager `virtual:cer-components` side-effect import with
|
|
230
|
+
* per-file static imports, giving Rollup graph edges it needs to
|
|
231
|
+
* automatically code-split components per page chunk.
|
|
232
|
+
*
|
|
233
|
+
* Must be used with `enforce: 'pre'` (already set internally) to ensure
|
|
234
|
+
* the transform sees the original TypeScript source before esbuild runs.
|
|
235
|
+
*/
|
|
236
|
+
export declare function cerComponentImports(options: CerComponentImportsOptions): Plugin;
|
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.
|
|
4
|
+
"version": "3.6.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"web-components",
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@eslint/js": "^10.0.1",
|
|
39
39
|
"@testing-library/jest-dom": "^6.9.1",
|
|
40
|
-
"@types/jsdom": "^28.0.
|
|
40
|
+
"@types/jsdom": "^28.0.1",
|
|
41
41
|
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
|
42
42
|
"@typescript-eslint/parser": "^8.46.2",
|
|
43
|
-
"@vitest/coverage-v8": "^4.1.
|
|
44
|
-
"cypress": "^15.
|
|
45
|
-
"eslint": "^10.0
|
|
43
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
44
|
+
"cypress": "^15.13.0",
|
|
45
|
+
"eslint": "^10.1.0",
|
|
46
46
|
"eslint-config-prettier": "^10.1.8",
|
|
47
47
|
"eslint-plugin-prettier": "^5.5.5",
|
|
48
|
-
"jsdom": "^29.0.
|
|
48
|
+
"jsdom": "^29.0.1",
|
|
49
49
|
"prettier": "^3.8.1",
|
|
50
50
|
"typescript": "^5.9.3",
|
|
51
|
-
"typescript-eslint": "^8.57.
|
|
52
|
-
"vite": "^8.0.
|
|
51
|
+
"typescript-eslint": "^8.57.2",
|
|
52
|
+
"vite": "^8.0.3",
|
|
53
53
|
"vitest": "^4.0.12"
|
|
54
54
|
},
|
|
55
55
|
"main": "dist/custom-elements-runtime.cjs.js",
|