nativescript 8.2.3 → 8.2.4-alpha.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.
@@ -1 +1 @@
1
- {"@jsdevtools/coverage-istanbul-loader":"3.0.5","karma":"6.3.17","karma-coverage":"2.2.0","karma-nativescript-launcher":"0.4.0","mocha":"9.2.2","karma-mocha":"2.0.1","karma-chai":"0.1.0","karma-jasmine":"4.0.1","karma-qunit":"4.1.2","@types/karma-chai":"0.1.3","@types/mocha":"9.1.0","@types/jasmine":"4.0.0","@types/qunit":"2.11.3","nyc":"15.1.0"}
1
+ {"@jsdevtools/coverage-istanbul-loader":"3.0.5","karma":"6.3.19","karma-coverage":"2.2.0","karma-nativescript-launcher":"0.4.0","mocha":"9.2.2","karma-mocha":"2.0.1","karma-chai":"0.1.0","karma-jasmine":"5.0.0","karma-qunit":"4.1.2","@types/karma-chai":"0.1.3","@types/mocha":"9.1.1","@types/jasmine":"4.0.3","@types/qunit":"2.11.3","nyc":"15.1.0"}
@@ -82,7 +82,7 @@ class CreateProjectCommand {
82
82
  selectedTemplate = yield this.interactiveFlavorAndTemplateSelection(getNextInteractiveAdverb(), getNextInteractiveAdverb());
83
83
  }
84
84
  this.createdProjectData = yield this.$projectService.createProject({
85
- projectName: projectName,
85
+ projectName: projectName === null || projectName === void 0 ? void 0 : projectName.toLowerCase(),
86
86
  template: selectedTemplate,
87
87
  appId: this.$options.appid,
88
88
  pathToProject: this.$options.path,
@@ -47,6 +47,7 @@ class RunController extends events_1.EventEmitter {
47
47
  this.$projectChangesService = $projectChangesService;
48
48
  this.$projectDataService = $projectDataService;
49
49
  this.prepareReadyEventHandler = null;
50
+ this.currentStartingHash = "";
50
51
  }
51
52
  run(runData) {
52
53
  return __awaiter(this, void 0, void 0, function* () {
@@ -423,15 +424,40 @@ class RunController extends events_1.EventEmitter {
423
424
  const fullLiveSyncResultInfo = yield platformLiveSyncService.liveSyncWatchAction(device, watchInfo);
424
425
  _.assign(liveSyncResultInfo, fullLiveSyncResultInfo);
425
426
  });
427
+ yield this.$hooksService.executeBeforeHooks("watchAction", {
428
+ hookArgs: {
429
+ liveSyncResultInfo,
430
+ filesToSync,
431
+ allAppFiles,
432
+ isInHMRMode,
433
+ filesChangedEvent: data,
434
+ },
435
+ });
426
436
  yield this.refreshApplication(projectData, liveSyncResultInfo, data, deviceDescriptor, fullSyncAction);
427
- if (!liveSyncResultInfo.didRecover && isInHMRMode) {
437
+ const startingHash = this.$hmrStatusService.getStartingHash();
438
+ if (!liveSyncResultInfo.didRecover &&
439
+ isInHMRMode &&
440
+ filesToSync.some((file) => file.includes("hot-update")) &&
441
+ (!startingHash ||
442
+ this.currentStartingHash === startingHash ||
443
+ startingHash === data.hmrData.hash)) {
444
+ this.currentStartingHash = startingHash;
445
+ console.time("hmrStatus");
428
446
  const status = yield this.$hmrStatusService.getHmrStatus(device.deviceInfo.identifier, data.hmrData.hash);
447
+ console.timeEnd("hmrStatus");
429
448
  if (status === constants_1.HmrConstants.HMR_ERROR_STATUS) {
430
449
  yield fullSyncAction();
431
450
  liveSyncResultInfo.isFullSync = true;
432
451
  yield this.refreshApplication(projectData, liveSyncResultInfo, data, deviceDescriptor);
433
452
  }
434
453
  }
454
+ yield this.$hooksService.executeAfterHooks("watchAction", {
455
+ liveSyncResultInfo,
456
+ filesToSync,
457
+ allAppFiles,
458
+ filesChangedEvent: data,
459
+ isInHMRMode,
460
+ });
435
461
  this.$logger.info(util.format(successfullySyncedMessageFormat, deviceAppData.appIdentifier, device.deviceInfo.identifier));
436
462
  });
437
463
  if (liveSyncInfo.useHotModuleReload) {
@@ -2,4 +2,5 @@ interface IHmrStatusService {
2
2
  watchHmrStatus(deviceId: string, operationHash: string): void;
3
3
  getHmrStatus(deviceId: string, operationHash: string): Promise<number>;
4
4
  attachToHmrStatusEvent(): void;
5
+ getStartingHash(): string;
5
6
  }
@@ -21,13 +21,20 @@ class HmrStatusService {
21
21
  getHmrStatus(deviceId, operationHash) {
22
22
  return new Promise((resolve, reject) => {
23
23
  const key = `${deviceId}${operationHash}`;
24
+ this.$logger.trace("INITIAL CHECKING HASH STATUS", operationHash);
25
+ const status = this.getStatusByKey(operationHash);
26
+ if (status) {
27
+ resolve(status);
28
+ return;
29
+ }
24
30
  let retryCount = 40;
25
31
  this.intervals[key] = setInterval(() => {
32
+ this.$logger.trace("CHECKING HASH STATUS", operationHash);
26
33
  const status = this.getStatusByKey(key);
27
34
  if (status || retryCount === 0) {
28
35
  clearInterval(this.intervals[key]);
29
36
  this.intervals[key] = null;
30
- resolve(status);
37
+ resolve(status !== null && status !== void 0 ? status : constants_1.HmrConstants.HMR_ERROR_STATUS);
31
38
  }
32
39
  else {
33
40
  retryCount--;
@@ -64,6 +71,9 @@ class HmrStatusService {
64
71
  regex: /\[HMR]\[(.+)]\s*(\w+)\s*\|/,
65
72
  handler: (matches, deviceId) => {
66
73
  const [hash, status] = matches.slice(1);
74
+ if (status.trim() === "boot") {
75
+ this.startingBundleHash = hash;
76
+ }
67
77
  const mappedStatus = statusStringMap[status.trim()];
68
78
  if (mappedStatus) {
69
79
  this.setData(deviceId, hash, statusStringMap[status]);
@@ -72,6 +82,9 @@ class HmrStatusService {
72
82
  name: "hmr-status",
73
83
  });
74
84
  }
85
+ getStartingHash() {
86
+ return this.startingBundleHash;
87
+ }
75
88
  handleAppCrash(matches, deviceId) {
76
89
  for (const operationId in this.hashOperationStatuses) {
77
90
  const operation = this.hashOperationStatuses[operationId];
@@ -40,6 +40,8 @@ class WebpackCompilerService extends events_1.EventEmitter {
40
40
  this.$packageInstallationManager = $packageInstallationManager;
41
41
  this.webpackProcesses = {};
42
42
  this.expectedHashes = {};
43
+ this.hashQueue = [];
44
+ this.lastEmittedHash = "";
43
45
  }
44
46
  compileWithWatch(platformData, projectData, prepareData) {
45
47
  return __awaiter(this, void 0, void 0, function* () {
@@ -57,6 +59,12 @@ class WebpackCompilerService extends events_1.EventEmitter {
57
59
  if (typeof message === "object" &&
58
60
  "version" in message &&
59
61
  "type" in message) {
62
+ const currentHash = message.hash;
63
+ if (this.hashQueue.length == 0 ||
64
+ this.hashQueue[this.hashQueue.length - 1] !== currentHash) {
65
+ this.hashQueue.push(currentHash);
66
+ }
67
+ this.currentCompilationHash = currentHash;
60
68
  if (isFirstWebpackWatchCompilation) {
61
69
  isFirstWebpackWatchCompilation = false;
62
70
  resolve(childProcess);
@@ -333,25 +341,30 @@ class WebpackCompilerService extends events_1.EventEmitter {
333
341
  this.$logger.trace("Webpack build done!");
334
342
  const files = message.data.emittedAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, "app", asset));
335
343
  const staleFiles = message.data.staleAssets.map((asset) => path.join(platformData.appDestinationDirectoryPath, "app", asset));
336
- const lastHash = (() => {
337
- const fileWithLastHash = files.find((fileName) => fileName.endsWith("hot-update.js"));
338
- if (!fileWithLastHash) {
339
- return null;
340
- }
341
- const matches = fileWithLastHash.match(/\.(.+).hot-update\.js/);
342
- if (matches) {
343
- return matches[1];
344
- }
345
- })();
346
344
  if (!files.length) {
347
345
  return;
348
346
  }
347
+ let currentIdx = 0;
348
+ let lastHash = this.hashQueue.length > 0
349
+ ? this.hashQueue[currentIdx]
350
+ : this.currentCompilationHash;
351
+ while (lastHash !== this.currentCompilationHash) {
352
+ if (files.some((f) => f.endsWith(`${lastHash}.hot-update.js`))) {
353
+ this.hashQueue.splice(0, currentIdx + 1);
354
+ break;
355
+ }
356
+ currentIdx++;
357
+ lastHash =
358
+ this.hashQueue.length > currentIdx
359
+ ? this.hashQueue[currentIdx]
360
+ : this.currentCompilationHash;
361
+ }
349
362
  this.emit(constants_1.WEBPACK_COMPILATION_COMPLETE, {
350
363
  files,
351
364
  staleFiles,
352
365
  hasOnlyHotUpdateFiles: prepareData.hmr,
353
366
  hmrData: {
354
- hash: lastHash || message.hash,
367
+ hash: lastHash,
355
368
  fallbackFiles: [],
356
369
  },
357
370
  platform: platformData.platformNameLowerCase,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nativescript",
3
3
  "preferGlobal": true,
4
- "version": "8.2.3",
4
+ "version": "8.2.4-alpha.0",
5
5
  "author": "NativeScript <support@nativescript.org>",
6
6
  "description": "Command-line interface for building NativeScript projects",
7
7
  "bin": {