@jasonshimmy/vite-plugin-cer-app 0.1.5 → 0.1.6
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/CHANGELOG.md +4 -0
- package/README.md +5 -2
- package/commits.txt +1 -1
- package/dist/cli/create/templates/spa/app/app.ts.tpl +93 -0
- package/dist/cli/create/templates/spa/app/layouts/default.ts.tpl +15 -0
- package/dist/cli/create/templates/spa/app/pages/index.ts.tpl +8 -0
- package/dist/cli/create/templates/spa/cer.config.ts.tpl +6 -0
- package/dist/cli/create/templates/spa/index.html.tpl +12 -0
- package/dist/cli/create/templates/spa/package.json.tpl +18 -0
- package/dist/cli/create/templates/ssg/app/app.ts.tpl +97 -0
- package/dist/cli/create/templates/ssg/app/layouts/default.ts.tpl +15 -0
- package/dist/cli/create/templates/ssg/app/pages/index.ts.tpl +8 -0
- package/dist/cli/create/templates/ssg/cer.config.ts.tpl +13 -0
- package/dist/cli/create/templates/ssg/index.html.tpl +12 -0
- package/dist/cli/create/templates/ssg/package.json.tpl +19 -0
- package/dist/cli/create/templates/ssr/app/app.ts.tpl +97 -0
- package/dist/cli/create/templates/ssr/app/layouts/default.ts.tpl +15 -0
- package/dist/cli/create/templates/ssr/app/pages/index.ts.tpl +8 -0
- package/dist/cli/create/templates/ssr/cer.config.ts.tpl +10 -0
- package/dist/cli/create/templates/ssr/index.html.tpl +12 -0
- package/dist/cli/create/templates/ssr/package.json.tpl +18 -0
- package/docs/cli.md +10 -8
- package/docs/configuration.md +4 -2
- package/docs/getting-started.md +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
|
+
## [v0.1.6] - 2026-03-20
|
|
5
|
+
|
|
6
|
+
- fix: update CLI usage instructions to include --package flag for create-cer-app (457114d)
|
|
7
|
+
|
|
4
8
|
## [v0.1.5] - 2026-03-20
|
|
5
9
|
|
|
6
10
|
- fix: use vite plugin for light dom jit css fix: update incorrect docs fix: fix the plugin config (c32cf6a)
|
package/README.md
CHANGED
|
@@ -58,17 +58,20 @@ export default defineConfig({
|
|
|
58
58
|
The fastest path is scaffolding a new project:
|
|
59
59
|
|
|
60
60
|
```sh
|
|
61
|
-
npx create-cer-app my-app
|
|
61
|
+
npx --package @jasonshimmy/vite-plugin-cer-app create-cer-app my-app
|
|
62
62
|
# → choose spa / ssr / ssg
|
|
63
63
|
cd my-app
|
|
64
64
|
npm install
|
|
65
65
|
npm run dev
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
> **Note:** The `--package` flag is required because `create-cer-app` is bundled inside `@jasonshimmy/vite-plugin-cer-app` rather than published as a standalone package.
|
|
69
|
+
|
|
70
|
+
Or install the CLI globally to skip the flag entirely:
|
|
69
71
|
|
|
70
72
|
```sh
|
|
71
73
|
npm install -g @jasonshimmy/vite-plugin-cer-app
|
|
74
|
+
create-cer-app my-app
|
|
72
75
|
cer-app dev
|
|
73
76
|
```
|
|
74
77
|
|
package/commits.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
- fix:
|
|
1
|
+
- fix: update CLI usage instructions to include --package flag for create-cer-app (457114d)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import '@jasonshimmy/custom-elements-runtime/css'
|
|
2
|
+
import 'virtual:cer-jit-css'
|
|
3
|
+
import 'virtual:cer-components'
|
|
4
|
+
import routes from 'virtual:cer-routes'
|
|
5
|
+
import layouts from 'virtual:cer-layouts'
|
|
6
|
+
import plugins from 'virtual:cer-plugins'
|
|
7
|
+
import { hasLoading, loadingTag } from 'virtual:cer-loading'
|
|
8
|
+
import { hasError, errorTag } from 'virtual:cer-error'
|
|
9
|
+
import {
|
|
10
|
+
component,
|
|
11
|
+
ref,
|
|
12
|
+
provide,
|
|
13
|
+
useOnConnected,
|
|
14
|
+
useOnDisconnected,
|
|
15
|
+
registerBuiltinComponents,
|
|
16
|
+
} from '@jasonshimmy/custom-elements-runtime'
|
|
17
|
+
import { initRouter } from '@jasonshimmy/custom-elements-runtime/router'
|
|
18
|
+
import { enableJITCSS } from '@jasonshimmy/custom-elements-runtime/jit-css'
|
|
19
|
+
|
|
20
|
+
registerBuiltinComponents()
|
|
21
|
+
enableJITCSS()
|
|
22
|
+
|
|
23
|
+
const router = initRouter({ routes })
|
|
24
|
+
|
|
25
|
+
const isNavigating = ref(false)
|
|
26
|
+
const currentError = ref(null)
|
|
27
|
+
;(globalThis as any).resetError = () => {
|
|
28
|
+
currentError.value = null
|
|
29
|
+
router.replace(router.getCurrent().path)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const _push = router.push.bind(router)
|
|
33
|
+
const _replace = router.replace.bind(router)
|
|
34
|
+
router.push = async (path) => {
|
|
35
|
+
isNavigating.value = true
|
|
36
|
+
currentError.value = null
|
|
37
|
+
try { await _push(path) } catch (err) { currentError.value = err instanceof Error ? err.message : String(err) } finally { isNavigating.value = false }
|
|
38
|
+
}
|
|
39
|
+
router.replace = async (path) => {
|
|
40
|
+
isNavigating.value = true
|
|
41
|
+
currentError.value = null
|
|
42
|
+
try { await _replace(path) } catch (err) { currentError.value = err instanceof Error ? err.message : String(err) } finally { isNavigating.value = false }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const _pluginProvides = new Map<string, unknown>()
|
|
46
|
+
;(globalThis as any).__cerPluginProvides = _pluginProvides
|
|
47
|
+
|
|
48
|
+
component('cer-layout-view', () => {
|
|
49
|
+
for (const [key, value] of _pluginProvides) {
|
|
50
|
+
provide(key, value)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const current = ref(router.getCurrent())
|
|
54
|
+
let unsub: (() => void) | undefined
|
|
55
|
+
useOnConnected(() => { unsub = router.subscribe((s: typeof current.value) => { current.value = s }) })
|
|
56
|
+
useOnDisconnected(() => { unsub?.(); unsub = undefined })
|
|
57
|
+
|
|
58
|
+
if (currentError.value !== null) {
|
|
59
|
+
if (hasError && errorTag) return { tag: errorTag, props: { attrs: { error: String(currentError.value) } }, children: [] }
|
|
60
|
+
return { tag: 'div', props: { attrs: { style: 'padding:2rem;font-family:monospace' } }, children: String(currentError.value) }
|
|
61
|
+
}
|
|
62
|
+
if (isNavigating.value && hasLoading && loadingTag) return { tag: loadingTag, props: {}, children: [] }
|
|
63
|
+
|
|
64
|
+
const matched = router.matchRoute(current.value.path)
|
|
65
|
+
const layoutName = (matched?.route as any)?.meta?.layout ?? 'default'
|
|
66
|
+
const layoutTag = (layouts as Record<string, string>)[layoutName]
|
|
67
|
+
const routerView = { tag: 'router-view', props: {}, children: [] }
|
|
68
|
+
return layoutTag ? { tag: layoutTag, props: {}, children: [routerView] } : routerView
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
for (const plugin of plugins) {
|
|
72
|
+
if (plugin && typeof plugin.setup === 'function') {
|
|
73
|
+
await plugin.setup({ router, provide: (key: string, value: unknown) => { _pluginProvides.set(key, value) }, config: {} })
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Pre-load the current page's route chunk AFTER plugins run so that
|
|
78
|
+
// cer-layout-view's first render (which calls provide()) completes before
|
|
79
|
+
// page components are defined. This ensures inject() in child components
|
|
80
|
+
// can find values stored by provide().
|
|
81
|
+
if (typeof window !== 'undefined') {
|
|
82
|
+
const _initMatch = router.matchRoute(window.location.pathname)
|
|
83
|
+
if (_initMatch?.route?.load) {
|
|
84
|
+
try { await _initMatch.route.load() } catch { /* non-fatal */ }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof window !== 'undefined') {
|
|
89
|
+
// Use the original (unwrapped) replace so isNavigating stays false on first paint.
|
|
90
|
+
await _replace(window.location.pathname + window.location.search + window.location.hash)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { router }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>{{projectName}}</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<cer-layout-view></cer-layout-view>
|
|
10
|
+
<script type="module" src="/app/app.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "cer-app dev",
|
|
7
|
+
"build": "cer-app build",
|
|
8
|
+
"preview": "cer-app preview"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@jasonshimmy/custom-elements-runtime": "^3.1.1"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"vite": "^5.0.0",
|
|
15
|
+
"@jasonshimmy/vite-plugin-cer-app": "^0.1.0",
|
|
16
|
+
"typescript": "^5.4.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import '@jasonshimmy/custom-elements-runtime/css'
|
|
2
|
+
import 'virtual:cer-jit-css'
|
|
3
|
+
import 'virtual:cer-components'
|
|
4
|
+
import routes from 'virtual:cer-routes'
|
|
5
|
+
import layouts from 'virtual:cer-layouts'
|
|
6
|
+
import plugins from 'virtual:cer-plugins'
|
|
7
|
+
import { hasLoading, loadingTag } from 'virtual:cer-loading'
|
|
8
|
+
import { hasError, errorTag } from 'virtual:cer-error'
|
|
9
|
+
import {
|
|
10
|
+
component,
|
|
11
|
+
ref,
|
|
12
|
+
provide,
|
|
13
|
+
useOnConnected,
|
|
14
|
+
useOnDisconnected,
|
|
15
|
+
registerBuiltinComponents,
|
|
16
|
+
} from '@jasonshimmy/custom-elements-runtime'
|
|
17
|
+
import { initRouter } from '@jasonshimmy/custom-elements-runtime/router'
|
|
18
|
+
import { enableJITCSS } from '@jasonshimmy/custom-elements-runtime/jit-css'
|
|
19
|
+
|
|
20
|
+
registerBuiltinComponents()
|
|
21
|
+
enableJITCSS()
|
|
22
|
+
|
|
23
|
+
const router = initRouter({ routes })
|
|
24
|
+
|
|
25
|
+
const isNavigating = ref(false)
|
|
26
|
+
const currentError = ref(null)
|
|
27
|
+
;(globalThis as any).resetError = () => {
|
|
28
|
+
currentError.value = null
|
|
29
|
+
router.replace(router.getCurrent().path)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const _push = router.push.bind(router)
|
|
33
|
+
const _replace = router.replace.bind(router)
|
|
34
|
+
router.push = async (path) => {
|
|
35
|
+
isNavigating.value = true
|
|
36
|
+
currentError.value = null
|
|
37
|
+
try { await _push(path) } catch (err) { currentError.value = err instanceof Error ? err.message : String(err) } finally { isNavigating.value = false }
|
|
38
|
+
}
|
|
39
|
+
router.replace = async (path) => {
|
|
40
|
+
isNavigating.value = true
|
|
41
|
+
currentError.value = null
|
|
42
|
+
try { await _replace(path) } catch (err) { currentError.value = err instanceof Error ? err.message : String(err) } finally { isNavigating.value = false }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const _pluginProvides = new Map<string, unknown>()
|
|
46
|
+
;(globalThis as any).__cerPluginProvides = _pluginProvides
|
|
47
|
+
|
|
48
|
+
component('cer-layout-view', () => {
|
|
49
|
+
for (const [key, value] of _pluginProvides) {
|
|
50
|
+
provide(key, value)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const current = ref(router.getCurrent())
|
|
54
|
+
let unsub: (() => void) | undefined
|
|
55
|
+
useOnConnected(() => { unsub = router.subscribe((s: typeof current.value) => { current.value = s }) })
|
|
56
|
+
useOnDisconnected(() => { unsub?.(); unsub = undefined })
|
|
57
|
+
|
|
58
|
+
if (currentError.value !== null) {
|
|
59
|
+
if (hasError && errorTag) return { tag: errorTag, props: { attrs: { error: String(currentError.value) } }, children: [] }
|
|
60
|
+
return { tag: 'div', props: { attrs: { style: 'padding:2rem;font-family:monospace' } }, children: String(currentError.value) }
|
|
61
|
+
}
|
|
62
|
+
if (isNavigating.value && hasLoading && loadingTag) return { tag: loadingTag, props: {}, children: [] }
|
|
63
|
+
|
|
64
|
+
const matched = router.matchRoute(current.value.path)
|
|
65
|
+
const layoutName = (matched?.route as any)?.meta?.layout ?? 'default'
|
|
66
|
+
const layoutTag = (layouts as Record<string, string>)[layoutName]
|
|
67
|
+
const routerView = { tag: 'router-view', props: {}, children: [] }
|
|
68
|
+
return layoutTag ? { tag: layoutTag, props: {}, children: [routerView] } : routerView
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
for (const plugin of plugins) {
|
|
72
|
+
if (plugin && typeof plugin.setup === 'function') {
|
|
73
|
+
await plugin.setup({ router, provide: (key: string, value: unknown) => { _pluginProvides.set(key, value) }, config: {} })
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Pre-load the current page's route chunk AFTER plugins run so that
|
|
78
|
+
// cer-layout-view's first render (which calls provide()) completes before
|
|
79
|
+
// page components are defined. This ensures inject() in child components
|
|
80
|
+
// can find values stored by provide().
|
|
81
|
+
if (typeof window !== 'undefined') {
|
|
82
|
+
const _initMatch = router.matchRoute(window.location.pathname)
|
|
83
|
+
if (_initMatch?.route?.load) {
|
|
84
|
+
try { await _initMatch.route.load() } catch { /* non-fatal */ }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof window !== 'undefined') {
|
|
89
|
+
// Use the original (unwrapped) replace so isNavigating stays false on first
|
|
90
|
+
// paint — the loading component must not flash over pre-rendered SSG content.
|
|
91
|
+
await _replace(window.location.pathname + window.location.search + window.location.hash)
|
|
92
|
+
// Clear SSR hydration data after initial navigation so subsequent navigations
|
|
93
|
+
// don't accidentally reuse it.
|
|
94
|
+
delete (globalThis as any).__CER_DATA__
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { router }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from '@jasonshimmy/vite-plugin-cer-app'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
mode: 'ssg',
|
|
5
|
+
ssg: {
|
|
6
|
+
routes: 'auto',
|
|
7
|
+
concurrency: 4,
|
|
8
|
+
},
|
|
9
|
+
ssr: {
|
|
10
|
+
dsd: true,
|
|
11
|
+
},
|
|
12
|
+
autoImports: { components: true, composables: true, directives: true, runtime: true },
|
|
13
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>{{projectName}}</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<cer-layout-view></cer-layout-view>
|
|
10
|
+
<script type="module" src="/app/app.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "cer-app dev",
|
|
7
|
+
"build": "cer-app build",
|
|
8
|
+
"generate": "cer-app generate",
|
|
9
|
+
"preview": "cer-app preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@jasonshimmy/custom-elements-runtime": "^3.1.1"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"vite": "^5.0.0",
|
|
16
|
+
"@jasonshimmy/vite-plugin-cer-app": "^0.1.0",
|
|
17
|
+
"typescript": "^5.4.0"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import '@jasonshimmy/custom-elements-runtime/css'
|
|
2
|
+
import 'virtual:cer-jit-css'
|
|
3
|
+
import 'virtual:cer-components'
|
|
4
|
+
import routes from 'virtual:cer-routes'
|
|
5
|
+
import layouts from 'virtual:cer-layouts'
|
|
6
|
+
import plugins from 'virtual:cer-plugins'
|
|
7
|
+
import { hasLoading, loadingTag } from 'virtual:cer-loading'
|
|
8
|
+
import { hasError, errorTag } from 'virtual:cer-error'
|
|
9
|
+
import {
|
|
10
|
+
component,
|
|
11
|
+
ref,
|
|
12
|
+
provide,
|
|
13
|
+
useOnConnected,
|
|
14
|
+
useOnDisconnected,
|
|
15
|
+
registerBuiltinComponents,
|
|
16
|
+
} from '@jasonshimmy/custom-elements-runtime'
|
|
17
|
+
import { initRouter } from '@jasonshimmy/custom-elements-runtime/router'
|
|
18
|
+
import { enableJITCSS } from '@jasonshimmy/custom-elements-runtime/jit-css'
|
|
19
|
+
|
|
20
|
+
registerBuiltinComponents()
|
|
21
|
+
enableJITCSS()
|
|
22
|
+
|
|
23
|
+
const router = initRouter({ routes })
|
|
24
|
+
|
|
25
|
+
const isNavigating = ref(false)
|
|
26
|
+
const currentError = ref(null)
|
|
27
|
+
;(globalThis as any).resetError = () => {
|
|
28
|
+
currentError.value = null
|
|
29
|
+
router.replace(router.getCurrent().path)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const _push = router.push.bind(router)
|
|
33
|
+
const _replace = router.replace.bind(router)
|
|
34
|
+
router.push = async (path) => {
|
|
35
|
+
isNavigating.value = true
|
|
36
|
+
currentError.value = null
|
|
37
|
+
try { await _push(path) } catch (err) { currentError.value = err instanceof Error ? err.message : String(err) } finally { isNavigating.value = false }
|
|
38
|
+
}
|
|
39
|
+
router.replace = async (path) => {
|
|
40
|
+
isNavigating.value = true
|
|
41
|
+
currentError.value = null
|
|
42
|
+
try { await _replace(path) } catch (err) { currentError.value = err instanceof Error ? err.message : String(err) } finally { isNavigating.value = false }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const _pluginProvides = new Map<string, unknown>()
|
|
46
|
+
;(globalThis as any).__cerPluginProvides = _pluginProvides
|
|
47
|
+
|
|
48
|
+
component('cer-layout-view', () => {
|
|
49
|
+
for (const [key, value] of _pluginProvides) {
|
|
50
|
+
provide(key, value)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const current = ref(router.getCurrent())
|
|
54
|
+
let unsub: (() => void) | undefined
|
|
55
|
+
useOnConnected(() => { unsub = router.subscribe((s: typeof current.value) => { current.value = s }) })
|
|
56
|
+
useOnDisconnected(() => { unsub?.(); unsub = undefined })
|
|
57
|
+
|
|
58
|
+
if (currentError.value !== null) {
|
|
59
|
+
if (hasError && errorTag) return { tag: errorTag, props: { attrs: { error: String(currentError.value) } }, children: [] }
|
|
60
|
+
return { tag: 'div', props: { attrs: { style: 'padding:2rem;font-family:monospace' } }, children: String(currentError.value) }
|
|
61
|
+
}
|
|
62
|
+
if (isNavigating.value && hasLoading && loadingTag) return { tag: loadingTag, props: {}, children: [] }
|
|
63
|
+
|
|
64
|
+
const matched = router.matchRoute(current.value.path)
|
|
65
|
+
const layoutName = (matched?.route as any)?.meta?.layout ?? 'default'
|
|
66
|
+
const layoutTag = (layouts as Record<string, string>)[layoutName]
|
|
67
|
+
const routerView = { tag: 'router-view', props: {}, children: [] }
|
|
68
|
+
return layoutTag ? { tag: layoutTag, props: {}, children: [routerView] } : routerView
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
for (const plugin of plugins) {
|
|
72
|
+
if (plugin && typeof plugin.setup === 'function') {
|
|
73
|
+
await plugin.setup({ router, provide: (key: string, value: unknown) => { _pluginProvides.set(key, value) }, config: {} })
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Pre-load the current page's route chunk AFTER plugins run so that
|
|
78
|
+
// cer-layout-view's first render (which calls provide()) completes before
|
|
79
|
+
// page components are defined. This ensures inject() in child components
|
|
80
|
+
// can find values stored by provide().
|
|
81
|
+
if (typeof window !== 'undefined') {
|
|
82
|
+
const _initMatch = router.matchRoute(window.location.pathname)
|
|
83
|
+
if (_initMatch?.route?.load) {
|
|
84
|
+
try { await _initMatch.route.load() } catch { /* non-fatal */ }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof window !== 'undefined') {
|
|
89
|
+
// Use the original (unwrapped) replace so isNavigating stays false on first
|
|
90
|
+
// paint — the loading component must not flash over pre-rendered SSR content.
|
|
91
|
+
await _replace(window.location.pathname + window.location.search + window.location.hash)
|
|
92
|
+
// Clear SSR hydration data after initial navigation so subsequent navigations
|
|
93
|
+
// don't accidentally reuse it.
|
|
94
|
+
delete (globalThis as any).__CER_DATA__
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { router }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>{{projectName}}</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<cer-layout-view></cer-layout-view>
|
|
10
|
+
<script type="module" src="/app/app.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "cer-app dev",
|
|
7
|
+
"build": "cer-app build",
|
|
8
|
+
"preview": "cer-app preview --ssr"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@jasonshimmy/custom-elements-runtime": "^3.1.1"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"vite": "^5.0.0",
|
|
15
|
+
"@jasonshimmy/vite-plugin-cer-app": "^0.1.0",
|
|
16
|
+
"typescript": "^5.4.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/docs/cli.md
CHANGED
|
@@ -148,9 +148,11 @@ dist/
|
|
|
148
148
|
|
|
149
149
|
Scaffolds a new project from a template.
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
```
|
|
151
|
+
> **Note:** Because the scaffolder is bundled inside `@jasonshimmy/vite-plugin-cer-app` rather than published as a standalone `create-cer-app` package, you must use the `--package` flag with `npx`:
|
|
152
|
+
>
|
|
153
|
+
> ```sh
|
|
154
|
+
> npx --package @jasonshimmy/vite-plugin-cer-app create-cer-app [project-name] [options]
|
|
155
|
+
> ```
|
|
154
156
|
|
|
155
157
|
| Argument / Option | Description |
|
|
156
158
|
|---|---|
|
|
@@ -161,10 +163,10 @@ create-cer-app [project-name] [options]
|
|
|
161
163
|
**Examples:**
|
|
162
164
|
|
|
163
165
|
```sh
|
|
164
|
-
create-cer-app # interactive prompts
|
|
165
|
-
create-cer-app my-app # prompts for mode
|
|
166
|
-
create-cer-app my-app --mode ssr # no prompts
|
|
167
|
-
create-cer-app my-blog --mode ssg --dir ./sites/blog
|
|
166
|
+
npx --package @jasonshimmy/vite-plugin-cer-app create-cer-app # interactive prompts
|
|
167
|
+
npx --package @jasonshimmy/vite-plugin-cer-app create-cer-app my-app # prompts for mode
|
|
168
|
+
npx --package @jasonshimmy/vite-plugin-cer-app create-cer-app my-app --mode ssr # no prompts
|
|
169
|
+
npx --package @jasonshimmy/vite-plugin-cer-app create-cer-app my-blog --mode ssg --dir ./sites/blog
|
|
168
170
|
```
|
|
169
171
|
|
|
170
172
|
**Scaffolded files (all modes):**
|
|
@@ -231,5 +233,5 @@ npm run preview
|
|
|
231
233
|
```sh
|
|
232
234
|
npx cer-app dev
|
|
233
235
|
npx cer-app build
|
|
234
|
-
npx create-cer-app my-app
|
|
236
|
+
npx --package @jasonshimmy/vite-plugin-cer-app create-cer-app my-app
|
|
235
237
|
```
|
package/docs/configuration.md
CHANGED
|
@@ -217,8 +217,10 @@ When `runtime: true`, the following are injected if used and not already importe
|
|
|
217
217
|
```ts
|
|
218
218
|
import { component, html, css, ref, computed, watch, watchEffect,
|
|
219
219
|
useProps, useEmit, useOnConnected, useOnDisconnected,
|
|
220
|
-
useOnAttributeChanged, useOnError, useStyle,
|
|
221
|
-
useSlots, provide, inject,
|
|
220
|
+
useOnAttributeChanged, useOnError, useStyle, useDesignTokens,
|
|
221
|
+
useGlobalStyle, useExpose, useSlots, provide, inject,
|
|
222
|
+
createComposable, nextTick, defineModel, getCurrentComponentContext,
|
|
223
|
+
isReactiveState, unsafeHTML, decodeEntities, useTeleport
|
|
222
224
|
} from '@jasonshimmy/custom-elements-runtime'
|
|
223
225
|
```
|
|
224
226
|
|
package/docs/getting-started.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
## Option A — Scaffold with `create-cer-app` (recommended)
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
npx create-cer-app my-app
|
|
14
|
+
npx --package @jasonshimmy/vite-plugin-cer-app create-cer-app my-app
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
The interactive prompt asks for a project name and rendering mode:
|
|
@@ -39,7 +39,7 @@ Project created! To get started:
|
|
|
39
39
|
You can also skip the prompts with flags:
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
|
-
npx create-cer-app my-app --mode ssr
|
|
42
|
+
npx --package @jasonshimmy/vite-plugin-cer-app create-cer-app my-app --mode ssr
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jasonshimmy/vite-plugin-cer-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Nuxt-style meta-framework for @jasonshimmy/custom-elements-runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"create-cer-app": "./dist/cli/create/index.js"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "tsc -p tsconfig.build.json",
|
|
47
|
+
"build": "tsc -p tsconfig.build.json && cp -r src/cli/create/templates dist/cli/create/templates",
|
|
48
48
|
"dev": "tsc -p tsconfig.build.json --watch",
|
|
49
49
|
"test": "vitest run",
|
|
50
50
|
"test:watch": "vitest",
|