@absolutejs/absolute 0.19.0-beta.924 → 0.19.0-beta.926

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
@@ -17789,6 +17789,7 @@ var init_rewriteImports = __esm(() => {
17789
17789
  var exports_resolveOwningComponents = {};
17790
17790
  __export(exports_resolveOwningComponents, {
17791
17791
  resolveOwningComponents: () => resolveOwningComponents,
17792
+ resolveDescendantsOfParent: () => resolveDescendantsOfParent,
17792
17793
  invalidateResourceIndex: () => invalidateResourceIndex
17793
17794
  });
17794
17795
  import { readdirSync as readdirSync2, readFileSync as readFileSync19, statSync as statSync3 } from "fs";
@@ -17869,11 +17870,23 @@ var ENTITY_DECORATORS, isAngularSourceFile = (file5) => file5.endsWith(".ts") ||
17869
17870
  const kind = ENTITY_DECORATORS[fn2.text];
17870
17871
  if (!kind)
17871
17872
  continue;
17873
+ let extendsName = null;
17874
+ for (const heritage of node.heritageClauses ?? []) {
17875
+ if (heritage.token !== ts3.SyntaxKind.ExtendsKeyword) {
17876
+ continue;
17877
+ }
17878
+ const first = heritage.types[0];
17879
+ if (first && ts3.isIdentifier(first.expression)) {
17880
+ extendsName = first.expression.text;
17881
+ }
17882
+ break;
17883
+ }
17872
17884
  const entry = {
17873
17885
  className: node.name.text,
17874
17886
  kind,
17875
17887
  styleUrls: [],
17876
- templateUrls: []
17888
+ templateUrls: [],
17889
+ extendsName
17877
17890
  };
17878
17891
  const arg = expr.arguments[0];
17879
17892
  if (arg && ts3.isObjectLiteralExpression(arg) && kind === "component") {
@@ -17926,36 +17939,117 @@ var ENTITY_DECORATORS, isAngularSourceFile = (file5) => file5.endsWith(".ts") ||
17926
17939
  out.push(...owners);
17927
17940
  }
17928
17941
  return out;
17929
- }, resourceIndexByRoot, getOrBuildResourceIndex = (userAngularRoot) => {
17930
- const cached = resourceIndexByRoot.get(userAngularRoot);
17942
+ }, indexByRoot, resolveParentClassFile = (parentName, childFilePath, angularRoot) => {
17943
+ let source;
17944
+ try {
17945
+ source = readFileSync19(childFilePath, "utf8");
17946
+ } catch {
17947
+ return null;
17948
+ }
17949
+ const sf = ts3.createSourceFile(childFilePath, source, ts3.ScriptTarget.ES2022, true, ts3.ScriptKind.TS);
17950
+ const childDir = dirname18(childFilePath);
17951
+ for (const stmt of sf.statements) {
17952
+ if (!ts3.isImportDeclaration(stmt))
17953
+ continue;
17954
+ if (!ts3.isStringLiteral(stmt.moduleSpecifier))
17955
+ continue;
17956
+ const clause = stmt.importClause;
17957
+ if (!clause || clause.isTypeOnly)
17958
+ continue;
17959
+ let matchesName = false;
17960
+ if (clause.name && clause.name.text === parentName)
17961
+ matchesName = true;
17962
+ if (!matchesName && clause.namedBindings && ts3.isNamedImports(clause.namedBindings)) {
17963
+ for (const el of clause.namedBindings.elements) {
17964
+ if (el.isTypeOnly)
17965
+ continue;
17966
+ if (el.name.text === parentName) {
17967
+ matchesName = true;
17968
+ break;
17969
+ }
17970
+ }
17971
+ }
17972
+ if (!matchesName)
17973
+ continue;
17974
+ const spec = stmt.moduleSpecifier.text;
17975
+ if (!spec.startsWith(".") && !spec.startsWith("/")) {
17976
+ return null;
17977
+ }
17978
+ const base = resolve33(childDir, spec);
17979
+ const candidates = [
17980
+ `${base}.ts`,
17981
+ `${base}.tsx`,
17982
+ `${base}/index.ts`,
17983
+ `${base}/index.tsx`
17984
+ ];
17985
+ const angularRootNorm = safeNormalize(angularRoot);
17986
+ for (const candidate of candidates) {
17987
+ try {
17988
+ if (statSync3(candidate).isFile()) {
17989
+ const norm = safeNormalize(candidate);
17990
+ if (!norm.startsWith(angularRootNorm))
17991
+ return null;
17992
+ return norm;
17993
+ }
17994
+ } catch {}
17995
+ }
17996
+ return null;
17997
+ }
17998
+ return null;
17999
+ }, getOrBuildIndexes = (userAngularRoot) => {
18000
+ const cached = indexByRoot.get(userAngularRoot);
17931
18001
  if (cached)
17932
18002
  return cached;
17933
- const index = new Map;
18003
+ const resource = new Map;
18004
+ const parentFile = new Map;
17934
18005
  for (const tsPath of walkAngularSourceFiles(userAngularRoot)) {
17935
18006
  const classes = parseDecoratedClasses(tsPath);
17936
18007
  const componentDir = dirname18(tsPath);
17937
18008
  for (const cls of classes) {
17938
- if (cls.kind !== "component")
17939
- continue;
17940
- const owner = {
18009
+ const entity = {
17941
18010
  className: cls.className,
17942
18011
  componentFilePath: tsPath,
17943
- kind: "component"
18012
+ kind: cls.kind
17944
18013
  };
17945
- for (const url of [...cls.templateUrls, ...cls.styleUrls]) {
17946
- const abs = safeNormalize(resolve33(componentDir, url));
17947
- const existing = index.get(abs);
17948
- if (existing)
17949
- existing.push(owner);
17950
- else
17951
- index.set(abs, [owner]);
18014
+ if (cls.kind === "component") {
18015
+ for (const url of [...cls.templateUrls, ...cls.styleUrls]) {
18016
+ const abs = safeNormalize(resolve33(componentDir, url));
18017
+ const existing = resource.get(abs);
18018
+ if (existing)
18019
+ existing.push(entity);
18020
+ else
18021
+ resource.set(abs, [entity]);
18022
+ }
18023
+ }
18024
+ if (cls.extendsName !== null) {
18025
+ const parentPath = resolveParentClassFile(cls.extendsName, tsPath, userAngularRoot);
18026
+ if (parentPath !== null && parentPath !== safeNormalize(tsPath)) {
18027
+ const existing = parentFile.get(parentPath);
18028
+ if (existing)
18029
+ existing.push(entity);
18030
+ else
18031
+ parentFile.set(parentPath, [entity]);
18032
+ }
17952
18033
  }
17953
18034
  }
17954
18035
  }
17955
- resourceIndexByRoot.set(userAngularRoot, index);
17956
- return index;
18036
+ const bundle = { parentFile, resource };
18037
+ indexByRoot.set(userAngularRoot, bundle);
18038
+ return bundle;
18039
+ }, getOrBuildResourceIndex = (userAngularRoot) => getOrBuildIndexes(userAngularRoot).resource, resolveDescendantsOfParent = (params) => {
18040
+ const norm = safeNormalize(params.changedFilePath);
18041
+ let rootStat;
18042
+ try {
18043
+ rootStat = statSync3(params.userAngularRoot);
18044
+ } catch {
18045
+ return [];
18046
+ }
18047
+ if (!rootStat.isDirectory())
18048
+ return [];
18049
+ const bundle = getOrBuildIndexes(params.userAngularRoot);
18050
+ return bundle.parentFile.get(norm) ?? [];
17957
18051
  }, invalidateResourceIndex = () => {
17958
- resourceIndexByRoot.clear();
18052
+ indexByRoot.clear();
17959
18053
  };
17960
18054
  var init_resolveOwningComponents = __esm(() => {
17961
18055
  ENTITY_DECORATORS = {
@@ -17964,7 +18058,7 @@ var init_resolveOwningComponents = __esm(() => {
17964
18058
  Pipe: "pipe",
17965
18059
  Injectable: "service"
17966
18060
  };
17967
- resourceIndexByRoot = new Map;
18061
+ indexByRoot = new Map;
17968
18062
  });
17969
18063
 
17970
18064
  // src/dev/angular/hmrImportGenerator.ts
@@ -18702,6 +18796,74 @@ var fail = (reason, detail, location) => ({
18702
18796
  fingerprintCache.set(id, fp);
18703
18797
  }, invalidateFingerprintCache = () => {
18704
18798
  fingerprintCache.clear();
18799
+ entityFingerprintCache.clear();
18800
+ }, entityFingerprintCache, entityFingerprintsEqual = (a, b2) => {
18801
+ if (a.className !== b2.className)
18802
+ return false;
18803
+ if (a.decoratorArgsText !== b2.decoratorArgsText)
18804
+ return false;
18805
+ if (!arraysEqual(a.ctorParamTypes, b2.ctorParamTypes))
18806
+ return false;
18807
+ if (!arraysEqual(a.topLevelImports, b2.topLevelImports))
18808
+ return false;
18809
+ if (!arraysEqual(a.memberDecoratorSig, b2.memberDecoratorSig))
18810
+ return false;
18811
+ if (!arraysEqual(a.arrowFieldSig, b2.arrowFieldSig))
18812
+ return false;
18813
+ if (!arraysEqual(a.propertyFieldNames, b2.propertyFieldNames))
18814
+ return false;
18815
+ return true;
18816
+ }, ENTITY_DECORATOR_NAMES, findEntityDecorator = (cls) => {
18817
+ for (const dec of ts7.getDecorators(cls) ?? []) {
18818
+ const expr = dec.expression;
18819
+ if (!ts7.isCallExpression(expr))
18820
+ continue;
18821
+ if (!ts7.isIdentifier(expr.expression))
18822
+ continue;
18823
+ if (ENTITY_DECORATOR_NAMES.has(expr.expression.text))
18824
+ return dec;
18825
+ }
18826
+ return null;
18827
+ }, extractEntityFingerprint = (cls, className, sourceFile) => {
18828
+ const decorator = findEntityDecorator(cls);
18829
+ let decoratorArgsText = "";
18830
+ if (decorator !== null) {
18831
+ const expr = decorator.expression;
18832
+ const arg = expr.arguments[0];
18833
+ if (arg !== undefined) {
18834
+ decoratorArgsText = arg.getText().replace(/\s+/g, " ").trim();
18835
+ }
18836
+ }
18837
+ const ctorParamTypes = [];
18838
+ for (const member of cls.members) {
18839
+ if (!ts7.isConstructorDeclaration(member))
18840
+ continue;
18841
+ for (const param of member.parameters) {
18842
+ const typeText = param.type ? param.type.getText() : "";
18843
+ const decorators = ts7.getDecorators(param) ?? [];
18844
+ const decoratorSig = decorators.length === 0 ? "" : decorators.map((d2) => {
18845
+ const e = d2.expression;
18846
+ if (ts7.isCallExpression(e) && ts7.isIdentifier(e.expression)) {
18847
+ const args = e.arguments.map((a) => a.getText()).join(",");
18848
+ return `@${e.expression.text}(${args})`;
18849
+ }
18850
+ if (ts7.isIdentifier(e))
18851
+ return `@${e.text}`;
18852
+ return "@<unknown>";
18853
+ }).join("");
18854
+ ctorParamTypes.push(`${typeText}${decoratorSig}`);
18855
+ }
18856
+ break;
18857
+ }
18858
+ return {
18859
+ className,
18860
+ decoratorArgsText,
18861
+ ctorParamTypes,
18862
+ topLevelImports: extractTopLevelImports(sourceFile),
18863
+ memberDecoratorSig: extractMemberDecoratorSig(cls),
18864
+ arrowFieldSig: extractArrowFieldSig(cls),
18865
+ propertyFieldNames: extractPropertyFieldNames(cls)
18866
+ };
18705
18867
  }, findClassDeclaration = (sourceFile, className) => {
18706
18868
  let found = null;
18707
18869
  const walk = (node) => {
@@ -18839,6 +19001,33 @@ var fail = (reason, detail, location) => ({
18839
19001
  }
18840
19002
  }
18841
19003
  return false;
19004
+ }, CONTROL_CREATE_METHOD_NAME = "\u0275ngControlCreate", extractControlCreate = (cls) => {
19005
+ for (const member of cls.members) {
19006
+ if (!ts7.isMethodDeclaration(member))
19007
+ continue;
19008
+ if (member.modifiers?.some((m) => m.kind === ts7.SyntaxKind.StaticKeyword))
19009
+ continue;
19010
+ const name = member.name;
19011
+ if (name === undefined)
19012
+ continue;
19013
+ const nameText = ts7.isIdentifier(name) ? name.text : name.getText();
19014
+ if (nameText !== CONTROL_CREATE_METHOD_NAME)
19015
+ continue;
19016
+ const firstParam = member.parameters[0];
19017
+ if (firstParam === undefined || firstParam.type === undefined || !ts7.isTypeReferenceNode(firstParam.type)) {
19018
+ return { passThroughInput: null };
19019
+ }
19020
+ const typeArgs = firstParam.type.typeArguments;
19021
+ if (typeArgs === undefined || typeArgs.length !== 1) {
19022
+ return { passThroughInput: null };
19023
+ }
19024
+ const arg = typeArgs[0];
19025
+ if (arg === undefined || !ts7.isLiteralTypeNode(arg) || !ts7.isStringLiteral(arg.literal)) {
19026
+ return { passThroughInput: null };
19027
+ }
19028
+ return { passThroughInput: arg.literal.text };
19029
+ }
19030
+ return null;
18842
19031
  }, resolveEnumPropertyAccess = (expr, enumName, values) => {
18843
19032
  if (!ts7.isPropertyAccessExpression(expr))
18844
19033
  return null;
@@ -20018,10 +20207,17 @@ ${block}
20018
20207
  }
20019
20208
  const kind = params.kind ?? "component";
20020
20209
  if (kind !== "component") {
20210
+ const entityId = encodeURIComponent(`${relative13(projectRoot, componentFilePath).replace(/\\/g, "/")}@${className}`);
20211
+ const currentEntityFingerprint = extractEntityFingerprint(classNode, className, sourceFile);
20212
+ const cachedEntityFingerprint = entityFingerprintCache.get(entityId);
20213
+ if (cachedEntityFingerprint !== undefined && !entityFingerprintsEqual(cachedEntityFingerprint, currentEntityFingerprint)) {
20214
+ return fail("structural-change", `${kind} ${className} decorator-args or structural surface changed`);
20215
+ }
20021
20216
  const moduleText = buildSimpleEntityModule(classNode, className);
20022
20217
  if (!moduleText) {
20023
20218
  return fail("unexpected-error", `buildSimpleEntityModule returned null for ${className}`);
20024
20219
  }
20220
+ entityFingerprintCache.set(entityId, currentEntityFingerprint);
20025
20221
  return {
20026
20222
  componentSource: sourceFile,
20027
20223
  fingerprintChanged: false,
@@ -20132,7 +20328,7 @@ ${block}
20132
20328
  inputs,
20133
20329
  outputs,
20134
20330
  usesInheritance: false,
20135
- controlCreate: null,
20331
+ controlCreate: extractControlCreate(classNode),
20136
20332
  exportAs: advancedMetadata.exportAs,
20137
20333
  providers: advancedMetadata.providers,
20138
20334
  isStandalone: decoratorMeta.standalone,
@@ -20301,6 +20497,12 @@ var init_fastHmrCompiler = __esm(() => {
20301
20497
  init_typescript_translator();
20302
20498
  fingerprintCache = new Map;
20303
20499
  pendingModuleCache = new Map;
20500
+ entityFingerprintCache = new Map;
20501
+ ENTITY_DECORATOR_NAMES = new Set([
20502
+ "Pipe",
20503
+ "Directive",
20504
+ "Injectable"
20505
+ ]);
20304
20506
  VIEW_ENCAPSULATION_VALUES = {
20305
20507
  Emulated: 0,
20306
20508
  ExperimentalIsolatedShadowDom: 4,
@@ -20999,6 +21201,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
20999
21201
  let anyFingerprintChanged = false;
21000
21202
  let totalResolveMs = 0;
21001
21203
  let totalCompileMs = 0;
21204
+ const { resolveDescendantsOfParent: resolveDescendantsOfParent2 } = await Promise.resolve().then(() => (init_resolveOwningComponents(), exports_resolveOwningComponents));
21002
21205
  for (const editedFile of userEdited) {
21003
21206
  const resolveStart = performance.now();
21004
21207
  const owners = resolveOwningComponents2({
@@ -21006,6 +21209,20 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21006
21209
  userAngularRoot: angularDir
21007
21210
  });
21008
21211
  totalResolveMs += performance.now() - resolveStart;
21212
+ if (owners.length === 0) {
21213
+ const descendants = resolveDescendantsOfParent2({
21214
+ changedFilePath: editedFile,
21215
+ userAngularRoot: angularDir
21216
+ });
21217
+ if (descendants.length > 0) {
21218
+ const names = descendants.map((d2) => d2.className).slice(0, 3).join(", ");
21219
+ return {
21220
+ kind: "rebootstrap",
21221
+ reason: `parent class file edited; descendant Angular entities (${names}${descendants.length > 3 ? ", ..." : ""}) need to pick up new prototype`,
21222
+ tier: 1
21223
+ };
21224
+ }
21225
+ }
21009
21226
  if (owners.length === 0 && (editedFile.endsWith(".component.ts") || editedFile.endsWith(".directive.ts") || editedFile.endsWith(".pipe.ts") || editedFile.endsWith(".service.ts"))) {
21010
21227
  return {
21011
21228
  kind: "rebootstrap",
@@ -31594,5 +31811,5 @@ export {
31594
31811
  ANGULAR_INIT_TIMEOUT_MS
31595
31812
  };
31596
31813
 
31597
- //# debugId=F92C1416B50F9B9A64756E2164756E21
31814
+ //# debugId=26FFFD73925522E664756E2164756E21
31598
31815
  //# sourceMappingURL=index.js.map