@absolutejs/absolute 0.19.0-beta.867 → 0.19.0-beta.869

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
@@ -9876,12 +9876,50 @@ var ENTITY_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9876
9876
  u.default(${className}, [core]);
9877
9877
  }
9878
9878
  };
9879
+ // Tier 1 remount: structural changes (new ctor params / new field
9880
+ // initializers / new providers) make a CONTEXT-preserving replace
9881
+ // unsafe \u2014 the existing instance lacks the new fields. The remount
9882
+ // path tears down the live LView and re-creates it via public
9883
+ // \`createComponent\` against the same host, so the new constructor
9884
+ // runs with fresh DI, new lifecycle hooks fire, and the splice
9885
+ // logic puts the result back in the parent's view tree. The
9886
+ // shared implementation is on \`globalThis.__absAngularRemount\` \u2014
9887
+ // installed by hmrClient.ts's import-time wiring.
9888
+ const __ng_hmr_remount = async (t) => {
9889
+ const [u, core] = await Promise.all([
9890
+ import('/@ng/component?c=' + encodeURIComponent(__ng_hmr_id) + '&t=' + t),
9891
+ import('@angular/core')
9892
+ ]);
9893
+ if (!u || typeof u.default !== 'function') return;
9894
+ if (typeof globalThis.__absAngularRemount === 'function' && ${className}.\u0275cmp) {
9895
+ try {
9896
+ await globalThis.__absAngularRemount(
9897
+ ${className},
9898
+ u.default,
9899
+ [core],
9900
+ [],
9901
+ core,
9902
+ ${JSON.stringify(className)}
9903
+ );
9904
+ } catch (err) {
9905
+ console.error('[abs-hmr] remount threw for ${className}:', err);
9906
+ }
9907
+ } else {
9908
+ // No remount helper installed (older absolutejs runtime, or
9909
+ // non-component entity). Fall back to surgical replace.
9910
+ u.default(${className}, [core]);
9911
+ }
9912
+ };
9913
+
9879
9914
  if (typeof globalThis !== 'undefined' &&
9880
9915
  globalThis.__angularHmr &&
9881
9916
  typeof globalThis.__angularHmr.on === 'function') {
9882
9917
  globalThis.__angularHmr.on('angular:component-update', (d) => {
9883
9918
  if (d && d.id === __ng_hmr_id) __ng_hmr_load(d.timestamp);
9884
9919
  });
9920
+ globalThis.__angularHmr.on('angular:component-remount', (d) => {
9921
+ if (d && d.id === __ng_hmr_id) __ng_hmr_remount(d.timestamp);
9922
+ });
9885
9923
  }
9886
9924
  }
9887
9925
  `, createAngularHmrInjectionPlugin = (params) => {
@@ -18929,7 +18967,12 @@ ${block}
18929
18967
  if (!moduleText) {
18930
18968
  return fail("unexpected-error", `buildSimpleEntityModule returned null for ${className}`);
18931
18969
  }
18932
- return { componentSource: sourceFile, moduleText, ok: true };
18970
+ return {
18971
+ componentSource: sourceFile,
18972
+ fingerprintChanged: false,
18973
+ moduleText,
18974
+ ok: true
18975
+ };
18933
18976
  }
18934
18977
  if (inheritsDecoratedClass(classNode)) {
18935
18978
  return fail("inherits-decorated-class");
@@ -18984,9 +19027,7 @@ ${block}
18984
19027
  const fingerprintId = encodeURIComponent(`${projectRelPath}@${className}`);
18985
19028
  const currentFingerprint = extractFingerprint(classNode, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
18986
19029
  const cachedFingerprint = fingerprintCache.get(fingerprintId);
18987
- if (cachedFingerprint && !fingerprintsEqual(cachedFingerprint, currentFingerprint)) {
18988
- return fail("structural-change", `fingerprint changed for ${className}; escalate to Tier 1`);
18989
- }
19030
+ const fingerprintChanged = cachedFingerprint !== undefined && !fingerprintsEqual(cachedFingerprint, currentFingerprint);
18990
19031
  const sourceFileObj = new compiler.ParseSourceFile(tsSource, componentFilePath);
18991
19032
  const zeroLoc = new compiler.ParseLocation(sourceFileObj, 0, 0, 0);
18992
19033
  const typeSourceSpan = new compiler.ParseSourceSpan(zeroLoc, zeroLoc);
@@ -19091,7 +19132,12 @@ ${block}
19091
19132
  }
19092
19133
  }
19093
19134
  fingerprintCache.set(fingerprintId, currentFingerprint);
19094
- return { ok: true, moduleText, componentSource: sourceFile };
19135
+ return {
19136
+ componentSource: sourceFile,
19137
+ fingerprintChanged,
19138
+ moduleText,
19139
+ ok: true
19140
+ };
19095
19141
  } catch (err) {
19096
19142
  return fail("unexpected-error", String(err));
19097
19143
  }
@@ -19891,6 +19937,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
19891
19937
  const { tryFastHmr: tryFastHmr2 } = await Promise.resolve().then(() => (init_fastHmrCompiler(), exports_fastHmrCompiler));
19892
19938
  const queue = [];
19893
19939
  const queueIds = new Set;
19940
+ let anyFingerprintChanged = false;
19894
19941
  for (const editedFile of userEdited) {
19895
19942
  const owners = resolveOwningComponents2({
19896
19943
  changedFilePath: editedFile,
@@ -19898,6 +19945,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
19898
19945
  });
19899
19946
  if (owners.length === 0 && (editedFile.endsWith(".component.ts") || editedFile.endsWith(".directive.ts") || editedFile.endsWith(".pipe.ts") || editedFile.endsWith(".service.ts"))) {
19900
19947
  return {
19948
+ kind: "rebootstrap",
19901
19949
  reason: `no Angular-decorated class found in ${editedFile}`,
19902
19950
  tier: 1
19903
19951
  };
@@ -19913,14 +19961,21 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
19913
19961
  });
19914
19962
  if (!result.ok) {
19915
19963
  return {
19964
+ kind: "rebootstrap",
19916
19965
  reason: `${className}: ${result.reason}${result.detail ? ` (${result.detail})` : ""}`,
19917
19966
  tier: 1
19918
19967
  };
19919
19968
  }
19969
+ if (result.fingerprintChanged) {
19970
+ anyFingerprintChanged = true;
19971
+ }
19920
19972
  queueIds.add(id);
19921
19973
  queue.push({ className, id });
19922
19974
  }
19923
19975
  }
19976
+ if (anyFingerprintChanged) {
19977
+ return { kind: "remount", queue, tier: 1 };
19978
+ }
19924
19979
  return { queue, tier: 0 };
19925
19980
  }, broadcastSurgical = (state, queue) => {
19926
19981
  const timestamp = Date.now();
@@ -19931,6 +19986,15 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
19931
19986
  });
19932
19987
  logInfo(`[ng-hmr broadcast] ${className}`);
19933
19988
  }
19989
+ }, broadcastRemount = (state, queue) => {
19990
+ const timestamp = Date.now();
19991
+ for (const { id, className } of queue) {
19992
+ broadcastToClients(state, {
19993
+ data: { id, timestamp },
19994
+ type: "angular:component-remount"
19995
+ });
19996
+ logInfo(`[ng-hmr tier-1 remount] ${className}`);
19997
+ }
19934
19998
  }, broadcastRebootstrap = async (state, reason) => {
19935
19999
  logInfo(`[ng-hmr tier-1 rebootstrap] ${reason}`);
19936
20000
  broadcastToClients(state, {
@@ -19994,7 +20058,12 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
19994
20058
  runBundle().catch((err) => {
19995
20059
  logWarn(`[ng-hmr async bundle] rebuild failed: ${err instanceof Error ? err.message : String(err)}`);
19996
20060
  });
19997
- } else {
20061
+ } else if (verdict.tier === 1 && verdict.kind === "remount") {
20062
+ broadcastRemount(state, verdict.queue);
20063
+ runBundle().catch((err) => {
20064
+ logWarn(`[ng-hmr async bundle] rebuild failed: ${err instanceof Error ? err.message : String(err)}`);
20065
+ });
20066
+ } else if (verdict.tier === 1 && verdict.kind === "rebootstrap") {
19998
20067
  await runBundle();
19999
20068
  await broadcastRebootstrap(state, verdict.reason);
20000
20069
  }
@@ -30289,5 +30358,5 @@ export {
30289
30358
  ANGULAR_INIT_TIMEOUT_MS
30290
30359
  };
30291
30360
 
30292
- //# debugId=FEFC595D5DEBE05064756E2164756E21
30361
+ //# debugId=F19AC49C80B89ABF64756E2164756E21
30293
30362
  //# sourceMappingURL=index.js.map