neogrok 0.0.1

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 (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -0
  3. package/build/client/_app/immutable/assets/0.5df5b886.css +1 -0
  4. package/build/client/_app/immutable/assets/0.5df5b886.css.br +0 -0
  5. package/build/client/_app/immutable/assets/0.5df5b886.css.gz +0 -0
  6. package/build/client/_app/immutable/assets/_layout.bb9a93e0.css +1 -0
  7. package/build/client/_app/immutable/assets/_layout.bb9a93e0.css.br +0 -0
  8. package/build/client/_app/immutable/assets/_layout.bb9a93e0.css.gz +0 -0
  9. package/build/client/_app/immutable/chunks/5.4ed993c7.js +1 -0
  10. package/build/client/_app/immutable/chunks/5.4ed993c7.js.br +0 -0
  11. package/build/client/_app/immutable/chunks/5.4ed993c7.js.gz +0 -0
  12. package/build/client/_app/immutable/chunks/each.ece37974.js +1 -0
  13. package/build/client/_app/immutable/chunks/each.ece37974.js.br +0 -0
  14. package/build/client/_app/immutable/chunks/each.ece37974.js.gz +0 -0
  15. package/build/client/_app/immutable/chunks/example-query.ac8ef50a.js +1 -0
  16. package/build/client/_app/immutable/chunks/example-query.ac8ef50a.js.br +0 -0
  17. package/build/client/_app/immutable/chunks/example-query.ac8ef50a.js.gz +0 -0
  18. package/build/client/_app/immutable/chunks/index.81a0017d.js +1 -0
  19. package/build/client/_app/immutable/chunks/index.81a0017d.js.br +0 -0
  20. package/build/client/_app/immutable/chunks/index.81a0017d.js.gz +0 -0
  21. package/build/client/_app/immutable/chunks/index.d0e6da70.js +1 -0
  22. package/build/client/_app/immutable/chunks/index.d0e6da70.js.br +0 -0
  23. package/build/client/_app/immutable/chunks/index.d0e6da70.js.gz +0 -0
  24. package/build/client/_app/immutable/chunks/input-colors.e7674f0c.js +1 -0
  25. package/build/client/_app/immutable/chunks/input-colors.e7674f0c.js.br +0 -0
  26. package/build/client/_app/immutable/chunks/input-colors.e7674f0c.js.gz +0 -0
  27. package/build/client/_app/immutable/chunks/integer-input.e86d05ad.js +1 -0
  28. package/build/client/_app/immutable/chunks/integer-input.e86d05ad.js.br +0 -0
  29. package/build/client/_app/immutable/chunks/integer-input.e86d05ad.js.gz +0 -0
  30. package/build/client/_app/immutable/chunks/link.70630bff.js +1 -0
  31. package/build/client/_app/immutable/chunks/link.70630bff.js.br +0 -0
  32. package/build/client/_app/immutable/chunks/link.70630bff.js.gz +0 -0
  33. package/build/client/_app/immutable/chunks/preferences.e389d16d.js +1 -0
  34. package/build/client/_app/immutable/chunks/preferences.e389d16d.js.br +0 -0
  35. package/build/client/_app/immutable/chunks/preferences.e389d16d.js.gz +0 -0
  36. package/build/client/_app/immutable/chunks/regexp.50bc0e87.js +1 -0
  37. package/build/client/_app/immutable/chunks/regexp.50bc0e87.js.br +2 -0
  38. package/build/client/_app/immutable/chunks/regexp.50bc0e87.js.gz +0 -0
  39. package/build/client/_app/immutable/chunks/scheduler.80902d3b.js +1 -0
  40. package/build/client/_app/immutable/chunks/scheduler.80902d3b.js.br +0 -0
  41. package/build/client/_app/immutable/chunks/scheduler.80902d3b.js.gz +0 -0
  42. package/build/client/_app/immutable/chunks/singletons.a17b5cab.js +1 -0
  43. package/build/client/_app/immutable/chunks/singletons.a17b5cab.js.br +0 -0
  44. package/build/client/_app/immutable/chunks/singletons.a17b5cab.js.gz +0 -0
  45. package/build/client/_app/immutable/chunks/stores.a4da01c2.js +1 -0
  46. package/build/client/_app/immutable/chunks/stores.a4da01c2.js.br +0 -0
  47. package/build/client/_app/immutable/chunks/stores.a4da01c2.js.gz +0 -0
  48. package/build/client/_app/immutable/chunks/toggle-search-type.f1a3061d.js +1 -0
  49. package/build/client/_app/immutable/chunks/toggle-search-type.f1a3061d.js.br +0 -0
  50. package/build/client/_app/immutable/chunks/toggle-search-type.f1a3061d.js.gz +0 -0
  51. package/build/client/_app/immutable/entry/app.4673b9f2.js +1 -0
  52. package/build/client/_app/immutable/entry/app.4673b9f2.js.br +0 -0
  53. package/build/client/_app/immutable/entry/app.4673b9f2.js.gz +0 -0
  54. package/build/client/_app/immutable/entry/start.6bed40d3.js +3 -0
  55. package/build/client/_app/immutable/entry/start.6bed40d3.js.br +0 -0
  56. package/build/client/_app/immutable/entry/start.6bed40d3.js.gz +0 -0
  57. package/build/client/_app/immutable/nodes/0.529467ca.js +1 -0
  58. package/build/client/_app/immutable/nodes/0.529467ca.js.br +0 -0
  59. package/build/client/_app/immutable/nodes/0.529467ca.js.gz +0 -0
  60. package/build/client/_app/immutable/nodes/1.abd8d795.js +1 -0
  61. package/build/client/_app/immutable/nodes/1.abd8d795.js.br +5 -0
  62. package/build/client/_app/immutable/nodes/1.abd8d795.js.gz +0 -0
  63. package/build/client/_app/immutable/nodes/10.28836ccc.js +9 -0
  64. package/build/client/_app/immutable/nodes/10.28836ccc.js.br +0 -0
  65. package/build/client/_app/immutable/nodes/10.28836ccc.js.gz +0 -0
  66. package/build/client/_app/immutable/nodes/11.93ac6006.js +25 -0
  67. package/build/client/_app/immutable/nodes/11.93ac6006.js.br +0 -0
  68. package/build/client/_app/immutable/nodes/11.93ac6006.js.gz +0 -0
  69. package/build/client/_app/immutable/nodes/12.67089c6b.js +11 -0
  70. package/build/client/_app/immutable/nodes/12.67089c6b.js.br +0 -0
  71. package/build/client/_app/immutable/nodes/12.67089c6b.js.gz +0 -0
  72. package/build/client/_app/immutable/nodes/13.418c6178.js +5 -0
  73. package/build/client/_app/immutable/nodes/13.418c6178.js.br +0 -0
  74. package/build/client/_app/immutable/nodes/13.418c6178.js.gz +0 -0
  75. package/build/client/_app/immutable/nodes/14.40bc0592.js +161 -0
  76. package/build/client/_app/immutable/nodes/14.40bc0592.js.br +0 -0
  77. package/build/client/_app/immutable/nodes/14.40bc0592.js.gz +0 -0
  78. package/build/client/_app/immutable/nodes/2.08d89d34.js +9 -0
  79. package/build/client/_app/immutable/nodes/2.08d89d34.js.br +0 -0
  80. package/build/client/_app/immutable/nodes/2.08d89d34.js.gz +0 -0
  81. package/build/client/_app/immutable/nodes/3.a382d3d5.js +8 -0
  82. package/build/client/_app/immutable/nodes/3.a382d3d5.js.br +0 -0
  83. package/build/client/_app/immutable/nodes/3.a382d3d5.js.gz +0 -0
  84. package/build/client/_app/immutable/nodes/4.37e53904.js +8 -0
  85. package/build/client/_app/immutable/nodes/4.37e53904.js.br +0 -0
  86. package/build/client/_app/immutable/nodes/4.37e53904.js.gz +0 -0
  87. package/build/client/_app/immutable/nodes/6.6cd1e711.js +14 -0
  88. package/build/client/_app/immutable/nodes/6.6cd1e711.js.br +0 -0
  89. package/build/client/_app/immutable/nodes/6.6cd1e711.js.gz +0 -0
  90. package/build/client/_app/immutable/nodes/7.b6576b19.js +8 -0
  91. package/build/client/_app/immutable/nodes/7.b6576b19.js.br +0 -0
  92. package/build/client/_app/immutable/nodes/7.b6576b19.js.gz +0 -0
  93. package/build/client/_app/immutable/nodes/8.b18d1c14.js +7 -0
  94. package/build/client/_app/immutable/nodes/8.b18d1c14.js.br +0 -0
  95. package/build/client/_app/immutable/nodes/8.b18d1c14.js.gz +0 -0
  96. package/build/client/_app/immutable/nodes/9.b3dcb728.js +12 -0
  97. package/build/client/_app/immutable/nodes/9.b3dcb728.js.br +0 -0
  98. package/build/client/_app/immutable/nodes/9.b3dcb728.js.gz +0 -0
  99. package/build/client/_app/version.json +1 -0
  100. package/build/client/_app/version.json.br +0 -0
  101. package/build/client/_app/version.json.gz +0 -0
  102. package/build/client/android-chrome-192x192.png +0 -0
  103. package/build/client/android-chrome-512x512.png +0 -0
  104. package/build/client/apple-touch-icon.png +0 -0
  105. package/build/client/favicon-16x16.png +0 -0
  106. package/build/client/favicon-32x32.png +0 -0
  107. package/build/client/favicon.ico +0 -0
  108. package/build/client/site.webmanifest +19 -0
  109. package/build/env.js +37 -0
  110. package/build/handler.js +1307 -0
  111. package/build/index.js +225 -0
  112. package/build/server/chunks/0-040b7d6d.js +27 -0
  113. package/build/server/chunks/0-040b7d6d.js.map +1 -0
  114. package/build/server/chunks/1-5c251174.js +9 -0
  115. package/build/server/chunks/1-5c251174.js.map +1 -0
  116. package/build/server/chunks/10-f6f67083.js +133 -0
  117. package/build/server/chunks/10-f6f67083.js.map +1 -0
  118. package/build/server/chunks/11-1055c6c2.js +9 -0
  119. package/build/server/chunks/11-1055c6c2.js.map +1 -0
  120. package/build/server/chunks/12-fb53c717.js +9 -0
  121. package/build/server/chunks/12-fb53c717.js.map +1 -0
  122. package/build/server/chunks/13-7237c6c6.js +85 -0
  123. package/build/server/chunks/13-7237c6c6.js.map +1 -0
  124. package/build/server/chunks/14-6241604d.js +9 -0
  125. package/build/server/chunks/14-6241604d.js.map +1 -0
  126. package/build/server/chunks/2-bd870b05.js +9 -0
  127. package/build/server/chunks/2-bd870b05.js.map +1 -0
  128. package/build/server/chunks/3-255408ab.js +57 -0
  129. package/build/server/chunks/3-255408ab.js.map +1 -0
  130. package/build/server/chunks/4-99742ef4.js +57 -0
  131. package/build/server/chunks/4-99742ef4.js.map +1 -0
  132. package/build/server/chunks/5-369c06ab.js +19 -0
  133. package/build/server/chunks/5-369c06ab.js.map +1 -0
  134. package/build/server/chunks/6-fc810a9f.js +57 -0
  135. package/build/server/chunks/6-fc810a9f.js.map +1 -0
  136. package/build/server/chunks/7-992dd8b0.js +57 -0
  137. package/build/server/chunks/7-992dd8b0.js.map +1 -0
  138. package/build/server/chunks/8-a92e2ef7.js +454 -0
  139. package/build/server/chunks/8-a92e2ef7.js.map +1 -0
  140. package/build/server/chunks/9-55cb67b6.js +59 -0
  141. package/build/server/chunks/9-55cb67b6.js.map +1 -0
  142. package/build/server/chunks/_error.svelte-dd890063.js +13 -0
  143. package/build/server/chunks/_error.svelte-dd890063.js.map +1 -0
  144. package/build/server/chunks/_layout.svelte-9a1c428f.js +37 -0
  145. package/build/server/chunks/_layout.svelte-9a1c428f.js.map +1 -0
  146. package/build/server/chunks/_layout.svelte-bed2b2d4.js +39 -0
  147. package/build/server/chunks/_layout.svelte-bed2b2d4.js.map +1 -0
  148. package/build/server/chunks/_page.svelte-2f290f09.js +30 -0
  149. package/build/server/chunks/_page.svelte-2f290f09.js.map +1 -0
  150. package/build/server/chunks/_page.svelte-33789d2d.js +36 -0
  151. package/build/server/chunks/_page.svelte-33789d2d.js.map +1 -0
  152. package/build/server/chunks/_page.svelte-5bb56058.js +41 -0
  153. package/build/server/chunks/_page.svelte-5bb56058.js.map +1 -0
  154. package/build/server/chunks/_page.svelte-701b9558.js +284 -0
  155. package/build/server/chunks/_page.svelte-701b9558.js.map +1 -0
  156. package/build/server/chunks/_page.svelte-7848979a.js +396 -0
  157. package/build/server/chunks/_page.svelte-7848979a.js.map +1 -0
  158. package/build/server/chunks/_page.svelte-7a8514c3.js +37 -0
  159. package/build/server/chunks/_page.svelte-7a8514c3.js.map +1 -0
  160. package/build/server/chunks/_page.svelte-9ea0ef4c.js +120 -0
  161. package/build/server/chunks/_page.svelte-9ea0ef4c.js.map +1 -0
  162. package/build/server/chunks/_page.svelte-a1e80515.js +30 -0
  163. package/build/server/chunks/_page.svelte-a1e80515.js.map +1 -0
  164. package/build/server/chunks/_page.svelte-cf45c2db.js +124 -0
  165. package/build/server/chunks/_page.svelte-cf45c2db.js.map +1 -0
  166. package/build/server/chunks/_page.svelte-dcbbe643.js +56 -0
  167. package/build/server/chunks/_page.svelte-dcbbe643.js.map +1 -0
  168. package/build/server/chunks/_page.svelte-f4064b9c.js +30 -0
  169. package/build/server/chunks/_page.svelte-f4064b9c.js.map +1 -0
  170. package/build/server/chunks/_server.ts-93a1fbab.js +354 -0
  171. package/build/server/chunks/_server.ts-93a1fbab.js.map +1 -0
  172. package/build/server/chunks/_server.ts-dec04c7b.js +12 -0
  173. package/build/server/chunks/_server.ts-dec04c7b.js.map +1 -0
  174. package/build/server/chunks/configuration-d033c4d1.js +48 -0
  175. package/build/server/chunks/configuration-d033c4d1.js.map +1 -0
  176. package/build/server/chunks/example-query-99034259.js +39 -0
  177. package/build/server/chunks/example-query-99034259.js.map +1 -0
  178. package/build/server/chunks/hooks.server-cb019385.js +32 -0
  179. package/build/server/chunks/hooks.server-cb019385.js.map +1 -0
  180. package/build/server/chunks/index-64aa7a5e.js +84 -0
  181. package/build/server/chunks/index-64aa7a5e.js.map +1 -0
  182. package/build/server/chunks/index2-7c17b4da.js +100 -0
  183. package/build/server/chunks/index2-7c17b4da.js.map +1 -0
  184. package/build/server/chunks/input-colors-c9063ebd.js +15 -0
  185. package/build/server/chunks/input-colors-c9063ebd.js.map +1 -0
  186. package/build/server/chunks/integer-input-9f57bf61.js +40 -0
  187. package/build/server/chunks/integer-input-9f57bf61.js.map +1 -0
  188. package/build/server/chunks/lifecycle-cbdd95e4.js +84 -0
  189. package/build/server/chunks/lifecycle-cbdd95e4.js.map +1 -0
  190. package/build/server/chunks/link-fded4b17.js +11 -0
  191. package/build/server/chunks/link-fded4b17.js.map +1 -0
  192. package/build/server/chunks/metrics-a6a74309.js +43 -0
  193. package/build/server/chunks/metrics-a6a74309.js.map +1 -0
  194. package/build/server/chunks/navigation-a410b94d.js +22 -0
  195. package/build/server/chunks/navigation-a410b94d.js.map +1 -0
  196. package/build/server/chunks/preferences-304b2e02.js +84 -0
  197. package/build/server/chunks/preferences-304b2e02.js.map +1 -0
  198. package/build/server/chunks/regexp-5017d573.js +4 -0
  199. package/build/server/chunks/regexp-5017d573.js.map +1 -0
  200. package/build/server/chunks/ssr-0f259a0f.js +195 -0
  201. package/build/server/chunks/ssr-0f259a0f.js.map +1 -0
  202. package/build/server/chunks/stores-2f0685cf.js +32 -0
  203. package/build/server/chunks/stores-2f0685cf.js.map +1 -0
  204. package/build/server/chunks/toggle-search-type-6ced5306.js +106 -0
  205. package/build/server/chunks/toggle-search-type-6ced5306.js.map +1 -0
  206. package/build/server/chunks/zoekt-client-dec73ec9.js +26 -0
  207. package/build/server/chunks/zoekt-client-dec73ec9.js.map +1 -0
  208. package/build/server/chunks/zoekt-list-repositories-773bcddb.js +100 -0
  209. package/build/server/chunks/zoekt-list-repositories-773bcddb.js.map +1 -0
  210. package/build/server/index.js +4070 -0
  211. package/build/server/index.js.map +1 -0
  212. package/build/server/manifest.js +142 -0
  213. package/build/server/manifest.js.map +1 -0
  214. package/build/shims.js +0 -0
  215. package/main.js +91 -0
  216. package/package.json +64 -0
@@ -0,0 +1,1307 @@
1
+ import './shims.js';
2
+ import fs$1 from 'node:fs';
3
+ import path from 'node:path';
4
+ import * as fs from 'fs';
5
+ import { readdirSync, statSync } from 'fs';
6
+ import { resolve, join, normalize } from 'path';
7
+ import * as qs from 'querystring';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { Server } from './server/index.js';
10
+ import { manifest, prerendered } from './server/manifest.js';
11
+ import { env } from './env.js';
12
+
13
+ function totalist(dir, callback, pre='') {
14
+ dir = resolve('.', dir);
15
+ let arr = readdirSync(dir);
16
+ let i=0, abs, stats;
17
+ for (; i < arr.length; i++) {
18
+ abs = join(dir, arr[i]);
19
+ stats = statSync(abs);
20
+ stats.isDirectory()
21
+ ? totalist(abs, callback, join(pre, arr[i]))
22
+ : callback(join(pre, arr[i]), abs, stats);
23
+ }
24
+ }
25
+
26
+ /**
27
+ * @typedef ParsedURL
28
+ * @type {import('.').ParsedURL}
29
+ */
30
+
31
+ /**
32
+ * @typedef Request
33
+ * @property {string} url
34
+ * @property {ParsedURL} _parsedUrl
35
+ */
36
+
37
+ /**
38
+ * @param {Request} req
39
+ * @returns {ParsedURL|void}
40
+ */
41
+ function parse$1(req) {
42
+ let raw = req.url;
43
+ if (raw == null) return;
44
+
45
+ let prev = req._parsedUrl;
46
+ if (prev && prev.raw === raw) return prev;
47
+
48
+ let pathname=raw, search='', query;
49
+
50
+ if (raw.length > 1) {
51
+ let idx = raw.indexOf('?', 1);
52
+
53
+ if (idx !== -1) {
54
+ search = raw.substring(idx);
55
+ pathname = raw.substring(0, idx);
56
+ if (search.length > 1) {
57
+ query = qs.parse(search.substring(1));
58
+ }
59
+ }
60
+ }
61
+
62
+ return req._parsedUrl = { pathname, search, query, raw };
63
+ }
64
+
65
+ const mimes = {
66
+ "ez": "application/andrew-inset",
67
+ "aw": "application/applixware",
68
+ "atom": "application/atom+xml",
69
+ "atomcat": "application/atomcat+xml",
70
+ "atomdeleted": "application/atomdeleted+xml",
71
+ "atomsvc": "application/atomsvc+xml",
72
+ "dwd": "application/atsc-dwd+xml",
73
+ "held": "application/atsc-held+xml",
74
+ "rsat": "application/atsc-rsat+xml",
75
+ "bdoc": "application/bdoc",
76
+ "xcs": "application/calendar+xml",
77
+ "ccxml": "application/ccxml+xml",
78
+ "cdfx": "application/cdfx+xml",
79
+ "cdmia": "application/cdmi-capability",
80
+ "cdmic": "application/cdmi-container",
81
+ "cdmid": "application/cdmi-domain",
82
+ "cdmio": "application/cdmi-object",
83
+ "cdmiq": "application/cdmi-queue",
84
+ "cu": "application/cu-seeme",
85
+ "mpd": "application/dash+xml",
86
+ "davmount": "application/davmount+xml",
87
+ "dbk": "application/docbook+xml",
88
+ "dssc": "application/dssc+der",
89
+ "xdssc": "application/dssc+xml",
90
+ "es": "application/ecmascript",
91
+ "ecma": "application/ecmascript",
92
+ "emma": "application/emma+xml",
93
+ "emotionml": "application/emotionml+xml",
94
+ "epub": "application/epub+zip",
95
+ "exi": "application/exi",
96
+ "fdt": "application/fdt+xml",
97
+ "pfr": "application/font-tdpfr",
98
+ "geojson": "application/geo+json",
99
+ "gml": "application/gml+xml",
100
+ "gpx": "application/gpx+xml",
101
+ "gxf": "application/gxf",
102
+ "gz": "application/gzip",
103
+ "hjson": "application/hjson",
104
+ "stk": "application/hyperstudio",
105
+ "ink": "application/inkml+xml",
106
+ "inkml": "application/inkml+xml",
107
+ "ipfix": "application/ipfix",
108
+ "its": "application/its+xml",
109
+ "jar": "application/java-archive",
110
+ "war": "application/java-archive",
111
+ "ear": "application/java-archive",
112
+ "ser": "application/java-serialized-object",
113
+ "class": "application/java-vm",
114
+ "js": "application/javascript",
115
+ "mjs": "application/javascript",
116
+ "json": "application/json",
117
+ "map": "application/json",
118
+ "json5": "application/json5",
119
+ "jsonml": "application/jsonml+json",
120
+ "jsonld": "application/ld+json",
121
+ "lgr": "application/lgr+xml",
122
+ "lostxml": "application/lost+xml",
123
+ "hqx": "application/mac-binhex40",
124
+ "cpt": "application/mac-compactpro",
125
+ "mads": "application/mads+xml",
126
+ "webmanifest": "application/manifest+json",
127
+ "mrc": "application/marc",
128
+ "mrcx": "application/marcxml+xml",
129
+ "ma": "application/mathematica",
130
+ "nb": "application/mathematica",
131
+ "mb": "application/mathematica",
132
+ "mathml": "application/mathml+xml",
133
+ "mbox": "application/mbox",
134
+ "mscml": "application/mediaservercontrol+xml",
135
+ "metalink": "application/metalink+xml",
136
+ "meta4": "application/metalink4+xml",
137
+ "mets": "application/mets+xml",
138
+ "maei": "application/mmt-aei+xml",
139
+ "musd": "application/mmt-usd+xml",
140
+ "mods": "application/mods+xml",
141
+ "m21": "application/mp21",
142
+ "mp21": "application/mp21",
143
+ "mp4s": "application/mp4",
144
+ "m4p": "application/mp4",
145
+ "doc": "application/msword",
146
+ "dot": "application/msword",
147
+ "mxf": "application/mxf",
148
+ "nq": "application/n-quads",
149
+ "nt": "application/n-triples",
150
+ "cjs": "application/node",
151
+ "bin": "application/octet-stream",
152
+ "dms": "application/octet-stream",
153
+ "lrf": "application/octet-stream",
154
+ "mar": "application/octet-stream",
155
+ "so": "application/octet-stream",
156
+ "dist": "application/octet-stream",
157
+ "distz": "application/octet-stream",
158
+ "pkg": "application/octet-stream",
159
+ "bpk": "application/octet-stream",
160
+ "dump": "application/octet-stream",
161
+ "elc": "application/octet-stream",
162
+ "deploy": "application/octet-stream",
163
+ "exe": "application/octet-stream",
164
+ "dll": "application/octet-stream",
165
+ "deb": "application/octet-stream",
166
+ "dmg": "application/octet-stream",
167
+ "iso": "application/octet-stream",
168
+ "img": "application/octet-stream",
169
+ "msi": "application/octet-stream",
170
+ "msp": "application/octet-stream",
171
+ "msm": "application/octet-stream",
172
+ "buffer": "application/octet-stream",
173
+ "oda": "application/oda",
174
+ "opf": "application/oebps-package+xml",
175
+ "ogx": "application/ogg",
176
+ "omdoc": "application/omdoc+xml",
177
+ "onetoc": "application/onenote",
178
+ "onetoc2": "application/onenote",
179
+ "onetmp": "application/onenote",
180
+ "onepkg": "application/onenote",
181
+ "oxps": "application/oxps",
182
+ "relo": "application/p2p-overlay+xml",
183
+ "xer": "application/patch-ops-error+xml",
184
+ "pdf": "application/pdf",
185
+ "pgp": "application/pgp-encrypted",
186
+ "asc": "application/pgp-signature",
187
+ "sig": "application/pgp-signature",
188
+ "prf": "application/pics-rules",
189
+ "p10": "application/pkcs10",
190
+ "p7m": "application/pkcs7-mime",
191
+ "p7c": "application/pkcs7-mime",
192
+ "p7s": "application/pkcs7-signature",
193
+ "p8": "application/pkcs8",
194
+ "ac": "application/pkix-attr-cert",
195
+ "cer": "application/pkix-cert",
196
+ "crl": "application/pkix-crl",
197
+ "pkipath": "application/pkix-pkipath",
198
+ "pki": "application/pkixcmp",
199
+ "pls": "application/pls+xml",
200
+ "ai": "application/postscript",
201
+ "eps": "application/postscript",
202
+ "ps": "application/postscript",
203
+ "provx": "application/provenance+xml",
204
+ "cww": "application/prs.cww",
205
+ "pskcxml": "application/pskc+xml",
206
+ "raml": "application/raml+yaml",
207
+ "rdf": "application/rdf+xml",
208
+ "owl": "application/rdf+xml",
209
+ "rif": "application/reginfo+xml",
210
+ "rnc": "application/relax-ng-compact-syntax",
211
+ "rl": "application/resource-lists+xml",
212
+ "rld": "application/resource-lists-diff+xml",
213
+ "rs": "application/rls-services+xml",
214
+ "rapd": "application/route-apd+xml",
215
+ "sls": "application/route-s-tsid+xml",
216
+ "rusd": "application/route-usd+xml",
217
+ "gbr": "application/rpki-ghostbusters",
218
+ "mft": "application/rpki-manifest",
219
+ "roa": "application/rpki-roa",
220
+ "rsd": "application/rsd+xml",
221
+ "rss": "application/rss+xml",
222
+ "rtf": "application/rtf",
223
+ "sbml": "application/sbml+xml",
224
+ "scq": "application/scvp-cv-request",
225
+ "scs": "application/scvp-cv-response",
226
+ "spq": "application/scvp-vp-request",
227
+ "spp": "application/scvp-vp-response",
228
+ "sdp": "application/sdp",
229
+ "senmlx": "application/senml+xml",
230
+ "sensmlx": "application/sensml+xml",
231
+ "setpay": "application/set-payment-initiation",
232
+ "setreg": "application/set-registration-initiation",
233
+ "shf": "application/shf+xml",
234
+ "siv": "application/sieve",
235
+ "sieve": "application/sieve",
236
+ "smi": "application/smil+xml",
237
+ "smil": "application/smil+xml",
238
+ "rq": "application/sparql-query",
239
+ "srx": "application/sparql-results+xml",
240
+ "gram": "application/srgs",
241
+ "grxml": "application/srgs+xml",
242
+ "sru": "application/sru+xml",
243
+ "ssdl": "application/ssdl+xml",
244
+ "ssml": "application/ssml+xml",
245
+ "swidtag": "application/swid+xml",
246
+ "tei": "application/tei+xml",
247
+ "teicorpus": "application/tei+xml",
248
+ "tfi": "application/thraud+xml",
249
+ "tsd": "application/timestamped-data",
250
+ "toml": "application/toml",
251
+ "trig": "application/trig",
252
+ "ttml": "application/ttml+xml",
253
+ "ubj": "application/ubjson",
254
+ "rsheet": "application/urc-ressheet+xml",
255
+ "td": "application/urc-targetdesc+xml",
256
+ "vxml": "application/voicexml+xml",
257
+ "wasm": "application/wasm",
258
+ "wgt": "application/widget",
259
+ "hlp": "application/winhlp",
260
+ "wsdl": "application/wsdl+xml",
261
+ "wspolicy": "application/wspolicy+xml",
262
+ "xaml": "application/xaml+xml",
263
+ "xav": "application/xcap-att+xml",
264
+ "xca": "application/xcap-caps+xml",
265
+ "xdf": "application/xcap-diff+xml",
266
+ "xel": "application/xcap-el+xml",
267
+ "xns": "application/xcap-ns+xml",
268
+ "xenc": "application/xenc+xml",
269
+ "xhtml": "application/xhtml+xml",
270
+ "xht": "application/xhtml+xml",
271
+ "xlf": "application/xliff+xml",
272
+ "xml": "application/xml",
273
+ "xsl": "application/xml",
274
+ "xsd": "application/xml",
275
+ "rng": "application/xml",
276
+ "dtd": "application/xml-dtd",
277
+ "xop": "application/xop+xml",
278
+ "xpl": "application/xproc+xml",
279
+ "xslt": "application/xml",
280
+ "xspf": "application/xspf+xml",
281
+ "mxml": "application/xv+xml",
282
+ "xhvml": "application/xv+xml",
283
+ "xvml": "application/xv+xml",
284
+ "xvm": "application/xv+xml",
285
+ "yang": "application/yang",
286
+ "yin": "application/yin+xml",
287
+ "zip": "application/zip",
288
+ "3gpp": "video/3gpp",
289
+ "adp": "audio/adpcm",
290
+ "amr": "audio/amr",
291
+ "au": "audio/basic",
292
+ "snd": "audio/basic",
293
+ "mid": "audio/midi",
294
+ "midi": "audio/midi",
295
+ "kar": "audio/midi",
296
+ "rmi": "audio/midi",
297
+ "mxmf": "audio/mobile-xmf",
298
+ "mp3": "audio/mpeg",
299
+ "m4a": "audio/mp4",
300
+ "mp4a": "audio/mp4",
301
+ "mpga": "audio/mpeg",
302
+ "mp2": "audio/mpeg",
303
+ "mp2a": "audio/mpeg",
304
+ "m2a": "audio/mpeg",
305
+ "m3a": "audio/mpeg",
306
+ "oga": "audio/ogg",
307
+ "ogg": "audio/ogg",
308
+ "spx": "audio/ogg",
309
+ "opus": "audio/ogg",
310
+ "s3m": "audio/s3m",
311
+ "sil": "audio/silk",
312
+ "wav": "audio/wav",
313
+ "weba": "audio/webm",
314
+ "xm": "audio/xm",
315
+ "ttc": "font/collection",
316
+ "otf": "font/otf",
317
+ "ttf": "font/ttf",
318
+ "woff": "font/woff",
319
+ "woff2": "font/woff2",
320
+ "exr": "image/aces",
321
+ "apng": "image/apng",
322
+ "avif": "image/avif",
323
+ "bmp": "image/bmp",
324
+ "cgm": "image/cgm",
325
+ "drle": "image/dicom-rle",
326
+ "emf": "image/emf",
327
+ "fits": "image/fits",
328
+ "g3": "image/g3fax",
329
+ "gif": "image/gif",
330
+ "heic": "image/heic",
331
+ "heics": "image/heic-sequence",
332
+ "heif": "image/heif",
333
+ "heifs": "image/heif-sequence",
334
+ "hej2": "image/hej2k",
335
+ "hsj2": "image/hsj2",
336
+ "ief": "image/ief",
337
+ "jls": "image/jls",
338
+ "jp2": "image/jp2",
339
+ "jpg2": "image/jp2",
340
+ "jpeg": "image/jpeg",
341
+ "jpg": "image/jpeg",
342
+ "jpe": "image/jpeg",
343
+ "jph": "image/jph",
344
+ "jhc": "image/jphc",
345
+ "jpm": "image/jpm",
346
+ "jpx": "image/jpx",
347
+ "jpf": "image/jpx",
348
+ "jxr": "image/jxr",
349
+ "jxra": "image/jxra",
350
+ "jxrs": "image/jxrs",
351
+ "jxs": "image/jxs",
352
+ "jxsc": "image/jxsc",
353
+ "jxsi": "image/jxsi",
354
+ "jxss": "image/jxss",
355
+ "ktx": "image/ktx",
356
+ "ktx2": "image/ktx2",
357
+ "png": "image/png",
358
+ "btif": "image/prs.btif",
359
+ "pti": "image/prs.pti",
360
+ "sgi": "image/sgi",
361
+ "svg": "image/svg+xml",
362
+ "svgz": "image/svg+xml",
363
+ "t38": "image/t38",
364
+ "tif": "image/tiff",
365
+ "tiff": "image/tiff",
366
+ "tfx": "image/tiff-fx",
367
+ "webp": "image/webp",
368
+ "wmf": "image/wmf",
369
+ "disposition-notification": "message/disposition-notification",
370
+ "u8msg": "message/global",
371
+ "u8dsn": "message/global-delivery-status",
372
+ "u8mdn": "message/global-disposition-notification",
373
+ "u8hdr": "message/global-headers",
374
+ "eml": "message/rfc822",
375
+ "mime": "message/rfc822",
376
+ "3mf": "model/3mf",
377
+ "gltf": "model/gltf+json",
378
+ "glb": "model/gltf-binary",
379
+ "igs": "model/iges",
380
+ "iges": "model/iges",
381
+ "msh": "model/mesh",
382
+ "mesh": "model/mesh",
383
+ "silo": "model/mesh",
384
+ "mtl": "model/mtl",
385
+ "obj": "model/obj",
386
+ "stpz": "model/step+zip",
387
+ "stpxz": "model/step-xml+zip",
388
+ "stl": "model/stl",
389
+ "wrl": "model/vrml",
390
+ "vrml": "model/vrml",
391
+ "x3db": "model/x3d+fastinfoset",
392
+ "x3dbz": "model/x3d+binary",
393
+ "x3dv": "model/x3d-vrml",
394
+ "x3dvz": "model/x3d+vrml",
395
+ "x3d": "model/x3d+xml",
396
+ "x3dz": "model/x3d+xml",
397
+ "appcache": "text/cache-manifest",
398
+ "manifest": "text/cache-manifest",
399
+ "ics": "text/calendar",
400
+ "ifb": "text/calendar",
401
+ "coffee": "text/coffeescript",
402
+ "litcoffee": "text/coffeescript",
403
+ "css": "text/css",
404
+ "csv": "text/csv",
405
+ "html": "text/html",
406
+ "htm": "text/html",
407
+ "shtml": "text/html",
408
+ "jade": "text/jade",
409
+ "jsx": "text/jsx",
410
+ "less": "text/less",
411
+ "markdown": "text/markdown",
412
+ "md": "text/markdown",
413
+ "mml": "text/mathml",
414
+ "mdx": "text/mdx",
415
+ "n3": "text/n3",
416
+ "txt": "text/plain",
417
+ "text": "text/plain",
418
+ "conf": "text/plain",
419
+ "def": "text/plain",
420
+ "list": "text/plain",
421
+ "log": "text/plain",
422
+ "in": "text/plain",
423
+ "ini": "text/plain",
424
+ "dsc": "text/prs.lines.tag",
425
+ "rtx": "text/richtext",
426
+ "sgml": "text/sgml",
427
+ "sgm": "text/sgml",
428
+ "shex": "text/shex",
429
+ "slim": "text/slim",
430
+ "slm": "text/slim",
431
+ "spdx": "text/spdx",
432
+ "stylus": "text/stylus",
433
+ "styl": "text/stylus",
434
+ "tsv": "text/tab-separated-values",
435
+ "t": "text/troff",
436
+ "tr": "text/troff",
437
+ "roff": "text/troff",
438
+ "man": "text/troff",
439
+ "me": "text/troff",
440
+ "ms": "text/troff",
441
+ "ttl": "text/turtle",
442
+ "uri": "text/uri-list",
443
+ "uris": "text/uri-list",
444
+ "urls": "text/uri-list",
445
+ "vcard": "text/vcard",
446
+ "vtt": "text/vtt",
447
+ "yaml": "text/yaml",
448
+ "yml": "text/yaml",
449
+ "3gp": "video/3gpp",
450
+ "3g2": "video/3gpp2",
451
+ "h261": "video/h261",
452
+ "h263": "video/h263",
453
+ "h264": "video/h264",
454
+ "m4s": "video/iso.segment",
455
+ "jpgv": "video/jpeg",
456
+ "jpgm": "image/jpm",
457
+ "mj2": "video/mj2",
458
+ "mjp2": "video/mj2",
459
+ "ts": "video/mp2t",
460
+ "mp4": "video/mp4",
461
+ "mp4v": "video/mp4",
462
+ "mpg4": "video/mp4",
463
+ "mpeg": "video/mpeg",
464
+ "mpg": "video/mpeg",
465
+ "mpe": "video/mpeg",
466
+ "m1v": "video/mpeg",
467
+ "m2v": "video/mpeg",
468
+ "ogv": "video/ogg",
469
+ "qt": "video/quicktime",
470
+ "mov": "video/quicktime",
471
+ "webm": "video/webm"
472
+ };
473
+
474
+ function lookup(extn) {
475
+ let tmp = ('' + extn).trim().toLowerCase();
476
+ let idx = tmp.lastIndexOf('.');
477
+ return mimes[!~idx ? tmp : tmp.substring(++idx)];
478
+ }
479
+
480
+ const noop = () => {};
481
+
482
+ function isMatch(uri, arr) {
483
+ for (let i=0; i < arr.length; i++) {
484
+ if (arr[i].test(uri)) return true;
485
+ }
486
+ }
487
+
488
+ function toAssume(uri, extns) {
489
+ let i=0, x, len=uri.length - 1;
490
+ if (uri.charCodeAt(len) === 47) {
491
+ uri = uri.substring(0, len);
492
+ }
493
+
494
+ let arr=[], tmp=`${uri}/index`;
495
+ for (; i < extns.length; i++) {
496
+ x = extns[i] ? `.${extns[i]}` : '';
497
+ if (uri) arr.push(uri + x);
498
+ arr.push(tmp + x);
499
+ }
500
+
501
+ return arr;
502
+ }
503
+
504
+ function viaCache(cache, uri, extns) {
505
+ let i=0, data, arr=toAssume(uri, extns);
506
+ for (; i < arr.length; i++) {
507
+ if (data = cache[arr[i]]) return data;
508
+ }
509
+ }
510
+
511
+ function viaLocal(dir, isEtag, uri, extns) {
512
+ let i=0, arr=toAssume(uri, extns);
513
+ let abs, stats, name, headers;
514
+ for (; i < arr.length; i++) {
515
+ abs = normalize(join(dir, name=arr[i]));
516
+ if (abs.startsWith(dir) && fs.existsSync(abs)) {
517
+ stats = fs.statSync(abs);
518
+ if (stats.isDirectory()) continue;
519
+ headers = toHeaders(name, stats, isEtag);
520
+ headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
521
+ return { abs, stats, headers };
522
+ }
523
+ }
524
+ }
525
+
526
+ function is404(req, res) {
527
+ return (res.statusCode=404,res.end());
528
+ }
529
+
530
+ function send(req, res, file, stats, headers) {
531
+ let code=200, tmp, opts={};
532
+ headers = { ...headers };
533
+
534
+ for (let key in headers) {
535
+ tmp = res.getHeader(key);
536
+ if (tmp) headers[key] = tmp;
537
+ }
538
+
539
+ if (tmp = res.getHeader('content-type')) {
540
+ headers['Content-Type'] = tmp;
541
+ }
542
+
543
+ if (req.headers.range) {
544
+ code = 206;
545
+ let [x, y] = req.headers.range.replace('bytes=', '').split('-');
546
+ let end = opts.end = parseInt(y, 10) || stats.size - 1;
547
+ let start = opts.start = parseInt(x, 10) || 0;
548
+
549
+ if (end >= stats.size) {
550
+ end = stats.size - 1;
551
+ }
552
+
553
+ if (start >= stats.size) {
554
+ res.setHeader('Content-Range', `bytes */${stats.size}`);
555
+ res.statusCode = 416;
556
+ return res.end();
557
+ }
558
+
559
+ headers['Content-Range'] = `bytes ${start}-${end}/${stats.size}`;
560
+ headers['Content-Length'] = (end - start + 1);
561
+ headers['Accept-Ranges'] = 'bytes';
562
+ }
563
+
564
+ res.writeHead(code, headers);
565
+ fs.createReadStream(file, opts).pipe(res);
566
+ }
567
+
568
+ const ENCODING = {
569
+ '.br': 'br',
570
+ '.gz': 'gzip',
571
+ };
572
+
573
+ function toHeaders(name, stats, isEtag) {
574
+ let enc = ENCODING[name.slice(-3)];
575
+
576
+ let ctype = lookup(name.slice(0, enc && -3)) || '';
577
+ if (ctype === 'text/html') ctype += ';charset=utf-8';
578
+
579
+ let headers = {
580
+ 'Content-Length': stats.size,
581
+ 'Content-Type': ctype,
582
+ 'Last-Modified': stats.mtime.toUTCString(),
583
+ };
584
+
585
+ if (enc) headers['Content-Encoding'] = enc;
586
+ if (isEtag) headers['ETag'] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
587
+
588
+ return headers;
589
+ }
590
+
591
+ function sirv (dir, opts={}) {
592
+ dir = resolve(dir || '.');
593
+
594
+ let isNotFound = opts.onNoMatch || is404;
595
+ let setHeaders = opts.setHeaders || noop;
596
+
597
+ let extensions = opts.extensions || ['html', 'htm'];
598
+ let gzips = opts.gzip && extensions.map(x => `${x}.gz`).concat('gz');
599
+ let brots = opts.brotli && extensions.map(x => `${x}.br`).concat('br');
600
+
601
+ const FILES = {};
602
+
603
+ let fallback = '/';
604
+ let isEtag = !!opts.etag;
605
+ let isSPA = !!opts.single;
606
+ if (typeof opts.single === 'string') {
607
+ let idx = opts.single.lastIndexOf('.');
608
+ fallback += !!~idx ? opts.single.substring(0, idx) : opts.single;
609
+ }
610
+
611
+ let ignores = [];
612
+ if (opts.ignores !== false) {
613
+ ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/); // any extn
614
+ if (opts.dotfiles) ignores.push(/\/\.\w/);
615
+ else ignores.push(/\/\.well-known/);
616
+ [].concat(opts.ignores || []).forEach(x => {
617
+ ignores.push(new RegExp(x, 'i'));
618
+ });
619
+ }
620
+
621
+ let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
622
+ if (cc && opts.immutable) cc += ',immutable';
623
+ else if (cc && opts.maxAge === 0) cc += ',must-revalidate';
624
+
625
+ if (!opts.dev) {
626
+ totalist(dir, (name, abs, stats) => {
627
+ if (/\.well-known[\\+\/]/.test(name)) ; // keep
628
+ else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name)) return;
629
+
630
+ let headers = toHeaders(name, stats, isEtag);
631
+ if (cc) headers['Cache-Control'] = cc;
632
+
633
+ FILES['/' + name.normalize().replace(/\\+/g, '/')] = { abs, stats, headers };
634
+ });
635
+ }
636
+
637
+ let lookup = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES);
638
+
639
+ return function (req, res, next) {
640
+ let extns = [''];
641
+ let pathname = parse$1(req).pathname;
642
+ let val = req.headers['accept-encoding'] || '';
643
+ if (gzips && val.includes('gzip')) extns.unshift(...gzips);
644
+ if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots);
645
+ extns.push(...extensions); // [...br, ...gz, orig, ...exts]
646
+
647
+ if (pathname.indexOf('%') !== -1) {
648
+ try { pathname = decodeURI(pathname); }
649
+ catch (err) { /* malform uri */ }
650
+ }
651
+
652
+ let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns);
653
+ if (!data) return next ? next() : isNotFound(req, res);
654
+
655
+ if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {
656
+ res.writeHead(304);
657
+ return res.end();
658
+ }
659
+
660
+ if (gzips || brots) {
661
+ res.setHeader('Vary', 'Accept-Encoding');
662
+ }
663
+
664
+ setHeaders(res, pathname, data.stats);
665
+ send(req, res, data.abs, data.stats, data.headers);
666
+ };
667
+ }
668
+
669
+ var setCookie = {exports: {}};
670
+
671
+ var defaultParseOptions = {
672
+ decodeValues: true,
673
+ map: false,
674
+ silent: false,
675
+ };
676
+
677
+ function isNonEmptyString(str) {
678
+ return typeof str === "string" && !!str.trim();
679
+ }
680
+
681
+ function parseString(setCookieValue, options) {
682
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
683
+
684
+ var nameValuePairStr = parts.shift();
685
+ var parsed = parseNameValuePair(nameValuePairStr);
686
+ var name = parsed.name;
687
+ var value = parsed.value;
688
+
689
+ options = options
690
+ ? Object.assign({}, defaultParseOptions, options)
691
+ : defaultParseOptions;
692
+
693
+ try {
694
+ value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
695
+ } catch (e) {
696
+ console.error(
697
+ "set-cookie-parser encountered an error while decoding a cookie with value '" +
698
+ value +
699
+ "'. Set options.decodeValues to false to disable this feature.",
700
+ e
701
+ );
702
+ }
703
+
704
+ var cookie = {
705
+ name: name,
706
+ value: value,
707
+ };
708
+
709
+ parts.forEach(function (part) {
710
+ var sides = part.split("=");
711
+ var key = sides.shift().trimLeft().toLowerCase();
712
+ var value = sides.join("=");
713
+ if (key === "expires") {
714
+ cookie.expires = new Date(value);
715
+ } else if (key === "max-age") {
716
+ cookie.maxAge = parseInt(value, 10);
717
+ } else if (key === "secure") {
718
+ cookie.secure = true;
719
+ } else if (key === "httponly") {
720
+ cookie.httpOnly = true;
721
+ } else if (key === "samesite") {
722
+ cookie.sameSite = value;
723
+ } else {
724
+ cookie[key] = value;
725
+ }
726
+ });
727
+
728
+ return cookie;
729
+ }
730
+
731
+ function parseNameValuePair(nameValuePairStr) {
732
+ // Parses name-value-pair according to rfc6265bis draft
733
+
734
+ var name = "";
735
+ var value = "";
736
+ var nameValueArr = nameValuePairStr.split("=");
737
+ if (nameValueArr.length > 1) {
738
+ name = nameValueArr.shift();
739
+ value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
740
+ } else {
741
+ value = nameValuePairStr;
742
+ }
743
+
744
+ return { name: name, value: value };
745
+ }
746
+
747
+ function parse(input, options) {
748
+ options = options
749
+ ? Object.assign({}, defaultParseOptions, options)
750
+ : defaultParseOptions;
751
+
752
+ if (!input) {
753
+ if (!options.map) {
754
+ return [];
755
+ } else {
756
+ return {};
757
+ }
758
+ }
759
+
760
+ if (input.headers) {
761
+ if (typeof input.headers.getSetCookie === "function") {
762
+ // for fetch responses - they combine headers of the same type in the headers array,
763
+ // but getSetCookie returns an uncombined array
764
+ input = input.headers.getSetCookie();
765
+ } else if (input.headers["set-cookie"]) {
766
+ // fast-path for node.js (which automatically normalizes header names to lower-case
767
+ input = input.headers["set-cookie"];
768
+ } else {
769
+ // slow-path for other environments - see #25
770
+ var sch =
771
+ input.headers[
772
+ Object.keys(input.headers).find(function (key) {
773
+ return key.toLowerCase() === "set-cookie";
774
+ })
775
+ ];
776
+ // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
777
+ if (!sch && input.headers.cookie && !options.silent) {
778
+ console.warn(
779
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
780
+ );
781
+ }
782
+ input = sch;
783
+ }
784
+ }
785
+ if (!Array.isArray(input)) {
786
+ input = [input];
787
+ }
788
+
789
+ options = options
790
+ ? Object.assign({}, defaultParseOptions, options)
791
+ : defaultParseOptions;
792
+
793
+ if (!options.map) {
794
+ return input.filter(isNonEmptyString).map(function (str) {
795
+ return parseString(str, options);
796
+ });
797
+ } else {
798
+ var cookies = {};
799
+ return input.filter(isNonEmptyString).reduce(function (cookies, str) {
800
+ var cookie = parseString(str, options);
801
+ cookies[cookie.name] = cookie;
802
+ return cookies;
803
+ }, cookies);
804
+ }
805
+ }
806
+
807
+ /*
808
+ Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
809
+ that are within a single set-cookie field-value, such as in the Expires portion.
810
+
811
+ This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
812
+ Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
813
+ React Native's fetch does this for *every* header, including set-cookie.
814
+
815
+ Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
816
+ Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
817
+ */
818
+ function splitCookiesString(cookiesString) {
819
+ if (Array.isArray(cookiesString)) {
820
+ return cookiesString;
821
+ }
822
+ if (typeof cookiesString !== "string") {
823
+ return [];
824
+ }
825
+
826
+ var cookiesStrings = [];
827
+ var pos = 0;
828
+ var start;
829
+ var ch;
830
+ var lastComma;
831
+ var nextStart;
832
+ var cookiesSeparatorFound;
833
+
834
+ function skipWhitespace() {
835
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
836
+ pos += 1;
837
+ }
838
+ return pos < cookiesString.length;
839
+ }
840
+
841
+ function notSpecialChar() {
842
+ ch = cookiesString.charAt(pos);
843
+
844
+ return ch !== "=" && ch !== ";" && ch !== ",";
845
+ }
846
+
847
+ while (pos < cookiesString.length) {
848
+ start = pos;
849
+ cookiesSeparatorFound = false;
850
+
851
+ while (skipWhitespace()) {
852
+ ch = cookiesString.charAt(pos);
853
+ if (ch === ",") {
854
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
855
+ lastComma = pos;
856
+ pos += 1;
857
+
858
+ skipWhitespace();
859
+ nextStart = pos;
860
+
861
+ while (pos < cookiesString.length && notSpecialChar()) {
862
+ pos += 1;
863
+ }
864
+
865
+ // currently special character
866
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
867
+ // we found cookies separator
868
+ cookiesSeparatorFound = true;
869
+ // pos is inside the next cookie, so back up and return it.
870
+ pos = nextStart;
871
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
872
+ start = pos;
873
+ } else {
874
+ // in param ',' or param separator ';',
875
+ // we continue from that comma
876
+ pos = lastComma + 1;
877
+ }
878
+ } else {
879
+ pos += 1;
880
+ }
881
+ }
882
+
883
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
884
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
885
+ }
886
+ }
887
+
888
+ return cookiesStrings;
889
+ }
890
+
891
+ setCookie.exports = parse;
892
+ setCookie.exports.parse = parse;
893
+ setCookie.exports.parseString = parseString;
894
+ var splitCookiesString_1 = setCookie.exports.splitCookiesString = splitCookiesString;
895
+
896
+ class HttpError {
897
+ /**
898
+ * @param {number} status
899
+ * @param {{message: string} extends App.Error ? (App.Error | string | undefined) : App.Error} body
900
+ */
901
+ constructor(status, body) {
902
+ this.status = status;
903
+ if (typeof body === 'string') {
904
+ this.body = { message: body };
905
+ } else if (body) {
906
+ this.body = body;
907
+ } else {
908
+ this.body = { message: `Error: ${status}` };
909
+ }
910
+ }
911
+
912
+ toString() {
913
+ return JSON.stringify(this.body);
914
+ }
915
+ }
916
+
917
+ /**
918
+ * @overload
919
+ * @param {number} status
920
+ * @param {App.Error} body
921
+ * @return {HttpError}
922
+ */
923
+
924
+ /**
925
+ * @overload
926
+ * @param {number} status
927
+ * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} [body]
928
+ * @return {HttpError}
929
+ */
930
+
931
+ /**
932
+ * Creates an `HttpError` object with an HTTP status code and an optional message.
933
+ * This object, if thrown during request handling, will cause SvelteKit to
934
+ * return an error response without invoking `handleError`.
935
+ * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
936
+ * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
937
+ * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.
938
+ */
939
+ function error(status, body) {
940
+ if ((isNaN(status) || status < 400 || status > 599)) {
941
+ throw new Error(`HTTP error status codes must be between 400 and 599 — ${status} is invalid`);
942
+ }
943
+
944
+ return new HttpError(status, body);
945
+ }
946
+
947
+ new TextEncoder();
948
+
949
+ /**
950
+ * @param {import('http').IncomingMessage} req
951
+ * @param {number} [body_size_limit]
952
+ */
953
+ function get_raw_body(req, body_size_limit) {
954
+ const h = req.headers;
955
+
956
+ if (!h['content-type']) {
957
+ return null;
958
+ }
959
+
960
+ const content_length = Number(h['content-length']);
961
+
962
+ // check if no request body
963
+ if (
964
+ (req.httpVersionMajor === 1 && isNaN(content_length) && h['transfer-encoding'] == null) ||
965
+ content_length === 0
966
+ ) {
967
+ return null;
968
+ }
969
+
970
+ let length = content_length;
971
+
972
+ if (body_size_limit) {
973
+ if (!length) {
974
+ length = body_size_limit;
975
+ } else if (length > body_size_limit) {
976
+ throw error(
977
+ 413,
978
+ `Received content-length of ${length}, but only accept up to ${body_size_limit} bytes.`
979
+ );
980
+ }
981
+ }
982
+
983
+ if (req.destroyed) {
984
+ const readable = new ReadableStream();
985
+ readable.cancel();
986
+ return readable;
987
+ }
988
+
989
+ let size = 0;
990
+ let cancelled = false;
991
+
992
+ return new ReadableStream({
993
+ start(controller) {
994
+ req.on('error', (error) => {
995
+ cancelled = true;
996
+ controller.error(error);
997
+ });
998
+
999
+ req.on('end', () => {
1000
+ if (cancelled) return;
1001
+ controller.close();
1002
+ });
1003
+
1004
+ req.on('data', (chunk) => {
1005
+ if (cancelled) return;
1006
+
1007
+ size += chunk.length;
1008
+ if (size > length) {
1009
+ cancelled = true;
1010
+ controller.error(
1011
+ error(
1012
+ 413,
1013
+ `request body size exceeded ${
1014
+ content_length ? "'content-length'" : 'BODY_SIZE_LIMIT'
1015
+ } of ${length}`
1016
+ )
1017
+ );
1018
+ return;
1019
+ }
1020
+
1021
+ controller.enqueue(chunk);
1022
+
1023
+ if (controller.desiredSize === null || controller.desiredSize <= 0) {
1024
+ req.pause();
1025
+ }
1026
+ });
1027
+ },
1028
+
1029
+ pull() {
1030
+ req.resume();
1031
+ },
1032
+
1033
+ cancel(reason) {
1034
+ cancelled = true;
1035
+ req.destroy(reason);
1036
+ }
1037
+ });
1038
+ }
1039
+
1040
+ /**
1041
+ * @param {{
1042
+ * request: import('http').IncomingMessage;
1043
+ * base: string;
1044
+ * bodySizeLimit?: number;
1045
+ * }} options
1046
+ * @returns {Promise<Request>}
1047
+ */
1048
+ async function getRequest({ request, base, bodySizeLimit }) {
1049
+ return new Request(base + request.url, {
1050
+ // @ts-expect-error
1051
+ duplex: 'half',
1052
+ method: request.method,
1053
+ headers: /** @type {Record<string, string>} */ (request.headers),
1054
+ body: get_raw_body(request, bodySizeLimit)
1055
+ });
1056
+ }
1057
+
1058
+ /**
1059
+ * @param {import('http').ServerResponse} res
1060
+ * @param {Response} response
1061
+ * @returns {Promise<void>}
1062
+ */
1063
+ async function setResponse(res, response) {
1064
+ for (const [key, value] of response.headers) {
1065
+ try {
1066
+ res.setHeader(
1067
+ key,
1068
+ key === 'set-cookie'
1069
+ ? splitCookiesString_1(
1070
+ // This is absurd but necessary, TODO: investigate why
1071
+ /** @type {string}*/ (response.headers.get(key))
1072
+ )
1073
+ : value
1074
+ );
1075
+ } catch (error) {
1076
+ res.getHeaderNames().forEach((name) => res.removeHeader(name));
1077
+ res.writeHead(500).end(String(error));
1078
+ return;
1079
+ }
1080
+ }
1081
+
1082
+ res.writeHead(response.status);
1083
+
1084
+ if (!response.body) {
1085
+ res.end();
1086
+ return;
1087
+ }
1088
+
1089
+ if (response.body.locked) {
1090
+ res.end(
1091
+ 'Fatal error: Response body is locked. ' +
1092
+ "This can happen when the response was already read (for example through 'response.json()' or 'response.text()')."
1093
+ );
1094
+ return;
1095
+ }
1096
+
1097
+ const reader = response.body.getReader();
1098
+
1099
+ if (res.destroyed) {
1100
+ reader.cancel();
1101
+ return;
1102
+ }
1103
+
1104
+ const cancel = (/** @type {Error|undefined} */ error) => {
1105
+ res.off('close', cancel);
1106
+ res.off('error', cancel);
1107
+
1108
+ // If the reader has already been interrupted with an error earlier,
1109
+ // then it will appear here, it is useless, but it needs to be catch.
1110
+ reader.cancel(error).catch(() => {});
1111
+ if (error) res.destroy(error);
1112
+ };
1113
+
1114
+ res.on('close', cancel);
1115
+ res.on('error', cancel);
1116
+
1117
+ next();
1118
+ async function next() {
1119
+ try {
1120
+ for (;;) {
1121
+ const { done, value } = await reader.read();
1122
+
1123
+ if (done) break;
1124
+
1125
+ if (!res.write(value)) {
1126
+ res.once('drain', next);
1127
+ return;
1128
+ }
1129
+ }
1130
+ res.end();
1131
+ } catch (error) {
1132
+ cancel(error instanceof Error ? error : new Error(String(error)));
1133
+ }
1134
+ }
1135
+ }
1136
+
1137
+ /* global "" */
1138
+
1139
+ const server = new Server(manifest);
1140
+ await server.init({ env: process.env });
1141
+ const origin = env('ORIGIN', undefined);
1142
+ const xff_depth = parseInt(env('XFF_DEPTH', '1'));
1143
+ const address_header = env('ADDRESS_HEADER', '').toLowerCase();
1144
+ const protocol_header = env('PROTOCOL_HEADER', '').toLowerCase();
1145
+ const host_header = env('HOST_HEADER', 'host').toLowerCase();
1146
+ const body_size_limit = parseInt(env('BODY_SIZE_LIMIT', '524288'));
1147
+
1148
+ const dir = path.dirname(fileURLToPath(import.meta.url));
1149
+
1150
+ /**
1151
+ * @param {string} path
1152
+ * @param {boolean} client
1153
+ */
1154
+ function serve(path, client = false) {
1155
+ return (
1156
+ fs$1.existsSync(path) &&
1157
+ sirv(path, {
1158
+ etag: true,
1159
+ gzip: true,
1160
+ brotli: true,
1161
+ setHeaders:
1162
+ client &&
1163
+ ((res, pathname) => {
1164
+ // only apply to build directory, not e.g. version.json
1165
+ if (pathname.startsWith(`/${manifest.appPath}/immutable/`) && res.statusCode === 200) {
1166
+ res.setHeader('cache-control', 'public,max-age=31536000,immutable');
1167
+ }
1168
+ })
1169
+ })
1170
+ );
1171
+ }
1172
+
1173
+ // required because the static file server ignores trailing slashes
1174
+ /** @returns {import('polka').Middleware} */
1175
+ function serve_prerendered() {
1176
+ const handler = serve(path.join(dir, 'prerendered'));
1177
+
1178
+ return (req, res, next) => {
1179
+ let { pathname, search, query } = parse$1(req);
1180
+
1181
+ try {
1182
+ pathname = decodeURIComponent(pathname);
1183
+ } catch {
1184
+ // ignore invalid URI
1185
+ }
1186
+
1187
+ if (prerendered.has(pathname)) {
1188
+ return handler(req, res, next);
1189
+ }
1190
+
1191
+ // remove or add trailing slash as appropriate
1192
+ let location = pathname.at(-1) === '/' ? pathname.slice(0, -1) : pathname + '/';
1193
+ if (prerendered.has(location)) {
1194
+ if (query) location += search;
1195
+ res.writeHead(308, { location }).end();
1196
+ } else {
1197
+ next();
1198
+ }
1199
+ };
1200
+ }
1201
+
1202
+ /** @type {import('polka').Middleware} */
1203
+ const ssr = async (req, res) => {
1204
+ /** @type {Request | undefined} */
1205
+ let request;
1206
+
1207
+ try {
1208
+ request = await getRequest({
1209
+ base: origin || get_origin(req.headers),
1210
+ request: req,
1211
+ bodySizeLimit: body_size_limit
1212
+ });
1213
+ } catch (err) {
1214
+ res.statusCode = err.status || 400;
1215
+ res.end('Invalid request body');
1216
+ return;
1217
+ }
1218
+
1219
+ setResponse(
1220
+ res,
1221
+ await server.respond(request, {
1222
+ platform: { req },
1223
+ getClientAddress: () => {
1224
+ if (address_header) {
1225
+ if (!(address_header in req.headers)) {
1226
+ throw new Error(
1227
+ `Address header was specified with ${
1228
+ "" + 'ADDRESS_HEADER'
1229
+ }=${address_header} but is absent from request`
1230
+ );
1231
+ }
1232
+
1233
+ const value = /** @type {string} */ (req.headers[address_header]) || '';
1234
+
1235
+ if (address_header === 'x-forwarded-for') {
1236
+ const addresses = value.split(',');
1237
+
1238
+ if (xff_depth < 1) {
1239
+ throw new Error(`${"" + 'XFF_DEPTH'} must be a positive integer`);
1240
+ }
1241
+
1242
+ if (xff_depth > addresses.length) {
1243
+ throw new Error(
1244
+ `${"" + 'XFF_DEPTH'} is ${xff_depth}, but only found ${
1245
+ addresses.length
1246
+ } addresses`
1247
+ );
1248
+ }
1249
+ return addresses[addresses.length - xff_depth].trim();
1250
+ }
1251
+
1252
+ return value;
1253
+ }
1254
+
1255
+ return (
1256
+ req.connection?.remoteAddress ||
1257
+ // @ts-expect-error
1258
+ req.connection?.socket?.remoteAddress ||
1259
+ req.socket?.remoteAddress ||
1260
+ // @ts-expect-error
1261
+ req.info?.remoteAddress
1262
+ );
1263
+ }
1264
+ })
1265
+ );
1266
+ };
1267
+
1268
+ /** @param {import('polka').Middleware[]} handlers */
1269
+ function sequence(handlers) {
1270
+ /** @type {import('polka').Middleware} */
1271
+ return (req, res, next) => {
1272
+ /**
1273
+ * @param {number} i
1274
+ * @returns {ReturnType<import('polka').Middleware>}
1275
+ */
1276
+ function handle(i) {
1277
+ if (i < handlers.length) {
1278
+ return handlers[i](req, res, () => handle(i + 1));
1279
+ } else {
1280
+ return next();
1281
+ }
1282
+ }
1283
+
1284
+ return handle(0);
1285
+ };
1286
+ }
1287
+
1288
+ /**
1289
+ * @param {import('http').IncomingHttpHeaders} headers
1290
+ * @returns
1291
+ */
1292
+ function get_origin(headers) {
1293
+ const protocol = (protocol_header && headers[protocol_header]) || 'https';
1294
+ const host = headers[host_header];
1295
+ return `${protocol}://${host}`;
1296
+ }
1297
+
1298
+ const handler = sequence(
1299
+ [
1300
+ serve(path.join(dir, 'client'), true),
1301
+ serve(path.join(dir, 'static')),
1302
+ serve_prerendered(),
1303
+ ssr
1304
+ ].filter(Boolean)
1305
+ );
1306
+
1307
+ export { handler };