@absolutejs/absolute 0.19.0-beta.881 → 0.19.0-beta.884

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/dist/index.js CHANGED
@@ -9883,6 +9883,15 @@ var ENTITY_DECORATOR_RE, IMPORT_RE, TOP_LEVEL_DECL_RE, extractAllTopLevelNames =
9883
9883
  // patch the prototype, no view recreation needed).
9884
9884
  {
9885
9885
  const __ng_hmr_id = ${encodedIdLiteral};
9886
+ // Per-class sequence counter. Each \`__ng_hmr_load\` /
9887
+ // \`__ng_hmr_remount\` invocation captures \`seq\` at start, then
9888
+ // checks after the async fetch + before the apply. If a NEWER
9889
+ // event has bumped the counter while we were awaiting (rapid
9890
+ // edits), this older invocation aborts so the latest payload
9891
+ // is the one that lands. Without this guard, racing
9892
+ // \`\u0275\u0275replaceMetadata\` calls can complete out of order and an
9893
+ // older edit's def stomps a newer one's.
9894
+ let __ng_hmr_seq = 0;
9886
9895
  // Send a server-side ack so the dev terminal can log the
9887
9896
  // full HMR latency (server compile + WS hop + client apply +
9888
9897
  // CD pulse) rather than just the server-side compile time.
@@ -9902,11 +9911,13 @@ var ENTITY_DECORATOR_RE, IMPORT_RE, TOP_LEVEL_DECL_RE, extractAllTopLevelNames =
9902
9911
  } catch {}
9903
9912
  };
9904
9913
  const __ng_hmr_load = async (t) => {
9914
+ const mySeq = ++__ng_hmr_seq;
9905
9915
  const t0 = performance.now();
9906
9916
  const [u, core] = await Promise.all([
9907
9917
  import('/@ng/component?c=' + encodeURIComponent(__ng_hmr_id) + '&t=' + t),
9908
9918
  import('@angular/core')
9909
9919
  ]);
9920
+ if (mySeq !== __ng_hmr_seq) return; // superseded by a newer event
9910
9921
  if (!u || typeof u.default !== 'function') return;
9911
9922
  if (${className}.\u0275cmp && typeof core.\u0275\u0275replaceMetadata === 'function') {
9912
9923
  try {
@@ -9940,11 +9951,13 @@ var ENTITY_DECORATOR_RE, IMPORT_RE, TOP_LEVEL_DECL_RE, extractAllTopLevelNames =
9940
9951
  // shared implementation is on \`globalThis.__absAngularRemount\` \u2014
9941
9952
  // installed by hmrClient.ts's import-time wiring.
9942
9953
  const __ng_hmr_remount = async (t) => {
9954
+ const mySeq = ++__ng_hmr_seq;
9943
9955
  const t0 = performance.now();
9944
9956
  const [u, core] = await Promise.all([
9945
9957
  import('/@ng/component?c=' + encodeURIComponent(__ng_hmr_id) + '&t=' + t),
9946
9958
  import('@angular/core')
9947
9959
  ]);
9960
+ if (mySeq !== __ng_hmr_seq) return; // superseded by a newer event
9948
9961
  if (!u || typeof u.default !== 'function') return;
9949
9962
  if (typeof globalThis.__absAngularRemount === 'function' && ${className}.\u0275cmp) {
9950
9963
  try {
@@ -9956,6 +9969,7 @@ var ENTITY_DECORATOR_RE, IMPORT_RE, TOP_LEVEL_DECL_RE, extractAllTopLevelNames =
9956
9969
  core,
9957
9970
  ${JSON.stringify(className)}
9958
9971
  );
9972
+ if (mySeq !== __ng_hmr_seq) return; // newer event arrived during remount
9959
9973
  __ng_hmr_ack('tier-1a', performance.now() - t0);
9960
9974
  } catch (err) {
9961
9975
  console.error('[abs-hmr] remount threw for ${className}:', err);
@@ -17623,7 +17637,8 @@ var init_rewriteImports = __esm(() => {
17623
17637
  // src/dev/angular/resolveOwningComponents.ts
17624
17638
  var exports_resolveOwningComponents = {};
17625
17639
  __export(exports_resolveOwningComponents, {
17626
- resolveOwningComponents: () => resolveOwningComponents
17640
+ resolveOwningComponents: () => resolveOwningComponents,
17641
+ invalidateResourceIndex: () => invalidateResourceIndex
17627
17642
  });
17628
17643
  import { readdirSync as readdirSync2, readFileSync as readFileSync19, statSync as statSync3 } from "fs";
17629
17644
  import { dirname as dirname18, extname as extname9, join as join29, resolve as resolve32 } from "path";
@@ -17754,27 +17769,42 @@ var ENTITY_DECORATORS, isAngularSourceFile = (file5) => file5.endsWith(".ts") ||
17754
17769
  }
17755
17770
  if (!rootStat.isDirectory())
17756
17771
  return out;
17772
+ const index = getOrBuildResourceIndex(userAngularRoot);
17773
+ const owners = index.get(changedAbs);
17774
+ if (owners) {
17775
+ out.push(...owners);
17776
+ }
17777
+ return out;
17778
+ }, resourceIndexByRoot, getOrBuildResourceIndex = (userAngularRoot) => {
17779
+ const cached = resourceIndexByRoot.get(userAngularRoot);
17780
+ if (cached)
17781
+ return cached;
17782
+ const index = new Map;
17757
17783
  for (const tsPath of walkAngularSourceFiles(userAngularRoot)) {
17758
17784
  const classes = parseDecoratedClasses(tsPath);
17759
17785
  const componentDir = dirname18(tsPath);
17760
- const matchesResource = (relativeUrl) => {
17761
- const abs = safeNormalize(resolve32(componentDir, relativeUrl));
17762
- return abs === changedAbs;
17763
- };
17764
17786
  for (const cls of classes) {
17765
17787
  if (cls.kind !== "component")
17766
17788
  continue;
17767
- const referencesChanged = cls.templateUrls.some(matchesResource) || cls.styleUrls.some(matchesResource);
17768
- if (!referencesChanged)
17769
- continue;
17770
- out.push({
17789
+ const owner = {
17771
17790
  className: cls.className,
17772
17791
  componentFilePath: tsPath,
17773
17792
  kind: "component"
17774
- });
17793
+ };
17794
+ for (const url of [...cls.templateUrls, ...cls.styleUrls]) {
17795
+ const abs = safeNormalize(resolve32(componentDir, url));
17796
+ const existing = index.get(abs);
17797
+ if (existing)
17798
+ existing.push(owner);
17799
+ else
17800
+ index.set(abs, [owner]);
17801
+ }
17775
17802
  }
17776
17803
  }
17777
- return out;
17804
+ resourceIndexByRoot.set(userAngularRoot, index);
17805
+ return index;
17806
+ }, invalidateResourceIndex = () => {
17807
+ resourceIndexByRoot.clear();
17778
17808
  };
17779
17809
  var init_resolveOwningComponents = __esm(() => {
17780
17810
  ENTITY_DECORATORS = {
@@ -17783,6 +17813,7 @@ var init_resolveOwningComponents = __esm(() => {
17783
17813
  Pipe: "pipe",
17784
17814
  Injectable: "service"
17785
17815
  };
17816
+ resourceIndexByRoot = new Map;
17786
17817
  });
17787
17818
 
17788
17819
  // src/dev/angular/hmrImportGenerator.ts
@@ -20099,21 +20130,51 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
20099
20130
  const clientManifest = generateManifest2(clientResult.outputs, buildDir);
20100
20131
  Object.assign(state.manifest, clientManifest);
20101
20132
  await populateAssetStore(state.assetStore, clientManifest, buildDir);
20133
+ }, angularDispatcherModules = null, loadAngularDispatcherModules = async () => {
20134
+ if (angularDispatcherModules)
20135
+ return angularDispatcherModules;
20136
+ const [resolveMod, hmrMod, fastMod] = await Promise.all([
20137
+ Promise.resolve().then(() => (init_resolveOwningComponents(), exports_resolveOwningComponents)),
20138
+ Promise.resolve().then(() => (init_hmrCompiler(), exports_hmrCompiler)),
20139
+ Promise.resolve().then(() => (init_fastHmrCompiler(), exports_fastHmrCompiler))
20140
+ ]);
20141
+ angularDispatcherModules = {
20142
+ encodeHmrComponentId: hmrMod.encodeHmrComponentId,
20143
+ invalidateResourceIndex: resolveMod.invalidateResourceIndex,
20144
+ resolveOwningComponents: resolveMod.resolveOwningComponents,
20145
+ tryFastHmr: fastMod.tryFastHmr
20146
+ };
20147
+ return angularDispatcherModules;
20102
20148
  }, decideAngularTier = async (state, angularDir) => {
20103
20149
  const userEdited = state.lastUserEditedFiles ?? new Set;
20104
20150
  if (userEdited.size === 0)
20105
20151
  return { queue: [], tier: 0 };
20106
- const { resolveOwningComponents: resolveOwningComponents2 } = await Promise.resolve().then(() => (init_resolveOwningComponents(), exports_resolveOwningComponents));
20107
- const { encodeHmrComponentId: encodeHmrComponentId2 } = await Promise.resolve().then(() => (init_hmrCompiler(), exports_hmrCompiler));
20108
- const { tryFastHmr: tryFastHmr2 } = await Promise.resolve().then(() => (init_fastHmrCompiler(), exports_fastHmrCompiler));
20152
+ const importsStart = performance.now();
20153
+ const {
20154
+ resolveOwningComponents: resolveOwningComponents2,
20155
+ invalidateResourceIndex: invalidateResourceIndex2,
20156
+ encodeHmrComponentId: encodeHmrComponentId2,
20157
+ tryFastHmr: tryFastHmr2
20158
+ } = await loadAngularDispatcherModules();
20159
+ const importsMs = performance.now() - importsStart;
20160
+ for (const editedFile of userEdited) {
20161
+ if (editedFile.endsWith(".ts") || editedFile.endsWith(".tsx")) {
20162
+ invalidateResourceIndex2();
20163
+ break;
20164
+ }
20165
+ }
20109
20166
  const queue = [];
20110
20167
  const queueIds = new Set;
20111
20168
  let anyFingerprintChanged = false;
20169
+ let totalResolveMs = 0;
20170
+ let totalCompileMs = 0;
20112
20171
  for (const editedFile of userEdited) {
20172
+ const resolveStart = performance.now();
20113
20173
  const owners = resolveOwningComponents2({
20114
20174
  changedFilePath: editedFile,
20115
20175
  userAngularRoot: angularDir
20116
20176
  });
20177
+ totalResolveMs += performance.now() - resolveStart;
20117
20178
  if (owners.length === 0 && (editedFile.endsWith(".component.ts") || editedFile.endsWith(".directive.ts") || editedFile.endsWith(".pipe.ts") || editedFile.endsWith(".service.ts"))) {
20118
20179
  return {
20119
20180
  kind: "rebootstrap",
@@ -20125,11 +20186,13 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
20125
20186
  const id = encodeHmrComponentId2(componentFilePath, className);
20126
20187
  if (queueIds.has(id))
20127
20188
  continue;
20189
+ const compileStart = performance.now();
20128
20190
  const result = await tryFastHmr2({
20129
20191
  className,
20130
20192
  componentFilePath,
20131
20193
  kind
20132
20194
  });
20195
+ totalCompileMs += performance.now() - compileStart;
20133
20196
  if (!result.ok) {
20134
20197
  return {
20135
20198
  kind: "rebootstrap",
@@ -20144,10 +20207,15 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
20144
20207
  queue.push({ className, id });
20145
20208
  }
20146
20209
  }
20210
+ const breakdown = {
20211
+ importsMs: Math.round(importsMs),
20212
+ resolveMs: Math.round(totalResolveMs),
20213
+ compileMs: Math.round(totalCompileMs)
20214
+ };
20147
20215
  if (anyFingerprintChanged) {
20148
- return { kind: "remount", queue, tier: 1 };
20216
+ return { breakdown, kind: "remount", queue, tier: 1 };
20149
20217
  }
20150
- return { queue, tier: 0 };
20218
+ return { breakdown, queue, tier: 0 };
20151
20219
  }, broadcastSurgical = (state, queue) => {
20152
20220
  const timestamp = Date.now();
20153
20221
  for (const { id } of queue) {
@@ -20227,13 +20295,15 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
20227
20295
  const queueDescription = (queue) => queue.map((e) => e.className).join(", ");
20228
20296
  if (verdict.tier === 0) {
20229
20297
  broadcastSurgical(state, verdict.queue);
20230
- logInfo(`[ng-hmr] tier-0 ${queueDescription(verdict.queue)} (server ${tierMs}ms; awaiting client apply)`);
20298
+ const b2 = verdict.breakdown;
20299
+ logInfo(`[ng-hmr] tier-0 ${queueDescription(verdict.queue)} (server ${tierMs}ms: imports ${b2.importsMs}/resolve ${b2.resolveMs}/compile ${b2.compileMs}; awaiting client apply)`);
20231
20300
  runBundle().catch((err) => {
20232
20301
  logWarn(`[ng-hmr async bundle] rebuild failed: ${err instanceof Error ? err.message : String(err)}`);
20233
20302
  });
20234
20303
  } else if (verdict.tier === 1 && verdict.kind === "remount") {
20235
20304
  broadcastRemount(state, verdict.queue);
20236
- logInfo(`[ng-hmr] tier-1a remount ${queueDescription(verdict.queue)} (server ${tierMs}ms; awaiting client apply)`);
20305
+ const b2 = verdict.breakdown;
20306
+ logInfo(`[ng-hmr] tier-1a remount ${queueDescription(verdict.queue)} (server ${tierMs}ms: imports ${b2.importsMs}/resolve ${b2.resolveMs}/compile ${b2.compileMs}; awaiting client apply)`);
20237
20307
  runBundle().catch((err) => {
20238
20308
  logWarn(`[ng-hmr async bundle] rebuild failed: ${err instanceof Error ? err.message : String(err)}`);
20239
20309
  });
@@ -30541,5 +30611,5 @@ export {
30541
30611
  ANGULAR_INIT_TIMEOUT_MS
30542
30612
  };
30543
30613
 
30544
- //# debugId=95397A3CB2938E4164756E2164756E21
30614
+ //# debugId=8DCA359899760D3964756E2164756E21
30545
30615
  //# sourceMappingURL=index.js.map