@absolutejs/absolute 0.19.0-beta.980 → 0.19.0-beta.982

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
@@ -12043,6 +12043,10 @@ var init_emitAngularRouteMounts = __esm(() => {
12043
12043
  });
12044
12044
 
12045
12045
  // src/build/parseAngularConfigImports.ts
12046
+ var exports_parseAngularConfigImports = {};
12047
+ __export(exports_parseAngularConfigImports, {
12048
+ parseAngularProvidersImport: () => parseAngularProvidersImport
12049
+ });
12046
12050
  import { existsSync as existsSync20, readFileSync as readFileSync14 } from "fs";
12047
12051
  import { dirname as dirname14, isAbsolute as isAbsolute3, join as join25 } from "path";
12048
12052
  import ts6 from "typescript";
@@ -15149,7 +15153,7 @@ export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
15149
15153
  }
15150
15154
  }
15151
15155
  return allOutputs;
15152
- }, compileAngular = async (entryPoints, outRoot, hmr = false, stylePreprocessors) => {
15156
+ }, compileAngular = async (entryPoints, outRoot, hmr = false, stylePreprocessors, providersInjection) => {
15153
15157
  const compiledParent = getFrameworkGeneratedDir("angular");
15154
15158
  if (entryPoints.length === 0) {
15155
15159
  const emptyPaths = [];
@@ -15264,25 +15268,40 @@ export default ${componentClassName};
15264
15268
  export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
15265
15269
  `;
15266
15270
  }
15267
- const providersServerPath = join30(compiledParent, "providers", `${toPascal(fileBase)}.providers.js`);
15268
- if (existsSync23(providersServerPath)) {
15269
- const rel = relative12(dirname18(rawServerFile), providersServerPath).replace(/\\/g, "/");
15270
- const specifier = rel.startsWith(".") ? rel : `./${rel}`;
15271
+ const pageInjection = providersInjection?.pagesByFile.get(resolvedEntry);
15272
+ if (providersInjection && pageInjection) {
15273
+ const compiledAppProvidersPath = (() => {
15274
+ const angularDirAbs = resolve25(outRoot);
15275
+ const appSourceAbs = resolve25(providersInjection.appProvidersSource);
15276
+ const rel = relative12(angularDirAbs, appSourceAbs).replace(/\\/g, "/");
15277
+ return join30(compiledParent, rel).replace(/\.[cm]?[tj]sx?$/, ".js");
15278
+ })();
15279
+ const appProvidersSpec = (() => {
15280
+ const rel = relative12(dirname18(rawServerFile), compiledAppProvidersPath).replace(/\\/g, "/");
15281
+ return rel.startsWith(".") ? rel : `./${rel}`;
15282
+ })();
15283
+ const importLines = [
15284
+ `import { appProviders as __abs_globalProviders } from "${appProvidersSpec}";`
15285
+ ];
15286
+ const fragments = ["...__abs_globalProviders"];
15287
+ if (pageInjection.hasRoutes) {
15288
+ importLines.push(`import { provideRouter as __abs_provideRouter, withComponentInputBinding as __abs_withComponentInputBinding, withViewTransitions as __abs_withViewTransitions } from "@angular/router";`);
15289
+ fragments.push("__abs_provideRouter(routes, __abs_withComponentInputBinding(), __abs_withViewTransitions())");
15290
+ }
15291
+ if (pageInjection.basePath !== null) {
15292
+ importLines.push(`import { APP_BASE_HREF as __abs_APP_BASE_HREF } from "@angular/common";`);
15293
+ fragments.push(`{ provide: __abs_APP_BASE_HREF, useValue: ${JSON.stringify(pageInjection.basePath)} }`);
15294
+ }
15271
15295
  rewritten += `
15272
- export { providers } from "${specifier}";
15296
+ ${importLines.join(`
15297
+ `)}
15298
+ export const providers = [${fragments.join(", ")}];
15273
15299
  `;
15274
15300
  }
15275
15301
  await traceAngularPhase("wrapper/write-server-output", () => fs5.writeFile(rawServerFile, rewritten, "utf-8"), { entry: resolvedEntry });
15276
15302
  const relativePath = relative12(indexesDir, rawServerFile).replace(/\\/g, "/");
15277
15303
  const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
15278
- const manifestKeyForProviders = toPascal(fileBase);
15279
- const providersServerFilePath = join30(compiledParent, "providers", `${manifestKeyForProviders}.providers.js`);
15280
- const hasGeneratedProviders = existsSync23(providersServerFilePath);
15281
- const providersImportPath = hasGeneratedProviders ? (() => {
15282
- const rel = relative12(indexesDir, providersServerFilePath.replace(/\.js$/, "")).replace(/\\/g, "/");
15283
- return rel.startsWith(".") ? rel : `./${rel}`;
15284
- })() : null;
15285
- const generatedProvidersImport = providersImportPath ? `import { providers as generatedProviders } from '${providersImportPath}';` : "var generatedProviders = null;";
15304
+ const generatedProvidersImport = "var generatedProviders = null;";
15286
15305
  const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
15287
15306
  import "${hmrClientPath5}";
15288
15307
  ` : "";
@@ -20345,12 +20364,42 @@ ${content.slice(firstUseIdx)}`;
20345
20364
  const shouldCompileIslandSvelte = svelteDir && islandSvelteSources.length > 0;
20346
20365
  const shouldCompileIslandVue = vueDir && islandVueSources.length > 0;
20347
20366
  const shouldCompileIslandAngular = angularDir && islandAngularSources.length > 0;
20348
- let angularProvidersFilesToCompile = [];
20367
+ let angularProvidersInjection = undefined;
20368
+ let angularAppProvidersSource = undefined;
20349
20369
  if (shouldCompileAngular && angularDir) {
20350
20370
  await tracePhase("scan/angular-handlers", async () => {
20351
20371
  const { runAngularHandlerScan: runAngularHandlerScan2 } = await Promise.resolve().then(() => (init_runAngularHandlerScan(), exports_runAngularHandlerScan));
20372
+ const { parseAngularProvidersImport: parseAngularProvidersImport2 } = await Promise.resolve().then(() => (init_parseAngularConfigImports(), exports_parseAngularConfigImports));
20352
20373
  const scanResult = runAngularHandlerScan2(projectRoot, angularDir);
20353
- angularProvidersFilesToCompile = scanResult.providersFiles.map((file5) => file5.outputPath);
20374
+ const providersImport = parseAngularProvidersImport2(projectRoot);
20375
+ if (providersImport) {
20376
+ angularAppProvidersSource = providersImport.absolutePath;
20377
+ const pagesByFile = new Map;
20378
+ const basePathByKey = new Map;
20379
+ for (const call of scanResult.calls) {
20380
+ basePathByKey.set(call.manifestKey, call.mountPath?.endsWith("/*") ? call.mountPath.slice(0, -1) : null);
20381
+ }
20382
+ for (const route of scanResult.pageRoutes) {
20383
+ const basePath = basePathByKey.get(route.manifestKey) ?? null;
20384
+ const normalizedBase = basePath === "/" ? null : basePath;
20385
+ pagesByFile.set(route.pageFile, {
20386
+ basePath: normalizedBase,
20387
+ hasRoutes: route.hasRoutes
20388
+ });
20389
+ }
20390
+ for (const route of scanResult.pageRoutes) {
20391
+ if (pagesByFile.has(route.pageFile))
20392
+ continue;
20393
+ pagesByFile.set(route.pageFile, {
20394
+ basePath: null,
20395
+ hasRoutes: route.hasRoutes
20396
+ });
20397
+ }
20398
+ angularProvidersInjection = {
20399
+ appProvidersSource: providersImport.absolutePath,
20400
+ pagesByFile
20401
+ };
20402
+ }
20354
20403
  });
20355
20404
  }
20356
20405
  const [
@@ -20375,12 +20424,12 @@ ${content.slice(firstUseIdx)}`;
20375
20424
  },
20376
20425
  shouldCompileAngular ? tracePhase("compile/angular", async () => {
20377
20426
  const mod = await Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular));
20378
- if (angularProvidersFilesToCompile.length > 0 && angularDir) {
20427
+ if (angularAppProvidersSource && angularDir) {
20379
20428
  const { getFrameworkGeneratedDir: getFrameworkGeneratedDir2 } = await Promise.resolve().then(() => (init_generatedDir(), exports_generatedDir));
20380
20429
  const compiledRoot = getFrameworkGeneratedDir2("angular", projectRoot);
20381
- await Promise.all(angularProvidersFilesToCompile.map((entry) => mod.compileAngularFileJIT(entry, compiledRoot, angularDir, styleTransformConfig)));
20430
+ await mod.compileAngularFileJIT(angularAppProvidersSource, compiledRoot, angularDir, styleTransformConfig);
20382
20431
  }
20383
- const result = await mod.compileAngular(angularEntries, angularDir, hmr, styleTransformConfig);
20432
+ const result = await mod.compileAngular(angularEntries, angularDir, hmr, styleTransformConfig, angularProvidersInjection);
20384
20433
  if (hmr) {
20385
20434
  try {
20386
20435
  const { primeComponentFingerprint: primeComponentFingerprint2 } = await Promise.resolve().then(() => (init_fastHmrCompiler(), exports_fastHmrCompiler));
@@ -35645,5 +35694,5 @@ export {
35645
35694
  ANGULAR_INIT_TIMEOUT_MS
35646
35695
  };
35647
35696
 
35648
- //# debugId=D3E1DAEC8C4DD35264756E2164756E21
35697
+ //# debugId=76639FC616A4AF9764756E2164756E21
35649
35698
  //# sourceMappingURL=index.js.map