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

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,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-Md8b3A/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-pL6ibI/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-Md8b3A/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-pL6ibI/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -48,7 +48,7 @@ var warnMissingStreamingSlotCollector = (primitiveName) => {
48
48
  getWarningController()?.maybeWarn(primitiveName);
49
49
  };
50
50
 
51
- // .angular-partial-tmp-Md8b3A/src/core/streamingSlotRegistry.ts
51
+ // .angular-partial-tmp-pL6ibI/src/core/streamingSlotRegistry.ts
52
52
  var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
53
53
  var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
54
54
  var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
package/dist/build.js CHANGED
@@ -9561,7 +9561,7 @@ __export(exports_hmrInjectionPlugin, {
9561
9561
  });
9562
9562
  import { readFile as readFile5 } from "fs/promises";
9563
9563
  import { relative as relative6, resolve as resolve12 } from "path";
9564
- var COMPONENT_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9564
+ var ENTITY_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9565
9565
 
9566
9566
  // absolutejs HMR \u2014 auto-generated; mirrors compileHmrInitializer from
9567
9567
  // @angular/compiler with import.meta.hot adapted to globalThis.__angularHmr.
@@ -9596,7 +9596,7 @@ var COMPONENT_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9596
9596
  const seen = new Set;
9597
9597
  const classNames = [];
9598
9598
  let match;
9599
- const re2 = new RegExp(COMPONENT_DECORATOR_RE.source, COMPONENT_DECORATOR_RE.flags);
9599
+ const re2 = new RegExp(ENTITY_DECORATOR_RE.source, ENTITY_DECORATOR_RE.flags);
9600
9600
  while ((match = re2.exec(text)) !== null) {
9601
9601
  const className = match[1];
9602
9602
  if (className && !seen.has(className)) {
@@ -9619,7 +9619,7 @@ var COMPONENT_DECORATOR_RE, buildHmrTail = (className, encodedIdLiteral) => `
9619
9619
  };
9620
9620
  };
9621
9621
  var init_hmrInjectionPlugin = __esm(() => {
9622
- 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;
9622
+ 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;
9623
9623
  });
9624
9624
 
9625
9625
  // src/utils/cleanStaleOutputs.ts
@@ -17389,7 +17389,7 @@ __export(exports_resolveOwningComponents, {
17389
17389
  import { readdirSync as readdirSync2, readFileSync as readFileSync18, statSync as statSync3 } from "fs";
17390
17390
  import { dirname as dirname17, extname as extname9, join as join28, resolve as resolve30 } from "path";
17391
17391
  import ts3 from "typescript";
17392
- var isComponentTsFile = (file4) => file4.endsWith(".component.ts") || file4.endsWith(".component.tsx"), walkComponentTsFiles = (root) => {
17392
+ var ENTITY_DECORATORS, isAngularSourceFile = (file4) => file4.endsWith(".ts") || file4.endsWith(".tsx"), walkAngularSourceFiles = (root) => {
17393
17393
  const out = [];
17394
17394
  const visit = (dir) => {
17395
17395
  let entries;
@@ -17405,7 +17405,7 @@ var isComponentTsFile = (file4) => file4.endsWith(".component.ts") || file4.ends
17405
17405
  const full = join28(dir, entry.name);
17406
17406
  if (entry.isDirectory()) {
17407
17407
  visit(full);
17408
- } else if (entry.isFile() && isComponentTsFile(entry.name)) {
17408
+ } else if (entry.isFile() && isAngularSourceFile(entry.name)) {
17409
17409
  out.push(full);
17410
17410
  }
17411
17411
  }
@@ -17443,58 +17443,67 @@ var isComponentTsFile = (file4) => file4.endsWith(".component.ts") || file4.ends
17443
17443
  }
17444
17444
  }
17445
17445
  return out;
17446
- }, parseComponentRefs = (filePath) => {
17447
- const refs = {
17448
- classNames: [],
17449
- templateUrls: [],
17450
- styleUrls: []
17451
- };
17446
+ }, parseDecoratedClasses = (filePath) => {
17452
17447
  let source;
17453
17448
  try {
17454
17449
  source = readFileSync18(filePath, "utf8");
17455
17450
  } catch {
17456
- return refs;
17451
+ return [];
17457
17452
  }
17458
17453
  const sourceFile = ts3.createSourceFile(filePath, source, ts3.ScriptTarget.ES2022, true, ts3.ScriptKind.TS);
17454
+ const out = [];
17459
17455
  const visit = (node) => {
17460
17456
  if (ts3.isClassDeclaration(node) && node.name) {
17461
- const decorators = ts3.getDecorators(node) ?? [];
17462
- for (const decorator of decorators) {
17457
+ for (const decorator of ts3.getDecorators(node) ?? []) {
17463
17458
  const expr = decorator.expression;
17464
17459
  if (!ts3.isCallExpression(expr))
17465
17460
  continue;
17466
17461
  const fn2 = expr.expression;
17467
- if (!ts3.isIdentifier(fn2) || fn2.text !== "Component")
17462
+ if (!ts3.isIdentifier(fn2))
17468
17463
  continue;
17469
- refs.classNames.push(node.name.text);
17470
- const arg = expr.arguments[0];
17471
- if (!arg || !ts3.isObjectLiteralExpression(arg))
17464
+ const kind = ENTITY_DECORATORS[fn2.text];
17465
+ if (!kind)
17472
17466
  continue;
17473
- const tplUrl = getStringPropertyValue(arg, "templateUrl");
17474
- if (tplUrl)
17475
- refs.templateUrls.push(tplUrl);
17476
- const styleUrl = getStringPropertyValue(arg, "styleUrl");
17477
- if (styleUrl)
17478
- refs.styleUrls.push(styleUrl);
17479
- refs.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
17467
+ const entry = {
17468
+ className: node.name.text,
17469
+ kind,
17470
+ styleUrls: [],
17471
+ templateUrls: []
17472
+ };
17473
+ const arg = expr.arguments[0];
17474
+ if (arg && ts3.isObjectLiteralExpression(arg) && kind === "component") {
17475
+ const tplUrl = getStringPropertyValue(arg, "templateUrl");
17476
+ if (tplUrl)
17477
+ entry.templateUrls.push(tplUrl);
17478
+ const styleUrl = getStringPropertyValue(arg, "styleUrl");
17479
+ if (styleUrl)
17480
+ entry.styleUrls.push(styleUrl);
17481
+ entry.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
17482
+ }
17483
+ out.push(entry);
17484
+ break;
17480
17485
  }
17481
17486
  }
17482
17487
  ts3.forEachChild(node, visit);
17483
17488
  };
17484
17489
  visit(sourceFile);
17485
- return refs;
17490
+ return out;
17486
17491
  }, safeNormalize = (path) => resolve30(path).replace(/\\/g, "/"), resolveOwningComponents = (params) => {
17487
17492
  const { changedFilePath, userAngularRoot } = params;
17488
17493
  const changedAbs = safeNormalize(changedFilePath);
17489
17494
  const out = [];
17490
- if (changedAbs.endsWith(".component.ts")) {
17491
- const refs = parseComponentRefs(changedAbs);
17492
- for (const className of refs.classNames) {
17493
- out.push({ componentFilePath: changedAbs, className });
17495
+ const ext = extname9(changedAbs).toLowerCase();
17496
+ if (ext === ".ts" || ext === ".tsx") {
17497
+ const classes = parseDecoratedClasses(changedAbs);
17498
+ for (const cls of classes) {
17499
+ out.push({
17500
+ className: cls.className,
17501
+ componentFilePath: changedAbs,
17502
+ kind: cls.kind
17503
+ });
17494
17504
  }
17495
17505
  return out;
17496
17506
  }
17497
- const ext = extname9(changedAbs).toLowerCase();
17498
17507
  if (ext !== ".html" && ext !== ".css" && ext !== ".scss" && ext !== ".sass") {
17499
17508
  return out;
17500
17509
  }
@@ -17506,26 +17515,36 @@ var isComponentTsFile = (file4) => file4.endsWith(".component.ts") || file4.ends
17506
17515
  }
17507
17516
  if (!rootStat.isDirectory())
17508
17517
  return out;
17509
- for (const componentTsPath of walkComponentTsFiles(userAngularRoot)) {
17510
- const refs = parseComponentRefs(componentTsPath);
17511
- const componentDir = dirname17(componentTsPath);
17518
+ for (const tsPath of walkAngularSourceFiles(userAngularRoot)) {
17519
+ const classes = parseDecoratedClasses(tsPath);
17520
+ const componentDir = dirname17(tsPath);
17512
17521
  const matchesResource = (relativeUrl) => {
17513
17522
  const abs = safeNormalize(resolve30(componentDir, relativeUrl));
17514
17523
  return abs === changedAbs;
17515
17524
  };
17516
- const referencesChanged = refs.templateUrls.some(matchesResource) || refs.styleUrls.some(matchesResource);
17517
- if (!referencesChanged)
17518
- continue;
17519
- for (const className of refs.classNames) {
17525
+ for (const cls of classes) {
17526
+ if (cls.kind !== "component")
17527
+ continue;
17528
+ const referencesChanged = cls.templateUrls.some(matchesResource) || cls.styleUrls.some(matchesResource);
17529
+ if (!referencesChanged)
17530
+ continue;
17520
17531
  out.push({
17521
- componentFilePath: componentTsPath,
17522
- className
17532
+ className: cls.className,
17533
+ componentFilePath: tsPath,
17534
+ kind: "component"
17523
17535
  });
17524
17536
  }
17525
17537
  }
17526
17538
  return out;
17527
17539
  };
17528
- var init_resolveOwningComponents = () => {};
17540
+ var init_resolveOwningComponents = __esm(() => {
17541
+ ENTITY_DECORATORS = {
17542
+ Component: "component",
17543
+ Directive: "directive",
17544
+ Pipe: "pipe",
17545
+ Injectable: "service"
17546
+ };
17547
+ });
17529
17548
 
17530
17549
  // src/dev/angular/hmrImportGenerator.ts
17531
17550
  import ts4 from "typescript";
@@ -18627,13 +18646,14 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18627
18646
  };
18628
18647
  }, buildFreshClassMethodsBlock = (classNode, className) => {
18629
18648
  const methodSources = [];
18649
+ let hasStatic = false;
18630
18650
  for (const member of classNode.members) {
18631
18651
  if (ts7.isMethodDeclaration(member) || ts7.isGetAccessorDeclaration(member) || ts7.isSetAccessorDeclaration(member)) {
18632
- const modifiers = ts7.getModifiers(member) ?? [];
18633
- const isStatic = modifiers.some((m) => m.kind === ts7.SyntaxKind.StaticKeyword);
18634
- if (isStatic)
18635
- continue;
18636
18652
  methodSources.push(member.getText());
18653
+ const modifiers = ts7.getModifiers(member) ?? [];
18654
+ if (modifiers.some((m) => m.kind === ts7.SyntaxKind.StaticKeyword)) {
18655
+ hasStatic = true;
18656
+ }
18637
18657
  }
18638
18658
  }
18639
18659
  if (methodSources.length === 0)
@@ -18654,9 +18674,18 @@ ${methodSources.join(`
18654
18674
  } catch {
18655
18675
  return null;
18656
18676
  }
18657
- return `// SURGICAL_HMR \u2014 patch prototype methods so existing instances
18658
- // pick up new method bodies (\`compileComponentFromMetadata\` only
18659
- // updates \`\u0275cmp\`, never the prototype).
18677
+ const staticPatch = hasStatic ? `
18678
+ {
18679
+ for (const __name of Object.getOwnPropertyNames(_Fresh)) {
18680
+ if (__name === 'length' || __name === 'name' || __name === 'prototype') continue;
18681
+ const __desc = Object.getOwnPropertyDescriptor(_Fresh, __name);
18682
+ if (__desc) Object.defineProperty(${className}, __name, __desc);
18683
+ }
18684
+ }` : "";
18685
+ return `// SURGICAL_HMR \u2014 patch prototype + static methods so existing
18686
+ // instances and direct \`Class.staticMethod()\` calls pick up new
18687
+ // method bodies (\`compileComponentFromMetadata\` only updates
18688
+ // \`\u0275cmp\`, never the prototype or the class itself).
18660
18689
  ${transpiled}
18661
18690
  {
18662
18691
  const __fresh_proto = _Fresh.prototype;
@@ -18665,7 +18694,7 @@ ${transpiled}
18665
18694
  const __desc = Object.getOwnPropertyDescriptor(__fresh_proto, __name);
18666
18695
  if (__desc) Object.defineProperty(${className}.prototype, __name, __desc);
18667
18696
  }
18668
- }`;
18697
+ }${staticPatch}`;
18669
18698
  }, resolveAndReadResource = (componentDir, url) => {
18670
18699
  const abs = resolve31(componentDir, url);
18671
18700
  if (!existsSync25(abs))
@@ -18684,6 +18713,16 @@ ${transpiled}
18684
18713
  styles.push(css);
18685
18714
  }
18686
18715
  return { styles, missing: null };
18716
+ }, buildSimpleEntityModule = (classNode, className) => {
18717
+ const block = buildFreshClassMethodsBlock(classNode, className);
18718
+ if (!block) {
18719
+ return `export default function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) { /* no method-body changes detected */ }
18720
+ `;
18721
+ }
18722
+ return `export default function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) {
18723
+ ${block}
18724
+ }
18725
+ `;
18687
18726
  }, tryFastHmr = async (params) => {
18688
18727
  const { componentFilePath, className } = params;
18689
18728
  const projectRoot = params.projectRoot ?? process.cwd();
@@ -18702,6 +18741,14 @@ ${transpiled}
18702
18741
  if (!classNode) {
18703
18742
  return fail("class-not-found", `${className} in ${componentFilePath}`);
18704
18743
  }
18744
+ const kind = params.kind ?? "component";
18745
+ if (kind !== "component") {
18746
+ const moduleText = buildSimpleEntityModule(classNode, className);
18747
+ if (!moduleText) {
18748
+ return fail("unexpected-error", `buildSimpleEntityModule returned null for ${className}`);
18749
+ }
18750
+ return { componentSource: sourceFile, moduleText, ok: true };
18751
+ }
18705
18752
  if (inheritsDecoratedClass(classNode)) {
18706
18753
  return fail("inherits-decorated-class");
18707
18754
  }
@@ -19050,10 +19097,17 @@ var globalCache, getCachedHmrProgram = () => globalCache.__ABSOLUTE_ANGULAR_HMR_
19050
19097
  const filePathRel = decoded.slice(0, at2);
19051
19098
  const className = decoded.slice(at2 + 1);
19052
19099
  const componentFilePath = resolve32(process.cwd(), filePathRel);
19100
+ const { resolveOwningComponents: resolveOwningComponents2 } = await Promise.resolve().then(() => (init_resolveOwningComponents(), exports_resolveOwningComponents));
19101
+ const owners = resolveOwningComponents2({
19102
+ changedFilePath: componentFilePath,
19103
+ userAngularRoot: dirname19(componentFilePath)
19104
+ });
19105
+ const owner = owners.find((o2) => o2.className === className);
19106
+ const kind = owner?.kind ?? "component";
19053
19107
  const fastStart = performance2.now();
19054
- const fast = await tryFastHmr({ componentFilePath, className });
19108
+ const fast = await tryFastHmr({ className, componentFilePath, kind });
19055
19109
  if (fast.ok) {
19056
- logInfo(`[ng-hmr fast] ${className} ${(performance2.now() - fastStart).toFixed(1)}ms`);
19110
+ logInfo(`[ng-hmr fast/${kind}] ${className} ${(performance2.now() - fastStart).toFixed(1)}ms`);
19057
19111
  return fast.moduleText;
19058
19112
  }
19059
19113
  logWarn(`[ng-hmr slow] ${className} fast path bailed (${fast.reason}${fast.detail ? `: ${fast.detail}` : ""}), falling back to ngtsc`);
@@ -19673,17 +19727,21 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
19673
19727
  changedFilePath: editedFile,
19674
19728
  userAngularRoot: angularDir
19675
19729
  });
19676
- if (owners.length === 0 && editedFile.endsWith(".component.ts")) {
19730
+ if (owners.length === 0 && (editedFile.endsWith(".component.ts") || editedFile.endsWith(".directive.ts") || editedFile.endsWith(".pipe.ts") || editedFile.endsWith(".service.ts"))) {
19677
19731
  return {
19678
- reason: `no @Component class found in ${editedFile}`,
19732
+ reason: `no Angular-decorated class found in ${editedFile}`,
19679
19733
  tier: 1
19680
19734
  };
19681
19735
  }
19682
- for (const { componentFilePath, className } of owners) {
19736
+ for (const { componentFilePath, className, kind } of owners) {
19683
19737
  const id = encodeHmrComponentId2(componentFilePath, className);
19684
19738
  if (queueIds.has(id))
19685
19739
  continue;
19686
- const result = await tryFastHmr2({ className, componentFilePath });
19740
+ const result = await tryFastHmr2({
19741
+ className,
19742
+ componentFilePath,
19743
+ kind
19744
+ });
19687
19745
  if (!result.ok) {
19688
19746
  return {
19689
19747
  reason: `${className}: ${result.reason}${result.detail ? ` (${result.detail})` : ""}`,
@@ -21491,5 +21549,5 @@ export {
21491
21549
  build
21492
21550
  };
21493
21551
 
21494
- //# debugId=0DF8D7C94DA9EB2864756E2164756E21
21552
+ //# debugId=E92A4B463882454F64756E2164756E21
21495
21553
  //# sourceMappingURL=build.js.map