@nativescript/vite 8.0.0-dev.0 → 8.0.0-rc.1

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.
Files changed (78) hide show
  1. package/README.md +1 -17
  2. package/configuration/base.js +1 -1
  3. package/configuration/base.js.map +1 -1
  4. package/helpers/flavor.d.ts +0 -18
  5. package/helpers/flavor.js +1 -35
  6. package/helpers/flavor.js.map +1 -1
  7. package/helpers/global-defines.d.ts +0 -1
  8. package/helpers/global-defines.js +0 -5
  9. package/helpers/global-defines.js.map +1 -1
  10. package/helpers/init.js +6 -18
  11. package/helpers/init.js.map +1 -1
  12. package/helpers/logging.d.ts +1 -11
  13. package/helpers/logging.js +1 -16
  14. package/helpers/logging.js.map +1 -1
  15. package/helpers/typescript-check.d.ts +2 -1
  16. package/hmr/client/css-handler.js +4 -10
  17. package/hmr/client/css-handler.js.map +1 -1
  18. package/hmr/client/framework-client-strategy.d.ts +0 -30
  19. package/hmr/client/hot-context.d.ts +0 -22
  20. package/hmr/client/hot-context.js +5 -102
  21. package/hmr/client/hot-context.js.map +1 -1
  22. package/hmr/client/strategy-loader.js +5 -41
  23. package/hmr/client/strategy-loader.js.map +1 -1
  24. package/hmr/client/update-pipeline.js +0 -25
  25. package/hmr/client/update-pipeline.js.map +1 -1
  26. package/hmr/entry-runtime.js +2 -12
  27. package/hmr/entry-runtime.js.map +1 -1
  28. package/hmr/frameworks/vue/client/index.js +34 -14
  29. package/hmr/frameworks/vue/client/index.js.map +1 -1
  30. package/hmr/frameworks/vue/client/navigate-app.d.ts +29 -0
  31. package/hmr/frameworks/vue/client/navigate-app.js +73 -6
  32. package/hmr/frameworks/vue/client/navigate-app.js.map +1 -1
  33. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +7 -0
  34. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +19 -0
  35. package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -1
  36. package/hmr/frameworks/vue/server/sfc-change-kind.d.ts +50 -0
  37. package/hmr/frameworks/vue/server/sfc-change-kind.js +92 -0
  38. package/hmr/frameworks/vue/server/sfc-change-kind.js.map +1 -0
  39. package/hmr/frameworks/vue/server/strategy.js +37 -2
  40. package/hmr/frameworks/vue/server/strategy.js.map +1 -1
  41. package/hmr/server/deps-bundle.js +2 -2
  42. package/hmr/server/deps-bundle.js.map +1 -1
  43. package/hmr/server/process-code-for-device.d.ts +1 -11
  44. package/hmr/server/process-code-for-device.js +5 -3
  45. package/hmr/server/process-code-for-device.js.map +1 -1
  46. package/hmr/server/vite-plugin.js +12 -3
  47. package/hmr/server/vite-plugin.js.map +1 -1
  48. package/hmr/server/websocket-hot-update.js +2 -6
  49. package/hmr/server/websocket-hot-update.js.map +1 -1
  50. package/hmr/server/websocket-module-specifiers.d.ts +0 -2
  51. package/hmr/server/websocket-module-specifiers.js +0 -13
  52. package/hmr/server/websocket-module-specifiers.js.map +1 -1
  53. package/hmr/server/websocket-ns-m.js +2 -4
  54. package/hmr/server/websocket-ns-m.js.map +1 -1
  55. package/hmr/server/websocket-served-module-helpers.d.ts +0 -9
  56. package/hmr/server/websocket-served-module-helpers.js +0 -13
  57. package/hmr/server/websocket-served-module-helpers.js.map +1 -1
  58. package/hmr/server/websocket.d.ts +4 -3
  59. package/hmr/server/websocket.js +5 -5
  60. package/hmr/server/websocket.js.map +1 -1
  61. package/hmr/shared/ns-globals.d.ts +0 -1
  62. package/hmr/shared/ns-globals.js.map +1 -1
  63. package/hmr/shared/protocol.d.ts +9 -0
  64. package/hmr/shared/protocol.js.map +1 -1
  65. package/hmr/shared/runtime/restyle-roots.d.ts +22 -0
  66. package/hmr/shared/runtime/restyle-roots.js +67 -0
  67. package/hmr/shared/runtime/restyle-roots.js.map +1 -0
  68. package/package.json +1 -8
  69. package/shims/react-jsx-runtime.d.ts +4 -4
  70. package/framework.d.ts +0 -22
  71. package/framework.js +0 -18
  72. package/framework.js.map +0 -1
  73. package/hmr/client/framework.d.ts +0 -31
  74. package/hmr/client/framework.js +0 -17
  75. package/hmr/client/framework.js.map +0 -1
  76. package/hmr/framework-flavors.d.ts +0 -59
  77. package/hmr/framework-flavors.js +0 -108
  78. package/hmr/framework-flavors.js.map +0 -1
@@ -1,59 +0,0 @@
1
- import type { FrameworkServerStrategy } from './server/framework-strategy.js';
2
- /**
3
- * A framework flavor contributed from outside this package.
4
- *
5
- * The built-in flavors (`angular`, `vue`, `react`, `solid`, `typescript`,
6
- * `javascript`) are wired by name inside `@nativescript/vite`. Everything a
7
- * flavor needs beyond a name is expressed here, so a framework can ship its
8
- * own HMR support as a package: the server half runs in the dev server
9
- * process; the client half is a module the device fetches and evaluates next
10
- * to the shared HMR client.
11
- */
12
- export interface FrameworkFlavorDefinition {
13
- /**
14
- * The flavor name. It is what the config helper declares through
15
- * `baseConfig({ flavor })`, what the device receives as `__NS_TARGET_FLAVOR__`,
16
- * and what selects both strategies. Must not collide with a built-in name.
17
- */
18
- flavor: string;
19
- /**
20
- * The dev-server half. Most frameworks start from `typescriptServerStrategy`
21
- * (the generic device-module pipeline) and override `handleHotUpdate`.
22
- */
23
- server: FrameworkServerStrategy;
24
- /**
25
- * The device half: a module specifier resolvable from the app's root —
26
- * usually a package subpath such as `@my-framework/nativescript-vite/client`.
27
- * The module is served to the device as-is through `/ns/m`, so it must be
28
- * plain ESM with explicit `.js` import extensions, importing shared client
29
- * helpers only from `@nativescript/vite/hmr/client/framework.js`. It exports
30
- * the strategy as `default`, `clientStrategy`, or `<flavor>ClientStrategy`.
31
- */
32
- client: string;
33
- }
34
- /**
35
- * Register a flavor. Call it before `baseConfig({ flavor })` runs — from the
36
- * top of the framework's config helper is the natural place — so the HMR
37
- * plugins the base config installs can find the server strategy, and the
38
- * device bundle is seeded with the client strategy's URL. Registering the
39
- * same flavor again replaces the previous definition.
40
- */
41
- export declare function registerFrameworkFlavor(definition: FrameworkFlavorDefinition): void;
42
- export declare function getFrameworkFlavor(flavor: string): FrameworkFlavorDefinition | undefined;
43
- /**
44
- * Package names that ship a registered flavor's client strategy. The device
45
- * pipeline treats them like `@nativescript/vite` itself: served per-module
46
- * through `/ns/m`, never through the vendor bundle or the plugin registry
47
- * shim, so the module's own relative imports and its imports of the shared
48
- * client surface resolve to the live client's canonical URLs.
49
- */
50
- export declare function getFlavorClientPackages(): ReadonlySet<string>;
51
- export declare function isBuiltInFlavor(flavor: string): boolean;
52
- /**
53
- * The device-side URL path of a registered flavor's client strategy module —
54
- * `/ns/m/node_modules/<package>/<file>` — or `''` for a built-in / unknown
55
- * flavor. The specifier is resolved from the app root like any import, then
56
- * expressed relative to its package so the path holds whether the package is
57
- * installed or linked from a workspace.
58
- */
59
- export declare function getClientStrategyDevicePath(flavor: string, projectRoot?: string): string;
@@ -1,108 +0,0 @@
1
- import { createRequire } from 'node:module';
2
- import { existsSync, readFileSync } from 'node:fs';
3
- import * as path from 'node:path';
4
- import { getProjectRootPath } from '../helpers/project.js';
5
- const BUILT_IN_FLAVORS = new Set(['angular', 'vue', 'react', 'solid', 'typescript', 'javascript']);
6
- const flavors = new Map();
7
- /**
8
- * Register a flavor. Call it before `baseConfig({ flavor })` runs — from the
9
- * top of the framework's config helper is the natural place — so the HMR
10
- * plugins the base config installs can find the server strategy, and the
11
- * device bundle is seeded with the client strategy's URL. Registering the
12
- * same flavor again replaces the previous definition.
13
- */
14
- export function registerFrameworkFlavor(definition) {
15
- const flavor = String(definition?.flavor || '').trim();
16
- if (!flavor)
17
- throw new TypeError('[@nativescript/vite] registerFrameworkFlavor: `flavor` is required.');
18
- if (BUILT_IN_FLAVORS.has(flavor)) {
19
- throw new Error(`[@nativescript/vite] registerFrameworkFlavor: "${flavor}" is a built-in flavor and cannot be replaced.`);
20
- }
21
- if (!definition.server || typeof definition.server.matchesFile !== 'function' || typeof definition.server.processFile !== 'function' || typeof definition.server.buildRegistry !== 'function') {
22
- throw new TypeError(`[@nativescript/vite] registerFrameworkFlavor("${flavor}"): \`server\` must be a FrameworkServerStrategy.`);
23
- }
24
- if (typeof definition.client !== 'string' || !definition.client.trim()) {
25
- throw new TypeError(`[@nativescript/vite] registerFrameworkFlavor("${flavor}"): \`client\` must be a module specifier.`);
26
- }
27
- if (definition.server.flavor !== flavor) {
28
- throw new Error(`[@nativescript/vite] registerFrameworkFlavor("${flavor}"): the server strategy declares flavor "${definition.server.flavor}".`);
29
- }
30
- flavors.set(flavor, { ...definition, flavor });
31
- }
32
- export function getFrameworkFlavor(flavor) {
33
- return flavors.get(flavor);
34
- }
35
- /**
36
- * Package names that ship a registered flavor's client strategy. The device
37
- * pipeline treats them like `@nativescript/vite` itself: served per-module
38
- * through `/ns/m`, never through the vendor bundle or the plugin registry
39
- * shim, so the module's own relative imports and its imports of the shared
40
- * client surface resolve to the live client's canonical URLs.
41
- */
42
- export function getFlavorClientPackages() {
43
- const names = new Set();
44
- for (const definition of flavors.values()) {
45
- const name = packageNameOfSpecifier(definition.client);
46
- if (name)
47
- names.add(name);
48
- }
49
- return names;
50
- }
51
- function packageNameOfSpecifier(specifier) {
52
- if (!specifier || specifier.startsWith('.') || path.isAbsolute(specifier))
53
- return null;
54
- const parts = specifier.split('/');
55
- return specifier.startsWith('@') ? (parts.length >= 2 ? `${parts[0]}/${parts[1]}` : null) : parts[0];
56
- }
57
- export function isBuiltInFlavor(flavor) {
58
- return BUILT_IN_FLAVORS.has(flavor);
59
- }
60
- /**
61
- * The device-side URL path of a registered flavor's client strategy module —
62
- * `/ns/m/node_modules/<package>/<file>` — or `''` for a built-in / unknown
63
- * flavor. The specifier is resolved from the app root like any import, then
64
- * expressed relative to its package so the path holds whether the package is
65
- * installed or linked from a workspace.
66
- */
67
- export function getClientStrategyDevicePath(flavor, projectRoot = getProjectRootPath()) {
68
- const definition = flavors.get(flavor);
69
- if (!definition)
70
- return '';
71
- const resolved = resolveFromProject(definition.client, projectRoot);
72
- const pkg = findPackageRoot(resolved);
73
- if (!pkg) {
74
- throw new Error(`[@nativescript/vite] flavor "${flavor}": client module ${definition.client} resolved to ${resolved}, which is not inside a package.`);
75
- }
76
- const inside = path.relative(pkg.dir, resolved).split(path.sep).join('/');
77
- return `/ns/m/node_modules/${pkg.name}/${inside}`;
78
- }
79
- function resolveFromProject(specifier, projectRoot) {
80
- if (path.isAbsolute(specifier))
81
- return specifier;
82
- const require = createRequire(path.join(projectRoot, 'package.json'));
83
- try {
84
- return require.resolve(specifier);
85
- }
86
- catch (error) {
87
- throw new Error(`[@nativescript/vite] cannot resolve client strategy module ${JSON.stringify(specifier)} from ${projectRoot}: ${error.message}`);
88
- }
89
- }
90
- function findPackageRoot(file) {
91
- let dir = path.dirname(file);
92
- for (;;) {
93
- const manifest = path.join(dir, 'package.json');
94
- if (existsSync(manifest)) {
95
- try {
96
- const name = JSON.parse(readFileSync(manifest, 'utf8')).name;
97
- if (typeof name === 'string' && name)
98
- return { dir, name };
99
- }
100
- catch { }
101
- }
102
- const parent = path.dirname(dir);
103
- if (parent === dir)
104
- return null;
105
- dir = parent;
106
- }
107
- }
108
- //# sourceMappingURL=framework-flavors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"framework-flavors.js","sourceRoot":"","sources":["../../../../packages/vite/hmr/framework-flavors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAmC3D,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;AACnG,MAAM,OAAO,GAAG,IAAI,GAAG,EAAqC,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAAqC;IAC5E,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,E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