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,256 @@
|
|
|
1
|
+
import { createCacheKey, executeCacheStrategy } from "./cache.js";
|
|
2
|
+
/**
|
|
3
|
+
* Unified REST/HTTP data fetcher for both server and client.
|
|
4
|
+
* Integrates with cache, retry logic, interceptors, and timeout handling.
|
|
5
|
+
*
|
|
6
|
+
* Supports:
|
|
7
|
+
* - Multiple HTTP methods (GET, POST, PUT, DELETE, PATCH)
|
|
8
|
+
* - Request/response transformation via interceptors
|
|
9
|
+
* - Automatic retry with backoff strategies
|
|
10
|
+
* - Pluggable cache backends
|
|
11
|
+
* - Comprehensive error handling
|
|
12
|
+
*/
|
|
13
|
+
export class RestFetcher {
|
|
14
|
+
cache;
|
|
15
|
+
interceptors;
|
|
16
|
+
baseUrl;
|
|
17
|
+
defaultHeaders = {};
|
|
18
|
+
constructor(opts) {
|
|
19
|
+
this.cache = opts?.cache;
|
|
20
|
+
this.interceptors = opts?.interceptors || [];
|
|
21
|
+
this.baseUrl = opts?.baseUrl;
|
|
22
|
+
this.defaultHeaders = opts?.defaultHeaders || {};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Registers a new interceptor for request/response transformation.
|
|
26
|
+
*/
|
|
27
|
+
addInterceptor(interceptor) {
|
|
28
|
+
this.interceptors.push(interceptor);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Performs a GET request with optional caching.
|
|
32
|
+
*/
|
|
33
|
+
async get(url, config) {
|
|
34
|
+
return this.fetch(url, { ...config, method: "GET" });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Performs a POST request.
|
|
38
|
+
*/
|
|
39
|
+
async post(url, body, config) {
|
|
40
|
+
return this.fetch(url, { ...config, method: "POST", body });
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Performs a PUT request.
|
|
44
|
+
*/
|
|
45
|
+
async put(url, body, config) {
|
|
46
|
+
return this.fetch(url, { ...config, method: "PUT", body });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Performs a DELETE request.
|
|
50
|
+
*/
|
|
51
|
+
async delete(url, config) {
|
|
52
|
+
return this.fetch(url, { ...config, method: "DELETE" });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Performs a PATCH request.
|
|
56
|
+
*/
|
|
57
|
+
async patch(url, body, config) {
|
|
58
|
+
return this.fetch(url, { ...config, method: "PATCH", body });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Core fetch method with cache, retry, and interceptor support.
|
|
62
|
+
*/
|
|
63
|
+
async fetch(url, config) {
|
|
64
|
+
const fullUrl = this.resolveUrl(url);
|
|
65
|
+
const method = config?.method || "GET";
|
|
66
|
+
// Merge headers
|
|
67
|
+
const headers = {
|
|
68
|
+
...this.defaultHeaders,
|
|
69
|
+
...config?.headers,
|
|
70
|
+
...(config?.body && !config.headers?.["content-type"]
|
|
71
|
+
? { "content-type": "application/json" }
|
|
72
|
+
: {}),
|
|
73
|
+
};
|
|
74
|
+
let options = {
|
|
75
|
+
method,
|
|
76
|
+
headers,
|
|
77
|
+
body: config?.body,
|
|
78
|
+
timeout: config?.timeout || 30000,
|
|
79
|
+
credentials: config?.credentials || "same-origin",
|
|
80
|
+
signal: config?.signal,
|
|
81
|
+
};
|
|
82
|
+
// Run beforeRequest interceptors
|
|
83
|
+
for (const interceptor of this.interceptors) {
|
|
84
|
+
if (interceptor.beforeRequest) {
|
|
85
|
+
options = await interceptor.beforeRequest(options);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
// Check cache first if enabled
|
|
90
|
+
const cacheStrategy =
|
|
91
|
+
typeof config?.cache === "boolean"
|
|
92
|
+
? config.cache
|
|
93
|
+
? "cache-first"
|
|
94
|
+
: "no-cache"
|
|
95
|
+
: config?.cache?.strategy || "no-cache";
|
|
96
|
+
const cacheKey = createCacheKey(fullUrl, options);
|
|
97
|
+
const cacheTags =
|
|
98
|
+
(typeof config?.cache === "object" && config.cache.tags) || [];
|
|
99
|
+
const cacheTtl =
|
|
100
|
+
(typeof config?.cache === "object" && config.cache.ttl) || 60000;
|
|
101
|
+
let result;
|
|
102
|
+
if (cacheStrategy !== "no-cache" && method === "GET") {
|
|
103
|
+
const { data, cached } = await executeCacheStrategy(cacheStrategy, {
|
|
104
|
+
key: cacheKey,
|
|
105
|
+
cache: this.cache,
|
|
106
|
+
fetchFn: () => this.performFetch(fullUrl, options),
|
|
107
|
+
ttl: cacheTtl,
|
|
108
|
+
tags: cacheTags,
|
|
109
|
+
});
|
|
110
|
+
result = {
|
|
111
|
+
ok: true,
|
|
112
|
+
data,
|
|
113
|
+
meta: {
|
|
114
|
+
status: 200,
|
|
115
|
+
statusText: "OK",
|
|
116
|
+
headers: {},
|
|
117
|
+
url: fullUrl,
|
|
118
|
+
ok: true,
|
|
119
|
+
cached,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
} else {
|
|
123
|
+
const data = await this.performFetch(fullUrl, options);
|
|
124
|
+
result = {
|
|
125
|
+
ok: true,
|
|
126
|
+
data,
|
|
127
|
+
meta: {
|
|
128
|
+
status: 200,
|
|
129
|
+
statusText: "OK",
|
|
130
|
+
headers: {},
|
|
131
|
+
url: fullUrl,
|
|
132
|
+
ok: true,
|
|
133
|
+
cached: false,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// Run afterResponse interceptors
|
|
138
|
+
for (const interceptor of this.interceptors) {
|
|
139
|
+
if (interceptor.afterResponse) {
|
|
140
|
+
result = await interceptor.afterResponse(result);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
} catch (err) {
|
|
145
|
+
const errorResult = {
|
|
146
|
+
ok: false,
|
|
147
|
+
error: {
|
|
148
|
+
message: err.message || "Unknown error",
|
|
149
|
+
code: err.code,
|
|
150
|
+
status: err.status,
|
|
151
|
+
details: err,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
// Run onError interceptors
|
|
155
|
+
for (const interceptor of this.interceptors) {
|
|
156
|
+
if (interceptor.onError) {
|
|
157
|
+
return await interceptor.onError(errorResult);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return errorResult;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Internal method to perform the actual HTTP request with retry logic.
|
|
165
|
+
*/
|
|
166
|
+
async performFetch(url, options) {
|
|
167
|
+
const retryConfig = {
|
|
168
|
+
attempts: 3,
|
|
169
|
+
delay: 100,
|
|
170
|
+
backoff: "exponential",
|
|
171
|
+
};
|
|
172
|
+
let lastError = null;
|
|
173
|
+
for (let attempt = 0; attempt < retryConfig.attempts; attempt++) {
|
|
174
|
+
try {
|
|
175
|
+
const response = await this.executeRequest(url, options);
|
|
176
|
+
return response;
|
|
177
|
+
} catch (err) {
|
|
178
|
+
lastError = err;
|
|
179
|
+
// Don't retry on client-side errors (4xx)
|
|
180
|
+
if (err.status && err.status >= 400 && err.status < 500) {
|
|
181
|
+
throw err;
|
|
182
|
+
}
|
|
183
|
+
// Calculate backoff delay
|
|
184
|
+
if (attempt < retryConfig.attempts - 1) {
|
|
185
|
+
const delay =
|
|
186
|
+
retryConfig.backoff === "exponential"
|
|
187
|
+
? retryConfig.delay * Math.pow(2, attempt)
|
|
188
|
+
: retryConfig.delay * (attempt + 1);
|
|
189
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
throw lastError || new Error("Failed to fetch after retries");
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Executes the actual HTTP request using fetch API (universal).
|
|
197
|
+
*/
|
|
198
|
+
async executeRequest(url, options) {
|
|
199
|
+
const fetchOpts = {
|
|
200
|
+
method: options.method,
|
|
201
|
+
headers: options.headers,
|
|
202
|
+
credentials: options.credentials,
|
|
203
|
+
signal: options.signal,
|
|
204
|
+
};
|
|
205
|
+
if (options.body) {
|
|
206
|
+
fetchOpts.body =
|
|
207
|
+
typeof options.body === "string"
|
|
208
|
+
? options.body
|
|
209
|
+
: JSON.stringify(options.body);
|
|
210
|
+
}
|
|
211
|
+
const controller = new AbortController();
|
|
212
|
+
const timeoutId = setTimeout(
|
|
213
|
+
() => controller.abort(),
|
|
214
|
+
options.timeout || 30000,
|
|
215
|
+
);
|
|
216
|
+
try {
|
|
217
|
+
const response = await fetch(url, {
|
|
218
|
+
...fetchOpts,
|
|
219
|
+
signal: controller.signal,
|
|
220
|
+
});
|
|
221
|
+
if (!response.ok) {
|
|
222
|
+
const errorText = await response.text().catch(() => "");
|
|
223
|
+
const error = new Error(
|
|
224
|
+
errorText || response.statusText || "HTTP Error",
|
|
225
|
+
);
|
|
226
|
+
error.status = response.status;
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
229
|
+
const contentType = response.headers.get("content-type") || "";
|
|
230
|
+
if (contentType.includes("application/json")) {
|
|
231
|
+
return await response.json();
|
|
232
|
+
} else if (contentType.includes("text")) {
|
|
233
|
+
return await response.text();
|
|
234
|
+
} else {
|
|
235
|
+
return await response.arrayBuffer();
|
|
236
|
+
}
|
|
237
|
+
} finally {
|
|
238
|
+
clearTimeout(timeoutId);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Resolves relative URLs using baseUrl if configured.
|
|
243
|
+
*/
|
|
244
|
+
resolveUrl(url) {
|
|
245
|
+
if (this.baseUrl && !url.startsWith("http")) {
|
|
246
|
+
return this.baseUrl.replace(/\/$/, "") + "/" + url.replace(/^\//, "");
|
|
247
|
+
}
|
|
248
|
+
return url;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Creates a REST fetcher with sensible defaults.
|
|
253
|
+
*/
|
|
254
|
+
export function createRestFetcher(opts) {
|
|
255
|
+
return new RestFetcher(opts);
|
|
256
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { RestFetcher } from "./rest.js";
|
|
2
|
+
import { GraphQLClient } from "./graphql.js";
|
|
3
|
+
/**
|
|
4
|
+
* Server-side data fetching utilities for use in loaders and middleware.
|
|
5
|
+
* Provides access to REST and GraphQL clients with proper cache integration.
|
|
6
|
+
*
|
|
7
|
+
* Server fetchers have access to:
|
|
8
|
+
* - Backend cache (memory, Redis, etc.)
|
|
9
|
+
* - Request/response interceptors
|
|
10
|
+
* - Loader context (URL, params, headers, cookies)
|
|
11
|
+
*/
|
|
12
|
+
export class ServerDataFetcher {
|
|
13
|
+
rest;
|
|
14
|
+
graphql;
|
|
15
|
+
context;
|
|
16
|
+
constructor(serverCtx) {
|
|
17
|
+
this.rest = new RestFetcher({
|
|
18
|
+
cache: serverCtx.cache,
|
|
19
|
+
interceptors: serverCtx.interceptors,
|
|
20
|
+
});
|
|
21
|
+
this.graphql = new GraphQLClient({
|
|
22
|
+
endpoint: serverCtx.config.baseUrl || "https://api.example.com/graphql",
|
|
23
|
+
cache: serverCtx.cache,
|
|
24
|
+
interceptors: serverCtx.interceptors,
|
|
25
|
+
});
|
|
26
|
+
this.context = serverCtx.loaderContext;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns loader context information for conditional data fetching.
|
|
30
|
+
* Useful for customizing requests based on route params, headers, etc.
|
|
31
|
+
*/
|
|
32
|
+
getLoaderContext() {
|
|
33
|
+
return this.context;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a request interceptor that adds authentication headers.
|
|
37
|
+
* Common pattern for API authentication.
|
|
38
|
+
*/
|
|
39
|
+
withAuthToken(token) {
|
|
40
|
+
this.rest.addInterceptor({
|
|
41
|
+
beforeRequest: (req) => {
|
|
42
|
+
req.headers = {
|
|
43
|
+
...req.headers,
|
|
44
|
+
Authorization: `Bearer ${token}`,
|
|
45
|
+
};
|
|
46
|
+
return req;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a request interceptor that adds common headers.
|
|
53
|
+
*/
|
|
54
|
+
withHeaders(headers) {
|
|
55
|
+
this.rest.addInterceptor({
|
|
56
|
+
beforeRequest: (req) => {
|
|
57
|
+
req.headers = {
|
|
58
|
+
...req.headers,
|
|
59
|
+
...headers,
|
|
60
|
+
};
|
|
61
|
+
return req;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Adds request tracing/logging interceptor.
|
|
68
|
+
*/
|
|
69
|
+
withLogging(logger) {
|
|
70
|
+
const log = logger || console.log;
|
|
71
|
+
this.rest.addInterceptor({
|
|
72
|
+
beforeRequest: (req) => {
|
|
73
|
+
log(`[ServerFetch] ${req.method} ${req.headers}`);
|
|
74
|
+
return req;
|
|
75
|
+
},
|
|
76
|
+
afterResponse: (res) => {
|
|
77
|
+
log(`[ServerFetch] Response: ${res.ok ? "ok" : "error"}`);
|
|
78
|
+
return res;
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Global cache instance for server-side fetching.
|
|
86
|
+
* Should be initialized during app startup with the configured cache backend.
|
|
87
|
+
*/
|
|
88
|
+
let globalServerCache = null;
|
|
89
|
+
/**
|
|
90
|
+
* Initializes the global server fetch context.
|
|
91
|
+
* Called during app startup to set up cache and interceptors.
|
|
92
|
+
*/
|
|
93
|
+
export function initializeServerFetch(context) {
|
|
94
|
+
globalServerCache = context;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the server data fetcher for use in loaders and middleware.
|
|
98
|
+
* Must be called after initializeServerFetch().
|
|
99
|
+
*/
|
|
100
|
+
export function getServerDataFetcher(loaderCtx) {
|
|
101
|
+
if (!globalServerCache) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
"Server fetch not initialized. Call initializeServerFetch() during app startup.",
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return new ServerDataFetcher({
|
|
107
|
+
...globalServerCache,
|
|
108
|
+
loaderContext: loaderCtx,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Convenience function for quick REST GET requests in loaders.
|
|
113
|
+
* Uses the global server fetch context.
|
|
114
|
+
*/
|
|
115
|
+
export async function fetchData(url, loaderCtx) {
|
|
116
|
+
const fetcher = getServerDataFetcher(loaderCtx);
|
|
117
|
+
return fetcher.rest.get(url);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Convenience function for GraphQL queries in loaders.
|
|
121
|
+
*/
|
|
122
|
+
export async function queryGraphQL(query, variables, loaderCtx) {
|
|
123
|
+
const fetcher = getServerDataFetcher(loaderCtx);
|
|
124
|
+
return fetcher.graphql.query({ query, variables });
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a data loader that wraps error handling and logging.
|
|
128
|
+
*/
|
|
129
|
+
export function createDataLoader(fn) {
|
|
130
|
+
return async (loaderCtx) => {
|
|
131
|
+
try {
|
|
132
|
+
const fetcher = getServerDataFetcher(loaderCtx);
|
|
133
|
+
return await fn(fetcher);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
console.error("[DataLoader] Error:", err);
|
|
136
|
+
throw err;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Parallel data loader for fetching multiple resources concurrently.
|
|
142
|
+
*/
|
|
143
|
+
export function createParallelDataLoader(loaders) {
|
|
144
|
+
return async (loaderCtx) => {
|
|
145
|
+
const fetcher = getServerDataFetcher(loaderCtx);
|
|
146
|
+
const results = {};
|
|
147
|
+
const promises = Object.entries(loaders).map(async ([key, loader]) => {
|
|
148
|
+
try {
|
|
149
|
+
results[key] = await loader(loaderCtx);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
console.error(`[DataLoader] ${String(key)} failed:`, err);
|
|
152
|
+
throw err;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
await Promise.all(promises);
|
|
156
|
+
return results;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Conditional data loader that fetches based on route params or query.
|
|
161
|
+
*/
|
|
162
|
+
export function createConditionalDataLoader(condition, loader, fallback) {
|
|
163
|
+
return async (loaderCtx) => {
|
|
164
|
+
if (condition(loaderCtx)) {
|
|
165
|
+
return loader(loaderCtx);
|
|
166
|
+
}
|
|
167
|
+
return fallback;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Error-tolerant data loader with fallback value.
|
|
172
|
+
*/
|
|
173
|
+
export function createResilientDataLoader(loader, fallback) {
|
|
174
|
+
return async (loaderCtx) => {
|
|
175
|
+
try {
|
|
176
|
+
return await loader(loaderCtx);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
console.warn("[DataLoader] Using fallback due to error:", err);
|
|
179
|
+
return fallback;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
@@ -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 { JDBDriver } from "./drivers/jdb";
|
|
19
2
|
import { SQLDriver } from "./drivers/sql";
|
|
20
3
|
/**
|
|
@@ -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 { JDBEngine } from "../../jdb";
|
|
19
2
|
export class JDBDriver {
|
|
20
3
|
engine;
|
|
@@ -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
|
// Whitelist of allowed identifiers (table/column names) - must be explicitly allowed
|
|
19
2
|
const ALLOWED_IDENTIFIERS = new Set();
|
|
20
3
|
/**
|
|
@@ -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 { DBConnector } from "./connector";
|
|
19
2
|
export * from "./types";
|
|
20
3
|
export * from "./drivers/jdb";
|
|
@@ -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 {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of Jen.js.
|
|
3
|
+
* Copyright (C) 2026 oopsio
|
|
4
|
+
*/
|
|
5
|
+
export class ComponentTreeManager {
|
|
6
|
+
components = new Map();
|
|
7
|
+
tree = [];
|
|
8
|
+
eventBus;
|
|
9
|
+
constructor(eventBus) {
|
|
10
|
+
this.eventBus = eventBus;
|
|
11
|
+
}
|
|
12
|
+
addComponent(component) {
|
|
13
|
+
this.components.set(component.id, component);
|
|
14
|
+
// Add to root tree if no parent
|
|
15
|
+
if (!component.parent) {
|
|
16
|
+
this.tree.push(component);
|
|
17
|
+
}
|
|
18
|
+
this.eventBus.emit("component:added", component);
|
|
19
|
+
}
|
|
20
|
+
getComponentById(id) {
|
|
21
|
+
return this.components.get(id);
|
|
22
|
+
}
|
|
23
|
+
getTree() {
|
|
24
|
+
return this.tree;
|
|
25
|
+
}
|
|
26
|
+
getNextComponent(current) {
|
|
27
|
+
if (current.children && current.children.length > 0) {
|
|
28
|
+
return current.children[0];
|
|
29
|
+
}
|
|
30
|
+
let node = current;
|
|
31
|
+
while (node) {
|
|
32
|
+
if (node.parent) {
|
|
33
|
+
const siblings = node.parent.children;
|
|
34
|
+
const index = siblings.indexOf(node);
|
|
35
|
+
if (index < siblings.length - 1) {
|
|
36
|
+
return siblings[index + 1];
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
// Check root level siblings
|
|
40
|
+
const index = this.tree.indexOf(node);
|
|
41
|
+
if (index < this.tree.length - 1) {
|
|
42
|
+
return this.tree[index + 1];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
node = node.parent;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
getPreviousComponent(current) {
|
|
50
|
+
if (current.parent) {
|
|
51
|
+
const siblings = current.parent.children;
|
|
52
|
+
const index = siblings.indexOf(current);
|
|
53
|
+
if (index > 0) {
|
|
54
|
+
const prev = siblings[index - 1];
|
|
55
|
+
return prev.children && prev.children.length > 0
|
|
56
|
+
? this.getLastDescendant(prev)
|
|
57
|
+
: prev;
|
|
58
|
+
}
|
|
59
|
+
return current.parent;
|
|
60
|
+
}
|
|
61
|
+
const index = this.tree.indexOf(current);
|
|
62
|
+
if (index > 0) {
|
|
63
|
+
const prev = this.tree[index - 1];
|
|
64
|
+
return prev.children && prev.children.length > 0
|
|
65
|
+
? this.getLastDescendant(prev)
|
|
66
|
+
: prev;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
getLastDescendant(node) {
|
|
71
|
+
if (!node.children || node.children.length === 0) {
|
|
72
|
+
return node;
|
|
73
|
+
}
|
|
74
|
+
return this.getLastDescendant(node.children[node.children.length - 1]);
|
|
75
|
+
}
|
|
76
|
+
removeComponent(id) {
|
|
77
|
+
const component = this.components.get(id);
|
|
78
|
+
if (!component) return;
|
|
79
|
+
if (component.parent) {
|
|
80
|
+
const index = component.parent.children.indexOf(component);
|
|
81
|
+
if (index > -1) {
|
|
82
|
+
component.parent.children.splice(index, 1);
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
const index = this.tree.indexOf(component);
|
|
86
|
+
if (index > -1) {
|
|
87
|
+
this.tree.splice(index, 1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
this.components.delete(id);
|
|
91
|
+
this.eventBus.emit("component:removed", id);
|
|
92
|
+
}
|
|
93
|
+
updateComponent(id, updates) {
|
|
94
|
+
const component = this.components.get(id);
|
|
95
|
+
if (!component) return;
|
|
96
|
+
Object.assign(component, updates);
|
|
97
|
+
this.eventBus.emit("component:updated", component);
|
|
98
|
+
}
|
|
99
|
+
clear() {
|
|
100
|
+
this.components.clear();
|
|
101
|
+
this.tree = [];
|
|
102
|
+
}
|
|
103
|
+
getAllComponents() {
|
|
104
|
+
return Array.from(this.components.values());
|
|
105
|
+
}
|
|
106
|
+
}
|