@jasonshimmy/vite-plugin-cer-app 0.23.2 → 0.24.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/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/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 +3 -1
- 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 +227 -17
- package/dist/plugin/build-ssg.js.map +1 -1
- package/dist/plugin/content/parser.d.ts.map +1 -1
- package/dist/plugin/content/parser.js +54 -10
- 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 +6 -0
- package/dist/plugin/html-post-process.d.ts.map +1 -1
- package/dist/plugin/html-post-process.js +24 -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 +179 -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/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
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { autoImportTransform } from '../../../plugin/transforms/auto-import.js'
|
|
3
|
-
|
|
4
|
-
const srcDir = '/project/app'
|
|
5
|
-
const opts = { srcDir }
|
|
6
|
-
|
|
7
|
-
const RUNTIME_PKG = `'@jasonshimmy/custom-elements-runtime'`
|
|
8
|
-
const DIRECTIVES_PKG = `'@jasonshimmy/custom-elements-runtime/directives'`
|
|
9
|
-
const FRAMEWORK_PKG = `'@jasonshimmy/vite-plugin-cer-app/composables'`
|
|
10
|
-
|
|
11
|
-
// ─── Target-directory gating ─────────────────────────────────────────────────
|
|
12
|
-
|
|
13
|
-
describe('autoImportTransform — target directory gating', () => {
|
|
14
|
-
it('returns null for files outside pages/, layouts/, components/, middleware/, composables/', () => {
|
|
15
|
-
expect(
|
|
16
|
-
autoImportTransform("component('x', () => html``)", '/project/app/plugins/my-plugin.ts', opts),
|
|
17
|
-
).toBeNull()
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('returns null for virtual modules (id starts with \\0)', () => {
|
|
21
|
-
expect(
|
|
22
|
-
autoImportTransform("component('x', () => html``)", '\0virtual:cer-routes', opts),
|
|
23
|
-
).toBeNull()
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('returns null for non-.ts/.js files', () => {
|
|
27
|
-
expect(
|
|
28
|
-
autoImportTransform('<div>content</div>', '/project/app/pages/about.html', opts),
|
|
29
|
-
).toBeNull()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('transforms files in pages/', () => {
|
|
33
|
-
const result = autoImportTransform(
|
|
34
|
-
"component('page-about', () => html`<h1>About</h1>`)",
|
|
35
|
-
'/project/app/pages/about.ts',
|
|
36
|
-
opts,
|
|
37
|
-
)
|
|
38
|
-
expect(result).not.toBeNull()
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('transforms files in layouts/', () => {
|
|
42
|
-
const result = autoImportTransform(
|
|
43
|
-
"component('layout-default', () => html`<slot></slot>`)",
|
|
44
|
-
'/project/app/layouts/default.ts',
|
|
45
|
-
opts,
|
|
46
|
-
)
|
|
47
|
-
expect(result).not.toBeNull()
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('transforms files in components/', () => {
|
|
51
|
-
const result = autoImportTransform(
|
|
52
|
-
"component('my-button', () => html`<button></button>`)",
|
|
53
|
-
'/project/app/components/my-button.ts',
|
|
54
|
-
opts,
|
|
55
|
-
)
|
|
56
|
-
expect(result).not.toBeNull()
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('transforms files in middleware/ (so defineMiddleware is auto-imported)', () => {
|
|
60
|
-
const result = autoImportTransform(
|
|
61
|
-
"export default defineMiddleware(() => true)",
|
|
62
|
-
'/project/app/middleware/auth.ts',
|
|
63
|
-
opts,
|
|
64
|
-
)
|
|
65
|
-
expect(result).not.toBeNull()
|
|
66
|
-
expect(result).toContain('defineMiddleware')
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
it('injects framework imports for composables/ (in scope)', () => {
|
|
70
|
-
const result = autoImportTransform("export default defineMiddleware(() => true)", '/project/app/composables/useTheme.ts', opts)
|
|
71
|
-
expect(result).not.toBeNull()
|
|
72
|
-
expect(result).toContain('defineMiddleware')
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
// ─── No injection needed ─────────────────────────────────────────────────────
|
|
77
|
-
|
|
78
|
-
describe('autoImportTransform — no injection needed', () => {
|
|
79
|
-
it('returns null when no runtime or directive identifiers are used', () => {
|
|
80
|
-
expect(
|
|
81
|
-
autoImportTransform('const greeting = "hello"', '/project/app/pages/about.ts', opts),
|
|
82
|
-
).toBeNull()
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it('returns null when runtime is already imported from the package', () => {
|
|
86
|
-
const code =
|
|
87
|
-
`import { component, html } from ${RUNTIME_PKG}\ncomponent('test', () => html\`\`)`
|
|
88
|
-
expect(autoImportTransform(code, '/project/app/pages/about.ts', opts)).toBeNull()
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('returns null when directives already imported and no other identifiers used', () => {
|
|
92
|
-
const code = `import { when } from ${DIRECTIVES_PKG}\nconst x = 1`
|
|
93
|
-
expect(autoImportTransform(code, '/project/app/pages/about.ts', opts)).toBeNull()
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
// ─── Runtime import injection ────────────────────────────────────────────────
|
|
98
|
-
|
|
99
|
-
describe('autoImportTransform — runtime import injection', () => {
|
|
100
|
-
it('injects runtime import when "component" identifier is used', () => {
|
|
101
|
-
const result = autoImportTransform(
|
|
102
|
-
"component('page-about', () => {})",
|
|
103
|
-
'/project/app/pages/about.ts',
|
|
104
|
-
opts,
|
|
105
|
-
)!
|
|
106
|
-
expect(result).toContain(`from ${RUNTIME_PKG}`)
|
|
107
|
-
expect(result).toContain('component')
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
it('injects runtime import when "html" identifier is used', () => {
|
|
111
|
-
const result = autoImportTransform(
|
|
112
|
-
'const t = html`<div></div>`',
|
|
113
|
-
'/project/app/pages/about.ts',
|
|
114
|
-
opts,
|
|
115
|
-
)!
|
|
116
|
-
expect(result).toContain(`from ${RUNTIME_PKG}`)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it('injects runtime import when "ref" identifier is used', () => {
|
|
120
|
-
const result = autoImportTransform(
|
|
121
|
-
'const count = ref(0)',
|
|
122
|
-
'/project/app/pages/counter.ts',
|
|
123
|
-
opts,
|
|
124
|
-
)!
|
|
125
|
-
expect(result).toContain(`from ${RUNTIME_PKG}`)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('prepends import at the very top of the file', () => {
|
|
129
|
-
const original = "component('x', () => html``)"
|
|
130
|
-
const result = autoImportTransform(original, '/project/app/pages/test.ts', opts)!
|
|
131
|
-
expect(result.startsWith('import {')).toBe(true)
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
it('does not add duplicate runtime import when already present', () => {
|
|
135
|
-
const code = `import { component } from ${RUNTIME_PKG}\ncomponent('x', () => {})`
|
|
136
|
-
const result = autoImportTransform(code, '/project/app/pages/test.ts', opts)
|
|
137
|
-
const count = (result ?? code).split(`from ${RUNTIME_PKG}`).length - 1
|
|
138
|
-
expect(count).toBe(1)
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
// ─── Directive import injection ──────────────────────────────────────────────
|
|
143
|
-
|
|
144
|
-
describe('autoImportTransform — directive import injection', () => {
|
|
145
|
-
it('injects directive import when "when" identifier is used', () => {
|
|
146
|
-
const result = autoImportTransform(
|
|
147
|
-
'const t = when(true, html`<span>yes</span>`)',
|
|
148
|
-
'/project/app/pages/about.ts',
|
|
149
|
-
opts,
|
|
150
|
-
)!
|
|
151
|
-
expect(result).toContain(`from ${DIRECTIVES_PKG}`)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
it('injects directive import when "each" identifier is used', () => {
|
|
155
|
-
const result = autoImportTransform(
|
|
156
|
-
'const t = each(items, (item) => html`<li>${item}</li>`)',
|
|
157
|
-
'/project/app/pages/list.ts',
|
|
158
|
-
opts,
|
|
159
|
-
)!
|
|
160
|
-
expect(result).toContain(`from ${DIRECTIVES_PKG}`)
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
it('injects directive import when "match" identifier is used', () => {
|
|
164
|
-
const result = autoImportTransform(
|
|
165
|
-
'const t = match(state, {})',
|
|
166
|
-
'/project/app/pages/test.ts',
|
|
167
|
-
opts,
|
|
168
|
-
)!
|
|
169
|
-
expect(result).toContain(`from ${DIRECTIVES_PKG}`)
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
it('does not add duplicate directive import when already present', () => {
|
|
173
|
-
const code = `import { when } from ${DIRECTIVES_PKG}\nconst t = when(true, html\`\`)`
|
|
174
|
-
// html is used → runtime import needed, but directives should not be duplicated
|
|
175
|
-
const result = autoImportTransform(code, '/project/app/pages/test.ts', opts)!
|
|
176
|
-
const count = (result ?? code).split(`from ${DIRECTIVES_PKG}`).length - 1
|
|
177
|
-
expect(count).toBe(1)
|
|
178
|
-
})
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
// ─── Both runtime + directive injected ───────────────────────────────────────
|
|
182
|
-
|
|
183
|
-
describe('autoImportTransform — both runtime and directive injection', () => {
|
|
184
|
-
it('injects both when both are needed', () => {
|
|
185
|
-
const code = "component('x', () => html`${when(true, html`<span></span>`)}`)"
|
|
186
|
-
const result = autoImportTransform(code, '/project/app/pages/test.ts', opts)!
|
|
187
|
-
expect(result).toContain(`from ${RUNTIME_PKG}`)
|
|
188
|
-
expect(result).toContain(`from ${DIRECTIVES_PKG}`)
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
it('only injects runtime when directives already imported', () => {
|
|
192
|
-
const code = `import { when } from ${DIRECTIVES_PKG}\ncomponent('x', () => html\`\`)`
|
|
193
|
-
const result = autoImportTransform(code, '/project/app/pages/test.ts', opts)!
|
|
194
|
-
expect(result).toContain(`from ${RUNTIME_PKG}`)
|
|
195
|
-
const directivesCount = result.split(`from ${DIRECTIVES_PKG}`).length - 1
|
|
196
|
-
expect(directivesCount).toBe(1) // only the original, not a new one
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
// ─── Framework composable injection (useHead) ────────────────────────────────
|
|
201
|
-
|
|
202
|
-
describe('autoImportTransform — framework composable injection', () => {
|
|
203
|
-
it('injects useHead import when useHead is used', () => {
|
|
204
|
-
const code = "component('page-about', () => { useHead({ title: 'About' }); return html`<h1>About</h1>` })"
|
|
205
|
-
const result = autoImportTransform(code, '/project/app/pages/about.ts', opts)!
|
|
206
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
207
|
-
expect(result).toContain('useHead')
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
it('does not inject useHead when not used', () => {
|
|
211
|
-
const code = "component('page-about', () => html`<h1>About</h1>`)"
|
|
212
|
-
const result = autoImportTransform(code, '/project/app/pages/about.ts', opts)
|
|
213
|
-
expect(result === null || !result.includes(FRAMEWORK_PKG)).toBe(true)
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
it('does not add duplicate useHead import when already present', () => {
|
|
217
|
-
const code = `import { useHead } from ${FRAMEWORK_PKG}\ncomponent('x', () => { useHead({ title: 'X' }); return html\`\` })`
|
|
218
|
-
const result = autoImportTransform(code, '/project/app/pages/test.ts', opts)!
|
|
219
|
-
const count = (result ?? code).split(`from ${FRAMEWORK_PKG}`).length - 1
|
|
220
|
-
expect(count).toBe(1)
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
it('injects usePageData import when usePageData is used', () => {
|
|
224
|
-
const code = "component('page-items-id', () => { const data = usePageData(); return html`<div></div>` })"
|
|
225
|
-
const result = autoImportTransform(code, '/project/app/pages/items/[id].ts', opts)!
|
|
226
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
227
|
-
expect(result).toContain('usePageData')
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
it('injects both useHead and usePageData when both are used', () => {
|
|
231
|
-
const code = "component('page-blog-slug', () => { useHead({ title: 'x' }); const data = usePageData(); return html`<div></div>` })"
|
|
232
|
-
const result = autoImportTransform(code, '/project/app/pages/blog/[slug].ts', opts)!
|
|
233
|
-
expect(result).toContain('useHead')
|
|
234
|
-
expect(result).toContain('usePageData')
|
|
235
|
-
// Only one import statement from the framework package
|
|
236
|
-
const count = result.split(`from ${FRAMEWORK_PKG}`).length - 1
|
|
237
|
-
expect(count).toBe(1)
|
|
238
|
-
})
|
|
239
|
-
|
|
240
|
-
it('injects useInject import when useInject is used', () => {
|
|
241
|
-
const code = "component('page-about', () => { const svc = useInject('my-service'); return html`<div></div>` })"
|
|
242
|
-
const result = autoImportTransform(code, '/project/app/pages/about.ts', opts)!
|
|
243
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
244
|
-
expect(result).toContain('useInject')
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
it('injects usePageData for root-level convention files (loading.ts, error.ts)', () => {
|
|
248
|
-
const code = "component('page-loading', () => { const d = usePageData(); return html`<div></div>` })"
|
|
249
|
-
const result = autoImportTransform(code, '/project/app/loading.ts', opts)!
|
|
250
|
-
expect(result).toContain('usePageData')
|
|
251
|
-
})
|
|
252
|
-
|
|
253
|
-
it('injects useRuntimeConfig import when useRuntimeConfig is used', () => {
|
|
254
|
-
const code = "component('page-dashboard', () => { const cfg = useRuntimeConfig(); return html`<div></div>` })"
|
|
255
|
-
const result = autoImportTransform(code, '/project/app/pages/dashboard.ts', opts)!
|
|
256
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
257
|
-
expect(result).toContain('useRuntimeConfig')
|
|
258
|
-
})
|
|
259
|
-
|
|
260
|
-
it('injects useRuntimeConfig alongside other framework composables', () => {
|
|
261
|
-
const code = "component('page-x', () => { useHead({ title: 'x' }); const cfg = useRuntimeConfig(); return html`<div></div>` })"
|
|
262
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', opts)!
|
|
263
|
-
expect(result).toContain('useHead')
|
|
264
|
-
expect(result).toContain('useRuntimeConfig')
|
|
265
|
-
const count = result.split(`from ${FRAMEWORK_PKG}`).length - 1
|
|
266
|
-
expect(count).toBe(1)
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
it('injects useSeoMeta import when useSeoMeta is used', () => {
|
|
270
|
-
const code = "component('page-home', () => { useSeoMeta({ title: 'Home', description: 'Welcome' }); return html`<h1>Home</h1>` })"
|
|
271
|
-
const result = autoImportTransform(code, '/project/app/pages/index.ts', opts)!
|
|
272
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
273
|
-
expect(result).toContain('useSeoMeta')
|
|
274
|
-
})
|
|
275
|
-
|
|
276
|
-
it('injects useCookie import when useCookie is used', () => {
|
|
277
|
-
const code = "component('page-profile', () => { const session = useCookie('session'); return html`<div></div>` })"
|
|
278
|
-
const result = autoImportTransform(code, '/project/app/pages/profile.ts', opts)!
|
|
279
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
280
|
-
expect(result).toContain('useCookie')
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
it('injects useSeoMeta and useCookie alongside other framework composables in a single import', () => {
|
|
284
|
-
const code = "component('page-shop', () => { useSeoMeta({ title: 'Shop' }); const cart = useCookie('cart'); return html`<div></div>` })"
|
|
285
|
-
const result = autoImportTransform(code, '/project/app/pages/shop.ts', opts)!
|
|
286
|
-
expect(result).toContain('useSeoMeta')
|
|
287
|
-
expect(result).toContain('useCookie')
|
|
288
|
-
const count = result.split(`from ${FRAMEWORK_PKG}`).length - 1
|
|
289
|
-
expect(count).toBe(1)
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
it('injects defineServerMiddleware import when defineServerMiddleware is used', () => {
|
|
293
|
-
const code = "export default defineServerMiddleware((_req, _res, next) => { next() })"
|
|
294
|
-
const result = autoImportTransform(code, '/project/app/middleware/server-check.ts', opts)!
|
|
295
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
296
|
-
expect(result).toContain('defineServerMiddleware')
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
it('injects useSession import when useSession is used', () => {
|
|
300
|
-
const code = "component('page-x', () => { const s = useSession(); return html`<div></div>` })"
|
|
301
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', opts)!
|
|
302
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
303
|
-
expect(result).toContain('useSession')
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
it('injects useState import when useState is used', () => {
|
|
307
|
-
const code = "component('layout-default', () => { const title = useState('pageTitle', 'My App'); return html`<title>${title.value}</title><slot></slot>` })"
|
|
308
|
-
const result = autoImportTransform(code, '/project/app/layouts/default.ts', opts)!
|
|
309
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
310
|
-
expect(result).toContain('useState')
|
|
311
|
-
})
|
|
312
|
-
|
|
313
|
-
it('does not inject useState when not used', () => {
|
|
314
|
-
const code = "component('layout-default', () => html`<slot></slot>`)"
|
|
315
|
-
const result = autoImportTransform(code, '/project/app/layouts/default.ts', opts)
|
|
316
|
-
expect(result === null || !result!.includes('useState')).toBe(true)
|
|
317
|
-
})
|
|
318
|
-
|
|
319
|
-
it('injects useState alongside other framework composables in a single import', () => {
|
|
320
|
-
const code = "component('layout-x', () => { useHead({ title: 'x' }); const title = useState('t', ''); return html`` })"
|
|
321
|
-
const result = autoImportTransform(code, '/project/app/layouts/x.ts', opts)!
|
|
322
|
-
expect(result).toContain('useHead')
|
|
323
|
-
expect(result).toContain('useState')
|
|
324
|
-
const count = result.split(`from ${FRAMEWORK_PKG}`).length - 1
|
|
325
|
-
expect(count).toBe(1)
|
|
326
|
-
})
|
|
327
|
-
|
|
328
|
-
it('injects useLocale import when useLocale is used', () => {
|
|
329
|
-
const code = "component('page-about', () => { const { locale } = useLocale(); return html`<p>${locale}</p>` })"
|
|
330
|
-
const result = autoImportTransform(code, '/project/app/pages/about.ts', opts)!
|
|
331
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
332
|
-
expect(result).toContain('useLocale')
|
|
333
|
-
})
|
|
334
|
-
|
|
335
|
-
it('does not inject useLocale when not used', () => {
|
|
336
|
-
const code = "component('page-about', () => html`<h1>About</h1>`)"
|
|
337
|
-
const result = autoImportTransform(code, '/project/app/pages/about.ts', opts)
|
|
338
|
-
expect(result === null || !result!.includes('useLocale')).toBe(true)
|
|
339
|
-
})
|
|
340
|
-
|
|
341
|
-
it('injects useLocale alongside other framework composables in a single import', () => {
|
|
342
|
-
const code = "component('page-x', () => { useHead({ title: 'x' }); const { locale } = useLocale(); return html`` })"
|
|
343
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', opts)!
|
|
344
|
-
expect(result).toContain('useHead')
|
|
345
|
-
expect(result).toContain('useLocale')
|
|
346
|
-
const count = result.split(`from ${FRAMEWORK_PKG}`).length - 1
|
|
347
|
-
expect(count).toBe(1)
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
it('injects queryContent import when queryContent is used', () => {
|
|
351
|
-
const code = "component('page-blog', () => { queryContent('/blog').find().then(posts => {}); return html`` })"
|
|
352
|
-
const result = autoImportTransform(code, '/project/app/pages/blog.ts', opts)!
|
|
353
|
-
expect(result).toContain('queryContent')
|
|
354
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
355
|
-
})
|
|
356
|
-
|
|
357
|
-
it('injects useContentSearch import when useContentSearch is used', () => {
|
|
358
|
-
const code = "component('site-search', () => { const { query, results } = useContentSearch(); return html`` })"
|
|
359
|
-
const result = autoImportTransform(code, '/project/app/components/site-search.ts', opts)!
|
|
360
|
-
expect(result).toContain('useContentSearch')
|
|
361
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
362
|
-
})
|
|
363
|
-
})
|
|
364
|
-
|
|
365
|
-
describe('autoImportTransform — server/middleware/ directory', () => {
|
|
366
|
-
const serverOpts = { srcDir, serverMiddlewareDir: '/project/server/middleware' }
|
|
367
|
-
|
|
368
|
-
it('transforms files in server/middleware/ when serverMiddlewareDir is provided', () => {
|
|
369
|
-
const code = "export default defineServerMiddleware((_req, _res, next) => { next() })"
|
|
370
|
-
const result = autoImportTransform(code, '/project/server/middleware/cors.ts', serverOpts)
|
|
371
|
-
expect(result).not.toBeNull()
|
|
372
|
-
})
|
|
373
|
-
|
|
374
|
-
it('injects defineServerMiddleware import for server/middleware/ files', () => {
|
|
375
|
-
const code = "export default defineServerMiddleware((_req, _res, next) => { next() })"
|
|
376
|
-
const result = autoImportTransform(code, '/project/server/middleware/cors.ts', serverOpts)!
|
|
377
|
-
expect(result).toContain('defineServerMiddleware')
|
|
378
|
-
expect(result).toContain(`from ${FRAMEWORK_PKG}`)
|
|
379
|
-
})
|
|
380
|
-
|
|
381
|
-
it('injects useSession import for server/middleware/ files', () => {
|
|
382
|
-
const code = "export default defineServerMiddleware(async (_req, res, next) => { const s = useSession(); const d = await s.get(); if (!d) { res.end(); return } next() })"
|
|
383
|
-
const result = autoImportTransform(code, '/project/server/middleware/auth.ts', serverOpts)!
|
|
384
|
-
expect(result).toContain('useSession')
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
it('injects useCookie import for server/middleware/ files', () => {
|
|
388
|
-
const code = "export default defineServerMiddleware((req, res, next) => { const token = useCookie('token'); next() })"
|
|
389
|
-
const result = autoImportTransform(code, '/project/server/middleware/auth.ts', serverOpts)!
|
|
390
|
-
expect(result).toContain('useCookie')
|
|
391
|
-
})
|
|
392
|
-
|
|
393
|
-
it('does NOT transform server/middleware/ when serverMiddlewareDir is not set', () => {
|
|
394
|
-
const code = "export default defineServerMiddleware((_req, _res, next) => { next() })"
|
|
395
|
-
const result = autoImportTransform(code, '/project/server/middleware/cors.ts', { srcDir })
|
|
396
|
-
expect(result).toBeNull()
|
|
397
|
-
})
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
// ─── Composable import injection ─────────────────────────────────────────────
|
|
401
|
-
|
|
402
|
-
describe('autoImportTransform — composable import injection', () => {
|
|
403
|
-
const COMPOSABLES_PKG = `'virtual:cer-composables'`
|
|
404
|
-
|
|
405
|
-
it('injects composable import when a registered composable is used', () => {
|
|
406
|
-
const composableExports = new Map([['useTheme', '/project/app/composables/useTheme.ts']])
|
|
407
|
-
const code = "component('page-x', () => { const t = useTheme(); return html`<div></div>` })"
|
|
408
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', { srcDir, composableExports })!
|
|
409
|
-
expect(result).toContain(`from ${COMPOSABLES_PKG}`)
|
|
410
|
-
expect(result).toContain('useTheme')
|
|
411
|
-
})
|
|
412
|
-
|
|
413
|
-
it('does not inject composable import when composable is not used in file', () => {
|
|
414
|
-
const composableExports = new Map([['useTheme', '/project/app/composables/useTheme.ts']])
|
|
415
|
-
const code = "component('page-x', () => html`<h1>Hello</h1>`)"
|
|
416
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', { srcDir, composableExports })
|
|
417
|
-
expect(result === null || !result!.includes('virtual:cer-composables')).toBe(true)
|
|
418
|
-
})
|
|
419
|
-
|
|
420
|
-
it('does not inject when already imported from virtual:cer-composables (single quotes)', () => {
|
|
421
|
-
const composableExports = new Map([['useTheme', '/project/app/composables/useTheme.ts']])
|
|
422
|
-
const code = `import { useTheme } from 'virtual:cer-composables'\ncomponent('x', () => { useTheme(); return html\`\` })`
|
|
423
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', { srcDir, composableExports })
|
|
424
|
-
const count = (result ?? code).split(`from ${COMPOSABLES_PKG}`).length - 1
|
|
425
|
-
expect(count).toBe(1)
|
|
426
|
-
})
|
|
427
|
-
|
|
428
|
-
it('does not inject when already imported from virtual:cer-composables (double quotes)', () => {
|
|
429
|
-
const composableExports = new Map([['useTheme', '/project/app/composables/useTheme.ts']])
|
|
430
|
-
const code = `import { useTheme } from "virtual:cer-composables"\ncomponent('x', () => { useTheme(); return html\`\` })`
|
|
431
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', { srcDir, composableExports })
|
|
432
|
-
const count = (result ?? code).split('virtual:cer-composables').length - 1
|
|
433
|
-
expect(count).toBe(1)
|
|
434
|
-
})
|
|
435
|
-
|
|
436
|
-
it('injects all used composables in a single import statement', () => {
|
|
437
|
-
const composableExports = new Map([
|
|
438
|
-
['useTheme', '/project/app/composables/useTheme.ts'],
|
|
439
|
-
['useAuth', '/project/app/composables/useAuth.ts'],
|
|
440
|
-
])
|
|
441
|
-
const code = "component('page-x', () => { useTheme(); useAuth(); return html`<div></div>` })"
|
|
442
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', { srcDir, composableExports })!
|
|
443
|
-
expect(result).toContain('useTheme')
|
|
444
|
-
expect(result).toContain('useAuth')
|
|
445
|
-
const count = result.split(`from ${COMPOSABLES_PKG}`).length - 1
|
|
446
|
-
expect(count).toBe(1)
|
|
447
|
-
})
|
|
448
|
-
|
|
449
|
-
it('returns null when composableExports is empty and no other identifiers used', () => {
|
|
450
|
-
const composableExports = new Map<string, string>()
|
|
451
|
-
const code = 'const x = 1'
|
|
452
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', { srcDir, composableExports })
|
|
453
|
-
expect(result).toBeNull()
|
|
454
|
-
})
|
|
455
|
-
|
|
456
|
-
it('returns null when composableExports is undefined and no other identifiers used', () => {
|
|
457
|
-
const code = 'const x = 1'
|
|
458
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', { srcDir })
|
|
459
|
-
expect(result).toBeNull()
|
|
460
|
-
})
|
|
461
|
-
})
|
|
462
|
-
|
|
463
|
-
// ─── P1-5: Per-identifier tree shaking ────────────────────────────────────────
|
|
464
|
-
|
|
465
|
-
describe('autoImportTransform — per-identifier tree shaking (P1-5)', () => {
|
|
466
|
-
it('injects only used identifiers, not all runtime identifiers', () => {
|
|
467
|
-
const code = "const count = ref(0)"
|
|
468
|
-
const result = autoImportTransform(code, '/project/app/pages/counter.ts', opts)!
|
|
469
|
-
// Only ref should be imported, not component/html/computed etc.
|
|
470
|
-
expect(result).toContain('ref')
|
|
471
|
-
expect(result).not.toContain('computed')
|
|
472
|
-
expect(result).not.toContain('watchEffect')
|
|
473
|
-
expect(result).not.toContain('useEmit')
|
|
474
|
-
})
|
|
475
|
-
|
|
476
|
-
it('injects only the used directive, not all directives', () => {
|
|
477
|
-
const code = "const t = each(items, (i) => html`<li>${i}</li>`)"
|
|
478
|
-
const result = autoImportTransform(code, '/project/app/pages/list.ts', opts)!
|
|
479
|
-
expect(result).toContain('each')
|
|
480
|
-
expect(result).not.toContain('when')
|
|
481
|
-
expect(result).not.toContain('match')
|
|
482
|
-
expect(result).not.toContain('anchorBlock')
|
|
483
|
-
})
|
|
484
|
-
|
|
485
|
-
it('injects only the used framework composable, not the full framework set', () => {
|
|
486
|
-
const code = "component('page-x', () => { const r = useRoute(); return html`<div></div>` })"
|
|
487
|
-
const result = autoImportTransform(code, '/project/app/pages/x.ts', opts)!
|
|
488
|
-
expect(result).toContain('useRoute')
|
|
489
|
-
expect(result).not.toContain('useHead')
|
|
490
|
-
expect(result).not.toContain('useFetch')
|
|
491
|
-
expect(result).not.toContain('useState')
|
|
492
|
-
})
|
|
493
|
-
|
|
494
|
-
it('groups multiple used identifiers from the same module into one import statement', () => {
|
|
495
|
-
const code = "const a = ref(0)\nconst b = computed(() => a.value * 2)"
|
|
496
|
-
const result = autoImportTransform(code, '/project/app/pages/computed.ts', opts)!
|
|
497
|
-
// Both ref and computed are from the runtime — should be one import
|
|
498
|
-
const count = result.split(`from ${RUNTIME_PKG}`).length - 1
|
|
499
|
-
expect(count).toBe(1)
|
|
500
|
-
expect(result).toContain('ref')
|
|
501
|
-
expect(result).toContain('computed')
|
|
502
|
-
})
|
|
503
|
-
|
|
504
|
-
it('defineAsyncComponent is injected when used (P2-4 auto-import)', () => {
|
|
505
|
-
const code = "defineAsyncComponent('heavy-editor', () => import('./impl.ts').then(m => m.render))"
|
|
506
|
-
const result = autoImportTransform(code, '/project/app/components/heavy-editor.ts', opts)!
|
|
507
|
-
expect(result).toContain('defineAsyncComponent')
|
|
508
|
-
expect(result).toContain(`from ${RUNTIME_PKG}`)
|
|
509
|
-
})
|
|
510
|
-
})
|