@absolutejs/absolute 0.20.0-beta.54 → 0.20.0-beta.55

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 (37) hide show
  1. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  2. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  3. package/dist/angular/index.js +25 -4
  4. package/dist/angular/index.js.map +6 -5
  5. package/dist/angular/server.js +25 -4
  6. package/dist/angular/server.js.map +6 -5
  7. package/dist/build.js +56 -9
  8. package/dist/build.js.map +10 -9
  9. package/dist/cli/config/server.js +4 -1
  10. package/dist/client/index.js +126 -7
  11. package/dist/client/index.js.map +8 -6
  12. package/dist/index.js +279 -232
  13. package/dist/index.js.map +12 -11
  14. package/dist/islands/index.js +17 -2
  15. package/dist/islands/index.js.map +5 -4
  16. package/dist/react/index.js +19 -3
  17. package/dist/react/index.js.map +6 -5
  18. package/dist/react/server.js +17 -2
  19. package/dist/react/server.js.map +5 -4
  20. package/dist/src/client/browserTranslation.d.ts +19 -0
  21. package/dist/src/client/index.d.ts +1 -0
  22. package/dist/src/core/browserTranslation.d.ts +6 -0
  23. package/dist/src/ember/browser.d.ts +0 -16
  24. package/dist/src/vue/browser.d.ts +1 -0
  25. package/dist/src/vue/browserTranslation.d.ts +5 -0
  26. package/dist/src/vue/index.d.ts +1 -0
  27. package/dist/svelte/index.js +19 -3
  28. package/dist/svelte/index.js.map +6 -5
  29. package/dist/svelte/server.js +17 -2
  30. package/dist/svelte/server.js.map +5 -4
  31. package/dist/vue/browser.js +96 -1
  32. package/dist/vue/browser.js.map +5 -3
  33. package/dist/vue/index.js +114 -3
  34. package/dist/vue/index.js.map +8 -5
  35. package/dist/vue/server.js +17 -2
  36. package/dist/vue/server.js.map +5 -4
  37. package/package.json +7 -7
@@ -0,0 +1,6 @@
1
+ /** Inline this after SSR markup and before any client entry executes. The
2
+ * snapshot records server-authored text while keeping it out of the DOM, so
3
+ * browser translation remains free to edit the rendered text. */
4
+ export declare const BROWSER_TRANSLATION_BASELINE_SCRIPT: string;
5
+ export declare const browserTranslationBaselineTag: () => string;
6
+ export declare const injectBrowserTranslationBaseline: (html: string) => string;
@@ -1,19 +1,3 @@
1
- /**
2
- * Phase 1 Ember client entry.
3
- *
4
- * The page index file (emitted by the build) imports this module and
5
- * the user's compiled page module. We mount the page component into
6
- * `#ember-root` using the same `renderComponent` API SSR used — Ember
7
- * Router's hydration story is post-Phase-1 work; for v1 we re-render
8
- * client-side over the SSR'd HTML.
9
- *
10
- * `@ember/renderer` is loaded dynamically rather than via static import
11
- * because (a) the AbsoluteJS framework typecheck shouldn't require
12
- * ember-source as a dep, and (b) the resolved URL at runtime is
13
- * `/ember/vendor/ember_renderer.js` (the vendor build's output) rather
14
- * than the bare specifier — only the user's bundle pass knows which
15
- * mapping to apply.
16
- */
17
1
  declare global {
18
2
  interface Window {
19
3
  __INITIAL_PROPS__?: Record<string, unknown>;
@@ -1,6 +1,7 @@
1
1
  export { Island } from './Island.browser';
2
2
  export { createTypedIsland } from './createIsland.browser';
3
3
  export { useIslandStore } from './useIslandStore';
4
+ export { captureSsrTextBaselines, prepareBrowserTranslationHydration, preserveBrowserTranslation } from './browserTranslation';
4
5
  export { defineRoutes, defineVueSetupApp } from './defineVuePage';
5
6
  export { applyVueRouterRedirect } from './routerRedirectProviders';
6
7
  export type { VueAutoRouter, VueRouteRecord, VueRoutes, VueSetupApp, VueSetupAppContext } from '../../types/vue';
@@ -0,0 +1,5 @@
1
+ import type { HydrationStrategy } from 'vue';
2
+ export { captureSsrTextBaselines, prepareBrowserTranslationHydration } from '../client/browserTranslation';
3
+ /** Wrap a Vue lazy-hydration strategy so text changed by browser translation
4
+ * after the SSR snapshot neither triggers a mismatch nor gets reset. */
5
+ export declare const preserveBrowserTranslation: (strategy: HydrationStrategy) => HydrationStrategy;
@@ -5,6 +5,7 @@ export type { VueAutoRouter, VueRouteRecord, VueRoutes, VueSetupApp, VueSetupApp
5
5
  export { Island } from './Island';
6
6
  export { createTypedIsland } from './createIsland';
7
7
  export { useIslandStore } from './useIslandStore';
8
+ export { captureSsrTextBaselines, prepareBrowserTranslationHydration, preserveBrowserTranslation } from './browserTranslation';
8
9
  export { Image } from './components/Image';
9
10
  export { StreamSlot, SuspenseSlot } from './components';
10
11
  export { useResource } from './useResource';
@@ -2466,6 +2466,20 @@ var init_spaRouteManifest = __esm(() => {
2466
2466
  init_resolveConvention();
2467
2467
  });
2468
2468
 
2469
+ // src/core/browserTranslation.ts
2470
+ var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BASELINE_SCRIPT, browserTranslationBaselineTag = () => `<script>${BROWSER_TRANSLATION_BASELINE_SCRIPT}</script>`, injectBrowserTranslationBaseline = (html) => {
2471
+ if (html.includes(BASELINE_MARKER))
2472
+ return html;
2473
+ const script = browserTranslationBaselineTag();
2474
+ const closingBodyIndex = html.lastIndexOf("</body>");
2475
+ if (closingBodyIndex < 0)
2476
+ return `${html}${script}`;
2477
+ return `${html.slice(0, closingBodyIndex)}${script}${html.slice(closingBodyIndex)}`;
2478
+ };
2479
+ var init_browserTranslation = __esm(() => {
2480
+ BROWSER_TRANSLATION_BASELINE_SCRIPT = "window.__ABSOLUTE_SSR_TEXT_BASELINES__=new WeakMap();" + "{const r=document.body,b=window.__ABSOLUTE_SSR_TEXT_BASELINES__;" + 'if(r)for(const e of [r,...r.querySelectorAll("*")]){' + "const t=new Map();for(const [i,n]of[...e.childNodes].entries())" + 'if(n.nodeType===3)t.set(i,n.nodeValue??"");if(t.size)b.set(e,t);}}';
2481
+ });
2482
+
2469
2483
  // src/svelte/renderToReadableStream.ts
2470
2484
  var exports_renderToReadableStream = {};
2471
2485
  __export(exports_renderToReadableStream, {
@@ -2901,7 +2915,7 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
2901
2915
  }
2902
2916
  return html + snippet;
2903
2917
  }, injectSsrScripts = (html, requestId, indexPath, requestContext) => {
2904
- let result = html;
2918
+ let result = injectBeforeClose(html, browserTranslationBaselineTag());
2905
2919
  const registeredScripts = getAndClearClientScripts(requestId);
2906
2920
  if (registeredScripts.length > 0) {
2907
2921
  result = injectBeforeClose(result, generateClientScriptCode(registeredScripts));
@@ -2937,6 +2951,7 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
2937
2951
  };
2938
2952
  var init_ssrRender = __esm(() => {
2939
2953
  init_registerClientScript();
2954
+ init_browserTranslation();
2940
2955
  routeContextCache = new Map;
2941
2956
  selectorCache = new Map;
2942
2957
  });
@@ -4795,6 +4810,7 @@ var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage(
4795
4810
  init_inlinePageCss();
4796
4811
  init_spaRouteManifest();
4797
4812
  init_resolveConvention();
4813
+ init_browserTranslation();
4798
4814
  var isRecord3 = (value) => typeof value === "object" && value !== null;
4799
4815
  var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord3(value);
4800
4816
  var readHasIslands = (value) => {
@@ -4899,7 +4915,7 @@ var handleSveltePageRequest = async (input) => {
4899
4915
  const composedHeadContent = `${cssBlock}${resolvedOptions?.headContent ?? ""}`;
4900
4916
  const stream = await renderToReadableStream2(resolvedPage.component, resolvedProps, {
4901
4917
  bodyContent: resolvedOptions?.bodyContent,
4902
- bootstrapScriptContent: `window.__ABS_SLOT_HYDRATION_PENDING__=true;window.__INITIAL_PROPS__=${JSON.stringify(resolvedProps)};${resolvedIndexPath ? `import(${JSON.stringify(resolvedIndexPath)});` : ""}`,
4918
+ bootstrapScriptContent: `${BROWSER_TRANSLATION_BASELINE_SCRIPT}window.__ABS_SLOT_HYDRATION_PENDING__=true;window.__INITIAL_PROPS__=${JSON.stringify(resolvedProps)};${resolvedIndexPath ? `import(${JSON.stringify(resolvedIndexPath)});` : ""}`,
4903
4919
  headContent: composedHeadContent
4904
4920
  });
4905
4921
  const htmlStream = injectIslandPageContextStream(stream, {
@@ -5071,5 +5087,5 @@ export {
5071
5087
  useIslandStore
5072
5088
  };
5073
5089
 
5074
- //# debugId=7A8AED3F56517C4464756E2164756E21
5090
+ //# debugId=907A498851BFBA5664756E2164756E21
5075
5091
  //# sourceMappingURL=index.js.map