@jasonshimmy/vite-plugin-cer-app 0.23.2 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/adapters/netlify.js +4 -2
- package/dist/cli/adapters/netlify.js.map +1 -1
- package/dist/cli/checks/lighthouse.d.ts +26 -0
- package/dist/cli/checks/lighthouse.d.ts.map +1 -0
- package/dist/cli/checks/lighthouse.js +121 -0
- package/dist/cli/checks/lighthouse.js.map +1 -0
- package/dist/cli/checks/links.d.ts +12 -0
- package/dist/cli/checks/links.d.ts.map +1 -0
- package/dist/cli/checks/links.js +89 -0
- package/dist/cli/checks/links.js.map +1 -0
- package/dist/cli/checks/performance.d.ts +17 -0
- package/dist/cli/checks/performance.d.ts.map +1 -0
- package/dist/cli/checks/performance.js +61 -0
- package/dist/cli/checks/performance.js.map +1 -0
- package/dist/cli/commands/check.d.ts +3 -0
- package/dist/cli/commands/check.d.ts.map +1 -0
- package/dist/cli/commands/check.js +85 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/preview.d.ts.map +1 -1
- package/dist/cli/commands/preview.js +4 -2
- package/dist/cli/commands/preview.js.map +1 -1
- package/dist/cli/create/index.d.ts +11 -1
- package/dist/cli/create/index.d.ts.map +1 -1
- package/dist/cli/create/index.js +135 -65
- package/dist/cli/create/index.js.map +1 -1
- package/dist/cli/create/templates/spa/package.json.tpl +5 -3
- package/dist/cli/create/templates/ssg/cer.config.ts.tpl +2 -0
- package/dist/cli/create/templates/ssg/package.json.tpl +5 -3
- package/dist/cli/create/templates/ssr/package.json.tpl +5 -3
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/plugin/build-ssg.d.ts +22 -6
- package/dist/plugin/build-ssg.d.ts.map +1 -1
- package/dist/plugin/build-ssg.js +226 -17
- package/dist/plugin/build-ssg.js.map +1 -1
- package/dist/plugin/content/index.d.ts +1 -1
- package/dist/plugin/content/index.d.ts.map +1 -1
- package/dist/plugin/content/index.js +8 -8
- package/dist/plugin/content/index.js.map +1 -1
- package/dist/plugin/content/parser.d.ts +3 -3
- package/dist/plugin/content/parser.d.ts.map +1 -1
- package/dist/plugin/content/parser.js +103 -24
- package/dist/plugin/content/parser.js.map +1 -1
- package/dist/plugin/dev-server.d.ts +4 -1
- package/dist/plugin/dev-server.d.ts.map +1 -1
- package/dist/plugin/dev-server.js.map +1 -1
- package/dist/plugin/dts-generator.d.ts.map +1 -1
- package/dist/plugin/dts-generator.js +50 -8
- package/dist/plugin/dts-generator.js.map +1 -1
- package/dist/plugin/generated-dir.d.ts +2 -0
- package/dist/plugin/generated-dir.d.ts.map +1 -1
- package/dist/plugin/generated-dir.js +17 -6
- package/dist/plugin/generated-dir.js.map +1 -1
- package/dist/plugin/html-post-process.d.ts +7 -0
- package/dist/plugin/html-post-process.d.ts.map +1 -1
- package/dist/plugin/html-post-process.js +26 -0
- package/dist/plugin/html-post-process.js.map +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +60 -13
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/transforms/auto-import.d.ts.map +1 -1
- package/dist/plugin/transforms/auto-import.js +7 -0
- package/dist/plugin/transforms/auto-import.js.map +1 -1
- package/dist/plugin/transforms/prune-runtime-css.d.ts +8 -0
- package/dist/plugin/transforms/prune-runtime-css.d.ts.map +1 -0
- package/dist/plugin/transforms/prune-runtime-css.js +40 -0
- package/dist/plugin/transforms/prune-runtime-css.js.map +1 -0
- package/dist/runtime/app-template.d.ts +1 -1
- package/dist/runtime/app-template.d.ts.map +1 -1
- package/dist/runtime/app-template.js +206 -36
- package/dist/runtime/app-template.js.map +1 -1
- package/dist/runtime/composables/index.d.ts +4 -0
- package/dist/runtime/composables/index.d.ts.map +1 -1
- package/dist/runtime/composables/index.js +2 -0
- package/dist/runtime/composables/index.js.map +1 -1
- package/dist/runtime/composables/use-active-headings.d.ts +24 -0
- package/dist/runtime/composables/use-active-headings.d.ts.map +1 -0
- package/dist/runtime/composables/use-active-headings.js +112 -0
- package/dist/runtime/composables/use-active-headings.js.map +1 -0
- package/dist/runtime/composables/use-content-page.d.ts +45 -0
- package/dist/runtime/composables/use-content-page.d.ts.map +1 -0
- package/dist/runtime/composables/use-content-page.js +181 -0
- package/dist/runtime/composables/use-content-page.js.map +1 -0
- package/dist/runtime/composables/use-content-search.d.ts.map +1 -1
- package/dist/runtime/composables/use-content-search.js +1 -5
- package/dist/runtime/composables/use-content-search.js.map +1 -1
- package/dist/runtime/composables/use-fetch.d.ts +2 -1
- package/dist/runtime/composables/use-fetch.d.ts.map +1 -1
- package/dist/runtime/composables/use-fetch.js +112 -43
- package/dist/runtime/composables/use-fetch.js.map +1 -1
- package/dist/runtime/composables/use-route.d.ts.map +1 -1
- package/dist/runtime/composables/use-route.js +39 -11
- package/dist/runtime/composables/use-route.js.map +1 -1
- package/dist/runtime/content/client.js +2 -2
- package/dist/runtime/content/client.js.map +1 -1
- package/dist/runtime/entry-server-template.d.ts +16 -1
- package/dist/runtime/entry-server-template.d.ts.map +1 -1
- package/dist/runtime/entry-server-template.js +120 -13
- package/dist/runtime/entry-server-template.js.map +1 -1
- package/dist/types/config.d.ts +45 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/types/content.d.ts +18 -1
- package/dist/types/content.d.ts.map +1 -1
- package/dist/types/middleware.d.ts +2 -2
- package/dist/types/middleware.d.ts.map +1 -1
- package/package.json +22 -19
- package/.github/copilot-instructions.md +0 -169
- package/.github/workflows/publish.yml +0 -257
- package/.nvmrc +0 -1
- package/CHANGELOG.md +0 -236
- package/CLAUDE.md +0 -113
- package/commits.txt +0 -1
- package/cypress.config.ts +0 -16
- package/docs/authentication.md +0 -285
- package/docs/cli.md +0 -324
- package/docs/components.md +0 -237
- package/docs/composables.md +0 -907
- package/docs/configuration.md +0 -696
- package/docs/content.md +0 -570
- package/docs/data-loading.md +0 -336
- package/docs/getting-started.md +0 -237
- package/docs/head-management.md +0 -212
- package/docs/i18n.md +0 -159
- package/docs/layouts.md +0 -224
- package/docs/middleware.md +0 -234
- package/docs/plugins.md +0 -170
- package/docs/rendering-modes.md +0 -377
- package/docs/routing.md +0 -485
- package/docs/server-api.md +0 -253
- package/docs/testing.md +0 -455
- package/docs/use-fetch.md +0 -183
- package/e2e/cypress/e2e/api.cy.ts +0 -123
- package/e2e/cypress/e2e/async-component.cy.ts +0 -27
- package/e2e/cypress/e2e/component-splitting.cy.ts +0 -50
- package/e2e/cypress/e2e/content.cy.ts +0 -425
- package/e2e/cypress/e2e/cookie.cy.ts +0 -85
- package/e2e/cypress/e2e/data.cy.ts +0 -158
- package/e2e/cypress/e2e/error-boundary.cy.ts +0 -88
- package/e2e/cypress/e2e/fouc.cy.ts +0 -254
- package/e2e/cypress/e2e/group-meta.cy.ts +0 -36
- package/e2e/cypress/e2e/head.cy.ts +0 -89
- package/e2e/cypress/e2e/i18n.cy.ts +0 -79
- package/e2e/cypress/e2e/interactive.cy.ts +0 -137
- package/e2e/cypress/e2e/isr-nested-runtime.cy.ts +0 -102
- package/e2e/cypress/e2e/jit-css-custom-colors.cy.ts +0 -43
- package/e2e/cypress/e2e/middleware-chain.cy.ts +0 -89
- package/e2e/cypress/e2e/middleware-status.cy.ts +0 -30
- package/e2e/cypress/e2e/middleware.cy.ts +0 -45
- package/e2e/cypress/e2e/navigate.cy.ts +0 -39
- package/e2e/cypress/e2e/observability.cy.ts +0 -77
- package/e2e/cypress/e2e/per-route-error.cy.ts +0 -42
- package/e2e/cypress/e2e/per-route-render.cy.ts +0 -70
- package/e2e/cypress/e2e/preview-hardening.cy.ts +0 -88
- package/e2e/cypress/e2e/routes.cy.ts +0 -128
- package/e2e/cypress/e2e/seo-meta.cy.ts +0 -108
- package/e2e/cypress/e2e/server-middleware.cy.ts +0 -46
- package/e2e/cypress/e2e/session-rotation.cy.ts +0 -25
- package/e2e/cypress/e2e/session.cy.ts +0 -73
- package/e2e/cypress/e2e/ssr-render-error.cy.ts +0 -68
- package/e2e/cypress/e2e/synthetic-404.cy.ts +0 -45
- package/e2e/cypress/e2e/use-page-data.cy.ts +0 -122
- package/e2e/cypress/e2e/use-state.cy.ts +0 -138
- package/e2e/cypress/support/commands.ts +0 -120
- package/e2e/cypress/support/e2e.ts +0 -10
- package/e2e/cypress/tsconfig.json +0 -14
- package/e2e/kitchen-sink/app/components/ks-badge.ts +0 -8
- package/e2e/kitchen-sink/app/composables/useKsCounter.ts +0 -9
- package/e2e/kitchen-sink/app/error.ts +0 -18
- package/e2e/kitchen-sink/app/layouts/admin.ts +0 -13
- package/e2e/kitchen-sink/app/layouts/default.ts +0 -25
- package/e2e/kitchen-sink/app/layouts/group.ts +0 -9
- package/e2e/kitchen-sink/app/layouts/minimal.ts +0 -7
- package/e2e/kitchen-sink/app/loading.ts +0 -9
- package/e2e/kitchen-sink/app/middleware/auth.ts +0 -9
- package/e2e/kitchen-sink/app/middleware/custom-log.ts +0 -4
- package/e2e/kitchen-sink/app/middleware/group-auth.ts +0 -7
- package/e2e/kitchen-sink/app/middleware/logger.ts +0 -14
- package/e2e/kitchen-sink/app/pages/(auth)/login.ts +0 -13
- package/e2e/kitchen-sink/app/pages/(auth)/protected.ts +0 -16
- package/e2e/kitchen-sink/app/pages/404.ts +0 -9
- package/e2e/kitchen-sink/app/pages/about.ts +0 -17
- package/e2e/kitchen-sink/app/pages/admin/_layout.ts +0 -1
- package/e2e/kitchen-sink/app/pages/admin/dashboard.ts +0 -11
- package/e2e/kitchen-sink/app/pages/async-component-error-test.ts +0 -18
- package/e2e/kitchen-sink/app/pages/async-component-test.ts +0 -18
- package/e2e/kitchen-sink/app/pages/blog/[slug].ts +0 -59
- package/e2e/kitchen-sink/app/pages/blog/index.ts +0 -51
- package/e2e/kitchen-sink/app/pages/content-blog.ts +0 -37
- package/e2e/kitchen-sink/app/pages/content-doc.ts +0 -42
- package/e2e/kitchen-sink/app/pages/content-fallback.ts +0 -36
- package/e2e/kitchen-sink/app/pages/content-guides.ts +0 -35
- package/e2e/kitchen-sink/app/pages/content-index.ts +0 -39
- package/e2e/kitchen-sink/app/pages/content-search.ts +0 -36
- package/e2e/kitchen-sink/app/pages/cookie-test.ts +0 -22
- package/e2e/kitchen-sink/app/pages/counter.ts +0 -17
- package/e2e/kitchen-sink/app/pages/group-auth-blocked.ts +0 -9
- package/e2e/kitchen-sink/app/pages/group-meta-test/_layout.ts +0 -6
- package/e2e/kitchen-sink/app/pages/group-meta-test/custom-mw.ts +0 -14
- package/e2e/kitchen-sink/app/pages/group-meta-test/page.ts +0 -9
- package/e2e/kitchen-sink/app/pages/group-meta-test/protected.ts +0 -8
- package/e2e/kitchen-sink/app/pages/head.ts +0 -20
- package/e2e/kitchen-sink/app/pages/i18n-test.ts +0 -14
- package/e2e/kitchen-sink/app/pages/index.ts +0 -27
- package/e2e/kitchen-sink/app/pages/isr-test.ts +0 -17
- package/e2e/kitchen-sink/app/pages/items/[id].ts +0 -20
- package/e2e/kitchen-sink/app/pages/jit-css-custom-colors-test.ts +0 -14
- package/e2e/kitchen-sink/app/pages/loader-error-test.ts +0 -13
- package/e2e/kitchen-sink/app/pages/loader-props-test.ts +0 -19
- package/e2e/kitchen-sink/app/pages/loader-response-error-test.ts +0 -13
- package/e2e/kitchen-sink/app/pages/middleware-chain-test.ts +0 -12
- package/e2e/kitchen-sink/app/pages/middleware-status-test.ts +0 -9
- package/e2e/kitchen-sink/app/pages/navigate-test.ts +0 -16
- package/e2e/kitchen-sink/app/pages/observability-test.ts +0 -25
- package/e2e/kitchen-sink/app/pages/per-route-error-test.error.ts +0 -13
- package/e2e/kitchen-sink/app/pages/per-route-error-test.ts +0 -15
- package/e2e/kitchen-sink/app/pages/plugin-dsd-test.ts +0 -10
- package/e2e/kitchen-sink/app/pages/render-error-test.ts +0 -12
- package/e2e/kitchen-sink/app/pages/render-server-test.ts +0 -12
- package/e2e/kitchen-sink/app/pages/render-spa-test.ts +0 -12
- package/e2e/kitchen-sink/app/pages/route-info.ts +0 -14
- package/e2e/kitchen-sink/app/pages/seo-test.ts +0 -23
- package/e2e/kitchen-sink/app/pages/session-rotation-test.ts +0 -25
- package/e2e/kitchen-sink/app/pages/use-state-test.ts +0 -37
- package/e2e/kitchen-sink/app/plugins/01.setup.ts +0 -7
- package/e2e/kitchen-sink/app/plugins/02.ks-plugin-components.ts +0 -27
- package/e2e/kitchen-sink/cer-auto-imports.d.ts +0 -51
- package/e2e/kitchen-sink/cer-env.d.ts +0 -35
- package/e2e/kitchen-sink/cer-tsconfig.json +0 -30
- package/e2e/kitchen-sink/cer.config.ts +0 -43
- package/e2e/kitchen-sink/content/01.guides/01.index.md +0 -8
- package/e2e/kitchen-sink/content/01.guides/02.intro.md +0 -8
- package/e2e/kitchen-sink/content/01.guides/10.advanced.md +0 -8
- package/e2e/kitchen-sink/content/blog/2026-04-01-hello.md +0 -26
- package/e2e/kitchen-sink/content/blog/2026-04-02-draft.md +0 -10
- package/e2e/kitchen-sink/content/blog/index.md +0 -8
- package/e2e/kitchen-sink/content/blog/no-frontmatter.md +0 -7
- package/e2e/kitchen-sink/content/docs/getting-started.md +0 -48
- package/e2e/kitchen-sink/content/index.md +0 -16
- package/e2e/kitchen-sink/server/api/echo.ts +0 -12
- package/e2e/kitchen-sink/server/api/health.ts +0 -3
- package/e2e/kitchen-sink/server/api/posts/[slug].ts +0 -11
- package/e2e/kitchen-sink/server/api/posts/index.ts +0 -5
- package/e2e/kitchen-sink/server/api/session.ts +0 -23
- package/e2e/kitchen-sink/server/data/posts.ts +0 -21
- package/e2e/kitchen-sink/server/middleware/01-headers.ts +0 -6
- package/e2e/kitchen-sink/server/middleware/02-status-test.ts +0 -10
- package/e2e/kitchen-sink/tsconfig.json +0 -3
- package/e2e/scripts/clean.mjs +0 -14
- package/eslint.config.ts +0 -22
- package/src/__tests__/cli/adapters/cloudflare-worker.integration.test.ts +0 -132
- package/src/__tests__/cli/adapters/cloudflare.test.ts +0 -332
- package/src/__tests__/cli/adapters/netlify-bridge.integration.test.ts +0 -139
- package/src/__tests__/cli/adapters/netlify.test.ts +0 -286
- package/src/__tests__/cli/adapters/vercel-launcher.integration.test.ts +0 -129
- package/src/__tests__/cli/adapters/vercel.test.ts +0 -263
- package/src/__tests__/cli/preview-hardening.test.ts +0 -265
- package/src/__tests__/cli/preview-isr.test.ts +0 -320
- package/src/__tests__/index.test.ts +0 -21
- package/src/__tests__/plugin/app-template.test.ts +0 -166
- package/src/__tests__/plugin/build-ssg-render.test.ts +0 -155
- package/src/__tests__/plugin/build-ssg.test.ts +0 -598
- package/src/__tests__/plugin/build-ssr.test.ts +0 -192
- package/src/__tests__/plugin/cer-app-plugin.test.ts +0 -552
- package/src/__tests__/plugin/content/emitter.test.ts +0 -117
- package/src/__tests__/plugin/content/loader.test.ts +0 -154
- package/src/__tests__/plugin/content/parser.test.ts +0 -381
- package/src/__tests__/plugin/content/path-utils.test.ts +0 -69
- package/src/__tests__/plugin/content/search.test.ts +0 -119
- package/src/__tests__/plugin/dev-server.test.ts +0 -813
- package/src/__tests__/plugin/dts-generator.test.ts +0 -394
- package/src/__tests__/plugin/entry-server-template.test.ts +0 -385
- package/src/__tests__/plugin/generated-dir.test.ts +0 -144
- package/src/__tests__/plugin/html-post-process.test.ts +0 -146
- package/src/__tests__/plugin/path-utils.test.ts +0 -411
- package/src/__tests__/plugin/resolve-config.test.ts +0 -233
- package/src/__tests__/plugin/scanner.test.ts +0 -186
- package/src/__tests__/plugin/transforms/auto-import.test.ts +0 -510
- package/src/__tests__/plugin/transforms/head-inject.test.ts +0 -178
- package/src/__tests__/plugin/virtual/composables.test.ts +0 -57
- package/src/__tests__/plugin/virtual/content-components.test.ts +0 -66
- package/src/__tests__/plugin/virtual/error.test.ts +0 -71
- package/src/__tests__/plugin/virtual/layouts.test.ts +0 -70
- package/src/__tests__/plugin/virtual/loading.test.ts +0 -72
- package/src/__tests__/plugin/virtual/middleware.test.ts +0 -83
- package/src/__tests__/plugin/virtual/plugins.test.ts +0 -129
- package/src/__tests__/plugin/virtual/routes.test.ts +0 -884
- package/src/__tests__/plugin/virtual/server-api.test.ts +0 -164
- package/src/__tests__/plugin/virtual/server-middleware.test.ts +0 -102
- package/src/__tests__/runtime/app-template.test.ts +0 -208
- package/src/__tests__/runtime/define-middleware.test.ts +0 -64
- package/src/__tests__/runtime/define-server-middleware.test.ts +0 -54
- package/src/__tests__/runtime/entry-client-template.test.ts +0 -61
- package/src/__tests__/runtime/isr-handler.test.ts +0 -338
- package/src/__tests__/runtime/oauth/handler.test.ts +0 -358
- package/src/__tests__/runtime/oauth/providers.test.ts +0 -47
- package/src/__tests__/runtime/oauth-index.test.ts +0 -43
- package/src/__tests__/runtime/use-auth.test.ts +0 -169
- package/src/__tests__/runtime/use-content-search-composable.test.ts +0 -405
- package/src/__tests__/runtime/use-content-search.test.ts +0 -163
- package/src/__tests__/runtime/use-content.test.ts +0 -226
- package/src/__tests__/runtime/use-cookie.test.ts +0 -277
- package/src/__tests__/runtime/use-fetch-component.test.ts +0 -214
- package/src/__tests__/runtime/use-fetch.test.ts +0 -377
- package/src/__tests__/runtime/use-head.test.ts +0 -311
- package/src/__tests__/runtime/use-inject-client.test.ts +0 -67
- package/src/__tests__/runtime/use-inject.test.ts +0 -66
- package/src/__tests__/runtime/use-locale.test.ts +0 -152
- package/src/__tests__/runtime/use-navigate.test.ts +0 -121
- package/src/__tests__/runtime/use-page-data.test.ts +0 -298
- package/src/__tests__/runtime/use-route.test.ts +0 -156
- package/src/__tests__/runtime/use-runtime-config.test.ts +0 -182
- package/src/__tests__/runtime/use-seo-meta.test.ts +0 -109
- package/src/__tests__/runtime/use-session.test.ts +0 -320
- package/src/__tests__/runtime/use-state.test.ts +0 -340
- package/src/__tests__/types/config.test.ts +0 -18
- package/src/cli/adapters/cloudflare.ts +0 -335
- package/src/cli/adapters/netlify.ts +0 -326
- package/src/cli/adapters/vercel.ts +0 -311
- package/src/cli/commands/adapt.ts +0 -84
- package/src/cli/commands/build.ts +0 -165
- package/src/cli/commands/dev.ts +0 -125
- package/src/cli/commands/generate.ts +0 -91
- package/src/cli/commands/preview-isr.ts +0 -172
- package/src/cli/commands/preview.ts +0 -523
- package/src/cli/create/index.ts +0 -275
- package/src/cli/create/templates/shared/.gitignore.tpl +0 -25
- package/src/cli/create/templates/shared/app/layouts/default.ts.tpl +0 -15
- package/src/cli/create/templates/shared/app/pages/index.ts.tpl +0 -8
- package/src/cli/create/templates/shared/index.html.tpl +0 -12
- package/src/cli/create/templates/shared/tsconfig.json.tpl +0 -6
- package/src/cli/create/templates/spa/cer.config.ts.tpl +0 -6
- package/src/cli/create/templates/spa/package.json.tpl +0 -18
- package/src/cli/create/templates/ssg/cer.config.ts.tpl +0 -10
- package/src/cli/create/templates/ssg/package.json.tpl +0 -19
- package/src/cli/create/templates/ssr/cer.config.ts.tpl +0 -6
- package/src/cli/create/templates/ssr/package.json.tpl +0 -18
- package/src/cli/index.ts +0 -22
- package/src/index.ts +0 -20
- package/src/plugin/build-ssg.ts +0 -403
- package/src/plugin/build-ssr.ts +0 -134
- package/src/plugin/content/emitter.ts +0 -50
- package/src/plugin/content/index.ts +0 -233
- package/src/plugin/content/parser.ts +0 -259
- package/src/plugin/content/path-utils.ts +0 -55
- package/src/plugin/content/scanner.ts +0 -26
- package/src/plugin/content/search.ts +0 -28
- package/src/plugin/dev-server.ts +0 -379
- package/src/plugin/dts-generator.ts +0 -273
- package/src/plugin/generated-dir.ts +0 -121
- package/src/plugin/html-post-process.ts +0 -96
- package/src/plugin/index.ts +0 -584
- package/src/plugin/path-utils.ts +0 -186
- package/src/plugin/scanner.ts +0 -65
- package/src/plugin/transforms/auto-import.ts +0 -206
- package/src/plugin/transforms/head-inject.ts +0 -161
- package/src/plugin/virtual/composables.ts +0 -28
- package/src/plugin/virtual/content-components.ts +0 -83
- package/src/plugin/virtual/error.ts +0 -34
- package/src/plugin/virtual/layouts.ts +0 -41
- package/src/plugin/virtual/loading.ts +0 -32
- package/src/plugin/virtual/middleware.ts +0 -45
- package/src/plugin/virtual/plugins.ts +0 -46
- package/src/plugin/virtual/routes.ts +0 -514
- package/src/plugin/virtual/server-api.ts +0 -85
- package/src/plugin/virtual/server-middleware.ts +0 -44
- package/src/runtime/app-template.ts +0 -377
- package/src/runtime/composables/define-middleware.ts +0 -17
- package/src/runtime/composables/define-server-middleware.ts +0 -18
- package/src/runtime/composables/index.ts +0 -27
- package/src/runtime/composables/use-auth.ts +0 -125
- package/src/runtime/composables/use-content-search.ts +0 -205
- package/src/runtime/composables/use-content.ts +0 -146
- package/src/runtime/composables/use-cookie.ts +0 -135
- package/src/runtime/composables/use-fetch.ts +0 -438
- package/src/runtime/composables/use-head.ts +0 -234
- package/src/runtime/composables/use-inject.ts +0 -49
- package/src/runtime/composables/use-locale.ts +0 -109
- package/src/runtime/composables/use-navigate.ts +0 -58
- package/src/runtime/composables/use-page-data.ts +0 -93
- package/src/runtime/composables/use-route.ts +0 -71
- package/src/runtime/composables/use-runtime-config.ts +0 -123
- package/src/runtime/composables/use-seo-meta.ts +0 -80
- package/src/runtime/composables/use-session.ts +0 -186
- package/src/runtime/composables/use-state.ts +0 -92
- package/src/runtime/content/client.ts +0 -168
- package/src/runtime/entry-client-template.ts +0 -39
- package/src/runtime/entry-server-template.ts +0 -493
- package/src/runtime/isr-handler.ts +0 -184
- package/src/runtime/oauth/handler.ts +0 -407
- package/src/runtime/oauth/index.ts +0 -49
- package/src/runtime/oauth/providers.ts +0 -38
- package/src/types/api.ts +0 -40
- package/src/types/config.ts +0 -379
- package/src/types/content.ts +0 -66
- package/src/types/index.ts +0 -7
- package/src/types/middleware.ts +0 -63
- package/src/types/page.ts +0 -117
- package/src/types/plugin.ts +0 -34
- package/tsconfig.build.json +0 -10
- package/tsconfig.json +0 -19
- package/vitest.config.ts +0 -33
package/src/plugin/index.ts
DELETED
|
@@ -1,584 +0,0 @@
|
|
|
1
|
-
import { resolve, join, dirname } from 'pathe'
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
3
|
-
import type { Plugin, ViteDevServer } from 'vite'
|
|
4
|
-
import type { CerAppConfig } from '../types/config.js'
|
|
5
|
-
import type { ResolvedCerConfig } from './dev-server.js'
|
|
6
|
-
import { cerPlugin, cerComponentImports } from '@jasonshimmy/custom-elements-runtime/vite-plugin'
|
|
7
|
-
import { autoImportTransform } from './transforms/auto-import.js'
|
|
8
|
-
import { scanComposableExports, writeAutoImportDts, writeTsconfigPaths } from './dts-generator.js'
|
|
9
|
-
import { configureCerDevServer } from './dev-server.js'
|
|
10
|
-
import { writeGeneratedDir, getGeneratedDir } from './generated-dir.js'
|
|
11
|
-
import { generateAppEntryTemplate } from '../runtime/app-template.js'
|
|
12
|
-
import { generateRoutesCode } from './virtual/routes.js'
|
|
13
|
-
import { generateLayoutsCode } from './virtual/layouts.js'
|
|
14
|
-
import { generateComposablesCode } from './virtual/composables.js'
|
|
15
|
-
import { generatePluginsCode } from './virtual/plugins.js'
|
|
16
|
-
import { generateMiddlewareCode } from './virtual/middleware.js'
|
|
17
|
-
import { generateServerApiCode } from './virtual/server-api.js'
|
|
18
|
-
import { generateServerMiddlewareCode } from './virtual/server-middleware.js'
|
|
19
|
-
import { generateLoadingCode } from './virtual/loading.js'
|
|
20
|
-
import { generateErrorCode } from './virtual/error.js'
|
|
21
|
-
import { generateContentComponentsCode } from './virtual/content-components.js'
|
|
22
|
-
import { createWatcher } from './scanner.js'
|
|
23
|
-
import { cerContent } from './content/index.js'
|
|
24
|
-
|
|
25
|
-
// Virtual module IDs (raw)
|
|
26
|
-
const VIRTUAL_IDS = {
|
|
27
|
-
routes: 'virtual:cer-routes',
|
|
28
|
-
layouts: 'virtual:cer-layouts',
|
|
29
|
-
composables: 'virtual:cer-composables',
|
|
30
|
-
plugins: 'virtual:cer-plugins',
|
|
31
|
-
middleware: 'virtual:cer-middleware',
|
|
32
|
-
serverApi: 'virtual:cer-server-api',
|
|
33
|
-
serverMiddleware: 'virtual:cer-server-middleware',
|
|
34
|
-
appConfig: 'virtual:cer-app-config',
|
|
35
|
-
loading: 'virtual:cer-loading',
|
|
36
|
-
error: 'virtual:cer-error',
|
|
37
|
-
contentComponents: 'virtual:cer-content-components',
|
|
38
|
-
i18n: 'virtual:cer-i18n',
|
|
39
|
-
jitInit: 'virtual:cer-jit-init',
|
|
40
|
-
} as const
|
|
41
|
-
|
|
42
|
-
// Resolved virtual module IDs (prefixed with \0)
|
|
43
|
-
const RESOLVED_IDS = Object.fromEntries(
|
|
44
|
-
Object.entries(VIRTUAL_IDS).map(([k, v]) => [k, `\0${v}`]),
|
|
45
|
-
) as Record<keyof typeof VIRTUAL_IDS, string>
|
|
46
|
-
|
|
47
|
-
// The app entry is served via a virtual module at /@cer/app.ts.
|
|
48
|
-
// Using /@ avoids Vite's dot-directory fs security restriction that blocks /.cer/
|
|
49
|
-
// from being served through the transform middleware. The physical .cer/app.ts
|
|
50
|
-
// is still written to disk for IDE/TypeScript support, but the browser fetches
|
|
51
|
-
// /@cer/app.ts which resolves to this virtual module.
|
|
52
|
-
const APP_ENTRY_URL = '/@cer/app.ts'
|
|
53
|
-
const RESOLVED_APP_ENTRY = '\0cer-app-entry'
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Fills in default values for all config fields and resolves absolute paths.
|
|
57
|
-
*/
|
|
58
|
-
export function resolveConfig(userConfig: CerAppConfig, root: string = process.cwd()): ResolvedCerConfig {
|
|
59
|
-
const mode = userConfig.mode ?? 'spa'
|
|
60
|
-
const srcDir = resolve(root, userConfig.srcDir ?? 'app')
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
mode,
|
|
64
|
-
srcDir,
|
|
65
|
-
root,
|
|
66
|
-
siteUrl: userConfig.siteUrl ? userConfig.siteUrl.replace(/\/$/, '') : null,
|
|
67
|
-
contentDir: resolve(root, userConfig.content?.dir ?? 'content'),
|
|
68
|
-
pagesDir: join(srcDir, 'pages'),
|
|
69
|
-
layoutsDir: join(srcDir, 'layouts'),
|
|
70
|
-
componentsDir: join(srcDir, 'components'),
|
|
71
|
-
composablesDir: join(srcDir, 'composables'),
|
|
72
|
-
pluginsDir: join(srcDir, 'plugins'),
|
|
73
|
-
middlewareDir: join(srcDir, 'middleware'),
|
|
74
|
-
serverApiDir: join(root, 'server/api'),
|
|
75
|
-
serverMiddlewareDir: join(root, 'server/middleware'),
|
|
76
|
-
port: userConfig.port ?? 3000,
|
|
77
|
-
ssg: {
|
|
78
|
-
routes: userConfig.ssg?.routes ?? 'auto',
|
|
79
|
-
concurrency: userConfig.ssg?.concurrency ?? 4,
|
|
80
|
-
fallback: userConfig.ssg?.fallback ?? false,
|
|
81
|
-
},
|
|
82
|
-
router: {
|
|
83
|
-
base: userConfig.router?.base,
|
|
84
|
-
scrollToFragment: userConfig.router?.scrollToFragment,
|
|
85
|
-
},
|
|
86
|
-
jitCss: {
|
|
87
|
-
content: userConfig.jitCss?.content ?? [
|
|
88
|
-
`${srcDir}/pages/**/*.ts`,
|
|
89
|
-
`${srcDir}/components/**/*.ts`,
|
|
90
|
-
`${srcDir}/layouts/**/*.ts`,
|
|
91
|
-
],
|
|
92
|
-
extendedColors: userConfig.jitCss?.extendedColors ?? false,
|
|
93
|
-
customColors: userConfig.jitCss?.customColors,
|
|
94
|
-
},
|
|
95
|
-
autoImports: {
|
|
96
|
-
components: userConfig.autoImports?.components ?? true,
|
|
97
|
-
composables: userConfig.autoImports?.composables ?? true,
|
|
98
|
-
directives: userConfig.autoImports?.directives ?? true,
|
|
99
|
-
runtime: userConfig.autoImports?.runtime ?? true,
|
|
100
|
-
},
|
|
101
|
-
runtimeConfig: {
|
|
102
|
-
public: {
|
|
103
|
-
...(userConfig.siteUrl ? { siteUrl: userConfig.siteUrl.replace(/\/$/, '') } : {}),
|
|
104
|
-
...userConfig.runtimeConfig?.public,
|
|
105
|
-
},
|
|
106
|
-
private: userConfig.runtimeConfig?.private ?? {},
|
|
107
|
-
},
|
|
108
|
-
auth: userConfig.auth ?? null,
|
|
109
|
-
i18n: userConfig.i18n
|
|
110
|
-
? {
|
|
111
|
-
locales: userConfig.i18n.locales,
|
|
112
|
-
defaultLocale: userConfig.i18n.defaultLocale,
|
|
113
|
-
strategy: userConfig.i18n.strategy ?? 'prefix_except_default',
|
|
114
|
-
}
|
|
115
|
-
: null,
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Maps a resolved virtual ID to the appropriate generator function.
|
|
121
|
-
*/
|
|
122
|
-
async function generateVirtualModule(
|
|
123
|
-
id: string,
|
|
124
|
-
config: ResolvedCerConfig,
|
|
125
|
-
ssr = false,
|
|
126
|
-
): Promise<string | null> {
|
|
127
|
-
switch (id) {
|
|
128
|
-
case RESOLVED_IDS.routes:
|
|
129
|
-
return generateRoutesCode(config.pagesDir, config.i18n)
|
|
130
|
-
case RESOLVED_IDS.layouts:
|
|
131
|
-
return generateLayoutsCode(config.layoutsDir)
|
|
132
|
-
case RESOLVED_IDS.composables:
|
|
133
|
-
return generateComposablesCode(config.composablesDir)
|
|
134
|
-
case RESOLVED_IDS.plugins:
|
|
135
|
-
return generatePluginsCode(config.pluginsDir, ssr)
|
|
136
|
-
case RESOLVED_IDS.middleware:
|
|
137
|
-
return generateMiddlewareCode(config.middlewareDir)
|
|
138
|
-
case RESOLVED_IDS.serverApi:
|
|
139
|
-
return generateServerApiCode(config.serverApiDir, config.auth)
|
|
140
|
-
case RESOLVED_IDS.serverMiddleware:
|
|
141
|
-
return generateServerMiddlewareCode(config.serverMiddlewareDir)
|
|
142
|
-
case RESOLVED_IDS.appConfig:
|
|
143
|
-
return generateAppConfigModule(config, ssr)
|
|
144
|
-
case RESOLVED_IDS.loading:
|
|
145
|
-
return generateLoadingCode(config.srcDir)
|
|
146
|
-
case RESOLVED_IDS.error:
|
|
147
|
-
return generateErrorCode(config.srcDir)
|
|
148
|
-
case RESOLVED_IDS.contentComponents:
|
|
149
|
-
return generateContentComponentsCode(config.componentsDir, config.contentDir)
|
|
150
|
-
case RESOLVED_IDS.i18n:
|
|
151
|
-
return generateI18nModule(config.i18n)
|
|
152
|
-
case RESOLVED_IDS.jitInit:
|
|
153
|
-
return generateJitInitModule(config.jitCss)
|
|
154
|
-
default:
|
|
155
|
-
return null
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Generates the virtual:cer-i18n module that exports the resolved i18n config.
|
|
161
|
-
* Exports a null config when i18n is not configured so useLocale() degrades
|
|
162
|
-
* gracefully in apps that don't need internationalisation.
|
|
163
|
-
*/
|
|
164
|
-
function generateI18nModule(
|
|
165
|
-
i18n: ResolvedCerConfig['i18n'],
|
|
166
|
-
): string {
|
|
167
|
-
const value = i18n
|
|
168
|
-
? JSON.stringify({ locales: i18n.locales, defaultLocale: i18n.defaultLocale, strategy: i18n.strategy }, null, 2)
|
|
169
|
-
: 'null'
|
|
170
|
-
return (
|
|
171
|
-
`// AUTO-GENERATED by @jasonshimmy/vite-plugin-cer-app\n` +
|
|
172
|
-
`export const i18nConfig = ${value}\n` +
|
|
173
|
-
`export default i18nConfig\n`
|
|
174
|
-
)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Generates the virtual:cer-jit-init module that calls enableJITCSS() with the
|
|
179
|
-
* project's jitCss options. Imported as the first side-effect import in app.ts
|
|
180
|
-
* so JIT CSS is active before virtual:cer-layouts and virtual:cer-plugins run
|
|
181
|
-
* their static imports — which upgrade custom elements synchronously via
|
|
182
|
-
* customElements.define(). Without this, applyStyle() runs with _jitCSSEnabled=false
|
|
183
|
-
* and produces unstyled renders that replace the DSD pre-rendered content.
|
|
184
|
-
*/
|
|
185
|
-
export function generateJitInitModule(jitCss: ResolvedCerConfig['jitCss']): string {
|
|
186
|
-
const args: string[] = []
|
|
187
|
-
if (jitCss.extendedColors) {
|
|
188
|
-
args.push(`extendedColors: ${JSON.stringify(jitCss.extendedColors)}`)
|
|
189
|
-
}
|
|
190
|
-
if (jitCss.customColors && Object.keys(jitCss.customColors).length > 0) {
|
|
191
|
-
args.push(`customColors: ${JSON.stringify(jitCss.customColors)}`)
|
|
192
|
-
}
|
|
193
|
-
const callArgs = args.length > 0 ? `{ ${args.join(', ')} }` : ''
|
|
194
|
-
return (
|
|
195
|
-
`// AUTO-GENERATED by @jasonshimmy/vite-plugin-cer-app\n` +
|
|
196
|
-
`import { enableJITCSS } from '@jasonshimmy/custom-elements-runtime/jit-css'\n` +
|
|
197
|
-
`enableJITCSS(${callArgs})\n`
|
|
198
|
-
)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Generates a virtual module that exports the resolved app config.
|
|
203
|
-
* When `ssr` is true, also exports `_runtimePrivateDefaults` (server-only).
|
|
204
|
-
* The client bundle never receives private keys.
|
|
205
|
-
*/
|
|
206
|
-
function generateAppConfigModule(config: ResolvedCerConfig, ssr = false): string {
|
|
207
|
-
const exportedConfig = {
|
|
208
|
-
mode: config.mode,
|
|
209
|
-
router: config.router,
|
|
210
|
-
ssg: config.ssg,
|
|
211
|
-
}
|
|
212
|
-
const publicConfig = config.runtimeConfig.public
|
|
213
|
-
const i18nValue = config.i18n ? JSON.stringify(config.i18n) : 'null'
|
|
214
|
-
let code =
|
|
215
|
-
`// AUTO-GENERATED by @jasonshimmy/vite-plugin-cer-app\n` +
|
|
216
|
-
`export const appConfig = ${JSON.stringify(exportedConfig, null, 2)}\n` +
|
|
217
|
-
`export default appConfig\n` +
|
|
218
|
-
`\n` +
|
|
219
|
-
`export const runtimeConfig = { public: ${JSON.stringify(publicConfig, null, 2)} }\n` +
|
|
220
|
-
`\n` +
|
|
221
|
-
`export const i18nConfig = ${i18nValue}\n` +
|
|
222
|
-
`;(globalThis).__CER_I18N_CONFIG__ = i18nConfig\n` +
|
|
223
|
-
`;(globalThis).__CER_APP_CONFIG__ = appConfig\n`
|
|
224
|
-
|
|
225
|
-
if (ssr) {
|
|
226
|
-
const privateDefaults = config.runtimeConfig.private
|
|
227
|
-
code += `\nexport const _runtimePrivateDefaults = ${JSON.stringify(privateDefaults, null, 2)}\n`
|
|
228
|
-
// Expose the auth session key so the entry-server template can pre-resolve
|
|
229
|
-
// the authenticated user without duplicating config knowledge.
|
|
230
|
-
const authSessionKey = config.auth?.sessionKey ?? (config.auth ? 'auth' : null)
|
|
231
|
-
code += `\nexport const _authSessionKey = ${JSON.stringify(authSessionKey)}\n`
|
|
232
|
-
// Thread observability hooks by re-importing the user's cer.config.ts.
|
|
233
|
-
// Functions can't be JSON-serialised, so we import directly and re-export.
|
|
234
|
-
const configFilePath = join(config.root, 'cer.config.ts')
|
|
235
|
-
if (existsSync(configFilePath)) {
|
|
236
|
-
code += `\nimport _cerUserConfig from ${JSON.stringify(configFilePath)}\n`
|
|
237
|
-
code += `export const _hooks = {\n`
|
|
238
|
-
code += ` onError: _cerUserConfig.onError ?? null,\n`
|
|
239
|
-
code += ` onRequest: _cerUserConfig.onRequest ?? null,\n`
|
|
240
|
-
code += ` onResponse: _cerUserConfig.onResponse ?? null,\n`
|
|
241
|
-
code += `}\n`
|
|
242
|
-
} else {
|
|
243
|
-
code += `\nexport const _hooks = { onError: null, onRequest: null, onResponse: null }\n`
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return code
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Determines which virtual module IDs should be invalidated when a file changes
|
|
252
|
-
* in a given directory.
|
|
253
|
-
*/
|
|
254
|
-
function getDirtyVirtualIds(filePath: string, config: ResolvedCerConfig): string[] {
|
|
255
|
-
const dirty: string[] = []
|
|
256
|
-
|
|
257
|
-
if (filePath.startsWith(config.pagesDir)) {
|
|
258
|
-
dirty.push(RESOLVED_IDS.routes)
|
|
259
|
-
}
|
|
260
|
-
if (filePath.startsWith(config.layoutsDir)) {
|
|
261
|
-
dirty.push(RESOLVED_IDS.layouts)
|
|
262
|
-
}
|
|
263
|
-
if (filePath.startsWith(config.componentsDir)) {
|
|
264
|
-
dirty.push(RESOLVED_IDS.contentComponents)
|
|
265
|
-
}
|
|
266
|
-
if (filePath.startsWith(config.composablesDir)) {
|
|
267
|
-
dirty.push(RESOLVED_IDS.composables)
|
|
268
|
-
}
|
|
269
|
-
if (filePath.startsWith(config.pluginsDir)) {
|
|
270
|
-
dirty.push(RESOLVED_IDS.plugins)
|
|
271
|
-
}
|
|
272
|
-
if (filePath.startsWith(config.middlewareDir)) {
|
|
273
|
-
dirty.push(RESOLVED_IDS.middleware)
|
|
274
|
-
}
|
|
275
|
-
if (filePath.startsWith(config.serverApiDir)) {
|
|
276
|
-
dirty.push(RESOLVED_IDS.serverApi)
|
|
277
|
-
}
|
|
278
|
-
if (filePath.startsWith(config.serverMiddlewareDir)) {
|
|
279
|
-
dirty.push(RESOLVED_IDS.serverMiddleware)
|
|
280
|
-
}
|
|
281
|
-
if (filePath.startsWith(config.contentDir)) {
|
|
282
|
-
dirty.push(RESOLVED_IDS.contentComponents)
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return dirty
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* The main cerApp() Vite plugin factory.
|
|
290
|
-
* Returns an array of plugins: the cer-app orchestrator + the runtime JIT CSS plugin(s).
|
|
291
|
-
*/
|
|
292
|
-
export function cerApp(userConfig: CerAppConfig = {}): Plugin[] {
|
|
293
|
-
let config: ResolvedCerConfig
|
|
294
|
-
let composableExports = new Map<string, string>()
|
|
295
|
-
|
|
296
|
-
// Cache for generated virtual module code (invalidated on file changes)
|
|
297
|
-
const moduleCache = new Map<string, string>()
|
|
298
|
-
|
|
299
|
-
const cerAppPlugin: Plugin = {
|
|
300
|
-
name: '@jasonshimmy/vite-plugin-cer-app',
|
|
301
|
-
|
|
302
|
-
config(viteConfig) {
|
|
303
|
-
const root = viteConfig.root ? resolve(viteConfig.root) : process.cwd()
|
|
304
|
-
config = resolveConfig(userConfig, root)
|
|
305
|
-
return {
|
|
306
|
-
build: {
|
|
307
|
-
target: 'esnext',
|
|
308
|
-
rollupOptions: {
|
|
309
|
-
onwarn(warning, warn) {
|
|
310
|
-
// loader and meta are optional exports from page files — suppress noise
|
|
311
|
-
if (
|
|
312
|
-
warning.code === 'MISSING_EXPORT' &&
|
|
313
|
-
(warning.binding === 'loader' || warning.binding === 'meta')
|
|
314
|
-
) {
|
|
315
|
-
return
|
|
316
|
-
}
|
|
317
|
-
warn(warning)
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
},
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
|
|
324
|
-
configResolved(resolvedConfig) {
|
|
325
|
-
// Re-resolve with the final root
|
|
326
|
-
config = resolveConfig(userConfig, resolvedConfig.root)
|
|
327
|
-
// Write .cer/ immediately after config is resolved so the physical
|
|
328
|
-
// app.ts exists for IDE/TypeScript support before any Vite hooks fire.
|
|
329
|
-
writeGeneratedDir(config)
|
|
330
|
-
},
|
|
331
|
-
|
|
332
|
-
transformIndexHtml(html: string) {
|
|
333
|
-
// Rewrite any existing /.cer/app.ts src reference (older projects or
|
|
334
|
-
// the scaffold template) to /@cer/app.ts so Vite's transform middleware
|
|
335
|
-
// processes it. Vite blocks /.* paths from the transform pipeline.
|
|
336
|
-
return html.replace(/src=["']\/\.cer\/app\.ts["']/g, 'src="/@cer/app.ts"')
|
|
337
|
-
},
|
|
338
|
-
|
|
339
|
-
resolveId(id: string) {
|
|
340
|
-
if (id === APP_ENTRY_URL) return RESOLVED_APP_ENTRY
|
|
341
|
-
if ((Object.values(VIRTUAL_IDS) as string[]).includes(id)) {
|
|
342
|
-
return `\0${id}`
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
async load(id: string, options?: { ssr?: boolean }) {
|
|
347
|
-
if (id === RESOLVED_APP_ENTRY) return generateAppEntryTemplate()
|
|
348
|
-
|
|
349
|
-
const allResolved = Object.values(RESOLVED_IDS) as string[]
|
|
350
|
-
if (!allResolved.includes(id)) return null
|
|
351
|
-
|
|
352
|
-
const ssr = options?.ssr ?? false
|
|
353
|
-
// For virtual:cer-app-config and virtual:cer-plugins the SSR and client
|
|
354
|
-
// variants differ: app-config includes private defaults in SSR; plugins
|
|
355
|
-
// excludes .client.ts files in SSR. Use separate cache keys for both.
|
|
356
|
-
const cacheKey = (id === RESOLVED_IDS.appConfig || id === RESOLVED_IDS.plugins)
|
|
357
|
-
? `${id}:${ssr ? 'ssr' : 'client'}`
|
|
358
|
-
: id
|
|
359
|
-
|
|
360
|
-
// Return from cache if available
|
|
361
|
-
if (moduleCache.has(cacheKey)) {
|
|
362
|
-
return moduleCache.get(cacheKey)!
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Generate and cache
|
|
366
|
-
const code = await generateVirtualModule(id, config, ssr)
|
|
367
|
-
if (code !== null) {
|
|
368
|
-
moduleCache.set(cacheKey, code)
|
|
369
|
-
return code
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return null
|
|
373
|
-
},
|
|
374
|
-
|
|
375
|
-
transform(code: string, id: string) {
|
|
376
|
-
if (!config) return null
|
|
377
|
-
if (config.autoImports?.runtime === false) return null
|
|
378
|
-
// Skip virtual modules
|
|
379
|
-
if (id.startsWith('\0')) return null
|
|
380
|
-
|
|
381
|
-
const result = autoImportTransform(code, id, {
|
|
382
|
-
srcDir: config.srcDir,
|
|
383
|
-
serverMiddlewareDir: config.serverMiddlewareDir,
|
|
384
|
-
composableExports: config.autoImports?.composables !== false ? composableExports : undefined,
|
|
385
|
-
})
|
|
386
|
-
if (result === null) return null
|
|
387
|
-
return { code: result, map: null }
|
|
388
|
-
},
|
|
389
|
-
|
|
390
|
-
async configureServer(server: ViteDevServer) {
|
|
391
|
-
if (!config) {
|
|
392
|
-
// config might not be set yet; resolve with cwd
|
|
393
|
-
config = resolveConfig(userConfig, process.cwd())
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// Write .cer/ generated files (app.ts fallback, index.html, .gitignore)
|
|
397
|
-
writeGeneratedDir(config)
|
|
398
|
-
|
|
399
|
-
// Scan composables and write .d.ts + tsconfig paths on dev server start
|
|
400
|
-
composableExports = await scanComposableExports(config.composablesDir)
|
|
401
|
-
await writeAutoImportDts(config.root, config.composablesDir, composableExports)
|
|
402
|
-
writeTsconfigPaths(config.root, config.srcDir)
|
|
403
|
-
|
|
404
|
-
// Serve a generated index.html for HTML requests when the consumer has
|
|
405
|
-
// not provided one. This runs BEFORE configureCerDevServer so that the
|
|
406
|
-
// Vite HTML pipeline (HMR injection, module preprocessing) is applied.
|
|
407
|
-
const userHtml = resolve(config.root, 'index.html')
|
|
408
|
-
if (!existsSync(userHtml)) {
|
|
409
|
-
const cerHtmlPath = join(getGeneratedDir(config.root), 'index.html')
|
|
410
|
-
server.middlewares.use(async (req, res, next) => {
|
|
411
|
-
// In SSR/SSG mode, HTML requests must fall through to configureCerDevServer
|
|
412
|
-
// so the SSR handler can run loaders and inject __CER_DATA__ into the response.
|
|
413
|
-
// Only SPA mode (no server rendering) should serve the raw SPA shell here.
|
|
414
|
-
if (config.mode === 'ssr' || config.mode === 'ssg') {
|
|
415
|
-
next()
|
|
416
|
-
return
|
|
417
|
-
}
|
|
418
|
-
const url = (req as { url?: string }).url ?? '/'
|
|
419
|
-
const isHtmlRequest =
|
|
420
|
-
url === '/' ||
|
|
421
|
-
url === '/index.html' ||
|
|
422
|
-
(!url.includes('.') && !url.startsWith('/api/'))
|
|
423
|
-
if (isHtmlRequest && existsSync(cerHtmlPath)) {
|
|
424
|
-
const rawHtml = readFileSync(cerHtmlPath, 'utf-8')
|
|
425
|
-
const transformed = await server.transformIndexHtml(url, rawHtml)
|
|
426
|
-
res.setHeader('Content-Type', 'text/html; charset=utf-8')
|
|
427
|
-
res.end(transformed)
|
|
428
|
-
return
|
|
429
|
-
}
|
|
430
|
-
next()
|
|
431
|
-
})
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
// Watch app/ and server/ directories for file changes
|
|
435
|
-
const watchDirs = [
|
|
436
|
-
config.pagesDir,
|
|
437
|
-
config.layoutsDir,
|
|
438
|
-
config.componentsDir,
|
|
439
|
-
config.contentDir,
|
|
440
|
-
config.composablesDir,
|
|
441
|
-
config.pluginsDir,
|
|
442
|
-
config.middlewareDir,
|
|
443
|
-
config.serverApiDir,
|
|
444
|
-
config.serverMiddlewareDir,
|
|
445
|
-
]
|
|
446
|
-
|
|
447
|
-
createWatcher(server.watcher, watchDirs, async (event, file) => {
|
|
448
|
-
if (event === 'add' || event === 'unlink') {
|
|
449
|
-
// Re-scan composables and regenerate .d.ts if a composable changed
|
|
450
|
-
if (file.startsWith(config.composablesDir)) {
|
|
451
|
-
composableExports = await scanComposableExports(config.composablesDir)
|
|
452
|
-
await writeAutoImportDts(config.root, config.composablesDir, composableExports)
|
|
453
|
-
}
|
|
454
|
-
// Invalidate relevant virtual modules
|
|
455
|
-
const dirtyIds = getDirtyVirtualIds(file, config)
|
|
456
|
-
for (const resolvedId of dirtyIds) {
|
|
457
|
-
moduleCache.delete(resolvedId)
|
|
458
|
-
const mod = server.moduleGraph.getModuleById(resolvedId)
|
|
459
|
-
if (mod) {
|
|
460
|
-
server.moduleGraph.invalidateModule(mod)
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
// Trigger HMR
|
|
464
|
-
server.ws.send({ type: 'full-reload' })
|
|
465
|
-
}
|
|
466
|
-
})
|
|
467
|
-
|
|
468
|
-
// Register dev server middleware for API routes + SSR
|
|
469
|
-
configureCerDevServer(server, config)
|
|
470
|
-
},
|
|
471
|
-
|
|
472
|
-
async buildStart() {
|
|
473
|
-
if (!config) {
|
|
474
|
-
config = resolveConfig(userConfig, process.cwd())
|
|
475
|
-
}
|
|
476
|
-
// Write .cer/ generated files before the build begins
|
|
477
|
-
writeGeneratedDir(config)
|
|
478
|
-
// Scan composables and generate type declarations + tsconfig paths
|
|
479
|
-
composableExports = await scanComposableExports(config.composablesDir)
|
|
480
|
-
await writeAutoImportDts(config.root, config.composablesDir, composableExports)
|
|
481
|
-
writeTsconfigPaths(config.root, config.srcDir)
|
|
482
|
-
// Warm the virtual module cache.
|
|
483
|
-
// virtual:cer-app-config is cached under separate :client/:ssr keys because
|
|
484
|
-
// the SSR variant includes _runtimePrivateDefaults (private env var defaults)
|
|
485
|
-
// that must never appear in the client bundle. Warm both variants here so
|
|
486
|
-
// neither the client build nor the SSR build incurs a cache miss on first load.
|
|
487
|
-
for (const resolvedId of Object.values(RESOLVED_IDS)) {
|
|
488
|
-
if (resolvedId === RESOLVED_IDS.appConfig) {
|
|
489
|
-
const clientCode = await generateVirtualModule(resolvedId, config, false)
|
|
490
|
-
if (clientCode !== null) moduleCache.set(`${resolvedId}:client`, clientCode)
|
|
491
|
-
const ssrCode = await generateVirtualModule(resolvedId, config, true)
|
|
492
|
-
if (ssrCode !== null) moduleCache.set(`${resolvedId}:ssr`, ssrCode)
|
|
493
|
-
} else {
|
|
494
|
-
const code = await generateVirtualModule(resolvedId, config)
|
|
495
|
-
if (code !== null) moduleCache.set(resolvedId, code)
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
},
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// Include cerPlugin from the runtime for JIT CSS support
|
|
502
|
-
// Resolve config eagerly so cerPlugin can use the final resolved values
|
|
503
|
-
const resolvedForJit = resolveConfig(userConfig)
|
|
504
|
-
const { content, ...jitOptions } = resolvedForJit.jitCss
|
|
505
|
-
const jitPlugins = cerPlugin({
|
|
506
|
-
content,
|
|
507
|
-
...jitOptions,
|
|
508
|
-
ssr: {
|
|
509
|
-
dsd: true,
|
|
510
|
-
jit: jitOptions,
|
|
511
|
-
},
|
|
512
|
-
})
|
|
513
|
-
|
|
514
|
-
// cerComponentImports must be initialized lazily — it needs the root-resolved
|
|
515
|
-
// config.componentsDir and config.srcDir, which are only available after Vite
|
|
516
|
-
// calls configResolved (where `config` is finalized with the correct root).
|
|
517
|
-
// Initializing with resolvedForJit (which uses process.cwd() as root) would
|
|
518
|
-
// point to wrong paths when the CLI builds with --root pointing elsewhere.
|
|
519
|
-
let _componentImports: Plugin | null = null
|
|
520
|
-
|
|
521
|
-
const componentImportsProxy: Plugin = {
|
|
522
|
-
name: 'cer-component-imports',
|
|
523
|
-
enforce: 'pre' as const,
|
|
524
|
-
resolveId(id: string, importer: string | undefined) {
|
|
525
|
-
// The library root package.json has "sideEffects": ["**/*.css"], which causes
|
|
526
|
-
// Rollup to tree-shake side-effect-only imports of .ts files (e.g. component
|
|
527
|
-
// registrations) when those files reside inside the same package boundary.
|
|
528
|
-
// Override this for all app .ts files so their component() calls are retained.
|
|
529
|
-
//
|
|
530
|
-
// Two import forms need coverage:
|
|
531
|
-
// 1. Relative imports from page/component files: e.g. './ks-badge.ts'
|
|
532
|
-
// 2. Absolute imports from virtual modules: e.g. virtual:cer-layouts generates
|
|
533
|
-
// `import "/abs/path/app/layouts/default.ts"` as a side-effect import.
|
|
534
|
-
if (!importer || !config) return null
|
|
535
|
-
const appRoot = config.srcDir.replace(/\\/g, '/').replace(/\/?$/, '/')
|
|
536
|
-
let resolved: string
|
|
537
|
-
if (id.startsWith('/')) {
|
|
538
|
-
// Absolute path (used by virtual module generators like virtual:cer-layouts)
|
|
539
|
-
resolved = id.replace(/\\/g, '/')
|
|
540
|
-
} else if (id.startsWith('.')) {
|
|
541
|
-
// Relative path from the importing file
|
|
542
|
-
const importerDir = dirname(importer.split('?')[0])
|
|
543
|
-
resolved = resolve(importerDir, id).replace(/\\/g, '/')
|
|
544
|
-
} else {
|
|
545
|
-
return null
|
|
546
|
-
}
|
|
547
|
-
if (resolved.startsWith(appRoot) && resolved.endsWith('.ts')) {
|
|
548
|
-
return { id: resolved, moduleSideEffects: true }
|
|
549
|
-
}
|
|
550
|
-
return null
|
|
551
|
-
},
|
|
552
|
-
buildStart(opts) {
|
|
553
|
-
// Initialize here so config is guaranteed to be fully resolved.
|
|
554
|
-
// All configResolved hooks (including cerAppPlugin's) fire before any buildStart.
|
|
555
|
-
_componentImports = cerComponentImports({
|
|
556
|
-
componentsDir: config.componentsDir,
|
|
557
|
-
appRoot: config.srcDir,
|
|
558
|
-
}) as Plugin
|
|
559
|
-
return (_componentImports?.buildStart as ((this: unknown, o: unknown) => void) | undefined)
|
|
560
|
-
?.call(this, opts)
|
|
561
|
-
},
|
|
562
|
-
watchChange(id: string, change: { event: 'create' | 'update' | 'delete' }) {
|
|
563
|
-
return (_componentImports?.watchChange as ((this: unknown, id: string, change: unknown) => void) | undefined)
|
|
564
|
-
?.call(this, id, change)
|
|
565
|
-
},
|
|
566
|
-
transform(code: string, id: string) {
|
|
567
|
-
return (_componentImports?.transform as ((this: unknown, code: string, id: string) => unknown) | undefined)
|
|
568
|
-
?.call(this, code, id) ?? null
|
|
569
|
-
},
|
|
570
|
-
handleHotUpdate(ctx: unknown) {
|
|
571
|
-
;(_componentImports?.handleHotUpdate as ((this: unknown, ctx: unknown) => void) | undefined)
|
|
572
|
-
?.call(this, ctx)
|
|
573
|
-
},
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
return [
|
|
577
|
-
cerAppPlugin,
|
|
578
|
-
...jitPlugins,
|
|
579
|
-
...(userConfig.autoImports?.components !== false ? [componentImportsProxy] : []),
|
|
580
|
-
cerContent(
|
|
581
|
-
userConfig.content,
|
|
582
|
-
),
|
|
583
|
-
]
|
|
584
|
-
}
|