@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.
@@ -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-tL6HLh/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-tL6HLh/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-tL6HLh/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";
@@ -18222,6 +18241,8 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18222
18241
  return false;
18223
18242
  if (!arraysEqual(a.arrowFieldSig, b2.arrowFieldSig))
18224
18243
  return false;
18244
+ if (!arraysEqual(a.memberDecoratorSig, b2.memberDecoratorSig))
18245
+ return false;
18225
18246
  return true;
18226
18247
  }, recordFingerprint = (id, fp) => {
18227
18248
  fingerprintCache.set(id, fp);
@@ -18491,6 +18512,33 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18491
18512
  entries.push(`${name}:${bodyHash}`);
18492
18513
  }
18493
18514
  return entries.sort();
18515
+ }, INPUT_OUTPUT_DECORATORS, extractMemberDecoratorSig = (cls) => {
18516
+ const entries = [];
18517
+ for (const member of cls.members) {
18518
+ const decorators = ts7.getDecorators(member) ?? [];
18519
+ if (decorators.length === 0)
18520
+ continue;
18521
+ const memberName = member.name?.getText() ?? "<anon>";
18522
+ for (const decorator of decorators) {
18523
+ const expr = decorator.expression;
18524
+ let decName = "<unknown>";
18525
+ let argText = "";
18526
+ if (ts7.isCallExpression(expr)) {
18527
+ if (ts7.isIdentifier(expr.expression)) {
18528
+ decName = expr.expression.text;
18529
+ }
18530
+ if (expr.arguments.length > 0) {
18531
+ argText = expr.arguments.map((a) => a.getText()).join(",");
18532
+ }
18533
+ } else if (ts7.isIdentifier(expr)) {
18534
+ decName = expr.text;
18535
+ }
18536
+ if (INPUT_OUTPUT_DECORATORS.has(decName))
18537
+ continue;
18538
+ entries.push(`${decName}:${memberName}:${djb2Hash(argText)}`);
18539
+ }
18540
+ }
18541
+ return entries.sort();
18494
18542
  }, providerProbeCache, fileHasModuleProviders = (filePath) => {
18495
18543
  let stat3;
18496
18544
  try {
@@ -18612,6 +18660,7 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18612
18660
  const inputNames = Object.keys(inputs).sort();
18613
18661
  const outputNames = Object.keys(outputs).sort();
18614
18662
  const arrowFieldSig = extractArrowFieldSig(cls);
18663
+ const memberDecoratorSig = extractMemberDecoratorSig(cls);
18615
18664
  const providerImportSig = extractProviderImportSig(decoratorMeta.importsExpr, sourceFile, componentDir);
18616
18665
  return {
18617
18666
  arrowFieldSig,
@@ -18620,6 +18669,7 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18620
18669
  hasProviders: decoratorMeta.hasProviders,
18621
18670
  hasViewProviders: decoratorMeta.hasViewProviders,
18622
18671
  inputs: inputNames,
18672
+ memberDecoratorSig,
18623
18673
  outputs: outputNames,
18624
18674
  providerImportSig,
18625
18675
  selector: decoratorMeta.selector,
@@ -18627,13 +18677,14 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18627
18677
  };
18628
18678
  }, buildFreshClassMethodsBlock = (classNode, className) => {
18629
18679
  const methodSources = [];
18680
+ let hasStatic = false;
18630
18681
  for (const member of classNode.members) {
18631
18682
  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
18683
  methodSources.push(member.getText());
18684
+ const modifiers = ts7.getModifiers(member) ?? [];
18685
+ if (modifiers.some((m) => m.kind === ts7.SyntaxKind.StaticKeyword)) {
18686
+ hasStatic = true;
18687
+ }
18637
18688
  }
18638
18689
  }
18639
18690
  if (methodSources.length === 0)
@@ -18654,9 +18705,18 @@ ${methodSources.join(`
18654
18705
  } catch {
18655
18706
  return null;
18656
18707
  }
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).
18708
+ const staticPatch = hasStatic ? `
18709
+ {
18710
+ for (const __name of Object.getOwnPropertyNames(_Fresh)) {
18711
+ if (__name === 'length' || __name === 'name' || __name === 'prototype') continue;
18712
+ const __desc = Object.getOwnPropertyDescriptor(_Fresh, __name);
18713
+ if (__desc) Object.defineProperty(${className}, __name, __desc);
18714
+ }
18715
+ }` : "";
18716
+ return `// SURGICAL_HMR \u2014 patch prototype + static methods so existing
18717
+ // instances and direct \`Class.staticMethod()\` calls pick up new
18718
+ // method bodies (\`compileComponentFromMetadata\` only updates
18719
+ // \`\u0275cmp\`, never the prototype or the class itself).
18660
18720
  ${transpiled}
18661
18721
  {
18662
18722
  const __fresh_proto = _Fresh.prototype;
@@ -18665,7 +18725,7 @@ ${transpiled}
18665
18725
  const __desc = Object.getOwnPropertyDescriptor(__fresh_proto, __name);
18666
18726
  if (__desc) Object.defineProperty(${className}.prototype, __name, __desc);
18667
18727
  }
18668
- }`;
18728
+ }${staticPatch}`;
18669
18729
  }, resolveAndReadResource = (componentDir, url) => {
18670
18730
  const abs = resolve31(componentDir, url);
18671
18731
  if (!existsSync25(abs))
@@ -18684,6 +18744,16 @@ ${transpiled}
18684
18744
  styles.push(css);
18685
18745
  }
18686
18746
  return { styles, missing: null };
18747
+ }, buildSimpleEntityModule = (classNode, className) => {
18748
+ const block = buildFreshClassMethodsBlock(classNode, className);
18749
+ if (!block) {
18750
+ return `export default function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) { /* no method-body changes detected */ }
18751
+ `;
18752
+ }
18753
+ return `export default function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) {
18754
+ ${block}
18755
+ }
18756
+ `;
18687
18757
  }, tryFastHmr = async (params) => {
18688
18758
  const { componentFilePath, className } = params;
18689
18759
  const projectRoot = params.projectRoot ?? process.cwd();
@@ -18702,6 +18772,14 @@ ${transpiled}
18702
18772
  if (!classNode) {
18703
18773
  return fail("class-not-found", `${className} in ${componentFilePath}`);
18704
18774
  }
18775
+ const kind = params.kind ?? "component";
18776
+ if (kind !== "component") {
18777
+ const moduleText = buildSimpleEntityModule(classNode, className);
18778
+ if (!moduleText) {
18779
+ return fail("unexpected-error", `buildSimpleEntityModule returned null for ${className}`);
18780
+ }
18781
+ return { componentSource: sourceFile, moduleText, ok: true };
18782
+ }
18705
18783
  if (inheritsDecoratedClass(classNode)) {
18706
18784
  return fail("inherits-decorated-class");
18707
18785
  }
@@ -18885,6 +18963,7 @@ var init_fastHmrCompiler = __esm(() => {
18885
18963
  init_hmrImportGenerator();
18886
18964
  init_typescript_translator();
18887
18965
  fingerprintCache = new Map;
18966
+ INPUT_OUTPUT_DECORATORS = new Set(["Input", "Output"]);
18888
18967
  providerProbeCache = new Map;
18889
18968
  TS_EXTENSIONS = [".ts", ".tsx", ".d.ts"];
18890
18969
  });
@@ -19050,10 +19129,17 @@ var globalCache, getCachedHmrProgram = () => globalCache.__ABSOLUTE_ANGULAR_HMR_
19050
19129
  const filePathRel = decoded.slice(0, at2);
19051
19130
  const className = decoded.slice(at2 + 1);
19052
19131
  const componentFilePath = resolve32(process.cwd(), filePathRel);
19132
+ const { resolveOwningComponents: resolveOwningComponents2 } = await Promise.resolve().then(() => (init_resolveOwningComponents(), exports_resolveOwningComponents));
19133
+ const owners = resolveOwningComponents2({
19134
+ changedFilePath: componentFilePath,
19135
+ userAngularRoot: dirname19(componentFilePath)
19136
+ });
19137
+ const owner = owners.find((o2) => o2.className === className);
19138
+ const kind = owner?.kind ?? "component";
19053
19139
  const fastStart = performance2.now();
19054
- const fast = await tryFastHmr({ componentFilePath, className });
19140
+ const fast = await tryFastHmr({ className, componentFilePath, kind });
19055
19141
  if (fast.ok) {
19056
- logInfo(`[ng-hmr fast] ${className} ${(performance2.now() - fastStart).toFixed(1)}ms`);
19142
+ logInfo(`[ng-hmr fast/${kind}] ${className} ${(performance2.now() - fastStart).toFixed(1)}ms`);
19057
19143
  return fast.moduleText;
19058
19144
  }
19059
19145
  logWarn(`[ng-hmr slow] ${className} fast path bailed (${fast.reason}${fast.detail ? `: ${fast.detail}` : ""}), falling back to ngtsc`);
@@ -19673,17 +19759,21 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
19673
19759
  changedFilePath: editedFile,
19674
19760
  userAngularRoot: angularDir
19675
19761
  });
19676
- if (owners.length === 0 && editedFile.endsWith(".component.ts")) {
19762
+ if (owners.length === 0 && (editedFile.endsWith(".component.ts") || editedFile.endsWith(".directive.ts") || editedFile.endsWith(".pipe.ts") || editedFile.endsWith(".service.ts"))) {
19677
19763
  return {
19678
- reason: `no @Component class found in ${editedFile}`,
19764
+ reason: `no Angular-decorated class found in ${editedFile}`,
19679
19765
  tier: 1
19680
19766
  };
19681
19767
  }
19682
- for (const { componentFilePath, className } of owners) {
19768
+ for (const { componentFilePath, className, kind } of owners) {
19683
19769
  const id = encodeHmrComponentId2(componentFilePath, className);
19684
19770
  if (queueIds.has(id))
19685
19771
  continue;
19686
- const result = await tryFastHmr2({ className, componentFilePath });
19772
+ const result = await tryFastHmr2({
19773
+ className,
19774
+ componentFilePath,
19775
+ kind
19776
+ });
19687
19777
  if (!result.ok) {
19688
19778
  return {
19689
19779
  reason: `${className}: ${result.reason}${result.detail ? ` (${result.detail})` : ""}`,
@@ -21491,5 +21581,5 @@ export {
21491
21581
  build
21492
21582
  };
21493
21583
 
21494
- //# debugId=0DF8D7C94DA9EB2864756E2164756E21
21584
+ //# debugId=B20F16F557D901EC64756E2164756E21
21495
21585
  //# sourceMappingURL=build.js.map