@absolutejs/absolute 0.19.0-beta.855 → 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.
package/dist/index.js CHANGED
@@ -18287,40 +18287,38 @@ __export(exports_fastHmrCompiler, {
18287
18287
  recordFingerprint: () => recordFingerprint,
18288
18288
  invalidateFingerprintCache: () => invalidateFingerprintCache
18289
18289
  });
18290
- import { existsSync as existsSync26, readFileSync as readFileSync20 } from "fs";
18290
+ import { existsSync as existsSync26, readFileSync as readFileSync20, statSync as statSync4 } from "fs";
18291
18291
  import { dirname as dirname19, relative as relative13, resolve as resolve33 } from "path";
18292
18292
  import ts7 from "typescript";
18293
- var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache, fingerprintsEqual = (a, b2) => {
18293
+ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache, arraysEqual = (a, b2) => {
18294
+ if (a.length !== b2.length)
18295
+ return false;
18296
+ for (let i = 0;i < a.length; i++) {
18297
+ if (a[i] !== b2[i])
18298
+ return false;
18299
+ }
18300
+ return true;
18301
+ }, fingerprintsEqual = (a, b2) => {
18294
18302
  if (a.className !== b2.className)
18295
18303
  return false;
18296
18304
  if (a.selector !== b2.selector)
18297
18305
  return false;
18298
18306
  if (a.standalone !== b2.standalone)
18299
18307
  return false;
18300
- if (a.importsArity !== b2.importsArity)
18301
- return false;
18302
18308
  if (a.hasProviders !== b2.hasProviders)
18303
18309
  return false;
18304
18310
  if (a.hasViewProviders !== b2.hasViewProviders)
18305
18311
  return false;
18306
- if (a.ctorParamTypes.length !== b2.ctorParamTypes.length)
18312
+ if (!arraysEqual(a.ctorParamTypes, b2.ctorParamTypes))
18307
18313
  return false;
18308
- for (let i = 0;i < a.ctorParamTypes.length; i++) {
18309
- if (a.ctorParamTypes[i] !== b2.ctorParamTypes[i])
18310
- return false;
18311
- }
18312
- if (a.inputs.length !== b2.inputs.length)
18314
+ if (!arraysEqual(a.inputs, b2.inputs))
18313
18315
  return false;
18314
- for (let i = 0;i < a.inputs.length; i++) {
18315
- if (a.inputs[i] !== b2.inputs[i])
18316
- return false;
18317
- }
18318
- if (a.outputs.length !== b2.outputs.length)
18316
+ if (!arraysEqual(a.outputs, b2.outputs))
18317
+ return false;
18318
+ if (!arraysEqual(a.providerImportSig, b2.providerImportSig))
18319
+ return false;
18320
+ if (!arraysEqual(a.arrowFieldSig, b2.arrowFieldSig))
18319
18321
  return false;
18320
- for (let i = 0;i < a.outputs.length; i++) {
18321
- if (a.outputs[i] !== b2.outputs[i])
18322
- return false;
18323
- }
18324
18322
  return true;
18325
18323
  }, recordFingerprint = (id, fp) => {
18326
18324
  fingerprintCache.set(id, fp);
@@ -18568,7 +18566,137 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18568
18566
  }
18569
18567
  }
18570
18568
  return { inputs, outputs };
18571
- }, extractFingerprint = (cls, className, decoratorMeta, inputs, outputs) => {
18569
+ }, djb2Hash = (s2) => {
18570
+ let h2 = 5381;
18571
+ for (let i = 0;i < s2.length; i++) {
18572
+ h2 = h2 * 33 ^ s2.charCodeAt(i);
18573
+ }
18574
+ return (h2 >>> 0).toString(36);
18575
+ }, extractArrowFieldSig = (cls) => {
18576
+ const entries = [];
18577
+ for (const member of cls.members) {
18578
+ if (!ts7.isPropertyDeclaration(member))
18579
+ continue;
18580
+ const init = member.initializer;
18581
+ if (!init)
18582
+ continue;
18583
+ if (!ts7.isArrowFunction(init) && !ts7.isFunctionExpression(init)) {
18584
+ continue;
18585
+ }
18586
+ const name = member.name.getText();
18587
+ const bodyHash = djb2Hash(init.getText());
18588
+ entries.push(`${name}:${bodyHash}`);
18589
+ }
18590
+ return entries.sort();
18591
+ }, providerProbeCache, fileHasModuleProviders = (filePath) => {
18592
+ let stat3;
18593
+ try {
18594
+ stat3 = statSync4(filePath);
18595
+ } catch {
18596
+ return true;
18597
+ }
18598
+ const cached = providerProbeCache.get(filePath);
18599
+ if (cached && cached.mtimeMs === stat3.mtimeMs)
18600
+ return cached.hasProviders;
18601
+ let source;
18602
+ try {
18603
+ source = readFileSync20(filePath, "utf8");
18604
+ } catch {
18605
+ return true;
18606
+ }
18607
+ const sf = ts7.createSourceFile(filePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
18608
+ let hasProviders = false;
18609
+ const visit = (node) => {
18610
+ if (hasProviders)
18611
+ return;
18612
+ if (ts7.isClassDeclaration(node)) {
18613
+ for (const decorator of ts7.getDecorators(node) ?? []) {
18614
+ const expr = decorator.expression;
18615
+ if (!ts7.isCallExpression(expr))
18616
+ continue;
18617
+ const arg = expr.arguments[0];
18618
+ if (!arg || !ts7.isObjectLiteralExpression(arg))
18619
+ continue;
18620
+ if (getProperty(arg, "providers") !== null) {
18621
+ hasProviders = true;
18622
+ return;
18623
+ }
18624
+ }
18625
+ }
18626
+ ts7.forEachChild(node, visit);
18627
+ };
18628
+ visit(sf);
18629
+ providerProbeCache.set(filePath, {
18630
+ hasProviders,
18631
+ mtimeMs: stat3.mtimeMs
18632
+ });
18633
+ return hasProviders;
18634
+ }, TS_EXTENSIONS, resolveImportSource = (identifierName, sourceFile, componentDir) => {
18635
+ for (const stmt of sourceFile.statements) {
18636
+ if (!ts7.isImportDeclaration(stmt))
18637
+ continue;
18638
+ const moduleSpec = stmt.moduleSpecifier;
18639
+ if (!ts7.isStringLiteral(moduleSpec))
18640
+ continue;
18641
+ const spec = moduleSpec.text;
18642
+ if (!spec.startsWith(".") && !spec.startsWith("/"))
18643
+ continue;
18644
+ const importClause = stmt.importClause;
18645
+ if (!importClause)
18646
+ continue;
18647
+ let matches = false;
18648
+ if (importClause.name && importClause.name.text === identifierName) {
18649
+ matches = true;
18650
+ }
18651
+ if (importClause.namedBindings) {
18652
+ const nb = importClause.namedBindings;
18653
+ if (ts7.isNamespaceImport(nb)) {
18654
+ if (nb.name.text === identifierName)
18655
+ matches = true;
18656
+ } else {
18657
+ for (const element of nb.elements) {
18658
+ if (element.name.text === identifierName) {
18659
+ matches = true;
18660
+ break;
18661
+ }
18662
+ }
18663
+ }
18664
+ }
18665
+ if (!matches)
18666
+ continue;
18667
+ const resolved = resolve33(componentDir, spec);
18668
+ for (const ext of TS_EXTENSIONS) {
18669
+ const candidate = resolved + ext;
18670
+ if (existsSync26(candidate))
18671
+ return candidate;
18672
+ }
18673
+ const indexCandidate = resolve33(resolved, "index.ts");
18674
+ if (existsSync26(indexCandidate))
18675
+ return indexCandidate;
18676
+ }
18677
+ return null;
18678
+ }, extractProviderImportSig = (importsExpr, sourceFile, componentDir) => {
18679
+ if (!importsExpr)
18680
+ return [];
18681
+ const sig = [];
18682
+ for (const entry of importsExpr.elements) {
18683
+ if (ts7.isIdentifier(entry)) {
18684
+ const importPath = resolveImportSource(entry.text, sourceFile, componentDir);
18685
+ if (importPath) {
18686
+ if (fileHasModuleProviders(importPath)) {
18687
+ sig.push(`P:${entry.text}`);
18688
+ }
18689
+ continue;
18690
+ }
18691
+ if (/Module$/.test(entry.text)) {
18692
+ sig.push(`P:${entry.text}`);
18693
+ }
18694
+ } else {
18695
+ sig.push(`P:${entry.getText()}`);
18696
+ }
18697
+ }
18698
+ return sig.sort();
18699
+ }, extractFingerprint = (cls, className, decoratorMeta, inputs, outputs, sourceFile, componentDir) => {
18572
18700
  const ctorParamTypes = [];
18573
18701
  for (const member of cls.members) {
18574
18702
  if (!ts7.isConstructorDeclaration(member))
@@ -18580,17 +18708,17 @@ var fail = (reason, detail) => ({ ok: false, reason, detail }), fingerprintCache
18580
18708
  }
18581
18709
  const inputNames = Object.keys(inputs).sort();
18582
18710
  const outputNames = Object.keys(outputs).sort();
18583
- const importsArity = decoratorMeta.importsExpr ? decoratorMeta.importsExpr.elements.length : 0;
18584
- const hasProviders = decoratorMeta.hasProviders;
18585
- const hasViewProviders = decoratorMeta.hasViewProviders;
18711
+ const arrowFieldSig = extractArrowFieldSig(cls);
18712
+ const providerImportSig = extractProviderImportSig(decoratorMeta.importsExpr, sourceFile, componentDir);
18586
18713
  return {
18714
+ arrowFieldSig,
18587
18715
  className,
18588
18716
  ctorParamTypes,
18589
- hasProviders,
18590
- hasViewProviders,
18591
- importsArity,
18717
+ hasProviders: decoratorMeta.hasProviders,
18718
+ hasViewProviders: decoratorMeta.hasViewProviders,
18592
18719
  inputs: inputNames,
18593
18720
  outputs: outputNames,
18721
+ providerImportSig,
18594
18722
  selector: decoratorMeta.selector,
18595
18723
  standalone: decoratorMeta.standalone
18596
18724
  };
@@ -18722,7 +18850,7 @@ ${transpiled}
18722
18850
  const { inputs, outputs } = extractInputsAndOutputs(classNode);
18723
18851
  const projectRelPath = relative13(projectRoot, componentFilePath).replace(/\\/g, "/");
18724
18852
  const fingerprintId = encodeURIComponent(`${projectRelPath}@${className}`);
18725
- const currentFingerprint = extractFingerprint(classNode, className, decoratorMeta, inputs, outputs);
18853
+ const currentFingerprint = extractFingerprint(classNode, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
18726
18854
  const cachedFingerprint = fingerprintCache.get(fingerprintId);
18727
18855
  if (cachedFingerprint && !fingerprintsEqual(cachedFingerprint, currentFingerprint)) {
18728
18856
  return fail("structural-change", `fingerprint changed for ${className}; escalate to Tier 1`);
@@ -18854,6 +18982,8 @@ var init_fastHmrCompiler = __esm(() => {
18854
18982
  init_hmrImportGenerator();
18855
18983
  init_typescript_translator();
18856
18984
  fingerprintCache = new Map;
18985
+ providerProbeCache = new Map;
18986
+ TS_EXTENSIONS = [".ts", ".tsx", ".d.ts"];
18857
18987
  });
18858
18988
 
18859
18989
  // src/dev/angular/hmrCompiler.ts
@@ -21078,7 +21208,7 @@ __export(exports_devBuild, {
21078
21208
  devBuild: () => devBuild
21079
21209
  });
21080
21210
  import { readdir as readdir5 } from "fs/promises";
21081
- import { statSync as statSync4 } from "fs";
21211
+ import { statSync as statSync5 } from "fs";
21082
21212
  import { resolve as resolve38 } from "path";
21083
21213
  var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
21084
21214
  const configuredDirs = [
@@ -21187,7 +21317,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
21187
21317
  state.fileChangeQueue.clear();
21188
21318
  }
21189
21319
  }, handleCachedReload = async () => {
21190
- const serverMtime = statSync4(resolve38(Bun.main)).mtimeMs;
21320
+ const serverMtime = statSync5(resolve38(Bun.main)).mtimeMs;
21191
21321
  const lastMtime = globalThis.__hmrServerMtime;
21192
21322
  globalThis.__hmrServerMtime = serverMtime;
21193
21323
  const cached = globalThis.__hmrDevResult;
@@ -21401,7 +21531,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
21401
21531
  manifest
21402
21532
  };
21403
21533
  globalThis.__hmrDevResult = result;
21404
- globalThis.__hmrServerMtime = statSync4(resolve38(Bun.main)).mtimeMs;
21534
+ globalThis.__hmrServerMtime = statSync5(resolve38(Bun.main)).mtimeMs;
21405
21535
  return result;
21406
21536
  };
21407
21537
  var init_devBuild = __esm(() => {
@@ -30003,5 +30133,5 @@ export {
30003
30133
  ANGULAR_INIT_TIMEOUT_MS
30004
30134
  };
30005
30135
 
30006
- //# debugId=A3C5EF48AC33740564756E2164756E21
30136
+ //# debugId=2BA92AA7B0159DCB64756E2164756E21
30007
30137
  //# sourceMappingURL=index.js.map