@claude-sessions/web 0.4.5 → 0.4.6

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 (175) hide show
  1. package/build/client/_app/immutable/assets/0.cQgYior5.css +1 -0
  2. package/build/client/_app/immutable/assets/0.cQgYior5.css.br +0 -0
  3. package/build/client/_app/immutable/assets/0.cQgYior5.css.gz +0 -0
  4. package/build/client/_app/immutable/chunks/B8g5xi4b.js +1 -0
  5. package/build/client/_app/immutable/chunks/B8g5xi4b.js.br +0 -0
  6. package/build/client/_app/immutable/chunks/B8g5xi4b.js.gz +0 -0
  7. package/build/client/_app/immutable/chunks/CG99hqDQ.js +2 -0
  8. package/build/client/_app/immutable/chunks/CG99hqDQ.js.br +0 -0
  9. package/build/client/_app/immutable/chunks/CG99hqDQ.js.gz +0 -0
  10. package/build/client/_app/immutable/chunks/CiIZzKcO.js +1 -0
  11. package/build/client/_app/immutable/chunks/CiIZzKcO.js.br +0 -0
  12. package/build/client/_app/immutable/chunks/CiIZzKcO.js.gz +0 -0
  13. package/build/client/_app/immutable/chunks/{BmH_exS6.js → DDmWtjsj.js} +1 -1
  14. package/build/client/_app/immutable/chunks/DDmWtjsj.js.br +0 -0
  15. package/build/client/_app/immutable/chunks/DDmWtjsj.js.gz +0 -0
  16. package/build/client/_app/immutable/chunks/DWa7QuMS.js +1 -0
  17. package/build/client/_app/immutable/chunks/DWa7QuMS.js.br +0 -0
  18. package/build/client/_app/immutable/chunks/DWa7QuMS.js.gz +0 -0
  19. package/build/client/_app/immutable/chunks/Dw50LpzA.js +1 -0
  20. package/build/client/_app/immutable/chunks/Dw50LpzA.js.br +0 -0
  21. package/build/client/_app/immutable/chunks/Dw50LpzA.js.gz +0 -0
  22. package/build/client/_app/immutable/chunks/aZi3OCpL.js +96 -0
  23. package/build/client/_app/immutable/chunks/aZi3OCpL.js.br +0 -0
  24. package/build/client/_app/immutable/chunks/aZi3OCpL.js.gz +0 -0
  25. package/build/client/_app/immutable/entry/app.CYY1PZCN.js +2 -0
  26. package/build/client/_app/immutable/entry/app.CYY1PZCN.js.br +0 -0
  27. package/build/client/_app/immutable/entry/app.CYY1PZCN.js.gz +0 -0
  28. package/build/client/_app/immutable/entry/start.D84fuMw9.js +1 -0
  29. package/build/client/_app/immutable/entry/start.D84fuMw9.js.br +2 -0
  30. package/build/client/_app/immutable/entry/start.D84fuMw9.js.gz +0 -0
  31. package/build/client/_app/immutable/nodes/0.B2uv-WBM.js +1 -0
  32. package/build/client/_app/immutable/nodes/0.B2uv-WBM.js.br +0 -0
  33. package/build/client/_app/immutable/nodes/0.B2uv-WBM.js.gz +0 -0
  34. package/build/client/_app/immutable/nodes/1.BoxEAqK6.js +1 -0
  35. package/build/client/_app/immutable/nodes/1.BoxEAqK6.js.br +3 -0
  36. package/build/client/_app/immutable/nodes/1.BoxEAqK6.js.gz +0 -0
  37. package/build/client/_app/immutable/nodes/{2.yd31CwaR.js → 2.mKAMmHlh.js} +1 -1
  38. package/build/client/_app/immutable/nodes/2.mKAMmHlh.js.br +0 -0
  39. package/build/client/_app/immutable/nodes/2.mKAMmHlh.js.gz +0 -0
  40. package/build/client/_app/immutable/nodes/3.Dj8iwfME.js +4 -0
  41. package/build/client/_app/immutable/nodes/3.Dj8iwfME.js.br +0 -0
  42. package/build/client/_app/immutable/nodes/3.Dj8iwfME.js.gz +0 -0
  43. package/build/client/_app/version.json +1 -1
  44. package/build/client/_app/version.json.br +0 -0
  45. package/build/client/_app/version.json.gz +0 -0
  46. package/build/handler.js +290 -228
  47. package/build/server/chunks/0-DChhR3gd.js +17 -0
  48. package/build/server/chunks/{0-D3SWM5E2.js.map → 0-DChhR3gd.js.map} +1 -1
  49. package/build/server/chunks/1-BBSPd3nB.js +9 -0
  50. package/build/server/chunks/{1-CXfgX4ux.js.map → 1-BBSPd3nB.js.map} +1 -1
  51. package/build/server/chunks/2-C20RW_lJ.js +9 -0
  52. package/build/server/chunks/{2-MV5uDYTL.js.map → 2-C20RW_lJ.js.map} +1 -1
  53. package/build/server/chunks/3-D3wL2YSE.js +9 -0
  54. package/build/server/chunks/{3-CsnDqfbG.js.map → 3-D3wL2YSE.js.map} +1 -1
  55. package/build/server/chunks/{InputModal-B9P0hP_j.js → InputModal-1qJGryUa.js} +6 -7
  56. package/build/server/chunks/InputModal-1qJGryUa.js.map +1 -0
  57. package/build/server/chunks/{Toast-DWQ-hmJu.js → Toast-C9b_dWm4.js} +7 -8
  58. package/build/server/chunks/Toast-C9b_dWm4.js.map +1 -0
  59. package/build/server/chunks/_layout.svelte-CdDMC1RI.js +134 -0
  60. package/build/server/chunks/_layout.svelte-CdDMC1RI.js.map +1 -0
  61. package/build/server/chunks/{_page.svelte-CGQGusC6.js → _page.svelte-CVL9fjg-.js} +10 -13
  62. package/build/server/chunks/_page.svelte-CVL9fjg-.js.map +1 -0
  63. package/build/server/chunks/{_page.svelte-BiD6gfpa.js → _page.svelte-Dx2ikKP_.js} +451 -497
  64. package/build/server/chunks/_page.svelte-Dx2ikKP_.js.map +1 -0
  65. package/build/server/chunks/{_server.ts-CDdRYdYO.js → _server.ts-B3M-jxF5.js} +2 -2
  66. package/build/server/chunks/{_server.ts-CDdRYdYO.js.map → _server.ts-B3M-jxF5.js.map} +1 -1
  67. package/build/server/chunks/{_server.ts-iCUks3KF.js → _server.ts-BCOHCAjW.js} +2 -2
  68. package/build/server/chunks/{_server.ts-iCUks3KF.js.map → _server.ts-BCOHCAjW.js.map} +1 -1
  69. package/build/server/chunks/{_server.ts-ChObRyrd.js → _server.ts-BGA9W8aM.js} +2 -2
  70. package/build/server/chunks/{_server.ts-ChObRyrd.js.map → _server.ts-BGA9W8aM.js.map} +1 -1
  71. package/build/server/chunks/{_server.ts-D5wsc-pR.js → _server.ts-BWxgSwZN.js} +2 -2
  72. package/build/server/chunks/{_server.ts-D5wsc-pR.js.map → _server.ts-BWxgSwZN.js.map} +1 -1
  73. package/build/server/chunks/{_server.ts-kfmLCgu8.js → _server.ts-C0mKXnG1.js} +2 -2
  74. package/build/server/chunks/{_server.ts-kfmLCgu8.js.map → _server.ts-C0mKXnG1.js.map} +1 -1
  75. package/build/server/chunks/{_server.ts-BsgoVOBd.js → _server.ts-C9GYaVf1.js} +3 -3
  76. package/build/server/chunks/{_server.ts-BsgoVOBd.js.map → _server.ts-C9GYaVf1.js.map} +1 -1
  77. package/build/server/chunks/{_server.ts-CPDPReZU.js → _server.ts-COPvamIQ.js} +2 -2
  78. package/build/server/chunks/{_server.ts-CPDPReZU.js.map → _server.ts-COPvamIQ.js.map} +1 -1
  79. package/build/server/chunks/{_server.ts-DLSXCOEM.js → _server.ts-CrKc6LEy.js} +2 -2
  80. package/build/server/chunks/{_server.ts-DLSXCOEM.js.map → _server.ts-CrKc6LEy.js.map} +1 -1
  81. package/build/server/chunks/{_server.ts-CKxzPqOL.js → _server.ts-DOSGEHuw.js} +2 -2
  82. package/build/server/chunks/{_server.ts-CKxzPqOL.js.map → _server.ts-DOSGEHuw.js.map} +1 -1
  83. package/build/server/chunks/{_server.ts-Be1LFWpG.js → _server.ts-DP0i5Bdl.js} +2 -2
  84. package/build/server/chunks/{_server.ts-Be1LFWpG.js.map → _server.ts-DP0i5Bdl.js.map} +1 -1
  85. package/build/server/chunks/{_server.ts-crvQ7CTS.js → _server.ts-DmN9rdOH.js} +3 -3
  86. package/build/server/chunks/{_server.ts-crvQ7CTS.js.map → _server.ts-DmN9rdOH.js.map} +1 -1
  87. package/build/server/chunks/{_server.ts-Brg38LxG.js → _server.ts-DmWsoikX.js} +2 -2
  88. package/build/server/chunks/{_server.ts-Brg38LxG.js.map → _server.ts-DmWsoikX.js.map} +1 -1
  89. package/build/server/chunks/{_server.ts-BOyCbZXG.js → _server.ts-F01KLghS.js} +2 -2
  90. package/build/server/chunks/{_server.ts-BOyCbZXG.js.map → _server.ts-F01KLghS.js.map} +1 -1
  91. package/build/server/chunks/{_server.ts-blDzB5RZ.js → _server.ts-QLTE_2dV.js} +2 -2
  92. package/build/server/chunks/{_server.ts-blDzB5RZ.js.map → _server.ts-QLTE_2dV.js.map} +1 -1
  93. package/build/server/chunks/{_server.ts-Fv64R5tZ.js → _server.ts-WZF_VFnZ.js} +2 -2
  94. package/build/server/chunks/{_server.ts-Fv64R5tZ.js.map → _server.ts-WZF_VFnZ.js.map} +1 -1
  95. package/build/server/chunks/{_server.ts-Dc0z7zpD.js → _server.ts-rTWeIoSC.js} +3 -3
  96. package/build/server/chunks/{_server.ts-Dc0z7zpD.js.map → _server.ts-rTWeIoSC.js.map} +1 -1
  97. package/build/server/chunks/{index4-B6vRxXfo.js → client-BtcIwznP.js} +3 -23
  98. package/build/server/chunks/client-BtcIwznP.js.map +1 -0
  99. package/build/server/chunks/{error.svelte-BNCG_dZH.js → error.svelte-B02-pvoO.js} +5 -4
  100. package/build/server/chunks/error.svelte-B02-pvoO.js.map +1 -0
  101. package/build/server/chunks/index-CoD1IJuy.js.map +1 -1
  102. package/build/server/chunks/index2-B2Ld-FFX.js +3575 -0
  103. package/build/server/chunks/index2-B2Ld-FFX.js.map +1 -0
  104. package/build/server/chunks/{index3-D8yIZRD-.js → index3-DNyQGNm8.js} +3 -3
  105. package/build/server/chunks/index3-DNyQGNm8.js.map +1 -0
  106. package/build/server/chunks/index4-CfOR2iO6.js +21 -0
  107. package/build/server/chunks/index4-CfOR2iO6.js.map +1 -0
  108. package/build/server/chunks/root-B5iYE7yO.js +1182 -0
  109. package/build/server/chunks/root-B5iYE7yO.js.map +1 -0
  110. package/build/server/chunks/{session-BwU3zV40.js → session-Dxp1vf6f.js} +2 -2
  111. package/build/server/chunks/{session-BwU3zV40.js.map → session-Dxp1vf6f.js.map} +1 -1
  112. package/build/server/index.js +703 -1411
  113. package/build/server/index.js.map +1 -1
  114. package/build/server/manifest.js +21 -21
  115. package/build/server/manifest.js.map +1 -1
  116. package/package.json +23 -23
  117. package/build/client/_app/immutable/assets/0.BTIBK81-.css +0 -1
  118. package/build/client/_app/immutable/assets/0.BTIBK81-.css.br +0 -0
  119. package/build/client/_app/immutable/assets/0.BTIBK81-.css.gz +0 -0
  120. package/build/client/_app/immutable/chunks/B-Z9hXPk.js +0 -1
  121. package/build/client/_app/immutable/chunks/B-Z9hXPk.js.br +0 -0
  122. package/build/client/_app/immutable/chunks/B-Z9hXPk.js.gz +0 -0
  123. package/build/client/_app/immutable/chunks/BmH_exS6.js.br +0 -0
  124. package/build/client/_app/immutable/chunks/BmH_exS6.js.gz +0 -0
  125. package/build/client/_app/immutable/chunks/Cr0eW1j3.js +0 -1
  126. package/build/client/_app/immutable/chunks/Cr0eW1j3.js.br +0 -0
  127. package/build/client/_app/immutable/chunks/Cr0eW1j3.js.gz +0 -0
  128. package/build/client/_app/immutable/chunks/DOXVKi87.js +0 -2
  129. package/build/client/_app/immutable/chunks/DOXVKi87.js.br +0 -0
  130. package/build/client/_app/immutable/chunks/DOXVKi87.js.gz +0 -0
  131. package/build/client/_app/immutable/chunks/WodlV_jD.js +0 -96
  132. package/build/client/_app/immutable/chunks/WodlV_jD.js.br +0 -0
  133. package/build/client/_app/immutable/chunks/WodlV_jD.js.gz +0 -0
  134. package/build/client/_app/immutable/chunks/YXuXYbOb.js +0 -1
  135. package/build/client/_app/immutable/chunks/YXuXYbOb.js.br +0 -0
  136. package/build/client/_app/immutable/chunks/YXuXYbOb.js.gz +0 -0
  137. package/build/client/_app/immutable/chunks/vDyoI7lw.js +0 -1
  138. package/build/client/_app/immutable/chunks/vDyoI7lw.js.br +0 -0
  139. package/build/client/_app/immutable/chunks/vDyoI7lw.js.gz +0 -0
  140. package/build/client/_app/immutable/entry/app.Kf_4i_t0.js +0 -2
  141. package/build/client/_app/immutable/entry/app.Kf_4i_t0.js.br +0 -0
  142. package/build/client/_app/immutable/entry/app.Kf_4i_t0.js.gz +0 -0
  143. package/build/client/_app/immutable/entry/start.DrVGwFzz.js +0 -1
  144. package/build/client/_app/immutable/entry/start.DrVGwFzz.js.br +0 -0
  145. package/build/client/_app/immutable/entry/start.DrVGwFzz.js.gz +0 -0
  146. package/build/client/_app/immutable/nodes/0.Dfn2ZpXY.js +0 -1
  147. package/build/client/_app/immutable/nodes/0.Dfn2ZpXY.js.br +0 -0
  148. package/build/client/_app/immutable/nodes/0.Dfn2ZpXY.js.gz +0 -0
  149. package/build/client/_app/immutable/nodes/1.CWRD2TOY.js +0 -1
  150. package/build/client/_app/immutable/nodes/1.CWRD2TOY.js.br +0 -0
  151. package/build/client/_app/immutable/nodes/1.CWRD2TOY.js.gz +0 -0
  152. package/build/client/_app/immutable/nodes/2.yd31CwaR.js.br +0 -0
  153. package/build/client/_app/immutable/nodes/2.yd31CwaR.js.gz +0 -0
  154. package/build/client/_app/immutable/nodes/3.Dh5fbLPm.js +0 -4
  155. package/build/client/_app/immutable/nodes/3.Dh5fbLPm.js.br +0 -0
  156. package/build/client/_app/immutable/nodes/3.Dh5fbLPm.js.gz +0 -0
  157. package/build/server/chunks/0-D3SWM5E2.js +0 -17
  158. package/build/server/chunks/1-CXfgX4ux.js +0 -9
  159. package/build/server/chunks/2-MV5uDYTL.js +0 -9
  160. package/build/server/chunks/3-CsnDqfbG.js +0 -9
  161. package/build/server/chunks/InputModal-B9P0hP_j.js.map +0 -1
  162. package/build/server/chunks/Toast-DWQ-hmJu.js.map +0 -1
  163. package/build/server/chunks/_layout.svelte-Cgt3CiZy.js +0 -106
  164. package/build/server/chunks/_layout.svelte-Cgt3CiZy.js.map +0 -1
  165. package/build/server/chunks/_page.svelte-BiD6gfpa.js.map +0 -1
  166. package/build/server/chunks/_page.svelte-CGQGusC6.js.map +0 -1
  167. package/build/server/chunks/error.svelte-BNCG_dZH.js.map +0 -1
  168. package/build/server/chunks/exports-BXvEiaiv.js +0 -238
  169. package/build/server/chunks/exports-BXvEiaiv.js.map +0 -1
  170. package/build/server/chunks/index-D4ev3Ona.js +0 -1352
  171. package/build/server/chunks/index-D4ev3Ona.js.map +0 -1
  172. package/build/server/chunks/index2-ybZwlzIk.js +0 -1925
  173. package/build/server/chunks/index2-ybZwlzIk.js.map +0 -1
  174. package/build/server/chunks/index3-D8yIZRD-.js.map +0 -1
  175. package/build/server/chunks/index4-B6vRxXfo.js.map +0 -1
@@ -1,1352 +0,0 @@
1
- import { H as HYDRATION_START, R as HYDRATION_END, aa as set_ssr_context, a7 as ssr_context, ab as push, ac as pop, ad as STALE_REACTION, ae as ELEMENT_PRESERVE_ATTRIBUTE_CASE, af as ELEMENT_IS_INPUT, a1 as escape_html, ag as ELEMENT_IS_NAMESPACED, ah as subscribe_to_store, ai as is_promise, a6 as noop, S as HYDRATION_START_ELSE } from './index2-ybZwlzIk.js';
2
-
3
- const escaped = {
4
- "<": "\\u003C",
5
- "\\": "\\\\",
6
- "\b": "\\b",
7
- "\f": "\\f",
8
- "\n": "\\n",
9
- "\r": "\\r",
10
- " ": "\\t",
11
- "\u2028": "\\u2028",
12
- "\u2029": "\\u2029"
13
- };
14
- class DevalueError extends Error {
15
- /**
16
- * @param {string} message
17
- * @param {string[]} keys
18
- * @param {any} [value] - The value that failed to be serialized
19
- * @param {any} [root] - The root value being serialized
20
- */
21
- constructor(message, keys, value, root) {
22
- super(message);
23
- this.name = "DevalueError";
24
- this.path = keys.join("");
25
- this.value = value;
26
- this.root = root;
27
- }
28
- }
29
- function is_primitive(thing) {
30
- return Object(thing) !== thing;
31
- }
32
- const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
33
- Object.prototype
34
- ).sort().join("\0");
35
- function is_plain_object(thing) {
36
- const proto = Object.getPrototypeOf(thing);
37
- return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
38
- }
39
- function get_type(thing) {
40
- return Object.prototype.toString.call(thing).slice(8, -1);
41
- }
42
- function get_escaped_char(char) {
43
- switch (char) {
44
- case '"':
45
- return '\\"';
46
- case "<":
47
- return "\\u003C";
48
- case "\\":
49
- return "\\\\";
50
- case "\n":
51
- return "\\n";
52
- case "\r":
53
- return "\\r";
54
- case " ":
55
- return "\\t";
56
- case "\b":
57
- return "\\b";
58
- case "\f":
59
- return "\\f";
60
- case "\u2028":
61
- return "\\u2028";
62
- case "\u2029":
63
- return "\\u2029";
64
- default:
65
- return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
66
- }
67
- }
68
- function stringify_string(str) {
69
- let result = "";
70
- let last_pos = 0;
71
- const len = str.length;
72
- for (let i = 0; i < len; i += 1) {
73
- const char = str[i];
74
- const replacement = get_escaped_char(char);
75
- if (replacement) {
76
- result += str.slice(last_pos, i) + replacement;
77
- last_pos = i + 1;
78
- }
79
- }
80
- return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
81
- }
82
- function enumerable_symbols(object) {
83
- return Object.getOwnPropertySymbols(object).filter(
84
- (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
85
- );
86
- }
87
- const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
88
- function stringify_key(key) {
89
- return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
90
- }
91
-
92
- const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
93
- const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
94
- const reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
95
- function uneval(value, replacer) {
96
- const counts = /* @__PURE__ */ new Map();
97
- const keys = [];
98
- const custom = /* @__PURE__ */ new Map();
99
- function walk(thing) {
100
- if (!is_primitive(thing)) {
101
- if (counts.has(thing)) {
102
- counts.set(thing, counts.get(thing) + 1);
103
- return;
104
- }
105
- counts.set(thing, 1);
106
- if (replacer) {
107
- const str2 = replacer(thing, (value2) => uneval(value2, replacer));
108
- if (typeof str2 === "string") {
109
- custom.set(thing, str2);
110
- return;
111
- }
112
- }
113
- if (typeof thing === "function") {
114
- throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
115
- }
116
- const type = get_type(thing);
117
- switch (type) {
118
- case "Number":
119
- case "BigInt":
120
- case "String":
121
- case "Boolean":
122
- case "Date":
123
- case "RegExp":
124
- case "URL":
125
- case "URLSearchParams":
126
- return;
127
- case "Array":
128
- thing.forEach((value2, i) => {
129
- keys.push(`[${i}]`);
130
- walk(value2);
131
- keys.pop();
132
- });
133
- break;
134
- case "Set":
135
- Array.from(thing).forEach(walk);
136
- break;
137
- case "Map":
138
- for (const [key, value2] of thing) {
139
- keys.push(
140
- `.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`
141
- );
142
- walk(value2);
143
- keys.pop();
144
- }
145
- break;
146
- case "Int8Array":
147
- case "Uint8Array":
148
- case "Uint8ClampedArray":
149
- case "Int16Array":
150
- case "Uint16Array":
151
- case "Int32Array":
152
- case "Uint32Array":
153
- case "Float32Array":
154
- case "Float64Array":
155
- case "BigInt64Array":
156
- case "BigUint64Array":
157
- walk(thing.buffer);
158
- return;
159
- case "ArrayBuffer":
160
- return;
161
- case "Temporal.Duration":
162
- case "Temporal.Instant":
163
- case "Temporal.PlainDate":
164
- case "Temporal.PlainTime":
165
- case "Temporal.PlainDateTime":
166
- case "Temporal.PlainMonthDay":
167
- case "Temporal.PlainYearMonth":
168
- case "Temporal.ZonedDateTime":
169
- return;
170
- default:
171
- if (!is_plain_object(thing)) {
172
- throw new DevalueError(
173
- `Cannot stringify arbitrary non-POJOs`,
174
- keys,
175
- thing,
176
- value
177
- );
178
- }
179
- if (enumerable_symbols(thing).length > 0) {
180
- throw new DevalueError(
181
- `Cannot stringify POJOs with symbolic keys`,
182
- keys,
183
- thing,
184
- value
185
- );
186
- }
187
- for (const key in thing) {
188
- keys.push(stringify_key(key));
189
- walk(thing[key]);
190
- keys.pop();
191
- }
192
- }
193
- }
194
- }
195
- walk(value);
196
- const names = /* @__PURE__ */ new Map();
197
- Array.from(counts).filter((entry) => entry[1] > 1).sort((a, b) => b[1] - a[1]).forEach((entry, i) => {
198
- names.set(entry[0], get_name(i));
199
- });
200
- function stringify2(thing) {
201
- if (names.has(thing)) {
202
- return names.get(thing);
203
- }
204
- if (is_primitive(thing)) {
205
- return stringify_primitive(thing);
206
- }
207
- if (custom.has(thing)) {
208
- return custom.get(thing);
209
- }
210
- const type = get_type(thing);
211
- switch (type) {
212
- case "Number":
213
- case "String":
214
- case "Boolean":
215
- return `Object(${stringify2(thing.valueOf())})`;
216
- case "RegExp":
217
- return `new RegExp(${stringify_string(thing.source)}, "${thing.flags}")`;
218
- case "Date":
219
- return `new Date(${thing.getTime()})`;
220
- case "URL":
221
- return `new URL(${stringify_string(thing.toString())})`;
222
- case "URLSearchParams":
223
- return `new URLSearchParams(${stringify_string(thing.toString())})`;
224
- case "Array":
225
- const members = (
226
- /** @type {any[]} */
227
- thing.map(
228
- (v, i) => i in thing ? stringify2(v) : ""
229
- )
230
- );
231
- const tail = thing.length === 0 || thing.length - 1 in thing ? "" : ",";
232
- return `[${members.join(",")}${tail}]`;
233
- case "Set":
234
- case "Map":
235
- return `new ${type}([${Array.from(thing).map(stringify2).join(",")}])`;
236
- case "Int8Array":
237
- case "Uint8Array":
238
- case "Uint8ClampedArray":
239
- case "Int16Array":
240
- case "Uint16Array":
241
- case "Int32Array":
242
- case "Uint32Array":
243
- case "Float32Array":
244
- case "Float64Array":
245
- case "BigInt64Array":
246
- case "BigUint64Array": {
247
- let str2 = `new ${type}`;
248
- if (counts.get(thing.buffer) === 1) {
249
- const array = new thing.constructor(thing.buffer);
250
- str2 += `([${array}])`;
251
- } else {
252
- str2 += `([${stringify2(thing.buffer)}])`;
253
- }
254
- const a = thing.byteOffset;
255
- const b = a + thing.byteLength;
256
- if (a > 0 || b !== thing.buffer.byteLength) {
257
- const m = +/(\d+)/.exec(type)[1] / 8;
258
- str2 += `.subarray(${a / m},${b / m})`;
259
- }
260
- return str2;
261
- }
262
- case "ArrayBuffer": {
263
- const ui8 = new Uint8Array(thing);
264
- return `new Uint8Array([${ui8.toString()}]).buffer`;
265
- }
266
- case "Temporal.Duration":
267
- case "Temporal.Instant":
268
- case "Temporal.PlainDate":
269
- case "Temporal.PlainTime":
270
- case "Temporal.PlainDateTime":
271
- case "Temporal.PlainMonthDay":
272
- case "Temporal.PlainYearMonth":
273
- case "Temporal.ZonedDateTime":
274
- return `${type}.from(${stringify_string(thing.toString())})`;
275
- default:
276
- const keys2 = Object.keys(thing);
277
- const obj = keys2.map((key) => `${safe_key(key)}:${stringify2(thing[key])}`).join(",");
278
- const proto = Object.getPrototypeOf(thing);
279
- if (proto === null) {
280
- return keys2.length > 0 ? `{${obj},__proto__:null}` : `{__proto__:null}`;
281
- }
282
- return `{${obj}}`;
283
- }
284
- }
285
- const str = stringify2(value);
286
- if (names.size) {
287
- const params = [];
288
- const statements = [];
289
- const values = [];
290
- names.forEach((name, thing) => {
291
- params.push(name);
292
- if (custom.has(thing)) {
293
- values.push(
294
- /** @type {string} */
295
- custom.get(thing)
296
- );
297
- return;
298
- }
299
- if (is_primitive(thing)) {
300
- values.push(stringify_primitive(thing));
301
- return;
302
- }
303
- const type = get_type(thing);
304
- switch (type) {
305
- case "Number":
306
- case "String":
307
- case "Boolean":
308
- values.push(`Object(${stringify2(thing.valueOf())})`);
309
- break;
310
- case "RegExp":
311
- values.push(thing.toString());
312
- break;
313
- case "Date":
314
- values.push(`new Date(${thing.getTime()})`);
315
- break;
316
- case "Array":
317
- values.push(`Array(${thing.length})`);
318
- thing.forEach((v, i) => {
319
- statements.push(`${name}[${i}]=${stringify2(v)}`);
320
- });
321
- break;
322
- case "Set":
323
- values.push(`new Set`);
324
- statements.push(
325
- `${name}.${Array.from(thing).map((v) => `add(${stringify2(v)})`).join(".")}`
326
- );
327
- break;
328
- case "Map":
329
- values.push(`new Map`);
330
- statements.push(
331
- `${name}.${Array.from(thing).map(([k, v]) => `set(${stringify2(k)}, ${stringify2(v)})`).join(".")}`
332
- );
333
- break;
334
- case "ArrayBuffer":
335
- values.push(
336
- `new Uint8Array([${new Uint8Array(thing).join(",")}]).buffer`
337
- );
338
- break;
339
- default:
340
- values.push(
341
- Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}"
342
- );
343
- Object.keys(thing).forEach((key) => {
344
- statements.push(
345
- `${name}${safe_prop(key)}=${stringify2(thing[key])}`
346
- );
347
- });
348
- }
349
- });
350
- statements.push(`return ${str}`);
351
- return `(function(${params.join(",")}){${statements.join(
352
- ";"
353
- )}}(${values.join(",")}))`;
354
- } else {
355
- return str;
356
- }
357
- }
358
- function get_name(num) {
359
- let name = "";
360
- do {
361
- name = chars[num % chars.length] + name;
362
- num = ~~(num / chars.length) - 1;
363
- } while (num >= 0);
364
- return reserved.test(name) ? `${name}0` : name;
365
- }
366
- function escape_unsafe_char(c) {
367
- return escaped[c] || c;
368
- }
369
- function escape_unsafe_chars(str) {
370
- return str.replace(unsafe_chars, escape_unsafe_char);
371
- }
372
- function safe_key(key) {
373
- return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
374
- }
375
- function safe_prop(key) {
376
- return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? `.${key}` : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
377
- }
378
- function stringify_primitive(thing) {
379
- if (typeof thing === "string") return stringify_string(thing);
380
- if (thing === void 0) return "void 0";
381
- if (thing === 0 && 1 / thing < 0) return "-0";
382
- const str = String(thing);
383
- if (typeof thing === "number") return str.replace(/^(-)?0\./, "$1.");
384
- if (typeof thing === "bigint") return thing + "n";
385
- return str;
386
- }
387
- const DOM_BOOLEAN_ATTRIBUTES = [
388
- "allowfullscreen",
389
- "async",
390
- "autofocus",
391
- "autoplay",
392
- "checked",
393
- "controls",
394
- "default",
395
- "disabled",
396
- "formnovalidate",
397
- "indeterminate",
398
- "inert",
399
- "ismap",
400
- "loop",
401
- "multiple",
402
- "muted",
403
- "nomodule",
404
- "novalidate",
405
- "open",
406
- "playsinline",
407
- "readonly",
408
- "required",
409
- "reversed",
410
- "seamless",
411
- "selected",
412
- "webkitdirectory",
413
- "defer",
414
- "disablepictureinpicture",
415
- "disableremoteplayback"
416
- ];
417
- function is_boolean_attribute(name) {
418
- return DOM_BOOLEAN_ATTRIBUTES.includes(name);
419
- }
420
- const PASSIVE_EVENTS = ["touchstart", "touchmove"];
421
- function is_passive_event(name) {
422
- return PASSIVE_EVENTS.includes(name);
423
- }
424
- function r(e) {
425
- var t, f, n = "";
426
- if ("string" == typeof e || "number" == typeof e) n += e;
427
- else if ("object" == typeof e) if (Array.isArray(e)) {
428
- var o = e.length;
429
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
430
- } else for (f in e) e[f] && (n && (n += " "), n += f);
431
- return n;
432
- }
433
- function clsx$1() {
434
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
435
- return n;
436
- }
437
- const replacements = {
438
- translate: /* @__PURE__ */ new Map([
439
- [true, "yes"],
440
- [false, "no"]
441
- ])
442
- };
443
- function attr(name, value, is_boolean = false) {
444
- if (name === "hidden" && value !== "until-found") {
445
- is_boolean = true;
446
- }
447
- if (value == null || !value && is_boolean) return "";
448
- const normalized = name in replacements && replacements[name].get(value) || value;
449
- const assignment = is_boolean ? "" : `="${escape_html(normalized, true)}"`;
450
- return ` ${name}${assignment}`;
451
- }
452
- function clsx(value) {
453
- if (typeof value === "object") {
454
- return clsx$1(value);
455
- } else {
456
- return value ?? "";
457
- }
458
- }
459
- const whitespace = [..." \n\r\f \v\uFEFF"];
460
- function to_class(value, hash, directives) {
461
- var classname = value == null ? "" : "" + value;
462
- if (hash) {
463
- classname = classname ? classname + " " + hash : hash;
464
- }
465
- if (directives) {
466
- for (var key in directives) {
467
- if (directives[key]) {
468
- classname = classname ? classname + " " + key : key;
469
- } else if (classname.length) {
470
- var len = key.length;
471
- var a = 0;
472
- while ((a = classname.indexOf(key, a)) >= 0) {
473
- var b = a + len;
474
- if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) {
475
- classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
476
- } else {
477
- a = b;
478
- }
479
- }
480
- }
481
- }
482
- }
483
- return classname === "" ? null : classname;
484
- }
485
- function append_styles(styles, important = false) {
486
- var separator = important ? " !important;" : ";";
487
- var css = "";
488
- for (var key in styles) {
489
- var value = styles[key];
490
- if (value != null && value !== "") {
491
- css += " " + key + ": " + value + separator;
492
- }
493
- }
494
- return css;
495
- }
496
- function to_css_name(name) {
497
- if (name[0] !== "-" || name[1] !== "-") {
498
- return name.toLowerCase();
499
- }
500
- return name;
501
- }
502
- function to_style(value, styles) {
503
- if (styles) {
504
- var new_style = "";
505
- var normal_styles;
506
- var important_styles;
507
- if (Array.isArray(styles)) {
508
- normal_styles = styles[0];
509
- important_styles = styles[1];
510
- } else {
511
- normal_styles = styles;
512
- }
513
- if (value) {
514
- value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
515
- var in_str = false;
516
- var in_apo = 0;
517
- var in_comment = false;
518
- var reserved_names = [];
519
- if (normal_styles) {
520
- reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
521
- }
522
- if (important_styles) {
523
- reserved_names.push(...Object.keys(important_styles).map(to_css_name));
524
- }
525
- var start_index = 0;
526
- var name_index = -1;
527
- const len = value.length;
528
- for (var i = 0; i < len; i++) {
529
- var c = value[i];
530
- if (in_comment) {
531
- if (c === "/" && value[i - 1] === "*") {
532
- in_comment = false;
533
- }
534
- } else if (in_str) {
535
- if (in_str === c) {
536
- in_str = false;
537
- }
538
- } else if (c === "/" && value[i + 1] === "*") {
539
- in_comment = true;
540
- } else if (c === '"' || c === "'") {
541
- in_str = c;
542
- } else if (c === "(") {
543
- in_apo++;
544
- } else if (c === ")") {
545
- in_apo--;
546
- }
547
- if (!in_comment && in_str === false && in_apo === 0) {
548
- if (c === ":" && name_index === -1) {
549
- name_index = i;
550
- } else if (c === ";" || i === len - 1) {
551
- if (name_index !== -1) {
552
- var name = to_css_name(value.substring(start_index, name_index).trim());
553
- if (!reserved_names.includes(name)) {
554
- if (c !== ";") {
555
- i++;
556
- }
557
- var property = value.substring(start_index, i).trim();
558
- new_style += " " + property + ";";
559
- }
560
- }
561
- start_index = i + 1;
562
- name_index = -1;
563
- }
564
- }
565
- }
566
- }
567
- if (normal_styles) {
568
- new_style += append_styles(normal_styles);
569
- }
570
- if (important_styles) {
571
- new_style += append_styles(important_styles, true);
572
- }
573
- new_style = new_style.trim();
574
- return new_style === "" ? null : new_style;
575
- }
576
- return value == null ? null : String(value);
577
- }
578
- const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
579
- const BLOCK_OPEN_ELSE = `<!--${HYDRATION_START_ELSE}-->`;
580
- const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
581
- const EMPTY_COMMENT = `<!---->`;
582
- let controller = null;
583
- function abort() {
584
- controller?.abort(STALE_REACTION);
585
- controller = null;
586
- }
587
- function await_invalid() {
588
- const error = new Error(`await_invalid
589
- Encountered asynchronous work while rendering synchronously.
590
- https://svelte.dev/e/await_invalid`);
591
- error.name = "Svelte error";
592
- throw error;
593
- }
594
- function invalid_csp() {
595
- const error = new Error(`invalid_csp
596
- \`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
597
- https://svelte.dev/e/invalid_csp`);
598
- error.name = "Svelte error";
599
- throw error;
600
- }
601
- function server_context_required() {
602
- const error = new Error(`server_context_required
603
- Could not resolve \`render\` context.
604
- https://svelte.dev/e/server_context_required`);
605
- error.name = "Svelte error";
606
- throw error;
607
- }
608
- function unresolved_hydratable(key, stack) {
609
- {
610
- console.warn(`https://svelte.dev/e/unresolved_hydratable`);
611
- }
612
- }
613
- function get_render_context() {
614
- const store = als?.getStore();
615
- {
616
- server_context_required();
617
- }
618
- return store;
619
- }
620
- let als = null;
621
- let text_encoder;
622
- let crypto;
623
- async function sha256(data) {
624
- text_encoder ??= new TextEncoder();
625
- crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (
626
- // @ts-ignore - we don't install node types in the prod build
627
- (await import('node:crypto')).webcrypto
628
- );
629
- const hash_buffer = await crypto.subtle.digest("SHA-256", text_encoder.encode(data));
630
- return base64_encode(hash_buffer);
631
- }
632
- function base64_encode(bytes) {
633
- if (globalThis.Buffer) {
634
- return globalThis.Buffer.from(bytes).toString("base64");
635
- }
636
- let binary = "";
637
- for (let i = 0; i < bytes.length; i++) {
638
- binary += String.fromCharCode(bytes[i]);
639
- }
640
- return btoa(binary);
641
- }
642
- class Renderer {
643
- /**
644
- * The contents of the renderer.
645
- * @type {RendererItem[]}
646
- */
647
- #out = [];
648
- /**
649
- * Any `onDestroy` callbacks registered during execution of this renderer.
650
- * @type {(() => void)[] | undefined}
651
- */
652
- #on_destroy = void 0;
653
- /**
654
- * Whether this renderer is a component body.
655
- * @type {boolean}
656
- */
657
- #is_component_body = false;
658
- /**
659
- * The type of string content that this renderer is accumulating.
660
- * @type {RendererType}
661
- */
662
- type;
663
- /** @type {Renderer | undefined} */
664
- #parent;
665
- /**
666
- * Asynchronous work associated with this renderer
667
- * @type {Promise<void> | undefined}
668
- */
669
- promise = void 0;
670
- /**
671
- * State which is associated with the content tree as a whole.
672
- * It will be re-exposed, uncopied, on all children.
673
- * @type {SSRState}
674
- * @readonly
675
- */
676
- global;
677
- /**
678
- * State that is local to the branch it is declared in.
679
- * It will be shallow-copied to all children.
680
- *
681
- * @type {{ select_value: string | undefined }}
682
- */
683
- local;
684
- /**
685
- * @param {SSRState} global
686
- * @param {Renderer | undefined} [parent]
687
- */
688
- constructor(global, parent) {
689
- this.#parent = parent;
690
- this.global = global;
691
- this.local = parent ? { ...parent.local } : { select_value: void 0 };
692
- this.type = parent ? parent.type : "body";
693
- }
694
- /**
695
- * @param {(renderer: Renderer) => void} fn
696
- */
697
- head(fn) {
698
- const head2 = new Renderer(this.global, this);
699
- head2.type = "head";
700
- this.#out.push(head2);
701
- head2.child(fn);
702
- }
703
- /**
704
- * @param {Array<Promise<void>>} blockers
705
- * @param {(renderer: Renderer) => void} fn
706
- */
707
- async_block(blockers, fn) {
708
- this.#out.push(BLOCK_OPEN);
709
- this.async(blockers, fn);
710
- this.#out.push(BLOCK_CLOSE);
711
- }
712
- /**
713
- * @param {Array<Promise<void>>} blockers
714
- * @param {(renderer: Renderer) => void} fn
715
- */
716
- async(blockers, fn) {
717
- let callback = fn;
718
- if (blockers.length > 0) {
719
- const context = ssr_context;
720
- callback = (renderer) => {
721
- return Promise.all(blockers).then(() => {
722
- const previous_context = ssr_context;
723
- try {
724
- set_ssr_context(context);
725
- return fn(renderer);
726
- } finally {
727
- set_ssr_context(previous_context);
728
- }
729
- });
730
- };
731
- }
732
- this.child(callback);
733
- }
734
- /**
735
- * @param {Array<() => void>} thunks
736
- */
737
- run(thunks) {
738
- const context = ssr_context;
739
- let promise = Promise.resolve(thunks[0]());
740
- const promises = [promise];
741
- for (const fn of thunks.slice(1)) {
742
- promise = promise.then(() => {
743
- const previous_context = ssr_context;
744
- set_ssr_context(context);
745
- try {
746
- return fn();
747
- } finally {
748
- set_ssr_context(previous_context);
749
- }
750
- });
751
- promises.push(promise);
752
- }
753
- return promises;
754
- }
755
- /**
756
- * Create a child renderer. The child renderer inherits the state from the parent,
757
- * but has its own content.
758
- * @param {(renderer: Renderer) => MaybePromise<void>} fn
759
- */
760
- child(fn) {
761
- const child = new Renderer(this.global, this);
762
- this.#out.push(child);
763
- const parent = ssr_context;
764
- set_ssr_context({
765
- ...ssr_context,
766
- p: parent,
767
- c: null,
768
- r: child
769
- });
770
- const result = fn(child);
771
- set_ssr_context(parent);
772
- if (result instanceof Promise) {
773
- if (child.global.mode === "sync") {
774
- await_invalid();
775
- }
776
- result.catch(() => {
777
- });
778
- child.promise = result;
779
- }
780
- return child;
781
- }
782
- /**
783
- * Create a component renderer. The component renderer inherits the state from the parent,
784
- * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
785
- * @param {(renderer: Renderer) => MaybePromise<void>} fn
786
- * @param {Function} [component_fn]
787
- * @returns {void}
788
- */
789
- component(fn, component_fn) {
790
- push();
791
- const child = this.child(fn);
792
- child.#is_component_body = true;
793
- pop();
794
- }
795
- /**
796
- * @param {Record<string, any>} attrs
797
- * @param {(renderer: Renderer) => void} fn
798
- * @param {string | undefined} [css_hash]
799
- * @param {Record<string, boolean> | undefined} [classes]
800
- * @param {Record<string, string> | undefined} [styles]
801
- * @param {number | undefined} [flags]
802
- * @returns {void}
803
- */
804
- select(attrs, fn, css_hash, classes, styles, flags) {
805
- const { value, ...select_attrs } = attrs;
806
- this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
807
- this.child((renderer) => {
808
- renderer.local.select_value = value;
809
- fn(renderer);
810
- });
811
- this.push("</select>");
812
- }
813
- /**
814
- * @param {Record<string, any>} attrs
815
- * @param {string | number | boolean | ((renderer: Renderer) => void)} body
816
- * @param {string | undefined} [css_hash]
817
- * @param {Record<string, boolean> | undefined} [classes]
818
- * @param {Record<string, string> | undefined} [styles]
819
- * @param {number | undefined} [flags]
820
- */
821
- option(attrs, body, css_hash, classes, styles, flags) {
822
- this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
823
- const close = (renderer, value, { head: head2, body: body2 }) => {
824
- if ("value" in attrs) {
825
- value = attrs.value;
826
- }
827
- if (value === this.local.select_value) {
828
- renderer.#out.push(" selected");
829
- }
830
- renderer.#out.push(`>${body2}</option>`);
831
- if (head2) {
832
- renderer.head((child) => child.push(head2));
833
- }
834
- };
835
- if (typeof body === "function") {
836
- this.child((renderer) => {
837
- const r2 = new Renderer(this.global, this);
838
- body(r2);
839
- if (this.global.mode === "async") {
840
- return r2.#collect_content_async().then((content) => {
841
- close(renderer, content.body.replaceAll("<!---->", ""), content);
842
- });
843
- } else {
844
- const content = r2.#collect_content();
845
- close(renderer, content.body.replaceAll("<!---->", ""), content);
846
- }
847
- });
848
- } else {
849
- close(this, body, { body });
850
- }
851
- }
852
- /**
853
- * @param {(renderer: Renderer) => void} fn
854
- */
855
- title(fn) {
856
- const path = this.get_path();
857
- const close = (head2) => {
858
- this.global.set_title(head2, path);
859
- };
860
- this.child((renderer) => {
861
- const r2 = new Renderer(renderer.global, renderer);
862
- fn(r2);
863
- if (renderer.global.mode === "async") {
864
- return r2.#collect_content_async().then((content) => {
865
- close(content.head);
866
- });
867
- } else {
868
- const content = r2.#collect_content();
869
- close(content.head);
870
- }
871
- });
872
- }
873
- /**
874
- * @param {string | (() => Promise<string>)} content
875
- */
876
- push(content) {
877
- if (typeof content === "function") {
878
- this.child(async (renderer) => renderer.push(await content()));
879
- } else {
880
- this.#out.push(content);
881
- }
882
- }
883
- /**
884
- * @param {() => void} fn
885
- */
886
- on_destroy(fn) {
887
- (this.#on_destroy ??= []).push(fn);
888
- }
889
- /**
890
- * @returns {number[]}
891
- */
892
- get_path() {
893
- return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
894
- }
895
- /**
896
- * @deprecated this is needed for legacy component bindings
897
- */
898
- copy() {
899
- const copy = new Renderer(this.global, this.#parent);
900
- copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
901
- copy.promise = this.promise;
902
- return copy;
903
- }
904
- /**
905
- * @param {Renderer} other
906
- * @deprecated this is needed for legacy component bindings
907
- */
908
- subsume(other) {
909
- if (this.global.mode !== other.global.mode) {
910
- throw new Error(
911
- "invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!"
912
- );
913
- }
914
- this.local = other.local;
915
- this.#out = other.#out.map((item) => {
916
- if (item instanceof Renderer) {
917
- item.subsume(item);
918
- }
919
- return item;
920
- });
921
- this.promise = other.promise;
922
- this.type = other.type;
923
- }
924
- get length() {
925
- return this.#out.length;
926
- }
927
- /**
928
- * Only available on the server and when compiling with the `server` option.
929
- * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
930
- * @template {Record<string, any>} Props
931
- * @param {Component<Props>} component
932
- * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
933
- * @returns {RenderOutput}
934
- */
935
- static render(component, options = {}) {
936
- let sync;
937
- const result = (
938
- /** @type {RenderOutput} */
939
- {}
940
- );
941
- Object.defineProperties(result, {
942
- html: {
943
- get: () => {
944
- return (sync ??= Renderer.#render(component, options)).body;
945
- }
946
- },
947
- head: {
948
- get: () => {
949
- return (sync ??= Renderer.#render(component, options)).head;
950
- }
951
- },
952
- body: {
953
- get: () => {
954
- return (sync ??= Renderer.#render(component, options)).body;
955
- }
956
- },
957
- hashes: {
958
- value: {
959
- script: ""
960
- }
961
- },
962
- then: {
963
- value: (
964
- /**
965
- * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
966
- *
967
- * @template TResult1
968
- * @template [TResult2=never]
969
- * @param { (value: SyncRenderOutput) => TResult1 } onfulfilled
970
- * @param { (reason: unknown) => TResult2 } onrejected
971
- */
972
- (onfulfilled, onrejected) => {
973
- {
974
- const result2 = sync ??= Renderer.#render(component, options);
975
- const user_result = onfulfilled({
976
- head: result2.head,
977
- body: result2.body,
978
- html: result2.body,
979
- hashes: { script: [] }
980
- });
981
- return Promise.resolve(user_result);
982
- }
983
- }
984
- )
985
- }
986
- });
987
- return result;
988
- }
989
- /**
990
- * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
991
- * after awaiting `collect_async`.
992
- *
993
- * Child renderers are "porous" and don't affect execution order, but component body renderers
994
- * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
995
- * @returns {Iterable<() => void>}
996
- */
997
- *#collect_on_destroy() {
998
- for (const component of this.#traverse_components()) {
999
- yield* component.#collect_ondestroy();
1000
- }
1001
- }
1002
- /**
1003
- * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
1004
- * @returns {Iterable<Renderer>}
1005
- */
1006
- *#traverse_components() {
1007
- for (const child of this.#out) {
1008
- if (typeof child !== "string") {
1009
- yield* child.#traverse_components();
1010
- }
1011
- }
1012
- if (this.#is_component_body) {
1013
- yield this;
1014
- }
1015
- }
1016
- /**
1017
- * @returns {Iterable<() => void>}
1018
- */
1019
- *#collect_ondestroy() {
1020
- if (this.#on_destroy) {
1021
- for (const fn of this.#on_destroy) {
1022
- yield fn;
1023
- }
1024
- }
1025
- for (const child of this.#out) {
1026
- if (child instanceof Renderer && !child.#is_component_body) {
1027
- yield* child.#collect_ondestroy();
1028
- }
1029
- }
1030
- }
1031
- /**
1032
- * Render a component. Throws if any of the children are performing asynchronous work.
1033
- *
1034
- * @template {Record<string, any>} Props
1035
- * @param {Component<Props>} component
1036
- * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
1037
- * @returns {AccumulatedContent}
1038
- */
1039
- static #render(component, options) {
1040
- var previous_context = ssr_context;
1041
- try {
1042
- const renderer = Renderer.#open_render("sync", component, options);
1043
- const content = renderer.#collect_content();
1044
- return Renderer.#close_render(content, renderer);
1045
- } finally {
1046
- abort();
1047
- set_ssr_context(previous_context);
1048
- }
1049
- }
1050
- /**
1051
- * Render a component.
1052
- *
1053
- * @template {Record<string, any>} Props
1054
- * @param {Component<Props>} component
1055
- * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
1056
- * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
1057
- */
1058
- static async #render_async(component, options) {
1059
- const previous_context = ssr_context;
1060
- try {
1061
- const renderer = Renderer.#open_render("async", component, options);
1062
- const content = await renderer.#collect_content_async();
1063
- const hydratables = await renderer.#collect_hydratables();
1064
- if (hydratables !== null) {
1065
- content.head = hydratables + content.head;
1066
- }
1067
- return Renderer.#close_render(content, renderer);
1068
- } finally {
1069
- set_ssr_context(previous_context);
1070
- abort();
1071
- }
1072
- }
1073
- /**
1074
- * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
1075
- * @param {AccumulatedContent} content
1076
- * @returns {AccumulatedContent}
1077
- */
1078
- #collect_content(content = { head: "", body: "" }) {
1079
- for (const item of this.#out) {
1080
- if (typeof item === "string") {
1081
- content[this.type] += item;
1082
- } else if (item instanceof Renderer) {
1083
- item.#collect_content(content);
1084
- }
1085
- }
1086
- return content;
1087
- }
1088
- /**
1089
- * Collect all of the code from the `out` array and return it as a string.
1090
- * @param {AccumulatedContent} content
1091
- * @returns {Promise<AccumulatedContent>}
1092
- */
1093
- async #collect_content_async(content = { head: "", body: "" }) {
1094
- await this.promise;
1095
- for (const item of this.#out) {
1096
- if (typeof item === "string") {
1097
- content[this.type] += item;
1098
- } else if (item instanceof Renderer) {
1099
- await item.#collect_content_async(content);
1100
- }
1101
- }
1102
- return content;
1103
- }
1104
- async #collect_hydratables() {
1105
- const ctx = get_render_context().hydratable;
1106
- for (const [_, key] of ctx.unresolved_promises) {
1107
- unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
1108
- }
1109
- for (const comparison of ctx.comparisons) {
1110
- await comparison;
1111
- }
1112
- return await this.#hydratable_block(ctx);
1113
- }
1114
- /**
1115
- * @template {Record<string, any>} Props
1116
- * @param {'sync' | 'async'} mode
1117
- * @param {import('svelte').Component<Props>} component
1118
- * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
1119
- * @returns {Renderer}
1120
- */
1121
- static #open_render(mode, component, options) {
1122
- const renderer = new Renderer(
1123
- new SSRState(mode, options.idPrefix ? options.idPrefix + "-" : "", options.csp)
1124
- );
1125
- renderer.push(BLOCK_OPEN);
1126
- if (options.context) {
1127
- push();
1128
- ssr_context.c = options.context;
1129
- ssr_context.r = renderer;
1130
- }
1131
- component(renderer, options.props ?? {});
1132
- if (options.context) {
1133
- pop();
1134
- }
1135
- renderer.push(BLOCK_CLOSE);
1136
- return renderer;
1137
- }
1138
- /**
1139
- * @param {AccumulatedContent} content
1140
- * @param {Renderer} renderer
1141
- * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
1142
- */
1143
- static #close_render(content, renderer) {
1144
- for (const cleanup of renderer.#collect_on_destroy()) {
1145
- cleanup();
1146
- }
1147
- let head2 = content.head + renderer.global.get_title();
1148
- let body = content.body;
1149
- for (const { hash, code } of renderer.global.css) {
1150
- head2 += `<style id="${hash}">${code}</style>`;
1151
- }
1152
- return {
1153
- head: head2,
1154
- body,
1155
- hashes: {
1156
- script: renderer.global.csp.script_hashes
1157
- }
1158
- };
1159
- }
1160
- /**
1161
- * @param {HydratableContext} ctx
1162
- */
1163
- async #hydratable_block(ctx) {
1164
- if (ctx.lookup.size === 0) {
1165
- return null;
1166
- }
1167
- let entries = [];
1168
- let has_promises = false;
1169
- for (const [k, v] of ctx.lookup) {
1170
- if (v.promises) {
1171
- has_promises = true;
1172
- for (const p of v.promises) await p;
1173
- }
1174
- entries.push(`[${uneval(k)},${v.serialized}]`);
1175
- }
1176
- let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
1177
- if (has_promises) {
1178
- prelude = `const r = (v) => Promise.resolve(v);
1179
- ${prelude}`;
1180
- }
1181
- const body = `
1182
- {
1183
- ${prelude}
1184
-
1185
- for (const [k, v] of [
1186
- ${entries.join(",\n ")}
1187
- ]) {
1188
- h.set(k, v);
1189
- }
1190
- }
1191
- `;
1192
- let csp_attr = "";
1193
- if (this.global.csp.nonce) {
1194
- csp_attr = ` nonce="${this.global.csp.nonce}"`;
1195
- } else if (this.global.csp.hash) {
1196
- const hash = await sha256(body);
1197
- this.global.csp.script_hashes.push(`sha256-${hash}`);
1198
- }
1199
- return `
1200
- <script${csp_attr}>${body}<\/script>`;
1201
- }
1202
- }
1203
- class SSRState {
1204
- /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
1205
- csp;
1206
- /** @readonly @type {'sync' | 'async'} */
1207
- mode;
1208
- /** @readonly @type {() => string} */
1209
- uid;
1210
- /** @readonly @type {Set<{ hash: string; code: string }>} */
1211
- css = /* @__PURE__ */ new Set();
1212
- /** @type {{ path: number[], value: string }} */
1213
- #title = { path: [], value: "" };
1214
- /**
1215
- * @param {'sync' | 'async'} mode
1216
- * @param {string} id_prefix
1217
- * @param {Csp} csp
1218
- */
1219
- constructor(mode, id_prefix = "", csp = { hash: false }) {
1220
- this.mode = mode;
1221
- this.csp = { ...csp, script_hashes: [] };
1222
- let uid = 1;
1223
- this.uid = () => `${id_prefix}s${uid++}`;
1224
- }
1225
- get_title() {
1226
- return this.#title.value;
1227
- }
1228
- /**
1229
- * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
1230
- * from earlier than or equal to the current value.
1231
- * @param {string} value
1232
- * @param {number[]} path
1233
- */
1234
- set_title(value, path) {
1235
- const current = this.#title.path;
1236
- let i = 0;
1237
- let l = Math.min(path.length, current.length);
1238
- while (i < l && path[i] === current[i]) i += 1;
1239
- if (path[i] === void 0) return;
1240
- if (current[i] === void 0 || path[i] > current[i]) {
1241
- this.#title.path = path;
1242
- this.#title.value = value;
1243
- }
1244
- }
1245
- }
1246
- const INVALID_ATTR_NAME_CHAR_REGEX = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
1247
- function render(component, options = {}) {
1248
- if (options.csp?.hash && options.csp.nonce) {
1249
- invalid_csp();
1250
- }
1251
- return Renderer.render(
1252
- /** @type {Component<Props>} */
1253
- component,
1254
- options
1255
- );
1256
- }
1257
- function head(hash, renderer, fn) {
1258
- renderer.head((renderer2) => {
1259
- renderer2.push(`<!--${hash}-->`);
1260
- renderer2.child(fn);
1261
- renderer2.push(EMPTY_COMMENT);
1262
- });
1263
- }
1264
- function attributes(attrs, css_hash, classes, styles, flags = 0) {
1265
- if (styles) {
1266
- attrs.style = to_style(attrs.style, styles);
1267
- }
1268
- if (attrs.class) {
1269
- attrs.class = clsx(attrs.class);
1270
- }
1271
- if (css_hash || classes) {
1272
- attrs.class = to_class(attrs.class, css_hash, classes);
1273
- }
1274
- let attr_str = "";
1275
- let name;
1276
- const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0;
1277
- const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;
1278
- const is_input = (flags & ELEMENT_IS_INPUT) !== 0;
1279
- for (name in attrs) {
1280
- if (typeof attrs[name] === "function") continue;
1281
- if (name[0] === "$" && name[1] === "$") continue;
1282
- if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
1283
- var value = attrs[name];
1284
- if (lowercase) {
1285
- name = name.toLowerCase();
1286
- }
1287
- if (is_input) {
1288
- if (name === "defaultvalue" || name === "defaultchecked") {
1289
- name = name === "defaultvalue" ? "value" : "checked";
1290
- if (attrs[name]) continue;
1291
- }
1292
- }
1293
- attr_str += attr(name, value, is_html && is_boolean_attribute(name));
1294
- }
1295
- return attr_str;
1296
- }
1297
- function stringify(value) {
1298
- return typeof value === "string" ? value : value == null ? "" : value + "";
1299
- }
1300
- function attr_class(value, hash, directives) {
1301
- var result = to_class(value, hash, directives);
1302
- return result ? ` class="${escape_html(result, true)}"` : "";
1303
- }
1304
- function store_get(store_values, store_name, store) {
1305
- if (store_name in store_values && store_values[store_name][0] === store) {
1306
- return store_values[store_name][2];
1307
- }
1308
- store_values[store_name]?.[1]();
1309
- store_values[store_name] = [store, null, void 0];
1310
- const unsub = subscribe_to_store(
1311
- store,
1312
- /** @param {any} v */
1313
- (v) => store_values[store_name][2] = v
1314
- );
1315
- store_values[store_name][1] = unsub;
1316
- return store_values[store_name][2];
1317
- }
1318
- function unsubscribe_stores(store_values) {
1319
- for (const store_name in store_values) {
1320
- store_values[store_name][1]();
1321
- }
1322
- }
1323
- function bind_props(props_parent, props_now) {
1324
- for (const key in props_now) {
1325
- const initial_value = props_parent[key];
1326
- const value = props_now[key];
1327
- if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) {
1328
- props_parent[key] = value;
1329
- }
1330
- }
1331
- }
1332
- function await_block(renderer, promise, pending_fn, then_fn) {
1333
- if (is_promise(promise)) {
1334
- renderer.push(BLOCK_OPEN);
1335
- promise.then(null, noop);
1336
- if (pending_fn !== null) {
1337
- pending_fn();
1338
- }
1339
- } else if (then_fn !== null) {
1340
- renderer.push(BLOCK_OPEN_ELSE);
1341
- then_fn(promise);
1342
- }
1343
- }
1344
- function ensure_array_like(array_like_or_iterator) {
1345
- if (array_like_or_iterator) {
1346
- return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
1347
- }
1348
- return [];
1349
- }
1350
-
1351
- export { DevalueError as D, is_plain_object as a, stringify_string as b, is_passive_event as c, attr as d, enumerable_symbols as e, attr_class as f, get_type as g, head as h, is_primitive as i, stringify as j, store_get as k, ensure_array_like as l, unsubscribe_stores as m, clsx as n, attributes as o, await_block as p, bind_props as q, render as r, stringify_key as s, uneval as u };
1352
- //# sourceMappingURL=index-D4ev3Ona.js.map