@absolutejs/absolute 0.19.0-beta.856 → 0.19.0-beta.858

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
@@ -9832,7 +9832,7 @@ __export(exports_hmrInjectionPlugin, {
9832
9832
  });
9833
9833
  import { readFile as readFile5 } from "fs/promises";
9834
9834
  import { relative as relative6, resolve as resolve15 } from "path";
9835
- var COMPONENT_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9835
+ var ENTITY_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9836
9836
 
9837
9837
  // absolutejs HMR \u2014 auto-generated; mirrors compileHmrInitializer from
9838
9838
  // @angular/compiler with import.meta.hot adapted to globalThis.__angularHmr.
@@ -9867,7 +9867,7 @@ var COMPONENT_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9867
9867
  const seen = new Set;
9868
9868
  const classNames = [];
9869
9869
  let match;
9870
- const re2 = new RegExp(COMPONENT_DECORATOR_RE.source, COMPONENT_DECORATOR_RE.flags);
9870
+ const re2 = new RegExp(ENTITY_DECORATOR_RE.source, ENTITY_DECORATOR_RE.flags);
9871
9871
  while ((match = re2.exec(text)) !== null) {
9872
9872
  const className = match[1];
9873
9873
  if (className && !seen.has(className)) {
@@ -9890,7 +9890,7 @@ var COMPONENT_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9890
9890
  };
9891
9891
  };
9892
9892
  var init_hmrInjectionPlugin = __esm(() => {
9893
- COMPONENT_DECORATOR_RE = /([A-Z][A-Za-z0-9_$]*)\s*=\s*__legacyDecorateClassTS[A-Za-z0-9_$]*\s*\(\s*\[[\s\S]*?\bComponent[A-Za-z0-9_$]*\s*\(/g;
9893
+ ENTITY_DECORATOR_RE = /([A-Z][A-Za-z0-9_$]*)\s*=\s*__legacyDecorateClassTS[A-Za-z0-9_$]*\s*\(\s*\[[\s\S]*?\b(?:Component|Directive|Pipe|Injectable)[A-Za-z0-9_$]*\s*\(/g;
9894
9894
  });
9895
9895
 
9896
9896
  // src/utils/cleanStaleOutputs.ts
@@ -17486,7 +17486,7 @@ __export(exports_resolveOwningComponents, {
17486
17486
  import { readdirSync as readdirSync2, readFileSync as readFileSync19, statSync as statSync3 } from "fs";
17487
17487
  import { dirname as dirname18, extname as extname9, join as join29, resolve as resolve32 } from "path";
17488
17488
  import ts3 from "typescript";
17489
- var isComponentTsFile = (file5) => file5.endsWith(".component.ts") || file5.endsWith(".component.tsx"), walkComponentTsFiles = (root) => {
17489
+ var ENTITY_DECORATORS, isAngularSourceFile = (file5) => file5.endsWith(".ts") || file5.endsWith(".tsx"), walkAngularSourceFiles = (root) => {
17490
17490
  const out = [];
17491
17491
  const visit = (dir) => {
17492
17492
  let entries;
@@ -17502,7 +17502,7 @@ var isComponentTsFile = (file5) => file5.endsWith(".component.ts") || file5.ends
17502
17502
  const full = join29(dir, entry.name);
17503
17503
  if (entry.isDirectory()) {
17504
17504
  visit(full);
17505
- } else if (entry.isFile() && isComponentTsFile(entry.name)) {
17505
+ } else if (entry.isFile() && isAngularSourceFile(entry.name)) {
17506
17506
  out.push(full);
17507
17507
  }
17508
17508
  }
@@ -17540,58 +17540,67 @@ var isComponentTsFile = (file5) => file5.endsWith(".component.ts") || file5.ends
17540
17540
  }
17541
17541
  }
17542
17542
  return out;
17543
- }, parseComponentRefs = (filePath) => {
17544
- const refs = {
17545
- classNames: [],
17546
- templateUrls: [],
17547
- styleUrls: []
17548
- };
17543
+ }, parseDecoratedClasses = (filePath) => {
17549
17544
  let source;
17550
17545
  try {
17551
17546
  source = readFileSync19(filePath, "utf8");
17552
17547
  } catch {
17553
- return refs;
17548
+ return [];
17554
17549
  }
17555
17550
  const sourceFile = ts3.createSourceFile(filePath, source, ts3.ScriptTarget.ES2022, true, ts3.ScriptKind.TS);
17551
+ const out = [];
17556
17552
  const visit = (node) => {
17557
17553
  if (ts3.isClassDeclaration(node) && node.name) {
17558
- const decorators = ts3.getDecorators(node) ?? [];
17559
- for (const decorator of decorators) {
17554
+ for (const decorator of ts3.getDecorators(node) ?? []) {
17560
17555
  const expr = decorator.expression;
17561
17556
  if (!ts3.isCallExpression(expr))
17562
17557
  continue;
17563
17558
  const fn2 = expr.expression;
17564
- if (!ts3.isIdentifier(fn2) || fn2.text !== "Component")
17559
+ if (!ts3.isIdentifier(fn2))
17565
17560
  continue;
17566
- refs.classNames.push(node.name.text);
17567
- const arg = expr.arguments[0];
17568
- if (!arg || !ts3.isObjectLiteralExpression(arg))
17561
+ const kind = ENTITY_DECORATORS[fn2.text];
17562
+ if (!kind)
17569
17563
  continue;
17570
- const tplUrl = getStringPropertyValue(arg, "templateUrl");
17571
- if (tplUrl)
17572
- refs.templateUrls.push(tplUrl);
17573
- const styleUrl = getStringPropertyValue(arg, "styleUrl");
17574
- if (styleUrl)
17575
- refs.styleUrls.push(styleUrl);
17576
- refs.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
17564
+ const entry = {
17565
+ className: node.name.text,
17566
+ kind,
17567
+ styleUrls: [],
17568
+ templateUrls: []
17569
+ };
17570
+ const arg = expr.arguments[0];
17571
+ if (arg && ts3.isObjectLiteralExpression(arg) && kind === "component") {
17572
+ const tplUrl = getStringPropertyValue(arg, "templateUrl");
17573
+ if (tplUrl)
17574
+ entry.templateUrls.push(tplUrl);
17575
+ const styleUrl = getStringPropertyValue(arg, "styleUrl");
17576
+ if (styleUrl)
17577
+ entry.styleUrls.push(styleUrl);
17578
+ entry.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
17579
+ }
17580
+ out.push(entry);
17581
+ break;
17577
17582
  }
17578
17583
  }
17579
17584
  ts3.forEachChild(node, visit);
17580
17585
  };
17581
17586
  visit(sourceFile);
17582
- return refs;
17587
+ return out;
17583
17588
  }, safeNormalize = (path) => resolve32(path).replace(/\\/g, "/"), resolveOwningComponents = (params) => {
17584
17589
  const { changedFilePath, userAngularRoot } = params;
17585
17590
  const changedAbs = safeNormalize(changedFilePath);
17586
17591
  const out = [];
17587
- if (changedAbs.endsWith(".component.ts")) {
17588
- const refs = parseComponentRefs(changedAbs);
17589
- for (const className of refs.classNames) {
17590
- out.push({ componentFilePath: changedAbs, className });
17592
+ const ext = extname9(changedAbs).toLowerCase();
17593
+ if (ext === ".ts" || ext === ".tsx") {
17594
+ const classes = parseDecoratedClasses(changedAbs);
17595
+ for (const cls of classes) {
17596
+ out.push({
17597
+ className: cls.className,
17598
+ componentFilePath: changedAbs,
17599
+ kind: cls.kind
17600
+ });
17591
17601
  }
17592
17602
  return out;
17593
17603
  }
17594
- const ext = extname9(changedAbs).toLowerCase();
17595
17604
  if (ext !== ".html" && ext !== ".css" && ext !== ".scss" && ext !== ".sass") {
17596
17605
  return out;
17597
17606
  }
@@ -17603,26 +17612,36 @@ var isComponentTsFile = (file5) => file5.endsWith(".component.ts") || file5.ends
17603
17612
  }
17604
17613
  if (!rootStat.isDirectory())
17605
17614
  return out;
17606
- for (const componentTsPath of walkComponentTsFiles(userAngularRoot)) {
17607
- const refs = parseComponentRefs(componentTsPath);
17608
- const componentDir = dirname18(componentTsPath);
17615
+ for (const tsPath of walkAngularSourceFiles(userAngularRoot)) {
17616
+ const classes = parseDecoratedClasses(tsPath);
17617
+ const componentDir = dirname18(tsPath);
17609
17618
  const matchesResource = (relativeUrl) => {
17610
17619
  const abs = safeNormalize(resolve32(componentDir, relativeUrl));
17611
17620
  return abs === changedAbs;
17612
17621
  };
17613
- const referencesChanged = refs.templateUrls.some(matchesResource) || refs.styleUrls.some(matchesResource);
17614
- if (!referencesChanged)
17615
- continue;
17616
- for (const className of refs.classNames) {
17622
+ for (const cls of classes) {
17623
+ if (cls.kind !== "component")
17624
+ continue;
17625
+ const referencesChanged = cls.templateUrls.some(matchesResource) || cls.styleUrls.some(matchesResource);
17626
+ if (!referencesChanged)
17627
+ continue;
17617
17628
  out.push({
17618
- componentFilePath: componentTsPath,
17619
- className
17629
+ className: cls.className,
17630
+ componentFilePath: tsPath,
17631
+ kind: "component"
17620
17632
  });
17621
17633
  }
17622
17634
  }
17623
17635
  return out;
17624
17636
  };
17625
- var init_resolveOwningComponents = () => {};
17637
+ var init_resolveOwningComponents = __esm(() => {
17638
+ ENTITY_DECORATORS = {
17639
+ Component: "component",
17640
+ Directive: "directive",
17641
+ Pipe: "pipe",
17642
+ Injectable: "service"
17643
+ };
17644
+ });
17626
17645
 
17627
17646
  // src/dev/angular/hmrImportGenerator.ts
17628
17647
  import ts4 from "typescript";
@@ -18319,6 +18338,8 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18319
18338
  return false;
18320
18339
  if (!arraysEqual(a.arrowFieldSig, b2.arrowFieldSig))
18321
18340
  return false;
18341
+ if (!arraysEqual(a.memberDecoratorSig, b2.memberDecoratorSig))
18342
+ return false;
18322
18343
  return true;
18323
18344
  }, recordFingerprint = (id, fp) => {
18324
18345
  fingerprintCache.set(id, fp);
@@ -18588,6 +18609,33 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18588
18609
  entries.push(`${name}:${bodyHash}`);
18589
18610
  }
18590
18611
  return entries.sort();
18612
+ }, INPUT_OUTPUT_DECORATORS, extractMemberDecoratorSig = (cls) => {
18613
+ const entries = [];
18614
+ for (const member of cls.members) {
18615
+ const decorators = ts7.getDecorators(member) ?? [];
18616
+ if (decorators.length === 0)
18617
+ continue;
18618
+ const memberName = member.name?.getText() ?? "<anon>";
18619
+ for (const decorator of decorators) {
18620
+ const expr = decorator.expression;
18621
+ let decName = "<unknown>";
18622
+ let argText = "";
18623
+ if (ts7.isCallExpression(expr)) {
18624
+ if (ts7.isIdentifier(expr.expression)) {
18625
+ decName = expr.expression.text;
18626
+ }
18627
+ if (expr.arguments.length > 0) {
18628
+ argText = expr.arguments.map((a) => a.getText()).join(",");
18629
+ }
18630
+ } else if (ts7.isIdentifier(expr)) {
18631
+ decName = expr.text;
18632
+ }
18633
+ if (INPUT_OUTPUT_DECORATORS.has(decName))
18634
+ continue;
18635
+ entries.push(`${decName}:${memberName}:${djb2Hash(argText)}`);
18636
+ }
18637
+ }
18638
+ return entries.sort();
18591
18639
  }, providerProbeCache, fileHasModuleProviders = (filePath) => {
18592
18640
  let stat3;
18593
18641
  try {
@@ -18709,6 +18757,7 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18709
18757
  const inputNames = Object.keys(inputs).sort();
18710
18758
  const outputNames = Object.keys(outputs).sort();
18711
18759
  const arrowFieldSig = extractArrowFieldSig(cls);
18760
+ const memberDecoratorSig = extractMemberDecoratorSig(cls);
18712
18761
  const providerImportSig = extractProviderImportSig(decoratorMeta.importsExpr, sourceFile, componentDir);
18713
18762
  return {
18714
18763
  arrowFieldSig,
@@ -18717,6 +18766,7 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18717
18766
  hasProviders: decoratorMeta.hasProviders,
18718
18767
  hasViewProviders: decoratorMeta.hasViewProviders,
18719
18768
  inputs: inputNames,
18769
+ memberDecoratorSig,
18720
18770
  outputs: outputNames,
18721
18771
  providerImportSig,
18722
18772
  selector: decoratorMeta.selector,
@@ -18724,13 +18774,14 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18724
18774
  };
18725
18775
  }, buildFreshClassMethodsBlock = (classNode, className) => {
18726
18776
  const methodSources = [];
18777
+ let hasStatic = false;
18727
18778
  for (const member of classNode.members) {
18728
18779
  if (ts7.isMethodDeclaration(member) || ts7.isGetAccessorDeclaration(member) || ts7.isSetAccessorDeclaration(member)) {
18729
- const modifiers = ts7.getModifiers(member) ?? [];
18730
- const isStatic = modifiers.some((m) => m.kind === ts7.SyntaxKind.StaticKeyword);
18731
- if (isStatic)
18732
- continue;
18733
18780
  methodSources.push(member.getText());
18781
+ const modifiers = ts7.getModifiers(member) ?? [];
18782
+ if (modifiers.some((m) => m.kind === ts7.SyntaxKind.StaticKeyword)) {
18783
+ hasStatic = true;
18784
+ }
18734
18785
  }
18735
18786
  }
18736
18787
  if (methodSources.length === 0)
@@ -18751,9 +18802,18 @@ ${methodSources.join(`
18751
18802
  } catch {
18752
18803
  return null;
18753
18804
  }
18754
- return `// SURGICAL_HMR \u2014 patch prototype methods so existing instances
18755
- // pick up new method bodies (\`compileComponentFromMetadata\` only
18756
- // updates \`\u0275cmp\`, never the prototype).
18805
+ const staticPatch = hasStatic ? `
18806
+ {
18807
+ for (const __name of Object.getOwnPropertyNames(_Fresh)) {
18808
+ if (__name === 'length' || __name === 'name' || __name === 'prototype') continue;
18809
+ const __desc = Object.getOwnPropertyDescriptor(_Fresh, __name);
18810
+ if (__desc) Object.defineProperty(${className}, __name, __desc);
18811
+ }
18812
+ }` : "";
18813
+ return `// SURGICAL_HMR \u2014 patch prototype + static methods so existing
18814
+ // instances and direct \`Class.staticMethod()\` calls pick up new
18815
+ // method bodies (\`compileComponentFromMetadata\` only updates
18816
+ // \`\u0275cmp\`, never the prototype or the class itself).
18757
18817
  ${transpiled}
18758
18818
  {
18759
18819
  const __fresh_proto = _Fresh.prototype;
@@ -18762,7 +18822,7 @@ ${transpiled}
18762
18822
  const __desc = Object.getOwnPropertyDescriptor(__fresh_proto, __name);
18763
18823
  if (__desc) Object.defineProperty(${className}.prototype, __name, __desc);
18764
18824
  }
18765
- }`;
18825
+ }${staticPatch}`;
18766
18826
  }, resolveAndReadResource = (componentDir, url) => {
18767
18827
  const abs = resolve33(componentDir, url);
18768
18828
  if (!existsSync26(abs))
@@ -18781,6 +18841,16 @@ ${transpiled}
18781
18841
  styles.push(css);
18782
18842
  }
18783
18843
  return { styles, missing: null };
18844
+ }, buildSimpleEntityModule = (classNode, className) => {
18845
+ const block = buildFreshClassMethodsBlock(classNode, className);
18846
+ if (!block) {
18847
+ return `export default function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) { /* no method-body changes detected */ }
18848
+ `;
18849
+ }
18850
+ return `export default function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) {
18851
+ ${block}
18852
+ }
18853
+ `;
18784
18854
  }, tryFastHmr = async (params) => {
18785
18855
  const { componentFilePath, className } = params;
18786
18856
  const projectRoot = params.projectRoot ?? process.cwd();
@@ -18799,6 +18869,14 @@ ${transpiled}
18799
18869
  if (!classNode) {
18800
18870
  return fail("class-not-found", `${className} in ${componentFilePath}`);
18801
18871
  }
18872
+ const kind = params.kind ?? "component";
18873
+ if (kind !== "component") {
18874
+ const moduleText = buildSimpleEntityModule(classNode, className);
18875
+ if (!moduleText) {
18876
+ return fail("unexpected-error", `buildSimpleEntityModule returned null for ${className}`);
18877
+ }
18878
+ return { componentSource: sourceFile, moduleText, ok: true };
18879
+ }
18802
18880
  if (inheritsDecoratedClass(classNode)) {
18803
18881
  return fail("inherits-decorated-class");
18804
18882
  }
@@ -18982,6 +19060,7 @@ var init_fastHmrCompiler = __esm(() => {
18982
19060
  init_hmrImportGenerator();
18983
19061
  init_typescript_translator();
18984
19062
  fingerprintCache = new Map;
19063
+ INPUT_OUTPUT_DECORATORS = new Set(["Input", "Output"]);
18985
19064
  providerProbeCache = new Map;
18986
19065
  TS_EXTENSIONS = [".ts", ".tsx", ".d.ts"];
18987
19066
  });
@@ -19147,10 +19226,17 @@ var globalCache, getCachedHmrProgram = () => globalCache.__ABSOLUTE_ANGULAR_HMR_
19147
19226
  const filePathRel = decoded.slice(0, at2);
19148
19227
  const className = decoded.slice(at2 + 1);
19149
19228
  const componentFilePath = resolve34(process.cwd(), filePathRel);
19229
+ const { resolveOwningComponents: resolveOwningComponents2 } = await Promise.resolve().then(() => (init_resolveOwningComponents(), exports_resolveOwningComponents));
19230
+ const owners = resolveOwningComponents2({
19231
+ changedFilePath: componentFilePath,
19232
+ userAngularRoot: dirname20(componentFilePath)
19233
+ });
19234
+ const owner = owners.find((o2) => o2.className === className);
19235
+ const kind = owner?.kind ?? "component";
19150
19236
  const fastStart = performance2.now();
19151
- const fast = await tryFastHmr({ componentFilePath, className });
19237
+ const fast = await tryFastHmr({ className, componentFilePath, kind });
19152
19238
  if (fast.ok) {
19153
- logInfo(`[ng-hmr fast] ${className} ${(performance2.now() - fastStart).toFixed(1)}ms`);
19239
+ logInfo(`[ng-hmr fast/${kind}] ${className} ${(performance2.now() - fastStart).toFixed(1)}ms`);
19154
19240
  return fast.moduleText;
19155
19241
  }
19156
19242
  logWarn(`[ng-hmr slow] ${className} fast path bailed (${fast.reason}${fast.detail ? `: ${fast.detail}` : ""}), falling back to ngtsc`);
@@ -19770,17 +19856,21 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
19770
19856
  changedFilePath: editedFile,
19771
19857
  userAngularRoot: angularDir
19772
19858
  });
19773
- if (owners.length === 0 && editedFile.endsWith(".component.ts")) {
19859
+ if (owners.length === 0 && (editedFile.endsWith(".component.ts") || editedFile.endsWith(".directive.ts") || editedFile.endsWith(".pipe.ts") || editedFile.endsWith(".service.ts"))) {
19774
19860
  return {
19775
- reason: `no @Component class found in ${editedFile}`,
19861
+ reason: `no Angular-decorated class found in ${editedFile}`,
19776
19862
  tier: 1
19777
19863
  };
19778
19864
  }
19779
- for (const { componentFilePath, className } of owners) {
19865
+ for (const { componentFilePath, className, kind } of owners) {
19780
19866
  const id = encodeHmrComponentId2(componentFilePath, className);
19781
19867
  if (queueIds.has(id))
19782
19868
  continue;
19783
- const result = await tryFastHmr2({ className, componentFilePath });
19869
+ const result = await tryFastHmr2({
19870
+ className,
19871
+ componentFilePath,
19872
+ kind
19873
+ });
19784
19874
  if (!result.ok) {
19785
19875
  return {
19786
19876
  reason: `${className}: ${result.reason}${result.detail ? ` (${result.detail})` : ""}`,
@@ -30133,5 +30223,5 @@ export {
30133
30223
  ANGULAR_INIT_TIMEOUT_MS
30134
30224
  };
30135
30225
 
30136
- //# debugId=2BA92AA7B0159DCB64756E2164756E21
30226
+ //# debugId=BC7AABB276B304AB64756E2164756E21
30137
30227
  //# sourceMappingURL=index.js.map