@absolutejs/absolute 0.20.0-beta.180 → 0.20.0-beta.181

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/changelog.json +16 -0
  3. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  4. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  5. package/dist/angular/index.js +6 -1
  6. package/dist/angular/index.js.map +3 -3
  7. package/dist/angular/server.js +6 -1
  8. package/dist/angular/server.js.map +3 -3
  9. package/dist/build.js +175 -37
  10. package/dist/build.js.map +7 -7
  11. package/dist/cli/{build-fntmf42w.js → build-ptx5a72p.js} +3 -3
  12. package/dist/cli/{buildReactServerComponents-fq6mw10d.js → buildReactServerComponents-01s87hnk.js} +1 -1
  13. package/dist/cli/{index-w79snsxv.js → index-5w8arh3m.js} +1 -1
  14. package/dist/cli/{index-xf9sfr8a.js → index-fgqh48qr.js} +63 -1
  15. package/dist/cli/{index-x1vvn549.js → index-jkg2h10c.js} +2 -2
  16. package/dist/cli/index.js +1 -1
  17. package/dist/cli/{staticAnalyzeSpaRoutes-2nev05m1.js → staticAnalyzeSpaRoutes-rcc1d3az.js} +3 -1
  18. package/dist/cli/{typecheck-488txsfc.js → typecheck-ynzw2eep.js} +36 -22
  19. package/dist/index.js +175 -37
  20. package/dist/index.js.map +7 -7
  21. package/dist/react/index.js +6 -1
  22. package/dist/react/index.js.map +3 -3
  23. package/dist/react/server.js +6 -1
  24. package/dist/react/server.js.map +3 -3
  25. package/dist/src/angular/staticAnalyzeSpaRoutes.d.ts +9 -0
  26. package/dist/src/cli/scripts/typecheck.d.ts +7 -0
  27. package/dist/src/dev/spaRouteRefresh.d.ts +12 -5
  28. package/dist/src/utils/spaRouteManifest.d.ts +2 -0
  29. package/dist/svelte/components/Image.svelte +1 -1
  30. package/dist/svelte/components/Island.svelte +1 -1
  31. package/dist/svelte/index.js +6 -1
  32. package/dist/svelte/index.js.map +3 -3
  33. package/dist/svelte/router/Router.svelte.d.ts +31 -1
  34. package/dist/svelte/server.js +6 -1
  35. package/dist/svelte/server.js.map +3 -3
  36. package/dist/vue/index.js +6 -1
  37. package/dist/vue/index.js.map +3 -3
  38. package/dist/vue/server.js +6 -1
  39. package/dist/vue/server.js.map +3 -3
  40. package/package.json +4 -1
package/dist/build.js CHANGED
@@ -7385,6 +7385,8 @@ var init_devRouteRegistrationCallsite = __esm(() => {
7385
7385
  // src/angular/staticAnalyzeSpaRoutes.ts
7386
7386
  var exports_staticAnalyzeSpaRoutes = {};
7387
7387
  __export(exports_staticAnalyzeSpaRoutes, {
7388
+ analyzeAngularColocatedRouteFile: () => analyzeAngularColocatedRouteFile,
7389
+ analyzeAngularColocatedRoutes: () => analyzeAngularColocatedRoutes,
7388
7390
  analyzeAngularSpaRouteFile: () => analyzeAngularSpaRouteFile,
7389
7391
  analyzeAngularSpaRoutes: () => analyzeAngularSpaRoutes
7390
7392
  });
@@ -7572,6 +7574,47 @@ var DYNAMIC_SEGMENT_PATTERN, pathHasDynamic = (path) => path.split("/").some((se
7572
7574
  routes,
7573
7575
  sourceFile: filePath
7574
7576
  };
7577
+ }, unwrapExpression = (expression) => {
7578
+ if (lazyTypescript.isAsExpression(expression) || lazyTypescript.isSatisfiesExpression(expression) || lazyTypescript.isParenthesizedExpression(expression))
7579
+ return unwrapExpression(expression.expression);
7580
+ return expression;
7581
+ }, findColocatedRoutesArray = (sourceFile) => {
7582
+ for (const statement of sourceFile.statements) {
7583
+ if (!lazyTypescript.isVariableStatement(statement))
7584
+ continue;
7585
+ const exported = statement.modifiers?.some((modifier) => modifier.kind === lazyTypescript.SyntaxKind.ExportKeyword);
7586
+ if (!exported)
7587
+ continue;
7588
+ for (const declaration of statement.declarationList.declarations) {
7589
+ if (!lazyTypescript.isIdentifier(declaration.name))
7590
+ continue;
7591
+ if (declaration.name.text !== "routes")
7592
+ continue;
7593
+ if (!declaration.initializer)
7594
+ continue;
7595
+ const initializer = unwrapExpression(declaration.initializer);
7596
+ if (lazyTypescript.isArrayLiteralExpression(initializer))
7597
+ return initializer;
7598
+ }
7599
+ }
7600
+ return null;
7601
+ }, COLOCATED_ROUTES_EXPORT, analyzeAngularColocatedRouteFile = async (filePath) => {
7602
+ let source;
7603
+ try {
7604
+ source = await fs.readFile(filePath, "utf-8");
7605
+ } catch {
7606
+ return null;
7607
+ }
7608
+ if (!COLOCATED_ROUTES_EXPORT.test(source))
7609
+ return null;
7610
+ const sourceFile = lazyTypescript.createSourceFile(filePath, source, lazyTypescript.ScriptTarget.Latest, true, lazyTypescript.ScriptKind.TS);
7611
+ const routesArray = findColocatedRoutesArray(sourceFile);
7612
+ if (!routesArray)
7613
+ return null;
7614
+ const routes = [];
7615
+ extractRoutePaths(routesArray, "", false, routes);
7616
+ const host = { baseHref: "/", routes, sourceFile: filePath };
7617
+ return host;
7575
7618
  }, walkTsFiles = async (dir, files) => {
7576
7619
  let items;
7577
7620
  try {
@@ -7593,6 +7636,22 @@ var DYNAMIC_SEGMENT_PATTERN, pathHasDynamic = (path) => path.split("/").some((se
7593
7636
  }
7594
7637
  }
7595
7638
  await Promise.all(directories.map((directory) => walkTsFiles(directory, files)));
7639
+ }, analyzeAngularColocatedRoutes = async (angularDirectory) => {
7640
+ if (!existsSync16(angularDirectory))
7641
+ return [];
7642
+ const tsFiles = [];
7643
+ await walkTsFiles(angularDirectory, tsFiles);
7644
+ const pages = [];
7645
+ await Promise.all(tsFiles.map(async (file) => {
7646
+ try {
7647
+ if (await analyzeAngularSpaRouteFile(file))
7648
+ return;
7649
+ const page = await analyzeAngularColocatedRouteFile(file);
7650
+ if (page)
7651
+ pages.push(page);
7652
+ } catch {}
7653
+ }));
7654
+ return pages;
7596
7655
  }, analyzeAngularSpaRoutes = async (angularDirectory) => {
7597
7656
  if (!existsSync16(angularDirectory))
7598
7657
  return [];
@@ -7613,6 +7672,7 @@ var DYNAMIC_SEGMENT_PATTERN, pathHasDynamic = (path) => path.split("/").some((se
7613
7672
  var init_staticAnalyzeSpaRoutes = __esm(() => {
7614
7673
  init_lazyTypescript();
7615
7674
  DYNAMIC_SEGMENT_PATTERN = /^[:*]/;
7675
+ COLOCATED_ROUTES_EXPORT = /\bexport\s+(?:const|let|var)\s+routes\b/;
7616
7676
  });
7617
7677
 
7618
7678
  // src/react/staticAnalyzeSpaRoutes.ts
@@ -15892,6 +15952,11 @@ var SPA_ROUTES_KEY = "__absoluteSpaRoutes", setSpaRouteManifest = (hosts) => {
15892
15952
  }, isRuntimeSpaHost = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "framework") === "string", getSpaRouteManifest = () => {
15893
15953
  const value = Reflect.get(globalThis, SPA_ROUTES_KEY);
15894
15954
  return Array.isArray(value) ? value.filter(isRuntimeSpaHost) : [];
15955
+ }, OBSERVED_SPA_ROUTES_KEY = "__absoluteObservedSpaRoutes", getObservedSpaRoutes = () => {
15956
+ const value = Reflect.get(globalThis, OBSERVED_SPA_ROUTES_KEY);
15957
+ return Array.isArray(value) ? value.filter(isRuntimeSpaHost) : [];
15958
+ }, setObservedSpaRoutes = (hosts) => {
15959
+ Reflect.set(globalThis, OBSERVED_SPA_ROUTES_KEY, hosts);
15895
15960
  }, normalizePath2 = (path) => {
15896
15961
  const withLeadingSlash = path.startsWith("/") ? path : `/${path}`;
15897
15962
  const trimmed = withLeadingSlash.replace(/\/+$/, "");
@@ -19899,13 +19964,13 @@ var SKIP_DIRS2, SOURCE_EXTENSIONS3, getScriptKind3 = (filePath) => {
19899
19964
  return name.text;
19900
19965
  }
19901
19966
  return null;
19902
- }, unwrapExpression = (node) => {
19967
+ }, unwrapExpression2 = (node) => {
19903
19968
  if (lazyTypescript.isAsExpression(node) || lazyTypescript.isSatisfiesExpression(node) || lazyTypescript.isParenthesizedExpression(node) || lazyTypescript.isTypeAssertionExpression(node)) {
19904
- return unwrapExpression(node.expression);
19969
+ return unwrapExpression2(node.expression);
19905
19970
  }
19906
19971
  return node;
19907
19972
  }, readLiteral = (node) => {
19908
- const inner = unwrapExpression(node);
19973
+ const inner = unwrapExpression2(node);
19909
19974
  if (lazyTypescript.isStringLiteral(inner) || lazyTypescript.isNoSubstitutionTemplateLiteral(inner)) {
19910
19975
  return inner.text;
19911
19976
  }
@@ -19924,7 +19989,7 @@ var SKIP_DIRS2, SOURCE_EXTENSIONS3, getScriptKind3 = (filePath) => {
19924
19989
  lazyTypescript.forEachChild(sourceFile, visit);
19925
19990
  return constants;
19926
19991
  }, readStringValue = (node, constants) => {
19927
- const inner = unwrapExpression(node);
19992
+ const inner = unwrapExpression2(node);
19928
19993
  if (lazyTypescript.isIdentifier(inner))
19929
19994
  return constants.get(inner.text) ?? null;
19930
19995
  return readLiteral(inner);
@@ -27998,6 +28063,11 @@ ${offenders.map((o) => ` \u2022 ${o}`).join(`
27998
28063
  }))
27999
28064
  ];
28000
28065
  setSpaRouteManifest(spaRouteHosts);
28066
+ const observedAngularHosts = isDev && angularDir ? await Promise.resolve().then(() => (init_staticAnalyzeSpaRoutes(), {})).then((module) => analyzeAngularColocatedRoutes(angularDir)) : [];
28067
+ setObservedSpaRoutes(observedAngularHosts.map((host) => ({
28068
+ ...host,
28069
+ framework: "angular"
28070
+ })));
28001
28071
  writeFileSync14(join57(buildPath, "spa-routes.json"), JSON.stringify(spaRouteHosts, null, "\t"));
28002
28072
  if (isIncremental) {
28003
28073
  writeBuildTrace(buildPath);
@@ -30245,10 +30315,15 @@ var normalizePath3 = (path) => resolve56(path).replace(/\\/g, "/"), owningFramew
30245
30315
  default:
30246
30316
  return null;
30247
30317
  }
30318
+ }, analyzeObservedFile = async (framework, file) => {
30319
+ if (framework !== "angular")
30320
+ return null;
30321
+ return (await Promise.resolve().then(() => (init_staticAnalyzeSpaRoutes(), exports_staticAnalyzeSpaRoutes))).analyzeAngularColocatedRouteFile(file);
30248
30322
  }, readHost = async (framework, file) => {
30249
30323
  try {
30250
30324
  const host = await analyzeFile(framework, file);
30251
- return { host };
30325
+ const observed = host ? null : await analyzeObservedFile(framework, file);
30326
+ return { host, observed };
30252
30327
  } catch (error) {
30253
30328
  logWarn(`Could not re-read SPA routes from ${file}: ${error instanceof Error ? error.message : String(error)}`);
30254
30329
  return null;
@@ -30260,43 +30335,73 @@ var normalizePath3 = (path) => resolve56(path).replace(/\\/g, "/"), owningFramew
30260
30335
  added: [...afterPaths].filter((path) => !beforePaths.has(path)),
30261
30336
  removed: [...beforePaths].filter((path) => !afterPaths.has(path))
30262
30337
  };
30263
- }, refreshSpaRoutesForFiles = async (files, paths) => {
30338
+ }, findHost = (hosts, framework, file) => hosts.find((host) => host.framework === framework && normalizePath3(host.sourceFile) === file), replaceHost = (hosts, change, next) => {
30339
+ const previous = findHost(hosts, change.framework, change.file);
30340
+ return [
30341
+ ...hosts.filter((host) => host !== previous),
30342
+ ...next ? [{ ...next, framework: change.framework }] : []
30343
+ ];
30344
+ }, writeRouteTable = async (hosts, paths) => {
30345
+ setSpaRouteManifest(hosts);
30346
+ try {
30347
+ await writeFile14(join63(paths.buildDir, "spa-routes.json"), JSON.stringify(hosts, null, "\t"));
30348
+ } catch {}
30349
+ }, publishRouteChanges = async (pending, paths) => {
30350
+ if (pending.length === 0)
30351
+ return;
30352
+ let hosts = getSpaRouteManifest();
30353
+ let observed = getObservedSpaRoutes();
30354
+ let enforcedChanged = false;
30355
+ for (const change of pending) {
30356
+ const previous = findHost(hosts, change.framework, change.file);
30357
+ if (hostSignature(previous) !== hostSignature(change.next))
30358
+ enforcedChanged = true;
30359
+ hosts = replaceHost(hosts, change, change.next);
30360
+ observed = replaceHost(observed, change, change.nextObserved);
30361
+ }
30362
+ setObservedSpaRoutes(observed);
30363
+ if (enforcedChanged)
30364
+ await writeRouteTable(hosts, paths);
30365
+ for (const change of pending) {
30366
+ logRoutesUpdate(change.file, change.framework, change.added, change.removed);
30367
+ }
30368
+ }, readSpaRouteChanges = async (files, paths) => {
30264
30369
  const candidates = [...new Set(files.map(normalizePath3))].flatMap((file) => {
30265
30370
  const framework = owningFramework(file, paths);
30266
30371
  return framework ? [{ file, framework }] : [];
30267
30372
  });
30268
- if (candidates.length === 0)
30269
- return [];
30270
- let hosts = getSpaRouteManifest();
30271
- const changes = [];
30373
+ const hosts = getSpaRouteManifest();
30374
+ const observed = getObservedSpaRoutes();
30375
+ const pending = [];
30272
30376
  await Promise.all(candidates.map(async ({ file, framework }) => {
30273
30377
  const read = await readHost(framework, file);
30274
30378
  if (!read)
30275
30379
  return;
30276
- const next = read.host;
30277
- const previous = hosts.find((host) => host.framework === framework && normalizePath3(host.sourceFile) === file);
30278
- if (hostSignature(previous) === hostSignature(next ?? undefined))
30380
+ const previous = findHost(hosts, framework, file);
30381
+ const previousObserved = findHost(observed, framework, file);
30382
+ if (hostSignature(previous) === hostSignature(read.host) && hostSignature(previousObserved) === hostSignature(read.observed))
30279
30383
  return;
30280
- hosts = [
30281
- ...hosts.filter((host) => host !== previous),
30282
- ...next ? [{ ...next, framework }] : []
30283
- ];
30284
- changes.push({
30384
+ pending.push({
30285
30385
  file,
30286
30386
  framework,
30287
- ...diffRoutes(previous, next ?? undefined)
30387
+ next: read.host,
30388
+ nextObserved: read.observed,
30389
+ ...diffRoutes(previous ?? previousObserved, read.host ?? read.observed)
30288
30390
  });
30289
30391
  }));
30290
- if (changes.length === 0)
30291
- return changes;
30292
- setSpaRouteManifest(hosts);
30293
- try {
30294
- await writeFile14(join63(paths.buildDir, "spa-routes.json"), JSON.stringify(hosts, null, "\t"));
30295
- } catch {}
30296
- for (const change of changes) {
30297
- logRoutesUpdate(change.file, change.framework, change.added, change.removed);
30298
- }
30299
- return changes;
30392
+ const changes = pending.map(({ added, file, framework, removed }) => ({
30393
+ added,
30394
+ file,
30395
+ framework,
30396
+ removed
30397
+ }));
30398
+ const publish = async (frameworks) => {
30399
+ const batch = pending.filter((change) => !frameworks || frameworks.includes(change.framework));
30400
+ for (const change of batch)
30401
+ pending.splice(pending.indexOf(change), 1);
30402
+ await publishRouteChanges(batch, paths);
30403
+ };
30404
+ return { changes, publish };
30300
30405
  };
30301
30406
  var init_spaRouteRefresh = __esm(() => {
30302
30407
  init_logger();
@@ -40286,16 +40391,21 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, clearDevSs
40286
40391
  ctx.inFlight = drive();
40287
40392
  ctx.inFlight.then(resolveFn, resolveFn);
40288
40393
  };
40289
- return () => {
40394
+ return ({ immediate = false } = {}) => {
40290
40395
  if (!ctx.debouncedPromise) {
40291
40396
  ctx.debouncedPromise = new Promise((resolve) => {
40292
40397
  ctx.debouncedResolve = resolve;
40293
40398
  });
40294
40399
  }
40400
+ const scheduled = ctx.debouncedPromise;
40295
40401
  if (ctx.debounceTimer)
40296
40402
  clearTimeout(ctx.debounceTimer);
40297
- ctx.debounceTimer = setTimeout(fire, SVELTE_BUNDLE_DEBOUNCE_MS);
40298
- return ctx.debouncedPromise;
40403
+ ctx.debounceTimer = null;
40404
+ if (immediate)
40405
+ fire();
40406
+ else
40407
+ ctx.debounceTimer = setTimeout(fire, SVELTE_BUNDLE_DEBOUNCE_MS);
40408
+ return scheduled;
40299
40409
  };
40300
40410
  }, handleSvelteFastPath = async (state, config, filesToRebuild, startTime, onRebuildComplete) => {
40301
40411
  const svelteDir = config.svelteDirectory ?? "";
@@ -40570,16 +40680,21 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, clearDevSs
40570
40680
  ctx.inFlight = drive();
40571
40681
  ctx.inFlight.then(resolveFn, resolveFn);
40572
40682
  };
40573
- return () => {
40683
+ return ({ immediate = false } = {}) => {
40574
40684
  if (!ctx.debouncedPromise) {
40575
40685
  ctx.debouncedPromise = new Promise((resolve) => {
40576
40686
  ctx.debouncedResolve = resolve;
40577
40687
  });
40578
40688
  }
40689
+ const scheduled = ctx.debouncedPromise;
40579
40690
  if (ctx.debounceTimer)
40580
40691
  clearTimeout(ctx.debounceTimer);
40581
- ctx.debounceTimer = setTimeout(fire, VUE_BUNDLE_DEBOUNCE_MS);
40582
- return ctx.debouncedPromise;
40692
+ ctx.debounceTimer = null;
40693
+ if (immediate)
40694
+ fire();
40695
+ else
40696
+ ctx.debounceTimer = setTimeout(fire, VUE_BUNDLE_DEBOUNCE_MS);
40697
+ return scheduled;
40583
40698
  };
40584
40699
  }, handleVueFastPath = async (state, config, filesToRebuild, startTime, onRebuildComplete) => {
40585
40700
  const vueFiles = filesToRebuild.filter((file) => file.endsWith(".vue") && detectFramework(file, state.resolvedPaths) === "vue");
@@ -41309,9 +41424,29 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, clearDevSs
41309
41424
  await processMarkupFiles(markupFiles);
41310
41425
  }, runHtmlFastPath = async (state, config, filesToRebuild, startTime) => runMarkupFastPath(state, config, filesToRebuild, startTime, "html"), runHtmxFastPath = async (state, config, filesToRebuild, startTime) => runMarkupFastPath(state, config, filesToRebuild, startTime, "htmx"), markHandledFiles = (files, framework, resolvedPaths, handled) => {
41311
41426
  files.filter((f) => detectFramework(f, resolvedPaths) === framework).forEach((f) => handled.add(f));
41427
+ }, rebuildSsrForRouteChanges = async (state, config, changes) => {
41428
+ const changedFiles = (framework) => changes.filter((change) => change.framework === framework).map((change) => change.file);
41429
+ const vueFiles = changedFiles("vue");
41430
+ const svelteFiles = changedFiles("svelte");
41431
+ await Promise.all([
41432
+ vueFiles.length > 0 && config.vueDirectory ? scheduleVueBundleRebuild(state, vueFiles, config)({ immediate: true }) : undefined,
41433
+ svelteFiles.length > 0 && config.svelteDirectory ? scheduleSvelteBundleRebuild(state, svelteFiles, config)({ immediate: true }) : undefined
41434
+ ]);
41435
+ }, flushAngularBundleRebuild = async (state) => {
41436
+ const ctx = angularBundleState.get(state);
41437
+ if (!ctx)
41438
+ return;
41439
+ if (ctx.debounceTimer) {
41440
+ await scheduleAngularBundleRebuild(state, ctx.pageEntries, ctx.angularDir)({ immediate: true });
41441
+ return;
41442
+ }
41443
+ if (ctx.inFlight)
41444
+ await ctx.inFlight;
41312
41445
  }, runFrameworkFastPaths = async (state, config, affectedFrameworks, files, startTime, onRebuildComplete) => {
41313
41446
  const handled = new Set;
41314
- await refreshSpaRoutesForFiles(files, state.resolvedPaths);
41447
+ const routeChanges = await readSpaRouteChanges(files, state.resolvedPaths);
41448
+ await rebuildSsrForRouteChanges(state, config, routeChanges.changes);
41449
+ await routeChanges.publish(["react", "svelte", "vue"]);
41315
41450
  const fastPaths = [
41316
41451
  {
41317
41452
  directory: config.angularDirectory,
@@ -41345,6 +41480,9 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, clearDevSs
41345
41480
  await fastPath.handler(state, config, files, startTime, onRebuildComplete);
41346
41481
  markHandledFiles(files, fastPath.framework, state.resolvedPaths, handled);
41347
41482
  });
41483
+ if (routeChanges.changes.some((change) => change.framework === "angular"))
41484
+ await flushAngularBundleRebuild(state);
41485
+ await routeChanges.publish();
41348
41486
  for (const file of files) {
41349
41487
  if (!handled.has(file) && detectFramework(file, state.resolvedPaths) === "unknown" && !state.lastUserEditedFiles?.has(resolvePath4(file)))
41350
41488
  handled.add(file);
@@ -42649,5 +42787,5 @@ export {
42649
42787
  devBuild
42650
42788
  };
42651
42789
 
42652
- //# debugId=49F451E82229DDB964756E2164756E21
42790
+ //# debugId=09C80D2AE135A40164756E2164756E21
42653
42791
  //# sourceMappingURL=build.js.map