@absolutejs/absolute 0.19.0-beta.942 → 0.19.0-beta.943

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/build.js CHANGED
@@ -3000,6 +3000,15 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
3000
3000
  url: new URL(`file://${filePath}`)
3001
3001
  });
3002
3002
  const css = await runPostcss(result.css, filePath, config);
3003
+ const loadedUrls = result.loadedUrls ?? [];
3004
+ for (const url of loadedUrls) {
3005
+ if (url.protocol !== "file:")
3006
+ continue;
3007
+ const dep = fileURLToPath(url);
3008
+ if (resolve6(dep) === resolve6(filePath))
3009
+ continue;
3010
+ deps.add(dep);
3011
+ }
3003
3012
  recordStyleDeps(filePath, deps);
3004
3013
  return css;
3005
3014
  } catch (error) {
@@ -3168,7 +3177,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
3168
3177
  }
3169
3178
  const contents = withAdditionalData(rawContents, options.additionalData);
3170
3179
  const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
3171
- const compiled = sass.compileString(contents, {
3180
+ const result = sass.compileString(contents, {
3172
3181
  importers: [
3173
3182
  createSassImporter(filePath, loadPaths, language, config)
3174
3183
  ],
@@ -3176,8 +3185,17 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
3176
3185
  style: "expanded",
3177
3186
  syntax: language === "sass" ? "indented" : "scss",
3178
3187
  url: new URL(`file://${filePath}`)
3179
- }).css;
3180
- return resolveCssImportsSync(compiled, dirname2(filePath), new Set([filePath]));
3188
+ });
3189
+ const loadedUrls = result.loadedUrls ?? [];
3190
+ for (const url of loadedUrls) {
3191
+ if (url.protocol !== "file:")
3192
+ continue;
3193
+ const dep = fileURLToPath(url);
3194
+ if (resolve6(dep) === resolve6(filePath))
3195
+ continue;
3196
+ addStyleImporter(filePath, dep);
3197
+ }
3198
+ return resolveCssImportsSync(result.css, dirname2(filePath), new Set([filePath]));
3181
3199
  }
3182
3200
  if (language === "less") {
3183
3201
  throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
@@ -13649,6 +13667,10 @@ var fail = (reason, detail, location) => ({
13649
13667
  return false;
13650
13668
  if (a.decoratorOutputsArraySig !== b2.decoratorOutputsArraySig)
13651
13669
  return false;
13670
+ if (a.hostBindingsSig !== b2.hostBindingsSig)
13671
+ return false;
13672
+ if (a.pageExportsSig !== b2.pageExportsSig)
13673
+ return false;
13652
13674
  return true;
13653
13675
  }, recordFingerprint = (id, fp) => {
13654
13676
  fingerprintCache.set(id, fp);
@@ -13672,25 +13694,47 @@ var fail = (reason, detail, location) => ({
13672
13694
  if (!className)
13673
13695
  continue;
13674
13696
  const decorators = ts6.getDecorators(stmt) ?? [];
13675
- const componentDecorator = decorators.find((d2) => {
13676
- if (!ts6.isCallExpression(d2.expression))
13677
- return false;
13678
- const expr = d2.expression.expression;
13679
- return ts6.isIdentifier(expr) && expr.text === "Component";
13680
- });
13681
- if (!componentDecorator)
13682
- continue;
13683
- const decoratorCall = componentDecorator.expression;
13684
- const args = decoratorCall.arguments[0];
13685
- if (!args || !ts6.isObjectLiteralExpression(args))
13697
+ const decoratorName = (() => {
13698
+ for (const d2 of decorators) {
13699
+ if (!ts6.isCallExpression(d2.expression))
13700
+ continue;
13701
+ const expr = d2.expression.expression;
13702
+ if (!ts6.isIdentifier(expr))
13703
+ continue;
13704
+ if (expr.text === "Component" || expr.text === "Directive" || expr.text === "Pipe" || expr.text === "Injectable") {
13705
+ return expr.text;
13706
+ }
13707
+ }
13708
+ return null;
13709
+ })();
13710
+ if (!decoratorName)
13686
13711
  continue;
13687
- const decoratorMeta = readDecoratorMeta(args);
13688
- const { inputs, outputs } = extractInputsAndOutputs(stmt, null);
13689
- const componentDir = dirname13(componentFilePath);
13690
- const fingerprint = extractFingerprint(stmt, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
13691
13712
  const projectRel = relative12(process.cwd(), componentFilePath).replace(/\\/g, "/");
13692
13713
  const id = encodeURIComponent(`${projectRel}@${className}`);
13693
- fingerprintCache.set(id, fingerprint);
13714
+ if (decoratorName === "Component") {
13715
+ const componentDecorator = decorators.find((d2) => {
13716
+ if (!ts6.isCallExpression(d2.expression))
13717
+ return false;
13718
+ const expr = d2.expression.expression;
13719
+ return ts6.isIdentifier(expr) && expr.text === "Component";
13720
+ });
13721
+ if (!componentDecorator)
13722
+ continue;
13723
+ const decoratorCall = componentDecorator.expression;
13724
+ const args = decoratorCall.arguments[0];
13725
+ if (!args || !ts6.isObjectLiteralExpression(args))
13726
+ continue;
13727
+ const decoratorMeta = readDecoratorMeta(args);
13728
+ const { inputs, outputs } = extractInputsAndOutputs(stmt, null);
13729
+ const componentDir = dirname13(componentFilePath);
13730
+ const fingerprint = extractFingerprint(stmt, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
13731
+ fingerprintCache.set(id, fingerprint);
13732
+ } else {
13733
+ try {
13734
+ const entityFingerprint = extractEntityFingerprint(stmt, className, sourceFile);
13735
+ entityFingerprintCache.set(id, entityFingerprint);
13736
+ } catch {}
13737
+ }
13694
13738
  }
13695
13739
  }, invalidateFingerprintCache = () => {
13696
13740
  fingerprintCache.clear();
@@ -13945,6 +13989,7 @@ var fail = (reason, detail, location) => ({
13945
13989
  const viewProvidersExpr = getProperty(args, "viewProviders");
13946
13990
  const inputsArrayExpr = getProperty(args, "inputs");
13947
13991
  const outputsArrayExpr = getProperty(args, "outputs");
13992
+ const hostExpr = getProperty(args, "host");
13948
13993
  const styleUrls = [];
13949
13994
  if (styleUrlsExpr && ts6.isArrayLiteralExpression(styleUrlsExpr)) {
13950
13995
  for (const el of styleUrlsExpr.elements) {
@@ -13980,6 +14025,7 @@ var fail = (reason, detail, location) => ({
13980
14025
  viewProvidersExpr: viewProvidersExpr && ts6.isArrayLiteralExpression(viewProvidersExpr) ? viewProvidersExpr : null,
13981
14026
  inputsArrayExpr: inputsArrayExpr && ts6.isArrayLiteralExpression(inputsArrayExpr) ? inputsArrayExpr : null,
13982
14027
  outputsArrayExpr: outputsArrayExpr && ts6.isArrayLiteralExpression(outputsArrayExpr) ? outputsArrayExpr : null,
14028
+ hostExpr: hostExpr && ts6.isObjectLiteralExpression(hostExpr) ? hostExpr : null,
13983
14029
  preserveWhitespaces: getBooleanProperty(args, "preserveWhitespaces") ?? projectDefaults.preserveWhitespaces ?? false,
13984
14030
  selector: getStringProperty(args, "selector"),
13985
14031
  standalone: getBooleanProperty(args, "standalone") ?? true,
@@ -14995,6 +15041,27 @@ var fail = (reason, detail, location) => ({
14995
15041
  const viewProvidersArraySig = decoratorMeta.viewProvidersExpr ? djb2Hash(decoratorMeta.viewProvidersExpr.getText()) : "";
14996
15042
  const decoratorInputsArraySig = decoratorMeta.inputsArrayExpr ? djb2Hash(decoratorMeta.inputsArrayExpr.getText()) : "";
14997
15043
  const decoratorOutputsArraySig = decoratorMeta.outputsArrayExpr ? djb2Hash(decoratorMeta.outputsArrayExpr.getText()) : "";
15044
+ const hostBindingsSig = decoratorMeta.hostExpr ? djb2Hash(decoratorMeta.hostExpr.getText()) : "";
15045
+ const PAGE_EXPORT_NAMES = new Set(["providers", "routes"]);
15046
+ const pageExportEntries = [];
15047
+ for (const stmt of sourceFile.statements) {
15048
+ if (!ts6.isVariableStatement(stmt))
15049
+ continue;
15050
+ const isExported = stmt.modifiers?.some((m) => m.kind === ts6.SyntaxKind.ExportKeyword);
15051
+ if (!isExported)
15052
+ continue;
15053
+ for (const decl of stmt.declarationList.declarations) {
15054
+ if (!ts6.isIdentifier(decl.name))
15055
+ continue;
15056
+ if (!PAGE_EXPORT_NAMES.has(decl.name.text))
15057
+ continue;
15058
+ if (!decl.initializer)
15059
+ continue;
15060
+ pageExportEntries.push(`${decl.name.text}=${djb2Hash(decl.initializer.getText())}`);
15061
+ }
15062
+ }
15063
+ pageExportEntries.sort();
15064
+ const pageExportsSig = pageExportEntries.length > 0 ? pageExportEntries.join("|") : "";
14998
15065
  return {
14999
15066
  animationsArraySig,
15000
15067
  arrowFieldSig,
@@ -15006,11 +15073,13 @@ var fail = (reason, detail, location) => ({
15006
15073
  encapsulation: decoratorMeta.encapsulation,
15007
15074
  hasProviders: decoratorMeta.hasProviders,
15008
15075
  hasViewProviders: decoratorMeta.hasViewProviders,
15076
+ hostBindingsSig,
15009
15077
  hostDirectivesSig,
15010
15078
  importsArraySig,
15011
15079
  inputs: inputNames,
15012
15080
  memberDecoratorSig,
15013
15081
  outputs: outputNames,
15082
+ pageExportsSig,
15014
15083
  propertyFieldNames,
15015
15084
  providerImportSig,
15016
15085
  providersArraySig,
@@ -15269,7 +15338,7 @@ ${block}
15269
15338
  const currentFingerprint = extractFingerprint(classNode, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
15270
15339
  const cachedFingerprint = fingerprintCache.get(fingerprintId);
15271
15340
  const fingerprintChanged = cachedFingerprint !== undefined && !fingerprintsEqual(cachedFingerprint, currentFingerprint);
15272
- const rebootstrapRequired = !currentFingerprint.standalone || cachedFingerprint !== undefined && (cachedFingerprint.importsArraySig !== currentFingerprint.importsArraySig || cachedFingerprint.hostDirectivesSig !== currentFingerprint.hostDirectivesSig || cachedFingerprint.providersArraySig !== currentFingerprint.providersArraySig || cachedFingerprint.viewProvidersArraySig !== currentFingerprint.viewProvidersArraySig || cachedFingerprint.selector !== currentFingerprint.selector || cachedFingerprint.standalone !== currentFingerprint.standalone);
15341
+ const rebootstrapRequired = !currentFingerprint.standalone || cachedFingerprint !== undefined && (cachedFingerprint.importsArraySig !== currentFingerprint.importsArraySig || cachedFingerprint.hostDirectivesSig !== currentFingerprint.hostDirectivesSig || cachedFingerprint.providersArraySig !== currentFingerprint.providersArraySig || cachedFingerprint.viewProvidersArraySig !== currentFingerprint.viewProvidersArraySig || cachedFingerprint.selector !== currentFingerprint.selector || cachedFingerprint.pageExportsSig !== currentFingerprint.pageExportsSig || cachedFingerprint.standalone !== currentFingerprint.standalone);
15273
15342
  const sourceFileObj = new compiler.ParseSourceFile(tsSource, componentFilePath);
15274
15343
  const zeroLoc = new compiler.ParseLocation(sourceFileObj, 0, 0, 0);
15275
15344
  const typeSourceSpan = new compiler.ParseSourceSpan(zeroLoc, zeroLoc);
@@ -19615,96 +19684,372 @@ var init_moduleMapper = __esm(() => {
19615
19684
  init_reactComponentClassifier();
19616
19685
  });
19617
19686
 
19618
- // types/typeGuards.ts
19619
- var isValidHMRClientMessage = (data) => {
19620
- if (!data || typeof data !== "object") {
19621
- return false;
19622
- }
19623
- if (!("type" in data) || typeof data.type !== "string") {
19624
- return false;
19687
+ // src/dev/angular/resolveOwningComponents.ts
19688
+ var exports_resolveOwningComponents = {};
19689
+ __export(exports_resolveOwningComponents, {
19690
+ resolveOwningComponents: () => resolveOwningComponents,
19691
+ resolveDescendantsOfParent: () => resolveDescendantsOfParent,
19692
+ invalidateResourceIndex: () => invalidateResourceIndex
19693
+ });
19694
+ import { readdirSync as readdirSync2, readFileSync as readFileSync18, statSync as statSync3 } from "fs";
19695
+ import { dirname as dirname18, extname as extname9, join as join28, resolve as resolve32 } from "path";
19696
+ import ts7 from "typescript";
19697
+ var ENTITY_DECORATORS, isAngularSourceFile = (file4) => file4.endsWith(".ts") || file4.endsWith(".tsx"), walkAngularSourceFiles = (root) => {
19698
+ const out = [];
19699
+ const visit = (dir) => {
19700
+ let entries;
19701
+ try {
19702
+ entries = readdirSync2(dir, { withFileTypes: true });
19703
+ } catch {
19704
+ return;
19705
+ }
19706
+ for (const entry of entries) {
19707
+ if (entry.name.startsWith(".") || entry.name === "node_modules") {
19708
+ continue;
19709
+ }
19710
+ const full = join28(dir, entry.name);
19711
+ if (entry.isDirectory()) {
19712
+ visit(full);
19713
+ } else if (entry.isFile() && isAngularSourceFile(entry.name)) {
19714
+ out.push(full);
19715
+ }
19716
+ }
19717
+ };
19718
+ visit(root);
19719
+ return out;
19720
+ }, getStringPropertyValue = (obj, name) => {
19721
+ for (const prop of obj.properties) {
19722
+ if (!ts7.isPropertyAssignment(prop))
19723
+ continue;
19724
+ const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
19725
+ if (propName !== name)
19726
+ continue;
19727
+ const init = prop.initializer;
19728
+ if (ts7.isStringLiteral(init) || ts7.isNoSubstitutionTemplateLiteral(init)) {
19729
+ return init.text;
19730
+ }
19625
19731
  }
19626
- switch (data.type) {
19627
- case "ping":
19628
- case "ready":
19629
- case "request-rebuild":
19630
- case "hydration-error":
19631
- case "hmr-timing":
19632
- case "angular:hmr-ack":
19633
- return true;
19634
- default:
19635
- return false;
19732
+ return null;
19733
+ }, getStringArrayProperty = (obj, name) => {
19734
+ const out = [];
19735
+ for (const prop of obj.properties) {
19736
+ if (!ts7.isPropertyAssignment(prop))
19737
+ continue;
19738
+ const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
19739
+ if (propName !== name)
19740
+ continue;
19741
+ const init = prop.initializer;
19742
+ if (!ts7.isArrayLiteralExpression(init))
19743
+ continue;
19744
+ for (const element of init.elements) {
19745
+ if (ts7.isStringLiteral(element) || ts7.isNoSubstitutionTemplateLiteral(element)) {
19746
+ out.push(element.text);
19747
+ }
19748
+ }
19636
19749
  }
19637
- };
19638
-
19639
- // src/dev/webSocket.ts
19640
- var trySendMessage = (client, messageStr) => {
19750
+ return out;
19751
+ }, parseDecoratedClasses = (filePath) => {
19752
+ let source;
19641
19753
  try {
19642
- client.send(messageStr);
19643
- return true;
19754
+ source = readFileSync18(filePath, "utf8");
19644
19755
  } catch {
19645
- return false;
19756
+ return [];
19646
19757
  }
19647
- }, broadcastToClients = (state, message) => {
19648
- const messageStr = JSON.stringify({
19649
- ...message,
19650
- timestamp: Date.now()
19651
- });
19652
- const shouldRemove = (client) => {
19653
- return !trySendMessage(client, messageStr);
19758
+ const sourceFile = ts7.createSourceFile(filePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
19759
+ const out = [];
19760
+ const visit = (node) => {
19761
+ if (ts7.isClassDeclaration(node) && node.name) {
19762
+ for (const decorator of ts7.getDecorators(node) ?? []) {
19763
+ const expr = decorator.expression;
19764
+ if (!ts7.isCallExpression(expr))
19765
+ continue;
19766
+ const fn2 = expr.expression;
19767
+ if (!ts7.isIdentifier(fn2))
19768
+ continue;
19769
+ const kind = ENTITY_DECORATORS[fn2.text];
19770
+ if (!kind)
19771
+ continue;
19772
+ let extendsName = null;
19773
+ for (const heritage of node.heritageClauses ?? []) {
19774
+ if (heritage.token !== ts7.SyntaxKind.ExtendsKeyword) {
19775
+ continue;
19776
+ }
19777
+ const first = heritage.types[0];
19778
+ if (first && ts7.isIdentifier(first.expression)) {
19779
+ extendsName = first.expression.text;
19780
+ }
19781
+ break;
19782
+ }
19783
+ const entry = {
19784
+ className: node.name.text,
19785
+ kind,
19786
+ styleUrls: [],
19787
+ templateUrls: [],
19788
+ extendsName
19789
+ };
19790
+ const arg = expr.arguments[0];
19791
+ if (arg && ts7.isObjectLiteralExpression(arg) && kind === "component") {
19792
+ const tplUrl = getStringPropertyValue(arg, "templateUrl");
19793
+ if (tplUrl)
19794
+ entry.templateUrls.push(tplUrl);
19795
+ const styleUrl = getStringPropertyValue(arg, "styleUrl");
19796
+ if (styleUrl)
19797
+ entry.styleUrls.push(styleUrl);
19798
+ entry.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
19799
+ }
19800
+ out.push(entry);
19801
+ break;
19802
+ }
19803
+ }
19804
+ ts7.forEachChild(node, visit);
19654
19805
  };
19655
- const clientsToRemove = [];
19656
- state.connectedClients.forEach((client) => {
19657
- if (shouldRemove(client))
19658
- clientsToRemove.push(client);
19659
- });
19660
- clientsToRemove.forEach((client) => {
19661
- state.connectedClients.delete(client);
19662
- });
19663
- }, handleClientConnect = (state, client, manifest) => {
19664
- state.connectedClients.add(client);
19665
- const serverVersions = serializeModuleVersions(state.moduleVersions);
19666
- client.send(JSON.stringify({
19667
- data: {
19668
- manifest,
19669
- serverVersions
19670
- },
19671
- timestamp: Date.now(),
19672
- type: "manifest"
19673
- }));
19674
- client.send(JSON.stringify({
19675
- message: "HMR client connected successfully",
19676
- timestamp: Date.now(),
19677
- type: "connected"
19678
- }));
19679
- }, handleClientDisconnect = (state, client) => {
19680
- state.connectedClients.delete(client);
19681
- }, parseJsonSafe = (raw) => JSON.parse(raw), parseMessage = (message) => {
19682
- if (typeof message === "string") {
19683
- return parseJsonSafe(message);
19806
+ visit(sourceFile);
19807
+ return out;
19808
+ }, safeNormalize = (path) => resolve32(path).replace(/\\/g, "/"), resolveOwningComponents = (params) => {
19809
+ const { changedFilePath, userAngularRoot } = params;
19810
+ const changedAbs = safeNormalize(changedFilePath);
19811
+ const out = [];
19812
+ const ext = extname9(changedAbs).toLowerCase();
19813
+ if (ext === ".ts" || ext === ".tsx") {
19814
+ const classes = parseDecoratedClasses(changedAbs);
19815
+ for (const cls of classes) {
19816
+ out.push({
19817
+ className: cls.className,
19818
+ componentFilePath: changedAbs,
19819
+ kind: cls.kind
19820
+ });
19821
+ }
19822
+ return out;
19684
19823
  }
19685
- if (message instanceof Buffer) {
19686
- return parseJsonSafe(message.toString());
19824
+ if (ext !== ".html" && ext !== ".css" && ext !== ".scss" && ext !== ".sass") {
19825
+ return out;
19687
19826
  }
19688
- if (message instanceof ArrayBuffer) {
19689
- return parseJsonSafe(new TextDecoder().decode(new Uint8Array(message)));
19827
+ let rootStat;
19828
+ try {
19829
+ rootStat = statSync3(userAngularRoot);
19830
+ } catch {
19831
+ return out;
19690
19832
  }
19691
- if (ArrayBuffer.isView(message)) {
19692
- const view = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
19693
- return parseJsonSafe(new TextDecoder().decode(view));
19833
+ if (!rootStat.isDirectory())
19834
+ return out;
19835
+ const index = getOrBuildResourceIndex(userAngularRoot);
19836
+ const owners = index.get(changedAbs);
19837
+ if (owners) {
19838
+ out.push(...owners);
19694
19839
  }
19695
- if (typeof message === "object" && message !== null) {
19696
- return message;
19840
+ return out;
19841
+ }, indexByRoot, resolveParentClassFile = (parentName, childFilePath, angularRoot) => {
19842
+ let source;
19843
+ try {
19844
+ source = readFileSync18(childFilePath, "utf8");
19845
+ } catch {
19846
+ return null;
19697
19847
  }
19698
- return null;
19699
- }, handleParsedMessage = (state, client, data) => {
19700
- switch (data.type) {
19701
- case "ping":
19702
- client.send(JSON.stringify({
19703
- timestamp: Date.now(),
19704
- type: "pong"
19705
- }));
19706
- break;
19707
- case "request-rebuild":
19848
+ const sf = ts7.createSourceFile(childFilePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
19849
+ const childDir = dirname18(childFilePath);
19850
+ for (const stmt of sf.statements) {
19851
+ if (!ts7.isImportDeclaration(stmt))
19852
+ continue;
19853
+ if (!ts7.isStringLiteral(stmt.moduleSpecifier))
19854
+ continue;
19855
+ const clause = stmt.importClause;
19856
+ if (!clause || clause.isTypeOnly)
19857
+ continue;
19858
+ let matchesName = false;
19859
+ if (clause.name && clause.name.text === parentName)
19860
+ matchesName = true;
19861
+ if (!matchesName && clause.namedBindings && ts7.isNamedImports(clause.namedBindings)) {
19862
+ for (const el of clause.namedBindings.elements) {
19863
+ if (el.isTypeOnly)
19864
+ continue;
19865
+ if (el.name.text === parentName) {
19866
+ matchesName = true;
19867
+ break;
19868
+ }
19869
+ }
19870
+ }
19871
+ if (!matchesName)
19872
+ continue;
19873
+ const spec = stmt.moduleSpecifier.text;
19874
+ if (!spec.startsWith(".") && !spec.startsWith("/")) {
19875
+ return null;
19876
+ }
19877
+ const base = resolve32(childDir, spec);
19878
+ const candidates = [
19879
+ `${base}.ts`,
19880
+ `${base}.tsx`,
19881
+ `${base}/index.ts`,
19882
+ `${base}/index.tsx`
19883
+ ];
19884
+ const angularRootNorm = safeNormalize(angularRoot);
19885
+ for (const candidate of candidates) {
19886
+ try {
19887
+ if (statSync3(candidate).isFile()) {
19888
+ const norm = safeNormalize(candidate);
19889
+ if (!norm.startsWith(angularRootNorm))
19890
+ return null;
19891
+ return norm;
19892
+ }
19893
+ } catch {}
19894
+ }
19895
+ return null;
19896
+ }
19897
+ return null;
19898
+ }, getOrBuildIndexes = (userAngularRoot) => {
19899
+ const cached = indexByRoot.get(userAngularRoot);
19900
+ if (cached)
19901
+ return cached;
19902
+ const resource = new Map;
19903
+ const parentFile = new Map;
19904
+ for (const tsPath of walkAngularSourceFiles(userAngularRoot)) {
19905
+ const classes = parseDecoratedClasses(tsPath);
19906
+ const componentDir = dirname18(tsPath);
19907
+ for (const cls of classes) {
19908
+ const entity = {
19909
+ className: cls.className,
19910
+ componentFilePath: tsPath,
19911
+ kind: cls.kind
19912
+ };
19913
+ if (cls.kind === "component") {
19914
+ for (const url of [...cls.templateUrls, ...cls.styleUrls]) {
19915
+ const abs = safeNormalize(resolve32(componentDir, url));
19916
+ const existing = resource.get(abs);
19917
+ if (existing)
19918
+ existing.push(entity);
19919
+ else
19920
+ resource.set(abs, [entity]);
19921
+ }
19922
+ }
19923
+ if (cls.extendsName !== null) {
19924
+ const parentPath = resolveParentClassFile(cls.extendsName, tsPath, userAngularRoot);
19925
+ if (parentPath !== null && parentPath !== safeNormalize(tsPath)) {
19926
+ const existing = parentFile.get(parentPath);
19927
+ if (existing)
19928
+ existing.push(entity);
19929
+ else
19930
+ parentFile.set(parentPath, [entity]);
19931
+ }
19932
+ }
19933
+ }
19934
+ }
19935
+ const bundle = { parentFile, resource };
19936
+ indexByRoot.set(userAngularRoot, bundle);
19937
+ return bundle;
19938
+ }, getOrBuildResourceIndex = (userAngularRoot) => getOrBuildIndexes(userAngularRoot).resource, resolveDescendantsOfParent = (params) => {
19939
+ const norm = safeNormalize(params.changedFilePath);
19940
+ let rootStat;
19941
+ try {
19942
+ rootStat = statSync3(params.userAngularRoot);
19943
+ } catch {
19944
+ return [];
19945
+ }
19946
+ if (!rootStat.isDirectory())
19947
+ return [];
19948
+ const bundle = getOrBuildIndexes(params.userAngularRoot);
19949
+ return bundle.parentFile.get(norm) ?? [];
19950
+ }, invalidateResourceIndex = () => {
19951
+ indexByRoot.clear();
19952
+ };
19953
+ var init_resolveOwningComponents = __esm(() => {
19954
+ ENTITY_DECORATORS = {
19955
+ Component: "component",
19956
+ Directive: "directive",
19957
+ Pipe: "pipe",
19958
+ Injectable: "service"
19959
+ };
19960
+ indexByRoot = new Map;
19961
+ });
19962
+
19963
+ // types/typeGuards.ts
19964
+ var isValidHMRClientMessage = (data) => {
19965
+ if (!data || typeof data !== "object") {
19966
+ return false;
19967
+ }
19968
+ if (!("type" in data) || typeof data.type !== "string") {
19969
+ return false;
19970
+ }
19971
+ switch (data.type) {
19972
+ case "ping":
19973
+ case "ready":
19974
+ case "request-rebuild":
19975
+ case "hydration-error":
19976
+ case "hmr-timing":
19977
+ case "angular:hmr-ack":
19978
+ return true;
19979
+ default:
19980
+ return false;
19981
+ }
19982
+ };
19983
+
19984
+ // src/dev/webSocket.ts
19985
+ var trySendMessage = (client, messageStr) => {
19986
+ try {
19987
+ client.send(messageStr);
19988
+ return true;
19989
+ } catch {
19990
+ return false;
19991
+ }
19992
+ }, broadcastToClients = (state, message) => {
19993
+ const messageStr = JSON.stringify({
19994
+ ...message,
19995
+ timestamp: Date.now()
19996
+ });
19997
+ const shouldRemove = (client) => {
19998
+ return !trySendMessage(client, messageStr);
19999
+ };
20000
+ const clientsToRemove = [];
20001
+ state.connectedClients.forEach((client) => {
20002
+ if (shouldRemove(client))
20003
+ clientsToRemove.push(client);
20004
+ });
20005
+ clientsToRemove.forEach((client) => {
20006
+ state.connectedClients.delete(client);
20007
+ });
20008
+ }, handleClientConnect = (state, client, manifest) => {
20009
+ state.connectedClients.add(client);
20010
+ const serverVersions = serializeModuleVersions(state.moduleVersions);
20011
+ client.send(JSON.stringify({
20012
+ data: {
20013
+ manifest,
20014
+ serverVersions
20015
+ },
20016
+ timestamp: Date.now(),
20017
+ type: "manifest"
20018
+ }));
20019
+ client.send(JSON.stringify({
20020
+ message: "HMR client connected successfully",
20021
+ timestamp: Date.now(),
20022
+ type: "connected"
20023
+ }));
20024
+ }, handleClientDisconnect = (state, client) => {
20025
+ state.connectedClients.delete(client);
20026
+ }, parseJsonSafe = (raw) => JSON.parse(raw), parseMessage = (message) => {
20027
+ if (typeof message === "string") {
20028
+ return parseJsonSafe(message);
20029
+ }
20030
+ if (message instanceof Buffer) {
20031
+ return parseJsonSafe(message.toString());
20032
+ }
20033
+ if (message instanceof ArrayBuffer) {
20034
+ return parseJsonSafe(new TextDecoder().decode(new Uint8Array(message)));
20035
+ }
20036
+ if (ArrayBuffer.isView(message)) {
20037
+ const view = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
20038
+ return parseJsonSafe(new TextDecoder().decode(view));
20039
+ }
20040
+ if (typeof message === "object" && message !== null) {
20041
+ return message;
20042
+ }
20043
+ return null;
20044
+ }, handleParsedMessage = (state, client, data) => {
20045
+ switch (data.type) {
20046
+ case "ping":
20047
+ client.send(JSON.stringify({
20048
+ timestamp: Date.now(),
20049
+ type: "pong"
20050
+ }));
20051
+ break;
20052
+ case "request-rebuild":
19708
20053
  break;
19709
20054
  case "ready":
19710
20055
  if (data.framework) {
@@ -19756,8 +20101,8 @@ __export(exports_moduleServer, {
19756
20101
  createModuleServer: () => createModuleServer,
19757
20102
  SRC_URL_PREFIX: () => SRC_URL_PREFIX
19758
20103
  });
19759
- import { existsSync as existsSync25, readFileSync as readFileSync18, statSync as statSync3 } from "fs";
19760
- import { basename as basename10, dirname as dirname18, extname as extname9, join as join28, resolve as resolve32, relative as relative14 } from "path";
20104
+ import { existsSync as existsSync25, readFileSync as readFileSync19, statSync as statSync4 } from "fs";
20105
+ import { basename as basename10, dirname as dirname19, extname as extname10, join as join29, resolve as resolve33, relative as relative14 } from "path";
19761
20106
  var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
19762
20107
  const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
19763
20108
  const allExports = [];
@@ -19777,7 +20122,7 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPIL
19777
20122
  ${stubs}
19778
20123
  `;
19779
20124
  }, resolveRelativeExtension = (srcPath, projectRoot, extensions) => {
19780
- const found = extensions.find((ext) => existsSync25(resolve32(projectRoot, srcPath + ext)));
20125
+ const found = extensions.find((ext) => existsSync25(resolve33(projectRoot, srcPath + ext)));
19781
20126
  return found ? srcPath + found : srcPath;
19782
20127
  }, IMPORT_EXTENSIONS, SIDE_EFFECT_EXTENSIONS, MODULE_EXTENSIONS, RESOLVED_MODULE_EXTENSIONS, REACT_EXTENSIONS, escapeRegex3 = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), buildImportRewriter = (vendorPaths) => {
19783
20128
  const entries = Object.entries(vendorPaths).sort(([a], [b2]) => b2.length - a.length);
@@ -19792,24 +20137,24 @@ ${stubs}
19792
20137
  return invalidationVersion > 0 ? `${mtime}.${invalidationVersion}` : `${mtime}`;
19793
20138
  }, srcUrl = (relPath, projectRoot) => {
19794
20139
  const base = `${SRC_PREFIX}${relPath.replace(/\\/g, "/")}`;
19795
- const absPath = resolve32(projectRoot, relPath);
20140
+ const absPath = resolve33(projectRoot, relPath);
19796
20141
  const cached = mtimeCache.get(absPath);
19797
20142
  if (cached !== undefined)
19798
20143
  return `${base}?v=${buildVersion(cached, absPath)}`;
19799
20144
  try {
19800
- const mtime = Math.round(statSync3(absPath).mtimeMs);
20145
+ const mtime = Math.round(statSync4(absPath).mtimeMs);
19801
20146
  mtimeCache.set(absPath, mtime);
19802
20147
  return `${base}?v=${buildVersion(mtime, absPath)}`;
19803
20148
  } catch {
19804
20149
  return base;
19805
20150
  }
19806
20151
  }, resolveRelativeImport = (relPath, fileDir, projectRoot, extensions) => {
19807
- const absPath = resolve32(fileDir, relPath);
20152
+ const absPath = resolve33(fileDir, relPath);
19808
20153
  const rel = relative14(projectRoot, absPath);
19809
- const extension = extname9(rel);
20154
+ const extension = extname10(rel);
19810
20155
  let srcPath = RESOLVED_MODULE_EXTENSIONS.has(extension) ? rel : resolveRelativeExtension(rel, projectRoot, extensions);
19811
- if (extname9(srcPath) === ".svelte") {
19812
- srcPath = relative14(projectRoot, resolveSvelteModulePath(resolve32(projectRoot, srcPath)));
20156
+ if (extname10(srcPath) === ".svelte") {
20157
+ srcPath = relative14(projectRoot, resolveSvelteModulePath(resolve33(projectRoot, srcPath)));
19813
20158
  }
19814
20159
  return srcUrl(srcPath, projectRoot);
19815
20160
  }, NODE_BUILTIN_RE, resolveAbsoluteSpecifier = (specifier, projectRoot) => {
@@ -19828,13 +20173,13 @@ ${stubs}
19828
20173
  const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
19829
20174
  const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
19830
20175
  if (!subpath) {
19831
- const pkgDir = resolve32(projectRoot, "node_modules", packageName ?? "");
19832
- const pkgJsonPath = join28(pkgDir, "package.json");
20176
+ const pkgDir = resolve33(projectRoot, "node_modules", packageName ?? "");
20177
+ const pkgJsonPath = join29(pkgDir, "package.json");
19833
20178
  if (existsSync25(pkgJsonPath)) {
19834
- const pkg = JSON.parse(readFileSync18(pkgJsonPath, "utf-8"));
20179
+ const pkg = JSON.parse(readFileSync19(pkgJsonPath, "utf-8"));
19835
20180
  const esmEntry = typeof pkg.module === "string" && pkg.module || typeof pkg.browser === "string" && pkg.browser;
19836
20181
  if (esmEntry) {
19837
- const resolved = resolve32(pkgDir, esmEntry);
20182
+ const resolved = resolve33(pkgDir, esmEntry);
19838
20183
  if (existsSync25(resolved))
19839
20184
  return relative14(projectRoot, resolved);
19840
20185
  }
@@ -19866,7 +20211,7 @@ ${stubs}
19866
20211
  };
19867
20212
  result = result.replace(/^((?:import\s+[\s\S]+?\s+from|export\s+[\s\S]+?\s+from|import)\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
19868
20213
  result = result.replace(/(import\s*\(\s*["'])([^"'./][^"']*)(["']\s*\))/g, stubReplace);
19869
- const fileDir = dirname18(filePath);
20214
+ const fileDir = dirname19(filePath);
19870
20215
  result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
19871
20216
  result = result.replace(/(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
19872
20217
  result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, SIDE_EFFECT_EXTENSIONS)}${suffix}`);
@@ -19881,12 +20226,12 @@ ${stubs}
19881
20226
  result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, rewriteAbsoluteToSrc);
19882
20227
  result = result.replace(/(import\s*\(\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["']\s*\))/g, rewriteAbsoluteToSrc);
19883
20228
  result = result.replace(/new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g, (_match, relPath) => {
19884
- const absPath = resolve32(fileDir, relPath);
20229
+ const absPath = resolve33(fileDir, relPath);
19885
20230
  const rel = relative14(projectRoot, absPath);
19886
20231
  return `new URL('${srcUrl(rel, projectRoot)}', import.meta.url)`;
19887
20232
  });
19888
20233
  result = result.replace(/import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g, (_match, relPath) => {
19889
- const absPath = resolve32(fileDir, relPath);
20234
+ const absPath = resolve33(fileDir, relPath);
19890
20235
  const rel = relative14(projectRoot, absPath);
19891
20236
  return `'${srcUrl(rel, projectRoot)}'`;
19892
20237
  });
@@ -19932,7 +20277,7 @@ ${code}`;
19932
20277
  reactFastRefreshWarningEmitted = true;
19933
20278
  logWarn("React HMR is blocked: this Bun build ignores " + "`reactFastRefresh` on Bun.Transpiler, so component state " + "cannot be preserved across edits. Tracking " + "https://github.com/oven-sh/bun/pull/28312 \u2014 if it still has " + "not merged, leave a \uD83D\uDC4D on the PR so the Bun team knows it " + "is blocking you. Until then, React edits trigger a full " + "reload instead of a fast refresh.");
19934
20279
  }, transformReactFile = (filePath, projectRoot, rewriter) => {
19935
- const raw = readFileSync18(filePath, "utf-8");
20280
+ const raw = readFileSync19(filePath, "utf-8");
19936
20281
  const valueExports = tsxTranspiler.scan(raw).exports;
19937
20282
  let transpiled = reactTranspiler.transformSync(raw);
19938
20283
  transpiled = preserveTypeExports(raw, transpiled, valueExports);
@@ -19948,8 +20293,8 @@ ${transpiled}`;
19948
20293
  transpiled += buildIslandMetadataExports(raw);
19949
20294
  return rewriteImports(transpiled, filePath, projectRoot, rewriter);
19950
20295
  }, transformPlainFile = (filePath, projectRoot, rewriter, vueDir) => {
19951
- const raw = readFileSync18(filePath, "utf-8");
19952
- const ext = extname9(filePath);
20296
+ const raw = readFileSync19(filePath, "utf-8");
20297
+ const ext = extname10(filePath);
19953
20298
  const isTS = ext === ".ts" || ext === ".tsx";
19954
20299
  const isTSX = ext === ".tsx" || ext === ".jsx";
19955
20300
  let transpiler6 = jsTranspiler2;
@@ -20114,7 +20459,7 @@ ${code}`;
20114
20459
  ` + ` var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
20115
20460
  return code.replace(/import\.meta\.hot\.accept\(/g, "__hmr_accept(");
20116
20461
  }, transformSvelteFile = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
20117
- const raw = readFileSync18(filePath, "utf-8");
20462
+ const raw = readFileSync19(filePath, "utf-8");
20118
20463
  if (!svelteCompiler) {
20119
20464
  svelteCompiler = await import("svelte/compiler");
20120
20465
  }
@@ -20176,7 +20521,7 @@ export default __script__;`;
20176
20521
  return `${cssInjection}
20177
20522
  ${code}`;
20178
20523
  }, transformVueFile = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
20179
- const rawSource = readFileSync18(filePath, "utf-8");
20524
+ const rawSource = readFileSync19(filePath, "utf-8");
20180
20525
  const raw = addAutoRouterSetupApp(rawSource);
20181
20526
  if (!vueCompiler) {
20182
20527
  vueCompiler = await import("@vue/compiler-sfc");
@@ -20199,7 +20544,7 @@ ${code}`;
20199
20544
  code = injectVueHmr(code, filePath, projectRoot, vueDir);
20200
20545
  return rewriteImports(code, filePath, projectRoot, rewriter);
20201
20546
  }, injectVueHmr = (code, filePath, projectRoot, vueDir) => {
20202
- const hmrBase = vueDir ? resolve32(vueDir) : projectRoot;
20547
+ const hmrBase = vueDir ? resolve33(vueDir) : projectRoot;
20203
20548
  const hmrId = relative14(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
20204
20549
  let result = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
20205
20550
  result += [
@@ -20231,7 +20576,7 @@ ${code}`;
20231
20576
  }
20232
20577
  });
20233
20578
  }, handleCssRequest = (filePath) => {
20234
- const raw = readFileSync18(filePath, "utf-8");
20579
+ const raw = readFileSync19(filePath, "utf-8");
20235
20580
  const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
20236
20581
  return [
20237
20582
  `const style = document.createElement('style');`,
@@ -20363,8 +20708,8 @@ export default {};
20363
20708
  const escaped = virtualCss.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
20364
20709
  return jsResponse(`var s=document.createElement('style');s.textContent=\`${escaped}\`;s.dataset.svelteHmr=${JSON.stringify(cssCheckPath)};var p=document.querySelector('style[data-svelte-hmr="${cssCheckPath}"]');if(p)p.remove();document.head.appendChild(s);`);
20365
20710
  }, resolveSourcePath = (relPath, projectRoot) => {
20366
- const filePath = resolve32(projectRoot, relPath);
20367
- const ext = extname9(filePath);
20711
+ const filePath = resolve33(projectRoot, relPath);
20712
+ const ext = extname10(filePath);
20368
20713
  if (ext === ".svelte")
20369
20714
  return { ext, filePath: resolveSvelteModulePath(filePath) };
20370
20715
  if (ext)
@@ -20389,8 +20734,8 @@ export default {};
20389
20734
  return transformAndCacheVue(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
20390
20735
  if (!TRANSPILABLE.has(ext))
20391
20736
  return;
20392
- const stat3 = statSync3(filePath);
20393
- const resolvedVueDir = vueDir ? resolve32(vueDir) : undefined;
20737
+ const stat3 = statSync4(filePath);
20738
+ const resolvedVueDir = vueDir ? resolve33(vueDir) : undefined;
20394
20739
  let content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, resolvedVueDir);
20395
20740
  const isAngularGeneratedJs = ext === ".js" && filePath.replace(/\\/g, "/").includes("/.absolutejs/generated/angular/");
20396
20741
  if (isAngularGeneratedJs) {
@@ -20417,12 +20762,12 @@ export default {};
20417
20762
  cachedAngularUserRoot = configuredAngularUserRoot ?? null;
20418
20763
  return cachedAngularUserRoot;
20419
20764
  }, configuredAngularUserRoot, transformAndCacheSvelte = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
20420
- const stat3 = statSync3(filePath);
20765
+ const stat3 = statSync4(filePath);
20421
20766
  const content = await transformSvelteFile(filePath, projectRoot, rewriter, stylePreprocessors);
20422
20767
  setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
20423
20768
  return jsResponse(content);
20424
20769
  }, transformAndCacheVue = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
20425
- const stat3 = statSync3(filePath);
20770
+ const stat3 = statSync4(filePath);
20426
20771
  const content = await transformVueFile(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
20427
20772
  setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
20428
20773
  return jsResponse(content);
@@ -20449,7 +20794,7 @@ export default {};
20449
20794
  const relPath = pathname.slice(SRC_PREFIX.length);
20450
20795
  if (relPath === "bun:wrap" || relPath.startsWith("bun:wrap?"))
20451
20796
  return handleBunWrapRequest();
20452
- const virtualCssResponse = handleVirtualSvelteCss(resolve32(projectRoot, relPath));
20797
+ const virtualCssResponse = handleVirtualSvelteCss(resolve33(projectRoot, relPath));
20453
20798
  if (virtualCssResponse)
20454
20799
  return virtualCssResponse;
20455
20800
  const { filePath, ext } = resolveSourcePath(relPath, projectRoot);
@@ -20465,11 +20810,11 @@ export default {};
20465
20810
  SRC_IMPORT_RE.lastIndex = 0;
20466
20811
  while ((match = SRC_IMPORT_RE.exec(content)) !== null) {
20467
20812
  if (match[1])
20468
- files.push(resolve32(projectRoot, match[1]));
20813
+ files.push(resolve33(projectRoot, match[1]));
20469
20814
  }
20470
20815
  return files;
20471
20816
  }, invalidateModule = (filePath) => {
20472
- const resolved = resolve32(filePath);
20817
+ const resolved = resolve33(filePath);
20473
20818
  invalidate(filePath);
20474
20819
  if (resolved !== filePath)
20475
20820
  invalidate(resolved);
@@ -20608,282 +20953,6 @@ var init_rewriteImports = __esm(() => {
20608
20953
  rewriteVendorDirectories2 = rewriteVendorDirectories;
20609
20954
  });
20610
20955
 
20611
- // src/dev/angular/resolveOwningComponents.ts
20612
- var exports_resolveOwningComponents = {};
20613
- __export(exports_resolveOwningComponents, {
20614
- resolveOwningComponents: () => resolveOwningComponents,
20615
- resolveDescendantsOfParent: () => resolveDescendantsOfParent,
20616
- invalidateResourceIndex: () => invalidateResourceIndex
20617
- });
20618
- import { readdirSync as readdirSync2, readFileSync as readFileSync19, statSync as statSync4 } from "fs";
20619
- import { dirname as dirname19, extname as extname10, join as join29, resolve as resolve33 } from "path";
20620
- import ts7 from "typescript";
20621
- var ENTITY_DECORATORS, isAngularSourceFile = (file4) => file4.endsWith(".ts") || file4.endsWith(".tsx"), walkAngularSourceFiles = (root) => {
20622
- const out = [];
20623
- const visit = (dir) => {
20624
- let entries;
20625
- try {
20626
- entries = readdirSync2(dir, { withFileTypes: true });
20627
- } catch {
20628
- return;
20629
- }
20630
- for (const entry of entries) {
20631
- if (entry.name.startsWith(".") || entry.name === "node_modules") {
20632
- continue;
20633
- }
20634
- const full = join29(dir, entry.name);
20635
- if (entry.isDirectory()) {
20636
- visit(full);
20637
- } else if (entry.isFile() && isAngularSourceFile(entry.name)) {
20638
- out.push(full);
20639
- }
20640
- }
20641
- };
20642
- visit(root);
20643
- return out;
20644
- }, getStringPropertyValue = (obj, name) => {
20645
- for (const prop of obj.properties) {
20646
- if (!ts7.isPropertyAssignment(prop))
20647
- continue;
20648
- const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
20649
- if (propName !== name)
20650
- continue;
20651
- const init = prop.initializer;
20652
- if (ts7.isStringLiteral(init) || ts7.isNoSubstitutionTemplateLiteral(init)) {
20653
- return init.text;
20654
- }
20655
- }
20656
- return null;
20657
- }, getStringArrayProperty = (obj, name) => {
20658
- const out = [];
20659
- for (const prop of obj.properties) {
20660
- if (!ts7.isPropertyAssignment(prop))
20661
- continue;
20662
- const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
20663
- if (propName !== name)
20664
- continue;
20665
- const init = prop.initializer;
20666
- if (!ts7.isArrayLiteralExpression(init))
20667
- continue;
20668
- for (const element of init.elements) {
20669
- if (ts7.isStringLiteral(element) || ts7.isNoSubstitutionTemplateLiteral(element)) {
20670
- out.push(element.text);
20671
- }
20672
- }
20673
- }
20674
- return out;
20675
- }, parseDecoratedClasses = (filePath) => {
20676
- let source;
20677
- try {
20678
- source = readFileSync19(filePath, "utf8");
20679
- } catch {
20680
- return [];
20681
- }
20682
- const sourceFile = ts7.createSourceFile(filePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
20683
- const out = [];
20684
- const visit = (node) => {
20685
- if (ts7.isClassDeclaration(node) && node.name) {
20686
- for (const decorator of ts7.getDecorators(node) ?? []) {
20687
- const expr = decorator.expression;
20688
- if (!ts7.isCallExpression(expr))
20689
- continue;
20690
- const fn2 = expr.expression;
20691
- if (!ts7.isIdentifier(fn2))
20692
- continue;
20693
- const kind = ENTITY_DECORATORS[fn2.text];
20694
- if (!kind)
20695
- continue;
20696
- let extendsName = null;
20697
- for (const heritage of node.heritageClauses ?? []) {
20698
- if (heritage.token !== ts7.SyntaxKind.ExtendsKeyword) {
20699
- continue;
20700
- }
20701
- const first = heritage.types[0];
20702
- if (first && ts7.isIdentifier(first.expression)) {
20703
- extendsName = first.expression.text;
20704
- }
20705
- break;
20706
- }
20707
- const entry = {
20708
- className: node.name.text,
20709
- kind,
20710
- styleUrls: [],
20711
- templateUrls: [],
20712
- extendsName
20713
- };
20714
- const arg = expr.arguments[0];
20715
- if (arg && ts7.isObjectLiteralExpression(arg) && kind === "component") {
20716
- const tplUrl = getStringPropertyValue(arg, "templateUrl");
20717
- if (tplUrl)
20718
- entry.templateUrls.push(tplUrl);
20719
- const styleUrl = getStringPropertyValue(arg, "styleUrl");
20720
- if (styleUrl)
20721
- entry.styleUrls.push(styleUrl);
20722
- entry.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
20723
- }
20724
- out.push(entry);
20725
- break;
20726
- }
20727
- }
20728
- ts7.forEachChild(node, visit);
20729
- };
20730
- visit(sourceFile);
20731
- return out;
20732
- }, safeNormalize = (path) => resolve33(path).replace(/\\/g, "/"), resolveOwningComponents = (params) => {
20733
- const { changedFilePath, userAngularRoot } = params;
20734
- const changedAbs = safeNormalize(changedFilePath);
20735
- const out = [];
20736
- const ext = extname10(changedAbs).toLowerCase();
20737
- if (ext === ".ts" || ext === ".tsx") {
20738
- const classes = parseDecoratedClasses(changedAbs);
20739
- for (const cls of classes) {
20740
- out.push({
20741
- className: cls.className,
20742
- componentFilePath: changedAbs,
20743
- kind: cls.kind
20744
- });
20745
- }
20746
- return out;
20747
- }
20748
- if (ext !== ".html" && ext !== ".css" && ext !== ".scss" && ext !== ".sass") {
20749
- return out;
20750
- }
20751
- let rootStat;
20752
- try {
20753
- rootStat = statSync4(userAngularRoot);
20754
- } catch {
20755
- return out;
20756
- }
20757
- if (!rootStat.isDirectory())
20758
- return out;
20759
- const index = getOrBuildResourceIndex(userAngularRoot);
20760
- const owners = index.get(changedAbs);
20761
- if (owners) {
20762
- out.push(...owners);
20763
- }
20764
- return out;
20765
- }, indexByRoot, resolveParentClassFile = (parentName, childFilePath, angularRoot) => {
20766
- let source;
20767
- try {
20768
- source = readFileSync19(childFilePath, "utf8");
20769
- } catch {
20770
- return null;
20771
- }
20772
- const sf = ts7.createSourceFile(childFilePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
20773
- const childDir = dirname19(childFilePath);
20774
- for (const stmt of sf.statements) {
20775
- if (!ts7.isImportDeclaration(stmt))
20776
- continue;
20777
- if (!ts7.isStringLiteral(stmt.moduleSpecifier))
20778
- continue;
20779
- const clause = stmt.importClause;
20780
- if (!clause || clause.isTypeOnly)
20781
- continue;
20782
- let matchesName = false;
20783
- if (clause.name && clause.name.text === parentName)
20784
- matchesName = true;
20785
- if (!matchesName && clause.namedBindings && ts7.isNamedImports(clause.namedBindings)) {
20786
- for (const el of clause.namedBindings.elements) {
20787
- if (el.isTypeOnly)
20788
- continue;
20789
- if (el.name.text === parentName) {
20790
- matchesName = true;
20791
- break;
20792
- }
20793
- }
20794
- }
20795
- if (!matchesName)
20796
- continue;
20797
- const spec = stmt.moduleSpecifier.text;
20798
- if (!spec.startsWith(".") && !spec.startsWith("/")) {
20799
- return null;
20800
- }
20801
- const base = resolve33(childDir, spec);
20802
- const candidates = [
20803
- `${base}.ts`,
20804
- `${base}.tsx`,
20805
- `${base}/index.ts`,
20806
- `${base}/index.tsx`
20807
- ];
20808
- const angularRootNorm = safeNormalize(angularRoot);
20809
- for (const candidate of candidates) {
20810
- try {
20811
- if (statSync4(candidate).isFile()) {
20812
- const norm = safeNormalize(candidate);
20813
- if (!norm.startsWith(angularRootNorm))
20814
- return null;
20815
- return norm;
20816
- }
20817
- } catch {}
20818
- }
20819
- return null;
20820
- }
20821
- return null;
20822
- }, getOrBuildIndexes = (userAngularRoot) => {
20823
- const cached = indexByRoot.get(userAngularRoot);
20824
- if (cached)
20825
- return cached;
20826
- const resource = new Map;
20827
- const parentFile = new Map;
20828
- for (const tsPath of walkAngularSourceFiles(userAngularRoot)) {
20829
- const classes = parseDecoratedClasses(tsPath);
20830
- const componentDir = dirname19(tsPath);
20831
- for (const cls of classes) {
20832
- const entity = {
20833
- className: cls.className,
20834
- componentFilePath: tsPath,
20835
- kind: cls.kind
20836
- };
20837
- if (cls.kind === "component") {
20838
- for (const url of [...cls.templateUrls, ...cls.styleUrls]) {
20839
- const abs = safeNormalize(resolve33(componentDir, url));
20840
- const existing = resource.get(abs);
20841
- if (existing)
20842
- existing.push(entity);
20843
- else
20844
- resource.set(abs, [entity]);
20845
- }
20846
- }
20847
- if (cls.extendsName !== null) {
20848
- const parentPath = resolveParentClassFile(cls.extendsName, tsPath, userAngularRoot);
20849
- if (parentPath !== null && parentPath !== safeNormalize(tsPath)) {
20850
- const existing = parentFile.get(parentPath);
20851
- if (existing)
20852
- existing.push(entity);
20853
- else
20854
- parentFile.set(parentPath, [entity]);
20855
- }
20856
- }
20857
- }
20858
- }
20859
- const bundle = { parentFile, resource };
20860
- indexByRoot.set(userAngularRoot, bundle);
20861
- return bundle;
20862
- }, getOrBuildResourceIndex = (userAngularRoot) => getOrBuildIndexes(userAngularRoot).resource, resolveDescendantsOfParent = (params) => {
20863
- const norm = safeNormalize(params.changedFilePath);
20864
- let rootStat;
20865
- try {
20866
- rootStat = statSync4(params.userAngularRoot);
20867
- } catch {
20868
- return [];
20869
- }
20870
- if (!rootStat.isDirectory())
20871
- return [];
20872
- const bundle = getOrBuildIndexes(params.userAngularRoot);
20873
- return bundle.parentFile.get(norm) ?? [];
20874
- }, invalidateResourceIndex = () => {
20875
- indexByRoot.clear();
20876
- };
20877
- var init_resolveOwningComponents = __esm(() => {
20878
- ENTITY_DECORATORS = {
20879
- Component: "component",
20880
- Directive: "directive",
20881
- Pipe: "pipe",
20882
- Injectable: "service"
20883
- };
20884
- indexByRoot = new Map;
20885
- });
20886
-
20887
20956
  // src/dev/angular/hmrCompiler.ts
20888
20957
  var exports_hmrCompiler = {};
20889
20958
  __export(exports_hmrCompiler, {
@@ -21348,6 +21417,35 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21348
21417
  for (const importer of findStyleEntriesImporting(changedStylePath)) {
21349
21418
  enqueueImporter(state, importer);
21350
21419
  }
21420
+ enqueueAngularOwningComponentForStyle(state, changedStylePath);
21421
+ }, enqueueAngularOwningComponentForStyle = (state, changedStylePath) => {
21422
+ const angularDir = state.resolvedPaths.angularDir;
21423
+ if (!angularDir)
21424
+ return;
21425
+ const visited = new Set;
21426
+ const stack = [
21427
+ changedStylePath,
21428
+ ...findStyleEntriesImporting(changedStylePath)
21429
+ ];
21430
+ while (stack.length > 0) {
21431
+ const stylePath = stack.pop();
21432
+ if (!stylePath || visited.has(stylePath))
21433
+ continue;
21434
+ visited.add(stylePath);
21435
+ for (const upstream of findStyleEntriesImporting(stylePath)) {
21436
+ if (!visited.has(upstream))
21437
+ stack.push(upstream);
21438
+ }
21439
+ try {
21440
+ const owners = resolveOwningComponents({
21441
+ changedFilePath: stylePath,
21442
+ userAngularRoot: angularDir
21443
+ });
21444
+ for (const owner of owners) {
21445
+ enqueueImporter(state, owner.componentFilePath);
21446
+ }
21447
+ } catch {}
21448
+ }
21351
21449
  }, queueFileChange = async (state, filePath, config, onRebuildComplete) => {
21352
21450
  const framework = detectFramework(filePath, state.resolvedPaths);
21353
21451
  if (framework === "ignored") {
@@ -22982,6 +23080,7 @@ var init_rebuildTrigger = __esm(() => {
22982
23080
  init_telemetryEvent();
22983
23081
  init_assetStore();
22984
23082
  init_pathUtils();
23083
+ init_resolveOwningComponents();
22985
23084
  init_webSocket();
22986
23085
  init_stylePreprocessor();
22987
23086
  init_compileTailwind();
@@ -23643,5 +23742,5 @@ export {
23643
23742
  build
23644
23743
  };
23645
23744
 
23646
- //# debugId=F2F7819D5956C6C964756E2164756E21
23745
+ //# debugId=1686DE6823FDD81564756E2164756E21
23647
23746
  //# sourceMappingURL=build.js.map