create-jen-app 1.2.3 → 1.2.4
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/colors.js +0 -17
- package/dist/create.js +5 -17
- package/dist/generator.js +14 -31
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/templates/ssr-isr/README.md +77 -0
- package/templates/ssr-isr/build.js +118 -0
- package/templates/ssr-isr/jen.config.ts +109 -0
- package/templates/ssr-isr/jenjs.d.ts +22 -0
- package/templates/ssr-isr/lib/api/(hello).js +9 -0
- package/templates/ssr-isr/lib/auth/cookie-utils.js +79 -0
- package/templates/ssr-isr/lib/auth/index.js +2 -0
- package/templates/ssr-isr/lib/auth/jwt.js +57 -0
- package/templates/ssr-isr/lib/auth/session.js +92 -0
- package/templates/ssr-isr/lib/build/asset-hashing.d.ts +10 -0
- package/templates/ssr-isr/lib/build/asset-hashing.js +25 -0
- package/templates/ssr-isr/lib/build/asset-manifest.d.ts +11 -0
- package/templates/ssr-isr/lib/build/asset-manifest.js +21 -0
- package/templates/{static → ssr-isr}/lib/build/build.d.ts +1 -1
- package/templates/ssr-isr/lib/build/build.js +141 -0
- package/templates/{static → ssr-isr}/lib/build/island-hydration.d.ts +8 -5
- package/templates/ssr-isr/lib/build/island-hydration.js +44 -0
- package/templates/ssr-isr/lib/build/minifier.d.ts +20 -0
- package/templates/ssr-isr/lib/build/minifier.js +46 -0
- package/templates/ssr-isr/lib/build/page-renderer.d.ts +17 -0
- package/templates/ssr-isr/lib/build/page-renderer.js +28 -0
- package/templates/ssr-isr/lib/build/production-build.d.ts +10 -0
- package/templates/ssr-isr/lib/build/production-build.js +13 -0
- package/templates/ssr-isr/lib/build/ssg-pipeline.d.ts +15 -0
- package/templates/ssr-isr/lib/build/ssg-pipeline.js +113 -0
- package/templates/ssr-isr/lib/build-tools/build-site.js +36 -0
- package/templates/ssr-isr/lib/cache/index.js +10 -0
- package/templates/ssr-isr/lib/cache/memory.js +40 -0
- package/templates/ssr-isr/lib/cache/redis.js +61 -0
- package/templates/ssr-isr/lib/cli/banner.js +28 -0
- package/templates/ssr-isr/lib/cli/templates/ssg/jen.config.js +32 -0
- package/templates/ssr-isr/lib/cli/templates/ssg/site/index.js +9 -0
- package/templates/ssr-isr/lib/cli/templates/ssr/jen.config.js +32 -0
- package/templates/ssr-isr/lib/cli/templates/ssr/site/index.js +9 -0
- package/templates/ssr-isr/lib/compilers/esbuild-plugins.js +111 -0
- package/templates/ssr-isr/lib/compilers/svelte.js +44 -0
- package/templates/ssr-isr/lib/compilers/vue.js +90 -0
- package/templates/ssr-isr/lib/core/http.js +71 -0
- package/templates/ssr-isr/lib/core/middleware-hooks.js +97 -0
- package/templates/ssr-isr/lib/core/paths.js +39 -0
- package/templates/ssr-isr/lib/core/routes/match.js +47 -0
- package/templates/ssr-isr/lib/core/routes/scan.js +190 -0
- package/templates/ssr-isr/lib/core/types.js +1 -0
- package/templates/ssr-isr/lib/css/compiler.js +74 -0
- package/templates/ssr-isr/lib/db/connector.js +42 -0
- package/templates/ssr-isr/lib/db/drivers/jdb.js +44 -0
- package/templates/ssr-isr/lib/db/drivers/sql.js +182 -0
- package/templates/ssr-isr/lib/db/index.js +48 -0
- package/templates/ssr-isr/lib/db/types.js +1 -0
- package/templates/ssr-isr/lib/graphql/index.js +52 -0
- package/templates/ssr-isr/lib/graphql/resolvers.js +25 -0
- package/templates/ssr-isr/lib/graphql/schema.js +35 -0
- package/templates/ssr-isr/lib/i18n/en.json +4 -0
- package/templates/ssr-isr/lib/i18n/es.json +4 -0
- package/templates/ssr-isr/lib/i18n/index.js +15 -0
- package/templates/ssr-isr/lib/import/jen-import.js +161 -0
- package/templates/ssr-isr/lib/index.js +116 -0
- package/templates/ssr-isr/lib/jdb/engine.js +275 -0
- package/templates/ssr-isr/lib/jdb/index.js +34 -0
- package/templates/ssr-isr/lib/jdb/types.js +1 -0
- package/templates/ssr-isr/lib/jdb/utils.js +176 -0
- package/templates/{static → ssr-isr}/lib/middleware/builtins/body-parser.js +0 -17
- package/templates/ssr-isr/lib/middleware/builtins/cors.js +54 -0
- package/templates/{static → ssr-isr}/lib/middleware/builtins/logger.js +0 -17
- package/templates/{static → ssr-isr}/lib/middleware/builtins/rate-limit.js +0 -17
- package/templates/{static → ssr-isr}/lib/middleware/builtins/request-id.js +0 -17
- package/templates/{static → ssr-isr}/lib/middleware/builtins/security-headers.js +0 -17
- package/templates/ssr-isr/lib/middleware/context.js +124 -0
- package/templates/{static → ssr-isr}/lib/middleware/decorators.js +0 -17
- package/templates/{static → ssr-isr}/lib/middleware/errors/handler.js +0 -17
- package/templates/ssr-isr/lib/middleware/errors/http-error.js +10 -0
- package/templates/ssr-isr/lib/middleware/kernel.js +85 -0
- package/templates/ssr-isr/lib/middleware/pipeline.js +148 -0
- package/templates/ssr-isr/lib/middleware/registry.js +85 -0
- package/templates/ssr-isr/lib/middleware/response.js +107 -0
- package/templates/ssr-isr/lib/middleware/types.d.ts +1 -0
- package/templates/ssr-isr/lib/middleware/types.js +1 -0
- package/templates/ssr-isr/lib/middleware/utils/matcher.js +13 -0
- package/templates/{static → ssr-isr}/lib/native/bundle.js +0 -17
- package/templates/{static → ssr-isr}/lib/native/dev-server.js +0 -17
- package/templates/{static → ssr-isr}/lib/native/index.js +0 -17
- package/templates/{static → ssr-isr}/lib/native/optimizer.js +0 -17
- package/templates/ssr-isr/lib/native/style-compiler.js +19 -0
- package/templates/ssr-isr/lib/plugin/loader.js +36 -0
- package/templates/ssr-isr/lib/runtime/client-runtime.js +25 -0
- package/templates/ssr-isr/lib/runtime/hmr.js +59 -0
- package/templates/ssr-isr/lib/runtime/hydrate.js +55 -0
- package/templates/ssr-isr/lib/runtime/island-hydration-client.js +146 -0
- package/templates/ssr-isr/lib/runtime/islands.js +110 -0
- package/templates/ssr-isr/lib/runtime/render.js +244 -0
- package/templates/ssr-isr/lib/server/api-routes.js +237 -0
- package/templates/ssr-isr/lib/server/api.js +108 -0
- package/templates/ssr-isr/lib/server/app.js +438 -0
- package/templates/ssr-isr/lib/server/runtimeServe.js +169 -0
- package/templates/ssr-isr/lib/server/ssr.js +202 -0
- package/templates/ssr-isr/lib/shared/log.js +64 -0
- package/templates/ssr-isr/package.json +23 -0
- package/templates/ssr-isr/server.js +128 -0
- package/templates/ssr-isr/site/pages/(index).tsx +11 -0
- package/templates/ssr-isr/site/styles/global.scss +37 -0
- package/templates/ssr-isr/tsconfig.json +39 -0
- package/templates/static/build.js +30 -18
- package/templates/static/jen.config.ts +0 -18
- package/templates/static/jenjs.d.ts +0 -18
- package/templates/static/lib/api/(hello).js +0 -17
- package/templates/static/lib/api/examples/files/[...slug].js +22 -0
- package/templates/static/lib/api/examples/hello.js +11 -0
- package/templates/static/lib/api/examples/posts/[id].js +37 -0
- package/templates/static/lib/api/examples/posts.js +37 -0
- package/templates/static/lib/api/examples/search.js +23 -0
- package/templates/static/lib/api/index.js +41 -0
- package/templates/static/lib/api/loader.js +234 -0
- package/templates/static/lib/api/router.js +259 -0
- package/templates/static/lib/assets/types.js +1 -0
- package/templates/static/lib/auth/cookie-utils.js +3 -16
- package/templates/static/lib/auth/index.js +0 -17
- package/templates/static/lib/auth/jwt.js +0 -17
- package/templates/static/lib/auth/session.js +0 -17
- package/templates/static/lib/build/asset-hashing.js +44 -36
- package/templates/static/lib/build/asset-manifest.js +16 -33
- package/templates/static/lib/build/build.js +270 -125
- package/templates/static/lib/build/bundle-analyzer-ui.js +417 -0
- package/templates/static/lib/build/bundle-analyzer.js +945 -0
- package/templates/static/lib/build/code-splitter.js +194 -0
- package/templates/static/lib/build/feature-analyzer.js +190 -0
- package/templates/static/lib/build/feature-gate.js +257 -0
- package/templates/static/lib/build/island-hydration.js +17 -35
- package/templates/static/lib/build/lazy-loader.js +322 -0
- package/templates/static/lib/build/minifier.js +40 -59
- package/templates/static/lib/build/page-renderer.js +23 -40
- package/templates/static/lib/build/production-build.js +9 -26
- package/templates/static/lib/build/rust-hashing.js +71 -0
- package/templates/static/lib/build/script-optimizer.js +285 -0
- package/templates/static/lib/build/ssg-pipeline.js +100 -106
- package/templates/static/lib/build/vercel-output.js +298 -0
- package/templates/static/lib/build-tools/build-site.js +0 -17
- package/templates/static/lib/cache/index.js +0 -17
- package/templates/static/lib/cache/memory.js +0 -17
- package/templates/static/lib/cache/redis.js +0 -17
- package/templates/static/lib/cli/banner.js +0 -17
- package/templates/static/lib/cli/templates/ssg/jen.config.js +0 -17
- package/templates/static/lib/cli/templates/ssr/jen.config.js +0 -17
- package/templates/static/lib/client/Image.js +42 -0
- package/templates/static/lib/client/Link.js +190 -0
- package/templates/static/lib/client/PWA.js +46 -0
- package/templates/static/lib/client/Seo.js +97 -0
- package/templates/static/lib/client/index.js +9 -0
- package/templates/static/lib/client/useNavigation.js +25 -0
- package/templates/static/lib/client/useRouter.js +64 -0
- package/templates/static/lib/client-routing/Link.js +17 -0
- package/templates/static/lib/client-routing/index.js +19 -0
- package/templates/static/lib/client-routing/router.js +151 -0
- package/templates/static/lib/client-routing/signal.js +147 -0
- package/templates/static/lib/compilers/esbuild-plugins.js +0 -17
- package/templates/static/lib/compilers/svelte.js +0 -17
- package/templates/static/lib/compilers/vue.js +0 -17
- package/templates/static/lib/core/config.js +0 -17
- package/templates/static/lib/core/feature-guard.js +136 -0
- package/templates/static/lib/core/features.js +99 -0
- package/templates/static/lib/core/http.js +0 -17
- package/templates/static/lib/core/layouts/index.js +10 -0
- package/templates/static/lib/core/layouts/render.js +158 -0
- package/templates/static/lib/core/layouts/scan.js +112 -0
- package/templates/static/lib/core/layouts/types.js +1 -0
- package/templates/static/lib/core/lifecycle.js +129 -0
- package/templates/static/lib/core/loader-schema.js +81 -0
- package/templates/static/lib/core/middleware-hooks.js +0 -17
- package/templates/static/lib/core/paths.js +0 -17
- package/templates/static/lib/core/routes/advanced.js +114 -0
- package/templates/static/lib/core/routes/handlers.js +181 -0
- package/templates/static/lib/core/routes/match.js +89 -17
- package/templates/static/lib/core/routes/orchestrator.js +171 -0
- package/templates/static/lib/core/routes/rendering-config.js +131 -0
- package/templates/static/lib/core/routes/scan.js +0 -17
- package/templates/static/lib/core/types.js +0 -17
- package/templates/static/lib/css/compiler.js +1 -18
- package/templates/static/lib/data-fetching/cache.js +223 -0
- package/templates/static/lib/data-fetching/client.js +202 -0
- package/templates/static/lib/data-fetching/feature-guard.js +29 -0
- package/templates/static/lib/data-fetching/graphql.js +265 -0
- package/templates/static/lib/data-fetching/index.js +57 -0
- package/templates/static/lib/data-fetching/rest.js +256 -0
- package/templates/static/lib/data-fetching/server.js +182 -0
- package/templates/static/lib/data-fetching/types.js +5 -0
- package/templates/static/lib/db/connector.js +0 -17
- package/templates/static/lib/db/drivers/jdb.js +0 -17
- package/templates/static/lib/db/drivers/sql.js +0 -17
- package/templates/static/lib/db/index.js +0 -17
- package/templates/static/lib/db/types.js +0 -17
- package/templates/static/lib/devtools/component-tree.js +106 -0
- package/templates/static/lib/devtools/devtools.js +638 -0
- package/templates/static/lib/devtools/event-bus.js +29 -0
- package/templates/static/lib/devtools/event-logger.js +67 -0
- package/templates/static/lib/devtools/index.js +9 -0
- package/templates/static/lib/devtools/integration.js +149 -0
- package/templates/static/lib/devtools/performance.js +84 -0
- package/templates/static/lib/devtools/persistence.js +57 -0
- package/templates/static/lib/devtools/plugins.js +97 -0
- package/templates/static/lib/devtools/search.js +89 -0
- package/templates/static/lib/devtools/ui.js +769 -0
- package/templates/static/lib/features/api/handler.js +10 -0
- package/templates/static/lib/features/api/index.js +5 -0
- package/templates/static/lib/features/api/types.js +4 -0
- package/templates/static/lib/features/middleware/compiled.js +7 -0
- package/templates/static/lib/features/middleware/index.js +5 -0
- package/templates/static/lib/features/middleware/types.js +4 -0
- package/templates/static/lib/fonts/index.js +46 -0
- package/templates/static/lib/fonts/inject.js +125 -0
- package/templates/static/lib/fonts/loader.js +196 -0
- package/templates/static/lib/fonts/types.js +1 -0
- package/templates/static/lib/graphql/index.js +1 -18
- package/templates/static/lib/graphql/resolvers.js +20 -13
- package/templates/static/lib/graphql/schema.js +0 -17
- package/templates/static/lib/i18n/index.js +7 -19
- package/templates/static/lib/import/jen-import.js +1 -18
- package/templates/static/lib/index.js +79 -125
- package/templates/static/lib/jdb/engine.js +0 -17
- package/templates/static/lib/jdb/index.js +1 -18
- package/templates/static/lib/jdb/types.js +0 -17
- package/templates/static/lib/jdb/utils.js +0 -17
- package/templates/static/lib/middleware/builtins/cors.js +3 -16
- package/templates/static/lib/middleware/context.js +0 -17
- package/templates/static/lib/middleware/kernel.js +117 -25
- package/templates/static/lib/middleware/pipeline.js +0 -17
- package/templates/static/lib/middleware/registry.js +0 -17
- package/templates/static/lib/middleware/response.js +0 -17
- package/templates/static/lib/plugin/examples/analytics-plugin.js +183 -0
- package/templates/static/lib/plugin/examples/cdn-upload-plugin.js +94 -0
- package/templates/static/lib/plugin/loader.js +0 -17
- package/templates/static/lib/plugin/plugin-manager.js +177 -0
- package/templates/static/lib/plugin/types.js +28 -0
- package/templates/static/lib/runtime/client-runtime.js +0 -17
- package/templates/static/lib/runtime/hmr.js +0 -17
- package/templates/static/lib/runtime/hydrate.js +0 -17
- package/templates/static/lib/runtime/island-hydration-client.js +0 -17
- package/templates/static/lib/runtime/islands.js +0 -17
- package/templates/static/lib/runtime/render.js +208 -50
- package/templates/static/lib/security/security-config.js +60 -0
- package/templates/static/lib/security/security-middleware.js +229 -0
- package/templates/static/lib/server/api-routes.js +153 -43
- package/templates/static/lib/server/api.js +0 -17
- package/templates/static/lib/server/app.js +539 -223
- package/templates/static/lib/server/isr.js +365 -0
- package/templates/static/lib/server/runtimeServe.js +31 -24
- package/templates/static/lib/server/ssr.js +98 -22
- package/templates/static/lib/server-actions/handler.js +180 -0
- package/templates/static/lib/server-actions/index.js +19 -0
- package/templates/static/lib/server-actions/middleware.js +146 -0
- package/templates/static/lib/server-actions/scan.js +152 -0
- package/templates/static/lib/server-actions/types.js +1 -0
- package/templates/static/lib/server-actions/validators.js +156 -0
- package/templates/static/lib/shared/log.js +19 -20
- package/templates/static/lib/telemetry/api/rate-limiter.js +32 -0
- package/templates/static/lib/telemetry/api/validator.js +67 -0
- package/templates/static/lib/telemetry/client.js +121 -0
- package/templates/static/lib/telemetry/tests/rate-limiter.test.js +46 -0
- package/templates/static/lib/telemetry/tests/validator.test.js +62 -0
- package/templates/static/lib/vendor/glob/glob.js +4766 -0
- package/templates/static/lib/vendor/preact/LICENSE +21 -0
- package/templates/static/lib/vendor/preact/preact.module.js +797 -0
- package/templates/static/lib/vendor/sass/sass.node.mjs +212 -0
- package/templates/static/package.json +4 -0
- package/templates/static/server.js +22 -22
- package/templates/static/site/(home).tsx +0 -18
- package/templates/static/tsconfig.json +5 -1
- package/templates/static/.esbuild/jen.config.js +0 -19
- package/templates/static/lib/build/asset-hashing.d.ts +0 -10
- package/templates/static/lib/build/asset-manifest.d.ts +0 -11
- package/templates/static/lib/build/minifier.d.ts +0 -20
- package/templates/static/lib/build/page-renderer.d.ts +0 -17
- package/templates/static/lib/build/production-build.d.ts +0 -10
- package/templates/static/lib/build/ssg-pipeline.d.ts +0 -15
- package/templates/static/lib/middleware/errors/http-error.js +0 -27
- package/templates/static/lib/middleware/types.js +0 -18
- package/templates/static/lib/middleware/utils/matcher.js +0 -30
- package/templates/static/lib/native/style-compiler.js +0 -36
- /package/templates/{static → ssr-isr}/lib/api/(hello).d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/auth/cookie-utils.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/auth/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/auth/jwt.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/auth/session.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/build-tools/build-site.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cache/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cache/memory.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cache/redis.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/banner.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/templates/ssg/jen.config.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/templates/ssg/site/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/templates/ssr/jen.config.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/cli/templates/ssr/site/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/compilers/esbuild-plugins.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/compilers/svelte.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/compilers/vue.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/config.d.ts +0 -0
- /package/templates/{static/lib/middleware/types.d.ts → ssr-isr/lib/core/config.js} +0 -0
- /package/templates/{static → ssr-isr}/lib/core/http.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/middleware-hooks.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/paths.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/routes/match.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/routes/scan.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/core/types.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/css/compiler.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/connector.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/drivers/jdb.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/drivers/sql.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/db/types.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/graphql/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/graphql/resolvers.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/graphql/schema.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/i18n/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/import/jen-import.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/jdb/engine.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/jdb/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/jdb/types.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/jdb/utils.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/body-parser.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/cors.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/logger.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/rate-limit.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/request-id.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/builtins/security-headers.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/context.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/decorators.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/errors/handler.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/errors/http-error.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/kernel.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/pipeline.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/registry.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/response.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/middleware/utils/matcher.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/bundle.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/dev-server.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/index.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/optimizer.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/native/style-compiler.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/plugin/loader.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/client-runtime.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/hmr.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/hydrate.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/island-hydration-client.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/islands.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/runtime/render.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/api-routes.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/api.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/app.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/runtimeServe.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/server/ssr.d.ts +0 -0
- /package/templates/{static → ssr-isr}/lib/shared/log.d.ts +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
jsx as _jsx,
|
|
4
|
+
Fragment as _Fragment,
|
|
5
|
+
jsxs as _jsxs,
|
|
6
|
+
} from "preact/jsx-runtime";
|
|
7
|
+
import { useEffect } from "preact/hooks";
|
|
8
|
+
/**
|
|
9
|
+
* PWA (Progressive Web App) setup component
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // With defaults
|
|
14
|
+
* <PWA />
|
|
15
|
+
*
|
|
16
|
+
* // With custom paths
|
|
17
|
+
* <PWA manifestPath="/app/manifest.json" swPath="/app/sw.js" />
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Automatically registers the service worker on component mount.
|
|
22
|
+
* Service worker errors are logged to console but don't break the app.
|
|
23
|
+
*/
|
|
24
|
+
export function PWA({ manifestPath = "/manifest.json", swPath = "/sw.js" }) {
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
// Register service worker in browser
|
|
27
|
+
if ("serviceWorker" in navigator) {
|
|
28
|
+
navigator.serviceWorker
|
|
29
|
+
.register(swPath)
|
|
30
|
+
.catch((err) =>
|
|
31
|
+
console.error("Service worker registration failed:", err),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}, [swPath]);
|
|
35
|
+
return _jsxs(_Fragment, {
|
|
36
|
+
children: [
|
|
37
|
+
_jsx("link", { rel: "manifest", href: manifestPath }),
|
|
38
|
+
_jsx("meta", { name: "theme-color", content: "#000000" }),
|
|
39
|
+
_jsx("meta", { name: "apple-mobile-web-app-capable", content: "yes" }),
|
|
40
|
+
_jsx("meta", {
|
|
41
|
+
name: "apple-mobile-web-app-status-bar-style",
|
|
42
|
+
content: "black-translucent",
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
jsx as _jsx,
|
|
4
|
+
Fragment as _Fragment,
|
|
5
|
+
jsxs as _jsxs,
|
|
6
|
+
} from "preact/jsx-runtime";
|
|
7
|
+
import { useEffect } from "preact/hooks";
|
|
8
|
+
/**
|
|
9
|
+
* SEO component that injects meta tags into the document head
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <Seo
|
|
14
|
+
* title="My Page"
|
|
15
|
+
* description="Page description"
|
|
16
|
+
* canonical="https://example.com/page"
|
|
17
|
+
* ogImage="https://example.com/og-image.png"
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Works both server-side and client-side. On server, ensure this component
|
|
23
|
+
* is rendered during SSR to include meta tags in the HTML head.
|
|
24
|
+
* On client, uses DOM manipulation to update existing meta tags.
|
|
25
|
+
*/
|
|
26
|
+
export function Seo({
|
|
27
|
+
title,
|
|
28
|
+
description,
|
|
29
|
+
keywords,
|
|
30
|
+
canonical,
|
|
31
|
+
ogTitle,
|
|
32
|
+
ogDescription,
|
|
33
|
+
ogImage,
|
|
34
|
+
twitterCard,
|
|
35
|
+
}) {
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
// Update title tag
|
|
38
|
+
document.title = title;
|
|
39
|
+
// Helper to set or create meta tags
|
|
40
|
+
const setMeta = (name, content, property = false) => {
|
|
41
|
+
const attr = property ? "property" : "name";
|
|
42
|
+
let meta = document.querySelector(`meta[${attr}="${name}"]`);
|
|
43
|
+
if (!meta) {
|
|
44
|
+
meta = document.createElement("meta");
|
|
45
|
+
meta.setAttribute(attr, name);
|
|
46
|
+
document.head.appendChild(meta);
|
|
47
|
+
}
|
|
48
|
+
meta.content = content;
|
|
49
|
+
};
|
|
50
|
+
// Set meta tags
|
|
51
|
+
if (description) setMeta("description", description);
|
|
52
|
+
if (keywords) setMeta("keywords", keywords);
|
|
53
|
+
if (canonical) {
|
|
54
|
+
let link = document.querySelector('link[rel="canonical"]');
|
|
55
|
+
if (!link) {
|
|
56
|
+
link = document.createElement("link");
|
|
57
|
+
link.rel = "canonical";
|
|
58
|
+
document.head.appendChild(link);
|
|
59
|
+
}
|
|
60
|
+
link.href = canonical;
|
|
61
|
+
}
|
|
62
|
+
// Open Graph tags
|
|
63
|
+
if (ogTitle) setMeta("og:title", ogTitle, true);
|
|
64
|
+
if (ogDescription) setMeta("og:description", ogDescription, true);
|
|
65
|
+
if (ogImage) setMeta("og:image", ogImage, true);
|
|
66
|
+
setMeta("og:type", "website", true);
|
|
67
|
+
// Twitter tags
|
|
68
|
+
if (twitterCard) setMeta("twitter:card", twitterCard);
|
|
69
|
+
}, [
|
|
70
|
+
title,
|
|
71
|
+
description,
|
|
72
|
+
keywords,
|
|
73
|
+
canonical,
|
|
74
|
+
ogTitle,
|
|
75
|
+
ogDescription,
|
|
76
|
+
ogImage,
|
|
77
|
+
twitterCard,
|
|
78
|
+
]);
|
|
79
|
+
// Server-side rendering: return meta tags
|
|
80
|
+
// Note: In Jen.js SSR context, render these elements to be included in head
|
|
81
|
+
return _jsxs(_Fragment, {
|
|
82
|
+
children: [
|
|
83
|
+
_jsx("title", { children: title }),
|
|
84
|
+
description &&
|
|
85
|
+
_jsx("meta", { name: "description", content: description }),
|
|
86
|
+
keywords && _jsx("meta", { name: "keywords", content: keywords }),
|
|
87
|
+
canonical && _jsx("link", { rel: "canonical", href: canonical }),
|
|
88
|
+
ogTitle && _jsx("meta", { property: "og:title", content: ogTitle }),
|
|
89
|
+
ogDescription &&
|
|
90
|
+
_jsx("meta", { property: "og:description", content: ogDescription }),
|
|
91
|
+
ogImage && _jsx("meta", { property: "og:image", content: ogImage }),
|
|
92
|
+
_jsx("meta", { property: "og:type", content: "website" }),
|
|
93
|
+
twitterCard &&
|
|
94
|
+
_jsx("meta", { name: "twitter:card", content: twitterCard }),
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side components for Jen.js
|
|
3
|
+
*/
|
|
4
|
+
export { Link } from "./Link.js";
|
|
5
|
+
export { Image } from "./Image.js";
|
|
6
|
+
export { Seo } from "./Seo.js";
|
|
7
|
+
export { PWA } from "./PWA.js";
|
|
8
|
+
export { useRouter } from "./useRouter.js";
|
|
9
|
+
export { useNavigation } from "./useNavigation.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, useState } from "preact/hooks";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to track navigation state
|
|
4
|
+
*/
|
|
5
|
+
export function useNavigation() {
|
|
6
|
+
const [isNavigating, setIsNavigating] = useState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (typeof window === "undefined") {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const handleNavigateStart = () => {
|
|
12
|
+
setIsNavigating(true);
|
|
13
|
+
};
|
|
14
|
+
const handleNavigateEnd = () => {
|
|
15
|
+
setIsNavigating(false);
|
|
16
|
+
};
|
|
17
|
+
window.addEventListener("jen:navigate:start", handleNavigateStart);
|
|
18
|
+
window.addEventListener("jen:navigate:end", handleNavigateEnd);
|
|
19
|
+
return () => {
|
|
20
|
+
window.removeEventListener("jen:navigate:start", handleNavigateStart);
|
|
21
|
+
window.removeEventListener("jen:navigate:end", handleNavigateEnd);
|
|
22
|
+
};
|
|
23
|
+
}, []);
|
|
24
|
+
return { isNavigating };
|
|
25
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "preact/hooks";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to access current route and navigate
|
|
4
|
+
*/
|
|
5
|
+
export function useRouter() {
|
|
6
|
+
const [state, setState] = useState(() => ({
|
|
7
|
+
pathname: typeof window !== "undefined" ? window.location.pathname : "/",
|
|
8
|
+
search: typeof window !== "undefined" ? window.location.search : "",
|
|
9
|
+
hash: typeof window !== "undefined" ? window.location.hash : "",
|
|
10
|
+
}));
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (typeof window === "undefined") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const handlePopState = () => {
|
|
16
|
+
setState({
|
|
17
|
+
pathname: window.location.pathname,
|
|
18
|
+
search: window.location.search,
|
|
19
|
+
hash: window.location.hash,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const handleNavigate = (event) => {
|
|
23
|
+
const { href } = event.detail;
|
|
24
|
+
setState({
|
|
25
|
+
pathname: new URL(href, window.location.href).pathname,
|
|
26
|
+
search: new URL(href, window.location.href).search,
|
|
27
|
+
hash: new URL(href, window.location.href).hash,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
window.addEventListener("popstate", handlePopState);
|
|
31
|
+
window.addEventListener("jen:navigate", handleNavigate);
|
|
32
|
+
return () => {
|
|
33
|
+
window.removeEventListener("popstate", handlePopState);
|
|
34
|
+
window.removeEventListener("jen:navigate", handleNavigate);
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
const push = useCallback((href) => {
|
|
38
|
+
window.dispatchEvent(
|
|
39
|
+
new CustomEvent("jen:navigate", {
|
|
40
|
+
detail: { href, replace: false },
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
window.history.pushState({ href }, "", href);
|
|
44
|
+
setState({
|
|
45
|
+
pathname: new URL(href, window.location.href).pathname,
|
|
46
|
+
search: new URL(href, window.location.href).search,
|
|
47
|
+
hash: new URL(href, window.location.href).hash,
|
|
48
|
+
});
|
|
49
|
+
}, []);
|
|
50
|
+
const replace = useCallback((href) => {
|
|
51
|
+
window.dispatchEvent(
|
|
52
|
+
new CustomEvent("jen:navigate", {
|
|
53
|
+
detail: { href, replace: true },
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
window.history.replaceState({ href }, "", href);
|
|
57
|
+
setState({
|
|
58
|
+
pathname: new URL(href, window.location.href).pathname,
|
|
59
|
+
search: new URL(href, window.location.href).search,
|
|
60
|
+
hash: new URL(href, window.location.href).hash,
|
|
61
|
+
});
|
|
62
|
+
}, []);
|
|
63
|
+
return { ...state, push, replace };
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { h } from "preact";
|
|
2
|
+
/**
|
|
3
|
+
* Link component for client-side routing
|
|
4
|
+
* Compiles to <a data-jen-link> at build time
|
|
5
|
+
* Router auto-intercepts clicks
|
|
6
|
+
*/
|
|
7
|
+
export function Link({ href, children, ...props }) {
|
|
8
|
+
return h(
|
|
9
|
+
"a",
|
|
10
|
+
{
|
|
11
|
+
href,
|
|
12
|
+
"data-jen-link": true,
|
|
13
|
+
...props,
|
|
14
|
+
},
|
|
15
|
+
children,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Router exports
|
|
2
|
+
export {
|
|
3
|
+
navigate,
|
|
4
|
+
getCurrentRoute,
|
|
5
|
+
onRouteChange,
|
|
6
|
+
initRouter,
|
|
7
|
+
} from "./router.js";
|
|
8
|
+
// Signal/State exports
|
|
9
|
+
export {
|
|
10
|
+
signal,
|
|
11
|
+
computed,
|
|
12
|
+
bindSignal,
|
|
13
|
+
bindInput,
|
|
14
|
+
batch,
|
|
15
|
+
watch,
|
|
16
|
+
createStore,
|
|
17
|
+
} from "./signal.js";
|
|
18
|
+
// Component exports
|
|
19
|
+
export { Link } from "./Link.js";
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal client-side router for Jen.js
|
|
3
|
+
* - Zero runtime cost if not used
|
|
4
|
+
* - < 2 KB minified
|
|
5
|
+
* - History API only
|
|
6
|
+
* - Partial page updates via #app
|
|
7
|
+
*/
|
|
8
|
+
let currentPath =
|
|
9
|
+
typeof window !== "undefined" ? window.location.pathname : "/";
|
|
10
|
+
const listeners = [];
|
|
11
|
+
let isNavigating = false;
|
|
12
|
+
/**
|
|
13
|
+
* Get the current route path
|
|
14
|
+
*/
|
|
15
|
+
export function getCurrentRoute() {
|
|
16
|
+
return currentPath;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Navigate to a new route
|
|
20
|
+
* @param path The path to navigate to
|
|
21
|
+
* @param opts Navigation options
|
|
22
|
+
*/
|
|
23
|
+
export async function navigate(path, opts) {
|
|
24
|
+
if (isNavigating || path === currentPath) return;
|
|
25
|
+
isNavigating = true;
|
|
26
|
+
try {
|
|
27
|
+
const previousPath = currentPath;
|
|
28
|
+
currentPath = path;
|
|
29
|
+
// Update browser history
|
|
30
|
+
if (opts?.replace) {
|
|
31
|
+
window.history.replaceState({ path }, "", path);
|
|
32
|
+
} else {
|
|
33
|
+
window.history.pushState({ path }, "", path);
|
|
34
|
+
}
|
|
35
|
+
// Handle scroll restoration
|
|
36
|
+
if (opts?.scroll !== false) {
|
|
37
|
+
window.scrollTo(0, 0);
|
|
38
|
+
}
|
|
39
|
+
// Fetch and update page content
|
|
40
|
+
await updatePageContent(path);
|
|
41
|
+
// Notify listeners
|
|
42
|
+
notifyListeners({ path, previousPath });
|
|
43
|
+
} finally {
|
|
44
|
+
isNavigating = false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Subscribe to route changes
|
|
49
|
+
*/
|
|
50
|
+
export function onRouteChange(listener) {
|
|
51
|
+
listeners.push(listener);
|
|
52
|
+
return () => {
|
|
53
|
+
const idx = listeners.indexOf(listener);
|
|
54
|
+
if (idx > -1) listeners.splice(idx, 1);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Fetch and replace #app content
|
|
59
|
+
*/
|
|
60
|
+
async function updatePageContent(path) {
|
|
61
|
+
try {
|
|
62
|
+
// Try to fetch JSON payload first (faster)
|
|
63
|
+
const jsonResponse = await fetch(`${path}?_json=1`, {
|
|
64
|
+
headers: { "X-Jen-Router": "1" },
|
|
65
|
+
});
|
|
66
|
+
if (jsonResponse.ok) {
|
|
67
|
+
const data = await jsonResponse.json();
|
|
68
|
+
updateDOM(data.html || data.content);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Fall back to HTML fetch
|
|
72
|
+
const htmlResponse = await fetch(path, {
|
|
73
|
+
headers: { "X-Jen-Router": "1" },
|
|
74
|
+
});
|
|
75
|
+
if (!htmlResponse.ok) {
|
|
76
|
+
if (htmlResponse.status === 404) {
|
|
77
|
+
show404();
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const html = await htmlResponse.text();
|
|
82
|
+
// Extract #app content from response
|
|
83
|
+
const parser = new DOMParser();
|
|
84
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
85
|
+
const newContent = doc.querySelector("#app")?.innerHTML;
|
|
86
|
+
if (newContent) {
|
|
87
|
+
updateDOM(newContent);
|
|
88
|
+
}
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error("[jen-router] Navigation failed:", error);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Update #app innerHTML and re-run hydration hooks
|
|
95
|
+
*/
|
|
96
|
+
function updateDOM(html) {
|
|
97
|
+
const appEl = document.querySelector("#app");
|
|
98
|
+
if (!appEl) return;
|
|
99
|
+
appEl.innerHTML = html;
|
|
100
|
+
// Re-run minimal hydration if available
|
|
101
|
+
if (typeof window !== "undefined" && window.__JEN_HYDRATE__) {
|
|
102
|
+
window.__JEN_HYDRATE__();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Show 404 page
|
|
107
|
+
*/
|
|
108
|
+
function show404() {
|
|
109
|
+
const appEl = document.querySelector("#app");
|
|
110
|
+
if (appEl) {
|
|
111
|
+
appEl.innerHTML =
|
|
112
|
+
'<div class="jen-404"><h1>404 - Page Not Found</h1></div>';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Notify all listeners of route change
|
|
117
|
+
*/
|
|
118
|
+
function notifyListeners(event) {
|
|
119
|
+
listeners.forEach((listener) => {
|
|
120
|
+
try {
|
|
121
|
+
listener(event);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error("[jen-router] Listener error:", error);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Initialize router
|
|
129
|
+
* - Set up popstate listener
|
|
130
|
+
* - Auto-intercept internal links
|
|
131
|
+
*/
|
|
132
|
+
export function initRouter() {
|
|
133
|
+
if (typeof window === "undefined") return;
|
|
134
|
+
// Handle back/forward
|
|
135
|
+
window.addEventListener("popstate", (event) => {
|
|
136
|
+
const path = event.state?.path || window.location.pathname;
|
|
137
|
+
currentPath = path;
|
|
138
|
+
updatePageContent(path).then(() => {
|
|
139
|
+
notifyListeners({ path });
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
// Auto-intercept internal links
|
|
143
|
+
document.addEventListener("click", (event) => {
|
|
144
|
+
const target = event.target.closest("[data-jen-link]");
|
|
145
|
+
if (!target) return;
|
|
146
|
+
const href = target.getAttribute("href");
|
|
147
|
+
if (!href || href.startsWith("http") || href.startsWith("//")) return;
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
navigate(href);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal signal-based reactive state system
|
|
3
|
+
* - No VDOM
|
|
4
|
+
* - Fine-grained reactivity
|
|
5
|
+
* - Under 2 KB minified
|
|
6
|
+
* - Tree-shakable
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Create a reactive signal
|
|
10
|
+
*/
|
|
11
|
+
export function signal(initialValue) {
|
|
12
|
+
let value = initialValue;
|
|
13
|
+
const subscribers = new Set();
|
|
14
|
+
return {
|
|
15
|
+
get value() {
|
|
16
|
+
return value;
|
|
17
|
+
},
|
|
18
|
+
set value(newValue) {
|
|
19
|
+
if (newValue !== value) {
|
|
20
|
+
value = newValue;
|
|
21
|
+
this.notify();
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
subscribe(fn) {
|
|
25
|
+
subscribers.add(fn);
|
|
26
|
+
return () => subscribers.delete(fn);
|
|
27
|
+
},
|
|
28
|
+
notify() {
|
|
29
|
+
subscribers.forEach((fn) => {
|
|
30
|
+
try {
|
|
31
|
+
fn();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("[jen-signal] Subscriber error:", error);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a computed signal (read-only derived value)
|
|
41
|
+
* Automatically tracks signal dependencies
|
|
42
|
+
*/
|
|
43
|
+
export function computed(fn) {
|
|
44
|
+
let cachedValue = fn();
|
|
45
|
+
const subs = new Set();
|
|
46
|
+
let dependencies = new Set();
|
|
47
|
+
const updateValue = () => {
|
|
48
|
+
const newValue = fn();
|
|
49
|
+
if (newValue !== cachedValue) {
|
|
50
|
+
cachedValue = newValue;
|
|
51
|
+
notifySubs();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const notifySubs = () => {
|
|
55
|
+
subs.forEach((sub) => {
|
|
56
|
+
try {
|
|
57
|
+
sub();
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error("[jen-signal] Subscriber error:", error);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
get value() {
|
|
65
|
+
return cachedValue;
|
|
66
|
+
},
|
|
67
|
+
set value(_) {
|
|
68
|
+
// Computed signals are read-only
|
|
69
|
+
console.warn("[jen-signal] Cannot set value on computed signal");
|
|
70
|
+
},
|
|
71
|
+
subscribe(fn) {
|
|
72
|
+
subs.add(fn);
|
|
73
|
+
return () => subs.delete(fn);
|
|
74
|
+
},
|
|
75
|
+
notify() {
|
|
76
|
+
updateValue();
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Bind a signal to a DOM element
|
|
82
|
+
* Updates text content when signal changes
|
|
83
|
+
*/
|
|
84
|
+
export function bindSignal(element, sig) {
|
|
85
|
+
// Set initial value
|
|
86
|
+
element.textContent = String(sig.value);
|
|
87
|
+
// Subscribe to changes
|
|
88
|
+
return sig.subscribe(() => {
|
|
89
|
+
element.textContent = String(sig.value);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Bind signal to an input element's value
|
|
94
|
+
*/
|
|
95
|
+
export function bindInput(input, sig) {
|
|
96
|
+
// Set initial value
|
|
97
|
+
input.value = String(sig.value);
|
|
98
|
+
// Subscribe to signal changes
|
|
99
|
+
const unsubscribe = sig.subscribe(() => {
|
|
100
|
+
input.value = String(sig.value);
|
|
101
|
+
});
|
|
102
|
+
// Update signal on input change
|
|
103
|
+
const handleChange = () => {
|
|
104
|
+
const newVal = input.type === "checkbox" ? input.checked : input.value;
|
|
105
|
+
// Try to coerce to original type
|
|
106
|
+
if (typeof sig.value === "number") {
|
|
107
|
+
sig.value = Number(newVal);
|
|
108
|
+
} else {
|
|
109
|
+
sig.value = newVal;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
input.addEventListener("change", handleChange);
|
|
113
|
+
input.addEventListener("input", handleChange);
|
|
114
|
+
return () => {
|
|
115
|
+
unsubscribe();
|
|
116
|
+
input.removeEventListener("change", handleChange);
|
|
117
|
+
input.removeEventListener("input", handleChange);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Batch multiple signal updates
|
|
122
|
+
* Only notify once after all updates
|
|
123
|
+
*/
|
|
124
|
+
export function batch(fn) {
|
|
125
|
+
fn();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Watch a signal and run effects
|
|
129
|
+
*/
|
|
130
|
+
export function watch(sig, effect) {
|
|
131
|
+
// Run effect immediately
|
|
132
|
+
effect(sig.value);
|
|
133
|
+
// Subscribe to changes
|
|
134
|
+
return sig.subscribe(() => {
|
|
135
|
+
effect(sig.value);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Create a store (collection of signals)
|
|
140
|
+
*/
|
|
141
|
+
export function createStore(initial) {
|
|
142
|
+
const store = {};
|
|
143
|
+
for (const key in initial) {
|
|
144
|
+
store[key] = signal(initial[key]);
|
|
145
|
+
}
|
|
146
|
+
return store;
|
|
147
|
+
}
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
import { readFileSync } from "node:fs";
|
|
19
2
|
import { createVueCompiler } from "./vue.js";
|
|
20
3
|
import { createSvelteCompiler } from "./svelte.js";
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
import { compile as svelteCompile } from "svelte/compiler";
|
|
19
2
|
import { log } from "../shared/log.js";
|
|
20
3
|
export class SvelteCompiler {
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
import {
|
|
19
2
|
parse,
|
|
20
3
|
compileScript,
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of Jen.js.
|
|
3
|
-
* Copyright (C) 2026 oopsio
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
*/
|
|
18
1
|
export {};
|