@akylas/nativescript-cli 8.8.7 → 8.10.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.
Files changed (85) hide show
  1. package/config/test-deps-versions-generated.json +16 -0
  2. package/docs/build-jekyll-md.sh +1 -1
  3. package/docs/man_pages/config/config-get.md +36 -0
  4. package/docs/man_pages/config/config-set.md +40 -0
  5. package/docs/man_pages/config/config.md +39 -0
  6. package/docs/man_pages/project/configuration/widget-ios.md +24 -0
  7. package/docs/man_pages/project/configuration/widget.md +24 -0
  8. package/docs/man_pages/project/hooks/hooks.md +35 -0
  9. package/docs/man_pages/start.md +2 -1
  10. package/lib/.d.ts +9 -3
  11. package/lib/bootstrap.js +4 -1
  12. package/lib/bun-package-manager.js +1 -1
  13. package/lib/color.js +38 -7
  14. package/lib/commands/build.js +18 -2
  15. package/lib/commands/clean.js +1 -2
  16. package/lib/commands/config.js +1 -1
  17. package/lib/commands/embedding/embed.js +1 -1
  18. package/lib/commands/generate.js +2 -41
  19. package/lib/commands/hooks/common.js +79 -0
  20. package/lib/commands/hooks/hooks-lock.js +100 -0
  21. package/lib/commands/hooks/hooks.js +71 -0
  22. package/lib/commands/post-install.js +2 -2
  23. package/lib/commands/typings.js +29 -18
  24. package/lib/commands/widget.js +799 -0
  25. package/lib/common/definitions/extensibility.d.ts +2 -2
  26. package/lib/common/definitions/mobile.d.ts +72 -72
  27. package/lib/common/file-system.js +1 -2
  28. package/lib/common/header.js +3 -3
  29. package/lib/common/logger/layouts/cli-layout.js +1 -1
  30. package/lib/common/logger/logger.js +5 -5
  31. package/lib/common/mobile/android/android-device.js +1 -1
  32. package/lib/common/mobile/android/android-emulator-services.js +9 -7
  33. package/lib/common/mobile/device-log-provider.js +3 -4
  34. package/lib/common/mobile/emulator-helper.js +1 -0
  35. package/lib/common/mobile/mobile-core/devices-service.js +2 -1
  36. package/lib/common/opener.js +2 -2
  37. package/lib/common/project-helper.js +15 -2
  38. package/lib/common/services/hooks-service.js +23 -6
  39. package/lib/common/verify-node-version.js +1 -1
  40. package/lib/constants.js +8 -5
  41. package/lib/controllers/migrate-controller.js +11 -12
  42. package/lib/controllers/prepare-controller.js +11 -13
  43. package/lib/controllers/run-controller.js +1 -1
  44. package/lib/declarations.d.ts +5 -0
  45. package/lib/definitions/hooks.d.ts +1 -0
  46. package/lib/definitions/ios.d.ts +11 -1
  47. package/lib/definitions/nativescript-dev-xcode.d.ts +25 -1
  48. package/lib/definitions/project.d.ts +102 -25
  49. package/lib/definitions/temp-service.d.ts +6 -2
  50. package/lib/helpers/key-command-helper.js +2 -1
  51. package/lib/nativescript-cli.js +28 -0
  52. package/lib/node-package-manager.js +1 -1
  53. package/lib/options.js +4 -0
  54. package/lib/project-data.js +10 -4
  55. package/lib/services/analytics/analytics-broker-process.js +1 -1
  56. package/lib/services/analytics/analytics-service.js +2 -1
  57. package/lib/services/analytics-settings-service.js +2 -1
  58. package/lib/services/android/gradle-build-args-service.js +8 -4
  59. package/lib/services/android/gradle-build-service.js +4 -1
  60. package/lib/services/android-plugin-build-service.js +1 -1
  61. package/lib/services/android-project-service.js +12 -10
  62. package/lib/services/assets-generation/assets-generation-service.js +33 -15
  63. package/lib/services/{webpack/webpack-compiler-service.js → bundler/bundler-compiler-service.js} +258 -88
  64. package/lib/services/bundler/bundler.js +2 -0
  65. package/lib/services/extensibility-service.js +1 -1
  66. package/lib/services/ios/spm-service.js +22 -2
  67. package/lib/services/ios/xcodebuild-args-service.js +7 -5
  68. package/lib/services/ios-debugger-port-service.js +1 -1
  69. package/lib/services/ios-project-service.js +45 -15
  70. package/lib/services/ios-watch-app-service.js +540 -16
  71. package/lib/services/livesync/android-livesync-tool.js +4 -2
  72. package/lib/services/plugins-service.js +1 -0
  73. package/lib/services/project-changes-service.js +1 -1
  74. package/lib/services/project-config-service.js +12 -3
  75. package/lib/services/temp-service.js +16 -4
  76. package/lib/services/versions-service.js +2 -1
  77. package/lib/tools/config-manipulation/config-transformer.js +9 -0
  78. package/package.json +59 -66
  79. package/vendor/aab-tool/README.txt +1 -1
  80. package/vendor/aab-tool/bundletool.jar +0 -0
  81. package/vendor/gradle-app/app/build.gradle +365 -130
  82. package/vendor/gradle-app/app/gradle.properties +45 -0
  83. package/vendor/gradle-app/build.gradle +7 -7
  84. package/vendor/gradle-plugin/build.gradle +7 -6
  85. package/lib/services/webpack/webpack.d.ts +0 -227
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.WebpackCompilerService = void 0;
9
+ exports.BundlerCompilerService = void 0;
10
10
  const path = require("path");
11
11
  const semver = require("semver");
12
12
  const _ = require("lodash");
@@ -15,8 +15,9 @@ const decorators_1 = require("../../common/decorators");
15
15
  const constants_1 = require("../../constants");
16
16
  const yok_1 = require("../../common/yok");
17
17
  const package_path_helper_1 = require("../../helpers/package-path-helper");
18
- class WebpackCompilerService extends events_1.EventEmitter {
19
- constructor($options, $errors, $childProcess, $fs, $hooksService, $hostInfo, $logger, $mobileHelper, $cleanupService, $packageManager, $packageInstallationManager) {
18
+ const debugLog = false;
19
+ class BundlerCompilerService extends events_1.EventEmitter {
20
+ constructor($options, $errors, $childProcess, $fs, $hooksService, $hostInfo, $logger, $mobileHelper, $cleanupService, $packageManager, $packageInstallationManager, $projectConfigService) {
20
21
  super();
21
22
  this.$options = $options;
22
23
  this.$errors = $errors;
@@ -29,19 +30,21 @@ class WebpackCompilerService extends events_1.EventEmitter {
29
30
  this.$cleanupService = $cleanupService;
30
31
  this.$packageManager = $packageManager;
31
32
  this.$packageInstallationManager = $packageInstallationManager;
32
- this.webpackProcesses = {};
33
+ this.$projectConfigService = $projectConfigService;
34
+ this.bundlerProcesses = {};
33
35
  this.expectedHashes = {};
34
36
  }
35
37
  async compileWithWatch(platformData, projectData, prepareData) {
36
38
  return new Promise(async (resolve, reject) => {
37
- if (this.webpackProcesses[platformData.platformNameLowerCase]) {
39
+ if (this.bundlerProcesses[platformData.platformNameLowerCase]) {
38
40
  resolve(void 0);
39
41
  return;
40
42
  }
41
- let isFirstWebpackWatchCompilation = true;
43
+ let isFirstBundlerWatchCompilation = true;
42
44
  prepareData.watch = true;
43
45
  try {
44
- const childProcess = await this.startWebpackProcess(platformData, projectData, prepareData);
46
+ const childProcess = await this.startBundleProcess(platformData, projectData, prepareData);
47
+ const isVite = this.getBundler() === "vite";
45
48
  childProcess.stdout.on("data", function (data) {
46
49
  process.stdout.write(data);
47
50
  });
@@ -49,25 +52,77 @@ class WebpackCompilerService extends events_1.EventEmitter {
49
52
  process.stderr.write(data);
50
53
  });
51
54
  childProcess.on("message", (message) => {
52
- this.$logger.trace("Message from webpack", message);
55
+ this.$logger.trace(`Message from ${projectData.bundler}`, message);
56
+ if (isVite &&
57
+ message &&
58
+ message.emittedFiles) {
59
+ message = message;
60
+ if (debugLog) {
61
+ console.log("Received Vite IPC message:", message);
62
+ }
63
+ const distOutput = path.join(projectData.projectDir, ".ns-vite-build");
64
+ const destDir = path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName);
65
+ if (debugLog) {
66
+ console.log(`Copying from ${distOutput} to ${destDir}.`);
67
+ }
68
+ if (message.buildType === "incremental" &&
69
+ message.emittedFiles &&
70
+ message.emittedFiles.length > 0) {
71
+ const filesToCopy = this.getIncrementalFilesToCopy(message.emittedFiles);
72
+ if (debugLog) {
73
+ console.log("Incremental build - files to copy:", filesToCopy);
74
+ }
75
+ this.copyViteBundleToNative(distOutput, destDir, filesToCopy);
76
+ }
77
+ else {
78
+ if (debugLog) {
79
+ console.log("Full build - copying all files.");
80
+ }
81
+ this.copyViteBundleToNative(distOutput, destDir);
82
+ }
83
+ if (isFirstBundlerWatchCompilation) {
84
+ isFirstBundlerWatchCompilation = false;
85
+ if (debugLog) {
86
+ console.log("Vite first build completed, resolving compileWithWatch");
87
+ }
88
+ resolve(childProcess);
89
+ }
90
+ const files = message.emittedFiles.map((file) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, file));
91
+ const data = {
92
+ files,
93
+ hasOnlyHotUpdateFiles: message.isHMR || false,
94
+ hmrData: {
95
+ hash: message.hash || "",
96
+ fallbackFiles: [],
97
+ },
98
+ platform: platformData.platformNameLowerCase,
99
+ };
100
+ this.$logger.info(`Vite build completed! Files copied to native platform.`);
101
+ if (debugLog) {
102
+ console.log("Emitting BUNDLER_COMPILATION_COMPLETE for full build.");
103
+ }
104
+ this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, data);
105
+ return;
106
+ }
53
107
  if (typeof message === "object" &&
54
108
  "version" in message &&
55
109
  "type" in message) {
56
- if (isFirstWebpackWatchCompilation) {
57
- isFirstWebpackWatchCompilation = false;
110
+ if (isFirstBundlerWatchCompilation) {
111
+ isFirstBundlerWatchCompilation = false;
58
112
  resolve(childProcess);
59
113
  return;
60
114
  }
61
115
  return this.handleHMRMessage(message, platformData, projectData, prepareData);
62
116
  }
63
- if (message === "Webpack compilation complete.") {
64
- this.$logger.info("Webpack build done!");
117
+ if (message ===
118
+ `${capitalizeFirstLetter(projectData.bundler)} compilation complete.`) {
119
+ this.$logger.info(`${capitalizeFirstLetter(projectData.bundler)} build done!`);
65
120
  resolve(childProcess);
66
121
  }
67
122
  message = message;
68
123
  if (message.emittedFiles) {
69
- if (isFirstWebpackWatchCompilation) {
70
- isFirstWebpackWatchCompilation = false;
124
+ if (isFirstBundlerWatchCompilation) {
125
+ isFirstBundlerWatchCompilation = false;
71
126
  this.expectedHashes[platformData.platformNameLowerCase] =
72
127
  prepareData.hmr ? message.hash : "";
73
128
  return;
@@ -95,27 +150,27 @@ class WebpackCompilerService extends events_1.EventEmitter {
95
150
  },
96
151
  platform: platformData.platformNameLowerCase,
97
152
  };
98
- this.$logger.trace("Generated data from webpack message:", data);
153
+ this.$logger.trace(`Generated data from ${projectData.bundler} message:`, data);
99
154
  if (data.hasOnlyHotUpdateFiles && previousHash === message.hash) {
100
155
  return;
101
156
  }
102
157
  if (data.files.length) {
103
- this.emit(constants_1.WEBPACK_COMPILATION_COMPLETE, data);
158
+ this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, data);
104
159
  }
105
160
  }
106
161
  });
107
162
  childProcess.on("error", (err) => {
108
- this.$logger.trace(`Unable to start webpack process in watch mode. Error is: ${err}`);
109
- delete this.webpackProcesses[platformData.platformNameLowerCase];
163
+ this.$logger.trace(`Unable to start ${projectData.bundler} process in watch mode. Error is: ${err}`);
164
+ delete this.bundlerProcesses[platformData.platformNameLowerCase];
110
165
  reject(err);
111
166
  });
112
167
  childProcess.on("close", async (arg) => {
113
- await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
114
168
  const exitCode = typeof arg === "number" ? arg : arg && arg.code;
115
- this.$logger.trace(`Webpack process exited with code ${exitCode} when we expected it to be long living with watch.`);
116
- const error = new Error(`Executing webpack failed with exit code ${exitCode}.`);
169
+ this.$logger.trace(`${capitalizeFirstLetter(projectData.bundler)} process exited with code ${exitCode} when we expected it to be long living with watch.`);
170
+ await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
171
+ const error = new Error(`Executing ${projectData.bundler} failed with exit code ${exitCode}.`);
117
172
  error.code = exitCode;
118
- delete this.webpackProcesses[platformData.platformNameLowerCase];
173
+ delete this.bundlerProcesses[platformData.platformNameLowerCase];
119
174
  reject(error);
120
175
  });
121
176
  }
@@ -126,26 +181,26 @@ class WebpackCompilerService extends events_1.EventEmitter {
126
181
  }
127
182
  async compileWithoutWatch(platformData, projectData, prepareData) {
128
183
  return new Promise(async (resolve, reject) => {
129
- if (this.webpackProcesses[platformData.platformNameLowerCase]) {
184
+ if (this.bundlerProcesses[platformData.platformNameLowerCase]) {
130
185
  resolve();
131
186
  return;
132
187
  }
133
188
  try {
134
- const childProcess = await this.startWebpackProcess(platformData, projectData, prepareData);
189
+ const childProcess = await this.startBundleProcess(platformData, projectData, prepareData);
135
190
  childProcess.on("error", (err) => {
136
- this.$logger.trace(`Unable to start webpack process in non-watch mode. Error is: ${err}`);
137
- delete this.webpackProcesses[platformData.platformNameLowerCase];
191
+ this.$logger.trace(`Unable to start ${projectData.bundler} process in non-watch mode. Error is: ${err}`);
192
+ delete this.bundlerProcesses[platformData.platformNameLowerCase];
138
193
  reject(err);
139
194
  });
140
195
  childProcess.on("close", async (arg) => {
141
196
  await this.$cleanupService.removeKillProcess(childProcess.pid.toString());
142
- delete this.webpackProcesses[platformData.platformNameLowerCase];
197
+ delete this.bundlerProcesses[platformData.platformNameLowerCase];
143
198
  const exitCode = typeof arg === "number" ? arg : arg && arg.code;
144
199
  if (exitCode === 0) {
145
200
  resolve();
146
201
  }
147
202
  else {
148
- const error = new Error(`Executing webpack failed with exit code ${exitCode}.`);
203
+ const error = new Error(`Executing ${projectData.bundler} failed with exit code ${exitCode}.`);
149
204
  error.code = exitCode;
150
205
  reject(error);
151
206
  }
@@ -156,14 +211,14 @@ class WebpackCompilerService extends events_1.EventEmitter {
156
211
  }
157
212
  });
158
213
  }
159
- async stopWebpackCompiler(platform) {
214
+ async stopBundlerCompiler(platform) {
160
215
  if (platform) {
161
- await this.stopWebpackForPlatform(platform);
216
+ await this.stopBundlerForPlatform(platform);
162
217
  }
163
218
  else {
164
- const webpackedPlatforms = Object.keys(this.webpackProcesses);
165
- for (let i = 0; i < webpackedPlatforms.length; i++) {
166
- await this.stopWebpackForPlatform(webpackedPlatforms[i]);
219
+ const bundlerPlatforms = Object.keys(this.bundlerProcesses);
220
+ for (let i = 0; i < bundlerPlatforms.length; i++) {
221
+ await this.stopBundlerForPlatform(bundlerPlatforms[i]);
167
222
  }
168
223
  }
169
224
  }
@@ -172,12 +227,28 @@ class WebpackCompilerService extends events_1.EventEmitter {
172
227
  const res = currentPackageManager !== constants_1.PackageManagers.pnpm;
173
228
  return res;
174
229
  }
175
- async startWebpackProcess(platformData, projectData, prepareData) {
176
- if (!this.$fs.exists(projectData.webpackConfigPath)) {
177
- this.$errors.fail(`The webpack configuration file ${projectData.webpackConfigPath} does not exist. Ensure the file exists, or update the path in ${constants_1.CONFIG_FILE_NAME_DISPLAY}.`);
230
+ async startBundleProcess(platformData, projectData, prepareData) {
231
+ if (projectData.bundlerConfigPath) {
232
+ if (!this.$fs.exists(projectData.bundlerConfigPath)) {
233
+ this.$errors.fail(`The bundler configuration file ${projectData.bundlerConfigPath} does not exist. Ensure the file exists, or update the path in ${constants_1.CONFIG_FILE_NAME_DISPLAY}.`);
234
+ }
235
+ }
236
+ else {
237
+ if (!this.$fs.exists(projectData.bundlerConfigPath)) {
238
+ this.$errors.fail(`The ${projectData.bundler} configuration file ${projectData.bundlerConfigPath} does not exist. Ensure the file exists, or update the path in ${constants_1.CONFIG_FILE_NAME_DISPLAY}.`);
239
+ }
178
240
  }
179
241
  const envData = this.buildEnvData(platformData.platformNameLowerCase, projectData, prepareData);
180
- const envParams = await this.buildEnvCommandLineParams(envData, platformData, projectData, prepareData);
242
+ const isVite = this.getBundler() === "vite";
243
+ const cliArgs = await this.buildEnvCommandLineParams(envData, platformData, projectData, prepareData);
244
+ const envParams = isVite
245
+ ? [
246
+ `--mode=${prepareData.release ? "production" : "development"}`,
247
+ `--watch`,
248
+ "--",
249
+ ...cliArgs,
250
+ ]
251
+ : cliArgs;
181
252
  const additionalNodeArgs = semver.major(process.version) <= 8 ? ["--harmony"] : [];
182
253
  if (await this.shouldUsePreserveSymlinksOption()) {
183
254
  additionalNodeArgs.push("--preserve-symlinks");
@@ -187,22 +258,26 @@ class WebpackCompilerService extends events_1.EventEmitter {
187
258
  }
188
259
  const args = [
189
260
  ...additionalNodeArgs,
190
- this.getWebpackExecutablePath(projectData),
191
- this.isWebpack5(projectData) ? `build` : null,
192
- `--config=${projectData.webpackConfigPath}`,
261
+ this.getBundlerExecutablePath(projectData),
262
+ isVite || this.isModernBundler(projectData) ? "build" : null,
263
+ `--config=${projectData.bundlerConfigPath}`,
193
264
  ...envParams,
194
265
  ].filter(Boolean);
195
- if (prepareData.watch) {
196
- args.push("--watch");
266
+ if (!isVite) {
267
+ if (prepareData.watch) {
268
+ args.push("--watch");
269
+ }
197
270
  }
198
- const stdio = prepareData.watch ? ["ipc"] : "inherit";
271
+ const stdio = prepareData.watch || isVite ? ["ipc"] : "inherit";
199
272
  const options = {
200
273
  cwd: projectData.projectDir,
201
274
  stdio,
202
275
  };
203
- options.env = Object.assign(process.env, {
204
- NATIVESCRIPT_WEBPACK_ENV: JSON.stringify(envData)
205
- });
276
+ options.env = {
277
+ ...process.env,
278
+ NATIVESCRIPT_WEBPACK_ENV: JSON.stringify(envData),
279
+ NATIVESCRIPT_BUNDLER_ENV: JSON.stringify(envData),
280
+ };
206
281
  if (this.$hostInfo.isWindows) {
207
282
  Object.assign(options.env, { APPDATA: process.env.appData });
208
283
  }
@@ -213,8 +288,11 @@ class WebpackCompilerService extends events_1.EventEmitter {
213
288
  USER_PROJECT_PLATFORMS_IOS: this.$options.hostProjectPath,
214
289
  });
215
290
  }
291
+ if (debugLog) {
292
+ console.log("args:", args);
293
+ }
216
294
  const childProcess = this.$childProcess.spawn(process.execPath, args, options);
217
- this.webpackProcesses[platformData.platformNameLowerCase] = childProcess;
295
+ this.bundlerProcesses[platformData.platformNameLowerCase] = childProcess;
218
296
  await this.$cleanupService.addKillProcess(childProcess.pid.toString());
219
297
  return childProcess;
220
298
  }
@@ -260,13 +338,15 @@ class WebpackCompilerService extends events_1.EventEmitter {
260
338
  envFlagNames.splice(envFlagNames.indexOf("snapshot"), 1);
261
339
  }
262
340
  else if (this.$hostInfo.isWindows) {
263
- const minWebpackPluginWithWinSnapshotsVersion = "1.3.0";
264
- const installedWebpackPluginVersion = await this.$packageInstallationManager.getInstalledDependencyVersion(constants_1.WEBPACK_PLUGIN_NAME, projectData.projectDir);
265
- const hasWebpackPluginWithWinSnapshotsSupport = !!installedWebpackPluginVersion
266
- ? semver.gte(semver.coerce(installedWebpackPluginVersion), minWebpackPluginWithWinSnapshotsVersion)
267
- : true;
268
- if (!hasWebpackPluginWithWinSnapshotsSupport) {
269
- this.$errors.fail(`In order to generate Snapshots on Windows, please upgrade your Webpack plugin version (npm i ${constants_1.WEBPACK_PLUGIN_NAME}@latest).`);
341
+ if (projectData.bundler === "webpack") {
342
+ const minWebpackPluginWithWinSnapshotsVersion = "1.3.0";
343
+ const installedWebpackPluginVersion = await this.$packageInstallationManager.getInstalledDependencyVersion(constants_1.WEBPACK_PLUGIN_NAME, projectData.projectDir);
344
+ const hasWebpackPluginWithWinSnapshotsSupport = !!installedWebpackPluginVersion
345
+ ? semver.gte(semver.coerce(installedWebpackPluginVersion), minWebpackPluginWithWinSnapshotsVersion)
346
+ : true;
347
+ if (!hasWebpackPluginWithWinSnapshotsSupport) {
348
+ this.$errors.fail(`In order to generate Snapshots on Windows, please upgrade your Webpack plugin version (npm i ${constants_1.WEBPACK_PLUGIN_NAME}@latest).`);
349
+ }
270
350
  }
271
351
  }
272
352
  }
@@ -317,21 +397,21 @@ class WebpackCompilerService extends events_1.EventEmitter {
317
397
  }
318
398
  return hotHash || "";
319
399
  }
320
- async stopWebpackForPlatform(platform) {
321
- this.$logger.trace(`Stopping webpack watch for platform ${platform}.`);
322
- const webpackProcess = this.webpackProcesses[platform];
323
- await this.$cleanupService.removeKillProcess(webpackProcess.pid.toString());
324
- if (webpackProcess) {
325
- webpackProcess.kill("SIGINT");
326
- delete this.webpackProcesses[platform];
400
+ async stopBundlerForPlatform(platform) {
401
+ this.$logger.trace(`Stopping ${this.getBundler()} watch for platform ${platform}.`);
402
+ const bundlerProcess = this.bundlerProcesses[platform];
403
+ await this.$cleanupService.removeKillProcess(bundlerProcess.pid.toString());
404
+ if (bundlerProcess) {
405
+ bundlerProcess.kill("SIGINT");
406
+ delete this.bundlerProcesses[platform];
327
407
  }
328
408
  }
329
409
  handleHMRMessage(message, platformData, projectData, prepareData) {
330
- this.$logger.trace("Received message from webpack process:", message);
410
+ this.$logger.trace(`Received message from ${projectData.bundler} process:`, message);
331
411
  if (message.type !== "compilation") {
332
412
  return;
333
413
  }
334
- this.$logger.trace("Webpack build done!");
414
+ this.$logger.trace(`${capitalizeFirstLetter(projectData.bundler)} build done!`);
335
415
  const files = message.data.emittedAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, asset));
336
416
  const staleFiles = message.data.staleAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, this.$options.hostProjectModuleName, asset));
337
417
  const lastHash = (() => {
@@ -348,7 +428,7 @@ class WebpackCompilerService extends events_1.EventEmitter {
348
428
  if (!files.length) {
349
429
  return;
350
430
  }
351
- this.emit(constants_1.WEBPACK_COMPILATION_COMPLETE, {
431
+ this.emit(constants_1.BUNDLER_COMPILATION_COMPLETE, {
352
432
  files,
353
433
  staleFiles,
354
434
  hasOnlyHotUpdateFiles: prepareData.hmr,
@@ -359,41 +439,131 @@ class WebpackCompilerService extends events_1.EventEmitter {
359
439
  platform: platformData.platformNameLowerCase,
360
440
  });
361
441
  }
362
- getWebpackExecutablePath(projectData) {
363
- if (this.isWebpack5(projectData)) {
364
- const packageName = projectData.nsConfig.webpackPackageName || constants_1.WEBPACK_PLUGIN_NAME;
365
- let packagePath = (0, package_path_helper_1.resolvePackagePath)(packageName, {
442
+ getBundlerExecutablePath(projectData) {
443
+ const bundler = this.getBundler();
444
+ if (bundler === "vite") {
445
+ const packagePath = (0, package_path_helper_1.resolvePackagePath)(`vite`, {
366
446
  paths: [projectData.projectDir],
367
447
  });
368
448
  if (packagePath) {
369
- return path.resolve(packagePath, "dist", "bin", "index.js");
449
+ return path.resolve(packagePath, "bin", "vite.js");
370
450
  }
371
451
  }
372
- const packagePath = (0, package_path_helper_1.resolvePackagePath)("webpack", {
373
- paths: [projectData.projectDir],
374
- });
375
- if (!packagePath) {
376
- return "";
452
+ else if (this.isModernBundler(projectData)) {
453
+ const webpackPluginName = this.$projectConfigService.getValue(`webpackPackageName`, constants_1.WEBPACK_PLUGIN_NAME);
454
+ const packagePath = (0, package_path_helper_1.resolvePackagePath)(webpackPluginName, {
455
+ paths: [projectData.projectDir],
456
+ });
457
+ if (packagePath) {
458
+ return path.resolve(packagePath, "dist", "bin", "index.js");
459
+ }
377
460
  }
378
- return path.resolve(packagePath, "bin", "webpack.js");
461
+ throw new Error('could not find bundler executable');
379
462
  }
380
- isWebpack5(projectData) {
381
- const packageName = projectData.nsConfig.webpackPackageName || constants_1.WEBPACK_PLUGIN_NAME;
382
- const packageJSONPath = (0, package_path_helper_1.resolvePackageJSONPath)(packageName, {
383
- paths: [projectData.projectDir],
384
- });
385
- if (packageJSONPath) {
386
- const packageData = this.$fs.readJson(packageJSONPath);
387
- const ver = semver.coerce(packageData.version);
388
- if (semver.satisfies(ver, ">= 5.0.0")) {
463
+ isModernBundler(projectData) {
464
+ const bundler = this.getBundler();
465
+ switch (bundler) {
466
+ case "rspack":
389
467
  return true;
390
- }
468
+ default:
469
+ const webpackPluginName = this.$projectConfigService.getValue(`webpackPackageName`, constants_1.WEBPACK_PLUGIN_NAME);
470
+ const packageJSONPath = (0, package_path_helper_1.resolvePackageJSONPath)(webpackPluginName, {
471
+ paths: [projectData.projectDir],
472
+ });
473
+ if (packageJSONPath) {
474
+ const packageData = this.$fs.readJson(packageJSONPath);
475
+ const ver = semver.coerce(packageData.version);
476
+ if (semver.satisfies(ver, ">= 5.0.0")) {
477
+ return true;
478
+ }
479
+ }
480
+ break;
391
481
  }
392
482
  return false;
393
483
  }
484
+ getBundler() {
485
+ return this.$projectConfigService.getValue(`bundler`, "webpack");
486
+ }
487
+ copyViteBundleToNative(distOutput, destDir, specificFiles = null) {
488
+ if (debugLog) {
489
+ console.log(`Copying Vite bundle from "${distOutput}" to "${destDir}".`);
490
+ }
491
+ try {
492
+ if (specificFiles) {
493
+ if (debugLog) {
494
+ console.log("Selective copy - copying specific files:", specificFiles);
495
+ }
496
+ this.$fs.createDirectory(destDir);
497
+ for (const file of specificFiles) {
498
+ const srcPath = path.join(distOutput, file);
499
+ const destPath = path.join(destDir, file);
500
+ if (!this.$fs.exists(srcPath))
501
+ continue;
502
+ this.$fs.createDirectory(path.dirname(destPath));
503
+ this.$fs.copyFile(srcPath, destPath);
504
+ if (debugLog) {
505
+ console.log(`Copied ${file}`);
506
+ }
507
+ }
508
+ }
509
+ else {
510
+ if (debugLog) {
511
+ console.log("Full build: Copying all files.");
512
+ }
513
+ if (this.$fs.exists(destDir)) {
514
+ this.$fs.deleteDirectory(destDir);
515
+ }
516
+ this.$fs.createDirectory(destDir);
517
+ if (this.$fs.exists(distOutput)) {
518
+ this.copyRecursiveSync(distOutput, destDir);
519
+ }
520
+ else {
521
+ this.$logger.warn(`Vite output directory does not exist: ${distOutput}`);
522
+ }
523
+ }
524
+ }
525
+ catch (error) {
526
+ this.$logger.warn(`Failed to copy Vite bundle: ${error.message}`);
527
+ }
528
+ }
529
+ getIncrementalFilesToCopy(emittedFiles) {
530
+ const filesToCopy = [];
531
+ const bundleFiles = emittedFiles.filter((file) => !file.includes("vendor") &&
532
+ (file.endsWith(".mjs") ||
533
+ file.endsWith(".js") ||
534
+ file.endsWith(".map")));
535
+ filesToCopy.push(...bundleFiles);
536
+ const assetFiles = emittedFiles.filter((file) => file.includes("assets/") ||
537
+ file.includes("static/") ||
538
+ file.includes("fonts/") ||
539
+ file.includes("images/"));
540
+ if (assetFiles.length > 0) {
541
+ filesToCopy.push(...assetFiles);
542
+ }
543
+ return [...new Set(filesToCopy)];
544
+ }
545
+ copyRecursiveSync(src, dest) {
546
+ this.$fs.createDirectory(dest);
547
+ const entries = this.$fs.readDirectory(src);
548
+ for (const name of entries) {
549
+ const srcPath = path.join(src, name);
550
+ const destPath = path.join(dest, name);
551
+ const lstats = this.$fs.getLsStats(srcPath);
552
+ if (lstats.isDirectory()) {
553
+ this.copyRecursiveSync(srcPath, destPath);
554
+ }
555
+ else if (lstats.isFile() || lstats.isSymbolicLink()) {
556
+ this.$fs.createDirectory(path.dirname(destPath));
557
+ this.$fs.copyFile(srcPath, destPath);
558
+ }
559
+ }
560
+ }
394
561
  }
395
- exports.WebpackCompilerService = WebpackCompilerService;
562
+ exports.BundlerCompilerService = BundlerCompilerService;
396
563
  __decorate([
397
564
  (0, decorators_1.performanceLog)()
398
- ], WebpackCompilerService.prototype, "startWebpackProcess", null);
399
- yok_1.injector.register("webpackCompilerService", WebpackCompilerService);
565
+ ], BundlerCompilerService.prototype, "startBundleProcess", null);
566
+ function capitalizeFirstLetter(val) {
567
+ return String(val).charAt(0).toUpperCase() + String(val).slice(1);
568
+ }
569
+ yok_1.injector.register("bundlerCompilerService", BundlerCompilerService);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -138,7 +138,7 @@ class ExtensibilityService {
138
138
  return {
139
139
  extensionName,
140
140
  registeredCommandName: currentCommand,
141
- installationMessage: `The command ${beautifiedCommandName} is registered in extension ${extensionName}. You can install it by executing 'tns extension install ${extensionName}'`,
141
+ installationMessage: `The command ${beautifiedCommandName} is registered in extension ${extensionName}. You can install it by executing 'ns extension install ${extensionName}'`,
142
142
  };
143
143
  }
144
144
  copyOfFullArgs.splice(-1, 1);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SPMService = void 0;
4
4
  const yok_1 = require("../../common/yok");
5
- const trapezedev_project_1 = require("@rigor789/trapezedev-project");
5
+ const trapezedev_project_1 = require("@nstudio/trapezedev-project");
6
6
  const path = require("path");
7
7
  class SPMService {
8
8
  constructor($logger, $projectConfigService, $xcodebuildCommandService, $xcodebuildArgsService) {
@@ -15,9 +15,24 @@ class SPMService {
15
15
  const spmPackages = this.$projectConfigService.getValue(`${platform}.SPMPackages`, []);
16
16
  return spmPackages;
17
17
  }
18
- async applySPMPackages(platformData, projectData) {
18
+ mergePluginSPMPackages(appPackages, pluginPackages) {
19
+ const appPackageNames = new Set(appPackages.map(pkg => pkg.name));
20
+ for (const pluginPkg of pluginPackages) {
21
+ if (appPackageNames.has(pluginPkg.name)) {
22
+ this.$logger.trace(`SPM: app package overrides plugin package: ${pluginPkg.name}`);
23
+ }
24
+ else {
25
+ appPackages.push(pluginPkg);
26
+ }
27
+ }
28
+ }
29
+ async applySPMPackages(platformData, projectData, pluginSpmPackages) {
30
+ var _a;
19
31
  try {
20
32
  const spmPackages = this.getSPMPackages(projectData, platformData.platformNameLowerCase);
33
+ if (pluginSpmPackages === null || pluginSpmPackages === void 0 ? void 0 : pluginSpmPackages.length) {
34
+ this.mergePluginSPMPackages(spmPackages, pluginSpmPackages);
35
+ }
21
36
  if (!spmPackages.length) {
22
37
  this.$logger.trace("SPM: no SPM packages to apply.");
23
38
  return;
@@ -40,6 +55,11 @@ class SPMService {
40
55
  }
41
56
  this.$logger.trace(`SPM: adding package ${pkg.name} to project.`, pkg);
42
57
  await project.ios.addSPMPackage(projectData.projectName, pkg);
58
+ if ((_a = pkg.targets) === null || _a === void 0 ? void 0 : _a.length) {
59
+ for (const target of pkg.targets) {
60
+ await project.ios.addSPMPackage(target, pkg);
61
+ }
62
+ }
43
63
  }
44
64
  await project.commit();
45
65
  await this.resolveSPMDependencies(platformData, projectData);
@@ -27,7 +27,7 @@ class XcodebuildArgsService {
27
27
  let destination = "generic/platform=iOS Simulator";
28
28
  let isvisionOS = this.$devicePlatformsConstants.isvisionOS(buildConfig.platform);
29
29
  if (isvisionOS) {
30
- destination = "platform=visionOS Simulator";
30
+ destination = "generic/platform=visionOS Simulator";
31
31
  if (buildConfig._device) {
32
32
  destination += `,id=${buildConfig._device.deviceInfo.identifier}`;
33
33
  }
@@ -40,7 +40,9 @@ class XcodebuildArgsService {
40
40
  "-configuration",
41
41
  buildConfig.release ? constants_1.Configurations.Release : constants_1.Configurations.Debug,
42
42
  ])
43
- .concat(this.getBuildCommonArgs(platformData, projectData, isvisionOS ? ios_project_service_1.VisionSimulatorPlatformSdkName : ios_project_service_1.SimulatorPlatformSdkName))
43
+ .concat(this.getBuildCommonArgs(platformData, projectData, isvisionOS
44
+ ? ios_project_service_1.VisionSimulatorPlatformSdkName
45
+ : ios_project_service_1.SimulatorPlatformSdkName))
44
46
  .concat(this.getBuildLoggingArgs())
45
47
  .concat(this.getXcodeProjectArgs(platformData, projectData));
46
48
  return args;
@@ -51,7 +53,7 @@ class XcodebuildArgsService {
51
53
  let destination = "generic/platform=iOS";
52
54
  let isvisionOS = this.$devicePlatformsConstants.isvisionOS(buildConfig.platform);
53
55
  if (isvisionOS) {
54
- destination = "platform=visionOS";
56
+ destination = "generic/platform=visionOS";
55
57
  if (buildConfig._device) {
56
58
  destination += `,id=${buildConfig._device.deviceInfo.identifier}`;
57
59
  }
@@ -68,14 +70,14 @@ class XcodebuildArgsService {
68
70
  ]
69
71
  .concat(this.getXcodeProjectArgs(platformData, projectData))
70
72
  .concat(architectures)
71
- .concat(this.getBuildCommonArgs(platformData, projectData, ios_project_service_1.DevicePlatformSdkName))
73
+ .concat(this.getBuildCommonArgs(platformData, projectData, isvisionOS ? ios_project_service_1.VisionDevicePlatformSdkName : ios_project_service_1.DevicePlatformSdkName))
72
74
  .concat(this.getBuildLoggingArgs());
73
75
  return args;
74
76
  }
75
77
  async getArchitecturesArgs(buildConfig) {
76
78
  const args = [];
77
79
  if (this.$devicePlatformsConstants.isvisionOS(buildConfig.platform)) {
78
- args.push("ONLY_ACTIVE_ARCH=YES");
80
+ args.push("ONLY_ACTIVE_ARCH=YES", "EXCLUDED_ARCHS=x86_64");
79
81
  return args;
80
82
  }
81
83
  const devicesArchitectures = buildConfig.buildForDevice
@@ -111,7 +111,7 @@ class IOSDebuggerPortService {
111
111
  }
112
112
  clearTimeout(data) {
113
113
  const storedData = this.mapDebuggerPortData[`${data.deviceId}${data.appId}`];
114
- if (storedData && storedData.timer) {
114
+ if (storedData && typeof storedData.timer === "number") {
115
115
  clearTimeout(storedData.timer);
116
116
  }
117
117
  }