@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/index.js CHANGED
@@ -527,6 +527,15 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
527
527
  url: new URL(`file://${filePath}`)
528
528
  });
529
529
  const css = await runPostcss(result.css, filePath, config);
530
+ const loadedUrls = result.loadedUrls ?? [];
531
+ for (const url of loadedUrls) {
532
+ if (url.protocol !== "file:")
533
+ continue;
534
+ const dep = fileURLToPath(url);
535
+ if (resolve2(dep) === resolve2(filePath))
536
+ continue;
537
+ deps.add(dep);
538
+ }
530
539
  recordStyleDeps(filePath, deps);
531
540
  return css;
532
541
  } catch (error) {
@@ -695,7 +704,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
695
704
  }
696
705
  const contents = withAdditionalData(rawContents, options.additionalData);
697
706
  const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
698
- const compiled = sass.compileString(contents, {
707
+ const result = sass.compileString(contents, {
699
708
  importers: [
700
709
  createSassImporter(filePath, loadPaths, language, config)
701
710
  ],
@@ -703,8 +712,17 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
703
712
  style: "expanded",
704
713
  syntax: language === "sass" ? "indented" : "scss",
705
714
  url: new URL(`file://${filePath}`)
706
- }).css;
707
- return resolveCssImportsSync(compiled, dirname2(filePath), new Set([filePath]));
715
+ });
716
+ const loadedUrls = result.loadedUrls ?? [];
717
+ for (const url of loadedUrls) {
718
+ if (url.protocol !== "file:")
719
+ continue;
720
+ const dep = fileURLToPath(url);
721
+ if (resolve2(dep) === resolve2(filePath))
722
+ continue;
723
+ addStyleImporter(filePath, dep);
724
+ }
725
+ return resolveCssImportsSync(result.css, dirname2(filePath), new Set([filePath]));
708
726
  }
709
727
  if (language === "less") {
710
728
  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.`);
@@ -13837,6 +13855,14 @@ var fail = (reason, detail, location) => ({
13837
13855
  return false;
13838
13856
  if (a.viewProvidersArraySig !== b2.viewProvidersArraySig)
13839
13857
  return false;
13858
+ if (a.decoratorInputsArraySig !== b2.decoratorInputsArraySig)
13859
+ return false;
13860
+ if (a.decoratorOutputsArraySig !== b2.decoratorOutputsArraySig)
13861
+ return false;
13862
+ if (a.hostBindingsSig !== b2.hostBindingsSig)
13863
+ return false;
13864
+ if (a.pageExportsSig !== b2.pageExportsSig)
13865
+ return false;
13840
13866
  return true;
13841
13867
  }, recordFingerprint = (id, fp) => {
13842
13868
  fingerprintCache.set(id, fp);
@@ -13860,25 +13886,47 @@ var fail = (reason, detail, location) => ({
13860
13886
  if (!className)
13861
13887
  continue;
13862
13888
  const decorators = ts6.getDecorators(stmt) ?? [];
13863
- const componentDecorator = decorators.find((d2) => {
13864
- if (!ts6.isCallExpression(d2.expression))
13865
- return false;
13866
- const expr = d2.expression.expression;
13867
- return ts6.isIdentifier(expr) && expr.text === "Component";
13868
- });
13869
- if (!componentDecorator)
13870
- continue;
13871
- const decoratorCall = componentDecorator.expression;
13872
- const args = decoratorCall.arguments[0];
13873
- if (!args || !ts6.isObjectLiteralExpression(args))
13889
+ const decoratorName = (() => {
13890
+ for (const d2 of decorators) {
13891
+ if (!ts6.isCallExpression(d2.expression))
13892
+ continue;
13893
+ const expr = d2.expression.expression;
13894
+ if (!ts6.isIdentifier(expr))
13895
+ continue;
13896
+ if (expr.text === "Component" || expr.text === "Directive" || expr.text === "Pipe" || expr.text === "Injectable") {
13897
+ return expr.text;
13898
+ }
13899
+ }
13900
+ return null;
13901
+ })();
13902
+ if (!decoratorName)
13874
13903
  continue;
13875
- const decoratorMeta = readDecoratorMeta(args);
13876
- const { inputs, outputs } = extractInputsAndOutputs(stmt, null);
13877
- const componentDir = dirname15(componentFilePath);
13878
- const fingerprint = extractFingerprint(stmt, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
13879
13904
  const projectRel = relative12(process.cwd(), componentFilePath).replace(/\\/g, "/");
13880
13905
  const id = encodeURIComponent(`${projectRel}@${className}`);
13881
- fingerprintCache.set(id, fingerprint);
13906
+ if (decoratorName === "Component") {
13907
+ const componentDecorator = decorators.find((d2) => {
13908
+ if (!ts6.isCallExpression(d2.expression))
13909
+ return false;
13910
+ const expr = d2.expression.expression;
13911
+ return ts6.isIdentifier(expr) && expr.text === "Component";
13912
+ });
13913
+ if (!componentDecorator)
13914
+ continue;
13915
+ const decoratorCall = componentDecorator.expression;
13916
+ const args = decoratorCall.arguments[0];
13917
+ if (!args || !ts6.isObjectLiteralExpression(args))
13918
+ continue;
13919
+ const decoratorMeta = readDecoratorMeta(args);
13920
+ const { inputs, outputs } = extractInputsAndOutputs(stmt, null);
13921
+ const componentDir = dirname15(componentFilePath);
13922
+ const fingerprint = extractFingerprint(stmt, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
13923
+ fingerprintCache.set(id, fingerprint);
13924
+ } else {
13925
+ try {
13926
+ const entityFingerprint = extractEntityFingerprint(stmt, className, sourceFile);
13927
+ entityFingerprintCache.set(id, entityFingerprint);
13928
+ } catch {}
13929
+ }
13882
13930
  }
13883
13931
  }, invalidateFingerprintCache = () => {
13884
13932
  fingerprintCache.clear();
@@ -14131,6 +14179,9 @@ var fail = (reason, detail, location) => ({
14131
14179
  const animationsExpr = getProperty(args, "animations");
14132
14180
  const providersExpr = getProperty(args, "providers");
14133
14181
  const viewProvidersExpr = getProperty(args, "viewProviders");
14182
+ const inputsArrayExpr = getProperty(args, "inputs");
14183
+ const outputsArrayExpr = getProperty(args, "outputs");
14184
+ const hostExpr = getProperty(args, "host");
14134
14185
  const styleUrls = [];
14135
14186
  if (styleUrlsExpr && ts6.isArrayLiteralExpression(styleUrlsExpr)) {
14136
14187
  for (const el of styleUrlsExpr.elements) {
@@ -14164,6 +14215,9 @@ var fail = (reason, detail, location) => ({
14164
14215
  animationsExpr: animationsExpr && ts6.isArrayLiteralExpression(animationsExpr) ? animationsExpr : null,
14165
14216
  providersExpr: providersExpr && ts6.isArrayLiteralExpression(providersExpr) ? providersExpr : null,
14166
14217
  viewProvidersExpr: viewProvidersExpr && ts6.isArrayLiteralExpression(viewProvidersExpr) ? viewProvidersExpr : null,
14218
+ inputsArrayExpr: inputsArrayExpr && ts6.isArrayLiteralExpression(inputsArrayExpr) ? inputsArrayExpr : null,
14219
+ outputsArrayExpr: outputsArrayExpr && ts6.isArrayLiteralExpression(outputsArrayExpr) ? outputsArrayExpr : null,
14220
+ hostExpr: hostExpr && ts6.isObjectLiteralExpression(hostExpr) ? hostExpr : null,
14167
14221
  preserveWhitespaces: getBooleanProperty(args, "preserveWhitespaces") ?? projectDefaults.preserveWhitespaces ?? false,
14168
14222
  selector: getStringProperty(args, "selector"),
14169
14223
  standalone: getBooleanProperty(args, "standalone") ?? true,
@@ -15177,20 +15231,47 @@ var fail = (reason, detail, location) => ({
15177
15231
  const animationsArraySig = decoratorMeta.animationsExpr ? djb2Hash(decoratorMeta.animationsExpr.getText()) : "";
15178
15232
  const providersArraySig = decoratorMeta.providersExpr ? djb2Hash(decoratorMeta.providersExpr.getText()) : "";
15179
15233
  const viewProvidersArraySig = decoratorMeta.viewProvidersExpr ? djb2Hash(decoratorMeta.viewProvidersExpr.getText()) : "";
15234
+ const decoratorInputsArraySig = decoratorMeta.inputsArrayExpr ? djb2Hash(decoratorMeta.inputsArrayExpr.getText()) : "";
15235
+ const decoratorOutputsArraySig = decoratorMeta.outputsArrayExpr ? djb2Hash(decoratorMeta.outputsArrayExpr.getText()) : "";
15236
+ const hostBindingsSig = decoratorMeta.hostExpr ? djb2Hash(decoratorMeta.hostExpr.getText()) : "";
15237
+ const PAGE_EXPORT_NAMES = new Set(["providers", "routes"]);
15238
+ const pageExportEntries = [];
15239
+ for (const stmt of sourceFile.statements) {
15240
+ if (!ts6.isVariableStatement(stmt))
15241
+ continue;
15242
+ const isExported = stmt.modifiers?.some((m) => m.kind === ts6.SyntaxKind.ExportKeyword);
15243
+ if (!isExported)
15244
+ continue;
15245
+ for (const decl of stmt.declarationList.declarations) {
15246
+ if (!ts6.isIdentifier(decl.name))
15247
+ continue;
15248
+ if (!PAGE_EXPORT_NAMES.has(decl.name.text))
15249
+ continue;
15250
+ if (!decl.initializer)
15251
+ continue;
15252
+ pageExportEntries.push(`${decl.name.text}=${djb2Hash(decl.initializer.getText())}`);
15253
+ }
15254
+ }
15255
+ pageExportEntries.sort();
15256
+ const pageExportsSig = pageExportEntries.length > 0 ? pageExportEntries.join("|") : "";
15180
15257
  return {
15181
15258
  animationsArraySig,
15182
15259
  arrowFieldSig,
15183
15260
  changeDetection: decoratorMeta.changeDetection,
15184
15261
  className,
15185
15262
  ctorParamTypes,
15263
+ decoratorInputsArraySig,
15264
+ decoratorOutputsArraySig,
15186
15265
  encapsulation: decoratorMeta.encapsulation,
15187
15266
  hasProviders: decoratorMeta.hasProviders,
15188
15267
  hasViewProviders: decoratorMeta.hasViewProviders,
15268
+ hostBindingsSig,
15189
15269
  hostDirectivesSig,
15190
15270
  importsArraySig,
15191
15271
  inputs: inputNames,
15192
15272
  memberDecoratorSig,
15193
15273
  outputs: outputNames,
15274
+ pageExportsSig,
15194
15275
  propertyFieldNames,
15195
15276
  providerImportSig,
15196
15277
  providersArraySig,
@@ -15449,7 +15530,7 @@ ${block}
15449
15530
  const currentFingerprint = extractFingerprint(classNode, className, decoratorMeta, inputs, outputs, sourceFile, componentDir);
15450
15531
  const cachedFingerprint = fingerprintCache.get(fingerprintId);
15451
15532
  const fingerprintChanged = cachedFingerprint !== undefined && !fingerprintsEqual(cachedFingerprint, currentFingerprint);
15452
- 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);
15533
+ 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);
15453
15534
  const sourceFileObj = new compiler.ParseSourceFile(tsSource, componentFilePath);
15454
15535
  const zeroLoc = new compiler.ParseLocation(sourceFileObj, 0, 0, 0);
15455
15536
  const typeSourceSpan = new compiler.ParseSourceSpan(zeroLoc, zeroLoc);
@@ -15582,7 +15663,29 @@ ${block}
15582
15663
  for (const entry of resolvedImports) {
15583
15664
  referencedNames.add(entry.identifier.text);
15584
15665
  }
15585
- const depsToDestructure = [...sourceScopeNames].filter((n) => referencedNames.has(n));
15666
+ const allImportedNames = new Set;
15667
+ for (const stmt of sourceFile.statements) {
15668
+ if (!ts6.isImportDeclaration(stmt))
15669
+ continue;
15670
+ const clause = stmt.importClause;
15671
+ if (!clause || clause.isTypeOnly)
15672
+ continue;
15673
+ if (clause.name)
15674
+ allImportedNames.add(clause.name.text);
15675
+ const bindings = clause.namedBindings;
15676
+ if (!bindings)
15677
+ continue;
15678
+ if (ts6.isNamespaceImport(bindings)) {
15679
+ allImportedNames.add(bindings.name.text);
15680
+ } else {
15681
+ for (const el of bindings.elements) {
15682
+ if (el.isTypeOnly)
15683
+ continue;
15684
+ allImportedNames.add(el.name.text);
15685
+ }
15686
+ }
15687
+ }
15688
+ const depsToDestructure = [...sourceScopeNames].filter((n) => referencedNames.has(n) || allImportedNames.has(n));
15586
15689
  const tsSourceText = fnText;
15587
15690
  const transpiled = ts6.transpileModule(tsSourceText, {
15588
15691
  compilerOptions: {
@@ -19699,105 +19802,381 @@ var init_moduleMapper = __esm(() => {
19699
19802
  init_reactComponentClassifier();
19700
19803
  });
19701
19804
 
19702
- // src/dev/webSocket.ts
19703
- var trySendMessage = (client2, messageStr) => {
19704
- try {
19705
- client2.send(messageStr);
19706
- return true;
19707
- } catch {
19708
- return false;
19709
- }
19710
- }, broadcastToClients = (state, message) => {
19711
- const messageStr = JSON.stringify({
19712
- ...message,
19713
- timestamp: Date.now()
19714
- });
19715
- const shouldRemove = (client2) => {
19716
- return !trySendMessage(client2, messageStr);
19805
+ // src/dev/angular/resolveOwningComponents.ts
19806
+ var exports_resolveOwningComponents = {};
19807
+ __export(exports_resolveOwningComponents, {
19808
+ resolveOwningComponents: () => resolveOwningComponents,
19809
+ resolveDescendantsOfParent: () => resolveDescendantsOfParent,
19810
+ invalidateResourceIndex: () => invalidateResourceIndex
19811
+ });
19812
+ import { readdirSync as readdirSync2, readFileSync as readFileSync19, statSync as statSync3 } from "fs";
19813
+ import { dirname as dirname19, extname as extname9, join as join29, resolve as resolve34 } from "path";
19814
+ import ts7 from "typescript";
19815
+ var ENTITY_DECORATORS, isAngularSourceFile = (file5) => file5.endsWith(".ts") || file5.endsWith(".tsx"), walkAngularSourceFiles = (root) => {
19816
+ const out = [];
19817
+ const visit = (dir) => {
19818
+ let entries;
19819
+ try {
19820
+ entries = readdirSync2(dir, { withFileTypes: true });
19821
+ } catch {
19822
+ return;
19823
+ }
19824
+ for (const entry of entries) {
19825
+ if (entry.name.startsWith(".") || entry.name === "node_modules") {
19826
+ continue;
19827
+ }
19828
+ const full = join29(dir, entry.name);
19829
+ if (entry.isDirectory()) {
19830
+ visit(full);
19831
+ } else if (entry.isFile() && isAngularSourceFile(entry.name)) {
19832
+ out.push(full);
19833
+ }
19834
+ }
19717
19835
  };
19718
- const clientsToRemove = [];
19719
- state.connectedClients.forEach((client2) => {
19720
- if (shouldRemove(client2))
19721
- clientsToRemove.push(client2);
19722
- });
19723
- clientsToRemove.forEach((client2) => {
19724
- state.connectedClients.delete(client2);
19725
- });
19726
- }, handleClientConnect = (state, client2, manifest) => {
19727
- state.connectedClients.add(client2);
19728
- const serverVersions = serializeModuleVersions(state.moduleVersions);
19729
- client2.send(JSON.stringify({
19730
- data: {
19731
- manifest,
19732
- serverVersions
19733
- },
19734
- timestamp: Date.now(),
19735
- type: "manifest"
19736
- }));
19737
- client2.send(JSON.stringify({
19738
- message: "HMR client connected successfully",
19739
- timestamp: Date.now(),
19740
- type: "connected"
19741
- }));
19742
- }, handleClientDisconnect = (state, client2) => {
19743
- state.connectedClients.delete(client2);
19744
- }, parseJsonSafe = (raw) => JSON.parse(raw), parseMessage = (message) => {
19745
- if (typeof message === "string") {
19746
- return parseJsonSafe(message);
19747
- }
19748
- if (message instanceof Buffer) {
19749
- return parseJsonSafe(message.toString());
19750
- }
19751
- if (message instanceof ArrayBuffer) {
19752
- return parseJsonSafe(new TextDecoder().decode(new Uint8Array(message)));
19753
- }
19754
- if (ArrayBuffer.isView(message)) {
19755
- const view = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
19756
- return parseJsonSafe(new TextDecoder().decode(view));
19757
- }
19758
- if (typeof message === "object" && message !== null) {
19759
- return message;
19836
+ visit(root);
19837
+ return out;
19838
+ }, getStringPropertyValue = (obj, name) => {
19839
+ for (const prop of obj.properties) {
19840
+ if (!ts7.isPropertyAssignment(prop))
19841
+ continue;
19842
+ const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
19843
+ if (propName !== name)
19844
+ continue;
19845
+ const init = prop.initializer;
19846
+ if (ts7.isStringLiteral(init) || ts7.isNoSubstitutionTemplateLiteral(init)) {
19847
+ return init.text;
19848
+ }
19760
19849
  }
19761
19850
  return null;
19762
- }, handleParsedMessage = (state, client2, data) => {
19763
- switch (data.type) {
19764
- case "ping":
19765
- client2.send(JSON.stringify({
19766
- timestamp: Date.now(),
19767
- type: "pong"
19768
- }));
19769
- break;
19770
- case "request-rebuild":
19771
- break;
19772
- case "ready":
19773
- if (data.framework) {
19774
- state.activeFrameworks.add(data.framework);
19851
+ }, getStringArrayProperty = (obj, name) => {
19852
+ const out = [];
19853
+ for (const prop of obj.properties) {
19854
+ if (!ts7.isPropertyAssignment(prop))
19855
+ continue;
19856
+ const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
19857
+ if (propName !== name)
19858
+ continue;
19859
+ const init = prop.initializer;
19860
+ if (!ts7.isArrayLiteralExpression(init))
19861
+ continue;
19862
+ for (const element of init.elements) {
19863
+ if (ts7.isStringLiteral(element) || ts7.isNoSubstitutionTemplateLiteral(element)) {
19864
+ out.push(element.text);
19775
19865
  }
19776
- break;
19777
- case "hmr-timing":
19778
- logHmrUpdate(state.lastHmrPath ?? "", state.lastHmrFramework, data.duration);
19779
- break;
19780
- case "angular:hmr-ack": {
19781
- const tag = data.tier === "tier-0" ? "tier-0" : "tier-1a";
19782
- const suffix = data.error ? ` FAILED \u2014 ${data.error}` : ` applied in ${data.applyMs.toFixed(0)}ms`;
19783
- logInfo(`[ng-hmr] ${tag} ${data.className}${suffix}`);
19784
- break;
19785
19866
  }
19786
19867
  }
19787
- }, handleHMRMessage = (state, client2, message) => {
19868
+ return out;
19869
+ }, parseDecoratedClasses = (filePath) => {
19870
+ let source;
19788
19871
  try {
19789
- const parsedData = parseMessage(message);
19790
- if (parsedData === null) {
19791
- return;
19872
+ source = readFileSync19(filePath, "utf8");
19873
+ } catch {
19874
+ return [];
19875
+ }
19876
+ const sourceFile = ts7.createSourceFile(filePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
19877
+ const out = [];
19878
+ const visit = (node) => {
19879
+ if (ts7.isClassDeclaration(node) && node.name) {
19880
+ for (const decorator of ts7.getDecorators(node) ?? []) {
19881
+ const expr = decorator.expression;
19882
+ if (!ts7.isCallExpression(expr))
19883
+ continue;
19884
+ const fn2 = expr.expression;
19885
+ if (!ts7.isIdentifier(fn2))
19886
+ continue;
19887
+ const kind = ENTITY_DECORATORS[fn2.text];
19888
+ if (!kind)
19889
+ continue;
19890
+ let extendsName = null;
19891
+ for (const heritage of node.heritageClauses ?? []) {
19892
+ if (heritage.token !== ts7.SyntaxKind.ExtendsKeyword) {
19893
+ continue;
19894
+ }
19895
+ const first = heritage.types[0];
19896
+ if (first && ts7.isIdentifier(first.expression)) {
19897
+ extendsName = first.expression.text;
19898
+ }
19899
+ break;
19900
+ }
19901
+ const entry = {
19902
+ className: node.name.text,
19903
+ kind,
19904
+ styleUrls: [],
19905
+ templateUrls: [],
19906
+ extendsName
19907
+ };
19908
+ const arg = expr.arguments[0];
19909
+ if (arg && ts7.isObjectLiteralExpression(arg) && kind === "component") {
19910
+ const tplUrl = getStringPropertyValue(arg, "templateUrl");
19911
+ if (tplUrl)
19912
+ entry.templateUrls.push(tplUrl);
19913
+ const styleUrl = getStringPropertyValue(arg, "styleUrl");
19914
+ if (styleUrl)
19915
+ entry.styleUrls.push(styleUrl);
19916
+ entry.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
19917
+ }
19918
+ out.push(entry);
19919
+ break;
19920
+ }
19792
19921
  }
19793
- if (!isValidHMRClientMessage(parsedData)) {
19794
- return;
19922
+ ts7.forEachChild(node, visit);
19923
+ };
19924
+ visit(sourceFile);
19925
+ return out;
19926
+ }, safeNormalize = (path) => resolve34(path).replace(/\\/g, "/"), resolveOwningComponents = (params) => {
19927
+ const { changedFilePath, userAngularRoot } = params;
19928
+ const changedAbs = safeNormalize(changedFilePath);
19929
+ const out = [];
19930
+ const ext = extname9(changedAbs).toLowerCase();
19931
+ if (ext === ".ts" || ext === ".tsx") {
19932
+ const classes = parseDecoratedClasses(changedAbs);
19933
+ for (const cls of classes) {
19934
+ out.push({
19935
+ className: cls.className,
19936
+ componentFilePath: changedAbs,
19937
+ kind: cls.kind
19938
+ });
19795
19939
  }
19796
- handleParsedMessage(state, client2, parsedData);
19797
- } catch {}
19798
- };
19799
- var init_webSocket = __esm(() => {
19800
- init_logger();
19940
+ return out;
19941
+ }
19942
+ if (ext !== ".html" && ext !== ".css" && ext !== ".scss" && ext !== ".sass") {
19943
+ return out;
19944
+ }
19945
+ let rootStat;
19946
+ try {
19947
+ rootStat = statSync3(userAngularRoot);
19948
+ } catch {
19949
+ return out;
19950
+ }
19951
+ if (!rootStat.isDirectory())
19952
+ return out;
19953
+ const index = getOrBuildResourceIndex(userAngularRoot);
19954
+ const owners = index.get(changedAbs);
19955
+ if (owners) {
19956
+ out.push(...owners);
19957
+ }
19958
+ return out;
19959
+ }, indexByRoot, resolveParentClassFile = (parentName, childFilePath, angularRoot) => {
19960
+ let source;
19961
+ try {
19962
+ source = readFileSync19(childFilePath, "utf8");
19963
+ } catch {
19964
+ return null;
19965
+ }
19966
+ const sf = ts7.createSourceFile(childFilePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
19967
+ const childDir = dirname19(childFilePath);
19968
+ for (const stmt of sf.statements) {
19969
+ if (!ts7.isImportDeclaration(stmt))
19970
+ continue;
19971
+ if (!ts7.isStringLiteral(stmt.moduleSpecifier))
19972
+ continue;
19973
+ const clause = stmt.importClause;
19974
+ if (!clause || clause.isTypeOnly)
19975
+ continue;
19976
+ let matchesName = false;
19977
+ if (clause.name && clause.name.text === parentName)
19978
+ matchesName = true;
19979
+ if (!matchesName && clause.namedBindings && ts7.isNamedImports(clause.namedBindings)) {
19980
+ for (const el of clause.namedBindings.elements) {
19981
+ if (el.isTypeOnly)
19982
+ continue;
19983
+ if (el.name.text === parentName) {
19984
+ matchesName = true;
19985
+ break;
19986
+ }
19987
+ }
19988
+ }
19989
+ if (!matchesName)
19990
+ continue;
19991
+ const spec = stmt.moduleSpecifier.text;
19992
+ if (!spec.startsWith(".") && !spec.startsWith("/")) {
19993
+ return null;
19994
+ }
19995
+ const base = resolve34(childDir, spec);
19996
+ const candidates = [
19997
+ `${base}.ts`,
19998
+ `${base}.tsx`,
19999
+ `${base}/index.ts`,
20000
+ `${base}/index.tsx`
20001
+ ];
20002
+ const angularRootNorm = safeNormalize(angularRoot);
20003
+ for (const candidate of candidates) {
20004
+ try {
20005
+ if (statSync3(candidate).isFile()) {
20006
+ const norm = safeNormalize(candidate);
20007
+ if (!norm.startsWith(angularRootNorm))
20008
+ return null;
20009
+ return norm;
20010
+ }
20011
+ } catch {}
20012
+ }
20013
+ return null;
20014
+ }
20015
+ return null;
20016
+ }, getOrBuildIndexes = (userAngularRoot) => {
20017
+ const cached = indexByRoot.get(userAngularRoot);
20018
+ if (cached)
20019
+ return cached;
20020
+ const resource = new Map;
20021
+ const parentFile = new Map;
20022
+ for (const tsPath of walkAngularSourceFiles(userAngularRoot)) {
20023
+ const classes = parseDecoratedClasses(tsPath);
20024
+ const componentDir = dirname19(tsPath);
20025
+ for (const cls of classes) {
20026
+ const entity = {
20027
+ className: cls.className,
20028
+ componentFilePath: tsPath,
20029
+ kind: cls.kind
20030
+ };
20031
+ if (cls.kind === "component") {
20032
+ for (const url of [...cls.templateUrls, ...cls.styleUrls]) {
20033
+ const abs = safeNormalize(resolve34(componentDir, url));
20034
+ const existing = resource.get(abs);
20035
+ if (existing)
20036
+ existing.push(entity);
20037
+ else
20038
+ resource.set(abs, [entity]);
20039
+ }
20040
+ }
20041
+ if (cls.extendsName !== null) {
20042
+ const parentPath = resolveParentClassFile(cls.extendsName, tsPath, userAngularRoot);
20043
+ if (parentPath !== null && parentPath !== safeNormalize(tsPath)) {
20044
+ const existing = parentFile.get(parentPath);
20045
+ if (existing)
20046
+ existing.push(entity);
20047
+ else
20048
+ parentFile.set(parentPath, [entity]);
20049
+ }
20050
+ }
20051
+ }
20052
+ }
20053
+ const bundle = { parentFile, resource };
20054
+ indexByRoot.set(userAngularRoot, bundle);
20055
+ return bundle;
20056
+ }, getOrBuildResourceIndex = (userAngularRoot) => getOrBuildIndexes(userAngularRoot).resource, resolveDescendantsOfParent = (params) => {
20057
+ const norm = safeNormalize(params.changedFilePath);
20058
+ let rootStat;
20059
+ try {
20060
+ rootStat = statSync3(params.userAngularRoot);
20061
+ } catch {
20062
+ return [];
20063
+ }
20064
+ if (!rootStat.isDirectory())
20065
+ return [];
20066
+ const bundle = getOrBuildIndexes(params.userAngularRoot);
20067
+ return bundle.parentFile.get(norm) ?? [];
20068
+ }, invalidateResourceIndex = () => {
20069
+ indexByRoot.clear();
20070
+ };
20071
+ var init_resolveOwningComponents = __esm(() => {
20072
+ ENTITY_DECORATORS = {
20073
+ Component: "component",
20074
+ Directive: "directive",
20075
+ Pipe: "pipe",
20076
+ Injectable: "service"
20077
+ };
20078
+ indexByRoot = new Map;
20079
+ });
20080
+
20081
+ // src/dev/webSocket.ts
20082
+ var trySendMessage = (client2, messageStr) => {
20083
+ try {
20084
+ client2.send(messageStr);
20085
+ return true;
20086
+ } catch {
20087
+ return false;
20088
+ }
20089
+ }, broadcastToClients = (state, message) => {
20090
+ const messageStr = JSON.stringify({
20091
+ ...message,
20092
+ timestamp: Date.now()
20093
+ });
20094
+ const shouldRemove = (client2) => {
20095
+ return !trySendMessage(client2, messageStr);
20096
+ };
20097
+ const clientsToRemove = [];
20098
+ state.connectedClients.forEach((client2) => {
20099
+ if (shouldRemove(client2))
20100
+ clientsToRemove.push(client2);
20101
+ });
20102
+ clientsToRemove.forEach((client2) => {
20103
+ state.connectedClients.delete(client2);
20104
+ });
20105
+ }, handleClientConnect = (state, client2, manifest) => {
20106
+ state.connectedClients.add(client2);
20107
+ const serverVersions = serializeModuleVersions(state.moduleVersions);
20108
+ client2.send(JSON.stringify({
20109
+ data: {
20110
+ manifest,
20111
+ serverVersions
20112
+ },
20113
+ timestamp: Date.now(),
20114
+ type: "manifest"
20115
+ }));
20116
+ client2.send(JSON.stringify({
20117
+ message: "HMR client connected successfully",
20118
+ timestamp: Date.now(),
20119
+ type: "connected"
20120
+ }));
20121
+ }, handleClientDisconnect = (state, client2) => {
20122
+ state.connectedClients.delete(client2);
20123
+ }, parseJsonSafe = (raw) => JSON.parse(raw), parseMessage = (message) => {
20124
+ if (typeof message === "string") {
20125
+ return parseJsonSafe(message);
20126
+ }
20127
+ if (message instanceof Buffer) {
20128
+ return parseJsonSafe(message.toString());
20129
+ }
20130
+ if (message instanceof ArrayBuffer) {
20131
+ return parseJsonSafe(new TextDecoder().decode(new Uint8Array(message)));
20132
+ }
20133
+ if (ArrayBuffer.isView(message)) {
20134
+ const view = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);
20135
+ return parseJsonSafe(new TextDecoder().decode(view));
20136
+ }
20137
+ if (typeof message === "object" && message !== null) {
20138
+ return message;
20139
+ }
20140
+ return null;
20141
+ }, handleParsedMessage = (state, client2, data) => {
20142
+ switch (data.type) {
20143
+ case "ping":
20144
+ client2.send(JSON.stringify({
20145
+ timestamp: Date.now(),
20146
+ type: "pong"
20147
+ }));
20148
+ break;
20149
+ case "request-rebuild":
20150
+ break;
20151
+ case "ready":
20152
+ if (data.framework) {
20153
+ state.activeFrameworks.add(data.framework);
20154
+ }
20155
+ break;
20156
+ case "hmr-timing":
20157
+ logHmrUpdate(state.lastHmrPath ?? "", state.lastHmrFramework, data.duration);
20158
+ break;
20159
+ case "angular:hmr-ack": {
20160
+ const tag = data.tier === "tier-0" ? "tier-0" : "tier-1a";
20161
+ const suffix = data.error ? ` FAILED \u2014 ${data.error}` : ` applied in ${data.applyMs.toFixed(0)}ms`;
20162
+ logInfo(`[ng-hmr] ${tag} ${data.className}${suffix}`);
20163
+ break;
20164
+ }
20165
+ }
20166
+ }, handleHMRMessage = (state, client2, message) => {
20167
+ try {
20168
+ const parsedData = parseMessage(message);
20169
+ if (parsedData === null) {
20170
+ return;
20171
+ }
20172
+ if (!isValidHMRClientMessage(parsedData)) {
20173
+ return;
20174
+ }
20175
+ handleParsedMessage(state, client2, parsedData);
20176
+ } catch {}
20177
+ };
20178
+ var init_webSocket = __esm(() => {
20179
+ init_logger();
19801
20180
  });
19802
20181
 
19803
20182
  // src/core/ssrCache.ts
@@ -19819,8 +20198,8 @@ __export(exports_moduleServer, {
19819
20198
  createModuleServer: () => createModuleServer,
19820
20199
  SRC_URL_PREFIX: () => SRC_URL_PREFIX
19821
20200
  });
19822
- import { existsSync as existsSync26, readFileSync as readFileSync19, statSync as statSync3 } from "fs";
19823
- import { basename as basename11, dirname as dirname19, extname as extname9, join as join29, resolve as resolve34, relative as relative14 } from "path";
20201
+ import { existsSync as existsSync26, readFileSync as readFileSync20, statSync as statSync4 } from "fs";
20202
+ import { basename as basename11, dirname as dirname20, extname as extname10, join as join30, resolve as resolve35, relative as relative14 } from "path";
19824
20203
  var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
19825
20204
  const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
19826
20205
  const allExports = [];
@@ -19840,7 +20219,7 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPIL
19840
20219
  ${stubs}
19841
20220
  `;
19842
20221
  }, resolveRelativeExtension = (srcPath, projectRoot, extensions) => {
19843
- const found = extensions.find((ext) => existsSync26(resolve34(projectRoot, srcPath + ext)));
20222
+ const found = extensions.find((ext) => existsSync26(resolve35(projectRoot, srcPath + ext)));
19844
20223
  return found ? srcPath + found : srcPath;
19845
20224
  }, IMPORT_EXTENSIONS, SIDE_EFFECT_EXTENSIONS, MODULE_EXTENSIONS, RESOLVED_MODULE_EXTENSIONS, REACT_EXTENSIONS, escapeRegex3 = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), buildImportRewriter = (vendorPaths) => {
19846
20225
  const entries = Object.entries(vendorPaths).sort(([a], [b2]) => b2.length - a.length);
@@ -19855,24 +20234,24 @@ ${stubs}
19855
20234
  return invalidationVersion > 0 ? `${mtime}.${invalidationVersion}` : `${mtime}`;
19856
20235
  }, srcUrl = (relPath, projectRoot) => {
19857
20236
  const base = `${SRC_PREFIX}${relPath.replace(/\\/g, "/")}`;
19858
- const absPath = resolve34(projectRoot, relPath);
20237
+ const absPath = resolve35(projectRoot, relPath);
19859
20238
  const cached = mtimeCache.get(absPath);
19860
20239
  if (cached !== undefined)
19861
20240
  return `${base}?v=${buildVersion(cached, absPath)}`;
19862
20241
  try {
19863
- const mtime = Math.round(statSync3(absPath).mtimeMs);
20242
+ const mtime = Math.round(statSync4(absPath).mtimeMs);
19864
20243
  mtimeCache.set(absPath, mtime);
19865
20244
  return `${base}?v=${buildVersion(mtime, absPath)}`;
19866
20245
  } catch {
19867
20246
  return base;
19868
20247
  }
19869
20248
  }, resolveRelativeImport = (relPath, fileDir, projectRoot, extensions) => {
19870
- const absPath = resolve34(fileDir, relPath);
20249
+ const absPath = resolve35(fileDir, relPath);
19871
20250
  const rel = relative14(projectRoot, absPath);
19872
- const extension = extname9(rel);
20251
+ const extension = extname10(rel);
19873
20252
  let srcPath = RESOLVED_MODULE_EXTENSIONS.has(extension) ? rel : resolveRelativeExtension(rel, projectRoot, extensions);
19874
- if (extname9(srcPath) === ".svelte") {
19875
- srcPath = relative14(projectRoot, resolveSvelteModulePath(resolve34(projectRoot, srcPath)));
20253
+ if (extname10(srcPath) === ".svelte") {
20254
+ srcPath = relative14(projectRoot, resolveSvelteModulePath(resolve35(projectRoot, srcPath)));
19876
20255
  }
19877
20256
  return srcUrl(srcPath, projectRoot);
19878
20257
  }, NODE_BUILTIN_RE, resolveAbsoluteSpecifier = (specifier, projectRoot) => {
@@ -19891,13 +20270,13 @@ ${stubs}
19891
20270
  const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
19892
20271
  const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
19893
20272
  if (!subpath) {
19894
- const pkgDir = resolve34(projectRoot, "node_modules", packageName ?? "");
19895
- const pkgJsonPath = join29(pkgDir, "package.json");
20273
+ const pkgDir = resolve35(projectRoot, "node_modules", packageName ?? "");
20274
+ const pkgJsonPath = join30(pkgDir, "package.json");
19896
20275
  if (existsSync26(pkgJsonPath)) {
19897
- const pkg = JSON.parse(readFileSync19(pkgJsonPath, "utf-8"));
20276
+ const pkg = JSON.parse(readFileSync20(pkgJsonPath, "utf-8"));
19898
20277
  const esmEntry = typeof pkg.module === "string" && pkg.module || typeof pkg.browser === "string" && pkg.browser;
19899
20278
  if (esmEntry) {
19900
- const resolved = resolve34(pkgDir, esmEntry);
20279
+ const resolved = resolve35(pkgDir, esmEntry);
19901
20280
  if (existsSync26(resolved))
19902
20281
  return relative14(projectRoot, resolved);
19903
20282
  }
@@ -19929,7 +20308,7 @@ ${stubs}
19929
20308
  };
19930
20309
  result = result.replace(/^((?:import\s+[\s\S]+?\s+from|export\s+[\s\S]+?\s+from|import)\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
19931
20310
  result = result.replace(/(import\s*\(\s*["'])([^"'./][^"']*)(["']\s*\))/g, stubReplace);
19932
- const fileDir = dirname19(filePath);
20311
+ const fileDir = dirname20(filePath);
19933
20312
  result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
19934
20313
  result = result.replace(/(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, IMPORT_EXTENSIONS)}${suffix}`);
19935
20314
  result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, SIDE_EFFECT_EXTENSIONS)}${suffix}`);
@@ -19944,12 +20323,12 @@ ${stubs}
19944
20323
  result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, rewriteAbsoluteToSrc);
19945
20324
  result = result.replace(/(import\s*\(\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["']\s*\))/g, rewriteAbsoluteToSrc);
19946
20325
  result = result.replace(/new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g, (_match, relPath) => {
19947
- const absPath = resolve34(fileDir, relPath);
20326
+ const absPath = resolve35(fileDir, relPath);
19948
20327
  const rel = relative14(projectRoot, absPath);
19949
20328
  return `new URL('${srcUrl(rel, projectRoot)}', import.meta.url)`;
19950
20329
  });
19951
20330
  result = result.replace(/import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g, (_match, relPath) => {
19952
- const absPath = resolve34(fileDir, relPath);
20331
+ const absPath = resolve35(fileDir, relPath);
19953
20332
  const rel = relative14(projectRoot, absPath);
19954
20333
  return `'${srcUrl(rel, projectRoot)}'`;
19955
20334
  });
@@ -19995,7 +20374,7 @@ ${code}`;
19995
20374
  reactFastRefreshWarningEmitted = true;
19996
20375
  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.");
19997
20376
  }, transformReactFile = (filePath, projectRoot, rewriter) => {
19998
- const raw = readFileSync19(filePath, "utf-8");
20377
+ const raw = readFileSync20(filePath, "utf-8");
19999
20378
  const valueExports = tsxTranspiler.scan(raw).exports;
20000
20379
  let transpiled = reactTranspiler.transformSync(raw);
20001
20380
  transpiled = preserveTypeExports(raw, transpiled, valueExports);
@@ -20011,8 +20390,8 @@ ${transpiled}`;
20011
20390
  transpiled += buildIslandMetadataExports(raw);
20012
20391
  return rewriteImports(transpiled, filePath, projectRoot, rewriter);
20013
20392
  }, transformPlainFile = (filePath, projectRoot, rewriter, vueDir) => {
20014
- const raw = readFileSync19(filePath, "utf-8");
20015
- const ext = extname9(filePath);
20393
+ const raw = readFileSync20(filePath, "utf-8");
20394
+ const ext = extname10(filePath);
20016
20395
  const isTS = ext === ".ts" || ext === ".tsx";
20017
20396
  const isTSX = ext === ".tsx" || ext === ".jsx";
20018
20397
  let transpiler6 = jsTranspiler2;
@@ -20177,7 +20556,7 @@ ${code}`;
20177
20556
  ` + ` var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
20178
20557
  return code.replace(/import\.meta\.hot\.accept\(/g, "__hmr_accept(");
20179
20558
  }, transformSvelteFile = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
20180
- const raw = readFileSync19(filePath, "utf-8");
20559
+ const raw = readFileSync20(filePath, "utf-8");
20181
20560
  if (!svelteCompiler) {
20182
20561
  svelteCompiler = await import("svelte/compiler");
20183
20562
  }
@@ -20239,7 +20618,7 @@ export default __script__;`;
20239
20618
  return `${cssInjection}
20240
20619
  ${code}`;
20241
20620
  }, transformVueFile = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
20242
- const rawSource = readFileSync19(filePath, "utf-8");
20621
+ const rawSource = readFileSync20(filePath, "utf-8");
20243
20622
  const raw = addAutoRouterSetupApp(rawSource);
20244
20623
  if (!vueCompiler) {
20245
20624
  vueCompiler = await import("@vue/compiler-sfc");
@@ -20262,7 +20641,7 @@ ${code}`;
20262
20641
  code = injectVueHmr(code, filePath, projectRoot, vueDir);
20263
20642
  return rewriteImports(code, filePath, projectRoot, rewriter);
20264
20643
  }, injectVueHmr = (code, filePath, projectRoot, vueDir) => {
20265
- const hmrBase = vueDir ? resolve34(vueDir) : projectRoot;
20644
+ const hmrBase = vueDir ? resolve35(vueDir) : projectRoot;
20266
20645
  const hmrId = relative14(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
20267
20646
  let result = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
20268
20647
  result += [
@@ -20294,7 +20673,7 @@ ${code}`;
20294
20673
  }
20295
20674
  });
20296
20675
  }, handleCssRequest = (filePath) => {
20297
- const raw = readFileSync19(filePath, "utf-8");
20676
+ const raw = readFileSync20(filePath, "utf-8");
20298
20677
  const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
20299
20678
  return [
20300
20679
  `const style = document.createElement('style');`,
@@ -20426,8 +20805,8 @@ export default {};
20426
20805
  const escaped = virtualCss.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
20427
20806
  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);`);
20428
20807
  }, resolveSourcePath = (relPath, projectRoot) => {
20429
- const filePath = resolve34(projectRoot, relPath);
20430
- const ext = extname9(filePath);
20808
+ const filePath = resolve35(projectRoot, relPath);
20809
+ const ext = extname10(filePath);
20431
20810
  if (ext === ".svelte")
20432
20811
  return { ext, filePath: resolveSvelteModulePath(filePath) };
20433
20812
  if (ext)
@@ -20452,8 +20831,8 @@ export default {};
20452
20831
  return transformAndCacheVue(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
20453
20832
  if (!TRANSPILABLE.has(ext))
20454
20833
  return;
20455
- const stat3 = statSync3(filePath);
20456
- const resolvedVueDir = vueDir ? resolve34(vueDir) : undefined;
20834
+ const stat3 = statSync4(filePath);
20835
+ const resolvedVueDir = vueDir ? resolve35(vueDir) : undefined;
20457
20836
  let content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, resolvedVueDir);
20458
20837
  const isAngularGeneratedJs = ext === ".js" && filePath.replace(/\\/g, "/").includes("/.absolutejs/generated/angular/");
20459
20838
  if (isAngularGeneratedJs) {
@@ -20480,12 +20859,12 @@ export default {};
20480
20859
  cachedAngularUserRoot = configuredAngularUserRoot ?? null;
20481
20860
  return cachedAngularUserRoot;
20482
20861
  }, configuredAngularUserRoot, transformAndCacheSvelte = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
20483
- const stat3 = statSync3(filePath);
20862
+ const stat3 = statSync4(filePath);
20484
20863
  const content = await transformSvelteFile(filePath, projectRoot, rewriter, stylePreprocessors);
20485
20864
  setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
20486
20865
  return jsResponse(content);
20487
20866
  }, transformAndCacheVue = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
20488
- const stat3 = statSync3(filePath);
20867
+ const stat3 = statSync4(filePath);
20489
20868
  const content = await transformVueFile(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
20490
20869
  setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
20491
20870
  return jsResponse(content);
@@ -20512,7 +20891,7 @@ export default {};
20512
20891
  const relPath = pathname.slice(SRC_PREFIX.length);
20513
20892
  if (relPath === "bun:wrap" || relPath.startsWith("bun:wrap?"))
20514
20893
  return handleBunWrapRequest();
20515
- const virtualCssResponse = handleVirtualSvelteCss(resolve34(projectRoot, relPath));
20894
+ const virtualCssResponse = handleVirtualSvelteCss(resolve35(projectRoot, relPath));
20516
20895
  if (virtualCssResponse)
20517
20896
  return virtualCssResponse;
20518
20897
  const { filePath, ext } = resolveSourcePath(relPath, projectRoot);
@@ -20528,11 +20907,11 @@ export default {};
20528
20907
  SRC_IMPORT_RE.lastIndex = 0;
20529
20908
  while ((match = SRC_IMPORT_RE.exec(content)) !== null) {
20530
20909
  if (match[1])
20531
- files.push(resolve34(projectRoot, match[1]));
20910
+ files.push(resolve35(projectRoot, match[1]));
20532
20911
  }
20533
20912
  return files;
20534
20913
  }, invalidateModule = (filePath) => {
20535
- const resolved = resolve34(filePath);
20914
+ const resolved = resolve35(filePath);
20536
20915
  invalidate(filePath);
20537
20916
  if (resolved !== filePath)
20538
20917
  invalidate(resolved);
@@ -20671,282 +21050,6 @@ var init_rewriteImports = __esm(() => {
20671
21050
  rewriteVendorDirectories2 = rewriteVendorDirectories;
20672
21051
  });
20673
21052
 
20674
- // src/dev/angular/resolveOwningComponents.ts
20675
- var exports_resolveOwningComponents = {};
20676
- __export(exports_resolveOwningComponents, {
20677
- resolveOwningComponents: () => resolveOwningComponents,
20678
- resolveDescendantsOfParent: () => resolveDescendantsOfParent,
20679
- invalidateResourceIndex: () => invalidateResourceIndex
20680
- });
20681
- import { readdirSync as readdirSync2, readFileSync as readFileSync20, statSync as statSync4 } from "fs";
20682
- import { dirname as dirname20, extname as extname10, join as join30, resolve as resolve35 } from "path";
20683
- import ts7 from "typescript";
20684
- var ENTITY_DECORATORS, isAngularSourceFile = (file5) => file5.endsWith(".ts") || file5.endsWith(".tsx"), walkAngularSourceFiles = (root) => {
20685
- const out = [];
20686
- const visit = (dir) => {
20687
- let entries;
20688
- try {
20689
- entries = readdirSync2(dir, { withFileTypes: true });
20690
- } catch {
20691
- return;
20692
- }
20693
- for (const entry of entries) {
20694
- if (entry.name.startsWith(".") || entry.name === "node_modules") {
20695
- continue;
20696
- }
20697
- const full = join30(dir, entry.name);
20698
- if (entry.isDirectory()) {
20699
- visit(full);
20700
- } else if (entry.isFile() && isAngularSourceFile(entry.name)) {
20701
- out.push(full);
20702
- }
20703
- }
20704
- };
20705
- visit(root);
20706
- return out;
20707
- }, getStringPropertyValue = (obj, name) => {
20708
- for (const prop of obj.properties) {
20709
- if (!ts7.isPropertyAssignment(prop))
20710
- continue;
20711
- const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
20712
- if (propName !== name)
20713
- continue;
20714
- const init = prop.initializer;
20715
- if (ts7.isStringLiteral(init) || ts7.isNoSubstitutionTemplateLiteral(init)) {
20716
- return init.text;
20717
- }
20718
- }
20719
- return null;
20720
- }, getStringArrayProperty = (obj, name) => {
20721
- const out = [];
20722
- for (const prop of obj.properties) {
20723
- if (!ts7.isPropertyAssignment(prop))
20724
- continue;
20725
- const propName = ts7.isIdentifier(prop.name) ? prop.name.text : ts7.isStringLiteral(prop.name) ? prop.name.text : null;
20726
- if (propName !== name)
20727
- continue;
20728
- const init = prop.initializer;
20729
- if (!ts7.isArrayLiteralExpression(init))
20730
- continue;
20731
- for (const element of init.elements) {
20732
- if (ts7.isStringLiteral(element) || ts7.isNoSubstitutionTemplateLiteral(element)) {
20733
- out.push(element.text);
20734
- }
20735
- }
20736
- }
20737
- return out;
20738
- }, parseDecoratedClasses = (filePath) => {
20739
- let source;
20740
- try {
20741
- source = readFileSync20(filePath, "utf8");
20742
- } catch {
20743
- return [];
20744
- }
20745
- const sourceFile = ts7.createSourceFile(filePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
20746
- const out = [];
20747
- const visit = (node) => {
20748
- if (ts7.isClassDeclaration(node) && node.name) {
20749
- for (const decorator of ts7.getDecorators(node) ?? []) {
20750
- const expr = decorator.expression;
20751
- if (!ts7.isCallExpression(expr))
20752
- continue;
20753
- const fn2 = expr.expression;
20754
- if (!ts7.isIdentifier(fn2))
20755
- continue;
20756
- const kind = ENTITY_DECORATORS[fn2.text];
20757
- if (!kind)
20758
- continue;
20759
- let extendsName = null;
20760
- for (const heritage of node.heritageClauses ?? []) {
20761
- if (heritage.token !== ts7.SyntaxKind.ExtendsKeyword) {
20762
- continue;
20763
- }
20764
- const first = heritage.types[0];
20765
- if (first && ts7.isIdentifier(first.expression)) {
20766
- extendsName = first.expression.text;
20767
- }
20768
- break;
20769
- }
20770
- const entry = {
20771
- className: node.name.text,
20772
- kind,
20773
- styleUrls: [],
20774
- templateUrls: [],
20775
- extendsName
20776
- };
20777
- const arg = expr.arguments[0];
20778
- if (arg && ts7.isObjectLiteralExpression(arg) && kind === "component") {
20779
- const tplUrl = getStringPropertyValue(arg, "templateUrl");
20780
- if (tplUrl)
20781
- entry.templateUrls.push(tplUrl);
20782
- const styleUrl = getStringPropertyValue(arg, "styleUrl");
20783
- if (styleUrl)
20784
- entry.styleUrls.push(styleUrl);
20785
- entry.styleUrls.push(...getStringArrayProperty(arg, "styleUrls"));
20786
- }
20787
- out.push(entry);
20788
- break;
20789
- }
20790
- }
20791
- ts7.forEachChild(node, visit);
20792
- };
20793
- visit(sourceFile);
20794
- return out;
20795
- }, safeNormalize = (path) => resolve35(path).replace(/\\/g, "/"), resolveOwningComponents = (params) => {
20796
- const { changedFilePath, userAngularRoot } = params;
20797
- const changedAbs = safeNormalize(changedFilePath);
20798
- const out = [];
20799
- const ext = extname10(changedAbs).toLowerCase();
20800
- if (ext === ".ts" || ext === ".tsx") {
20801
- const classes = parseDecoratedClasses(changedAbs);
20802
- for (const cls of classes) {
20803
- out.push({
20804
- className: cls.className,
20805
- componentFilePath: changedAbs,
20806
- kind: cls.kind
20807
- });
20808
- }
20809
- return out;
20810
- }
20811
- if (ext !== ".html" && ext !== ".css" && ext !== ".scss" && ext !== ".sass") {
20812
- return out;
20813
- }
20814
- let rootStat;
20815
- try {
20816
- rootStat = statSync4(userAngularRoot);
20817
- } catch {
20818
- return out;
20819
- }
20820
- if (!rootStat.isDirectory())
20821
- return out;
20822
- const index = getOrBuildResourceIndex(userAngularRoot);
20823
- const owners = index.get(changedAbs);
20824
- if (owners) {
20825
- out.push(...owners);
20826
- }
20827
- return out;
20828
- }, indexByRoot, resolveParentClassFile = (parentName, childFilePath, angularRoot) => {
20829
- let source;
20830
- try {
20831
- source = readFileSync20(childFilePath, "utf8");
20832
- } catch {
20833
- return null;
20834
- }
20835
- const sf = ts7.createSourceFile(childFilePath, source, ts7.ScriptTarget.ES2022, true, ts7.ScriptKind.TS);
20836
- const childDir = dirname20(childFilePath);
20837
- for (const stmt of sf.statements) {
20838
- if (!ts7.isImportDeclaration(stmt))
20839
- continue;
20840
- if (!ts7.isStringLiteral(stmt.moduleSpecifier))
20841
- continue;
20842
- const clause = stmt.importClause;
20843
- if (!clause || clause.isTypeOnly)
20844
- continue;
20845
- let matchesName = false;
20846
- if (clause.name && clause.name.text === parentName)
20847
- matchesName = true;
20848
- if (!matchesName && clause.namedBindings && ts7.isNamedImports(clause.namedBindings)) {
20849
- for (const el of clause.namedBindings.elements) {
20850
- if (el.isTypeOnly)
20851
- continue;
20852
- if (el.name.text === parentName) {
20853
- matchesName = true;
20854
- break;
20855
- }
20856
- }
20857
- }
20858
- if (!matchesName)
20859
- continue;
20860
- const spec = stmt.moduleSpecifier.text;
20861
- if (!spec.startsWith(".") && !spec.startsWith("/")) {
20862
- return null;
20863
- }
20864
- const base = resolve35(childDir, spec);
20865
- const candidates = [
20866
- `${base}.ts`,
20867
- `${base}.tsx`,
20868
- `${base}/index.ts`,
20869
- `${base}/index.tsx`
20870
- ];
20871
- const angularRootNorm = safeNormalize(angularRoot);
20872
- for (const candidate of candidates) {
20873
- try {
20874
- if (statSync4(candidate).isFile()) {
20875
- const norm = safeNormalize(candidate);
20876
- if (!norm.startsWith(angularRootNorm))
20877
- return null;
20878
- return norm;
20879
- }
20880
- } catch {}
20881
- }
20882
- return null;
20883
- }
20884
- return null;
20885
- }, getOrBuildIndexes = (userAngularRoot) => {
20886
- const cached = indexByRoot.get(userAngularRoot);
20887
- if (cached)
20888
- return cached;
20889
- const resource = new Map;
20890
- const parentFile = new Map;
20891
- for (const tsPath of walkAngularSourceFiles(userAngularRoot)) {
20892
- const classes = parseDecoratedClasses(tsPath);
20893
- const componentDir = dirname20(tsPath);
20894
- for (const cls of classes) {
20895
- const entity = {
20896
- className: cls.className,
20897
- componentFilePath: tsPath,
20898
- kind: cls.kind
20899
- };
20900
- if (cls.kind === "component") {
20901
- for (const url of [...cls.templateUrls, ...cls.styleUrls]) {
20902
- const abs = safeNormalize(resolve35(componentDir, url));
20903
- const existing = resource.get(abs);
20904
- if (existing)
20905
- existing.push(entity);
20906
- else
20907
- resource.set(abs, [entity]);
20908
- }
20909
- }
20910
- if (cls.extendsName !== null) {
20911
- const parentPath = resolveParentClassFile(cls.extendsName, tsPath, userAngularRoot);
20912
- if (parentPath !== null && parentPath !== safeNormalize(tsPath)) {
20913
- const existing = parentFile.get(parentPath);
20914
- if (existing)
20915
- existing.push(entity);
20916
- else
20917
- parentFile.set(parentPath, [entity]);
20918
- }
20919
- }
20920
- }
20921
- }
20922
- const bundle = { parentFile, resource };
20923
- indexByRoot.set(userAngularRoot, bundle);
20924
- return bundle;
20925
- }, getOrBuildResourceIndex = (userAngularRoot) => getOrBuildIndexes(userAngularRoot).resource, resolveDescendantsOfParent = (params) => {
20926
- const norm = safeNormalize(params.changedFilePath);
20927
- let rootStat;
20928
- try {
20929
- rootStat = statSync4(params.userAngularRoot);
20930
- } catch {
20931
- return [];
20932
- }
20933
- if (!rootStat.isDirectory())
20934
- return [];
20935
- const bundle = getOrBuildIndexes(params.userAngularRoot);
20936
- return bundle.parentFile.get(norm) ?? [];
20937
- }, invalidateResourceIndex = () => {
20938
- indexByRoot.clear();
20939
- };
20940
- var init_resolveOwningComponents = __esm(() => {
20941
- ENTITY_DECORATORS = {
20942
- Component: "component",
20943
- Directive: "directive",
20944
- Pipe: "pipe",
20945
- Injectable: "service"
20946
- };
20947
- indexByRoot = new Map;
20948
- });
20949
-
20950
21053
  // src/dev/angular/hmrCompiler.ts
20951
21054
  var exports_hmrCompiler = {};
20952
21055
  __export(exports_hmrCompiler, {
@@ -21411,6 +21514,35 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21411
21514
  for (const importer of findStyleEntriesImporting(changedStylePath)) {
21412
21515
  enqueueImporter(state, importer);
21413
21516
  }
21517
+ enqueueAngularOwningComponentForStyle(state, changedStylePath);
21518
+ }, enqueueAngularOwningComponentForStyle = (state, changedStylePath) => {
21519
+ const angularDir = state.resolvedPaths.angularDir;
21520
+ if (!angularDir)
21521
+ return;
21522
+ const visited = new Set;
21523
+ const stack = [
21524
+ changedStylePath,
21525
+ ...findStyleEntriesImporting(changedStylePath)
21526
+ ];
21527
+ while (stack.length > 0) {
21528
+ const stylePath = stack.pop();
21529
+ if (!stylePath || visited.has(stylePath))
21530
+ continue;
21531
+ visited.add(stylePath);
21532
+ for (const upstream of findStyleEntriesImporting(stylePath)) {
21533
+ if (!visited.has(upstream))
21534
+ stack.push(upstream);
21535
+ }
21536
+ try {
21537
+ const owners = resolveOwningComponents({
21538
+ changedFilePath: stylePath,
21539
+ userAngularRoot: angularDir
21540
+ });
21541
+ for (const owner of owners) {
21542
+ enqueueImporter(state, owner.componentFilePath);
21543
+ }
21544
+ } catch {}
21545
+ }
21414
21546
  }, queueFileChange = async (state, filePath, config, onRebuildComplete) => {
21415
21547
  const framework = detectFramework(filePath, state.resolvedPaths);
21416
21548
  if (framework === "ignored") {
@@ -21643,6 +21775,17 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
21643
21775
  tier: 1
21644
21776
  };
21645
21777
  }
21778
+ if (owners.length === 0 && editedFile.endsWith(".ts") && !editedFile.endsWith(".d.ts")) {
21779
+ const normalized = editedFile.replace(/\\/g, "/");
21780
+ const angularDirAbs = resolve39(angularDir).replace(/\\/g, "/");
21781
+ if (normalized.startsWith(angularDirAbs + "/")) {
21782
+ return {
21783
+ kind: "rebootstrap",
21784
+ reason: `non-decorated angular file edited (${editedFile}) \u2014 consumers may hold stale resolved values`,
21785
+ tier: 1
21786
+ };
21787
+ }
21788
+ }
21646
21789
  for (const { componentFilePath, className, kind } of owners) {
21647
21790
  const id = encodeHmrComponentId2(componentFilePath, className);
21648
21791
  if (queueIds.has(id))
@@ -23034,6 +23177,7 @@ var init_rebuildTrigger = __esm(() => {
23034
23177
  init_telemetryEvent();
23035
23178
  init_assetStore();
23036
23179
  init_pathUtils();
23180
+ init_resolveOwningComponents();
23037
23181
  init_webSocket();
23038
23182
  init_stylePreprocessor();
23039
23183
  init_compileTailwind();
@@ -32307,5 +32451,5 @@ export {
32307
32451
  ANGULAR_INIT_TIMEOUT_MS
32308
32452
  };
32309
32453
 
32310
- //# debugId=15F2EB7340C15AAA64756E2164756E21
32454
+ //# debugId=6FEE58AB0632470164756E2164756E21
32311
32455
  //# sourceMappingURL=index.js.map