hermium 0.1.9 → 0.2.0

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 (209) hide show
  1. package/README.md +56 -0
  2. package/bin/hermium.mjs +185 -164
  3. package/dist/api.mjs +3513 -0
  4. package/dist/public/assets/css/index-Dfs9RUU9.css +1 -0
  5. package/dist/public/assets/css/styles-B8p6jk5Z.css +1 -0
  6. package/dist/public/assets/js/ChatInputBlock-Bw7AL70H.js +1 -0
  7. package/dist/public/assets/js/MarkdownMessage-8d7Y6VL-.js +1 -0
  8. package/dist/public/assets/js/base-ui-BvQbAt_1.js +1 -0
  9. package/dist/public/assets/js/chat._sessionId-BG6lVraH.js +1 -0
  10. package/dist/public/assets/js/chat.index-D2zdMPTT.js +1 -0
  11. package/dist/public/assets/js/index-C0AK45FU.js +60 -0
  12. package/dist/public/assets/js/index-Cx5En4FK.js +1 -0
  13. package/dist/public/assets/js/memory-CeSRdTkW.js +3 -0
  14. package/dist/public/assets/js/router-8uDKazL-.js +1 -0
  15. package/dist/public/assets/js/settings-Bc3Y5zXO.js +1 -0
  16. package/dist/public/assets/js/skills-DZv7sA_5.js +1 -0
  17. package/dist/public/assets/js/theme-CPkdkpaj.js +1 -0
  18. package/dist/public/assets/js/usage-DXQsT9_b.js +1 -0
  19. package/dist/public/assets/woff2/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  20. package/dist/public/assets/woff2/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  21. package/dist/public/assets/woff2/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  22. package/dist/public/assets/woff2/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  23. package/dist/public/assets/woff2/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  24. package/dist/public/favicon.ico +0 -0
  25. package/dist/public/logo.png +0 -0
  26. package/package.json +1 -1
  27. package/dist/public/assets/IconAlertCircle-BHkmI3j7.js +0 -1
  28. package/dist/public/assets/IconAlertTriangle-wCJudlVg.js +0 -1
  29. package/dist/public/assets/IconCheck-CFuEh_p7.js +0 -1
  30. package/dist/public/assets/IconLoader2-BIx3OuF9.js +0 -1
  31. package/dist/public/assets/IconRefresh-Dgm93w3T.js +0 -1
  32. package/dist/public/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
  33. package/dist/public/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
  34. package/dist/public/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
  35. package/dist/public/assets/index-Bbz3abmO.js +0 -14
  36. package/dist/public/assets/index-CWUaRwcE.js +0 -1
  37. package/dist/public/assets/index-CinLq3cd.js +0 -1
  38. package/dist/public/assets/index-CrQs9n6q.js +0 -29
  39. package/dist/public/assets/index-CtacpN3I.js +0 -1
  40. package/dist/public/assets/index-DY7aE-9s.js +0 -2
  41. package/dist/public/assets/index-DkYGodJj.js +0 -94
  42. package/dist/public/assets/index-DvDLadUx.js +0 -1
  43. package/dist/public/assets/index-U6RcWedt.js +0 -1
  44. package/dist/public/assets/index-_6iFZ0fh.js +0 -1
  45. package/dist/public/assets/index-enFS26SU.js +0 -1
  46. package/dist/public/assets/input-eNcwlDHp.js +0 -1
  47. package/dist/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  48. package/dist/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  49. package/dist/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  50. package/dist/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  51. package/dist/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  52. package/dist/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  53. package/dist/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  54. package/dist/public/assets/queries-iHRgZzw2.js +0 -1
  55. package/dist/public/assets/styles-KcflDlA_.css +0 -1
  56. package/dist/public/assets/switch-B1DcZLwL.js +0 -1
  57. package/dist/public/assets/syntax-highlighter-DWPF-A_h.js +0 -6
  58. package/dist/public/assets/textarea-Di_syYTS.js +0 -1
  59. package/dist/public/favicon.png +0 -0
  60. package/dist/public/nous-logo.png +0 -0
  61. package/dist/server/index.mjs +0 -244
  62. package/dist/web-server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +0 -6
  63. package/dist/web-server/_chunks/ssr-renderer.mjs +0 -22
  64. package/dist/web-server/_libs/babel__runtime.mjs +0 -237
  65. package/dist/web-server/_libs/bail.mjs +0 -8
  66. package/dist/web-server/_libs/base-ui__react.mjs +0 -9554
  67. package/dist/web-server/_libs/base-ui__utils.mjs +0 -1101
  68. package/dist/web-server/_libs/ccount.mjs +0 -16
  69. package/dist/web-server/_libs/character-entities-legacy.mjs +0 -111
  70. package/dist/web-server/_libs/character-entities.mjs +0 -2130
  71. package/dist/web-server/_libs/character-reference-invalid.mjs +0 -33
  72. package/dist/web-server/_libs/class-variance-authority.mjs +0 -44
  73. package/dist/web-server/_libs/clsx.mjs +0 -16
  74. package/dist/web-server/_libs/comma-separated-tokens.mjs +0 -31
  75. package/dist/web-server/_libs/cookie-es.mjs +0 -44
  76. package/dist/web-server/_libs/croner.mjs +0 -1
  77. package/dist/web-server/_libs/crossws.mjs +0 -1
  78. package/dist/web-server/_libs/decode-named-character-reference+[...].mjs +0 -8
  79. package/dist/web-server/_libs/devlop.mjs +0 -8
  80. package/dist/web-server/_libs/escape-string-regexp.mjs +0 -9
  81. package/dist/web-server/_libs/estree-util-is-identifier-name.mjs +0 -11
  82. package/dist/web-server/_libs/extend.mjs +0 -97
  83. package/dist/web-server/_libs/fault.mjs +0 -1
  84. package/dist/web-server/_libs/floating-ui__core.mjs +0 -663
  85. package/dist/web-server/_libs/floating-ui__dom.mjs +0 -624
  86. package/dist/web-server/_libs/floating-ui__react-dom.mjs +0 -279
  87. package/dist/web-server/_libs/floating-ui__utils.mjs +0 -322
  88. package/dist/web-server/_libs/format.mjs +0 -1
  89. package/dist/web-server/_libs/h3.mjs +0 -408
  90. package/dist/web-server/_libs/hast-util-parse-selector.mjs +0 -39
  91. package/dist/web-server/_libs/hast-util-to-jsx-runtime.mjs +0 -388
  92. package/dist/web-server/_libs/hast-util-whitespace.mjs +0 -10
  93. package/dist/web-server/_libs/hastscript.mjs +0 -200
  94. package/dist/web-server/_libs/highlight.js.mjs +0 -1
  95. package/dist/web-server/_libs/hookable.mjs +0 -1
  96. package/dist/web-server/_libs/html-url-attributes.mjs +0 -26
  97. package/dist/web-server/_libs/inline-style-parser.mjs +0 -142
  98. package/dist/web-server/_libs/is-alphabetical.mjs +0 -7
  99. package/dist/web-server/_libs/is-alphanumerical.mjs +0 -8
  100. package/dist/web-server/_libs/is-decimal.mjs +0 -7
  101. package/dist/web-server/_libs/is-hexadecimal.mjs +0 -7
  102. package/dist/web-server/_libs/is-plain-obj.mjs +0 -10
  103. package/dist/web-server/_libs/isbot.mjs +0 -21
  104. package/dist/web-server/_libs/longest-streak.mjs +0 -25
  105. package/dist/web-server/_libs/lowlight.mjs +0 -1
  106. package/dist/web-server/_libs/markdown-table.mjs +0 -142
  107. package/dist/web-server/_libs/mdast-util-find-and-replace.mjs +0 -109
  108. package/dist/web-server/_libs/mdast-util-from-markdown.mjs +0 -717
  109. package/dist/web-server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +0 -156
  110. package/dist/web-server/_libs/mdast-util-gfm-footnote.mjs +0 -117
  111. package/dist/web-server/_libs/mdast-util-gfm-strikethrough.mjs +0 -54
  112. package/dist/web-server/_libs/mdast-util-gfm-table.mjs +0 -157
  113. package/dist/web-server/_libs/mdast-util-gfm-task-list-item.mjs +0 -77
  114. package/dist/web-server/_libs/mdast-util-gfm.mjs +0 -29
  115. package/dist/web-server/_libs/mdast-util-phrasing.mjs +0 -30
  116. package/dist/web-server/_libs/mdast-util-to-hast.mjs +0 -710
  117. package/dist/web-server/_libs/mdast-util-to-markdown.mjs +0 -798
  118. package/dist/web-server/_libs/mdast-util-to-string.mjs +0 -38
  119. package/dist/web-server/_libs/micromark-core-commonmark.mjs +0 -2259
  120. package/dist/web-server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +0 -344
  121. package/dist/web-server/_libs/micromark-extension-gfm-footnote+[...].mjs +0 -279
  122. package/dist/web-server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +0 -98
  123. package/dist/web-server/_libs/micromark-extension-gfm-table.mjs +0 -491
  124. package/dist/web-server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +0 -1
  125. package/dist/web-server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +0 -77
  126. package/dist/web-server/_libs/micromark-extension-gfm.mjs +0 -18
  127. package/dist/web-server/_libs/micromark-factory-destination.mjs +0 -94
  128. package/dist/web-server/_libs/micromark-factory-label.mjs +0 -63
  129. package/dist/web-server/_libs/micromark-factory-space.mjs +0 -24
  130. package/dist/web-server/_libs/micromark-factory-title.mjs +0 -65
  131. package/dist/web-server/_libs/micromark-factory-whitespace.mjs +0 -22
  132. package/dist/web-server/_libs/micromark-util-character.mjs +0 -44
  133. package/dist/web-server/_libs/micromark-util-chunked.mjs +0 -36
  134. package/dist/web-server/_libs/micromark-util-classify-character+[...].mjs +0 -12
  135. package/dist/web-server/_libs/micromark-util-combine-extensions+[...].mjs +0 -41
  136. package/dist/web-server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +0 -19
  137. package/dist/web-server/_libs/micromark-util-decode-string.mjs +0 -21
  138. package/dist/web-server/_libs/micromark-util-encode.mjs +0 -1
  139. package/dist/web-server/_libs/micromark-util-html-tag-name.mjs +0 -69
  140. package/dist/web-server/_libs/micromark-util-normalize-identifier+[...].mjs +0 -6
  141. package/dist/web-server/_libs/micromark-util-resolve-all.mjs +0 -15
  142. package/dist/web-server/_libs/micromark-util-sanitize-uri.mjs +0 -41
  143. package/dist/web-server/_libs/micromark-util-subtokenize.mjs +0 -346
  144. package/dist/web-server/_libs/micromark.mjs +0 -906
  145. package/dist/web-server/_libs/ocache.mjs +0 -1
  146. package/dist/web-server/_libs/ohash.mjs +0 -1
  147. package/dist/web-server/_libs/parse-entities.mjs +0 -245
  148. package/dist/web-server/_libs/property-information.mjs +0 -1210
  149. package/dist/web-server/_libs/react-dom.mjs +0 -10779
  150. package/dist/web-server/_libs/react-markdown.mjs +0 -147
  151. package/dist/web-server/_libs/react-syntax-highlighter.mjs +0 -941
  152. package/dist/web-server/_libs/react.mjs +0 -513
  153. package/dist/web-server/_libs/refractor.mjs +0 -2425
  154. package/dist/web-server/_libs/remark-gfm.mjs +0 -20
  155. package/dist/web-server/_libs/remark-parse.mjs +0 -19
  156. package/dist/web-server/_libs/remark-rehype.mjs +0 -21
  157. package/dist/web-server/_libs/reselect.mjs +0 -1
  158. package/dist/web-server/_libs/rou3.mjs +0 -8
  159. package/dist/web-server/_libs/seroval-plugins.mjs +0 -58
  160. package/dist/web-server/_libs/seroval.mjs +0 -1775
  161. package/dist/web-server/_libs/space-separated-tokens.mjs +0 -11
  162. package/dist/web-server/_libs/srvx.mjs +0 -781
  163. package/dist/web-server/_libs/style-to-js.mjs +0 -72
  164. package/dist/web-server/_libs/style-to-object.mjs +0 -38
  165. package/dist/web-server/_libs/tabler__icons-react.mjs +0 -230
  166. package/dist/web-server/_libs/tanstack__history.mjs +0 -204
  167. package/dist/web-server/_libs/tanstack__query-core.mjs +0 -2552
  168. package/dist/web-server/_libs/tanstack__react-query.mjs +0 -190
  169. package/dist/web-server/_libs/tanstack__react-router.mjs +0 -1120
  170. package/dist/web-server/_libs/tanstack__react-store.mjs +0 -2
  171. package/dist/web-server/_libs/tanstack__router-core.mjs +0 -4288
  172. package/dist/web-server/_libs/tanstack__store.mjs +0 -1
  173. package/dist/web-server/_libs/trim-lines.mjs +0 -41
  174. package/dist/web-server/_libs/trough.mjs +0 -85
  175. package/dist/web-server/_libs/ufo.mjs +0 -54
  176. package/dist/web-server/_libs/unctx.mjs +0 -1
  177. package/dist/web-server/_libs/ungap__structured-clone.mjs +0 -224
  178. package/dist/web-server/_libs/unified.mjs +0 -661
  179. package/dist/web-server/_libs/unist-util-is.mjs +0 -100
  180. package/dist/web-server/_libs/unist-util-position.mjs +0 -27
  181. package/dist/web-server/_libs/unist-util-stringify-position.mjs +0 -27
  182. package/dist/web-server/_libs/unist-util-visit-parents.mjs +0 -83
  183. package/dist/web-server/_libs/unist-util-visit.mjs +0 -24
  184. package/dist/web-server/_libs/unstorage.mjs +0 -1
  185. package/dist/web-server/_libs/use-sync-external-store.mjs +0 -139
  186. package/dist/web-server/_libs/vfile-message.mjs +0 -138
  187. package/dist/web-server/_libs/vfile.mjs +0 -467
  188. package/dist/web-server/_libs/zod.mjs +0 -3915
  189. package/dist/web-server/_libs/zustand.mjs +0 -343
  190. package/dist/web-server/_libs/zwitch.mjs +0 -1
  191. package/dist/web-server/_ssr/index-0n2Z3BPQ.mjs +0 -369
  192. package/dist/web-server/_ssr/index-6itDALOw.mjs +0 -339
  193. package/dist/web-server/_ssr/index-BIRTrOmp.mjs +0 -449
  194. package/dist/web-server/_ssr/index-BPzfADac.mjs +0 -66
  195. package/dist/web-server/_ssr/index-BQE3bF14.mjs +0 -1870
  196. package/dist/web-server/_ssr/index-C5HpvlUP.mjs +0 -190
  197. package/dist/web-server/_ssr/index-C_ZxnypN.mjs +0 -213
  198. package/dist/web-server/_ssr/index-Ca8JFH8f.mjs +0 -612
  199. package/dist/web-server/_ssr/index-DNVESZiA.mjs +0 -513
  200. package/dist/web-server/_ssr/index.mjs +0 -1558
  201. package/dist/web-server/_ssr/input-CqXjTRQg.mjs +0 -20
  202. package/dist/web-server/_ssr/queries-3H_19mUt.mjs +0 -16
  203. package/dist/web-server/_ssr/router-sbsNus0Y.mjs +0 -2093
  204. package/dist/web-server/_ssr/start-HYkvq4Ni.mjs +0 -4
  205. package/dist/web-server/_ssr/switch-usf2F1UM.mjs +0 -33
  206. package/dist/web-server/_ssr/syntax-highlighter-5vezNTce.mjs +0 -62
  207. package/dist/web-server/_ssr/textarea-DfRheWY0.mjs +0 -18
  208. package/dist/web-server/_tanstack-start-manifest_v-DqW-pKEH.mjs +0 -4
  209. package/dist/web-server/index.mjs +0 -597
@@ -1,1120 +0,0 @@
1
- import { r as reactExports, j as jsxRuntimeExports, R as React } from "./react.mjs";
2
- import { i as invariant, a as isDangerousProtocol, e as exactPathTest, r as removeTrailingSlash, h as hasKeys, d as deepEqual, f as functionalUpdate, B as BaseRootRoute, b as BaseRoute, c as isModuleNotFoundError, g as isNotFound, j as getScrollRestorationScriptForRouter, k as rootRouteId, l as isServer, m as isRedirect, n as createNonReactiveReadonlyStore, o as createNonReactiveMutableStore, R as RouterCore, p as escapeHtml, q as isInlinableStylesheet, s as getAssetCrossOrigin, t as resolveManifestAssetLink, u as transformReadableStreamWithRouter, v as transformPipeableStreamWithRouter } from "./tanstack__router-core.mjs";
3
- import { R as ReactDOMServer } from "./react-dom.mjs";
4
- import { PassThrough } from "node:stream";
5
- import { i as isbot } from "./isbot.mjs";
6
- var reactUse = reactExports.use;
7
- function useForwardedRef(ref) {
8
- const innerRef = reactExports.useRef(null);
9
- reactExports.useImperativeHandle(ref, () => innerRef.current, []);
10
- return innerRef;
11
- }
12
- function CatchBoundary(props) {
13
- const errorComponent = props.errorComponent ?? ErrorComponent;
14
- return /* @__PURE__ */ jsxRuntimeExports.jsx(CatchBoundaryImpl, {
15
- getResetKey: props.getResetKey,
16
- onCatch: props.onCatch,
17
- children: ({ error, reset }) => {
18
- if (error) return reactExports.createElement(errorComponent, {
19
- error,
20
- reset
21
- });
22
- return props.children;
23
- }
24
- });
25
- }
26
- var CatchBoundaryImpl = class extends reactExports.Component {
27
- constructor(..._args) {
28
- super(..._args);
29
- this.state = { error: null };
30
- }
31
- static getDerivedStateFromProps(props, state) {
32
- const resetKey = props.getResetKey();
33
- if (state.error && state.resetKey !== resetKey) return {
34
- resetKey,
35
- error: null
36
- };
37
- return { resetKey };
38
- }
39
- static getDerivedStateFromError(error) {
40
- return { error };
41
- }
42
- reset() {
43
- this.setState({ error: null });
44
- }
45
- componentDidCatch(error, errorInfo) {
46
- if (this.props.onCatch) this.props.onCatch(error, errorInfo);
47
- }
48
- render() {
49
- return this.props.children({
50
- error: this.state.error,
51
- reset: () => {
52
- this.reset();
53
- }
54
- });
55
- }
56
- };
57
- function ErrorComponent({ error }) {
58
- const [show, setShow] = reactExports.useState(false);
59
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
60
- style: {
61
- padding: ".5rem",
62
- maxWidth: "100%"
63
- },
64
- children: [
65
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
66
- style: {
67
- display: "flex",
68
- alignItems: "center",
69
- gap: ".5rem"
70
- },
71
- children: [/* @__PURE__ */ jsxRuntimeExports.jsx("strong", {
72
- style: { fontSize: "1rem" },
73
- children: "Something went wrong!"
74
- }), /* @__PURE__ */ jsxRuntimeExports.jsx("button", {
75
- style: {
76
- appearance: "none",
77
- fontSize: ".6em",
78
- border: "1px solid currentColor",
79
- padding: ".1rem .2rem",
80
- fontWeight: "bold",
81
- borderRadius: ".25rem"
82
- },
83
- onClick: () => setShow((d) => !d),
84
- children: show ? "Hide Error" : "Show Error"
85
- })]
86
- }),
87
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { height: ".25rem" } }),
88
- show ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", {
89
- style: {
90
- fontSize: ".7em",
91
- border: "1px solid red",
92
- borderRadius: ".25rem",
93
- padding: ".3rem",
94
- color: "red",
95
- overflow: "auto"
96
- },
97
- children: error.message ? /* @__PURE__ */ jsxRuntimeExports.jsx("code", { children: error.message }) : null
98
- }) }) : null
99
- ]
100
- });
101
- }
102
- function ClientOnly({ children, fallback = null }) {
103
- return useHydrated() ? /* @__PURE__ */ jsxRuntimeExports.jsx(React.Fragment, { children }) : /* @__PURE__ */ jsxRuntimeExports.jsx(React.Fragment, { children: fallback });
104
- }
105
- function useHydrated() {
106
- return React.useSyncExternalStore(subscribe, () => true, () => false);
107
- }
108
- function subscribe() {
109
- return () => {
110
- };
111
- }
112
- var routerContext = reactExports.createContext(null);
113
- function useRouter(opts) {
114
- const value = reactExports.useContext(routerContext);
115
- return value;
116
- }
117
- var matchContext = reactExports.createContext(void 0);
118
- var dummyMatchContext = reactExports.createContext(void 0);
119
- function useMatch(opts) {
120
- const router = useRouter();
121
- const nearestMatchId = reactExports.useContext(opts.from ? dummyMatchContext : matchContext);
122
- const key = opts.from ?? nearestMatchId;
123
- const matchStore = key ? opts.from ? router.stores.getRouteMatchStore(key) : router.stores.matchStores.get(key) : void 0;
124
- {
125
- const match = matchStore?.get();
126
- if ((opts.shouldThrow ?? true) && !match) {
127
- invariant();
128
- }
129
- if (match === void 0) return;
130
- return opts.select ? opts.select(match) : match;
131
- }
132
- }
133
- function useLoaderData(opts) {
134
- return useMatch({
135
- from: opts.from,
136
- strict: opts.strict,
137
- structuralSharing: opts.structuralSharing,
138
- select: (s) => {
139
- return opts.select ? opts.select(s.loaderData) : s.loaderData;
140
- }
141
- });
142
- }
143
- function useLoaderDeps(opts) {
144
- const { select, ...rest } = opts;
145
- return useMatch({
146
- ...rest,
147
- select: (s) => {
148
- return select ? select(s.loaderDeps) : s.loaderDeps;
149
- }
150
- });
151
- }
152
- function useParams(opts) {
153
- return useMatch({
154
- from: opts.from,
155
- shouldThrow: opts.shouldThrow,
156
- structuralSharing: opts.structuralSharing,
157
- strict: opts.strict,
158
- select: (match) => {
159
- const params = opts.strict === false ? match.params : match._strictParams;
160
- return opts.select ? opts.select(params) : params;
161
- }
162
- });
163
- }
164
- function useSearch(opts) {
165
- return useMatch({
166
- from: opts.from,
167
- strict: opts.strict,
168
- shouldThrow: opts.shouldThrow,
169
- structuralSharing: opts.structuralSharing,
170
- select: (match) => {
171
- return opts.select ? opts.select(match.search) : match.search;
172
- }
173
- });
174
- }
175
- function useNavigate(_defaultOpts) {
176
- const router = useRouter();
177
- return reactExports.useCallback((options) => {
178
- return router.navigate({
179
- ...options,
180
- from: options.from ?? _defaultOpts?.from
181
- });
182
- }, [_defaultOpts?.from, router]);
183
- }
184
- function useRouteContext(opts) {
185
- return useMatch({
186
- ...opts,
187
- select: (match) => opts.select ? opts.select(match.context) : match.context
188
- });
189
- }
190
- function useLinkProps(options, forwardedRef) {
191
- const router = useRouter();
192
- const innerRef = useForwardedRef(forwardedRef);
193
- const { activeProps, inactiveProps, activeOptions, to, preload: userPreload, preloadDelay: userPreloadDelay, preloadIntentProximity: _preloadIntentProximity, hashScrollIntoView, replace, startTransition, resetScroll, viewTransition, children, target, disabled, style, className, onClick, onBlur, onFocus, onMouseEnter, onMouseLeave, onTouchStart, ignoreBlocker, params: _params, search: _search, hash: _hash, state: _state, mask: _mask, reloadDocument: _reloadDocument, unsafeRelative: _unsafeRelative, from: _from, _fromLocation, ...propsSafeToSpread } = options;
194
- {
195
- const safeInternal = isSafeInternal(to);
196
- if (typeof to === "string" && !safeInternal && to.indexOf(":") > -1) try {
197
- new URL(to);
198
- if (isDangerousProtocol(to, router.protocolAllowlist)) {
199
- if (false) ;
200
- return {
201
- ...propsSafeToSpread,
202
- ref: innerRef,
203
- href: void 0,
204
- ...children && { children },
205
- ...target && { target },
206
- ...disabled && { disabled },
207
- ...style && { style },
208
- ...className && { className }
209
- };
210
- }
211
- return {
212
- ...propsSafeToSpread,
213
- ref: innerRef,
214
- href: to,
215
- ...children && { children },
216
- ...target && { target },
217
- ...disabled && { disabled },
218
- ...style && { style },
219
- ...className && { className }
220
- };
221
- } catch {
222
- }
223
- const next2 = router.buildLocation({
224
- ...options,
225
- from: options.from
226
- });
227
- const hrefOption2 = getHrefOption(next2.maskedLocation ? next2.maskedLocation.publicHref : next2.publicHref, next2.maskedLocation ? next2.maskedLocation.external : next2.external, router.history, disabled);
228
- const externalLink2 = (() => {
229
- if (hrefOption2?.external) {
230
- if (isDangerousProtocol(hrefOption2.href, router.protocolAllowlist)) {
231
- return;
232
- }
233
- return hrefOption2.href;
234
- }
235
- if (safeInternal) return void 0;
236
- if (typeof to === "string" && to.indexOf(":") > -1) try {
237
- new URL(to);
238
- if (isDangerousProtocol(to, router.protocolAllowlist)) {
239
- if (false) ;
240
- return;
241
- }
242
- return to;
243
- } catch {
244
- }
245
- })();
246
- const isActive2 = (() => {
247
- if (externalLink2) return false;
248
- const currentLocation2 = router.stores.location.get();
249
- const exact = activeOptions?.exact ?? false;
250
- if (exact) {
251
- if (!exactPathTest(currentLocation2.pathname, next2.pathname, router.basepath)) return false;
252
- } else {
253
- const currentPathSplit = removeTrailingSlash(currentLocation2.pathname, router.basepath);
254
- const nextPathSplit = removeTrailingSlash(next2.pathname, router.basepath);
255
- if (!(currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/"))) return false;
256
- }
257
- if (activeOptions?.includeSearch ?? true) {
258
- if (currentLocation2.search !== next2.search) {
259
- const currentSearchEmpty = !currentLocation2.search || typeof currentLocation2.search === "object" && !hasKeys(currentLocation2.search);
260
- const nextSearchEmpty = !next2.search || typeof next2.search === "object" && !hasKeys(next2.search);
261
- if (!(currentSearchEmpty && nextSearchEmpty)) {
262
- if (!deepEqual(currentLocation2.search, next2.search, {
263
- partial: !exact,
264
- ignoreUndefined: !activeOptions?.explicitUndefined
265
- })) return false;
266
- }
267
- }
268
- }
269
- if (activeOptions?.includeHash) return false;
270
- return true;
271
- })();
272
- if (externalLink2) return {
273
- ...propsSafeToSpread,
274
- ref: innerRef,
275
- href: externalLink2,
276
- ...children && { children },
277
- ...target && { target },
278
- ...disabled && { disabled },
279
- ...style && { style },
280
- ...className && { className }
281
- };
282
- const resolvedActiveProps2 = isActive2 ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
283
- const resolvedInactiveProps2 = isActive2 ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
284
- const resolvedStyle2 = (() => {
285
- const baseStyle = style;
286
- const activeStyle = resolvedActiveProps2.style;
287
- const inactiveStyle = resolvedInactiveProps2.style;
288
- if (!baseStyle && !activeStyle && !inactiveStyle) return;
289
- if (baseStyle && !activeStyle && !inactiveStyle) return baseStyle;
290
- if (!baseStyle && activeStyle && !inactiveStyle) return activeStyle;
291
- if (!baseStyle && !activeStyle && inactiveStyle) return inactiveStyle;
292
- return {
293
- ...baseStyle,
294
- ...activeStyle,
295
- ...inactiveStyle
296
- };
297
- })();
298
- const resolvedClassName2 = (() => {
299
- const baseClassName = className;
300
- const activeClassName = resolvedActiveProps2.className;
301
- const inactiveClassName = resolvedInactiveProps2.className;
302
- if (!baseClassName && !activeClassName && !inactiveClassName) return "";
303
- let out = "";
304
- if (baseClassName) out = baseClassName;
305
- if (activeClassName) out = out ? `${out} ${activeClassName}` : activeClassName;
306
- if (inactiveClassName) out = out ? `${out} ${inactiveClassName}` : inactiveClassName;
307
- return out;
308
- })();
309
- return {
310
- ...propsSafeToSpread,
311
- ...resolvedActiveProps2,
312
- ...resolvedInactiveProps2,
313
- href: hrefOption2?.href,
314
- ref: innerRef,
315
- disabled: !!disabled,
316
- target,
317
- ...resolvedStyle2 && { style: resolvedStyle2 },
318
- ...resolvedClassName2 && { className: resolvedClassName2 },
319
- ...disabled && STATIC_DISABLED_PROPS,
320
- ...isActive2 && STATIC_ACTIVE_PROPS
321
- };
322
- }
323
- }
324
- var STATIC_EMPTY_OBJECT = {};
325
- var STATIC_ACTIVE_OBJECT = { className: "active" };
326
- var STATIC_DISABLED_PROPS = {
327
- role: "link",
328
- "aria-disabled": true
329
- };
330
- var STATIC_ACTIVE_PROPS = {
331
- "data-status": "active",
332
- "aria-current": "page"
333
- };
334
- function getHrefOption(publicHref, external, history, disabled) {
335
- if (disabled) return void 0;
336
- if (external) return {
337
- href: publicHref,
338
- external: true
339
- };
340
- return {
341
- href: history.createHref(publicHref) || "/",
342
- external: false
343
- };
344
- }
345
- function isSafeInternal(to) {
346
- if (typeof to !== "string") return false;
347
- const zero = to.charCodeAt(0);
348
- if (zero === 47) return to.charCodeAt(1) !== 47;
349
- return zero === 46;
350
- }
351
- var Link = reactExports.forwardRef((props, ref) => {
352
- const { _asChild, ...rest } = props;
353
- const { type: _type, ...linkProps } = useLinkProps(rest, ref);
354
- const children = typeof rest.children === "function" ? rest.children({ isActive: linkProps["data-status"] === "active" }) : rest.children;
355
- if (!_asChild) {
356
- const { disabled: _, ...rest2 } = linkProps;
357
- return reactExports.createElement("a", rest2, children);
358
- }
359
- return reactExports.createElement(_asChild, linkProps, children);
360
- });
361
- var Route = class extends BaseRoute {
362
- /**
363
- * @deprecated Use the `createRoute` function instead.
364
- */
365
- constructor(options) {
366
- super(options);
367
- this.useMatch = (opts) => {
368
- return useMatch({
369
- select: opts?.select,
370
- from: this.id,
371
- structuralSharing: opts?.structuralSharing
372
- });
373
- };
374
- this.useRouteContext = (opts) => {
375
- return useRouteContext({
376
- ...opts,
377
- from: this.id
378
- });
379
- };
380
- this.useSearch = (opts) => {
381
- return useSearch({
382
- select: opts?.select,
383
- structuralSharing: opts?.structuralSharing,
384
- from: this.id
385
- });
386
- };
387
- this.useParams = (opts) => {
388
- return useParams({
389
- select: opts?.select,
390
- structuralSharing: opts?.structuralSharing,
391
- from: this.id
392
- });
393
- };
394
- this.useLoaderDeps = (opts) => {
395
- return useLoaderDeps({
396
- ...opts,
397
- from: this.id
398
- });
399
- };
400
- this.useLoaderData = (opts) => {
401
- return useLoaderData({
402
- ...opts,
403
- from: this.id
404
- });
405
- };
406
- this.useNavigate = () => {
407
- return useNavigate({ from: this.fullPath });
408
- };
409
- this.Link = React.forwardRef((props, ref) => {
410
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Link, {
411
- ref,
412
- from: this.fullPath,
413
- ...props
414
- });
415
- });
416
- }
417
- };
418
- function createRoute(options) {
419
- return new Route(options);
420
- }
421
- var RootRoute = class extends BaseRootRoute {
422
- /**
423
- * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
424
- */
425
- constructor(options) {
426
- super(options);
427
- this.useMatch = (opts) => {
428
- return useMatch({
429
- select: opts?.select,
430
- from: this.id,
431
- structuralSharing: opts?.structuralSharing
432
- });
433
- };
434
- this.useRouteContext = (opts) => {
435
- return useRouteContext({
436
- ...opts,
437
- from: this.id
438
- });
439
- };
440
- this.useSearch = (opts) => {
441
- return useSearch({
442
- select: opts?.select,
443
- structuralSharing: opts?.structuralSharing,
444
- from: this.id
445
- });
446
- };
447
- this.useParams = (opts) => {
448
- return useParams({
449
- select: opts?.select,
450
- structuralSharing: opts?.structuralSharing,
451
- from: this.id
452
- });
453
- };
454
- this.useLoaderDeps = (opts) => {
455
- return useLoaderDeps({
456
- ...opts,
457
- from: this.id
458
- });
459
- };
460
- this.useLoaderData = (opts) => {
461
- return useLoaderData({
462
- ...opts,
463
- from: this.id
464
- });
465
- };
466
- this.useNavigate = () => {
467
- return useNavigate({ from: this.fullPath });
468
- };
469
- this.Link = React.forwardRef((props, ref) => {
470
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Link, {
471
- ref,
472
- from: this.fullPath,
473
- ...props
474
- });
475
- });
476
- }
477
- };
478
- function createRootRoute(options) {
479
- return new RootRoute(options);
480
- }
481
- function createFileRoute(path) {
482
- return new FileRoute(path, { silent: true }).createRoute;
483
- }
484
- var FileRoute = class {
485
- constructor(path, _opts) {
486
- this.path = path;
487
- this.createRoute = (options) => {
488
- const route = createRoute(options);
489
- route.isRoot = false;
490
- return route;
491
- };
492
- this.silent = _opts?.silent;
493
- }
494
- };
495
- function lazyRouteComponent(importer, exportName) {
496
- let loadPromise;
497
- let comp;
498
- let error;
499
- let reload;
500
- const load = () => {
501
- if (!loadPromise) loadPromise = importer().then((res) => {
502
- loadPromise = void 0;
503
- comp = res[exportName];
504
- }).catch((err) => {
505
- error = err;
506
- if (isModuleNotFoundError(error)) {
507
- if (error instanceof Error && typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
508
- const storageKey = `tanstack_router_reload:${error.message}`;
509
- if (!sessionStorage.getItem(storageKey)) {
510
- sessionStorage.setItem(storageKey, "1");
511
- reload = true;
512
- }
513
- }
514
- }
515
- });
516
- return loadPromise;
517
- };
518
- const lazyComp = function Lazy(props) {
519
- if (reload) {
520
- window.location.reload();
521
- throw new Promise(() => {
522
- });
523
- }
524
- if (error) throw error;
525
- if (!comp) if (reactUse) reactUse(load());
526
- else throw load();
527
- return reactExports.createElement(comp, props);
528
- };
529
- lazyComp.preload = load;
530
- return lazyComp;
531
- }
532
- function CatchNotFound(props) {
533
- const router = useRouter();
534
- {
535
- const resetKey = `not-found-${router.stores.location.get().pathname}-${router.stores.status.get()}`;
536
- return /* @__PURE__ */ jsxRuntimeExports.jsx(CatchBoundary, {
537
- getResetKey: () => resetKey,
538
- onCatch: (error, errorInfo) => {
539
- if (isNotFound(error)) props.onCatch?.(error, errorInfo);
540
- else throw error;
541
- },
542
- errorComponent: ({ error }) => {
543
- if (isNotFound(error)) return props.fallback?.(error);
544
- else throw error;
545
- },
546
- children: props.children
547
- });
548
- }
549
- }
550
- function DefaultGlobalNotFound() {
551
- return /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Not Found" });
552
- }
553
- function ScriptOnce({ children }) {
554
- const router = useRouter();
555
- return /* @__PURE__ */ jsxRuntimeExports.jsx("script", {
556
- nonce: router.options.ssr?.nonce,
557
- dangerouslySetInnerHTML: { __html: children + ";document.currentScript.remove()" }
558
- });
559
- }
560
- function SafeFragment(props) {
561
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: props.children });
562
- }
563
- function renderRouteNotFound(router, route, data) {
564
- if (!route.options.notFoundComponent) {
565
- if (router.options.defaultNotFoundComponent) return /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.defaultNotFoundComponent, { ...data });
566
- return /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultGlobalNotFound, {});
567
- }
568
- return /* @__PURE__ */ jsxRuntimeExports.jsx(route.options.notFoundComponent, { ...data });
569
- }
570
- function ScrollRestoration() {
571
- const script = getScrollRestorationScriptForRouter(useRouter());
572
- if (!script) return null;
573
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ScriptOnce, { children: script });
574
- }
575
- var Match = reactExports.memo(function MatchImpl({ matchId }) {
576
- const router = useRouter();
577
- {
578
- const match2 = router.stores.matchStores.get(matchId)?.get();
579
- if (!match2) {
580
- invariant();
581
- }
582
- const routeId = match2.routeId;
583
- const parentRouteId = router.routesById[routeId].parentRoute?.id;
584
- return /* @__PURE__ */ jsxRuntimeExports.jsx(MatchView, {
585
- router,
586
- matchId,
587
- resetKey: router.stores.loadedAt.get(),
588
- matchState: {
589
- routeId,
590
- ssr: match2.ssr,
591
- _displayPending: match2._displayPending,
592
- parentRouteId
593
- }
594
- });
595
- }
596
- });
597
- function MatchView({ router, matchId, resetKey, matchState }) {
598
- const route = router.routesById[matchState.routeId];
599
- const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
600
- const pendingElement = PendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(PendingComponent, {}) : null;
601
- const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
602
- const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
603
- const routeNotFoundComponent = route.isRoot ? route.options.notFoundComponent ?? router.options.notFoundRoute?.options.component : route.options.notFoundComponent;
604
- const resolvedNoSsr = matchState.ssr === false || matchState.ssr === "data-only";
605
- const ResolvedSuspenseBoundary = (!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) && (route.options.wrapInSuspense ?? PendingComponent ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? reactExports.Suspense : SafeFragment;
606
- const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
607
- const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
608
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment, { children: [/* @__PURE__ */ jsxRuntimeExports.jsx(matchContext.Provider, {
609
- value: matchId,
610
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResolvedSuspenseBoundary, {
611
- fallback: pendingElement,
612
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResolvedCatchBoundary, {
613
- getResetKey: () => resetKey,
614
- errorComponent: routeErrorComponent || ErrorComponent,
615
- onCatch: (error, errorInfo) => {
616
- if (isNotFound(error)) {
617
- error.routeId ??= matchState.routeId;
618
- throw error;
619
- }
620
- routeOnCatch?.(error, errorInfo);
621
- },
622
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResolvedNotFoundBoundary, {
623
- fallback: (error) => {
624
- error.routeId ??= matchState.routeId;
625
- if (!routeNotFoundComponent || error.routeId && error.routeId !== matchState.routeId || !error.routeId && !route.isRoot) throw error;
626
- return reactExports.createElement(routeNotFoundComponent, error);
627
- },
628
- children: resolvedNoSsr || matchState._displayPending ? /* @__PURE__ */ jsxRuntimeExports.jsx(ClientOnly, {
629
- fallback: pendingElement,
630
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(MatchInner, { matchId })
631
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(MatchInner, { matchId })
632
- })
633
- })
634
- })
635
- }), matchState.parentRouteId === rootRouteId ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [/* @__PURE__ */ jsxRuntimeExports.jsx(OnRendered, { resetKey }), router.options.scrollRestoration && isServer ? /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollRestoration, {}) : null] }) : null] });
636
- }
637
- function OnRendered({ resetKey }) {
638
- useRouter();
639
- return null;
640
- }
641
- var MatchInner = reactExports.memo(function MatchInnerImpl({ matchId }) {
642
- const router = useRouter();
643
- const getMatchPromise = (match2, key2) => {
644
- return router.getMatch(match2.id)?._nonReactive[key2] ?? match2._nonReactive[key2];
645
- };
646
- {
647
- const match2 = router.stores.matchStores.get(matchId)?.get();
648
- if (!match2) {
649
- invariant();
650
- }
651
- const routeId2 = match2.routeId;
652
- const route2 = router.routesById[routeId2];
653
- const remountDeps = (router.routesById[routeId2].options.remountDeps ?? router.options.defaultRemountDeps)?.({
654
- routeId: routeId2,
655
- loaderDeps: match2.loaderDeps,
656
- params: match2._strictParams,
657
- search: match2._strictSearch
658
- });
659
- const key2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
660
- const Comp = route2.options.component ?? router.options.defaultComponent;
661
- const out2 = Comp ? /* @__PURE__ */ jsxRuntimeExports.jsx(Comp, {}, key2) : /* @__PURE__ */ jsxRuntimeExports.jsx(Outlet, {});
662
- if (match2._displayPending) throw getMatchPromise(match2, "displayPendingPromise");
663
- if (match2._forcePending) throw getMatchPromise(match2, "minPendingPromise");
664
- if (match2.status === "pending") throw getMatchPromise(match2, "loadPromise");
665
- if (match2.status === "notFound") {
666
- if (!isNotFound(match2.error)) {
667
- invariant();
668
- }
669
- return renderRouteNotFound(router, route2, match2.error);
670
- }
671
- if (match2.status === "redirected") {
672
- if (!isRedirect(match2.error)) {
673
- invariant();
674
- }
675
- throw getMatchPromise(match2, "loadPromise");
676
- }
677
- if (match2.status === "error") return /* @__PURE__ */ jsxRuntimeExports.jsx((route2.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent, {
678
- error: match2.error,
679
- reset: void 0,
680
- info: { componentStack: "" }
681
- });
682
- return out2;
683
- }
684
- });
685
- var Outlet = reactExports.memo(function OutletImpl() {
686
- const router = useRouter();
687
- const matchId = reactExports.useContext(matchContext);
688
- let routeId;
689
- let parentGlobalNotFound = false;
690
- let childMatchId;
691
- {
692
- const matches = router.stores.matches.get();
693
- const parentIndex = matchId ? matches.findIndex((match) => match.id === matchId) : -1;
694
- const parentMatch = parentIndex >= 0 ? matches[parentIndex] : void 0;
695
- routeId = parentMatch?.routeId;
696
- parentGlobalNotFound = parentMatch?.globalNotFound ?? false;
697
- childMatchId = parentIndex >= 0 ? matches[parentIndex + 1]?.id : void 0;
698
- }
699
- const route = routeId ? router.routesById[routeId] : void 0;
700
- const pendingElement = router.options.defaultPendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.defaultPendingComponent, {}) : null;
701
- if (parentGlobalNotFound) {
702
- if (!route) {
703
- invariant();
704
- }
705
- return renderRouteNotFound(router, route, void 0);
706
- }
707
- if (!childMatchId) return null;
708
- const nextMatch = /* @__PURE__ */ jsxRuntimeExports.jsx(Match, { matchId: childMatchId });
709
- if (routeId === rootRouteId) return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, {
710
- fallback: pendingElement,
711
- children: nextMatch
712
- });
713
- return nextMatch;
714
- });
715
- function Matches() {
716
- const router = useRouter();
717
- const PendingComponent = router.routesById[rootRouteId].options.pendingComponent ?? router.options.defaultPendingComponent;
718
- const pendingElement = PendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(PendingComponent, {}) : null;
719
- const inner = /* @__PURE__ */ jsxRuntimeExports.jsxs(SafeFragment, {
720
- fallback: pendingElement,
721
- children: [false, /* @__PURE__ */ jsxRuntimeExports.jsx(MatchesInner, {})]
722
- });
723
- return router.options.InnerWrap ? /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.InnerWrap, { children: inner }) : inner;
724
- }
725
- function MatchesInner() {
726
- const router = useRouter();
727
- const matchId = router.stores.firstId.get();
728
- const resetKey = router.stores.loadedAt.get();
729
- const matchComponent = matchId ? /* @__PURE__ */ jsxRuntimeExports.jsx(Match, { matchId }) : null;
730
- return /* @__PURE__ */ jsxRuntimeExports.jsx(matchContext.Provider, {
731
- value: matchId,
732
- children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ jsxRuntimeExports.jsx(CatchBoundary, {
733
- getResetKey: () => resetKey,
734
- errorComponent: ErrorComponent,
735
- onCatch: void 0,
736
- children: matchComponent
737
- })
738
- });
739
- }
740
- var getStoreFactory = (opts) => {
741
- return {
742
- createMutableStore: createNonReactiveMutableStore,
743
- createReadonlyStore: createNonReactiveReadonlyStore,
744
- batch: (fn) => fn()
745
- };
746
- };
747
- var createRouter = (options) => {
748
- return new Router(options);
749
- };
750
- var Router = class extends RouterCore {
751
- constructor(options) {
752
- super(options, getStoreFactory);
753
- }
754
- };
755
- function RouterContextProvider({ router, children, ...rest }) {
756
- if (hasKeys(rest)) router.update({
757
- ...router.options,
758
- ...rest,
759
- context: {
760
- ...router.options.context,
761
- ...rest.context
762
- }
763
- });
764
- const provider = /* @__PURE__ */ jsxRuntimeExports.jsx(routerContext.Provider, {
765
- value: router,
766
- children
767
- });
768
- if (router.options.Wrap) return /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.Wrap, { children: provider });
769
- return provider;
770
- }
771
- function RouterProvider({ router, ...rest }) {
772
- return /* @__PURE__ */ jsxRuntimeExports.jsx(RouterContextProvider, {
773
- router,
774
- ...rest,
775
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Matches, {})
776
- });
777
- }
778
- function useLocation(opts) {
779
- const router = useRouter();
780
- {
781
- const location = router.stores.location.get();
782
- return location;
783
- }
784
- }
785
- function Asset(asset) {
786
- const { attrs, children, nonce } = asset;
787
- switch (asset.tag) {
788
- case "title":
789
- return /* @__PURE__ */ jsxRuntimeExports.jsx("title", {
790
- ...attrs,
791
- suppressHydrationWarning: true,
792
- children
793
- });
794
- case "meta":
795
- return /* @__PURE__ */ jsxRuntimeExports.jsx("meta", {
796
- ...attrs,
797
- suppressHydrationWarning: true
798
- });
799
- case "link":
800
- return /* @__PURE__ */ jsxRuntimeExports.jsx("link", {
801
- ...attrs,
802
- precedence: attrs?.precedence ?? (attrs?.rel === "stylesheet" ? "default" : void 0),
803
- nonce,
804
- suppressHydrationWarning: true
805
- });
806
- case "style":
807
- if (asset.inlineCss && false) ;
808
- return /* @__PURE__ */ jsxRuntimeExports.jsx("style", {
809
- ...attrs,
810
- dangerouslySetInnerHTML: { __html: children },
811
- nonce
812
- });
813
- case "script":
814
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Script, {
815
- attrs,
816
- children
817
- });
818
- default:
819
- return null;
820
- }
821
- }
822
- function Script({ attrs, children }) {
823
- useRouter();
824
- useHydrated();
825
- const dataScript = typeof attrs?.type === "string" && attrs.type !== "" && attrs.type !== "text/javascript" && attrs.type !== "module";
826
- reactExports.useEffect(() => {
827
- if (dataScript) return;
828
- if (attrs?.src) {
829
- const normSrc = (() => {
830
- try {
831
- const base = document.baseURI || window.location.href;
832
- return new URL(attrs.src, base).href;
833
- } catch {
834
- return attrs.src;
835
- }
836
- })();
837
- if (Array.from(document.querySelectorAll("script[src]")).find((el) => el.src === normSrc)) return;
838
- const script = document.createElement("script");
839
- for (const [key, value] of Object.entries(attrs)) if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
840
- document.head.appendChild(script);
841
- return () => {
842
- if (script.parentNode) script.parentNode.removeChild(script);
843
- };
844
- }
845
- if (typeof children === "string") {
846
- const typeAttr = typeof attrs?.type === "string" ? attrs.type : "text/javascript";
847
- const nonceAttr = typeof attrs?.nonce === "string" ? attrs.nonce : void 0;
848
- if (Array.from(document.querySelectorAll("script:not([src])")).find((el) => {
849
- if (!(el instanceof HTMLScriptElement)) return false;
850
- const sType = el.getAttribute("type") ?? "text/javascript";
851
- const sNonce = el.getAttribute("nonce") ?? void 0;
852
- return el.textContent === children && sType === typeAttr && sNonce === nonceAttr;
853
- })) return;
854
- const script = document.createElement("script");
855
- script.textContent = children;
856
- if (attrs) {
857
- for (const [key, value] of Object.entries(attrs)) if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
858
- }
859
- document.head.appendChild(script);
860
- return () => {
861
- if (script.parentNode) script.parentNode.removeChild(script);
862
- };
863
- }
864
- }, [
865
- attrs,
866
- children,
867
- dataScript
868
- ]);
869
- {
870
- if (attrs?.src) return /* @__PURE__ */ jsxRuntimeExports.jsx("script", {
871
- ...attrs,
872
- suppressHydrationWarning: true
873
- });
874
- if (typeof children === "string") return /* @__PURE__ */ jsxRuntimeExports.jsx("script", {
875
- ...attrs,
876
- dangerouslySetInnerHTML: { __html: children },
877
- suppressHydrationWarning: true
878
- });
879
- return null;
880
- }
881
- }
882
- function buildTagsFromMatches(router, nonce, matches, assetCrossOrigin) {
883
- const routeMeta = matches.map((match) => match.meta).filter(Boolean);
884
- const resultMeta = [];
885
- const metaByAttribute = {};
886
- let title;
887
- for (let i = routeMeta.length - 1; i >= 0; i--) {
888
- const metas = routeMeta[i];
889
- for (let j = metas.length - 1; j >= 0; j--) {
890
- const m = metas[j];
891
- if (!m) continue;
892
- if (m.title) {
893
- if (!title) title = {
894
- tag: "title",
895
- children: m.title
896
- };
897
- } else if ("script:ld+json" in m) try {
898
- const json = JSON.stringify(m["script:ld+json"]);
899
- resultMeta.push({
900
- tag: "script",
901
- attrs: { type: "application/ld+json" },
902
- children: escapeHtml(json)
903
- });
904
- } catch {
905
- }
906
- else {
907
- const attribute = m.name ?? m.property;
908
- if (attribute) if (metaByAttribute[attribute]) continue;
909
- else metaByAttribute[attribute] = true;
910
- resultMeta.push({
911
- tag: "meta",
912
- attrs: {
913
- ...m,
914
- nonce
915
- }
916
- });
917
- }
918
- }
919
- }
920
- if (title) resultMeta.push(title);
921
- if (nonce) resultMeta.push({
922
- tag: "meta",
923
- attrs: {
924
- property: "csp-nonce",
925
- content: nonce
926
- }
927
- });
928
- resultMeta.reverse();
929
- const constructedLinks = matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
930
- tag: "link",
931
- attrs: {
932
- ...link,
933
- nonce
934
- }
935
- }));
936
- const manifest = router.ssr?.manifest;
937
- const assetLinks = matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).flatMap((asset) => {
938
- if (asset.tag === "link") {
939
- if (isInlinableStylesheet(manifest, asset)) return [];
940
- return [{
941
- tag: "link",
942
- attrs: {
943
- ...asset.attrs,
944
- crossOrigin: getAssetCrossOrigin(assetCrossOrigin, "stylesheet") ?? asset.attrs?.crossOrigin,
945
- suppressHydrationWarning: true,
946
- nonce
947
- }
948
- }];
949
- }
950
- if (asset.tag === "style") return [{
951
- tag: "style",
952
- attrs: {
953
- ...asset.attrs,
954
- nonce
955
- },
956
- children: asset.children,
957
- ...asset.inlineCss ? { inlineCss: true } : {}
958
- }];
959
- return [];
960
- });
961
- const preloadLinks = [];
962
- matches.map((match) => router.looseRoutesById[match.routeId]).forEach((route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
963
- const preloadLink = resolveManifestAssetLink(preload);
964
- preloadLinks.push({
965
- tag: "link",
966
- attrs: {
967
- rel: "modulepreload",
968
- href: preloadLink.href,
969
- crossOrigin: getAssetCrossOrigin(assetCrossOrigin, "modulepreload") ?? preloadLink.crossOrigin,
970
- nonce
971
- }
972
- });
973
- }));
974
- const styles = matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
975
- tag: "style",
976
- attrs: {
977
- ...attrs,
978
- nonce
979
- },
980
- children
981
- }));
982
- const headScripts = matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
983
- tag: "script",
984
- attrs: {
985
- ...script,
986
- nonce
987
- },
988
- children
989
- }));
990
- return uniqBy([
991
- ...resultMeta,
992
- ...preloadLinks,
993
- ...constructedLinks,
994
- ...assetLinks,
995
- ...styles,
996
- ...headScripts
997
- ], (d) => JSON.stringify(d));
998
- }
999
- var useTags = (assetCrossOrigin) => {
1000
- const router = useRouter();
1001
- const nonce = router.options.ssr?.nonce;
1002
- return buildTagsFromMatches(router, nonce, router.stores.matches.get(), assetCrossOrigin);
1003
- };
1004
- function uniqBy(arr, fn) {
1005
- const seen = /* @__PURE__ */ new Set();
1006
- return arr.filter((item) => {
1007
- const key = fn(item);
1008
- if (seen.has(key)) return false;
1009
- seen.add(key);
1010
- return true;
1011
- });
1012
- }
1013
- function HeadContent(props) {
1014
- const tags = useTags(props.assetCrossOrigin);
1015
- const nonce = useRouter().options.ssr?.nonce;
1016
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: tags.map((tag) => /* @__PURE__ */ reactExports.createElement(Asset, {
1017
- ...tag,
1018
- key: `tsr-meta-${JSON.stringify(tag)}`,
1019
- nonce
1020
- })) });
1021
- }
1022
- var Scripts = () => {
1023
- const router = useRouter();
1024
- const nonce = router.options.ssr?.nonce;
1025
- const getAssetScripts = (matches) => {
1026
- const assetScripts = [];
1027
- const manifest = router.ssr?.manifest;
1028
- if (!manifest) return [];
1029
- matches.map((match) => router.looseRoutesById[match.routeId]).forEach((route) => manifest.routes[route.id]?.assets?.filter((d) => d.tag === "script").forEach((asset) => {
1030
- assetScripts.push({
1031
- tag: "script",
1032
- attrs: {
1033
- ...asset.attrs,
1034
- nonce
1035
- },
1036
- children: asset.children
1037
- });
1038
- }));
1039
- return assetScripts;
1040
- };
1041
- const getScripts = (matches) => matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
1042
- tag: "script",
1043
- attrs: {
1044
- ...script,
1045
- suppressHydrationWarning: true,
1046
- nonce
1047
- },
1048
- children
1049
- }));
1050
- {
1051
- const activeMatches = router.stores.matches.get();
1052
- const assetScripts = getAssetScripts(activeMatches);
1053
- return renderScripts(router, getScripts(activeMatches), assetScripts);
1054
- }
1055
- };
1056
- function renderScripts(router, scripts, assetScripts) {
1057
- let serverBufferedScript = void 0;
1058
- if (router.serverSsr) serverBufferedScript = router.serverSsr.takeBufferedScripts();
1059
- const allScripts = [...scripts, ...assetScripts];
1060
- if (serverBufferedScript) allScripts.unshift(serverBufferedScript);
1061
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: allScripts.map((asset, i) => /* @__PURE__ */ reactExports.createElement(Asset, {
1062
- ...asset,
1063
- key: `tsr-scripts-${asset.tag}-${i}`
1064
- })) });
1065
- }
1066
- var renderRouterToStream = async ({ request, router, responseHeaders, children }) => {
1067
- if (typeof ReactDOMServer.renderToReadableStream === "function") {
1068
- const stream = await ReactDOMServer.renderToReadableStream(children, {
1069
- signal: request.signal,
1070
- nonce: router.options.ssr?.nonce,
1071
- progressiveChunkSize: Number.POSITIVE_INFINITY
1072
- });
1073
- if (isbot(request.headers.get("User-Agent"))) await stream.allReady;
1074
- const responseStream = transformReadableStreamWithRouter(router, stream);
1075
- return new Response(responseStream, {
1076
- status: router.stores.statusCode.get(),
1077
- headers: responseHeaders
1078
- });
1079
- }
1080
- if (typeof ReactDOMServer.renderToPipeableStream === "function") {
1081
- const reactAppPassthrough = new PassThrough();
1082
- try {
1083
- const pipeable = ReactDOMServer.renderToPipeableStream(children, {
1084
- nonce: router.options.ssr?.nonce,
1085
- progressiveChunkSize: Number.POSITIVE_INFINITY,
1086
- ...isbot(request.headers.get("User-Agent")) ? { onAllReady() {
1087
- pipeable.pipe(reactAppPassthrough);
1088
- } } : { onShellReady() {
1089
- pipeable.pipe(reactAppPassthrough);
1090
- } },
1091
- onError: (error, info) => {
1092
- console.error("Error in renderToPipeableStream:", error, info);
1093
- if (!reactAppPassthrough.destroyed) reactAppPassthrough.destroy(error instanceof Error ? error : new Error(String(error)));
1094
- }
1095
- });
1096
- } catch (e) {
1097
- console.error("Error in renderToPipeableStream:", e);
1098
- reactAppPassthrough.destroy(e instanceof Error ? e : new Error(String(e)));
1099
- }
1100
- const responseStream = transformPipeableStreamWithRouter(router, reactAppPassthrough);
1101
- return new Response(responseStream, {
1102
- status: router.stores.statusCode.get(),
1103
- headers: responseHeaders
1104
- });
1105
- }
1106
- throw new Error("No renderToReadableStream or renderToPipeableStream found in react-dom/server. Ensure you are using a version of react-dom that supports streaming.");
1107
- };
1108
- export {
1109
- HeadContent as H,
1110
- Link as L,
1111
- RouterProvider as R,
1112
- Scripts as S,
1113
- createRootRoute as a,
1114
- createFileRoute as b,
1115
- createRouter as c,
1116
- useNavigate as d,
1117
- lazyRouteComponent as l,
1118
- renderRouterToStream as r,
1119
- useLocation as u
1120
- };