@nativescript/vite 8.0.0-alpha.9 → 8.0.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -14
- package/bin/cli.cjs +8 -14
- package/configuration/angular.d.ts +34 -1
- package/configuration/angular.js +196 -217
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +152 -104
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +14 -93
- package/configuration/javascript.js.map +1 -1
- package/configuration/react.js +41 -73
- package/configuration/react.js.map +1 -1
- package/configuration/solid.js +51 -6
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +11 -92
- package/configuration/typescript.js.map +1 -1
- package/framework.d.ts +22 -0
- package/framework.js +18 -0
- package/framework.js.map +1 -0
- package/helpers/app-components.d.ts +2 -1
- package/helpers/app-components.js.map +1 -1
- package/helpers/app-css-refresh.d.ts +31 -0
- package/helpers/app-css-refresh.js +43 -0
- package/helpers/app-css-refresh.js.map +1 -0
- package/helpers/app-css-state.d.ts +17 -0
- package/helpers/app-css-state.js +51 -0
- package/helpers/app-css-state.js.map +1 -0
- package/helpers/bundler-context.d.ts +11 -0
- package/helpers/bundler-context.js +71 -0
- package/helpers/bundler-context.js.map +1 -0
- package/helpers/cli-flags.d.ts +12 -0
- package/helpers/cli-flags.js +34 -0
- package/helpers/cli-flags.js.map +1 -1
- package/helpers/css-platform-plugin.d.ts +14 -0
- package/helpers/css-platform-plugin.js +43 -25
- package/helpers/css-platform-plugin.js.map +1 -1
- package/helpers/dev-host.d.ts +360 -0
- package/helpers/dev-host.js +694 -0
- package/helpers/dev-host.js.map +1 -0
- package/helpers/dynamic-import-plugin.d.ts +2 -1
- package/helpers/dynamic-import-plugin.js +59 -53
- package/helpers/dynamic-import-plugin.js.map +1 -1
- package/helpers/esbuild-platform-resolver.js +4 -1
- package/helpers/esbuild-platform-resolver.js.map +1 -1
- package/helpers/external-configs.d.ts +10 -12
- package/helpers/external-configs.js +58 -35
- package/helpers/external-configs.js.map +1 -1
- package/helpers/flavor.d.ts +31 -0
- package/helpers/flavor.js +53 -2
- package/helpers/flavor.js.map +1 -1
- package/helpers/global-defines.d.ts +100 -33
- package/helpers/global-defines.js +192 -66
- package/helpers/global-defines.js.map +1 -1
- package/helpers/hmr-scope.d.ts +26 -0
- package/helpers/hmr-scope.js +67 -0
- package/helpers/hmr-scope.js.map +1 -0
- package/helpers/init.js +24 -26
- package/helpers/init.js.map +1 -1
- package/helpers/logging.d.ts +11 -1
- package/helpers/logging.js +45 -2
- package/helpers/logging.js.map +1 -1
- package/helpers/main-entry.d.ts +4 -1
- package/helpers/main-entry.js +293 -40
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
- package/helpers/nativeclass-esbuild-plugin.js +6 -1
- package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
- package/helpers/nativeclass-transform.d.ts +13 -0
- package/helpers/nativeclass-transform.js +37 -7
- package/helpers/nativeclass-transform.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.js +8 -3
- package/helpers/nativeclass-transformer-plugin.js.map +1 -1
- package/helpers/nativescript-package-resolver.js +10 -62
- package/helpers/nativescript-package-resolver.js.map +1 -1
- package/helpers/normalize-id.d.ts +42 -0
- package/helpers/normalize-id.js +60 -0
- package/helpers/normalize-id.js.map +1 -0
- package/helpers/ns-core-external-urls.d.ts +32 -0
- package/helpers/ns-core-external-urls.js +107 -0
- package/helpers/ns-core-external-urls.js.map +1 -0
- package/helpers/ns-core-url.d.ts +26 -3
- package/helpers/ns-core-url.js +66 -8
- package/helpers/ns-core-url.js.map +1 -1
- package/helpers/optimize-deps.d.ts +16 -0
- package/helpers/optimize-deps.js +17 -0
- package/helpers/optimize-deps.js.map +1 -0
- package/helpers/package-platform-aliases.js +34 -49
- package/helpers/package-platform-aliases.js.map +1 -1
- package/helpers/platform-types.d.ts +2 -0
- package/helpers/platform-types.js +2 -0
- package/helpers/platform-types.js.map +1 -0
- package/helpers/postcss-platform-config.d.ts +17 -1
- package/helpers/postcss-platform-config.js +20 -37
- package/helpers/postcss-platform-config.js.map +1 -1
- package/helpers/resolve-main-field-platform.d.ts +20 -0
- package/helpers/resolve-main-field-platform.js +49 -0
- package/helpers/resolve-main-field-platform.js.map +1 -0
- package/helpers/resolver.js +17 -2
- package/helpers/resolver.js.map +1 -1
- package/helpers/theme-core-plugins.js +1 -1
- package/helpers/theme-core-plugins.js.map +1 -1
- package/helpers/ts-config-paths.d.ts +32 -0
- package/helpers/ts-config-paths.js +143 -62
- package/helpers/ts-config-paths.js.map +1 -1
- package/helpers/typescript-check.d.ts +3 -3
- package/helpers/typescript-check.js +4 -4
- package/helpers/typescript-check.js.map +1 -1
- package/helpers/ui-registration.d.ts +21 -0
- package/helpers/ui-registration.js +156 -0
- package/helpers/ui-registration.js.map +1 -0
- package/helpers/utils.d.ts +9 -0
- package/helpers/utils.js +22 -2
- package/helpers/utils.js.map +1 -1
- package/helpers/vite-package-version.d.ts +7 -0
- package/helpers/vite-package-version.js +44 -0
- package/helpers/vite-package-version.js.map +1 -0
- package/helpers/workers.d.ts +33 -0
- package/helpers/workers.js +237 -10
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.d.ts +2 -1
- package/hmr/client/css-handler.js +63 -32
- package/hmr/client/css-handler.js.map +1 -1
- package/hmr/client/css-update-overlay.d.ts +18 -0
- package/hmr/client/css-update-overlay.js +27 -0
- package/hmr/client/css-update-overlay.js.map +1 -0
- package/hmr/client/framework-client-strategy.d.ts +117 -0
- package/hmr/client/framework-client-strategy.js +18 -0
- package/hmr/client/framework-client-strategy.js.map +1 -0
- package/hmr/client/framework.d.ts +31 -0
- package/hmr/client/framework.js +17 -0
- package/hmr/client/framework.js.map +1 -0
- package/hmr/client/hmr-pending-overlay.d.ts +0 -14
- package/hmr/client/hmr-pending-overlay.js +2 -11
- package/hmr/client/hmr-pending-overlay.js.map +1 -1
- package/hmr/client/hot-context.d.ts +89 -0
- package/hmr/client/hot-context.js +404 -0
- package/hmr/client/hot-context.js.map +1 -0
- package/hmr/client/index.d.ts +9 -1
- package/hmr/client/index.js +70 -1970
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/overlay-driver.d.ts +10 -0
- package/hmr/client/overlay-driver.js +33 -0
- package/hmr/client/overlay-driver.js.map +1 -0
- package/hmr/client/protocol-dispatch.d.ts +8 -0
- package/hmr/client/protocol-dispatch.js +308 -0
- package/hmr/client/protocol-dispatch.js.map +1 -0
- package/hmr/client/root-reset.d.ts +15 -0
- package/hmr/client/root-reset.js +358 -0
- package/hmr/client/root-reset.js.map +1 -0
- package/hmr/client/strategy-loader.d.ts +24 -0
- package/hmr/client/strategy-loader.js +136 -0
- package/hmr/client/strategy-loader.js.map +1 -0
- package/hmr/client/update-pipeline.d.ts +27 -0
- package/hmr/client/update-pipeline.js +489 -0
- package/hmr/client/update-pipeline.js.map +1 -0
- package/hmr/client/utils.d.ts +9 -1
- package/hmr/client/utils.js +117 -97
- package/hmr/client/utils.js.map +1 -1
- package/hmr/client/ws-transport.d.ts +21 -0
- package/hmr/client/ws-transport.js +323 -0
- package/hmr/client/ws-transport.js.map +1 -0
- package/hmr/entry-runtime.d.ts +2 -1
- package/hmr/entry-runtime.js +279 -44
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/framework-flavors.d.ts +59 -0
- package/hmr/framework-flavors.js +108 -0
- package/hmr/framework-flavors.js.map +1 -0
- package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
- package/hmr/frameworks/angular/build/angular-linker.js +113 -0
- package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/inject-component-hmr-registration.js +2 -70
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
- package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
- package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
- package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
- package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
- package/hmr/frameworks/angular/build/linker-stats.d.ts +18 -0
- package/hmr/frameworks/angular/build/linker-stats.js +29 -0
- package/hmr/frameworks/angular/build/linker-stats.js.map +1 -0
- package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
- package/hmr/frameworks/angular/build/shared-linker.js +128 -0
- package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
- package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
- package/hmr/frameworks/angular/build/ts-fallback-transform.d.ts +5 -0
- package/hmr/frameworks/angular/build/ts-fallback-transform.js +138 -0
- package/hmr/frameworks/angular/build/ts-fallback-transform.js.map +1 -0
- package/hmr/frameworks/angular/build/util.js.map +1 -0
- package/hmr/frameworks/angular/build/worker-url-preserve.d.ts +5 -0
- package/hmr/frameworks/angular/build/worker-url-preserve.js +140 -0
- package/hmr/frameworks/angular/build/worker-url-preserve.js.map +1 -0
- package/hmr/frameworks/angular/client/index.d.ts +0 -1
- package/hmr/frameworks/angular/client/index.js +360 -194
- package/hmr/frameworks/angular/client/index.js.map +1 -1
- package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
- package/hmr/frameworks/angular/client/strategy.js +19 -0
- package/hmr/frameworks/angular/client/strategy.js.map +1 -0
- package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
- package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
- package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
- package/hmr/frameworks/angular/server/ng-component-route.d.ts +43 -0
- package/hmr/frameworks/angular/server/ng-component-route.js +113 -0
- package/hmr/frameworks/angular/server/ng-component-route.js.map +1 -0
- package/hmr/frameworks/angular/server/strategy.js +668 -13
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
- package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
- package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +27 -11
- package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.js +179 -107
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
- package/hmr/frameworks/react/client/strategy.d.ts +12 -0
- package/hmr/frameworks/react/client/strategy.js +27 -0
- package/hmr/frameworks/react/client/strategy.js.map +1 -0
- package/hmr/frameworks/react/server/strategy.d.ts +2 -0
- package/hmr/frameworks/react/server/strategy.js +230 -0
- package/hmr/frameworks/react/server/strategy.js.map +1 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
- package/hmr/frameworks/solid/client/app-runtime.d.ts +68 -0
- package/hmr/frameworks/solid/client/app-runtime.js +252 -0
- package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
- package/hmr/frameworks/solid/client/strategy.d.ts +7 -0
- package/hmr/frameworks/solid/client/strategy.js +391 -0
- package/hmr/frameworks/solid/client/strategy.js.map +1 -0
- package/hmr/frameworks/solid/server/strategy.js +293 -16
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/client/strategy.d.ts +7 -0
- package/hmr/frameworks/typescript/client/strategy.js +418 -0
- package/hmr/frameworks/typescript/client/strategy.js.map +1 -0
- package/hmr/frameworks/typescript/server/strategy.js +40 -14
- package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/dep-propagation.d.ts +44 -0
- package/hmr/frameworks/vue/client/dep-propagation.js +148 -0
- package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
- package/hmr/frameworks/vue/client/index.d.ts +10 -1
- package/hmr/frameworks/vue/client/index.js +270 -521
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/frameworks/vue/client/navigate-app.d.ts +3 -0
- package/hmr/frameworks/vue/client/navigate-app.js +178 -0
- package/hmr/frameworks/vue/client/navigate-app.js.map +1 -0
- package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
- package/hmr/frameworks/vue/client/strategy.js +152 -0
- package/hmr/frameworks/vue/client/strategy.js.map +1 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +124 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
- package/hmr/frameworks/vue/server/compiler.d.ts +3 -1
- package/hmr/frameworks/vue/server/compiler.js +3 -1
- package/hmr/frameworks/vue/server/compiler.js.map +1 -1
- package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js +823 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js +462 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +45 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js +105 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
- package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
- package/hmr/frameworks/vue/server/strategy.js +291 -7
- package/hmr/frameworks/vue/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
- package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
- package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
- package/hmr/helpers/ast-normalizer.d.ts +3 -1
- package/hmr/helpers/ast-normalizer.js +109 -14
- package/hmr/helpers/ast-normalizer.js.map +1 -1
- package/hmr/helpers/package-exports.d.ts +16 -0
- package/hmr/helpers/package-exports.js +396 -0
- package/hmr/helpers/package-exports.js.map +1 -0
- package/hmr/helpers/vendor-rewrite.d.ts +1 -1
- package/hmr/helpers/vendor-rewrite.js +5 -3
- package/hmr/helpers/vendor-rewrite.js.map +1 -1
- package/hmr/server/boot-recording.d.ts +51 -0
- package/hmr/server/boot-recording.js +214 -0
- package/hmr/server/boot-recording.js.map +1 -0
- package/hmr/server/constants.js +7 -1
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/content-css-update.d.ts +54 -0
- package/hmr/server/content-css-update.js +78 -0
- package/hmr/server/content-css-update.js.map +1 -0
- package/hmr/server/core-bundle.d.ts +140 -0
- package/hmr/server/core-bundle.js +614 -0
- package/hmr/server/core-bundle.js.map +1 -0
- package/hmr/server/core-sanitize.d.ts +86 -7
- package/hmr/server/core-sanitize.js +155 -37
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/css-connect-sync.d.ts +28 -0
- package/hmr/server/css-connect-sync.js +59 -0
- package/hmr/server/css-connect-sync.js.map +1 -0
- package/hmr/server/css-device-module.d.ts +28 -0
- package/hmr/server/css-device-module.js +44 -0
- package/hmr/server/css-device-module.js.map +1 -0
- package/hmr/server/css-update-message.d.ts +23 -0
- package/hmr/server/css-update-message.js +41 -0
- package/hmr/server/css-update-message.js.map +1 -0
- package/hmr/server/deps-bundle.d.ts +233 -0
- package/hmr/server/deps-bundle.js +1022 -0
- package/hmr/server/deps-bundle.js.map +1 -0
- package/hmr/server/device-transform-helpers.d.ts +24 -0
- package/hmr/server/device-transform-helpers.js +408 -0
- package/hmr/server/device-transform-helpers.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +182 -11
- package/hmr/server/hmr-module-graph.d.ts +37 -0
- package/hmr/server/hmr-module-graph.js +215 -0
- package/hmr/server/hmr-module-graph.js.map +1 -0
- package/hmr/server/import-map.d.ts +57 -23
- package/hmr/server/import-map.js +142 -70
- package/hmr/server/import-map.js.map +1 -1
- package/hmr/server/index.js +7 -16
- package/hmr/server/index.js.map +1 -1
- package/hmr/server/node-builtins-route.d.ts +12 -0
- package/hmr/server/node-builtins-route.js +86 -0
- package/hmr/server/node-builtins-route.js.map +1 -0
- package/hmr/server/ns-m-response-memo.d.ts +10 -0
- package/hmr/server/ns-m-response-memo.js +33 -0
- package/hmr/server/ns-m-response-memo.js.map +1 -0
- package/hmr/server/ns-rt-bridge.d.ts +51 -0
- package/hmr/server/ns-rt-bridge.js +131 -0
- package/hmr/server/ns-rt-bridge.js.map +1 -0
- package/hmr/server/ns-rt-route.d.ts +5 -0
- package/hmr/server/ns-rt-route.js +39 -0
- package/hmr/server/ns-rt-route.js.map +1 -0
- package/hmr/server/perf-instrumentation.d.ts +1 -1
- package/hmr/server/perf-instrumentation.js +3 -1
- package/hmr/server/perf-instrumentation.js.map +1 -1
- package/hmr/server/process-code-for-device.d.ts +54 -0
- package/hmr/server/process-code-for-device.js +832 -0
- package/hmr/server/process-code-for-device.js.map +1 -0
- package/hmr/server/require-guard.d.ts +1 -0
- package/hmr/server/require-guard.js +12 -0
- package/hmr/server/require-guard.js.map +1 -0
- package/hmr/server/rewrite-imports.d.ts +2 -0
- package/hmr/server/rewrite-imports.js +631 -0
- package/hmr/server/rewrite-imports.js.map +1 -0
- package/hmr/server/route-helpers.d.ts +7 -0
- package/hmr/server/route-helpers.js +13 -0
- package/hmr/server/route-helpers.js.map +1 -0
- package/hmr/server/runtime-graph-filter.js +8 -1
- package/hmr/server/runtime-graph-filter.js.map +1 -1
- package/hmr/server/server-origin.d.ts +2 -0
- package/hmr/server/server-origin.js +88 -0
- package/hmr/server/server-origin.js.map +1 -0
- package/hmr/server/shared-transform-request.js +1 -2
- package/hmr/server/shared-transform-request.js.map +1 -1
- package/hmr/server/socket-utils.d.ts +10 -0
- package/hmr/server/socket-utils.js +14 -0
- package/hmr/server/socket-utils.js.map +1 -0
- package/hmr/server/transform-cache-invalidation.d.ts +37 -0
- package/hmr/server/transform-cache-invalidation.js +156 -0
- package/hmr/server/transform-cache-invalidation.js.map +1 -0
- package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
- package/hmr/server/vendor-bare-module-shims.js +80 -0
- package/hmr/server/vendor-bare-module-shims.js.map +1 -0
- package/hmr/server/vite-plugin.d.ts +1 -0
- package/hmr/server/vite-plugin.js +211 -53
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-core-bridge.d.ts +51 -4
- package/hmr/server/websocket-core-bridge.js +62 -49
- package/hmr/server/websocket-core-bridge.js.map +1 -1
- package/hmr/server/websocket-device-transform.d.ts +3 -0
- package/hmr/server/websocket-device-transform.js +7 -0
- package/hmr/server/websocket-device-transform.js.map +1 -0
- package/hmr/server/websocket-hmr-pending.d.ts +2 -16
- package/hmr/server/websocket-hmr-pending.js +0 -22
- package/hmr/server/websocket-hmr-pending.js.map +1 -1
- package/hmr/server/websocket-hot-update.d.ts +80 -0
- package/hmr/server/websocket-hot-update.js +299 -0
- package/hmr/server/websocket-hot-update.js.map +1 -0
- package/hmr/server/websocket-import-map-route.d.ts +15 -0
- package/hmr/server/websocket-import-map-route.js +51 -0
- package/hmr/server/websocket-import-map-route.js.map +1 -0
- package/hmr/server/websocket-module-bindings.d.ts +15 -0
- package/hmr/server/websocket-module-bindings.js +36 -3
- package/hmr/server/websocket-module-bindings.js.map +1 -1
- package/hmr/server/websocket-module-specifiers.d.ts +2 -5
- package/hmr/server/websocket-module-specifiers.js +42 -30
- package/hmr/server/websocket-module-specifiers.js.map +1 -1
- package/hmr/server/websocket-ns-core.d.ts +34 -0
- package/hmr/server/websocket-ns-core.js +414 -0
- package/hmr/server/websocket-ns-core.js.map +1 -0
- package/hmr/server/websocket-ns-entry.d.ts +21 -0
- package/hmr/server/websocket-ns-entry.js +163 -0
- package/hmr/server/websocket-ns-entry.js.map +1 -0
- package/hmr/server/websocket-ns-m-paths.d.ts +19 -3
- package/hmr/server/websocket-ns-m-paths.js +98 -75
- package/hmr/server/websocket-ns-m-paths.js.map +1 -1
- package/hmr/server/websocket-ns-m-request.d.ts +2 -1
- package/hmr/server/websocket-ns-m-request.js +3 -2
- package/hmr/server/websocket-ns-m-request.js.map +1 -1
- package/hmr/server/websocket-ns-m.d.ts +52 -0
- package/hmr/server/websocket-ns-m.js +592 -0
- package/hmr/server/websocket-ns-m.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +65 -3
- package/hmr/server/websocket-served-module-helpers.js +457 -140
- package/hmr/server/websocket-served-module-helpers.js.map +1 -1
- package/hmr/server/websocket-txn.js +6 -9
- package/hmr/server/websocket-txn.js.map +1 -1
- package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
- package/hmr/server/websocket-vendor-unifier.js +4 -9
- package/hmr/server/websocket-vendor-unifier.js.map +1 -1
- package/hmr/server/websocket.d.ts +6 -40
- package/hmr/server/websocket.js +661 -6751
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +108 -0
- package/hmr/shared/ns-globals.js +29 -0
- package/hmr/shared/ns-globals.js.map +1 -0
- package/hmr/shared/protocol.d.ts +157 -0
- package/hmr/shared/protocol.js +28 -0
- package/hmr/shared/protocol.js.map +1 -0
- package/hmr/shared/runtime/boot-complete.d.ts +14 -0
- package/hmr/shared/runtime/boot-complete.js +32 -0
- package/hmr/shared/runtime/boot-complete.js.map +1 -0
- package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
- package/hmr/shared/runtime/boot-progress.d.ts +44 -0
- package/hmr/shared/runtime/boot-progress.js +134 -0
- package/hmr/shared/runtime/boot-progress.js.map +1 -0
- package/hmr/shared/runtime/boot-timeline.d.ts +1 -1
- package/hmr/shared/runtime/boot-timeline.js +8 -19
- package/hmr/shared/runtime/boot-timeline.js.map +1 -1
- package/hmr/shared/runtime/browser-runtime-contract.d.ts +58 -25
- package/hmr/shared/runtime/browser-runtime-contract.js +21 -9
- package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
- package/hmr/shared/runtime/dev-overlay-ios.d.ts +87 -0
- package/hmr/shared/runtime/dev-overlay-ios.js +521 -0
- package/hmr/shared/runtime/dev-overlay-ios.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-shared.d.ts +58 -0
- package/hmr/shared/runtime/dev-overlay-shared.js +116 -0
- package/hmr/shared/runtime/dev-overlay-shared.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-tree.d.ts +59 -0
- package/hmr/shared/runtime/dev-overlay-tree.js +712 -0
- package/hmr/shared/runtime/dev-overlay-tree.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay.d.ts +23 -69
- package/hmr/shared/runtime/dev-overlay.js +67 -1011
- package/hmr/shared/runtime/dev-overlay.js.map +1 -1
- package/hmr/shared/runtime/global-scope.d.ts +18 -0
- package/hmr/shared/runtime/global-scope.js +21 -0
- package/hmr/shared/runtime/global-scope.js.map +1 -0
- package/hmr/shared/runtime/hooks.js +2 -1
- package/hmr/shared/runtime/hooks.js.map +1 -1
- package/hmr/shared/runtime/launch-bridge.d.ts +9 -0
- package/hmr/shared/runtime/launch-bridge.js +98 -0
- package/hmr/shared/runtime/launch-bridge.js.map +1 -0
- package/hmr/shared/runtime/module-provenance.js +3 -2
- package/hmr/shared/runtime/module-provenance.js.map +1 -1
- package/hmr/shared/runtime/ns-runtime-test-double.d.ts +21 -0
- package/hmr/shared/runtime/ns-runtime-test-double.js +20 -0
- package/hmr/shared/runtime/ns-runtime-test-double.js.map +1 -0
- package/hmr/shared/runtime/overlay-flag.d.ts +9 -0
- package/hmr/shared/runtime/overlay-flag.js +34 -0
- package/hmr/shared/runtime/overlay-flag.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
- package/hmr/shared/runtime/root-placeholder-view.js +311 -0
- package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.js +382 -157
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.js +209 -54
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-bootstrap.js +2 -1
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-resolve.d.ts +22 -0
- package/hmr/shared/runtime/vendor-resolve.js +45 -0
- package/hmr/shared/runtime/vendor-resolve.js.map +1 -0
- package/hmr/shared/runtime/worker-tracking.d.ts +28 -0
- package/hmr/shared/runtime/worker-tracking.js +114 -0
- package/hmr/shared/runtime/worker-tracking.js.map +1 -0
- package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
- package/hmr/shared/vendor/manifest-collect.js +909 -0
- package/hmr/shared/vendor/manifest-collect.js.map +1 -0
- package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
- package/hmr/shared/vendor/manifest-loader.js +5 -3
- package/hmr/shared/vendor/manifest-loader.js.map +1 -1
- package/hmr/shared/vendor/manifest.d.ts +10 -35
- package/hmr/shared/vendor/manifest.js +154 -978
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/hmr/shared/vendor/registry.d.ts +2 -0
- package/hmr/shared/vendor/registry.js +14 -0
- package/hmr/shared/vendor/registry.js.map +1 -1
- package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
- package/hmr/shared/vendor/vendor-device-shim.js +208 -0
- package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +107 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js +540 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
- package/package.json +70 -13
- package/runtime/core-aliases-early.js +11 -16
- package/runtime/core-aliases-early.js.map +1 -1
- package/shims/react-jsx-runtime.d.ts +4 -0
- package/shims/react-jsx-runtime.js +61 -0
- package/shims/react-jsx-runtime.js.map +1 -0
- package/helpers/angular/angular-linker.d.ts +0 -13
- package/helpers/angular/angular-linker.js +0 -185
- package/helpers/angular/angular-linker.js.map +0 -1
- package/helpers/angular/inject-component-hmr-registration.js.map +0 -1
- package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
- package/helpers/angular/shared-linker.d.ts +0 -11
- package/helpers/angular/shared-linker.js +0 -75
- package/helpers/angular/shared-linker.js.map +0 -1
- package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
- package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
- package/helpers/angular/util.js.map +0 -1
- package/helpers/module-runner-patch.d.ts +0 -3
- package/helpers/module-runner-patch.js +0 -63
- package/helpers/module-runner-patch.js.map +0 -1
- package/helpers/prelink-angular.d.ts +0 -2
- package/helpers/prelink-angular.js +0 -114
- package/helpers/prelink-angular.js.map +0 -1
- package/hmr/server/websocket-angular-entry.js.map +0 -1
- package/hmr/server/websocket-angular-hot-update.js.map +0 -1
- package/hmr/server/websocket-ns-m-finalize.d.ts +0 -22
- package/hmr/server/websocket-ns-m-finalize.js +0 -88
- package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
- package/hmr/server/websocket-runtime-compat.d.ts +0 -19
- package/hmr/server/websocket-runtime-compat.js +0 -287
- package/hmr/server/websocket-runtime-compat.js.map +0 -1
- package/hmr/server/websocket-vue-sfc.d.ts +0 -27
- package/hmr/server/websocket-vue-sfc.js +0 -1069
- package/hmr/server/websocket-vue-sfc.js.map +0 -1
- package/hmr/shared/runtime/http-only-boot.d.ts +0 -2
- package/hmr/shared/runtime/http-only-boot.js +0 -171
- package/hmr/shared/runtime/http-only-boot.js.map +0 -1
- package/hmr/vendor-bootstrap.d.ts +0 -3
- package/hmr/vendor-bootstrap.js +0 -32
- package/hmr/vendor-bootstrap.js.map +0 -1
- package/shims/react-reconciler-constants.d.ts +0 -14
- package/shims/react-reconciler-constants.js +0 -21
- package/shims/react-reconciler-constants.js.map +0 -1
- package/shims/react-reconciler.d.ts +0 -8
- package/shims/react-reconciler.js +0 -15
- package/shims/react-reconciler.js.map +0 -1
- package/transformers/NativeClass/index.d.ts +0 -2
- package/transformers/NativeClass/index.js +0 -222
- package/transformers/NativeClass/index.js.map +0 -1
- /package/{helpers/angular → hmr/frameworks/angular/build}/inject-component-hmr-registration.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/util.js +0 -0
- /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { typescriptServerStrategy } from '../../typescript/server/strategy.js';
|
|
5
|
+
import { runHotUpdatePrologue } from '../../../server/websocket-hot-update.js';
|
|
6
|
+
import { purgeTransformCachesForHotUpdate } from '../../../server/transform-cache-invalidation.js';
|
|
7
|
+
// React server strategy for NativeScript HMR.
|
|
8
|
+
//
|
|
9
|
+
// React renders through DOMiNATIVE via `@nativescript-community/react` and runs
|
|
10
|
+
// WITHOUT React Fast Refresh (module-level reload, mirroring the Solid flavor's
|
|
11
|
+
// `hot: false`). It therefore needs no framework-specific HMR transform — it
|
|
12
|
+
// reuses the generic TypeScript strategy's device-module pipeline verbatim
|
|
13
|
+
// (HTTP-loaded modules, vendor bridge, shared graph delta on hot update).
|
|
14
|
+
//
|
|
15
|
+
// The important part is that this is REGISTERED in `STRATEGY_REGISTRY`: the
|
|
16
|
+
// server-side HMR plugin (which installs the `/ns/*` device routes — `/ns/core`,
|
|
17
|
+
// `/ns/import-map.json`, `/ns/m`, `/ns/entry-rt`, …) is only added for flavors
|
|
18
|
+
// with a registered strategy. Without it, a React project's dev server serves no
|
|
19
|
+
// `/ns/*` routes and the app fails at boot fetching `/ns/core/xhr` (404).
|
|
20
|
+
// ── React-ecosystem CJS named-export interop (the `transformNodeModule` hook) ──
|
|
21
|
+
//
|
|
22
|
+
// React and friends ship the classic prod/dev conditional re-export wrapper:
|
|
23
|
+
//
|
|
24
|
+
// if (process.env.NODE_ENV === 'production') module.exports = require('./cjs/x.production.js');
|
|
25
|
+
// else module.exports = require('./cjs/x.development.js');
|
|
26
|
+
//
|
|
27
|
+
// Served raw over `/ns/m`, that wrapper exposes ONLY a default export — the device's
|
|
28
|
+
// ESM loader can't see the names (`jsx`, `useSyncExternalStoreWithSelector`, …)
|
|
29
|
+
// because they materialize on `module.exports` only at runtime, through the
|
|
30
|
+
// conditional require. So a consumer's `import { useSyncExternalStoreWithSelector }`
|
|
31
|
+
// (or `{ jsx }` from react/jsx-runtime, etc.) fails with "does not provide an export
|
|
32
|
+
// named …". The non-HMR rolldown build bundles these fine; this only affects the
|
|
33
|
+
// HMR/dev `/ns/m` path.
|
|
34
|
+
//
|
|
35
|
+
// The DEVELOPMENT target file is plain CJS (`exports.x = …`), whose named exports
|
|
36
|
+
// the `/ns/m` pipeline DOES statically surface. So we rewrite the wrapper to
|
|
37
|
+
// re-export EXPLICIT names from its development target. (We can't `export *` — the
|
|
38
|
+
// device transform downgrades export-star to a side-effect import — so we read the
|
|
39
|
+
// dev file and list the names.) Generic: works for any such wrapper, no per-package
|
|
40
|
+
// shim.
|
|
41
|
+
const projectRequire = createRequire(path.join(process.cwd(), 'package.json'));
|
|
42
|
+
// react/jsx-runtime is the hottest of these (every JSX module imports it). Serve a
|
|
43
|
+
// self-contained shim built on React.createElement so it never depends on the
|
|
44
|
+
// internals of react's dev jsx-runtime file. (App-code imports are already routed
|
|
45
|
+
// here by the resolve alias in configuration/react.ts; this covers vendored
|
|
46
|
+
// importers served through `/ns/m`.)
|
|
47
|
+
const REACT_JSX_RUNTIME_RE = /(^|[\\/])react[\\/]jsx-(?:dev-)?runtime(?:[\\/.]|$)/;
|
|
48
|
+
const REACT_JSX_RUNTIME_SHIM = [
|
|
49
|
+
`import { createElement, Fragment as __NS_Fragment } from 'react';`,
|
|
50
|
+
`export const Fragment = __NS_Fragment;`,
|
|
51
|
+
`function __ns_jsx(type, config, maybeKey) {`,
|
|
52
|
+
` if (maybeKey !== undefined) return createElement(type, Object.assign({}, config || {}, { key: maybeKey }));`,
|
|
53
|
+
` return createElement(type, config);`,
|
|
54
|
+
`}`,
|
|
55
|
+
`export function jsx(type, config, maybeKey) { return __ns_jsx(type, config, maybeKey); }`,
|
|
56
|
+
`export function jsxs(type, config, maybeKey) { return __ns_jsx(type, config, maybeKey); }`,
|
|
57
|
+
`export function jsxDEV(type, config, maybeKey) { return __ns_jsx(type, config, maybeKey); }`,
|
|
58
|
+
].join('\n');
|
|
59
|
+
// Lex `exports.NAME = …` / `Object.defineProperty(exports, "NAME", …)` from a CJS
|
|
60
|
+
// development file (the prod/dev targets are plain CJS, statically lexable).
|
|
61
|
+
function lexCjsExportNames(filePath) {
|
|
62
|
+
let src = '';
|
|
63
|
+
try {
|
|
64
|
+
src = readFileSync(filePath, 'utf8');
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
const names = new Set();
|
|
70
|
+
for (const m of src.matchAll(/\bexports\.([A-Za-z_$][\w$]*)\s*=/g))
|
|
71
|
+
names.add(m[1]);
|
|
72
|
+
for (const m of src.matchAll(/Object\.defineProperty\(\s*exports\s*,\s*['"]([A-Za-z_$][\w$]*)['"]/g))
|
|
73
|
+
names.add(m[1]);
|
|
74
|
+
names.delete('default');
|
|
75
|
+
names.delete('__esModule');
|
|
76
|
+
return Array.from(names);
|
|
77
|
+
}
|
|
78
|
+
// Resolve a wrapper module's development-target relative require (`devRel`) to an
|
|
79
|
+
// absolute fs path. `moduleId` is the wrapper's id (an fs path, or a
|
|
80
|
+
// `…/node_modules/<pkg>/<sub>` url/id). We find the wrapper's fs path — directly if
|
|
81
|
+
// it's already absolute, otherwise by resolving its public package subpath spec —
|
|
82
|
+
// then join `devRel` against the wrapper's directory (the dev file is internal, so
|
|
83
|
+
// it can't be import-resolved directly under an `exports` map).
|
|
84
|
+
function resolveDevTargetPath(moduleId, devRel) {
|
|
85
|
+
const clean = (moduleId || '').replace(/[?#].*$/, '');
|
|
86
|
+
if (!clean)
|
|
87
|
+
return null;
|
|
88
|
+
let wrapperPath = null;
|
|
89
|
+
if (path.isAbsolute(clean) && existsSync(clean)) {
|
|
90
|
+
wrapperPath = clean;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const nm = clean.match(/node_modules[\\/]((?:@[^\\/]+[\\/])?[^\\/]+[\\/].*)$/);
|
|
94
|
+
if (nm) {
|
|
95
|
+
const subpath = nm[1].split(path.sep).join('/');
|
|
96
|
+
for (const spec of [subpath.replace(/\.(?:js|mjs|cjs)$/, ''), subpath]) {
|
|
97
|
+
try {
|
|
98
|
+
wrapperPath = projectRequire.resolve(spec);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
catch { }
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (!wrapperPath)
|
|
106
|
+
return null;
|
|
107
|
+
const devPath = path.resolve(path.dirname(wrapperPath), devRel);
|
|
108
|
+
return existsSync(devPath) ? devPath : null;
|
|
109
|
+
}
|
|
110
|
+
// If `code` is a prod/dev conditional re-export wrapper, return an ESM module that
|
|
111
|
+
// re-exports the development target's explicit named exports (+ default). Returns
|
|
112
|
+
// null otherwise so non-matching modules pass through untouched. Detection is
|
|
113
|
+
// intentionally narrow (requires the `module.exports = require(...)` indirection
|
|
114
|
+
// AND both a `.production.js` and `.development.js` target) so it only fires on the
|
|
115
|
+
// React-ecosystem prod/dev idiom.
|
|
116
|
+
function buildCondRequireReexport(code, moduleId) {
|
|
117
|
+
if (!/module\.exports\s*=\s*require\(/.test(code))
|
|
118
|
+
return null;
|
|
119
|
+
const devMatch = code.match(/require\(\s*['"]([^'"]+\.development\.js)['"]\s*\)/);
|
|
120
|
+
const hasProd = /require\(\s*['"][^'"]+\.production\.js['"]\s*\)/.test(code);
|
|
121
|
+
if (!devMatch || !hasProd)
|
|
122
|
+
return null;
|
|
123
|
+
const devRel = devMatch[1]; // e.g. '../cjs/use-sync-external-store-shim/with-selector.development.js'
|
|
124
|
+
// Resolve the dev target to an fs path so we can lex its export names. The dev
|
|
125
|
+
// file is an INTERNAL package file — usually exports-gated, so it can't be
|
|
126
|
+
// resolved as `pkg/cjs/…` directly. Instead resolve the (public) WRAPPER to its
|
|
127
|
+
// fs path and join the relative dev path against the wrapper's directory.
|
|
128
|
+
const devPath = resolveDevTargetPath(moduleId, devRel);
|
|
129
|
+
if (!devPath)
|
|
130
|
+
return null;
|
|
131
|
+
const names = lexCjsExportNames(devPath);
|
|
132
|
+
// Re-export by the ORIGINAL relative path so the device transform rewrites it to
|
|
133
|
+
// the dev target's `/ns/m` URL (served with real named exports). Explicit names
|
|
134
|
+
// only — `export *` is downgraded to a side-effect import by the device transform.
|
|
135
|
+
const target = JSON.stringify(devRel);
|
|
136
|
+
const lines = [];
|
|
137
|
+
if (names.length)
|
|
138
|
+
lines.push(`export { ${names.join(', ')} } from ${target};`);
|
|
139
|
+
lines.push(`export { default } from ${target};`);
|
|
140
|
+
return lines.join('\n');
|
|
141
|
+
}
|
|
142
|
+
export const reactServerStrategy = {
|
|
143
|
+
...typescriptServerStrategy,
|
|
144
|
+
flavor: 'react',
|
|
145
|
+
transformNodeModule(code, moduleId, _verbose) {
|
|
146
|
+
if (moduleId && REACT_JSX_RUNTIME_RE.test(moduleId)) {
|
|
147
|
+
return REACT_JSX_RUNTIME_SHIM;
|
|
148
|
+
}
|
|
149
|
+
return buildCondRequireReexport(code, moduleId || '') ?? code;
|
|
150
|
+
},
|
|
151
|
+
// Like Solid (and unlike plain TypeScript, which recovers via a full
|
|
152
|
+
// `resetRootView`), React HMR applies an edit by having the CLIENT re-fetch +
|
|
153
|
+
// re-evaluate the just-changed route module and read its fresh
|
|
154
|
+
// `Route.options.component`. So the server MUST purge its transform caches
|
|
155
|
+
// BEFORE the client re-imports — otherwise the client races the server and the
|
|
156
|
+
// `/ns/m` re-fetch returns the PREVIOUS save's transform → V8 evaluates stale
|
|
157
|
+
// code → the visible page is "one save behind". The default TS strategy
|
|
158
|
+
// broadcasts the delta immediately (no purge), which is why React edits never
|
|
159
|
+
// applied. We mirror Solid's contract: defer the prologue's delta broadcast,
|
|
160
|
+
// purge the shared + Vite transform caches for the file AND its transitive
|
|
161
|
+
// importers (the route tree statically imports the route), re-transform fresh,
|
|
162
|
+
// then broadcast the delta.
|
|
163
|
+
deferDeltaBroadcast: true,
|
|
164
|
+
async handleHotUpdate(ctx, deps) {
|
|
165
|
+
const state = await runHotUpdatePrologue(ctx, deps);
|
|
166
|
+
if (!state)
|
|
167
|
+
return;
|
|
168
|
+
const { root, metrics, emitSummary } = state;
|
|
169
|
+
const { moduleGraph, verbose, sharedTransformRequest } = deps;
|
|
170
|
+
const { file, server } = ctx;
|
|
171
|
+
const isAppScriptFile = /\.(tsx?|jsx?)$/i.test(file);
|
|
172
|
+
if (!isAppScriptFile) {
|
|
173
|
+
emitSummary();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
metrics.tAfterFramework = Date.now();
|
|
177
|
+
try {
|
|
178
|
+
const rel = '/' + path.posix.normalize(path.relative(root, file)).split(path.sep).join('/');
|
|
179
|
+
const normalizedId = moduleGraph.normalizeGraphId(rel);
|
|
180
|
+
if (!moduleGraph.get(normalizedId)) {
|
|
181
|
+
moduleGraph.upsert(rel, `/* react-hmr ${Date.now()} */`, [], { emitDeltaOnInsert: true });
|
|
182
|
+
}
|
|
183
|
+
// Purge BOTH the shared transform-request cache and Vite's moduleGraph
|
|
184
|
+
// transformResult for the changed file + its bounded transitive importers
|
|
185
|
+
// (route tree → route file), so the client's re-import evaluates fresh code.
|
|
186
|
+
purgeTransformCachesForHotUpdate({ file, server, sharedTransformRequest, verbose, label: 'react' });
|
|
187
|
+
// Re-transform AFTER invalidation so the broadcast hash matches fresh
|
|
188
|
+
// content (the prologue's upsert ran before Vite's auto-invalidate fired).
|
|
189
|
+
try {
|
|
190
|
+
const ext = file.match(/\.(?:[mc]?[jt]sx?)$/i)?.[0] || '';
|
|
191
|
+
const baseSpec = '/' + path.posix.normalize(path.relative(root, file)).split(path.sep).join('/');
|
|
192
|
+
const baseNoExt = ext ? baseSpec.replace(/\.(?:[mc]?[jt]sx?)$/i, '') : baseSpec;
|
|
193
|
+
const candidates = Array.from(new Set([baseSpec, baseNoExt, baseNoExt + '.ts', baseNoExt + '.tsx', baseNoExt + '.js', baseNoExt + '.jsx', baseNoExt + '.mjs', file]));
|
|
194
|
+
let freshCode = '';
|
|
195
|
+
for (const cand of candidates) {
|
|
196
|
+
try {
|
|
197
|
+
const fresh = await sharedTransformRequest(cand, 30000);
|
|
198
|
+
if (fresh?.code && !freshCode)
|
|
199
|
+
freshCode = fresh.code;
|
|
200
|
+
}
|
|
201
|
+
catch { }
|
|
202
|
+
}
|
|
203
|
+
if (freshCode) {
|
|
204
|
+
const existingGm = moduleGraph.get(normalizedId);
|
|
205
|
+
moduleGraph.upsert(normalizedId, freshCode, (existingGm?.deps || []), { broadcastDelta: false });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
if (verbose)
|
|
210
|
+
console.warn('[hmr-ws][react] post-invalidation re-transform failed', e);
|
|
211
|
+
}
|
|
212
|
+
// Broadcast the now-fresh delta, AFTER cache invalidation.
|
|
213
|
+
try {
|
|
214
|
+
const gm = moduleGraph.get(normalizedId);
|
|
215
|
+
if (gm)
|
|
216
|
+
moduleGraph.emitDelta([gm], []);
|
|
217
|
+
}
|
|
218
|
+
catch (e) {
|
|
219
|
+
if (verbose)
|
|
220
|
+
console.warn('[hmr-ws][react] post-invalidation broadcast failed', e);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (e) {
|
|
224
|
+
if (verbose)
|
|
225
|
+
console.warn('[hmr-ws][react] failed to handle hot update for', file, e);
|
|
226
|
+
}
|
|
227
|
+
emitSummary();
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
//# sourceMappingURL=strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../../../../packages/vite/hmr/frameworks/react/server/strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AAEnG,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,6EAA6E;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CAAC,EAAE,EAAE,CAAC,CAAC;YACzC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACZ,IAAI,OAAO;oBAAE,OAAO,CAAC,IAAI,CAAC,oDAAoD,EAAE,CAAC,CAAC,CAAC;YACpF,CAAC;QACF,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,IAAI,OAAO;gBAAE,OAAO,CAAC,IAAI,CAAC,iDAAiD,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACvF,CAAC;QACD,WAAW,EAAE,CAAC;IACf,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find installed packages whose pre-bundle output would smuggle JSX into
|
|
3
|
+
* Vite's import-analysis stage. Returned names are safe to drop into
|
|
4
|
+
* `optimizeDeps.exclude` — the dev server will serve them through the
|
|
5
|
+
* normal module pipeline, where `vite-plugin-solid` can transform their
|
|
6
|
+
* original `.jsx`/`.tsx` files.
|
|
7
|
+
*
|
|
8
|
+
* The function is intentionally synchronous and best-effort: filesystem
|
|
9
|
+
* errors are swallowed, missing directories are skipped, and the scan
|
|
10
|
+
* caps at {@link MAX_SCAN_DEPTH} levels per package. Callers should
|
|
11
|
+
* treat the empty-array result as "no exclusions needed", not "scan
|
|
12
|
+
* failed". A nullable `monorepoRoot` is accepted so workspace hoisting
|
|
13
|
+
* is covered without forcing every caller to compute it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findSolidPackagesShippingJsx(projectRoot: string, monorepoRoot?: string | null): string[];
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Why this helper exists
|
|
5
|
+
* ----------------------
|
|
6
|
+
*
|
|
7
|
+
* Vite's depscanner happily pre-bundles every bare specifier the app
|
|
8
|
+
* imports. For a Solid library that publishes pre-compiled-but-still-JSX
|
|
9
|
+
* files (e.g. `solid-navigation`'s `dist/src/*.jsx`), the pre-bundle output
|
|
10
|
+
* lands at `node_modules/.vite/deps/<pkg>.js` with the JSX intact —
|
|
11
|
+
* rolldown's depscanner doesn't run Solid's JSX transform (that lives in
|
|
12
|
+
* `vite-plugin-solid`'s `transform` hook, which only matches files whose
|
|
13
|
+
* id ends in `.jsx`/`.tsx`).
|
|
14
|
+
*
|
|
15
|
+
* Vite then runs `vite:import-analysis` on the `.js` output, hits the
|
|
16
|
+
* first JSX expression, and aborts the dev server's pre-transform with:
|
|
17
|
+
*
|
|
18
|
+
* Failed to parse source for import analysis because the content
|
|
19
|
+
* contains invalid JS syntax. If you are using JSX, make sure to
|
|
20
|
+
* name the file with the .jsx or .tsx extension.
|
|
21
|
+
* File: /…/.vite/deps/<pkg>.js:51:32
|
|
22
|
+
*
|
|
23
|
+
* The fix: when a project depends on a Solid library that ships `.jsx`
|
|
24
|
+
* (or `.tsx`) source files in its package directory, mark that package
|
|
25
|
+
* as `optimizeDeps.exclude` so Vite serves it through the regular dev
|
|
26
|
+
* pipeline, where `vite-plugin-solid`'s `transform` hook matches the
|
|
27
|
+
* original `.jsx` id and applies the Solid babel preset.
|
|
28
|
+
*
|
|
29
|
+
* Detection rules — biased toward false negatives so we never wrongly
|
|
30
|
+
* exclude a package that Vite must pre-bundle (esp. CJS-only deps that
|
|
31
|
+
* need esm interop). A package is excluded only when ALL of the
|
|
32
|
+
* following hold:
|
|
33
|
+
*
|
|
34
|
+
* 1. It declares `solid-js` or `@nativescript-community/solid-js` in
|
|
35
|
+
* `dependencies` / `peerDependencies` / `devDependencies`. This is
|
|
36
|
+
* a strong signal that the package's published artifacts are
|
|
37
|
+
* meant to be processed by a Solid-aware JSX transformer.
|
|
38
|
+
* 2. Its package directory contains at least one `.jsx` / `.tsx`
|
|
39
|
+
* source file under `dist` / `lib` / `build` / `es` / `esm` /
|
|
40
|
+
* `out` (the common published-output dirs) or directly at the
|
|
41
|
+
* package root. We deliberately skip `node_modules`, `src` (raw
|
|
42
|
+
* sources, not what `main` points to), and test dirs.
|
|
43
|
+
*
|
|
44
|
+
* Both checks are scoped to packages installed in the app's
|
|
45
|
+
* `node_modules` (plus the monorepo's hoisted `node_modules`, if any)
|
|
46
|
+
* — we never recurse into transitive nested copies, since those are
|
|
47
|
+
* also reachable from the same top-level scan once Vite resolves them.
|
|
48
|
+
*/
|
|
49
|
+
const PUBLISHED_OUTPUT_DIRS = new Set(['dist', 'lib', 'build', 'es', 'esm', 'out']);
|
|
50
|
+
// Always-skip subdirs regardless of depth: nested copies, test fixtures,
|
|
51
|
+
// docs, and example apps. Notably `src` is NOT in here because a published
|
|
52
|
+
// bundle may use `dist/src/<file>.jsx` as its layout (e.g. `solid-navigation`).
|
|
53
|
+
// `src/` at the *package root* is rejected separately by the
|
|
54
|
+
// "depth 0 must be a published-output dir" gate below.
|
|
55
|
+
const ALWAYS_SKIP_DIR_NAMES = new Set(['node_modules', 'test', 'tests', '__tests__', 'spec', 'specs', 'docs', 'examples', 'example', '.git', '.cache']);
|
|
56
|
+
const JSX_EXT_RE = /\.(jsx|tsx)$/;
|
|
57
|
+
const MAX_SCAN_DEPTH = 4;
|
|
58
|
+
function isSolidConsumer(pkgJson) {
|
|
59
|
+
const buckets = ['dependencies', 'peerDependencies', 'devDependencies', 'optionalDependencies'];
|
|
60
|
+
for (const key of buckets) {
|
|
61
|
+
const deps = pkgJson[key];
|
|
62
|
+
if (!deps || typeof deps !== 'object')
|
|
63
|
+
continue;
|
|
64
|
+
if (deps['solid-js'])
|
|
65
|
+
return true;
|
|
66
|
+
if (deps['@nativescript-community/solid-js'])
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
function hasJsxFile(dir, depth = 0) {
|
|
72
|
+
if (depth > MAX_SCAN_DEPTH)
|
|
73
|
+
return false;
|
|
74
|
+
let entries;
|
|
75
|
+
try {
|
|
76
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
for (const entry of entries) {
|
|
82
|
+
if (entry.isFile() && JSX_EXT_RE.test(entry.name)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (entry.isDirectory()) {
|
|
86
|
+
if (entry.name.startsWith('.'))
|
|
87
|
+
continue;
|
|
88
|
+
if (ALWAYS_SKIP_DIR_NAMES.has(entry.name))
|
|
89
|
+
continue;
|
|
90
|
+
// At depth 0 (package root) only descend into known
|
|
91
|
+
// published-output dirs so a sibling `src/` (raw sources)
|
|
92
|
+
// can't flag the package on its own. Deeper levels are
|
|
93
|
+
// inside a publish dir already, so any subdir (incl. `src`)
|
|
94
|
+
// is fair game.
|
|
95
|
+
if (depth === 0 && !PUBLISHED_OUTPUT_DIRS.has(entry.name))
|
|
96
|
+
continue;
|
|
97
|
+
if (hasJsxFile(path.join(dir, entry.name), depth + 1))
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
function scanDirectoryForJsxPackages(nodeModulesDir, result, scope = '') {
|
|
104
|
+
let entries;
|
|
105
|
+
try {
|
|
106
|
+
entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
if (!entry.isDirectory())
|
|
113
|
+
continue;
|
|
114
|
+
if (entry.name.startsWith('.'))
|
|
115
|
+
continue;
|
|
116
|
+
if (entry.name === 'node_modules')
|
|
117
|
+
continue;
|
|
118
|
+
const entryPath = path.join(nodeModulesDir, entry.name);
|
|
119
|
+
if (!scope && entry.name.startsWith('@')) {
|
|
120
|
+
scanDirectoryForJsxPackages(entryPath, result, entry.name);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const pkgName = scope ? `${scope}/${entry.name}` : entry.name;
|
|
124
|
+
if (result.has(pkgName))
|
|
125
|
+
continue;
|
|
126
|
+
const pkgJsonPath = path.join(entryPath, 'package.json');
|
|
127
|
+
if (!fs.existsSync(pkgJsonPath))
|
|
128
|
+
continue;
|
|
129
|
+
let pkgJson;
|
|
130
|
+
try {
|
|
131
|
+
pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (!isSolidConsumer(pkgJson))
|
|
137
|
+
continue;
|
|
138
|
+
if (!hasJsxFile(entryPath))
|
|
139
|
+
continue;
|
|
140
|
+
result.add(pkgName);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Find installed packages whose pre-bundle output would smuggle JSX into
|
|
145
|
+
* Vite's import-analysis stage. Returned names are safe to drop into
|
|
146
|
+
* `optimizeDeps.exclude` — the dev server will serve them through the
|
|
147
|
+
* normal module pipeline, where `vite-plugin-solid` can transform their
|
|
148
|
+
* original `.jsx`/`.tsx` files.
|
|
149
|
+
*
|
|
150
|
+
* The function is intentionally synchronous and best-effort: filesystem
|
|
151
|
+
* errors are swallowed, missing directories are skipped, and the scan
|
|
152
|
+
* caps at {@link MAX_SCAN_DEPTH} levels per package. Callers should
|
|
153
|
+
* treat the empty-array result as "no exclusions needed", not "scan
|
|
154
|
+
* failed". A nullable `monorepoRoot` is accepted so workspace hoisting
|
|
155
|
+
* is covered without forcing every caller to compute it.
|
|
156
|
+
*/
|
|
157
|
+
export function findSolidPackagesShippingJsx(projectRoot, monorepoRoot) {
|
|
158
|
+
const found = new Set();
|
|
159
|
+
const seenDirs = new Set();
|
|
160
|
+
const scanDirs = [];
|
|
161
|
+
const projectNodeModules = path.resolve(projectRoot, 'node_modules');
|
|
162
|
+
scanDirs.push(projectNodeModules);
|
|
163
|
+
if (monorepoRoot && path.resolve(monorepoRoot) !== path.resolve(projectRoot)) {
|
|
164
|
+
const monorepoNodeModules = path.resolve(monorepoRoot, 'node_modules');
|
|
165
|
+
scanDirs.push(monorepoNodeModules);
|
|
166
|
+
}
|
|
167
|
+
for (const dir of scanDirs) {
|
|
168
|
+
const key = path.resolve(dir);
|
|
169
|
+
if (seenDirs.has(key))
|
|
170
|
+
continue;
|
|
171
|
+
seenDirs.add(key);
|
|
172
|
+
if (!fs.existsSync(dir))
|
|
173
|
+
continue;
|
|
174
|
+
scanDirectoryForJsxPackages(dir, found);
|
|
175
|
+
}
|
|
176
|
+
return Array.from(found).sort();
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=solid-jsx-deps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-jsx-deps.js","sourceRoot":"","sources":["../../../../../../../packages/vite/hmr/frameworks/solid/build/solid-jsx-deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACpF,yEAAyE;AACzE,2EAA2E;AAC3E,gFAAgF;AAChF,6DAA6D;AAC7D,uDAAuD;AACvD,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxJ,MAAM,UAAU,GAAG,cAAc,CAAC;AAClC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,SAAS,eAAe,CAAC,OAA4B;IACpD,MAAM,OAAO,GAAG,CAAC,cAAc,EAAE,kBAAkB,EAAE,iB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AAC;YAAE,SAAS;QAChC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QAClC,2BAA2B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap + HMR remount for NativeScript Solid apps.
|
|
3
|
+
*
|
|
4
|
+
* Solid runs with `hot: false` (solid-refresh is off — it rewrites `export
|
|
5
|
+
* function` into a non-hoisted const and breaks TanStack file-route modules), so
|
|
6
|
+
* there is no fine-grained component HMR.
|
|
7
|
+
*
|
|
8
|
+
* Division of labour on each Solid HMR cycle (`__ns_solid_hmr_subscribe`):
|
|
9
|
+
* • ROUTE files — handled by @nativescript/tanstack-router's per-page remount
|
|
10
|
+
* (`subscribeSolidHmrRemount` → `page.__ns_remount`), which swaps the route
|
|
11
|
+
* component in place WITHOUT re-navigating, so the user stays on their route.
|
|
12
|
+
* This helper does nothing for route-only edits.
|
|
13
|
+
* • Everything else (app shell / shared components / app entry) — this helper
|
|
14
|
+
* re-imports the app entry and re-renders the whole Solid tree. The router is
|
|
15
|
+
* REUSED (its chain is never evicted), so the current route is preserved.
|
|
16
|
+
*
|
|
17
|
+
* Renderer bindings (`Application`, `render`, `document`) are passed in rather than
|
|
18
|
+
* imported here so the helper uses the app's exact solid-js / dominative instances.
|
|
19
|
+
* Importing our own copies could resolve to a different module realm and break
|
|
20
|
+
* Solid reactivity (NativeScript can load a package's deps in a separate realm).
|
|
21
|
+
*/
|
|
22
|
+
export interface StartSolidAppOptions {
|
|
23
|
+
/** `@nativescript/core` `Application`. */
|
|
24
|
+
Application: {
|
|
25
|
+
run(entry: {
|
|
26
|
+
create: () => any;
|
|
27
|
+
}): void;
|
|
28
|
+
};
|
|
29
|
+
/** `@nativescript-community/solid-js` `render` — mounts a component, returns a disposer. */
|
|
30
|
+
render: (component: any, target: any) => () => void;
|
|
31
|
+
/** dominative `document` — returned as the root view; `document.body` is the mount target. */
|
|
32
|
+
document: any;
|
|
33
|
+
/** Initial root component (used for the first mount). */
|
|
34
|
+
root: any;
|
|
35
|
+
/**
|
|
36
|
+
* App-relative specifier of the module that exports the root component, as
|
|
37
|
+
* `App` or default (e.g. `/src/native/app`). Re-imported fresh on each cycle.
|
|
38
|
+
*/
|
|
39
|
+
rootModule: string;
|
|
40
|
+
/**
|
|
41
|
+
* Optional `@nativescript/core` `Frame` class. Pass it when the app uses a
|
|
42
|
+
* topmost-frame router (e.g. solid-navigation's `StackRouter` with
|
|
43
|
+
* `useTopMostFrame`): those routers re-run their initial navigation against
|
|
44
|
+
* `Frame.topmost()` when the fresh tree mounts. During a remount that would
|
|
45
|
+
* target a STALE frame from the old tree (often a nested tab frame) and push
|
|
46
|
+
* a backstack entry per edit. With `Frame` provided, the remount render
|
|
47
|
+
* redirects such navigations to the ROOT frame (`document.documentElement`)
|
|
48
|
+
* with `clearHistory: true`, so each HMR apply swaps the whole tree in place
|
|
49
|
+
* and disposes the old pages instead of stacking on top of them.
|
|
50
|
+
*/
|
|
51
|
+
Frame?: any;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Boot a NativeScript Solid app and wire up HMR remounting. Call once from the
|
|
55
|
+
* app entry, e.g.:
|
|
56
|
+
*
|
|
57
|
+
* import './utils/dom';
|
|
58
|
+
* import { Application, Frame } from '@nativescript/core';
|
|
59
|
+
* import { render } from '@nativescript-community/solid-js';
|
|
60
|
+
* import { document } from 'dominative';
|
|
61
|
+
* import { startSolidApp } from '@nativescript/vite/solid-bootstrap';
|
|
62
|
+
* import { App } from './app';
|
|
63
|
+
*
|
|
64
|
+
* // `Frame` is optional — pass it when using a topmost-frame router
|
|
65
|
+
* // (solid-navigation) so HMR remounts replace the root page in place.
|
|
66
|
+
* startSolidApp({ Application, render, document, Frame, root: App, rootModule: '/src/native/app' });
|
|
67
|
+
*/
|
|
68
|
+
export declare function startSolidApp(options: StartSolidAppOptions): void;
|