@nativescript/vite 0.0.1 → 0.0.2

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 (257) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +44 -0
  3. package/{dist/configuration → configuration}/angular.d.ts +1 -1
  4. package/configuration/angular.js +480 -0
  5. package/configuration/angular.js.map +1 -0
  6. package/configuration/base.d.ts +5 -0
  7. package/configuration/base.js +494 -0
  8. package/configuration/base.js.map +1 -0
  9. package/configuration/javascript.d.ts +4 -0
  10. package/configuration/javascript.js +151 -0
  11. package/configuration/javascript.js.map +1 -0
  12. package/{dist/configuration → configuration}/react.d.ts +1 -1
  13. package/{dist/configuration → configuration}/react.js +18 -17
  14. package/configuration/react.js.map +1 -0
  15. package/{dist/configuration → configuration}/solid.d.ts +1 -1
  16. package/{dist/configuration → configuration}/solid.js +17 -16
  17. package/configuration/solid.js.map +1 -0
  18. package/configuration/typescript.d.ts +4 -0
  19. package/configuration/typescript.js +175 -0
  20. package/configuration/typescript.js.map +1 -0
  21. package/{dist/configuration → configuration}/vue.d.ts +1 -1
  22. package/configuration/vue.js +163 -0
  23. package/configuration/vue.js.map +1 -0
  24. package/helpers/angular-linker.d.ts +13 -0
  25. package/helpers/angular-linker.js +181 -0
  26. package/helpers/angular-linker.js.map +1 -0
  27. package/helpers/cli-flags.d.ts +1 -0
  28. package/helpers/cli-flags.js +15 -0
  29. package/helpers/cli-flags.js.map +1 -0
  30. package/{dist/helpers → helpers}/commonjs-plugins.js +14 -13
  31. package/helpers/commonjs-plugins.js.map +1 -0
  32. package/{dist/helpers → helpers}/config-as-json.d.ts +1 -1
  33. package/{dist/helpers → helpers}/config-as-json.js +7 -6
  34. package/helpers/config-as-json.js.map +1 -0
  35. package/helpers/css-platform-plugin.d.ts +10 -0
  36. package/helpers/css-platform-plugin.js +76 -0
  37. package/helpers/css-platform-plugin.js.map +1 -0
  38. package/helpers/css-tree.js +22 -0
  39. package/helpers/css-tree.js.map +1 -0
  40. package/{dist/helpers → helpers}/dynamic-import-plugin.js +8 -7
  41. package/helpers/dynamic-import-plugin.js.map +1 -0
  42. package/helpers/esbuild-platform-resolver.d.ts +14 -0
  43. package/helpers/esbuild-platform-resolver.js +93 -0
  44. package/helpers/esbuild-platform-resolver.js.map +1 -0
  45. package/helpers/external-configs.d.ts +6 -0
  46. package/helpers/external-configs.js +34 -0
  47. package/helpers/external-configs.js.map +1 -0
  48. package/{dist/helpers → helpers}/flavor.d.ts +1 -0
  49. package/helpers/flavor.js +51 -0
  50. package/helpers/flavor.js.map +1 -0
  51. package/{dist/helpers → helpers}/global-defines.d.ts +11 -2
  52. package/helpers/global-defines.js +24 -0
  53. package/helpers/global-defines.js.map +1 -0
  54. package/helpers/logging.d.ts +13 -0
  55. package/helpers/logging.js +111 -0
  56. package/helpers/logging.js.map +1 -0
  57. package/helpers/main-entry.d.ts +10 -0
  58. package/helpers/main-entry.js +215 -0
  59. package/helpers/main-entry.js.map +1 -0
  60. package/{dist/helpers → helpers}/module-resolution.js +4 -3
  61. package/helpers/module-resolution.js.map +1 -0
  62. package/helpers/module-runner-patch.d.ts +3 -0
  63. package/helpers/module-runner-patch.js +63 -0
  64. package/helpers/module-runner-patch.js.map +1 -0
  65. package/helpers/nativeclass-transform.d.ts +7 -0
  66. package/helpers/nativeclass-transform.js +158 -0
  67. package/helpers/nativeclass-transform.js.map +1 -0
  68. package/helpers/nativeclass-transformer-plugin.d.ts +5 -0
  69. package/helpers/nativeclass-transformer-plugin.js +23 -0
  70. package/helpers/nativeclass-transformer-plugin.js.map +1 -0
  71. package/{dist/helpers → helpers}/nativescript-package-resolver.js +18 -17
  72. package/helpers/nativescript-package-resolver.js.map +1 -0
  73. package/helpers/ns-cli-plugins.d.ts +14 -0
  74. package/helpers/ns-cli-plugins.js +165 -0
  75. package/helpers/ns-cli-plugins.js.map +1 -0
  76. package/helpers/package-platform-aliases.d.ts +10 -0
  77. package/{dist/helpers → helpers}/package-platform-aliases.js +19 -23
  78. package/helpers/package-platform-aliases.js.map +1 -0
  79. package/helpers/postcss-platform-config.d.ts +13 -0
  80. package/helpers/postcss-platform-config.js +97 -0
  81. package/helpers/postcss-platform-config.js.map +1 -0
  82. package/helpers/prelink-angular.d.ts +2 -0
  83. package/helpers/prelink-angular.js +117 -0
  84. package/helpers/prelink-angular.js.map +1 -0
  85. package/helpers/preserve-imports.d.ts +2 -0
  86. package/helpers/preserve-imports.js +38 -0
  87. package/helpers/preserve-imports.js.map +1 -0
  88. package/{dist/helpers → helpers}/project.js +2 -4
  89. package/helpers/project.js.map +1 -0
  90. package/helpers/resolver.d.ts +4 -0
  91. package/{dist/helpers → helpers}/resolver.js +7 -6
  92. package/helpers/resolver.js.map +1 -0
  93. package/helpers/theme-core-plugins.d.ts +14 -0
  94. package/helpers/theme-core-plugins.js +121 -0
  95. package/helpers/theme-core-plugins.js.map +1 -0
  96. package/helpers/ts-config-paths.d.ts +10 -0
  97. package/{dist/helpers → helpers}/ts-config-paths.js +73 -72
  98. package/helpers/ts-config-paths.js.map +1 -0
  99. package/{dist/helpers → helpers}/utils.d.ts +6 -0
  100. package/{dist/helpers → helpers}/utils.js +28 -34
  101. package/helpers/utils.js.map +1 -0
  102. package/{dist/helpers → helpers}/workers.js +15 -16
  103. package/helpers/workers.js.map +1 -0
  104. package/hmr/client/css-handler.d.ts +4 -0
  105. package/hmr/client/css-handler.js +78 -0
  106. package/hmr/client/css-handler.js.map +1 -0
  107. package/hmr/client/index.d.ts +13 -0
  108. package/hmr/client/index.js +1550 -0
  109. package/hmr/client/index.js.map +1 -0
  110. package/hmr/client/utils.d.ts +38 -0
  111. package/hmr/client/utils.js +426 -0
  112. package/hmr/client/utils.js.map +1 -0
  113. package/hmr/entry-runtime.d.ts +8 -0
  114. package/hmr/entry-runtime.js +135 -0
  115. package/hmr/entry-runtime.js.map +1 -0
  116. package/hmr/frameworks/angular/server/strategy.d.ts +2 -0
  117. package/hmr/frameworks/angular/server/strategy.js +101 -0
  118. package/hmr/frameworks/angular/server/strategy.js.map +1 -0
  119. package/hmr/frameworks/vue/client/index.d.ts +22 -0
  120. package/hmr/frameworks/vue/client/index.js +1537 -0
  121. package/hmr/frameworks/vue/client/index.js.map +1 -0
  122. package/hmr/frameworks/vue/server/compiler.d.ts +11 -0
  123. package/hmr/frameworks/vue/server/compiler.js +26 -0
  124. package/hmr/frameworks/vue/server/compiler.js.map +1 -0
  125. package/hmr/frameworks/vue/server/sfc-transforms.d.ts +14 -0
  126. package/hmr/frameworks/vue/server/sfc-transforms.js +282 -0
  127. package/hmr/frameworks/vue/server/sfc-transforms.js.map +1 -0
  128. package/hmr/frameworks/vue/server/strategy.d.ts +2 -0
  129. package/hmr/frameworks/vue/server/strategy.js +273 -0
  130. package/hmr/frameworks/vue/server/strategy.js.map +1 -0
  131. package/hmr/helpers/ast-extract.d.ts +6 -0
  132. package/hmr/helpers/ast-extract.js +72 -0
  133. package/hmr/helpers/ast-extract.js.map +1 -0
  134. package/hmr/helpers/ast-normalizer.d.ts +7 -0
  135. package/hmr/helpers/ast-normalizer.js +772 -0
  136. package/hmr/helpers/ast-normalizer.js.map +1 -0
  137. package/hmr/helpers/babel.d.ts +3 -0
  138. package/hmr/helpers/babel.js +17 -0
  139. package/hmr/helpers/babel.js.map +1 -0
  140. package/hmr/helpers/sanitize.d.ts +6 -0
  141. package/hmr/helpers/sanitize.js +55 -0
  142. package/hmr/helpers/sanitize.js.map +1 -0
  143. package/hmr/helpers/vendor-rewrite.d.ts +1 -0
  144. package/hmr/helpers/vendor-rewrite.js +35 -0
  145. package/hmr/helpers/vendor-rewrite.js.map +1 -0
  146. package/hmr/server/compiler.d.ts +2 -0
  147. package/hmr/server/compiler.js +75 -0
  148. package/hmr/server/compiler.js.map +1 -0
  149. package/hmr/server/constants.d.ts +14 -0
  150. package/hmr/server/constants.js +23 -0
  151. package/hmr/server/constants.js.map +1 -0
  152. package/hmr/server/core-sanitize.d.ts +32 -0
  153. package/hmr/server/core-sanitize.js +134 -0
  154. package/hmr/server/core-sanitize.js.map +1 -0
  155. package/hmr/server/framework-strategy.d.ts +68 -0
  156. package/hmr/server/framework-strategy.js +2 -0
  157. package/hmr/server/framework-strategy.js.map +1 -0
  158. package/hmr/server/index.d.ts +5 -0
  159. package/hmr/server/index.js +19 -0
  160. package/hmr/server/index.js.map +1 -0
  161. package/hmr/server/vite-plugin.d.ts +5 -0
  162. package/hmr/server/vite-plugin.js +44 -0
  163. package/hmr/server/vite-plugin.js.map +1 -0
  164. package/hmr/server/websocket.d.ts +15 -0
  165. package/hmr/server/websocket.js +5528 -0
  166. package/hmr/server/websocket.js.map +1 -0
  167. package/hmr/shared/runtime/http-only-boot.d.ts +1 -0
  168. package/hmr/shared/runtime/http-only-boot.js +107 -0
  169. package/hmr/shared/runtime/http-only-boot.js.map +1 -0
  170. package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
  171. package/hmr/shared/runtime/root-placeholder.js +142 -0
  172. package/hmr/shared/runtime/root-placeholder.js.map +1 -0
  173. package/hmr/shared/runtime/vendor-bootstrap.d.ts +1 -0
  174. package/hmr/shared/runtime/vendor-bootstrap.js +134 -0
  175. package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -0
  176. package/hmr/shared/vendor/manifest-loader.d.ts +9 -0
  177. package/hmr/shared/vendor/manifest-loader.js +38 -0
  178. package/hmr/shared/vendor/manifest-loader.js.map +1 -0
  179. package/hmr/shared/vendor/manifest.d.ts +34 -0
  180. package/hmr/shared/vendor/manifest.js +787 -0
  181. package/hmr/shared/vendor/manifest.js.map +1 -0
  182. package/hmr/shared/vendor/registry.d.ts +9 -0
  183. package/hmr/shared/vendor/registry.js +62 -0
  184. package/hmr/shared/vendor/registry.js.map +1 -0
  185. package/hmr/vendor-bootstrap.d.ts +3 -0
  186. package/hmr/vendor-bootstrap.js +32 -0
  187. package/hmr/vendor-bootstrap.js.map +1 -0
  188. package/{dist/index.d.ts → index.d.ts} +2 -0
  189. package/{dist/index.js → index.js} +3 -0
  190. package/index.js.map +1 -0
  191. package/package.json +39 -30
  192. package/{dist/polyfills → polyfills}/mdn-data-at-rules.js +1 -0
  193. package/polyfills/mdn-data-at-rules.js.map +1 -0
  194. package/{dist/polyfills → polyfills}/mdn-data-properties.js +1 -0
  195. package/polyfills/mdn-data-properties.js.map +1 -0
  196. package/{dist/polyfills → polyfills}/mdn-data-syntaxes.js +1 -0
  197. package/polyfills/mdn-data-syntaxes.js.map +1 -0
  198. package/{dist/polyfills → polyfills}/module.js +1 -0
  199. package/polyfills/module.js.map +1 -0
  200. package/runtime/core-aliases-early.d.ts +1 -0
  201. package/runtime/core-aliases-early.js +334 -0
  202. package/runtime/core-aliases-early.js.map +1 -0
  203. package/shims/angular-animations-stub.d.ts +8 -0
  204. package/shims/angular-animations-stub.js +14 -0
  205. package/shims/angular-animations-stub.js.map +1 -0
  206. package/shims/node-module.d.ts +5 -0
  207. package/shims/node-module.js +13 -0
  208. package/shims/node-module.js.map +1 -0
  209. package/{dist/shims → shims}/react-reconciler-constants.js +2 -1
  210. package/shims/react-reconciler-constants.js.map +1 -0
  211. package/{dist/shims → shims}/react-reconciler.js +1 -0
  212. package/shims/react-reconciler.js.map +1 -0
  213. package/{dist/shims → shims}/set-value.js +5 -1
  214. package/shims/set-value.js.map +1 -0
  215. package/transformers/NativeClass/index.d.ts +2 -0
  216. package/transformers/NativeClass/index.js +222 -0
  217. package/transformers/NativeClass/index.js.map +1 -0
  218. package/dist/configuration/angular.js +0 -30
  219. package/dist/configuration/base.d.ts +0 -13
  220. package/dist/configuration/base.js +0 -228
  221. package/dist/configuration/old-without-merge-base.d.ts +0 -13
  222. package/dist/configuration/old-without-merge-base.js +0 -249
  223. package/dist/configuration/vue.js +0 -45
  224. package/dist/helpers/css-tree.js +0 -21
  225. package/dist/helpers/flavor.js +0 -40
  226. package/dist/helpers/global-defines.js +0 -18
  227. package/dist/helpers/main-entry.d.ts +0 -5
  228. package/dist/helpers/main-entry.js +0 -75
  229. package/dist/helpers/ns-cli-plugins.d.ts +0 -17
  230. package/dist/helpers/ns-cli-plugins.js +0 -128
  231. package/dist/helpers/package-platform-aliases.d.ts +0 -4
  232. package/dist/helpers/resolver.d.ts +0 -4
  233. package/dist/helpers/ts-config-paths.d.ts +0 -4
  234. package/dist/hmr/hmr-angular.d.ts +0 -1
  235. package/dist/hmr/hmr-angular.js +0 -34
  236. package/dist/hmr/hmr-bridge.d.ts +0 -18
  237. package/dist/hmr/hmr-bridge.js +0 -154
  238. package/dist/hmr/hmr-client.d.ts +0 -5
  239. package/dist/hmr/hmr-client.js +0 -93
  240. package/dist/hmr/hmr-server.d.ts +0 -20
  241. package/dist/hmr/hmr-server.js +0 -179
  242. package/dist/transformers/NativeClass/index.d.ts +0 -5
  243. package/dist/transformers/NativeClass/index.js +0 -46
  244. /package/{dist/helpers → helpers}/commonjs-plugins.d.ts +0 -0
  245. /package/{dist/helpers → helpers}/css-tree.d.ts +0 -0
  246. /package/{dist/helpers → helpers}/dynamic-import-plugin.d.ts +0 -0
  247. /package/{dist/helpers → helpers}/module-resolution.d.ts +0 -0
  248. /package/{dist/helpers → helpers}/nativescript-package-resolver.d.ts +0 -0
  249. /package/{dist/helpers → helpers}/project.d.ts +0 -0
  250. /package/{dist/helpers → helpers}/workers.d.ts +0 -0
  251. /package/{dist/polyfills → polyfills}/mdn-data-at-rules.d.ts +0 -0
  252. /package/{dist/polyfills → polyfills}/mdn-data-properties.d.ts +0 -0
  253. /package/{dist/polyfills → polyfills}/mdn-data-syntaxes.d.ts +0 -0
  254. /package/{dist/polyfills → polyfills}/module.d.ts +0 -0
  255. /package/{dist/shims → shims}/react-reconciler-constants.d.ts +0 -0
  256. /package/{dist/shims → shims}/react-reconciler.d.ts +0 -0
  257. /package/{dist/shims → shims}/set-value.d.ts +0 -0
@@ -1,32 +1,30 @@
1
- import path from "path";
2
- import fs from "fs";
3
- import { transformSync } from "esbuild";
4
- import { satisfies } from "semver";
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+ import { transformSync } from 'esbuild';
5
4
  import { createRequire } from 'node:module';
5
+ import { getPackageJson, getProjectFilePath, getProjectRootPath } from './project.js';
6
6
  const require = createRequire(import.meta.url);
7
- import { getPackageJson, getProjectFilePath } from "./project.js";
8
7
  // get the name from the package for the output
9
8
  const packageJson = getPackageJson();
10
9
  export function nsConfigToJson() {
11
10
  let configObject;
12
- ;
13
- const tsPath = getProjectFilePath("nativescript.config.ts");
14
- const tsCode = fs.readFileSync(tsPath, "utf-8");
11
+ const tsPath = getProjectFilePath('nativescript.config.ts');
12
+ const tsCode = fs.readFileSync(tsPath, 'utf-8');
15
13
  // a) Transpile your TS config to CommonJS so we can require() it
16
14
  const { code: cjsCode } = transformSync(tsCode, {
17
- loader: "ts",
18
- format: "cjs",
19
- target: "esnext",
15
+ loader: 'ts',
16
+ format: 'cjs',
17
+ target: 'esnext',
20
18
  });
21
19
  // b) Evaluate it in a VM-style sandbox to pull out the default export
22
20
  const module = { exports: {} };
23
21
  const requireFunc = (id) => require(id);
24
- new Function("exports", "require", "module", "__filename", "__dirname", cjsCode)(module.exports, requireFunc, module, tsPath, path.dirname(tsPath));
22
+ new Function('exports', 'require', 'module', '__filename', '__dirname', cjsCode)(module.exports, requireFunc, module, tsPath, path.dirname(tsPath));
25
23
  configObject = module.exports.default ?? module.exports;
26
24
  // ensure the config has a name
27
25
  configObject.name = packageJson.name;
28
26
  // ensure the main entry is set to "bundle"
29
- configObject.main = "bundle";
27
+ configObject.main = 'bundle';
30
28
  return configObject;
31
29
  }
32
30
  /**
@@ -57,38 +55,34 @@ export function resolveNativeScriptPlatformFile(id, platform) {
57
55
  * @returns string[] dependencies
58
56
  */
59
57
  export function getAllDependencies() {
60
- return [
61
- ...Object.keys(packageJson.dependencies ?? {}),
62
- ...Object.keys(packageJson.devDependencies ?? {}),
63
- ];
58
+ return [...Object.keys(packageJson.dependencies ?? {}), ...Object.keys(packageJson.devDependencies ?? {})];
64
59
  }
65
60
  /**
66
61
  * Check if a dependency is present in package.json
67
62
  */
68
63
  export function hasDependency(packageName) {
64
+ return getAllDependencies().includes(packageName);
65
+ }
66
+ /**
67
+ * Utility to get the path (usually nested in node_modules) of a dependency.
68
+ *
69
+ * @param dependencyName
70
+ */
71
+ export function getDependencyPath(dependencyName) {
69
72
  try {
70
- const packageJsonPath = path.resolve(process.cwd(), "package.json");
71
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
72
- return !!(packageJson.dependencies?.[packageName] ||
73
- packageJson.devDependencies?.[packageName] ||
74
- packageJson.peerDependencies?.[packageName]);
73
+ const resolvedPath = require.resolve(`${dependencyName}/package.json`, {
74
+ paths: [getProjectRootPath()],
75
+ });
76
+ return path.dirname(resolvedPath);
75
77
  }
76
- catch {
77
- return false;
78
+ catch (err) {
79
+ return null;
78
80
  }
79
81
  }
80
82
  /**
81
83
  * Get the version of a dependency from package.json
82
84
  */
83
85
  export function getDependencyVersion(packageName) {
84
- try {
85
- const packageJsonPath = path.resolve(process.cwd(), "package.json");
86
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
87
- return (packageJson.dependencies?.[packageName] ||
88
- packageJson.devDependencies?.[packageName] ||
89
- packageJson.peerDependencies?.[packageName]);
90
- }
91
- catch {
92
- return undefined;
93
- }
86
+ return packageJson.dependencies?.[packageName] ?? packageJson.devDependencies?.[packageName] ?? packageJson.peerDependencies?.[packageName];
94
87
  }
88
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AA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AG,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACvD,OAAO,WAAW,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,eAAe,EAAE,CAAC,WAAW,CAAC,IAAK,WAAmB,CAAC,gBAAgB,EAAE,CAAC,WAAW,CAAC,CAAC;AACtJ,CAAC"}
@@ -1,18 +1,18 @@
1
- import path from "path";
2
- import { nsConfigToJson, resolveNativeScriptPlatformFile } from "./utils.js";
1
+ import path from 'path';
2
+ import { nsConfigToJson, resolveNativeScriptPlatformFile } from './utils.js';
3
3
  export function getWorkerPlugins(platform) {
4
4
  return [
5
5
  // Handle ~/package.json virtual module for workers
6
6
  {
7
- name: "worker-virtual-package-json",
7
+ name: 'worker-virtual-package-json',
8
8
  resolveId(id) {
9
- if (id === "~/package.json") {
10
- return "\0worker:nsconfig-json"; // Use a completely different virtual ID that doesn't look like JSON
9
+ if (id === '~/package.json') {
10
+ return '\0worker:nsconfig-json'; // Use a completely different virtual ID that doesn't look like JSON
11
11
  }
12
12
  return null;
13
13
  },
14
14
  load(id) {
15
- if (id === "\0worker:nsconfig-json") {
15
+ if (id === '\0worker:nsconfig-json') {
16
16
  const configObject = nsConfigToJson();
17
17
  // Return the NativeScript config as a JavaScript module
18
18
  return `export default ${JSON.stringify(configObject, null, 2)};`;
@@ -22,13 +22,13 @@ export function getWorkerPlugins(platform) {
22
22
  },
23
23
  // Resolve NativeScript platform-specific files for workers
24
24
  {
25
- name: "nativescript-platform-resolver-worker",
25
+ name: 'nativescript-platform-resolver-worker',
26
26
  resolveId(id, importer) {
27
27
  // Handle relative imports from node_modules (not just @nativescript/core)
28
28
  if (importer) {
29
29
  const resolvedPath = path.resolve(path.dirname(importer), id);
30
30
  // Try different extensions with platform-specific resolution
31
- const extensions = [".js", ".mjs", ".ts", ".vue"];
31
+ const extensions = ['.js', '.mjs', '.ts'];
32
32
  for (const ext of extensions) {
33
33
  const testPath = resolvedPath + ext;
34
34
  // Use the existing NativeScript platform file resolver
@@ -44,14 +44,14 @@ export function getWorkerPlugins(platform) {
44
44
  },
45
45
  // Handle import.meta expressions in workers
46
46
  {
47
- name: "worker-import-meta-handler",
47
+ name: 'worker-import-meta-handler',
48
48
  transform(code, id) {
49
49
  // Replace import.meta.dirname with a static value for workers
50
- if (code.includes("import.meta.dirname")) {
50
+ if (code.includes('import.meta.dirname')) {
51
51
  code = code.replace(/import\.meta\.dirname/g, '""');
52
52
  }
53
53
  // Replace import.meta.url with a static value for workers
54
- if (code.includes("import.meta.url")) {
54
+ if (code.includes('import.meta.url')) {
55
55
  code = code.replace(/import\.meta\.url/g, '"file:///app/"');
56
56
  }
57
57
  return code;
@@ -61,11 +61,11 @@ export function getWorkerPlugins(platform) {
61
61
  }
62
62
  export function workerUrlPlugin() {
63
63
  return {
64
- name: "nativescript-worker-url-transform",
64
+ name: 'nativescript-worker-url-transform',
65
65
  generateBundle(options, bundle) {
66
66
  // Transform the main bundle to use NativeScript worker paths
67
67
  for (const [fileName, chunk] of Object.entries(bundle)) {
68
- if (chunk.type === "chunk" && !fileName.includes(".worker")) {
68
+ if (chunk.type === 'chunk' && !fileName.includes('.worker')) {
69
69
  // Transform Vite's worker URL pattern to NativeScript's expected format
70
70
  // From: new Worker(new URL(/* @vite-ignore */ "/assets/sample.worker-C6wW8q2-.js", import.meta.url))
71
71
  // To: new Worker('~/' + 'assets/sample.worker-C6wW8q2-.js')
@@ -73,9 +73,7 @@ export function workerUrlPlugin() {
73
73
  if (workerUrlRegex.test(chunk.code)) {
74
74
  chunk.code = chunk.code.replace(workerUrlRegex, (match, assetPath) => {
75
75
  // Use the full asset path including assets/ folder
76
- const fullPath = assetPath.startsWith("/")
77
- ? assetPath.slice(1)
78
- : assetPath;
76
+ const fullPath = assetPath.startsWith('/') ? assetPath.slice(1) : assetPath;
79
77
  return `new Worker('~/' + '${fullPath}')`;
80
78
  });
81
79
  }
@@ -84,3 +82,4 @@ export function workerUrlPlugin() {
84
82
  },
85
83
  };
86
84
  }
85
+ //# sourceMappingURL=workers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workers.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/workers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAE7E,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAChD,OAAO;QACN,mDAAmD;QACnD;YACC,IAAI,EAAE,6BAA6B;YACnC,SAAS,CAAC,EAAE;gBACX,IAAI,EAAE,KAAK,gBAAgB,EAAE,CAAC;oBAC7B,OAAO,wBAAwB,CAAC,CAAC,oEAAoE;gBACtG,CAAC;gBACD,OAAO,IAAI,CAAC;YACb,CAAC;YACD,IAAI,CAAC,EAAE;gBACN,IAAI,EAAE,KAAK,wBAAwB,EAAE,CAAC;oBACrC,MAAM,YAAY,GAAG,cAAc,EAAE,CAAC;oBACtC,wDAAwD;oBACxD,OAAO,kBAAkB,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC;gBACnE,CAAC;gBACD,OAAO,IAAI,CAAC;YACb,CAAC;SACD;QACD,2DAA2D;QAC3D;YACC,IAAI,EAAE,uCAAuC;YAC7C,SAAS,CAAC,EAAE,EAAE,QAAQ;gBACrB,0EAA0E;gBAC1E,IAAI,QAAQ,EAAE,CAAC;oBACd,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;oBAE9D,6DAA6D;oBAC7D,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;oBAE1C,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;wBAC9B,MAAM,QAAQ,GAA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AC,IAAI,CAAC,EAAE,CAAC;wBACrC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;4BACpE,mDAAmD;4BACnD,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;4BAC5E,OAAO,sBAAsB,QAAQ,IAAI,CAAC;wBAC3C,CAAC,CAAC,CAAC;oBACJ,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function applyCssText(cssText: string): void;
2
+ export declare function fetchText(url: string): Promise<string>;
3
+ export declare function handleCssUpdates(cssUpdates: any[], httpOrigin: string): Promise<void>;
4
+ export declare function handleCustomCss(cssText: string): void;
@@ -0,0 +1,78 @@
1
+ import { Application, Frame } from '@nativescript/core';
2
+ const VERBOSE = !!globalThis.__NS_ENV_VERBOSE__;
3
+ // CSS helper function
4
+ export function applyCssText(cssText) {
5
+ if (typeof cssText !== 'string' || !cssText.length)
6
+ return;
7
+ try {
8
+ if (Application.addCss) {
9
+ Application.addCss(cssText);
10
+ if (VERBOSE)
11
+ console.info('[ns-hmr] Applied app CSS');
12
+ }
13
+ else {
14
+ const topFrame = Frame.topmost?.();
15
+ const curPage = topFrame?.currentPage;
16
+ curPage.addCss(cssText);
17
+ if (VERBOSE)
18
+ console.info('[ns-hmr] Applied page CSS');
19
+ }
20
+ }
21
+ catch (e) {
22
+ console.warn('[ns-hmr] CSS apply failed:', e?.message || String(e));
23
+ }
24
+ }
25
+ // Fetch helper
26
+ export async function fetchText(url) {
27
+ try {
28
+ const g = globalThis;
29
+ if (typeof g.fetch === 'function') {
30
+ const res = await g.fetch(url);
31
+ return await res.text();
32
+ }
33
+ // Fallback to NativeScript Http if available
34
+ const Http = g.Http;
35
+ if (Http && Http.getString) {
36
+ return await Http.getString(url);
37
+ }
38
+ if (VERBOSE)
39
+ console.warn('[ns-hmr] No fetch method available');
40
+ return '';
41
+ }
42
+ catch (e) {
43
+ console.warn('[ns-hmr] Fetch failed:', e?.message || String(e));
44
+ return '';
45
+ }
46
+ }
47
+ // Handle CSS updates from Vite
48
+ export async function handleCssUpdates(cssUpdates, httpOrigin) {
49
+ for (const update of cssUpdates) {
50
+ try {
51
+ const path = update.path || update.acceptedPath || '';
52
+ if (!path || !httpOrigin)
53
+ continue;
54
+ // Compose URL like the Vite client (ensure raw content and cache-bust)
55
+ const hasQuery = path.includes('?');
56
+ const tParam = `t=${encodeURIComponent(String(update.timestamp || Date.now()))}`;
57
+ const directParam = hasQuery ? '&direct=1' : '?direct=1';
58
+ const tSuffix = (hasQuery ? '&' : '?') + tParam;
59
+ const url = httpOrigin + path + directParam + tSuffix;
60
+ if (VERBOSE)
61
+ console.info('[ns-hmr] Fetching CSS:', url);
62
+ const cssText = await fetchText(url);
63
+ if (cssText) {
64
+ applyCssText(cssText);
65
+ }
66
+ }
67
+ catch (e) {
68
+ console.warn('[ns-hmr] CSS update fetch/apply failed:', e?.message || String(e));
69
+ }
70
+ }
71
+ }
72
+ // Handle custom CSS events
73
+ export function handleCustomCss(cssText) {
74
+ if (typeof cssText === 'string' && cssText.length) {
75
+ applyCssText(cssText);
76
+ }
77
+ }
78
+ //# sourceMappingURL=css-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-handler.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/client/css-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACxD,MAAM,OAAO,GAAG,CAAC,CAAE,UAAkB,CAAC,kBAAkB,CAAC;AAEzD,sBAAsB;AACtB,MAAM,UAAU,YAAY,CAAC,OAAe;IAC3C,IAAI,OAAO,OAAO,KAAK,QAAQ,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;YACZ,OAAO,CAAC,IAAI,CAAC,yCAAyC,EAAE,CAAC,EAAE,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAClF,CAAC;IACF,CAAC;AACF,CAAC;AAED,2BAA2B;AAC3B,MAAM,UAAU,eAAe,CAAC,OAAe;IAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnD,YAAY,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;AACF,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Robust HMR client for NativeScript.
3
+ *
4
+ * Avoid importing from '@nativescript/core' and other framework modules here to prevent creating a second module realm via HTTP ESM.
5
+ * Always resolve core classes and Application from the vendor realm or globalThis at runtime.
6
+ * The HMR client is evaluated via HTTP ESM on device; static imports would create secondary instances.
7
+ */
8
+ export declare function initHmrClient(opts?: {
9
+ wsUrl?: string;
10
+ }): void;
11
+ export default function startViteHMR(opts?: {
12
+ wsUrl?: string;
13
+ }): void;