@fluixi/core 1.0.0-alpha.94 → 1.0.0-alpha.95

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 (51) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cdn/core.global.js +2 -2
  3. package/dist/src/cdn/{chunk-7XM7Q5VR.mjs → chunk-IFONZJWJ.mjs} +93 -2
  4. package/dist/src/cdn/core.cjs +99 -3
  5. package/dist/src/cdn/core.mjs +3 -3
  6. package/dist/src/cdn/{router-VOY43YNM.mjs → router-TU5CPI54.mjs} +1 -1
  7. package/dist/src/index.cjs +95 -4
  8. package/dist/src/index.mjs +95 -4
  9. package/dist/src/lib/client/{chunk-TSXM2PNY.mjs → chunk-AHNP3IWU.mjs} +1 -1
  10. package/dist/src/lib/client/index.cjs +100 -4
  11. package/dist/src/lib/client/index.mjs +4 -4
  12. package/dist/src/lib/client/{router-BDVPLLYX.mjs → router-5C6FQJQ4.mjs} +95 -4
  13. package/dist/src/lib/core.cjs +94 -3
  14. package/dist/src/lib/core.mjs +94 -3
  15. package/dist/src/lib/i18n/index.cjs +1 -1
  16. package/dist/src/lib/i18n/index.mjs +1 -1
  17. package/dist/src/lib/index.cjs +1 -1
  18. package/dist/src/lib/index.mjs +1 -1
  19. package/dist/src/lib/jsx-runtime/index.cjs +1 -1
  20. package/dist/src/lib/jsx-runtime/index.mjs +1 -1
  21. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +1 -1
  22. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +1 -1
  23. package/dist/src/lib/plugins/index.cjs +1 -1
  24. package/dist/src/lib/plugins/index.mjs +1 -1
  25. package/dist/src/lib/render/index.cjs +1 -1
  26. package/dist/src/lib/render/index.mjs +1 -1
  27. package/dist/src/lib/render/versions.cjs +1 -1
  28. package/dist/src/lib/render/versions.mjs +1 -1
  29. package/dist/src/lib/router/index.cjs +94 -3
  30. package/dist/src/lib/router/index.d.ts.map +1 -1
  31. package/dist/src/lib/router/index.js +55 -0
  32. package/dist/src/lib/router/index.mjs +94 -3
  33. package/dist/src/lib/router/scroll.cjs +79 -0
  34. package/dist/src/lib/router/scroll.d.ts +19 -0
  35. package/dist/src/lib/router/scroll.d.ts.map +1 -0
  36. package/dist/src/lib/router/scroll.js +68 -0
  37. package/dist/src/lib/router/scroll.mjs +58 -0
  38. package/dist/src/lib/server/index.cjs +1 -1
  39. package/dist/src/lib/server/index.mjs +1 -1
  40. package/dist/src/lib/storage/index.cjs +1 -1
  41. package/dist/src/lib/storage/index.mjs +1 -1
  42. package/dist/src/routes.cjs +1 -1
  43. package/dist/src/routes.mjs +1 -1
  44. package/dist/src/utils.cjs +1 -1
  45. package/dist/src/utils.mjs +1 -1
  46. package/dist/src/version.generated.cjs +1 -1
  47. package/dist/src/version.generated.d.ts +1 -1
  48. package/dist/src/version.generated.js +1 -1
  49. package/dist/src/version.generated.mjs +1 -1
  50. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  51. package/package.json +16 -16
@@ -0,0 +1,68 @@
1
+ const STORE = 'fx:scroll';
2
+ // Positions kept for this many entries, the most recent ones.
3
+ const KEEP = 100;
4
+ export function keepScroll(initial) {
5
+ const read = () => {
6
+ try {
7
+ return JSON.parse(sessionStorage.getItem(STORE) ?? '{}');
8
+ }
9
+ catch {
10
+ return {};
11
+ }
12
+ };
13
+ const positions = read();
14
+ const write = () => {
15
+ const keys = Object.keys(positions);
16
+ for (const key of keys.slice(0, Math.max(0, keys.length - KEEP)))
17
+ delete positions[key];
18
+ try {
19
+ sessionStorage.setItem(STORE, JSON.stringify(positions));
20
+ }
21
+ catch {
22
+ // Storage full or refused: positions still hold for this page's life.
23
+ }
24
+ };
25
+ let current = initial.key;
26
+ const save = () => {
27
+ if (current === undefined)
28
+ return;
29
+ delete positions[current];
30
+ positions[current] = window.scrollY;
31
+ write();
32
+ };
33
+ const restoration = history.scrollRestoration;
34
+ history.scrollRestoration = 'manual';
35
+ // A reload or a tab closed and reopened: the entry keeps its position.
36
+ window.addEventListener('pagehide', save);
37
+ // Instant, as a page load lands, whatever `scroll-behavior` the page's CSS sets: a smooth
38
+ // scroll would animate from where the last page was.
39
+ const to = (top) => window.scrollTo({ top, left: 0, behavior: 'instant' });
40
+ const toHash = (hash) => {
41
+ if (!hash || hash === '#')
42
+ return false;
43
+ const target = document.getElementById(decodeURIComponent(hash.slice(1)));
44
+ target?.scrollIntoView({ behavior: 'instant' });
45
+ return target !== null;
46
+ };
47
+ return {
48
+ leave: save,
49
+ arrive(location, from) {
50
+ current = location.key;
51
+ if (location.action === 'pop' || from === undefined) {
52
+ const y = location.key === undefined ? undefined : positions[location.key];
53
+ if (y !== undefined)
54
+ to(y);
55
+ return;
56
+ }
57
+ // A replace on the same page (a filter in the query) leaves the reader where they are.
58
+ if (location.action === 'replace' && location.pathname === from.pathname)
59
+ return;
60
+ if (!toHash(location.hash))
61
+ to(0);
62
+ },
63
+ dispose() {
64
+ window.removeEventListener('pagehide', save);
65
+ history.scrollRestoration = restoration;
66
+ },
67
+ };
68
+ }
@@ -0,0 +1,58 @@
1
+ // src/lib/router/scroll.ts
2
+ var STORE = "fx:scroll";
3
+ var KEEP = 100;
4
+ function keepScroll(initial) {
5
+ const read = () => {
6
+ try {
7
+ return JSON.parse(sessionStorage.getItem(STORE) ?? "{}");
8
+ } catch {
9
+ return {};
10
+ }
11
+ };
12
+ const positions = read();
13
+ const write = () => {
14
+ const keys = Object.keys(positions);
15
+ for (const key of keys.slice(0, Math.max(0, keys.length - KEEP))) delete positions[key];
16
+ try {
17
+ sessionStorage.setItem(STORE, JSON.stringify(positions));
18
+ } catch {
19
+ }
20
+ };
21
+ let current = initial.key;
22
+ const save = () => {
23
+ if (current === void 0) return;
24
+ delete positions[current];
25
+ positions[current] = window.scrollY;
26
+ write();
27
+ };
28
+ const restoration = history.scrollRestoration;
29
+ history.scrollRestoration = "manual";
30
+ window.addEventListener("pagehide", save);
31
+ const to = (top) => window.scrollTo({ top, left: 0, behavior: "instant" });
32
+ const toHash = (hash) => {
33
+ if (!hash || hash === "#") return false;
34
+ const target = document.getElementById(decodeURIComponent(hash.slice(1)));
35
+ target?.scrollIntoView({ behavior: "instant" });
36
+ return target !== null;
37
+ };
38
+ return {
39
+ leave: save,
40
+ arrive(location, from) {
41
+ current = location.key;
42
+ if (location.action === "pop" || from === void 0) {
43
+ const y = location.key === void 0 ? void 0 : positions[location.key];
44
+ if (y !== void 0) to(y);
45
+ return;
46
+ }
47
+ if (location.action === "replace" && location.pathname === from.pathname) return;
48
+ if (!toHash(location.hash)) to(0);
49
+ },
50
+ dispose() {
51
+ window.removeEventListener("pagehide", save);
52
+ history.scrollRestoration = restoration;
53
+ }
54
+ };
55
+ }
56
+ export {
57
+ keepScroll
58
+ };
@@ -1,4 +1,4 @@
1
- /*! @fluixi/core v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/core v1.0.0-alpha.95 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,4 +1,4 @@
1
- /*! @fluixi/core v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/core v1.0.0-alpha.95 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
 
3
3
  // src/lib/server/hydration.ts
4
4
  import { isServer as domIsServer } from "@fluixi/dom";
@@ -1,4 +1,4 @@
1
- /*! @fluixi/core v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/core v1.0.0-alpha.95 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,4 +1,4 @@
1
- /*! @fluixi/core v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/core v1.0.0-alpha.95 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
 
3
3
  // src/lib/storage/index.ts
4
4
  import { appendResponseHeader, getRequestContext, getServerData } from "@fluixi/dom";
@@ -1,4 +1,4 @@
1
- /*! @fluixi/core v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/core v1.0.0-alpha.95 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,4 +1,4 @@
1
- /*! @fluixi/core v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/core v1.0.0-alpha.95 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
 
3
3
  // src/routes.ts
4
4
  function missingPlugin() {
@@ -1,4 +1,4 @@
1
- /*! @fluixi/core v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/core v1.0.0-alpha.95 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,4 +1,4 @@
1
- /*! @fluixi/core v1.0.0-alpha.94 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/core v1.0.0-alpha.95 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
 
3
3
  // src/utils.ts
4
4
  export * from "@fluixi/utils";
@@ -23,4 +23,4 @@ __export(version_generated_exports, {
23
23
  VERSION: () => VERSION
24
24
  });
25
25
  module.exports = __toCommonJS(version_generated_exports);
26
- var VERSION = "1.0.0-alpha.94";
26
+ var VERSION = "1.0.0-alpha.95";
@@ -1,3 +1,3 @@
1
1
  /** The published version of @fluixi/core that this build came from. */
2
- export declare const VERSION = "1.0.0-alpha.94";
2
+ export declare const VERSION = "1.0.0-alpha.95";
3
3
  //# sourceMappingURL=version.generated.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // GENERATED by scripts/gen-version.mjs. Do not edit.
2
2
  /** The published version of @fluixi/core that this build came from. */
3
- export const VERSION = '1.0.0-alpha.94';
3
+ export const VERSION = '1.0.0-alpha.95';
@@ -1,5 +1,5 @@
1
1
  // src/version.generated.ts
2
- var VERSION = "1.0.0-alpha.94";
2
+ var VERSION = "1.0.0-alpha.95";
3
3
  export {
4
4
  VERSION
5
5
  };