@absolutejs/absolute 0.19.0-beta.941 → 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.`);
@@ -13645,6 +13663,14 @@ var fail = (reason, detail, location) => ({
13645
13663
  return false;
13646
13664
  if (a.viewProvidersArraySig !== b2.viewProvidersArraySig)
13647
13665
  return false;
13666
+ if (a.decoratorInputsArraySig !== b2.decoratorInputsArraySig)
13667
+ return false;
13668
+ if (a.decoratorOutputsArraySig !== b2.decoratorOutputsArraySig)
13669
+ return false;
13670
+ if (a.hostBindingsSig !== b2.hostBindingsSig)
13671
+ return false;
13672
+ if (a.pageExportsSig !== b2.pageExportsSig)
13673
+ return false;
13648
13674
  return true;
13649
13675
  }, recordFingerprint = (id, fp) => {
13650
13676
  fingerprintCache.set(id, fp);
@@ -13668,25 +13694,47 @@ var fail = (reason, detail, location) => ({
13668
13694
  if (!className)
13669
13695
  continue;
13670
13696
  const decorators = ts6.getDecorators(stmt) ?? [];
13671
- const componentDecorator = decorators.find((d2) => {
13672
- if (!ts6.isCallExpression(d2.expression))
13673
- return false;
13674
- const expr = d2.expression.expression;
13675
- return ts6.isIdentifier(expr) && expr.text === "Component";
13676
- });
13677
- if (!componentDecorator)
13678
- continue;
13679
- const decoratorCall = componentDecorator.expression;
13680
- const args = decoratorCall.arguments[0];
13681
- 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)
13682
13711
  continue;
13683
- const decoratorMeta = readDecoratorMeta(args);
13684
- const { inputs, outputs } = extractInputsAndOutputs(stmt, null);
13685
- const componentDir = dirname13(componentFilePath);
13686
- const fingerprint = extractFingerprint(stmt, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
13687
13712
  const projectRel = relative12(process.cwd(), componentFilePath).replace(/\\/g, "/");
13688
13713
  const id = encodeURIComponent(`${projectRel}@${className}`);
13689
- 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
+ }
13690
13738
  }
13691
13739
  }, invalidateFingerprintCache = () => {
13692
13740
  fingerprintCache.clear();
@@ -13939,6 +13987,9 @@ var fail = (reason, detail, location) => ({
13939
13987
  const animationsExpr = getProperty(args, "animations");
13940
13988
  const providersExpr = getProperty(args, "providers");
13941
13989
  const viewProvidersExpr = getProperty(args, "viewProviders");
13990
+ const inputsArrayExpr = getProperty(args, "inputs");
13991
+ const outputsArrayExpr = getProperty(args, "outputs");
13992
+ const hostExpr = getProperty(args, "host");
13942
13993
  const styleUrls = [];
13943
13994
  if (styleUrlsExpr && ts6.isArrayLiteralExpression(styleUrlsExpr)) {
13944
13995
  for (const el of styleUrlsExpr.elements) {
@@ -13972,6 +14023,9 @@ var fail = (reason, detail, location) => ({
13972
14023
  animationsExpr: animationsExpr && ts6.isArrayLiteralExpression(animationsExpr) ? animationsExpr : null,
13973
14024
  providersExpr: providersExpr && ts6.isArrayLiteralExpression(providersExpr) ? providersExpr : null,
13974
14025
  viewProvidersExpr: viewProvidersExpr && ts6.isArrayLiteralExpression(viewProvidersExpr) ? viewProvidersExpr : null,
14026
+ inputsArrayExpr: inputsArrayExpr && ts6.isArrayLiteralExpression(inputsArrayExpr) ? inputsArrayExpr : null,
14027
+ outputsArrayExpr: outputsArrayExpr && ts6.isArrayLiteralExpression(outputsArrayExpr) ? outputsArrayExpr : null,
14028
+ hostExpr: hostExpr && ts6.isObjectLiteralExpression(hostExpr) ? hostExpr : null,
13975
14029
  preserveWhitespaces: getBooleanProperty(args, "preserveWhitespaces") ?? projectDefaults.preserveWhitespaces ?? false,
13976
14030
  selector: getStringProperty(args, "selector"),
13977
14031
  standalone: getBooleanProperty(args, "standalone") ?? true,
@@ -14985,20 +15039,47 @@ var fail = (reason, detail, location) => ({
14985
15039
  const animationsArraySig = decoratorMeta.animationsExpr ? djb2Hash(decoratorMeta.animationsExpr.getText()) : "";
14986
15040
  const providersArraySig = decoratorMeta.providersExpr ? djb2Hash(decoratorMeta.providersExpr.getText()) : "";
14987
15041
  const viewProvidersArraySig = decoratorMeta.viewProvidersExpr ? djb2Hash(decoratorMeta.viewProvidersExpr.getText()) : "";
15042
+ const decoratorInputsArraySig = decoratorMeta.inputsArrayExpr ? djb2Hash(decoratorMeta.inputsArrayExpr.getText()) : "";
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("|") : "";
14988
15065
  return {
14989
15066
  animationsArraySig,
14990
15067
  arrowFieldSig,
14991
15068
  changeDetection: decoratorMeta.changeDetection,
14992
15069
  className,
14993
15070
  ctorParamTypes,
15071
+ decoratorInputsArraySig,
15072
+ decoratorOutputsArraySig,
14994
15073
  encapsulation: decoratorMeta.encapsulation,
14995
15074
  hasProviders: decoratorMeta.hasProviders,
14996
15075
  hasViewProviders: decoratorMeta.hasViewProviders,
15076
+ hostBindingsSig,
14997
15077
  hostDirectivesSig,
14998
15078
  importsArraySig,
14999
15079
  inputs: inputNames,
15000
15080
  memberDecoratorSig,
15001
15081
  outputs: outputNames,
15082
+ pageExportsSig,
15002
15083
  propertyFieldNames,
15003
15084
  providerImportSig,
15004
15085
  providersArraySig,
@@ -15257,7 +15338,7 @@ ${block}
15257
15338
  const currentFingerprint = extractFingerprint(classNode, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
15258
15339
  const cachedFingerprint = fingerprintCache.get(fingerprintId);
15259
15340
  const fingerprintChanged = cachedFingerprint !== undefined && !fingerprintsEqual(cachedFingerprint, currentFingerprint);
15260
- const rebootstrapRequired = !currentFingerprint.standalone || cachedFingerprint !== undefined && (cachedFingerprint.importsArraySig !== currentFingerprint.importsArraySig || cachedFingerprint.hostDirectivesSig !== currentFingerprint.hostDirectivesSig || cachedFingerprint.providersArraySig !== currentFingerprint.providersArraySig || cachedFingerprint.viewProvidersArraySig !== currentFingerprint.viewProvidersArraySig || 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);
15261
15342
  const sourceFileObj = new compiler.ParseSourceFile(tsSource, componentFilePath);
15262
15343
  const zeroLoc = new compiler.ParseLocation(sourceFileObj, 0, 0, 0);
15263
15344
  const typeSourceSpan = new compiler.ParseSourceSpan(zeroLoc, zeroLoc);
@@ -15390,7 +15471,29 @@ ${block}
15390
15471
  for (const entry of resolvedImports) {
15391
15472
  referencedNames.add(entry.identifier.text);
15392
15473
  }
15393
- const depsToDestructure = [...sourceScopeNames].filter((n) => referencedNames.has(n));
15474
+ const allImportedNames = new Set;
15475
+ for (const stmt of sourceFile.statements) {
15476
+ if (!ts6.isImportDeclaration(stmt))
15477
+ continue;
15478
+ const clause = stmt.importClause;
15479
+ if (!clause || clause.isTypeOnly)
15480
+ continue;
15481
+ if (clause.name)
15482
+ allImportedNames.add(clause.name.text);
15483
+ const bindings = clause.namedBindings;
15484
+ if (!bindings)
15485
+ continue;
15486
+ if (ts6.isNamespaceImport(bindings)) {
15487
+ allImportedNames.add(bindings.name.text);
15488
+ } else {
15489
+ for (const el of bindings.elements) {
15490
+ if (el.isTypeOnly)
15491
+ continue;
15492
+ allImportedNames.add(el.name.text);
15493
+ }
15494
+ }
15495
+ }
15496
+ const depsToDestructure = [...sourceScopeNames].filter((n) => referencedNames.has(n) || allImportedNames.has(n));
15394
15497
  const tsSourceText = fnText;
15395
15498
  const transpiled = ts6.transpileModule(tsSourceText, {
15396
15499
  compilerOptions: {
@@ -19581,90 +19684,366 @@ var init_moduleMapper = __esm(() => {
19581
19684
  init_reactComponentClassifier();
19582
19685
  });
19583
19686
 
19584
- // types/typeGuards.ts
19585
- var isValidHMRClientMessage = (data) => {
19586
- if (!data || typeof data !== "object") {
19587
- return false;
19588
- }
19589
- if (!("type" in data) || typeof data.type !== "string") {
19590
- 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
+ }
19591
19731
  }
19592
- switch (data.type) {
19593
- case "ping":
19594
- case "ready":
19595
- case "request-rebuild":
19596
- case "hydration-error":
19597
- case "hmr-timing":
19598
- case "angular:hmr-ack":
19599
- return true;
19600
- default:
19601
- 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
+ }
19602
19749
  }
19603
- };
19604
-
19605
- // src/dev/webSocket.ts
19606
- var trySendMessage = (client, messageStr) => {
19750
+ return out;
19751
+ }, parseDecoratedClasses = (filePath) => {
19752
+ let source;
19607
19753
  try {
19608
- client.send(messageStr);
19609
- return true;
19754
+ source = readFileSync18(filePath, "utf8");
19610
19755
  } catch {
19611
- return false;
19756
+ return [];
19612
19757
  }
19613
- }, broadcastToClients = (state, message) => {
19614
- const messageStr = JSON.stringify({
19615
- ...message,
19616
- timestamp: Date.now()
19617
- });
19618
- const shouldRemove = (client) => {
19619
- 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);
19620
19805
  };
19621
- const clientsToRemove = [];
19622
- state.connectedClients.forEach((client) => {
19623
- if (shouldRemove(client))
19624
- clientsToRemove.push(client);
19625
- });
19626
- clientsToRemove.forEach((client) => {
19627
- state.connectedClients.delete(client);
19628
- });
19629
- }, handleClientConnect = (state, client, manifest) => {
19630
- state.connectedClients.add(client);
19631
- const serverVersions = serializeModuleVersions(state.moduleVersions);
19632
- client.send(JSON.stringify({
19633
- data: {
19634
- manifest,
19635
- serverVersions
19636
- },
19637
- timestamp: Date.now(),
19638
- type: "manifest"
19639
- }));
19640
- client.send(JSON.stringify({
19641
- message: "HMR client connected successfully",
19642
- timestamp: Date.now(),
19643
- type: "connected"
19644
- }));
19645
- }, handleClientDisconnect = (state, client) => {
19646
- state.connectedClients.delete(client);
19647
- }, parseJsonSafe = (raw) => JSON.parse(raw), parseMessage = (message) => {
19648
- if (typeof message === "string") {
19649
- return parseJsonSafe(message);
19650
- }
19651
- if (message instanceof Buffer) {
19652
- return parseJsonSafe(message.toString());
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;
19653
19823
  }
19654
- if (message instanceof ArrayBuffer) {
19655
- return parseJsonSafe(new TextDecoder().decode(new Uint8Array(message)));
19824
+ if (ext !== ".html" && ext !== ".css" && ext !== ".scss" && ext !== ".sass") {
19825
+ return out;
19656
19826
  }
19657
- if (ArrayBuffer.isView(message)) {
19658
- const view = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
19659
- return parseJsonSafe(new TextDecoder().decode(view));
19827
+ let rootStat;
19828
+ try {
19829
+ rootStat = statSync3(userAngularRoot);
19830
+ } catch {
19831
+ return out;
19660
19832
  }
19661
- if (typeof message === "object" && message !== null) {
19662
- return message;
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);
19663
19839
  }
19664
- return null;
19665
- }, handleParsedMessage = (state, client, data) => {
19666
- switch (data.type) {
19667
- case "ping":
19840
+ return out;
19841
+ }, indexByRoot, resolveParentClassFile = (parentName, childFilePath, angularRoot) => {
19842
+ let source;
19843
+ try {
19844
+ source = readFileSync18(childFilePath, "utf8");
19845
+ } catch {
19846
+ return null;
19847
+ }
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":
19668
20047
  client.send(JSON.stringify({
19669
20048
  timestamp: Date.now(),
19670
20049
  type: "pong"
@@ -19722,8 +20101,8 @@ __export(exports_moduleServer, {
19722
20101
  createModuleServer: () => createModuleServer,
19723
20102
  SRC_URL_PREFIX: () => SRC_URL_PREFIX
19724
20103
  });
19725
- import { existsSync as existsSync25, readFileSync as readFileSync18, statSync as statSync3 } from "fs";
19726
- 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";
19727
20106
  var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
19728
20107
  const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
19729
20108
  const allExports = [];
@@ -19743,7 +20122,7 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPIL
19743
20122
  ${stubs}
19744
20123
  `;
19745
20124
  }, resolveRelativeExtension = (srcPath, projectRoot, extensions) => {
19746
- const found = extensions.find((ext) => existsSync25(resolve32(projectRoot, srcPath + ext)));
20125
+ const found = extensions.find((ext) => existsSync25(resolve33(projectRoot, srcPath + ext)));
19747
20126
  return found ? srcPath + found : srcPath;
19748
20127
  }, IMPORT_EXTENSIONS, SIDE_EFFECT_EXTENSIONS, MODULE_EXTENSIONS, RESOLVED_MODULE_EXTENSIONS, REACT_EXTENSIONS, escapeRegex3 = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), buildImportRewriter = (vendorPaths) => {
19749
20128
  const entries = Object.entries(vendorPaths).sort(([a], [b2]) => b2.length - a.length);
@@ -19758,24 +20137,24 @@ ${stubs}
19758
20137
  return invalidationVersion > 0 ? `${mtime}.${invalidationVersion}` : `${mtime}`;
19759
20138
  }, srcUrl = (relPath, projectRoot) => {
19760
20139
  const base = `${SRC_PREFIX}${relPath.replace(/\\/g, "/")}`;
19761
- const absPath = resolve32(projectRoot, relPath);
20140
+ const absPath = resolve33(projectRoot, relPath);
19762
20141
  const cached = mtimeCache.get(absPath);
19763
20142
  if (cached !== undefined)
19764
20143
  return `${base}?v=${buildVersion(cached, absPath)}`;
19765
20144
  try {
19766
- const mtime = Math.round(statSync3(absPath).mtimeMs);
20145
+ const mtime = Math.round(statSync4(absPath).mtimeMs);
19767
20146
  mtimeCache.set(absPath, mtime);
19768
20147
  return `${base}?v=${buildVersion(mtime, absPath)}`;
19769
20148
  } catch {
19770
20149
  return base;
19771
20150
  }
19772
20151
  }, resolveRelativeImport = (relPath, fileDir, projectRoot, extensions) => {
19773
- const absPath = resolve32(fileDir, relPath);
20152
+ const absPath = resolve33(fileDir, relPath);
19774
20153
  const rel = relative14(projectRoot, absPath);
19775
- const extension = extname9(rel);
20154
+ const extension = extname10(rel);
19776
20155
  let srcPath = RESOLVED_MODULE_EXTENSIONS.has(extension) ? rel : resolveRelativeExtension(rel, projectRoot, extensions);
19777
- if (extname9(srcPath) === ".svelte") {
19778
- srcPath = relative14(projectRoot, resolveSvelteModulePath(resolve32(projectRoot, srcPath)));
20156
+ if (extname10(srcPath) === ".svelte") {
20157
+ srcPath = relative14(projectRoot, resolveSvelteModulePath(resolve33(projectRoot, srcPath)));
19779
20158
  }
19780
20159
  return srcUrl(srcPath, projectRoot);
19781
20160
  }, NODE_BUILTIN_RE, resolveAbsoluteSpecifier = (specifier, projectRoot) => {
@@ -19794,13 +20173,13 @@ ${stubs}
19794
20173
  const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
19795
20174
  const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
19796
20175
  if (!subpath) {
19797
- const pkgDir = resolve32(projectRoot, "node_modules", packageName ?? "");
19798
- const pkgJsonPath = join28(pkgDir, "package.json");
20176
+ const pkgDir = resolve33(projectRoot, "node_modules", packageName ?? "");
20177
+ const pkgJsonPath = join29(pkgDir, "package.json");
19799
20178
  if (existsSync25(pkgJsonPath)) {
19800
- const pkg = JSON.parse(readFileSync18(pkgJsonPath, "utf-8"));
20179
+ const pkg = JSON.parse(readFileSync19(pkgJsonPath, "utf-8"));
19801
20180
  const esmEntry = typeof pkg.module === "string" && pkg.module || typeof pkg.browser === "string" && pkg.browser;
19802
20181
  if (esmEntry) {
19803
- const resolved = resolve32(pkgDir, esmEntry);
20182
+ const resolved = resolve33(pkgDir, esmEntry);
19804
20183
  if (existsSync25(resolved))
19805
20184
  return relative14(projectRoot, resolved);
19806
20185
  }
@@ -19832,7 +20211,7 @@ ${stubs}
19832
20211
  };
19833
20212
  result = result.replace(/^((?:import\s+[\s\S]+?\s+from|export\s+[\s\S]+?\s+from|import)\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
19834
20213
  result = result.replace(/(import\s*\(\s*["'])([^"'./][^"']*)(["']\s*\))/g, stubReplace);
19835
- const fileDir = dirname18(filePath);
20214
+ const fileDir = dirname19(filePath);
19836
20215
  result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
19837
20216
  result = result.replace(/(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
19838
20217
  result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, SIDE_EFFECT_EXTENSIONS)}${suffix}`);
@@ -19847,12 +20226,12 @@ ${stubs}
19847
20226
  result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, rewriteAbsoluteToSrc);
19848
20227
  result = result.replace(/(import\s*\(\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["']\s*\))/g, rewriteAbsoluteToSrc);
19849
20228
  result = result.replace(/new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g, (_match, relPath) => {
19850
- const absPath = resolve32(fileDir, relPath);
20229
+ const absPath = resolve33(fileDir, relPath);
19851
20230
  const rel = relative14(projectRoot, absPath);
19852
20231
  return `new URL('${srcUrl(rel, projectRoot)}', import.meta.url)`;
19853
20232
  });
19854
20233
  result = result.replace(/import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g, (_match, relPath) => {
19855
- const absPath = resolve32(fileDir, relPath);
20234
+ const absPath = resolve33(fileDir, relPath);
19856
20235
  const rel = relative14(projectRoot, absPath);
19857
20236
  return `'${srcUrl(rel, projectRoot)}'`;
19858
20237
  });
@@ -19898,7 +20277,7 @@ ${code}`;
19898
20277
  reactFastRefreshWarningEmitted = true;
19899
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.");
19900
20279
  }, transformReactFile = (filePath, projectRoot, rewriter) => {
19901
- const raw = readFileSync18(filePath, "utf-8");
20280
+ const raw = readFileSync19(filePath, "utf-8");
19902
20281
  const valueExports = tsxTranspiler.scan(raw).exports;
19903
20282
  let transpiled = reactTranspiler.transformSync(raw);
19904
20283
  transpiled = preserveTypeExports(raw, transpiled, valueExports);
@@ -19914,8 +20293,8 @@ ${transpiled}`;
19914
20293
  transpiled += buildIslandMetadataExports(raw);
19915
20294
  return rewriteImports(transpiled, filePath, projectRoot, rewriter);
19916
20295
  }, transformPlainFile = (filePath, projectRoot, rewriter, vueDir) => {
19917
- const raw = readFileSync18(filePath, "utf-8");
19918
- const ext = extname9(filePath);
20296
+ const raw = readFileSync19(filePath, "utf-8");
20297
+ const ext = extname10(filePath);
19919
20298
  const isTS = ext === ".ts" || ext === ".tsx";
19920
20299
  const isTSX = ext === ".tsx" || ext === ".jsx";
19921
20300
  let transpiler6 = jsTranspiler2;
@@ -20080,7 +20459,7 @@ ${code}`;
20080
20459
  ` + ` var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
20081
20460
  return code.replace(/import\.meta\.hot\.accept\(/g, "__hmr_accept(");
20082
20461
  }, transformSvelteFile = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
20083
- const raw = readFileSync18(filePath, "utf-8");
20462
+ const raw = readFileSync19(filePath, "utf-8");
20084
20463
  if (!svelteCompiler) {
20085
20464
  svelteCompiler = await import("svelte/compiler");
20086
20465
  }
@@ -20142,7 +20521,7 @@ export default __script__;`;
20142
20521
  return `${cssInjection}
20143
20522
  ${code}`;
20144
20523
  }, transformVueFile = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
20145
- const rawSource = readFileSync18(filePath, "utf-8");
20524
+ const rawSource = readFileSync19(filePath, "utf-8");
20146
20525
  const raw = addAutoRouterSetupApp(rawSource);
20147
20526
  if (!vueCompiler) {
20148
20527
  vueCompiler = await import("@vue/compiler-sfc");
@@ -20165,7 +20544,7 @@ ${code}`;
20165
20544
  code = injectVueHmr(code, filePath, projectRoot, vueDir);
20166
20545
  return rewriteImports(code, filePath, projectRoot, rewriter);
20167
20546
  }, injectVueHmr = (code, filePath, projectRoot, vueDir) => {
20168
- const hmrBase = vueDir ? resolve32(vueDir) : projectRoot;
20547
+ const hmrBase = vueDir ? resolve33(vueDir) : projectRoot;
20169
20548
  const hmrId = relative14(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
20170
20549
  let result = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
20171
20550
  result += [
@@ -20197,7 +20576,7 @@ ${code}`;
20197
20576
  }
20198
20577
  });
20199
20578
  }, handleCssRequest = (filePath) => {
20200
- const raw = readFileSync18(filePath, "utf-8");
20579
+ const raw = readFileSync19(filePath, "utf-8");
20201
20580
  const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
20202
20581
  return [
20203
20582
  `const style = document.createElement('style');`,
@@ -20329,8 +20708,8 @@ export default {};
20329
20708
  const escaped = virtualCss.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
20330
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);`);
20331
20710
  }, resolveSourcePath = (relPath, projectRoot) => {
20332
- const filePath = resolve32(projectRoot, relPath);
20333
- const ext = extname9(filePath);
20711
+ const filePath = resolve33(projectRoot, relPath);
20712
+ const ext = extname10(filePath);
20334
20713
  if (ext === ".svelte")
20335
20714
  return { ext, filePath: resolveSvelteModulePath(filePath) };
20336
20715
  if (ext)
@@ -20355,8 +20734,8 @@ export default {};
20355
20734
  return transformAndCacheVue(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
20356
20735
  if (!TRANSPILABLE.has(ext))
20357
20736
  return;
20358
- const stat3 = statSync3(filePath);
20359
- const resolvedVueDir = vueDir ? resolve32(vueDir) : undefined;
20737
+ const stat3 = statSync4(filePath);
20738
+ const resolvedVueDir = vueDir ? resolve33(vueDir) : undefined;
20360
20739
  let content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, resolvedVueDir);
20361
20740
  const isAngularGeneratedJs = ext === ".js" && filePath.replace(/\\/g, "/").includes("/.absolutejs/generated/angular/");
20362
20741
  if (isAngularGeneratedJs) {
@@ -20383,12 +20762,12 @@ export default {};
20383
20762
  cachedAngularUserRoot = configuredAngularUserRoot ?? null;
20384
20763
  return cachedAngularUserRoot;
20385
20764
  }, configuredAngularUserRoot, transformAndCacheSvelte = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
20386
- const stat3 = statSync3(filePath);
20765
+ const stat3 = statSync4(filePath);
20387
20766
  const content = await transformSvelteFile(filePath, projectRoot, rewriter, stylePreprocessors);
20388
20767
  setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
20389
20768
  return jsResponse(content);
20390
20769
  }, transformAndCacheVue = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
20391
- const stat3 = statSync3(filePath);
20770
+ const stat3 = statSync4(filePath);
20392
20771
  const content = await transformVueFile(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
20393
20772
  setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
20394
20773
  return jsResponse(content);
@@ -20415,7 +20794,7 @@ export default {};
20415
20794
  const relPath = pathname.slice(SRC_PREFIX.length);
20416
20795
  if (relPath === "bun:wrap" || relPath.startsWith("bun:wrap?"))
20417
20796
  return handleBunWrapRequest();
20418
- const virtualCssResponse = handleVirtualSvelteCss(resolve32(projectRoot, relPath));
20797
+ const virtualCssResponse = handleVirtualSvelteCss(resolve33(projectRoot, relPath));
20419
20798
  if (virtualCssResponse)
20420
20799
  return virtualCssResponse;
20421
20800
  const { filePath, ext } = resolveSourcePath(relPath, projectRoot);
@@ -20431,11 +20810,11 @@ export default {};
20431
20810
  SRC_IMPORT_RE.lastIndex = 0;
20432
20811
  while ((match = SRC_IMPORT_RE.exec(content)) !== null) {
20433
20812
  if (match[1])
20434
- files.push(resolve32(projectRoot, match[1]));
20813
+ files.push(resolve33(projectRoot, match[1]));
20435
20814
  }
20436
20815
  return files;
20437
20816
  }, invalidateModule = (filePath) => {
20438
- const resolved = resolve32(filePath);
20817
+ const resolved = resolve33(filePath);
20439
20818
  invalidate(filePath);
20440
20819
  if (resolved !== filePath)
20441
20820
  invalidate(resolved);
@@ -20574,282 +20953,6 @@ var init_rewriteImports = __esm(() => {
20574
20953
  rewriteVendorDirectories2 = rewriteVendorDirectories;
20575
20954
  });
20576
20955
 
20577
- // src/dev/angular/resolveOwningComponents.ts
20578
- var exports_resolveOwningComponents = {};
20579
- __export(exports_resolveOwningComponents, {
20580
- resolveOwningComponents: () => resolveOwningComponents,
20581
- resolveDescendantsOfParent: () => resolveDescendantsOfParent,
20582
- invalidateResourceIndex: () => invalidateResourceIndex
20583
- });
20584
- import { readdirSync as readdirSync2, readFileSync as readFileSync19, statSync as statSync4 } from "fs";
20585
- import { dirname as dirname19, extname as extname10, join as join29, resolve as resolve33 } from "path";
20586
- import ts7 from "typescript";
20587
- var ENTITY_DECORATORS, isAngularSourceFile = (file4) => file4.endsWith(".ts") || file4.endsWith(".tsx"), walkAngularSourceFiles = (root) => {
20588
- const out = [];
20589
- const visit = (dir) => {
20590
- let entries;
20591
- try {
20592
- entries = readdirSync2(dir, { withFileTypes: true });
20593
- } catch {
20594
- return;
20595
- }
20596
- for (const entry of entries) {
20597
- if (entry.name.startsWith(".") || entry.name === "node_modules") {
20598
- continue;
20599
- }
20600
- const full = join29(dir, entry.name);
20601
- if (entry.isDirectory()) {
20602
- visit(full);
20603
- } else if (entry.isFile() && isAngularSourceFile(entry.name)) {
20604
- out.push(full);
20605
- }
20606
- }
20607
- };
20608
- visit(root);
20609
- return out;
20610
- }, getStringPropertyValue = (obj, name) => {
20611
- for (const prop of obj.properties) {
20612
- if (!ts7.isPropertyAssignment(prop))
20613
- continue;
20614
- const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
20615
- if (propName !== name)
20616
- continue;
20617
- const init = prop.initializer;
20618
- if (ts7.isStringLiteral(init) || ts7.isNoSubstitutionTemplateLiteral(init)) {
20619
- return init.text;
20620
- }
20621
- }
20622
- return null;
20623
- }, getStringArrayProperty = (obj, name) => {
20624
- const out = [];
20625
- for (const prop of obj.properties) {
20626
- if (!ts7.isPropertyAssignment(prop))
20627
- continue;
20628
- const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
20629
- if (propName !== name)
20630
- continue;
20631
- const init = prop.initializer;
20632
- if (!ts7.isArrayLiteralExpression(init))
20633
- continue;
20634
- for (const element of init.elements) {
20635
- if (ts7.isStringLiteral(element) || ts7.isNoSubstitutionTemplateLiteral(element)) {
20636
- out.push(element.text);
20637
- }
20638
- }
20639
- }
20640
- return out;
20641
- }, parseDecoratedClasses = (filePath) => {
20642
- let source;
20643
- try {
20644
- source = readFileSync19(filePath, "utf8");
20645
- } catch {
20646
- return [];
20647
- }
20648
- const sourceFile = ts7.createSourceFile(filePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
20649
- const out = [];
20650
- const visit = (node) => {
20651
- if (ts7.isClassDeclaration(node) && node.name) {
20652
- for (const decorator of ts7.getDecorators(node) ?? []) {
20653
- const expr = decorator.expression;
20654
- if (!ts7.isCallExpression(expr))
20655
- continue;
20656
- const fn2 = expr.expression;
20657
- if (!ts7.isIdentifier(fn2))
20658
- continue;
20659
- const kind = ENTITY_DECORATORS[fn2.text];
20660
- if (!kind)
20661
- continue;
20662
- let extendsName = null;
20663
- for (const heritage of node.heritageClauses ?? []) {
20664
- if (heritage.token !== ts7.SyntaxKind.ExtendsKeyword) {
20665
- continue;
20666
- }
20667
- const first = heritage.types[0];
20668
- if (first && ts7.isIdentifier(first.expression)) {
20669
- extendsName = first.expression.text;
20670
- }
20671
- break;
20672
- }
20673
- const entry = {
20674
- className: node.name.text,
20675
- kind,
20676
- styleUrls: [],
20677
- templateUrls: [],
20678
- extendsName
20679
- };
20680
- const arg = expr.arguments[0];
20681
- if (arg && ts7.isObjectLiteralExpression(arg) && kind === "component") {
20682
- const tplUrl = getStringPropertyValue(arg, "templateUrl");
20683
- if (tplUrl)
20684
- entry.templateUrls.push(tplUrl);
20685
- const styleUrl = getStringPropertyValue(arg, "styleUrl");
20686
- if (styleUrl)
20687
- entry.styleUrls.push(styleUrl);
20688
- entry.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
20689
- }
20690
- out.push(entry);
20691
- break;
20692
- }
20693
- }
20694
- ts7.forEachChild(node, visit);
20695
- };
20696
- visit(sourceFile);
20697
- return out;
20698
- }, safeNormalize = (path) => resolve33(path).replace(/\\/g, "/"), resolveOwningComponents = (params) => {
20699
- const { changedFilePath, userAngularRoot } = params;
20700
- const changedAbs = safeNormalize(changedFilePath);
20701
- const out = [];
20702
- const ext = extname10(changedAbs).toLowerCase();
20703
- if (ext === ".ts" || ext === ".tsx") {
20704
- const classes = parseDecoratedClasses(changedAbs);
20705
- for (const cls of classes) {
20706
- out.push({
20707
- className: cls.className,
20708
- componentFilePath: changedAbs,
20709
- kind: cls.kind
20710
- });
20711
- }
20712
- return out;
20713
- }
20714
- if (ext !== ".html" && ext !== ".css" && ext !== ".scss" && ext !== ".sass") {
20715
- return out;
20716
- }
20717
- let rootStat;
20718
- try {
20719
- rootStat = statSync4(userAngularRoot);
20720
- } catch {
20721
- return out;
20722
- }
20723
- if (!rootStat.isDirectory())
20724
- return out;
20725
- const index = getOrBuildResourceIndex(userAngularRoot);
20726
- const owners = index.get(changedAbs);
20727
- if (owners) {
20728
- out.push(...owners);
20729
- }
20730
- return out;
20731
- }, indexByRoot, resolveParentClassFile = (parentName, childFilePath, angularRoot) => {
20732
- let source;
20733
- try {
20734
- source = readFileSync19(childFilePath, "utf8");
20735
- } catch {
20736
- return null;
20737
- }
20738
- const sf = ts7.createSourceFile(childFilePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
20739
- const childDir = dirname19(childFilePath);
20740
- for (const stmt of sf.statements) {
20741
- if (!ts7.isImportDeclaration(stmt))
20742
- continue;
20743
- if (!ts7.isStringLiteral(stmt.moduleSpecifier))
20744
- continue;
20745
- const clause = stmt.importClause;
20746
- if (!clause || clause.isTypeOnly)
20747
- continue;
20748
- let matchesName = false;
20749
- if (clause.name && clause.name.text === parentName)
20750
- matchesName = true;
20751
- if (!matchesName && clause.namedBindings && ts7.isNamedImports(clause.namedBindings)) {
20752
- for (const el of clause.namedBindings.elements) {
20753
- if (el.isTypeOnly)
20754
- continue;
20755
- if (el.name.text === parentName) {
20756
- matchesName = true;
20757
- break;
20758
- }
20759
- }
20760
- }
20761
- if (!matchesName)
20762
- continue;
20763
- const spec = stmt.moduleSpecifier.text;
20764
- if (!spec.startsWith(".") && !spec.startsWith("/")) {
20765
- return null;
20766
- }
20767
- const base = resolve33(childDir, spec);
20768
- const candidates = [
20769
- `${base}.ts`,
20770
- `${base}.tsx`,
20771
- `${base}/index.ts`,
20772
- `${base}/index.tsx`
20773
- ];
20774
- const angularRootNorm = safeNormalize(angularRoot);
20775
- for (const candidate of candidates) {
20776
- try {
20777
- if (statSync4(candidate).isFile()) {
20778
- const norm = safeNormalize(candidate);
20779
- if (!norm.startsWith(angularRootNorm))
20780
- return null;
20781
- return norm;
20782
- }
20783
- } catch {}
20784
- }
20785
- return null;
20786
- }
20787
- return null;
20788
- }, getOrBuildIndexes = (userAngularRoot) => {
20789
- const cached = indexByRoot.get(userAngularRoot);
20790
- if (cached)
20791
- return cached;
20792
- const resource = new Map;
20793
- const parentFile = new Map;
20794
- for (const tsPath of walkAngularSourceFiles(userAngularRoot)) {
20795
- const classes = parseDecoratedClasses(tsPath);
20796
- const componentDir = dirname19(tsPath);
20797
- for (const cls of classes) {
20798
- const entity = {
20799
- className: cls.className,
20800
- componentFilePath: tsPath,
20801
- kind: cls.kind
20802
- };
20803
- if (cls.kind === "component") {
20804
- for (const url of [...cls.templateUrls, ...cls.styleUrls]) {
20805
- const abs = safeNormalize(resolve33(componentDir, url));
20806
- const existing = resource.get(abs);
20807
- if (existing)
20808
- existing.push(entity);
20809
- else
20810
- resource.set(abs, [entity]);
20811
- }
20812
- }
20813
- if (cls.extendsName !== null) {
20814
- const parentPath = resolveParentClassFile(cls.extendsName, tsPath, userAngularRoot);
20815
- if (parentPath !== null && parentPath !== safeNormalize(tsPath)) {
20816
- const existing = parentFile.get(parentPath);
20817
- if (existing)
20818
- existing.push(entity);
20819
- else
20820
- parentFile.set(parentPath, [entity]);
20821
- }
20822
- }
20823
- }
20824
- }
20825
- const bundle = { parentFile, resource };
20826
- indexByRoot.set(userAngularRoot, bundle);
20827
- return bundle;
20828
- }, getOrBuildResourceIndex = (userAngularRoot) => getOrBuildIndexes(userAngularRoot).resource, resolveDescendantsOfParent = (params) => {
20829
- const norm = safeNormalize(params.changedFilePath);
20830
- let rootStat;
20831
- try {
20832
- rootStat = statSync4(params.userAngularRoot);
20833
- } catch {
20834
- return [];
20835
- }
20836
- if (!rootStat.isDirectory())
20837
- return [];
20838
- const bundle = getOrBuildIndexes(params.userAngularRoot);
20839
- return bundle.parentFile.get(norm) ?? [];
20840
- }, invalidateResourceIndex = () => {
20841
- indexByRoot.clear();
20842
- };
20843
- var init_resolveOwningComponents = __esm(() => {
20844
- ENTITY_DECORATORS = {
20845
- Component: "component",
20846
- Directive: "directive",
20847
- Pipe: "pipe",
20848
- Injectable: "service"
20849
- };
20850
- indexByRoot = new Map;
20851
- });
20852
-
20853
20956
  // src/dev/angular/hmrCompiler.ts
20854
20957
  var exports_hmrCompiler = {};
20855
20958
  __export(exports_hmrCompiler, {
@@ -21314,6 +21417,35 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21314
21417
  for (const importer of findStyleEntriesImporting(changedStylePath)) {
21315
21418
  enqueueImporter(state, importer);
21316
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
+ }
21317
21449
  }, queueFileChange = async (state, filePath, config, onRebuildComplete) => {
21318
21450
  const framework = detectFramework(filePath, state.resolvedPaths);
21319
21451
  if (framework === "ignored") {
@@ -21546,6 +21678,17 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21546
21678
  tier: 1
21547
21679
  };
21548
21680
  }
21681
+ if (owners.length === 0 && editedFile.endsWith(".ts") && !editedFile.endsWith(".d.ts")) {
21682
+ const normalized = editedFile.replace(/\\/g, "/");
21683
+ const angularDirAbs = resolve37(angularDir).replace(/\\/g, "/");
21684
+ if (normalized.startsWith(angularDirAbs + "/")) {
21685
+ return {
21686
+ kind: "rebootstrap",
21687
+ reason: `non-decorated angular file edited (${editedFile}) \u2014 consumers may hold stale resolved values`,
21688
+ tier: 1
21689
+ };
21690
+ }
21691
+ }
21549
21692
  for (const { componentFilePath, className, kind } of owners) {
21550
21693
  const id = encodeHmrComponentId2(componentFilePath, className);
21551
21694
  if (queueIds.has(id))
@@ -22937,6 +23080,7 @@ var init_rebuildTrigger = __esm(() => {
22937
23080
  init_telemetryEvent();
22938
23081
  init_assetStore();
22939
23082
  init_pathUtils();
23083
+ init_resolveOwningComponents();
22940
23084
  init_webSocket();
22941
23085
  init_stylePreprocessor();
22942
23086
  init_compileTailwind();
@@ -23598,5 +23742,5 @@ export {
23598
23742
  build
23599
23743
  };
23600
23744
 
23601
- //# debugId=03D479D7EFCEEBE864756E2164756E21
23745
+ //# debugId=1686DE6823FDD81564756E2164756E21
23602
23746
  //# sourceMappingURL=build.js.map