create-jen-app 1.2.2 → 1.2.3
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/README.md +3 -1
- package/dist/index.js +1 -6
- package/package.json +2 -2
- package/templates/static/.esbuild/jen.config.js +18 -0
- package/templates/static/README.md +63 -67
- package/templates/static/build.js +4 -6
- package/templates/static/jen.config.ts +3 -5
- package/templates/static/jenjs.d.ts +3 -3
- package/templates/static/lib/api/(hello).d.ts +5 -5
- package/templates/static/lib/api/(hello).js +7 -7
- package/templates/static/lib/auth/cookie-utils.d.ts +20 -11
- package/templates/static/lib/auth/cookie-utils.js +66 -69
- package/templates/static/lib/auth/jwt.d.ts +28 -0
- package/templates/static/lib/auth/jwt.js +50 -6
- package/templates/static/lib/auth/session.d.ts +34 -34
- package/templates/static/lib/auth/session.js +79 -81
- package/templates/static/lib/build/asset-hashing.js +4 -4
- package/templates/static/lib/build/asset-manifest.js +4 -4
- package/templates/static/lib/build/build.d.ts +20 -0
- package/templates/static/lib/build/build.js +43 -6
- package/templates/static/lib/build/island-hydration.js +2 -2
- package/templates/static/lib/build/minifier.js +12 -12
- package/templates/static/lib/build/page-renderer.d.ts +2 -2
- package/templates/static/lib/build/page-renderer.js +3 -3
- package/templates/static/lib/build/production-build.d.ts +1 -1
- package/templates/static/lib/build/production-build.js +4 -4
- package/templates/static/lib/build/ssg-pipeline.d.ts +1 -1
- package/templates/static/lib/build/ssg-pipeline.js +19 -19
- package/templates/static/lib/build-tools/build-site.d.ts +3 -3
- package/templates/static/lib/build-tools/build-site.js +27 -30
- package/templates/static/lib/cache/index.d.ts +8 -0
- package/templates/static/lib/cache/index.js +8 -0
- package/templates/static/lib/cache/memory.d.ts +31 -4
- package/templates/static/lib/cache/memory.js +38 -12
- package/templates/static/lib/cache/redis.d.ts +43 -4
- package/templates/static/lib/cache/redis.js +59 -14
- package/templates/static/lib/cli/banner.d.ts +5 -1
- package/templates/static/lib/cli/banner.js +18 -14
- package/templates/static/lib/cli/templates/ssg/jen.config.js +29 -29
- package/templates/static/lib/cli/templates/ssg/site/index.js +6 -1
- package/templates/static/lib/cli/templates/ssr/jen.config.js +29 -29
- package/templates/static/lib/cli/templates/ssr/site/index.js +6 -1
- package/templates/static/lib/compilers/esbuild-plugins.js +96 -98
- package/templates/static/lib/compilers/svelte.d.ts +10 -10
- package/templates/static/lib/compilers/svelte.js +31 -31
- package/templates/static/lib/compilers/vue.d.ts +8 -8
- package/templates/static/lib/compilers/vue.js +76 -68
- package/templates/static/lib/core/config.d.ts +217 -50
- package/templates/static/lib/core/http.d.ts +55 -2
- package/templates/static/lib/core/http.js +66 -20
- package/templates/static/lib/core/middleware-hooks.d.ts +204 -31
- package/templates/static/lib/core/middleware-hooks.js +86 -41
- package/templates/static/lib/core/paths.d.ts +42 -4
- package/templates/static/lib/core/paths.js +34 -2
- package/templates/static/lib/core/routes/match.d.ts +51 -3
- package/templates/static/lib/core/routes/match.js +44 -11
- package/templates/static/lib/core/routes/scan.d.ts +49 -5
- package/templates/static/lib/core/routes/scan.js +174 -115
- package/templates/static/lib/core/types.d.ts +148 -13
- package/templates/static/lib/css/compiler.d.ts +16 -13
- package/templates/static/lib/css/compiler.js +62 -58
- package/templates/static/lib/db/connector.d.ts +27 -1
- package/templates/static/lib/db/connector.js +37 -11
- package/templates/static/lib/db/drivers/jdb.d.ts +13 -9
- package/templates/static/lib/db/drivers/jdb.js +41 -39
- package/templates/static/lib/db/drivers/sql.d.ts +16 -12
- package/templates/static/lib/db/drivers/sql.js +152 -135
- package/templates/static/lib/db/index.d.ts +20 -12
- package/templates/static/lib/db/index.js +41 -41
- package/templates/static/lib/db/types.d.ts +22 -18
- package/templates/static/lib/graphql/index.d.ts +47 -0
- package/templates/static/lib/graphql/index.js +50 -3
- package/templates/static/lib/graphql/resolvers.d.ts +51 -11
- package/templates/static/lib/graphql/resolvers.js +22 -6
- package/templates/static/lib/graphql/schema.d.ts +34 -0
- package/templates/static/lib/graphql/schema.js +34 -2
- package/templates/static/lib/i18n/en.json +2 -2
- package/templates/static/lib/i18n/es.json +2 -2
- package/templates/static/lib/i18n/index.d.ts +4 -4
- package/templates/static/lib/i18n/index.js +10 -10
- package/templates/static/lib/import/jen-import.d.ts +39 -10
- package/templates/static/lib/import/jen-import.js +130 -80
- package/templates/static/lib/index.d.ts +42 -11
- package/templates/static/lib/index.js +21 -8
- package/templates/static/lib/jdb/engine.d.ts +35 -6
- package/templates/static/lib/jdb/engine.js +260 -144
- package/templates/static/lib/jdb/index.d.ts +32 -0
- package/templates/static/lib/jdb/index.js +32 -0
- package/templates/static/lib/jdb/types.d.ts +212 -30
- package/templates/static/lib/jdb/utils.d.ts +60 -0
- package/templates/static/lib/jdb/utils.js +159 -107
- package/templates/static/lib/middleware/builtins/body-parser.d.ts +15 -0
- package/templates/static/lib/middleware/builtins/body-parser.js +53 -35
- package/templates/static/lib/middleware/builtins/cors.d.ts +8 -6
- package/templates/static/lib/middleware/builtins/cors.js +52 -48
- package/templates/static/lib/middleware/builtins/logger.d.ts +18 -0
- package/templates/static/lib/middleware/builtins/logger.js +31 -13
- package/templates/static/lib/middleware/builtins/rate-limit.d.ts +19 -2
- package/templates/static/lib/middleware/builtins/rate-limit.js +75 -55
- package/templates/static/lib/middleware/builtins/request-id.d.ts +18 -0
- package/templates/static/lib/middleware/builtins/request-id.js +26 -5
- package/templates/static/lib/middleware/builtins/security-headers.d.ts +18 -0
- package/templates/static/lib/middleware/builtins/security-headers.js +51 -20
- package/templates/static/lib/middleware/context.d.ts +102 -15
- package/templates/static/lib/middleware/context.js +121 -30
- package/templates/static/lib/middleware/decorators.d.ts +18 -1
- package/templates/static/lib/middleware/decorators.js +83 -34
- package/templates/static/lib/middleware/errors/handler.js +22 -24
- package/templates/static/lib/middleware/errors/http-error.d.ts +3 -3
- package/templates/static/lib/middleware/errors/http-error.js +8 -8
- package/templates/static/lib/middleware/kernel.d.ts +67 -4
- package/templates/static/lib/middleware/kernel.js +80 -17
- package/templates/static/lib/middleware/pipeline.d.ts +51 -2
- package/templates/static/lib/middleware/pipeline.js +143 -45
- package/templates/static/lib/middleware/registry.d.ts +67 -8
- package/templates/static/lib/middleware/registry.js +83 -22
- package/templates/static/lib/middleware/response.d.ts +73 -11
- package/templates/static/lib/middleware/response.js +104 -40
- package/templates/static/lib/middleware/utils/matcher.js +11 -12
- package/templates/static/lib/native/bundle.d.ts +13 -8
- package/templates/static/lib/native/bundle.js +14 -14
- package/templates/static/lib/native/dev-server.d.ts +11 -4
- package/templates/static/lib/native/dev-server.js +14 -12
- package/templates/static/lib/native/index.d.ts +20 -20
- package/templates/static/lib/native/index.js +23 -21
- package/templates/static/lib/native/optimizer.d.ts +14 -10
- package/templates/static/lib/native/optimizer.js +14 -14
- package/templates/static/lib/native/style-compiler.d.ts +17 -8
- package/templates/static/lib/native/style-compiler.js +9 -9
- package/templates/static/lib/plugin/loader.d.ts +8 -6
- package/templates/static/lib/plugin/loader.js +25 -31
- package/templates/static/lib/runtime/client-runtime.d.ts +15 -0
- package/templates/static/lib/runtime/client-runtime.js +23 -9
- package/templates/static/lib/runtime/hmr.d.ts +23 -1
- package/templates/static/lib/runtime/hmr.js +27 -5
- package/templates/static/lib/runtime/hydrate.d.ts +17 -0
- package/templates/static/lib/runtime/hydrate.js +48 -21
- package/templates/static/lib/runtime/island-hydration-client.d.ts +5 -2
- package/templates/static/lib/runtime/island-hydration-client.js +122 -91
- package/templates/static/lib/runtime/islands.d.ts +82 -27
- package/templates/static/lib/runtime/islands.js +92 -54
- package/templates/static/lib/runtime/render.d.ts +36 -9
- package/templates/static/lib/runtime/render.js +208 -130
- package/templates/static/lib/server/api-routes.d.ts +96 -28
- package/templates/static/lib/server/api-routes.js +214 -156
- package/templates/static/lib/server/api.d.ts +3 -3
- package/templates/static/lib/server/api.js +93 -92
- package/templates/static/lib/server/app.d.ts +37 -3
- package/templates/static/lib/server/app.js +328 -254
- package/templates/static/lib/server/runtimeServe.d.ts +56 -0
- package/templates/static/lib/server/runtimeServe.js +130 -69
- package/templates/static/lib/server/ssr.d.ts +161 -0
- package/templates/static/lib/server/ssr.js +219 -0
- package/templates/static/lib/shared/log.d.ts +47 -3
- package/templates/static/lib/shared/log.js +60 -10
- package/templates/static/server.js +4 -6
- package/templates/static/site/(home).tsx +30 -12
- package/templates/static/site/styles/global.scss +89 -78
- package/templates/static/tsconfig.json +39 -39
- package/templates/static/node_modules/.bin/esbuild +0 -16
- package/templates/static/node_modules/.bin/esbuild.cmd +0 -17
- package/templates/static/node_modules/.bin/esbuild.ps1 +0 -28
- package/templates/static/node_modules/.bin/tsc +0 -16
- package/templates/static/node_modules/.bin/tsc.cmd +0 -17
- package/templates/static/node_modules/.bin/tsc.ps1 +0 -28
- package/templates/static/node_modules/.bin/tsserver +0 -16
- package/templates/static/node_modules/.bin/tsserver.cmd +0 -17
- package/templates/static/node_modules/.bin/tsserver.ps1 +0 -28
- package/templates/static/node_modules/.jen/cache/B__Jen.js_packages_create-jen-app_templates_static_site_(home).tsx.mjs +0 -14
- package/templates/static/node_modules/.jen/cache/B__Jen.js_packages_create-jen-app_yo_site_(home).tsx.mjs +0 -11
- package/templates/static/node_modules/.package-lock.json +0 -585
- package/templates/static/node_modules/@esbuild/win32-x64/README.md +0 -3
- package/templates/static/node_modules/@esbuild/win32-x64/esbuild.exe +0 -0
- package/templates/static/node_modules/@esbuild/win32-x64/package.json +0 -20
- package/templates/static/node_modules/@jenjs/master/README.md +0 -24
- package/templates/static/node_modules/@jenjs/master/index.js +0 -3655
- package/templates/static/node_modules/@jenjs/master/package.json +0 -36
- package/templates/static/node_modules/@polka/url/build.js +0 -49
- package/templates/static/node_modules/@polka/url/build.mjs +0 -47
- package/templates/static/node_modules/@polka/url/index.d.ts +0 -11
- package/templates/static/node_modules/@polka/url/package.json +0 -30
- package/templates/static/node_modules/@polka/url/readme.md +0 -68
- package/templates/static/node_modules/@types/node/LICENSE +0 -21
- package/templates/static/node_modules/@types/node/README.md +0 -15
- package/templates/static/node_modules/@types/node/assert/strict.d.ts +0 -111
- package/templates/static/node_modules/@types/node/assert.d.ts +0 -1078
- package/templates/static/node_modules/@types/node/async_hooks.d.ts +0 -603
- package/templates/static/node_modules/@types/node/buffer.buffer.d.ts +0 -472
- package/templates/static/node_modules/@types/node/buffer.d.ts +0 -1934
- package/templates/static/node_modules/@types/node/child_process.d.ts +0 -1476
- package/templates/static/node_modules/@types/node/cluster.d.ts +0 -578
- package/templates/static/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
- package/templates/static/node_modules/@types/node/compatibility/index.d.ts +0 -9
- package/templates/static/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
- package/templates/static/node_modules/@types/node/compatibility/iterators.d.ts +0 -20
- package/templates/static/node_modules/@types/node/console.d.ts +0 -452
- package/templates/static/node_modules/@types/node/constants.d.ts +0 -21
- package/templates/static/node_modules/@types/node/crypto.d.ts +0 -4545
- package/templates/static/node_modules/@types/node/dgram.d.ts +0 -600
- package/templates/static/node_modules/@types/node/diagnostics_channel.d.ts +0 -578
- package/templates/static/node_modules/@types/node/dns/promises.d.ts +0 -503
- package/templates/static/node_modules/@types/node/dns.d.ts +0 -923
- package/templates/static/node_modules/@types/node/domain.d.ts +0 -170
- package/templates/static/node_modules/@types/node/events.d.ts +0 -976
- package/templates/static/node_modules/@types/node/fs/promises.d.ts +0 -1295
- package/templates/static/node_modules/@types/node/fs.d.ts +0 -4461
- package/templates/static/node_modules/@types/node/globals.d.ts +0 -172
- package/templates/static/node_modules/@types/node/globals.typedarray.d.ts +0 -38
- package/templates/static/node_modules/@types/node/http.d.ts +0 -2089
- package/templates/static/node_modules/@types/node/http2.d.ts +0 -2644
- package/templates/static/node_modules/@types/node/https.d.ts +0 -579
- package/templates/static/node_modules/@types/node/index.d.ts +0 -97
- package/templates/static/node_modules/@types/node/inspector.d.ts +0 -253
- package/templates/static/node_modules/@types/node/inspector.generated.d.ts +0 -4052
- package/templates/static/node_modules/@types/node/module.d.ts +0 -891
- package/templates/static/node_modules/@types/node/net.d.ts +0 -1057
- package/templates/static/node_modules/@types/node/os.d.ts +0 -506
- package/templates/static/node_modules/@types/node/package.json +0 -145
- package/templates/static/node_modules/@types/node/path.d.ts +0 -200
- package/templates/static/node_modules/@types/node/perf_hooks.d.ts +0 -968
- package/templates/static/node_modules/@types/node/process.d.ts +0 -2089
- package/templates/static/node_modules/@types/node/punycode.d.ts +0 -117
- package/templates/static/node_modules/@types/node/querystring.d.ts +0 -152
- package/templates/static/node_modules/@types/node/readline/promises.d.ts +0 -161
- package/templates/static/node_modules/@types/node/readline.d.ts +0 -594
- package/templates/static/node_modules/@types/node/repl.d.ts +0 -428
- package/templates/static/node_modules/@types/node/sea.d.ts +0 -153
- package/templates/static/node_modules/@types/node/sqlite.d.ts +0 -721
- package/templates/static/node_modules/@types/node/stream/consumers.d.ts +0 -38
- package/templates/static/node_modules/@types/node/stream/promises.d.ts +0 -90
- package/templates/static/node_modules/@types/node/stream/web.d.ts +0 -622
- package/templates/static/node_modules/@types/node/stream.d.ts +0 -1664
- package/templates/static/node_modules/@types/node/string_decoder.d.ts +0 -67
- package/templates/static/node_modules/@types/node/test.d.ts +0 -2163
- package/templates/static/node_modules/@types/node/timers/promises.d.ts +0 -108
- package/templates/static/node_modules/@types/node/timers.d.ts +0 -287
- package/templates/static/node_modules/@types/node/tls.d.ts +0 -1319
- package/templates/static/node_modules/@types/node/trace_events.d.ts +0 -197
- package/templates/static/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -468
- package/templates/static/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -34
- package/templates/static/node_modules/@types/node/ts5.6/index.d.ts +0 -97
- package/templates/static/node_modules/@types/node/tty.d.ts +0 -208
- package/templates/static/node_modules/@types/node/url.d.ts +0 -984
- package/templates/static/node_modules/@types/node/util.d.ts +0 -2606
- package/templates/static/node_modules/@types/node/v8.d.ts +0 -920
- package/templates/static/node_modules/@types/node/vm.d.ts +0 -1000
- package/templates/static/node_modules/@types/node/wasi.d.ts +0 -181
- package/templates/static/node_modules/@types/node/web-globals/abortcontroller.d.ts +0 -34
- package/templates/static/node_modules/@types/node/web-globals/domexception.d.ts +0 -68
- package/templates/static/node_modules/@types/node/web-globals/events.d.ts +0 -97
- package/templates/static/node_modules/@types/node/web-globals/fetch.d.ts +0 -55
- package/templates/static/node_modules/@types/node/web-globals/navigator.d.ts +0 -22
- package/templates/static/node_modules/@types/node/web-globals/storage.d.ts +0 -24
- package/templates/static/node_modules/@types/node/worker_threads.d.ts +0 -784
- package/templates/static/node_modules/@types/node/zlib.d.ts +0 -683
- package/templates/static/node_modules/esbuild/LICENSE.md +0 -21
- package/templates/static/node_modules/esbuild/README.md +0 -3
- package/templates/static/node_modules/esbuild/bin/esbuild +0 -223
- package/templates/static/node_modules/esbuild/install.js +0 -289
- package/templates/static/node_modules/esbuild/lib/main.d.ts +0 -716
- package/templates/static/node_modules/esbuild/lib/main.js +0 -2242
- package/templates/static/node_modules/esbuild/package.json +0 -49
- package/templates/static/node_modules/mrmime/index.d.ts +0 -2
- package/templates/static/node_modules/mrmime/index.js +0 -449
- package/templates/static/node_modules/mrmime/index.mjs +0 -448
- package/templates/static/node_modules/mrmime/license +0 -21
- package/templates/static/node_modules/mrmime/package.json +0 -44
- package/templates/static/node_modules/mrmime/readme.md +0 -130
- package/templates/static/node_modules/preact/LICENSE +0 -21
- package/templates/static/node_modules/preact/README.md +0 -185
- package/templates/static/node_modules/preact/compat/client.d.ts +0 -13
- package/templates/static/node_modules/preact/compat/client.js +0 -21
- package/templates/static/node_modules/preact/compat/client.mjs +0 -24
- package/templates/static/node_modules/preact/compat/dist/compat.js +0 -2
- package/templates/static/node_modules/preact/compat/dist/compat.js.map +0 -1
- package/templates/static/node_modules/preact/compat/dist/compat.mjs +0 -2
- package/templates/static/node_modules/preact/compat/dist/compat.module.js +0 -2
- package/templates/static/node_modules/preact/compat/dist/compat.module.js.map +0 -1
- package/templates/static/node_modules/preact/compat/dist/compat.umd.js +0 -2
- package/templates/static/node_modules/preact/compat/dist/compat.umd.js.map +0 -1
- package/templates/static/node_modules/preact/compat/jsx-dev-runtime.js +0 -3
- package/templates/static/node_modules/preact/compat/jsx-dev-runtime.mjs +0 -3
- package/templates/static/node_modules/preact/compat/jsx-runtime.js +0 -3
- package/templates/static/node_modules/preact/compat/jsx-runtime.mjs +0 -3
- package/templates/static/node_modules/preact/compat/package.json +0 -55
- package/templates/static/node_modules/preact/compat/scheduler.js +0 -15
- package/templates/static/node_modules/preact/compat/scheduler.mjs +0 -23
- package/templates/static/node_modules/preact/compat/server.browser.js +0 -11
- package/templates/static/node_modules/preact/compat/server.js +0 -36
- package/templates/static/node_modules/preact/compat/server.mjs +0 -17
- package/templates/static/node_modules/preact/compat/src/Children.js +0 -21
- package/templates/static/node_modules/preact/compat/src/PureComponent.js +0 -16
- package/templates/static/node_modules/preact/compat/src/forwardRef.js +0 -44
- package/templates/static/node_modules/preact/compat/src/hooks.js +0 -70
- package/templates/static/node_modules/preact/compat/src/index.d.ts +0 -351
- package/templates/static/node_modules/preact/compat/src/index.js +0 -238
- package/templates/static/node_modules/preact/compat/src/internal.d.ts +0 -48
- package/templates/static/node_modules/preact/compat/src/memo.js +0 -35
- package/templates/static/node_modules/preact/compat/src/portals.js +0 -78
- package/templates/static/node_modules/preact/compat/src/render.js +0 -313
- package/templates/static/node_modules/preact/compat/src/suspense-list.d.ts +0 -16
- package/templates/static/node_modules/preact/compat/src/suspense-list.js +0 -127
- package/templates/static/node_modules/preact/compat/src/suspense.d.ts +0 -19
- package/templates/static/node_modules/preact/compat/src/suspense.js +0 -291
- package/templates/static/node_modules/preact/compat/src/util.js +0 -33
- package/templates/static/node_modules/preact/compat/test-utils.js +0 -1
- package/templates/static/node_modules/preact/compat/test-utils.mjs +0 -1
- package/templates/static/node_modules/preact/debug/dist/debug.js +0 -2
- package/templates/static/node_modules/preact/debug/dist/debug.js.map +0 -1
- package/templates/static/node_modules/preact/debug/dist/debug.mjs +0 -2
- package/templates/static/node_modules/preact/debug/dist/debug.module.js +0 -2
- package/templates/static/node_modules/preact/debug/dist/debug.module.js.map +0 -1
- package/templates/static/node_modules/preact/debug/dist/debug.umd.js +0 -2
- package/templates/static/node_modules/preact/debug/dist/debug.umd.js.map +0 -1
- package/templates/static/node_modules/preact/debug/package.json +0 -27
- package/templates/static/node_modules/preact/debug/src/check-props.js +0 -54
- package/templates/static/node_modules/preact/debug/src/component-stack.js +0 -146
- package/templates/static/node_modules/preact/debug/src/constants.js +0 -3
- package/templates/static/node_modules/preact/debug/src/debug.js +0 -593
- package/templates/static/node_modules/preact/debug/src/index.d.ts +0 -23
- package/templates/static/node_modules/preact/debug/src/index.js +0 -12
- package/templates/static/node_modules/preact/debug/src/internal.d.ts +0 -82
- package/templates/static/node_modules/preact/debug/src/util.js +0 -15
- package/templates/static/node_modules/preact/devtools/dist/devtools.js +0 -2
- package/templates/static/node_modules/preact/devtools/dist/devtools.js.map +0 -1
- package/templates/static/node_modules/preact/devtools/dist/devtools.mjs +0 -2
- package/templates/static/node_modules/preact/devtools/dist/devtools.module.js +0 -2
- package/templates/static/node_modules/preact/devtools/dist/devtools.module.js.map +0 -1
- package/templates/static/node_modules/preact/devtools/dist/devtools.umd.js +0 -2
- package/templates/static/node_modules/preact/devtools/dist/devtools.umd.js.map +0 -1
- package/templates/static/node_modules/preact/devtools/package.json +0 -25
- package/templates/static/node_modules/preact/devtools/src/devtools.js +0 -21
- package/templates/static/node_modules/preact/devtools/src/index.d.ts +0 -8
- package/templates/static/node_modules/preact/devtools/src/index.js +0 -15
- package/templates/static/node_modules/preact/dist/preact.js +0 -2
- package/templates/static/node_modules/preact/dist/preact.js.map +0 -1
- package/templates/static/node_modules/preact/dist/preact.min.js +0 -2
- package/templates/static/node_modules/preact/dist/preact.min.js.map +0 -1
- package/templates/static/node_modules/preact/dist/preact.min.module.js +0 -2
- package/templates/static/node_modules/preact/dist/preact.min.module.js.map +0 -1
- package/templates/static/node_modules/preact/dist/preact.min.umd.js +0 -2
- package/templates/static/node_modules/preact/dist/preact.min.umd.js.map +0 -1
- package/templates/static/node_modules/preact/dist/preact.mjs +0 -2
- package/templates/static/node_modules/preact/dist/preact.module.js +0 -2
- package/templates/static/node_modules/preact/dist/preact.module.js.map +0 -1
- package/templates/static/node_modules/preact/dist/preact.umd.js +0 -2
- package/templates/static/node_modules/preact/dist/preact.umd.js.map +0 -1
- package/templates/static/node_modules/preact/hooks/dist/hooks.js +0 -2
- package/templates/static/node_modules/preact/hooks/dist/hooks.js.map +0 -1
- package/templates/static/node_modules/preact/hooks/dist/hooks.mjs +0 -2
- package/templates/static/node_modules/preact/hooks/dist/hooks.module.js +0 -2
- package/templates/static/node_modules/preact/hooks/dist/hooks.module.js.map +0 -1
- package/templates/static/node_modules/preact/hooks/dist/hooks.umd.js +0 -2
- package/templates/static/node_modules/preact/hooks/dist/hooks.umd.js.map +0 -1
- package/templates/static/node_modules/preact/hooks/package.json +0 -35
- package/templates/static/node_modules/preact/hooks/src/index.d.ts +0 -145
- package/templates/static/node_modules/preact/hooks/src/index.js +0 -555
- package/templates/static/node_modules/preact/hooks/src/internal.d.ts +0 -103
- package/templates/static/node_modules/preact/jsx-runtime/dist/jsxRuntime.js +0 -2
- package/templates/static/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +0 -1
- package/templates/static/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs +0 -2
- package/templates/static/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js +0 -2
- package/templates/static/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +0 -1
- package/templates/static/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js +0 -2
- package/templates/static/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +0 -1
- package/templates/static/node_modules/preact/jsx-runtime/package.json +0 -28
- package/templates/static/node_modules/preact/jsx-runtime/src/index.d.ts +0 -62
- package/templates/static/node_modules/preact/jsx-runtime/src/index.js +0 -206
- package/templates/static/node_modules/preact/jsx-runtime/src/utils.js +0 -36
- package/templates/static/node_modules/preact/package.json +0 -258
- package/templates/static/node_modules/preact/src/cjs.js +0 -3
- package/templates/static/node_modules/preact/src/clone-element.js +0 -48
- package/templates/static/node_modules/preact/src/component.js +0 -249
- package/templates/static/node_modules/preact/src/constants.js +0 -22
- package/templates/static/node_modules/preact/src/create-context.js +0 -60
- package/templates/static/node_modules/preact/src/create-element.js +0 -97
- package/templates/static/node_modules/preact/src/diff/catch-error.js +0 -46
- package/templates/static/node_modules/preact/src/diff/children.js +0 -451
- package/templates/static/node_modules/preact/src/diff/index.js +0 -684
- package/templates/static/node_modules/preact/src/diff/props.js +0 -173
- package/templates/static/node_modules/preact/src/dom.d.ts +0 -2476
- package/templates/static/node_modules/preact/src/index-5.d.ts +0 -399
- package/templates/static/node_modules/preact/src/index.d.ts +0 -402
- package/templates/static/node_modules/preact/src/index.js +0 -13
- package/templates/static/node_modules/preact/src/internal.d.ts +0 -190
- package/templates/static/node_modules/preact/src/jsx.d.ts +0 -2878
- package/templates/static/node_modules/preact/src/options.js +0 -16
- package/templates/static/node_modules/preact/src/render.js +0 -78
- package/templates/static/node_modules/preact/src/util.js +0 -28
- package/templates/static/node_modules/preact/test-utils/dist/testUtils.js +0 -2
- package/templates/static/node_modules/preact/test-utils/dist/testUtils.js.map +0 -1
- package/templates/static/node_modules/preact/test-utils/dist/testUtils.mjs +0 -2
- package/templates/static/node_modules/preact/test-utils/dist/testUtils.module.js +0 -2
- package/templates/static/node_modules/preact/test-utils/dist/testUtils.module.js.map +0 -1
- package/templates/static/node_modules/preact/test-utils/dist/testUtils.umd.js +0 -2
- package/templates/static/node_modules/preact/test-utils/dist/testUtils.umd.js.map +0 -1
- package/templates/static/node_modules/preact/test-utils/package.json +0 -28
- package/templates/static/node_modules/preact/test-utils/src/index.d.ts +0 -3
- package/templates/static/node_modules/preact/test-utils/src/index.js +0 -129
- package/templates/static/node_modules/preact-render-to-string/LICENSE +0 -21
- package/templates/static/node_modules/preact-render-to-string/README.md +0 -149
- package/templates/static/node_modules/preact-render-to-string/dist/commonjs.js +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/index.d.ts +0 -17
- package/templates/static/node_modules/preact-render-to-string/dist/index.js +0 -6
- package/templates/static/node_modules/preact-render-to-string/dist/index.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/index.mjs +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/index.module.js +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/index.module.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/index.umd.js +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/index.umd.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/internal.d.ts +0 -35
- package/templates/static/node_modules/preact-render-to-string/dist/jsx/commonjs.js +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/jsx/index.js +0 -4
- package/templates/static/node_modules/preact-render-to-string/dist/jsx/index.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/jsx/index.mjs +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/jsx/index.module.js +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/jsx/index.module.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/jsx/index.umd.js +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/jsx/index.umd.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/jsx.d.ts +0 -24
- package/templates/static/node_modules/preact-render-to-string/dist/stream/index.js +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/stream/index.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/stream/index.mjs +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/stream/index.module.js +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/stream/index.module.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/stream/index.umd.js +0 -2
- package/templates/static/node_modules/preact-render-to-string/dist/stream/index.umd.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/stream/node/index.js +0 -884
- package/templates/static/node_modules/preact-render-to-string/dist/stream/node/index.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/stream/node/index.mjs +0 -884
- package/templates/static/node_modules/preact-render-to-string/dist/stream/node/index.module.js +0 -884
- package/templates/static/node_modules/preact-render-to-string/dist/stream/node/index.module.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/stream/node/index.umd.js +0 -888
- package/templates/static/node_modules/preact-render-to-string/dist/stream/node/index.umd.js.map +0 -1
- package/templates/static/node_modules/preact-render-to-string/dist/stream-node.d.ts +0 -19
- package/templates/static/node_modules/preact-render-to-string/dist/stream.d.ts +0 -10
- package/templates/static/node_modules/preact-render-to-string/jsx.d.ts +0 -24
- package/templates/static/node_modules/preact-render-to-string/jsx.js +0 -1
- package/templates/static/node_modules/preact-render-to-string/package.json +0 -152
- package/templates/static/node_modules/preact-render-to-string/src/index.d.ts +0 -17
- package/templates/static/node_modules/preact-render-to-string/src/index.js +0 -764
- package/templates/static/node_modules/preact-render-to-string/src/internal.d.ts +0 -35
- package/templates/static/node_modules/preact-render-to-string/src/jsx.d.ts +0 -24
- package/templates/static/node_modules/preact-render-to-string/src/jsx.js +0 -102
- package/templates/static/node_modules/preact-render-to-string/src/lib/chunked.js +0 -97
- package/templates/static/node_modules/preact-render-to-string/src/lib/client.js +0 -62
- package/templates/static/node_modules/preact-render-to-string/src/lib/constants.js +0 -20
- package/templates/static/node_modules/preact-render-to-string/src/lib/polyfills.js +0 -8
- package/templates/static/node_modules/preact-render-to-string/src/lib/util.js +0 -208
- package/templates/static/node_modules/preact-render-to-string/src/pretty.js +0 -491
- package/templates/static/node_modules/preact-render-to-string/src/stream-node.d.ts +0 -19
- package/templates/static/node_modules/preact-render-to-string/src/stream-node.js +0 -84
- package/templates/static/node_modules/preact-render-to-string/src/stream.d.ts +0 -10
- package/templates/static/node_modules/preact-render-to-string/src/stream.js +0 -43
- package/templates/static/node_modules/preact-render-to-string/typings.json +0 -5
- package/templates/static/node_modules/sirv/build.js +0 -197
- package/templates/static/node_modules/sirv/build.mjs +0 -197
- package/templates/static/node_modules/sirv/index.d.mts +0 -29
- package/templates/static/node_modules/sirv/index.d.ts +0 -33
- package/templates/static/node_modules/sirv/package.json +0 -40
- package/templates/static/node_modules/sirv/readme.md +0 -238
- package/templates/static/node_modules/totalist/dist/index.js +0 -24
- package/templates/static/node_modules/totalist/dist/index.mjs +0 -22
- package/templates/static/node_modules/totalist/index.d.ts +0 -3
- package/templates/static/node_modules/totalist/license +0 -21
- package/templates/static/node_modules/totalist/package.json +0 -55
- package/templates/static/node_modules/totalist/readme.md +0 -109
- package/templates/static/node_modules/totalist/sync/index.d.ts +0 -3
- package/templates/static/node_modules/totalist/sync/index.js +0 -17
- package/templates/static/node_modules/totalist/sync/index.mjs +0 -15
- package/templates/static/node_modules/typescript/bin/tsc +0 -2
- package/templates/static/node_modules/typescript/bin/tsserver +0 -2
- package/templates/static/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/lib.d.ts +0 -22
- package/templates/static/node_modules/typescript/lib/lib.decorators.d.ts +0 -384
- package/templates/static/node_modules/typescript/lib/lib.decorators.legacy.d.ts +0 -22
- package/templates/static/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +0 -41
- package/templates/static/node_modules/typescript/lib/lib.dom.d.ts +0 -39429
- package/templates/static/node_modules/typescript/lib/lib.dom.iterable.d.ts +0 -571
- package/templates/static/node_modules/typescript/lib/lib.es2015.collection.d.ts +0 -147
- package/templates/static/node_modules/typescript/lib/lib.es2015.core.d.ts +0 -597
- package/templates/static/node_modules/typescript/lib/lib.es2015.d.ts +0 -28
- package/templates/static/node_modules/typescript/lib/lib.es2015.generator.d.ts +0 -77
- package/templates/static/node_modules/typescript/lib/lib.es2015.iterable.d.ts +0 -605
- package/templates/static/node_modules/typescript/lib/lib.es2015.promise.d.ts +0 -81
- package/templates/static/node_modules/typescript/lib/lib.es2015.proxy.d.ts +0 -128
- package/templates/static/node_modules/typescript/lib/lib.es2015.reflect.d.ts +0 -144
- package/templates/static/node_modules/typescript/lib/lib.es2015.symbol.d.ts +0 -46
- package/templates/static/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -326
- package/templates/static/node_modules/typescript/lib/lib.es2016.array.include.d.ts +0 -116
- package/templates/static/node_modules/typescript/lib/lib.es2016.d.ts +0 -21
- package/templates/static/node_modules/typescript/lib/lib.es2016.full.d.ts +0 -23
- package/templates/static/node_modules/typescript/lib/lib.es2016.intl.d.ts +0 -31
- package/templates/static/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +0 -21
- package/templates/static/node_modules/typescript/lib/lib.es2017.d.ts +0 -26
- package/templates/static/node_modules/typescript/lib/lib.es2017.date.d.ts +0 -31
- package/templates/static/node_modules/typescript/lib/lib.es2017.full.d.ts +0 -23
- package/templates/static/node_modules/typescript/lib/lib.es2017.intl.d.ts +0 -44
- package/templates/static/node_modules/typescript/lib/lib.es2017.object.d.ts +0 -49
- package/templates/static/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +0 -135
- package/templates/static/node_modules/typescript/lib/lib.es2017.string.d.ts +0 -45
- package/templates/static/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +0 -53
- package/templates/static/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -77
- package/templates/static/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +0 -53
- package/templates/static/node_modules/typescript/lib/lib.es2018.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2018.full.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2018.intl.d.ts +0 -83
- package/templates/static/node_modules/typescript/lib/lib.es2018.promise.d.ts +0 -30
- package/templates/static/node_modules/typescript/lib/lib.es2018.regexp.d.ts +0 -37
- package/templates/static/node_modules/typescript/lib/lib.es2019.array.d.ts +0 -79
- package/templates/static/node_modules/typescript/lib/lib.es2019.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2019.full.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2019.intl.d.ts +0 -23
- package/templates/static/node_modules/typescript/lib/lib.es2019.object.d.ts +0 -33
- package/templates/static/node_modules/typescript/lib/lib.es2019.string.d.ts +0 -37
- package/templates/static/node_modules/typescript/lib/lib.es2019.symbol.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2020.bigint.d.ts +0 -765
- package/templates/static/node_modules/typescript/lib/lib.es2020.d.ts +0 -27
- package/templates/static/node_modules/typescript/lib/lib.es2020.date.d.ts +0 -42
- package/templates/static/node_modules/typescript/lib/lib.es2020.full.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2020.intl.d.ts +0 -474
- package/templates/static/node_modules/typescript/lib/lib.es2020.number.d.ts +0 -28
- package/templates/static/node_modules/typescript/lib/lib.es2020.promise.d.ts +0 -47
- package/templates/static/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +0 -99
- package/templates/static/node_modules/typescript/lib/lib.es2020.string.d.ts +0 -44
- package/templates/static/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -41
- package/templates/static/node_modules/typescript/lib/lib.es2021.d.ts +0 -23
- package/templates/static/node_modules/typescript/lib/lib.es2021.full.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2021.intl.d.ts +0 -166
- package/templates/static/node_modules/typescript/lib/lib.es2021.promise.d.ts +0 -48
- package/templates/static/node_modules/typescript/lib/lib.es2021.string.d.ts +0 -33
- package/templates/static/node_modules/typescript/lib/lib.es2021.weakref.d.ts +0 -78
- package/templates/static/node_modules/typescript/lib/lib.es2022.array.d.ts +0 -121
- package/templates/static/node_modules/typescript/lib/lib.es2022.d.ts +0 -25
- package/templates/static/node_modules/typescript/lib/lib.es2022.error.d.ts +0 -75
- package/templates/static/node_modules/typescript/lib/lib.es2022.full.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2022.intl.d.ts +0 -145
- package/templates/static/node_modules/typescript/lib/lib.es2022.object.d.ts +0 -26
- package/templates/static/node_modules/typescript/lib/lib.es2022.regexp.d.ts +0 -39
- package/templates/static/node_modules/typescript/lib/lib.es2022.string.d.ts +0 -25
- package/templates/static/node_modules/typescript/lib/lib.es2023.array.d.ts +0 -924
- package/templates/static/node_modules/typescript/lib/lib.es2023.collection.d.ts +0 -21
- package/templates/static/node_modules/typescript/lib/lib.es2023.d.ts +0 -22
- package/templates/static/node_modules/typescript/lib/lib.es2023.full.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2023.intl.d.ts +0 -56
- package/templates/static/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +0 -65
- package/templates/static/node_modules/typescript/lib/lib.es2024.collection.d.ts +0 -29
- package/templates/static/node_modules/typescript/lib/lib.es2024.d.ts +0 -26
- package/templates/static/node_modules/typescript/lib/lib.es2024.full.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.es2024.object.d.ts +0 -29
- package/templates/static/node_modules/typescript/lib/lib.es2024.promise.d.ts +0 -35
- package/templates/static/node_modules/typescript/lib/lib.es2024.regexp.d.ts +0 -25
- package/templates/static/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +0 -68
- package/templates/static/node_modules/typescript/lib/lib.es2024.string.d.ts +0 -29
- package/templates/static/node_modules/typescript/lib/lib.es5.d.ts +0 -4601
- package/templates/static/node_modules/typescript/lib/lib.es6.d.ts +0 -23
- package/templates/static/node_modules/typescript/lib/lib.esnext.array.d.ts +0 -35
- package/templates/static/node_modules/typescript/lib/lib.esnext.collection.d.ts +0 -96
- package/templates/static/node_modules/typescript/lib/lib.esnext.d.ts +0 -29
- package/templates/static/node_modules/typescript/lib/lib.esnext.decorators.d.ts +0 -28
- package/templates/static/node_modules/typescript/lib/lib.esnext.disposable.d.ts +0 -193
- package/templates/static/node_modules/typescript/lib/lib.esnext.error.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.esnext.float16.d.ts +0 -445
- package/templates/static/node_modules/typescript/lib/lib.esnext.full.d.ts +0 -24
- package/templates/static/node_modules/typescript/lib/lib.esnext.intl.d.ts +0 -21
- package/templates/static/node_modules/typescript/lib/lib.esnext.iterator.d.ts +0 -148
- package/templates/static/node_modules/typescript/lib/lib.esnext.promise.d.ts +0 -34
- package/templates/static/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +0 -25
- package/templates/static/node_modules/typescript/lib/lib.scripthost.d.ts +0 -322
- package/templates/static/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +0 -41
- package/templates/static/node_modules/typescript/lib/lib.webworker.d.ts +0 -13150
- package/templates/static/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +0 -23
- package/templates/static/node_modules/typescript/lib/lib.webworker.iterable.d.ts +0 -340
- package/templates/static/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2122
- package/templates/static/node_modules/typescript/lib/tsc.js +0 -8
- package/templates/static/node_modules/typescript/lib/tsserver.js +0 -8
- package/templates/static/node_modules/typescript/lib/tsserverlibrary.d.ts +0 -17
- package/templates/static/node_modules/typescript/lib/tsserverlibrary.js +0 -21
- package/templates/static/node_modules/typescript/lib/typescript.d.ts +0 -11437
|
@@ -1,491 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
encodeEntities,
|
|
3
|
-
indent,
|
|
4
|
-
isLargeString,
|
|
5
|
-
styleObjToCss,
|
|
6
|
-
getChildren,
|
|
7
|
-
createComponent,
|
|
8
|
-
UNSAFE_NAME,
|
|
9
|
-
VOID_ELEMENTS,
|
|
10
|
-
NAMESPACE_REPLACE_REGEX,
|
|
11
|
-
SVG_CAMEL_CASE,
|
|
12
|
-
HTML_ENUMERATED,
|
|
13
|
-
HTML_LOWER_CASE,
|
|
14
|
-
getContext,
|
|
15
|
-
setDirty,
|
|
16
|
-
isDirty,
|
|
17
|
-
unsetDirty
|
|
18
|
-
} from './lib/util.js';
|
|
19
|
-
import {
|
|
20
|
-
COMMIT,
|
|
21
|
-
DIFF,
|
|
22
|
-
DIFFED,
|
|
23
|
-
RENDER,
|
|
24
|
-
SKIP_EFFECTS,
|
|
25
|
-
PARENT,
|
|
26
|
-
CHILDREN
|
|
27
|
-
} from './lib/constants.js';
|
|
28
|
-
import { options, Fragment, h } from 'preact';
|
|
29
|
-
|
|
30
|
-
// components without names, kept as a hash for later comparison to return consistent UnnamedComponentXX names.
|
|
31
|
-
const UNNAMED = [];
|
|
32
|
-
|
|
33
|
-
const EMPTY_ARR = [];
|
|
34
|
-
const EMPTY_STR = '';
|
|
35
|
-
const PRESERVE_WHITESPACE_TAGS = new Set(['pre', 'textarea']);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Render Preact JSX + Components to a pretty-printed HTML-like string.
|
|
39
|
-
* @param {VNode} vnode JSX Element / VNode to render
|
|
40
|
-
* @param {Object} [context={}] Initial root context object
|
|
41
|
-
* @param {Object} [opts={}] Rendering options
|
|
42
|
-
* @param {Boolean} [opts.shallow=false] Serialize nested Components (`<Foo a="b" />`) instead of rendering
|
|
43
|
-
* @param {Boolean} [opts.xml=false] Use self-closing tags for elements without children
|
|
44
|
-
* @param {Boolean} [opts.pretty=false] Add whitespace for readability
|
|
45
|
-
* @param {RegExp|undefined} [opts.voidElements] RegeEx to define which element types are self-closing
|
|
46
|
-
* @param {boolean} [_inner]
|
|
47
|
-
* @returns {String} a pretty-printed HTML-like string
|
|
48
|
-
*/
|
|
49
|
-
export default function renderToStringPretty(vnode, context, opts, _inner) {
|
|
50
|
-
// Performance optimization: `renderToString` is synchronous and we
|
|
51
|
-
// therefore don't execute any effects. To do that we pass an empty
|
|
52
|
-
// array to `options._commit` (`__c`). But we can go one step further
|
|
53
|
-
// and avoid a lot of dirty checks and allocations by setting
|
|
54
|
-
// `options._skipEffects` (`__s`) too.
|
|
55
|
-
const previousSkipEffects = options[SKIP_EFFECTS];
|
|
56
|
-
options[SKIP_EFFECTS] = true;
|
|
57
|
-
|
|
58
|
-
const parent = h(Fragment, null);
|
|
59
|
-
parent[CHILDREN] = [vnode];
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
return _renderToStringPretty(
|
|
63
|
-
vnode,
|
|
64
|
-
context || {},
|
|
65
|
-
opts,
|
|
66
|
-
_inner,
|
|
67
|
-
false,
|
|
68
|
-
undefined,
|
|
69
|
-
parent
|
|
70
|
-
);
|
|
71
|
-
} finally {
|
|
72
|
-
// options._commit, we don't schedule any effects in this library right now,
|
|
73
|
-
// so we can pass an empty queue to this hook.
|
|
74
|
-
if (options[COMMIT]) options[COMMIT](vnode, EMPTY_ARR);
|
|
75
|
-
options[SKIP_EFFECTS] = previousSkipEffects;
|
|
76
|
-
EMPTY_ARR.length = 0;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function _renderToStringPretty(
|
|
81
|
-
vnode,
|
|
82
|
-
context,
|
|
83
|
-
opts,
|
|
84
|
-
inner,
|
|
85
|
-
isSvgMode,
|
|
86
|
-
selectValue,
|
|
87
|
-
parent
|
|
88
|
-
) {
|
|
89
|
-
if (vnode == null || typeof vnode === 'boolean') {
|
|
90
|
-
return '';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// #text nodes
|
|
94
|
-
if (typeof vnode !== 'object') {
|
|
95
|
-
if (typeof vnode === 'function') return '';
|
|
96
|
-
return encodeEntities(vnode + '');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
let pretty = opts.pretty,
|
|
100
|
-
indentChar = pretty && typeof pretty === 'string' ? pretty : '\t';
|
|
101
|
-
|
|
102
|
-
if (Array.isArray(vnode)) {
|
|
103
|
-
let rendered = '';
|
|
104
|
-
parent[CHILDREN] = vnode;
|
|
105
|
-
for (let i = 0; i < vnode.length; i++) {
|
|
106
|
-
if (pretty && i > 0) rendered = rendered + '\n';
|
|
107
|
-
rendered =
|
|
108
|
-
rendered +
|
|
109
|
-
_renderToStringPretty(
|
|
110
|
-
vnode[i],
|
|
111
|
-
context,
|
|
112
|
-
opts,
|
|
113
|
-
inner,
|
|
114
|
-
isSvgMode,
|
|
115
|
-
selectValue,
|
|
116
|
-
parent
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
return rendered;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// VNodes have {constructor:undefined} to prevent JSON injection:
|
|
123
|
-
if (vnode.constructor !== undefined) return '';
|
|
124
|
-
|
|
125
|
-
vnode[PARENT] = parent;
|
|
126
|
-
if (options[DIFF]) options[DIFF](vnode);
|
|
127
|
-
|
|
128
|
-
let nodeName = vnode.type,
|
|
129
|
-
props = vnode.props,
|
|
130
|
-
isComponent = false;
|
|
131
|
-
|
|
132
|
-
// components
|
|
133
|
-
if (typeof nodeName === 'function') {
|
|
134
|
-
isComponent = true;
|
|
135
|
-
if (
|
|
136
|
-
opts.shallow &&
|
|
137
|
-
(inner || opts.renderRootComponent === false) &&
|
|
138
|
-
nodeName !== Fragment
|
|
139
|
-
) {
|
|
140
|
-
nodeName = getComponentName(nodeName);
|
|
141
|
-
} else if (nodeName === Fragment) {
|
|
142
|
-
const children = [];
|
|
143
|
-
getChildren(children, vnode.props.children);
|
|
144
|
-
return _renderToStringPretty(
|
|
145
|
-
children,
|
|
146
|
-
context,
|
|
147
|
-
opts,
|
|
148
|
-
opts.shallowHighOrder !== false,
|
|
149
|
-
isSvgMode,
|
|
150
|
-
selectValue,
|
|
151
|
-
vnode
|
|
152
|
-
);
|
|
153
|
-
} else {
|
|
154
|
-
let rendered;
|
|
155
|
-
|
|
156
|
-
let c = (vnode.__c = createComponent(vnode, context));
|
|
157
|
-
|
|
158
|
-
let renderHook = options[RENDER];
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
!nodeName.prototype ||
|
|
162
|
-
typeof nodeName.prototype.render !== 'function'
|
|
163
|
-
) {
|
|
164
|
-
let cctx = getContext(nodeName, context);
|
|
165
|
-
|
|
166
|
-
// If a hook invokes setState() to invalidate the component during rendering,
|
|
167
|
-
// re-render it up to 25 times to allow "settling" of memoized states.
|
|
168
|
-
// Note:
|
|
169
|
-
// This will need to be updated for Preact 11 to use internal.flags rather than component._dirty:
|
|
170
|
-
// https://github.com/preactjs/preact/blob/d4ca6fdb19bc715e49fd144e69f7296b2f4daa40/src/diff/component.js#L35-L44
|
|
171
|
-
let count = 0;
|
|
172
|
-
while (isDirty(c) && count++ < 25) {
|
|
173
|
-
unsetDirty(c);
|
|
174
|
-
|
|
175
|
-
if (renderHook) renderHook(vnode);
|
|
176
|
-
|
|
177
|
-
// stateless functional components
|
|
178
|
-
rendered = nodeName.call(vnode.__c, props, cctx);
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
let cctx = getContext(nodeName, context);
|
|
182
|
-
|
|
183
|
-
// c = new nodeName(props, context);
|
|
184
|
-
c = vnode.__c = new nodeName(props, cctx);
|
|
185
|
-
c.__v = vnode;
|
|
186
|
-
// turn off stateful re-rendering:
|
|
187
|
-
setDirty(c);
|
|
188
|
-
c.props = props;
|
|
189
|
-
if (c.state == null) c.state = {};
|
|
190
|
-
|
|
191
|
-
if (c._nextState == null && c.__s == null) {
|
|
192
|
-
c._nextState = c.__s = c.state;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
c.context = cctx;
|
|
196
|
-
if (nodeName.getDerivedStateFromProps)
|
|
197
|
-
c.state = Object.assign(
|
|
198
|
-
{},
|
|
199
|
-
c.state,
|
|
200
|
-
nodeName.getDerivedStateFromProps(c.props, c.state)
|
|
201
|
-
);
|
|
202
|
-
else if (c.componentWillMount) {
|
|
203
|
-
c.componentWillMount();
|
|
204
|
-
|
|
205
|
-
// If the user called setState in cWM we need to flush pending,
|
|
206
|
-
// state updates. This is the same behaviour in React.
|
|
207
|
-
c.state =
|
|
208
|
-
c._nextState !== c.state
|
|
209
|
-
? c._nextState
|
|
210
|
-
: c.__s !== c.state
|
|
211
|
-
? c.__s
|
|
212
|
-
: c.state;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (renderHook) renderHook(vnode);
|
|
216
|
-
|
|
217
|
-
rendered = c.render(c.props, c.state, c.context);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (c.getChildContext) {
|
|
221
|
-
context = Object.assign({}, context, c.getChildContext());
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const res = _renderToStringPretty(
|
|
225
|
-
rendered,
|
|
226
|
-
context,
|
|
227
|
-
opts,
|
|
228
|
-
opts.shallowHighOrder !== false,
|
|
229
|
-
isSvgMode,
|
|
230
|
-
selectValue,
|
|
231
|
-
vnode
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
if (options[DIFFED]) options[DIFFED](vnode);
|
|
235
|
-
|
|
236
|
-
return res;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// render JSX to HTML
|
|
241
|
-
let s = '<' + nodeName,
|
|
242
|
-
propChildren,
|
|
243
|
-
html;
|
|
244
|
-
|
|
245
|
-
const shouldPreserveWhitespace =
|
|
246
|
-
pretty &&
|
|
247
|
-
typeof nodeName === 'string' &&
|
|
248
|
-
PRESERVE_WHITESPACE_TAGS.has(nodeName);
|
|
249
|
-
|
|
250
|
-
if (props) {
|
|
251
|
-
let attrs = Object.keys(props);
|
|
252
|
-
|
|
253
|
-
// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)
|
|
254
|
-
if (opts && opts.sortAttributes === true) attrs.sort();
|
|
255
|
-
|
|
256
|
-
for (let i = 0; i < attrs.length; i++) {
|
|
257
|
-
let name = attrs[i],
|
|
258
|
-
v = props[name];
|
|
259
|
-
if (name === 'children') {
|
|
260
|
-
propChildren = v;
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (UNSAFE_NAME.test(name)) continue;
|
|
265
|
-
|
|
266
|
-
if (
|
|
267
|
-
!(opts && opts.allAttributes) &&
|
|
268
|
-
(name === 'key' ||
|
|
269
|
-
name === 'ref' ||
|
|
270
|
-
name === '__self' ||
|
|
271
|
-
name === '__source')
|
|
272
|
-
)
|
|
273
|
-
continue;
|
|
274
|
-
|
|
275
|
-
if (name === 'defaultValue') {
|
|
276
|
-
name = 'value';
|
|
277
|
-
} else if (name === 'defaultChecked') {
|
|
278
|
-
name = 'checked';
|
|
279
|
-
} else if (name === 'defaultSelected') {
|
|
280
|
-
name = 'selected';
|
|
281
|
-
} else if (name === 'className') {
|
|
282
|
-
if (typeof props.class !== 'undefined') continue;
|
|
283
|
-
name = 'class';
|
|
284
|
-
} else if (name === 'acceptCharset') {
|
|
285
|
-
name = 'accept-charset';
|
|
286
|
-
} else if (name === 'httpEquiv') {
|
|
287
|
-
name = 'http-equiv';
|
|
288
|
-
} else if (NAMESPACE_REPLACE_REGEX.test(name)) {
|
|
289
|
-
name = name.replace(NAMESPACE_REPLACE_REGEX, '$1:$2').toLowerCase();
|
|
290
|
-
} else if (
|
|
291
|
-
(name.at(4) === '-' || HTML_ENUMERATED.has(name)) &&
|
|
292
|
-
v != null
|
|
293
|
-
) {
|
|
294
|
-
v = v + EMPTY_STR;
|
|
295
|
-
} else if (isSvgMode) {
|
|
296
|
-
if (SVG_CAMEL_CASE.test(name)) {
|
|
297
|
-
name =
|
|
298
|
-
name === 'panose1'
|
|
299
|
-
? 'panose-1'
|
|
300
|
-
: name.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
301
|
-
}
|
|
302
|
-
} else if (HTML_LOWER_CASE.test(name)) {
|
|
303
|
-
name = name.toLowerCase();
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (name === 'htmlFor') {
|
|
307
|
-
if (props.for) continue;
|
|
308
|
-
name = 'for';
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (name === 'style' && v && typeof v === 'object') {
|
|
312
|
-
v = styleObjToCss(v);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// always use string values instead of booleans for aria attributes
|
|
316
|
-
// also see https://github.com/preactjs/preact/pull/2347/files
|
|
317
|
-
if (name[0] === 'a' && name['1'] === 'r' && typeof v === 'boolean') {
|
|
318
|
-
v = String(v);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
let hooked =
|
|
322
|
-
opts.attributeHook &&
|
|
323
|
-
opts.attributeHook(name, v, context, opts, isComponent);
|
|
324
|
-
if (hooked || hooked === '') {
|
|
325
|
-
s = s + hooked;
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (name === 'dangerouslySetInnerHTML') {
|
|
330
|
-
html = v && v.__html;
|
|
331
|
-
} else if (nodeName === 'textarea' && name === 'value') {
|
|
332
|
-
// <textarea value="a&b"> --> <textarea>a&b</textarea>
|
|
333
|
-
propChildren = v;
|
|
334
|
-
} else if ((v || v === 0 || v === '') && typeof v !== 'function') {
|
|
335
|
-
if (v === true || v === '') {
|
|
336
|
-
v = name;
|
|
337
|
-
// in non-xml mode, allow boolean attributes
|
|
338
|
-
if (!opts || !opts.xml) {
|
|
339
|
-
s = s + ' ' + name;
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (name === 'value') {
|
|
345
|
-
if (nodeName === 'select') {
|
|
346
|
-
selectValue = v;
|
|
347
|
-
continue;
|
|
348
|
-
} else if (
|
|
349
|
-
// If we're looking at an <option> and it's the currently selected one
|
|
350
|
-
nodeName === 'option' &&
|
|
351
|
-
selectValue == v &&
|
|
352
|
-
// and the <option> doesn't already have a selected attribute on it
|
|
353
|
-
typeof props.selected === 'undefined'
|
|
354
|
-
) {
|
|
355
|
-
s = s + ` selected`;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
s = s + ` ${name}="${encodeEntities(v + '')}"`;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// account for >1 multiline attribute
|
|
364
|
-
if (pretty) {
|
|
365
|
-
let sub = s.replace(/\n\s*/, ' ');
|
|
366
|
-
if (sub !== s && !~sub.indexOf('\n')) s = sub;
|
|
367
|
-
else if (pretty && ~s.indexOf('\n')) s = s + '\n';
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
s = s + '>';
|
|
371
|
-
|
|
372
|
-
if (UNSAFE_NAME.test(nodeName))
|
|
373
|
-
throw new Error(`${nodeName} is not a valid HTML tag name in ${s}`);
|
|
374
|
-
|
|
375
|
-
let isVoid =
|
|
376
|
-
VOID_ELEMENTS.test(nodeName) ||
|
|
377
|
-
(opts.voidElements && opts.voidElements.test(nodeName));
|
|
378
|
-
let pieces = [];
|
|
379
|
-
|
|
380
|
-
let children;
|
|
381
|
-
if (html) {
|
|
382
|
-
// if multiline, indent.
|
|
383
|
-
if (pretty && !shouldPreserveWhitespace && isLargeString(html)) {
|
|
384
|
-
html = '\n' + indentChar + indent(html, indentChar);
|
|
385
|
-
}
|
|
386
|
-
s = s + html;
|
|
387
|
-
} else if (
|
|
388
|
-
propChildren != null &&
|
|
389
|
-
getChildren((children = []), propChildren).length
|
|
390
|
-
) {
|
|
391
|
-
const shouldPrettyFormatChildren =
|
|
392
|
-
pretty && !shouldPreserveWhitespace && typeof nodeName === 'string';
|
|
393
|
-
let hasLarge = shouldPrettyFormatChildren && ~s.indexOf('\n');
|
|
394
|
-
let lastWasText = false;
|
|
395
|
-
|
|
396
|
-
for (let i = 0; i < children.length; i++) {
|
|
397
|
-
let child = children[i];
|
|
398
|
-
|
|
399
|
-
if (child != null && child !== false) {
|
|
400
|
-
let childSvgMode =
|
|
401
|
-
nodeName === 'svg'
|
|
402
|
-
? true
|
|
403
|
-
: nodeName === 'foreignObject'
|
|
404
|
-
? false
|
|
405
|
-
: isSvgMode,
|
|
406
|
-
ret = _renderToStringPretty(
|
|
407
|
-
child,
|
|
408
|
-
context,
|
|
409
|
-
opts,
|
|
410
|
-
true,
|
|
411
|
-
childSvgMode,
|
|
412
|
-
selectValue,
|
|
413
|
-
vnode
|
|
414
|
-
);
|
|
415
|
-
|
|
416
|
-
if (shouldPrettyFormatChildren && !hasLarge && isLargeString(ret))
|
|
417
|
-
hasLarge = true;
|
|
418
|
-
|
|
419
|
-
// Skip if we received an empty string
|
|
420
|
-
if (ret) {
|
|
421
|
-
if (shouldPrettyFormatChildren) {
|
|
422
|
-
let isText = ret.length > 0 && ret[0] != '<';
|
|
423
|
-
|
|
424
|
-
// We merge adjacent text nodes, otherwise each piece would be printed
|
|
425
|
-
// on a new line.
|
|
426
|
-
if (lastWasText && isText) {
|
|
427
|
-
pieces[pieces.length - 1] += ret;
|
|
428
|
-
} else {
|
|
429
|
-
pieces.push(ret);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
lastWasText = isText;
|
|
433
|
-
} else {
|
|
434
|
-
pieces.push(ret);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
if (shouldPrettyFormatChildren && hasLarge) {
|
|
440
|
-
for (let i = pieces.length; i--; ) {
|
|
441
|
-
pieces[i] = '\n' + indentChar + indent(pieces[i], indentChar);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
if (options[DIFFED]) options[DIFFED](vnode);
|
|
447
|
-
|
|
448
|
-
if (pieces.length || html) {
|
|
449
|
-
s = s + pieces.join('');
|
|
450
|
-
} else if (opts && opts.xml) {
|
|
451
|
-
return s.substring(0, s.length - 1) + ' />';
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
if (isVoid && !children && !html) {
|
|
455
|
-
s = s.replace(/>$/, ' />');
|
|
456
|
-
} else {
|
|
457
|
-
if (pretty && !shouldPreserveWhitespace && ~s.indexOf('\n')) s = s + '\n';
|
|
458
|
-
s = s + `</${nodeName}>`;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
return s;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
function getComponentName(component) {
|
|
465
|
-
return (
|
|
466
|
-
component.displayName ||
|
|
467
|
-
(component !== Function && component.name) ||
|
|
468
|
-
getFallbackComponentName(component)
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
function getFallbackComponentName(component) {
|
|
473
|
-
let str = Function.prototype.toString.call(component),
|
|
474
|
-
name = (str.match(/^\s*function\s+([^( ]+)/) || '')[1];
|
|
475
|
-
if (!name) {
|
|
476
|
-
// search for an existing indexed name for the given component:
|
|
477
|
-
let index = -1;
|
|
478
|
-
for (let i = UNNAMED.length; i--; ) {
|
|
479
|
-
if (UNNAMED[i] === component) {
|
|
480
|
-
index = i;
|
|
481
|
-
break;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
// not found, create a new indexed name:
|
|
485
|
-
if (index < 0) {
|
|
486
|
-
index = UNNAMED.push(component) - 1;
|
|
487
|
-
}
|
|
488
|
-
name = `UnnamedComponent${index}`;
|
|
489
|
-
}
|
|
490
|
-
return name;
|
|
491
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { VNode } from 'preact';
|
|
2
|
-
import { WritableStream } from 'node:stream';
|
|
3
|
-
|
|
4
|
-
interface RenderToPipeableStreamOptions {
|
|
5
|
-
onShellReady?: () => void;
|
|
6
|
-
onAllReady?: () => void;
|
|
7
|
-
onError?: (error: any) => void;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface PipeableStream {
|
|
11
|
-
abort: (reason?: unknown) => void;
|
|
12
|
-
pipe: (writable: WritableStream) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function renderToPipeableStream<P = {}>(
|
|
16
|
-
vnode: VNode<P>,
|
|
17
|
-
options: RenderToPipeableStreamOptions,
|
|
18
|
-
context?: any
|
|
19
|
-
): PipeableStream;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { PassThrough } from 'node:stream';
|
|
2
|
-
import { renderToChunks } from './lib/chunked.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {object} RenderToPipeableStreamOptions
|
|
6
|
-
* @property {() => void} [onShellReady]
|
|
7
|
-
* @property {() => void} [onAllReady]
|
|
8
|
-
* @property {(error) => void} [onError]
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {object} PipeableStream
|
|
13
|
-
* @property {() => void} abort
|
|
14
|
-
* @property {(writable: import('stream').Writable) => void} pipe
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {import('preact').VNode} vnode
|
|
19
|
-
* @param {RenderToPipeableStreamOptions} options
|
|
20
|
-
* @param {any} [context]
|
|
21
|
-
* @returns {PipeableStream}
|
|
22
|
-
*/
|
|
23
|
-
export function renderToPipeableStream(vnode, options, context) {
|
|
24
|
-
const encoder = new TextEncoder('utf-8');
|
|
25
|
-
|
|
26
|
-
const controller = new AbortController();
|
|
27
|
-
const stream = new PassThrough();
|
|
28
|
-
|
|
29
|
-
renderToChunks(vnode, {
|
|
30
|
-
context,
|
|
31
|
-
abortSignal: controller.signal,
|
|
32
|
-
onError: (error) => {
|
|
33
|
-
if (options.onError) {
|
|
34
|
-
options.onError(error);
|
|
35
|
-
}
|
|
36
|
-
controller.abort(error);
|
|
37
|
-
},
|
|
38
|
-
onWrite(s) {
|
|
39
|
-
stream.write(encoder.encode(s));
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
.then(() => {
|
|
43
|
-
options.onAllReady && options.onAllReady();
|
|
44
|
-
stream.end();
|
|
45
|
-
})
|
|
46
|
-
.catch((error) => {
|
|
47
|
-
stream.destroy();
|
|
48
|
-
if (options.onError) {
|
|
49
|
-
options.onError(error);
|
|
50
|
-
} else {
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
Promise.resolve().then(() => {
|
|
56
|
-
options.onShellReady && options.onShellReady();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
/**
|
|
61
|
-
* @param {unknown} [reason]
|
|
62
|
-
*/
|
|
63
|
-
abort(
|
|
64
|
-
reason = new Error(
|
|
65
|
-
'The render was aborted by the server without a reason.'
|
|
66
|
-
)
|
|
67
|
-
) {
|
|
68
|
-
// Remix/React-Router will always call abort after a timeout, even on success
|
|
69
|
-
if (stream.closed) return;
|
|
70
|
-
|
|
71
|
-
controller.abort();
|
|
72
|
-
stream.destroy();
|
|
73
|
-
if (options.onError) {
|
|
74
|
-
options.onError(reason);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
/**
|
|
78
|
-
* @param {import("stream").Writable} writable
|
|
79
|
-
*/
|
|
80
|
-
pipe(writable) {
|
|
81
|
-
stream.pipe(writable, { end: true });
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Deferred } from './lib/util.js';
|
|
2
|
-
import { renderToChunks } from './lib/chunked.js';
|
|
3
|
-
|
|
4
|
-
/** @typedef {ReadableStream<Uint8Array> & { allReady: Promise<void>}} RenderStream */
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {import('preact').VNode} vnode
|
|
8
|
-
* @param {any} [context]
|
|
9
|
-
* @returns {RenderStream}
|
|
10
|
-
*/
|
|
11
|
-
export function renderToReadableStream(vnode, context) {
|
|
12
|
-
/** @type {Deferred<void>} */
|
|
13
|
-
const allReady = new Deferred();
|
|
14
|
-
const encoder = new TextEncoder('utf-8');
|
|
15
|
-
|
|
16
|
-
/** @type {RenderStream} */
|
|
17
|
-
const stream = new ReadableStream({
|
|
18
|
-
start(controller) {
|
|
19
|
-
renderToChunks(vnode, {
|
|
20
|
-
context,
|
|
21
|
-
onError: (error) => {
|
|
22
|
-
allReady.reject(error);
|
|
23
|
-
controller.abort(error);
|
|
24
|
-
},
|
|
25
|
-
onWrite(s) {
|
|
26
|
-
controller.enqueue(encoder.encode(s));
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
.then(() => {
|
|
30
|
-
controller.close();
|
|
31
|
-
allReady.resolve();
|
|
32
|
-
})
|
|
33
|
-
.catch((error) => {
|
|
34
|
-
controller.error(error);
|
|
35
|
-
allReady.reject(error);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
stream.allReady = allReady.promise;
|
|
41
|
-
|
|
42
|
-
return stream;
|
|
43
|
-
}
|