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

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-Z1uJ5x/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-Md8b3A/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-Z1uJ5x/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-Md8b3A/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-Z1uJ5x/src/core/streamingSlotRegistry.ts
51
+ // .angular-partial-tmp-Md8b3A/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
@@ -18190,40 +18190,38 @@ __export(exports_fastHmrCompiler, {
18190
18190
  recordFingerprint: () => recordFingerprint,
18191
18191
  invalidateFingerprintCache: () => invalidateFingerprintCache
18192
18192
  });
18193
- import { existsSync as existsSync25, readFileSync as readFileSync19 } from "fs";
18193
+ import { existsSync as existsSync25, readFileSync as readFileSync19, statSync as statSync4 } from "fs";
18194
18194
  import { dirname as dirname18, relative as relative13, resolve as resolve31 } from "path";
18195
18195
  import ts7 from "typescript";
18196
- var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache, fingerprintsEqual = (a, b2) => {
18196
+ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache, arraysEqual = (a, b2) => {
18197
+ if (a.length !== b2.length)
18198
+ return false;
18199
+ for (let i = 0;i < a.length; i++) {
18200
+ if (a[i] !== b2[i])
18201
+ return false;
18202
+ }
18203
+ return true;
18204
+ }, fingerprintsEqual = (a, b2) => {
18197
18205
  if (a.className !== b2.className)
18198
18206
  return false;
18199
18207
  if (a.selector !== b2.selector)
18200
18208
  return false;
18201
18209
  if (a.standalone !== b2.standalone)
18202
18210
  return false;
18203
- if (a.importsArity !== b2.importsArity)
18204
- return false;
18205
18211
  if (a.hasProviders !== b2.hasProviders)
18206
18212
  return false;
18207
18213
  if (a.hasViewProviders !== b2.hasViewProviders)
18208
18214
  return false;
18209
- if (a.ctorParamTypes.length !== b2.ctorParamTypes.length)
18215
+ if (!arraysEqual(a.ctorParamTypes, b2.ctorParamTypes))
18210
18216
  return false;
18211
- for (let i = 0;i < a.ctorParamTypes.length; i++) {
18212
- if (a.ctorParamTypes[i] !== b2.ctorParamTypes[i])
18213
- return false;
18214
- }
18215
- if (a.inputs.length !== b2.inputs.length)
18217
+ if (!arraysEqual(a.inputs, b2.inputs))
18216
18218
  return false;
18217
- for (let i = 0;i < a.inputs.length; i++) {
18218
- if (a.inputs[i] !== b2.inputs[i])
18219
- return false;
18220
- }
18221
- if (a.outputs.length !== b2.outputs.length)
18219
+ if (!arraysEqual(a.outputs, b2.outputs))
18220
+ return false;
18221
+ if (!arraysEqual(a.providerImportSig, b2.providerImportSig))
18222
+ return false;
18223
+ if (!arraysEqual(a.arrowFieldSig, b2.arrowFieldSig))
18222
18224
  return false;
18223
- for (let i = 0;i < a.outputs.length; i++) {
18224
- if (a.outputs[i] !== b2.outputs[i])
18225
- return false;
18226
- }
18227
18225
  return true;
18228
18226
  }, recordFingerprint = (id, fp) => {
18229
18227
  fingerprintCache.set(id, fp);
@@ -18471,7 +18469,137 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18471
18469
  }
18472
18470
  }
18473
18471
  return { inputs, outputs };
18474
- }, extractFingerprint = (cls, className, decoratorMeta, inputs, outputs) => {
18472
+ }, djb2Hash = (s2) => {
18473
+ let h2 = 5381;
18474
+ for (let i = 0;i < s2.length; i++) {
18475
+ h2 = h2 * 33 ^ s2.charCodeAt(i);
18476
+ }
18477
+ return (h2 >>> 0).toString(36);
18478
+ }, extractArrowFieldSig = (cls) => {
18479
+ const entries = [];
18480
+ for (const member of cls.members) {
18481
+ if (!ts7.isPropertyDeclaration(member))
18482
+ continue;
18483
+ const init = member.initializer;
18484
+ if (!init)
18485
+ continue;
18486
+ if (!ts7.isArrowFunction(init) && !ts7.isFunctionExpression(init)) {
18487
+ continue;
18488
+ }
18489
+ const name = member.name.getText();
18490
+ const bodyHash = djb2Hash(init.getText());
18491
+ entries.push(`${name}:${bodyHash}`);
18492
+ }
18493
+ return entries.sort();
18494
+ }, providerProbeCache, fileHasModuleProviders = (filePath) => {
18495
+ let stat3;
18496
+ try {
18497
+ stat3 = statSync4(filePath);
18498
+ } catch {
18499
+ return true;
18500
+ }
18501
+ const cached = providerProbeCache.get(filePath);
18502
+ if (cached && cached.mtimeMs === stat3.mtimeMs)
18503
+ return cached.hasProviders;
18504
+ let source;
18505
+ try {
18506
+ source = readFileSync19(filePath, "utf8");
18507
+ } catch {
18508
+ return true;
18509
+ }
18510
+ const sf = ts7.createSourceFile(filePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
18511
+ let hasProviders = false;
18512
+ const visit = (node) => {
18513
+ if (hasProviders)
18514
+ return;
18515
+ if (ts7.isClassDeclaration(node)) {
18516
+ for (const decorator of ts7.getDecorators(node) ?? []) {
18517
+ const expr = decorator.expression;
18518
+ if (!ts7.isCallExpression(expr))
18519
+ continue;
18520
+ const arg = expr.arguments[0];
18521
+ if (!arg || !ts7.isObjectLiteralExpression(arg))
18522
+ continue;
18523
+ if (getProperty(arg, "providers") !== null) {
18524
+ hasProviders = true;
18525
+ return;
18526
+ }
18527
+ }
18528
+ }
18529
+ ts7.forEachChild(node, visit);
18530
+ };
18531
+ visit(sf);
18532
+ providerProbeCache.set(filePath, {
18533
+ hasProviders,
18534
+ mtimeMs: stat3.mtimeMs
18535
+ });
18536
+ return hasProviders;
18537
+ }, TS_EXTENSIONS, resolveImportSource = (identifierName, sourceFile, componentDir) => {
18538
+ for (const stmt of sourceFile.statements) {
18539
+ if (!ts7.isImportDeclaration(stmt))
18540
+ continue;
18541
+ const moduleSpec = stmt.moduleSpecifier;
18542
+ if (!ts7.isStringLiteral(moduleSpec))
18543
+ continue;
18544
+ const spec = moduleSpec.text;
18545
+ if (!spec.startsWith(".") && !spec.startsWith("/"))
18546
+ continue;
18547
+ const importClause = stmt.importClause;
18548
+ if (!importClause)
18549
+ continue;
18550
+ let matches = false;
18551
+ if (importClause.name && importClause.name.text === identifierName) {
18552
+ matches = true;
18553
+ }
18554
+ if (importClause.namedBindings) {
18555
+ const nb = importClause.namedBindings;
18556
+ if (ts7.isNamespaceImport(nb)) {
18557
+ if (nb.name.text === identifierName)
18558
+ matches = true;
18559
+ } else {
18560
+ for (const element of nb.elements) {
18561
+ if (element.name.text === identifierName) {
18562
+ matches = true;
18563
+ break;
18564
+ }
18565
+ }
18566
+ }
18567
+ }
18568
+ if (!matches)
18569
+ continue;
18570
+ const resolved = resolve31(componentDir, spec);
18571
+ for (const ext of TS_EXTENSIONS) {
18572
+ const candidate = resolved + ext;
18573
+ if (existsSync25(candidate))
18574
+ return candidate;
18575
+ }
18576
+ const indexCandidate = resolve31(resolved, "index.ts");
18577
+ if (existsSync25(indexCandidate))
18578
+ return indexCandidate;
18579
+ }
18580
+ return null;
18581
+ }, extractProviderImportSig = (importsExpr, sourceFile, componentDir) => {
18582
+ if (!importsExpr)
18583
+ return [];
18584
+ const sig = [];
18585
+ for (const entry of importsExpr.elements) {
18586
+ if (ts7.isIdentifier(entry)) {
18587
+ const importPath = resolveImportSource(entry.text, sourceFile, componentDir);
18588
+ if (importPath) {
18589
+ if (fileHasModuleProviders(importPath)) {
18590
+ sig.push(`P:${entry.text}`);
18591
+ }
18592
+ continue;
18593
+ }
18594
+ if (/Module$/.test(entry.text)) {
18595
+ sig.push(`P:${entry.text}`);
18596
+ }
18597
+ } else {
18598
+ sig.push(`P:${entry.getText()}`);
18599
+ }
18600
+ }
18601
+ return sig.sort();
18602
+ }, extractFingerprint = (cls, className, decoratorMeta, inputs, outputs, sourceFile, componentDir) => {
18475
18603
  const ctorParamTypes = [];
18476
18604
  for (const member of cls.members) {
18477
18605
  if (!ts7.isConstructorDeclaration(member))
@@ -18483,20 +18611,61 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18483
18611
  }
18484
18612
  const inputNames = Object.keys(inputs).sort();
18485
18613
  const outputNames = Object.keys(outputs).sort();
18486
- const importsArity = decoratorMeta.importsExpr ? decoratorMeta.importsExpr.elements.length : 0;
18487
- const hasProviders = decoratorMeta.hasProviders;
18488
- const hasViewProviders = decoratorMeta.hasViewProviders;
18614
+ const arrowFieldSig = extractArrowFieldSig(cls);
18615
+ const providerImportSig = extractProviderImportSig(decoratorMeta.importsExpr, sourceFile, componentDir);
18489
18616
  return {
18617
+ arrowFieldSig,
18490
18618
  className,
18491
18619
  ctorParamTypes,
18492
- hasProviders,
18493
- hasViewProviders,
18494
- importsArity,
18620
+ hasProviders: decoratorMeta.hasProviders,
18621
+ hasViewProviders: decoratorMeta.hasViewProviders,
18495
18622
  inputs: inputNames,
18496
18623
  outputs: outputNames,
18624
+ providerImportSig,
18497
18625
  selector: decoratorMeta.selector,
18498
18626
  standalone: decoratorMeta.standalone
18499
18627
  };
18628
+ }, buildFreshClassMethodsBlock = (classNode, className) => {
18629
+ const methodSources = [];
18630
+ for (const member of classNode.members) {
18631
+ 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
+ methodSources.push(member.getText());
18637
+ }
18638
+ }
18639
+ if (methodSources.length === 0)
18640
+ return null;
18641
+ const wrappedSource = `class _Fresh {
18642
+ ${methodSources.join(`
18643
+ `)}
18644
+ }`;
18645
+ let transpiled;
18646
+ try {
18647
+ transpiled = ts7.transpileModule(wrappedSource, {
18648
+ compilerOptions: {
18649
+ module: ts7.ModuleKind.ES2022,
18650
+ target: ts7.ScriptTarget.ES2022
18651
+ },
18652
+ reportDiagnostics: false
18653
+ }).outputText;
18654
+ } catch {
18655
+ return null;
18656
+ }
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).
18660
+ ${transpiled}
18661
+ {
18662
+ const __fresh_proto = _Fresh.prototype;
18663
+ for (const __name of Object.getOwnPropertyNames(__fresh_proto)) {
18664
+ if (__name === 'constructor') continue;
18665
+ const __desc = Object.getOwnPropertyDescriptor(__fresh_proto, __name);
18666
+ if (__desc) Object.defineProperty(${className}.prototype, __name, __desc);
18667
+ }
18668
+ }`;
18500
18669
  }, resolveAndReadResource = (componentDir, url) => {
18501
18670
  const abs = resolve31(componentDir, url);
18502
18671
  if (!existsSync25(abs))
@@ -18584,7 +18753,7 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18584
18753
  const { inputs, outputs } = extractInputsAndOutputs(classNode);
18585
18754
  const projectRelPath = relative13(projectRoot, componentFilePath).replace(/\\/g, "/");
18586
18755
  const fingerprintId = encodeURIComponent(`${projectRelPath}@${className}`);
18587
- const currentFingerprint = extractFingerprint(classNode, className, decoratorMeta, inputs, outputs);
18756
+ const currentFingerprint = extractFingerprint(classNode, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
18588
18757
  const cachedFingerprint = fingerprintCache.get(fingerprintId);
18589
18758
  if (cachedFingerprint && !fingerprintsEqual(cachedFingerprint, currentFingerprint)) {
18590
18759
  return fail("structural-change", `fingerprint changed for ${className}; escalate to Tier 1`);
@@ -18686,7 +18855,7 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18686
18855
  removeComments: false
18687
18856
  });
18688
18857
  const tsSourceText = printer.printNode(ts7.EmitHint.Unspecified, exportedDecl, sourceFile);
18689
- const moduleText = ts7.transpileModule(tsSourceText, {
18858
+ const transpiled = ts7.transpileModule(tsSourceText, {
18690
18859
  compilerOptions: {
18691
18860
  module: ts7.ModuleKind.ES2022,
18692
18861
  target: ts7.ScriptTarget.ES2022
@@ -18694,6 +18863,18 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18694
18863
  fileName: componentFilePath,
18695
18864
  reportDiagnostics: false
18696
18865
  }).outputText;
18866
+ const methodsBlock = buildFreshClassMethodsBlock(classNode, className);
18867
+ let moduleText = transpiled;
18868
+ if (methodsBlock) {
18869
+ const fnOpening = `function ${className}_UpdateMetadata(${className}, \u0275\u0275namespaces) {`;
18870
+ const idx = moduleText.indexOf(fnOpening);
18871
+ if (idx >= 0) {
18872
+ const insertAt = idx + fnOpening.length;
18873
+ moduleText = moduleText.slice(0, insertAt) + `
18874
+ ` + methodsBlock + `
18875
+ ` + moduleText.slice(insertAt);
18876
+ }
18877
+ }
18697
18878
  fingerprintCache.set(fingerprintId, currentFingerprint);
18698
18879
  return { ok: true, moduleText, componentSource: sourceFile };
18699
18880
  } catch (err) {
@@ -18704,6 +18885,8 @@ var init_fastHmrCompiler = __esm(() => {
18704
18885
  init_hmrImportGenerator();
18705
18886
  init_typescript_translator();
18706
18887
  fingerprintCache = new Map;
18888
+ providerProbeCache = new Map;
18889
+ TS_EXTENSIONS = [".ts", ".tsx", ".d.ts"];
18707
18890
  });
18708
18891
 
18709
18892
  // src/dev/angular/hmrCompiler.ts
@@ -20948,7 +21131,7 @@ __export(exports_devBuild, {
20948
21131
  devBuild: () => devBuild
20949
21132
  });
20950
21133
  import { readdir as readdir5 } from "fs/promises";
20951
- import { statSync as statSync4 } from "fs";
21134
+ import { statSync as statSync5 } from "fs";
20952
21135
  import { resolve as resolve36 } from "path";
20953
21136
  var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
20954
21137
  const configuredDirs = [
@@ -21057,7 +21240,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
21057
21240
  state.fileChangeQueue.clear();
21058
21241
  }
21059
21242
  }, handleCachedReload = async () => {
21060
- const serverMtime = statSync4(resolve36(Bun.main)).mtimeMs;
21243
+ const serverMtime = statSync5(resolve36(Bun.main)).mtimeMs;
21061
21244
  const lastMtime = globalThis.__hmrServerMtime;
21062
21245
  globalThis.__hmrServerMtime = serverMtime;
21063
21246
  const cached = globalThis.__hmrDevResult;
@@ -21271,7 +21454,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
21271
21454
  manifest
21272
21455
  };
21273
21456
  globalThis.__hmrDevResult = result;
21274
- globalThis.__hmrServerMtime = statSync4(resolve36(Bun.main)).mtimeMs;
21457
+ globalThis.__hmrServerMtime = statSync5(resolve36(Bun.main)).mtimeMs;
21275
21458
  return result;
21276
21459
  };
21277
21460
  var init_devBuild = __esm(() => {
@@ -21308,5 +21491,5 @@ export {
21308
21491
  build
21309
21492
  };
21310
21493
 
21311
- //# debugId=A6EDFBBC6FF9BB9264756E2164756E21
21494
+ //# debugId=0DF8D7C94DA9EB2864756E2164756E21
21312
21495
  //# sourceMappingURL=build.js.map