@absolutejs/absolute 0.20.0-beta.177 → 0.20.0-beta.179

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 (88) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/changelog.json +72 -0
  3. package/dist/angular/browser.js +17 -2
  4. package/dist/angular/browser.js.map +4 -4
  5. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  6. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  7. package/dist/angular/index.js +100 -54
  8. package/dist/angular/index.js.map +10 -9
  9. package/dist/angular/server.js +100 -54
  10. package/dist/angular/server.js.map +10 -9
  11. package/dist/build/buildWorker.js +6 -5
  12. package/dist/build.js +595 -454
  13. package/dist/build.js.map +20 -20
  14. package/dist/cli/{add-ntg96znk.js → add-8gw9mk2b.js} +1 -1
  15. package/dist/cli/{compile-w2z6c9vt.js → compile-p5yv6ecp.js} +2 -2
  16. package/dist/cli/config/server.js +45 -12
  17. package/dist/cli/{dev-8br5mr7t.js → dev-2hbcsvkp.js} +1 -1
  18. package/dist/cli/{index-420h9hq7.js → index-1ewba8ye.js} +32 -3
  19. package/dist/cli/index-5q6k5mvr.js +86 -0
  20. package/dist/cli/{index-7z1hh3fg.js → index-9dzdbbfc.js} +1 -1
  21. package/dist/cli/index.js +9 -9
  22. package/dist/cli/{islands-bx67g15t.js → islands-6zgb7501.js} +1 -1
  23. package/dist/cli/{mobile-we5q51ey.js → mobile-93vaawcz.js} +3 -3
  24. package/dist/cli/{remove-4jh862qa.js → remove-x987pvd3.js} +1 -1
  25. package/dist/cli/{start-srs11bm8.js → start-asxb79rc.js} +2 -2
  26. package/dist/cli/{typecheck-7fvww3b7.js → typecheck-m2j4tkdk.js} +165 -35
  27. package/dist/client/chunks/{index-8m2qq61n.js → index-58svs66p.js} +13 -3
  28. package/dist/client/chunks/{index-8m2qq61n.js.map → index-58svs66p.js.map} +5 -4
  29. package/dist/client/chunks/{islands-mfjmdwnb.js → islands-tcadmgcx.js} +3 -6
  30. package/dist/client/chunks/{islands-mfjmdwnb.js.map → islands-tcadmgcx.js.map} +3 -4
  31. package/dist/client/chunks/{react-sprprqzs.js → react-khr6ewhr.js} +2 -2
  32. package/dist/client/index.js +82 -6
  33. package/dist/client/index.js.map +7 -6
  34. package/dist/dev/client/handlers/islands.ts +2 -0
  35. package/dist/dev/client/handlers/react.ts +92 -111
  36. package/dist/dev/client/handlers/reactUpdateQueue.ts +153 -0
  37. package/dist/index.js +568 -427
  38. package/dist/index.js.map +20 -20
  39. package/dist/islands/browser.js +2 -2
  40. package/dist/islands/browser.js.map +3 -3
  41. package/dist/islands/index.js +56 -27
  42. package/dist/islands/index.js.map +7 -6
  43. package/dist/react/browser.js +113 -12
  44. package/dist/react/browser.js.map +10 -7
  45. package/dist/react/components/index.js +31 -7
  46. package/dist/react/components/index.js.map +5 -4
  47. package/dist/react/components/server/index.js +22 -6
  48. package/dist/react/index.js +233 -67
  49. package/dist/react/index.js.map +16 -12
  50. package/dist/react/server.js +82 -23
  51. package/dist/react/server.js.map +11 -9
  52. package/dist/src/build/compileSvelte.d.ts +12 -1
  53. package/dist/src/build/compileVue.d.ts +1 -0
  54. package/dist/src/build/islandEntries.d.ts +3 -1
  55. package/dist/src/cli/add/dependencies.d.ts +34 -6
  56. package/dist/src/cli/scripts/typecheck.d.ts +8 -0
  57. package/dist/src/cli/scripts/typecheckDiagnostics.d.ts +17 -0
  58. package/dist/src/client/preserveIslandMarkup.d.ts +4 -0
  59. package/dist/src/core/islandManifest.d.ts +6 -0
  60. package/dist/src/core/islandStylesheet.d.ts +17 -0
  61. package/dist/src/react/Island.d.ts +9 -2
  62. package/dist/src/react/IslandStyleLink.d.ts +11 -0
  63. package/dist/src/react/createIsland.d.ts +1 -1
  64. package/dist/src/react/serverComponents/nodeRendererRef.d.ts +13 -0
  65. package/dist/src/utils/requestRenderUrl.d.ts +1 -0
  66. package/dist/src/utils/resolveConvention.d.ts +1 -0
  67. package/dist/src/vue/Island.browser.d.ts +3 -1
  68. package/dist/src/vue/Island.d.ts +2 -2
  69. package/dist/src/vue/createIsland.browser.d.ts +2 -2
  70. package/dist/src/vue/createIsland.d.ts +2 -2
  71. package/dist/src/vue/islandStyleLink.d.ts +30 -0
  72. package/dist/svelte/browser.js +2 -2
  73. package/dist/svelte/browser.js.map +3 -3
  74. package/dist/svelte/index.js +94 -70
  75. package/dist/svelte/index.js.map +10 -9
  76. package/dist/svelte/server.js +65 -59
  77. package/dist/svelte/server.js.map +9 -8
  78. package/dist/types/globals.d.ts +3 -0
  79. package/dist/vue/browser.js +105 -10
  80. package/dist/vue/browser.js.map +10 -7
  81. package/dist/vue/index.js +213 -68
  82. package/dist/vue/index.js.map +15 -12
  83. package/dist/vue/server.js +81 -22
  84. package/dist/vue/server.js.map +9 -7
  85. package/package.json +1 -1
  86. package/dist/cli/index-jjfbjv1z.js +0 -65
  87. /package/dist/cli/{index-6522t968.js → index-yd672jyq.js} +0 -0
  88. /package/dist/client/chunks/{react-sprprqzs.js.map → react-khr6ewhr.js.map} +0 -0
@@ -1176,7 +1176,7 @@ import { basename, dirname as dirname2, extname as extname2, join as join3, rela
1176
1176
  var serverCacheRoot, compiledModuleCache, originalSourcePathCache, syncIslandGeneration, transpiler, ensureRelativeImportPath = (from, target) => {
1177
1177
  const importPath = relative2(dirname2(from), target).replace(/\\/g, "/");
1178
1178
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
1179
- }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
1179
+ }, escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), replaceQuotedSpecifier = (code, spec, target) => code.replace(new RegExp(`(['"])${escapeRegExp(spec)}\\1`, "g"), (_match, quote) => `${quote}${target}${quote}`), processDirectoryEntries = (entries, dir, targetFileName, stack) => {
1180
1180
  for (const entry of entries) {
1181
1181
  const entryPath = join3(dir, entry.name);
1182
1182
  if (entry.isDirectory())
@@ -1221,18 +1221,21 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, syncIslandGen
1221
1221
  return null;
1222
1222
  }
1223
1223
  const basePath = resolve3(dirname2(from), spec);
1224
+ const extensions = [
1225
+ ".ts",
1226
+ ".tsx",
1227
+ ".mts",
1228
+ ".cts",
1229
+ ".js",
1230
+ ".jsx",
1231
+ ".mjs",
1232
+ ".cjs",
1233
+ ".json"
1234
+ ];
1224
1235
  const candidates = [
1225
1236
  basePath,
1226
- `${basePath}.ts`,
1227
- `${basePath}.js`,
1228
- `${basePath}.mjs`,
1229
- `${basePath}.cjs`,
1230
- `${basePath}.json`,
1231
- join3(basePath, "index.ts"),
1232
- join3(basePath, "index.js"),
1233
- join3(basePath, "index.mjs"),
1234
- join3(basePath, "index.cjs"),
1235
- join3(basePath, "index.json")
1237
+ ...extensions.map((extension) => `${basePath}${extension}`),
1238
+ ...extensions.map((extension) => join3(basePath, `index${extension}`))
1236
1239
  ];
1237
1240
  const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
1238
1241
  const foundIndex = existResults.indexOf(true);
@@ -1317,7 +1320,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, syncIslandGen
1317
1320
  rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), resolvedModuleImport));
1318
1321
  }
1319
1322
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
1320
- transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
1323
+ transpiled = replaceQuotedSpecifier(transpiled, spec, resolvedModuleImport);
1321
1324
  }
1322
1325
  let compiledCode = compile(transpiled, {
1323
1326
  css: "injected",
@@ -1329,10 +1332,10 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, syncIslandGen
1329
1332
  hmr: isDevelopmentRuntime()
1330
1333
  }).js.code;
1331
1334
  for (const [spec, compiledChildPath] of childModulePaths) {
1332
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
1335
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
1333
1336
  }
1334
1337
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
1335
- compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
1338
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, resolvedModuleImport);
1336
1339
  }
1337
1340
  const sourceId = JSON.stringify(relative2(process.cwd(), resolutionSourcePath).replace(/\\/g, "/"));
1338
1341
  const componentName = /export default function ([\w$]+)\s*\(/.exec(compiledCode)?.[1];
@@ -1571,7 +1574,7 @@ var ISLAND_BOOTSTRAP_MANIFEST_KEY = "AbsoluteIslandBootstrap", LEGACY_ISLAND_BOO
1571
1574
  islands[framework] = entries;
1572
1575
  }
1573
1576
  return islands;
1574
- }, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
1577
+ }, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`, ISLAND_STYLE_PREFIX = "IslandStyle", getIslandStyleManifestEntries = (manifest) => Object.entries(manifest).filter(([key]) => key.startsWith(ISLAND_STYLE_PREFIX)), getIslandStyleManifestKey = (framework, component) => `${ISLAND_STYLE_PREFIX}${toIslandFrameworkSegment(framework)}${component}`;
1575
1578
 
1576
1579
  // src/core/islandPageContext.ts
1577
1580
  var ISLAND_MARKER = 'data-island="true"', MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__", ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__", CLOSING_HEAD_TAG = "</head>", warnedMissingBootstrap = false, warnIfBootstrapMissing = (manifest) => {
@@ -1608,12 +1611,27 @@ var ISLAND_MARKER = 'data-island="true"', MANIFEST_MARKER = "__ABSOLUTE_MANIFEST
1608
1611
  browserManifest[key] = value;
1609
1612
  }
1610
1613
  return browserManifest;
1611
- }, buildIslandsHeadMarkup = (manifest) => {
1614
+ }, ISLAND_MARKER_TAG, ISLAND_FRAMEWORKS, readMarkerAttribute = (tag, name) => new RegExp(`\\b${name}="([^"]*)"`).exec(tag)?.[1]?.replaceAll("&quot;", '"').replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&"), toIslandFramework = (value) => ISLAND_FRAMEWORKS.find((framework) => framework === value), collectRenderedIslandStyleKeys = (html) => {
1615
+ const keys = new Set;
1616
+ for (const [tag] of html.matchAll(ISLAND_MARKER_TAG)) {
1617
+ const framework = toIslandFramework(readMarkerAttribute(tag, "data-framework"));
1618
+ const component = readMarkerAttribute(tag, "data-component");
1619
+ if (framework && component)
1620
+ keys.add(getIslandStyleManifestKey(framework, component));
1621
+ }
1622
+ return keys;
1623
+ }, buildIslandStyleLinks = (manifest, html) => {
1624
+ if (html === undefined)
1625
+ return "";
1626
+ const renderedKeys = collectRenderedIslandStyleKeys(html);
1627
+ return getIslandStyleManifestEntries(manifest).filter(([key]) => renderedKeys.has(key)).filter(([, href]) => !html.includes(`href="${href}"`)).map(([key, href]) => `<link rel="stylesheet" href="${href}" data-island-style="${key}"${nonceAttr()}>`).join("");
1628
+ }, buildIslandsHeadMarkup = (manifest, html) => {
1629
+ const styleLinks = buildIslandStyleLinks(manifest, html);
1612
1630
  const manifestScript = `<script${nonceAttr()}>window.__ABSOLUTE_MANIFEST__ = ${escapeScriptContent(JSON.stringify(toBrowserManifest(manifest)))}</script>`;
1613
1631
  const islandStateScript = `<script${nonceAttr()}>window.__ABS_ISLAND_STATE__ = ${escapeScriptContent(JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {}))}</script>`;
1614
1632
  const bootstrapPath = getIslandBootstrapPath(manifest);
1615
1633
  const bootstrapScript = bootstrapPath ? `<script${nonceAttr()} type="module" src="${bootstrapPath}"></script>` : "";
1616
- return `${manifestScript}${islandStateScript}${bootstrapScript}`;
1634
+ return `${styleLinks}${manifestScript}${islandStateScript}${bootstrapScript}`;
1617
1635
  }, injectHeadMarkup = (html, markup) => {
1618
1636
  const closingHeadIndex = html.indexOf("</head>");
1619
1637
  if (closingHeadIndex >= 0) {
@@ -1795,7 +1813,7 @@ var ISLAND_MARKER = 'data-island="true"', MANIFEST_MARKER = "__ABSOLUTE_MANIFEST
1795
1813
  return html;
1796
1814
  }
1797
1815
  warnIfBootstrapMissing(manifest);
1798
- return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
1816
+ return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest, html));
1799
1817
  }, injectIslandPageContextStream = (stream, options) => {
1800
1818
  const manifest = globalThis.__absoluteManifest;
1801
1819
  if (!manifest)
@@ -1819,6 +1837,13 @@ var init_islandPageContext = __esm(() => {
1819
1837
  init_logger();
1820
1838
  MANIFEST_BUILD_DIR_KEY = Symbol.for("absolutejs.islandManifestBuildDir");
1821
1839
  WINDOWS_ABSOLUTE_PATH = /^[A-Za-z]:[\\/]|^\\\\/;
1840
+ ISLAND_MARKER_TAG = /<[^>]*\bdata-island="true"[^>]*>/g;
1841
+ ISLAND_FRAMEWORKS = [
1842
+ "react",
1843
+ "svelte",
1844
+ "vue",
1845
+ "angular"
1846
+ ];
1822
1847
  });
1823
1848
 
1824
1849
  // src/core/devRouteRegistrationCallsite.ts
@@ -3286,6 +3311,12 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
3286
3311
  logConventionRenderError(framework, "error", renderError);
3287
3312
  }
3288
3313
  return null;
3314
+ }, isPageRequest = (request) => {
3315
+ if (request.headers.get("hx-request") === "true")
3316
+ return true;
3317
+ if (request.headers.get("sec-fetch-dest") === "document")
3318
+ return true;
3319
+ return (request.headers.get("accept") ?? "").includes("text/html");
3289
3320
  }, renderConventionError = async (framework, pageName, error) => {
3290
3321
  const errorProps = buildErrorProps(error);
3291
3322
  const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
@@ -3297,12 +3328,6 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
3297
3328
  return htmlResponse;
3298
3329
  }
3299
3330
  return null;
3300
- }, isPageRequest = (request) => {
3301
- if (request.headers.get("hx-request") === "true")
3302
- return true;
3303
- if (request.headers.get("sec-fetch-dest") === "document")
3304
- return true;
3305
- return (request.headers.get("accept") ?? "").includes("text/html");
3306
3331
  }, renderStaticRouteError = async (request, error) => {
3307
3332
  if (!isPageRequest(request))
3308
3333
  return null;
@@ -3696,6 +3721,18 @@ var asset = (source, name) => {
3696
3721
  return assetPath;
3697
3722
  };
3698
3723
 
3724
+ // src/utils/requestRenderUrl.ts
3725
+ var requestRenderUrl = (request) => {
3726
+ if (!request)
3727
+ return;
3728
+ try {
3729
+ const parsed = new URL(request.url);
3730
+ return `${parsed.pathname.replace(/\/{2,}/g, "/")}${parsed.search}`;
3731
+ } catch {
3732
+ return;
3733
+ }
3734
+ };
3735
+
3699
3736
  // src/svelte/pageHandler.ts
3700
3737
  init_cspNonceRef();
3701
3738
  init_svelteServerModule();
@@ -4085,35 +4122,7 @@ var readHasIslands = (value) => {
4085
4122
  return typeof hasIslands === "boolean" ? hasIslands : false;
4086
4123
  };
4087
4124
  var readDefaultExport = (value) => isRecord5(value) ? value.default : undefined;
4088
- var primeSvelteStream = async (stream) => {
4089
- const reader = stream.getReader();
4090
- const firstChunk = await reader.read();
4091
- return { firstChunk, reader };
4092
- };
4093
- var restorePrimedStream = (firstChunk, reader) => new ReadableStream({
4094
- start(controller) {
4095
- if (!firstChunk.done)
4096
- controller.enqueue(firstChunk.value);
4097
- if (firstChunk.done) {
4098
- controller.close();
4099
- return;
4100
- }
4101
- const pumpLoop = () => {
4102
- reader.read().then(({ done, value }) => done ? controller.close() : (controller.enqueue(value), pumpLoop())).catch((err) => controller.error(err));
4103
- };
4104
- pumpLoop();
4105
- }
4106
- });
4107
- var resolveRequestPathname = (request) => {
4108
- if (!request)
4109
- return;
4110
- try {
4111
- const parsed = new URL(request.url);
4112
- return `${parsed.pathname}${parsed.search}`;
4113
- } catch {
4114
- return;
4115
- }
4116
- };
4125
+ var resolveRequestPathname = (request) => requestRenderUrl(request);
4117
4126
  var handleSveltePageRequest = async (input) => {
4118
4127
  const deferredAssets = input.pagePath === "" || input.indexPath === "" ? await resolveDeferredPageAssets() : null;
4119
4128
  const buildFailure = devBuildErrorResponse("svelte", deferredAssets);
@@ -4209,11 +4218,8 @@ var handleSveltePageRequest = async (input) => {
4209
4218
  const routerResponse = routerSsr.response();
4210
4219
  if (routerResponse)
4211
4220
  return routerResponse;
4212
- const htmlStream = injectIslandPageContextStream(stream, {
4213
- hasIslands: resolvedPage.hasIslands ? true : undefined
4214
- });
4215
- const { firstChunk, reader } = await primeSvelteStream(htmlStream);
4216
- return new Response(restorePrimedStream(firstChunk, reader), {
4221
+ const html = injectIslandPageContext(await new Response(stream).text(), { hasIslands: resolvedPage.hasIslands ? true : undefined });
4222
+ return new Response(html, {
4217
4223
  headers: streamingPageHeaders()
4218
4224
  });
4219
4225
  };
@@ -4250,5 +4256,5 @@ export {
4250
4256
  svelteFileRoute
4251
4257
  };
4252
4258
 
4253
- //# debugId=20CAA04A1EAF2FEF64756E2164756E21
4259
+ //# debugId=78AD174572FEF3CC64756E2164756E21
4254
4260
  //# sourceMappingURL=server.js.map