@fastly/compute-js-static-publish 3.6.0 → 4.0.0-alpha.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 (197) hide show
  1. package/README.md +441 -103
  2. package/build/assets/asset-manager.d.ts +7 -0
  3. package/build/assets/asset-manager.d.ts.map +1 -0
  4. package/build/assets/asset-manager.js +11 -0
  5. package/build/assets/content-assets.d.ts +29 -0
  6. package/build/assets/content-assets.d.ts.map +1 -0
  7. package/build/assets/content-assets.js +88 -0
  8. package/build/assets/module-assets.d.ts +23 -0
  9. package/build/assets/module-assets.d.ts.map +1 -0
  10. package/build/assets/module-assets.js +45 -0
  11. package/build/cli/build-static.d.ts.map +1 -0
  12. package/build/cli/build-static.js +524 -0
  13. package/build/cli/clean-object-store.d.ts +2 -0
  14. package/build/cli/clean-object-store.d.ts.map +1 -0
  15. package/build/cli/cli.d.ts.map +1 -0
  16. package/build/{cli.js → cli/cli.js} +0 -0
  17. package/build/cli/commands/build-static.d.ts +3 -0
  18. package/build/cli/commands/build-static.d.ts.map +1 -0
  19. package/build/cli/commands/build-static.js +502 -0
  20. package/build/cli/commands/clean-object-store.d.ts +3 -0
  21. package/build/cli/commands/clean-object-store.d.ts.map +1 -0
  22. package/build/cli/commands/clean-object-store.js +54 -0
  23. package/build/cli/commands/init-app.d.ts.map +1 -0
  24. package/build/cli/commands/init-app.js +559 -0
  25. package/build/cli/compression/brotli.d.ts +3 -0
  26. package/build/cli/compression/brotli.d.ts.map +1 -0
  27. package/build/cli/compression/brotli.js +15 -0
  28. package/build/cli/compression/gzip.d.ts +3 -0
  29. package/build/cli/compression/gzip.d.ts.map +1 -0
  30. package/build/cli/compression/gzip.js +15 -0
  31. package/build/cli/compression/index.d.ts +8 -0
  32. package/build/cli/compression/index.d.ts.map +1 -0
  33. package/build/cli/compression/index.js +12 -0
  34. package/build/cli/index.d.ts +3 -0
  35. package/build/cli/index.d.ts.map +1 -0
  36. package/build/cli/index.js +86 -0
  37. package/build/cli/init-app.d.ts +3 -0
  38. package/build/cli/init-app.d.ts.map +1 -0
  39. package/build/{init-app.js → cli/init-app.js} +16 -16
  40. package/build/cli/load-config.d.ts +3 -0
  41. package/build/cli/load-config.d.ts.map +1 -0
  42. package/build/cli/load-config.js +357 -0
  43. package/build/cli/presets/implementations/create-react-app.d.ts +11 -0
  44. package/build/cli/presets/implementations/create-react-app.d.ts.map +1 -0
  45. package/build/cli/presets/implementations/create-react-app.js +34 -0
  46. package/build/cli/presets/implementations/docusaurus.d.ts +7 -0
  47. package/build/cli/presets/implementations/docusaurus.d.ts.map +1 -0
  48. package/build/cli/presets/implementations/docusaurus.js +13 -0
  49. package/build/cli/presets/implementations/gatsby.d.ts +7 -0
  50. package/build/cli/presets/implementations/gatsby.d.ts.map +1 -0
  51. package/build/cli/presets/implementations/gatsby.js +13 -0
  52. package/build/cli/presets/implementations/next.d.ts +7 -0
  53. package/build/cli/presets/implementations/next.d.ts.map +1 -0
  54. package/build/cli/presets/implementations/next.js +13 -0
  55. package/build/cli/presets/implementations/sveltekit.d.ts +7 -0
  56. package/build/cli/presets/implementations/sveltekit.d.ts.map +1 -0
  57. package/build/cli/presets/implementations/sveltekit.js +13 -0
  58. package/build/cli/presets/implementations/vite.d.ts +7 -0
  59. package/build/cli/presets/implementations/vite.d.ts.map +1 -0
  60. package/build/cli/presets/implementations/vite.js +13 -0
  61. package/build/cli/presets/index.d.ts +3 -0
  62. package/build/cli/presets/index.d.ts.map +1 -0
  63. package/build/cli/presets/index.js +16 -0
  64. package/build/cli/presets/preset-base.d.ts +19 -0
  65. package/build/cli/presets/preset-base.d.ts.map +1 -0
  66. package/build/cli/util/data.d.ts +7 -0
  67. package/build/cli/util/data.d.ts.map +1 -0
  68. package/build/cli/util/data.js +58 -0
  69. package/build/cli/util/fastly-api.d.ts +10 -0
  70. package/build/cli/util/fastly-api.d.ts.map +1 -0
  71. package/build/cli/util/fastly-api.js +47 -0
  72. package/build/cli/util/files.d.ts +11 -0
  73. package/build/cli/util/files.d.ts.map +1 -0
  74. package/build/cli/util/files.js +33 -0
  75. package/build/cli/util/hash.d.ts +5 -0
  76. package/build/cli/util/hash.d.ts.map +1 -0
  77. package/build/cli/util/hash.js +9 -0
  78. package/build/cli/util/id.d.ts +3 -0
  79. package/build/cli/util/id.d.ts.map +1 -0
  80. package/build/cli/util/id.js +17 -0
  81. package/build/cli/util/object-store.d.ts +16 -0
  82. package/build/cli/util/object-store.d.ts.map +1 -0
  83. package/build/cli/util/object-store.js +108 -0
  84. package/build/cli/util/publish-id.d.ts +5 -0
  85. package/build/cli/util/publish-id.d.ts.map +1 -0
  86. package/build/cli/util/publish-id.js +26 -0
  87. package/build/constants/compression.d.ts +3 -0
  88. package/build/constants/compression.d.ts.map +1 -0
  89. package/build/constants/compression.js +4 -0
  90. package/build/index.d.ts +5 -2
  91. package/build/index.d.ts.map +1 -1
  92. package/build/index.js +5 -1
  93. package/build/presets/implementations/create-react-app.js +1 -2
  94. package/build/presets/preset-base.d.ts +1 -1
  95. package/build/presets/preset-base.d.ts.map +1 -1
  96. package/build/server/assets/asset-manager.d.ts +7 -0
  97. package/build/server/assets/asset-manager.d.ts.map +1 -0
  98. package/build/server/assets/asset-manager.js +11 -0
  99. package/build/server/assets/content-assets.d.ts +33 -0
  100. package/build/server/assets/content-assets.d.ts.map +1 -0
  101. package/build/server/assets/content-assets.js +142 -0
  102. package/build/server/assets/module-assets.d.ts +23 -0
  103. package/build/server/assets/module-assets.d.ts.map +1 -0
  104. package/build/server/assets/module-assets.js +45 -0
  105. package/build/server/object-store/include-bytes-store-entry.d.ts +19 -0
  106. package/build/server/object-store/include-bytes-store-entry.d.ts.map +1 -0
  107. package/build/server/object-store/include-bytes-store-entry.js +87 -0
  108. package/build/server/object-store/inline-store-entry.d.ts +25 -0
  109. package/build/server/object-store/inline-store-entry.d.ts.map +1 -0
  110. package/build/server/object-store/inline-store-entry.js +99 -0
  111. package/build/server/publisher-server.d.ts +23 -0
  112. package/build/server/publisher-server.d.ts.map +1 -0
  113. package/build/server/publisher-server.js +257 -0
  114. package/build/server/serve-preconditions/if-modified-since.d.ts +4 -0
  115. package/build/server/serve-preconditions/if-modified-since.d.ts.map +1 -0
  116. package/build/server/serve-preconditions/if-modified-since.js +26 -0
  117. package/build/server/serve-preconditions/if-none-match.d.ts +3 -0
  118. package/build/server/serve-preconditions/if-none-match.d.ts.map +1 -0
  119. package/build/server/serve-preconditions/if-none-match.js +24 -0
  120. package/build/server/util/http.d.ts +2 -0
  121. package/build/server/util/http.d.ts.map +1 -0
  122. package/build/server/util/http.js +9 -0
  123. package/build/types/compute.d.ts +11 -0
  124. package/build/types/compute.d.ts.map +1 -0
  125. package/build/types/compute.js +1 -0
  126. package/build/types/config-normalized.d.ts +33 -0
  127. package/build/types/config-normalized.d.ts.map +1 -0
  128. package/build/types/config-normalized.js +1 -0
  129. package/build/types/config.d.ts +36 -0
  130. package/build/types/config.d.ts.map +1 -0
  131. package/build/types/config.js +1 -0
  132. package/build/types/content-assets.d.ts +38 -0
  133. package/build/types/content-assets.d.ts.map +1 -0
  134. package/build/types/content-assets.js +1 -0
  135. package/build/types/content-types.d.ts +11 -0
  136. package/build/types/content-types.d.ts.map +1 -0
  137. package/build/types/content-types.js +1 -0
  138. package/build/types/index.d.ts +7 -0
  139. package/build/types/index.d.ts.map +1 -0
  140. package/build/types/index.js +1 -0
  141. package/build/types/module-assets.d.ts +15 -0
  142. package/build/types/module-assets.d.ts.map +1 -0
  143. package/build/types/module-assets.js +1 -0
  144. package/build/types/util.d.ts +7 -0
  145. package/build/types/util.d.ts.map +1 -0
  146. package/build/types/util.js +1 -0
  147. package/build/util/content-types.d.ts +5 -0
  148. package/build/util/content-types.d.ts.map +1 -0
  149. package/build/util/content-types.js +92 -0
  150. package/build/util/data.d.ts +7 -0
  151. package/build/util/data.d.ts.map +1 -0
  152. package/build/util/data.js +58 -0
  153. package/build/util/fastly-api.d.ts +10 -0
  154. package/build/util/fastly-api.d.ts.map +1 -0
  155. package/build/util/fastly-api.js +47 -0
  156. package/build/util/files.d.ts +10 -0
  157. package/build/util/files.d.ts.map +1 -0
  158. package/build/util/files.js +32 -0
  159. package/build/util/hash.d.ts +2 -0
  160. package/build/util/hash.d.ts.map +1 -0
  161. package/build/util/hash.js +8 -0
  162. package/build/util/id.d.ts +3 -0
  163. package/build/util/id.d.ts.map +1 -0
  164. package/build/util/id.js +17 -0
  165. package/build/util/index.d.ts +3 -0
  166. package/build/util/index.d.ts.map +1 -0
  167. package/build/util/index.js +2 -0
  168. package/build/util/metadata.d.ts +3 -0
  169. package/build/util/metadata.d.ts.map +1 -0
  170. package/build/util/metadata.js +12 -0
  171. package/build/util/object-store.d.ts +12 -0
  172. package/build/util/object-store.d.ts.map +1 -0
  173. package/build/util/object-store.js +80 -0
  174. package/package.json +9 -5
  175. package/resources/index.js +9 -114
  176. package/resources/statics-metadata.d.ts +10 -0
  177. package/resources/statics.d.ts +15 -7
  178. package/resources/webpack.config.js +4 -10
  179. package/build/assets.d.ts +0 -8
  180. package/build/assets.d.ts.map +0 -1
  181. package/build/assets.js +0 -24
  182. package/build/build-static.d.ts.map +0 -1
  183. package/build/build-static.js +0 -249
  184. package/build/cli.d.ts.map +0 -1
  185. package/build/init-app.d.ts.map +0 -1
  186. package/build/static-assets.d.ts +0 -11
  187. package/build/static-assets.d.ts.map +0 -1
  188. package/build/static-assets.js +0 -33
  189. package/build/types.d.ts +0 -50
  190. package/build/types.d.ts.map +0 -1
  191. package/resources/default-content-types.cjs +0 -106
  192. package/resources/default-content-types.d.ts +0 -15
  193. /package/build/{build-static.d.ts → cli/build-static.d.ts} +0 -0
  194. /package/build/{content-types.js → cli/clean-object-store.js} +0 -0
  195. /package/build/{cli.d.ts → cli/cli.d.ts} +0 -0
  196. /package/build/{init-app.d.ts → cli/commands/init-app.d.ts} +0 -0
  197. /package/build/{types.js → cli/presets/preset-base.js} +0 -0
@@ -0,0 +1,257 @@
1
+ import { checkIfModifiedSince, getIfModifiedSinceHeader } from "./serve-preconditions/if-modified-since.js";
2
+ import { checkIfNoneMatch, getIfNoneMatchHeader } from "./serve-preconditions/if-none-match.js";
3
+ import { buildHeadersSubset } from "./util/http.js";
4
+ // https://httpwg.org/specs/rfc9110.html#rfc.section.15.4.5
5
+ // The server generating a 304 response MUST generate any of the following header fields that would have been sent in
6
+ // a 200 (OK) response to the same request:
7
+ // * Content-Location, Date, ETag, and Vary
8
+ // * Cache-Control and Expires
9
+ const headersToPreserveForUnmodified = ['Content-Location', 'ETag', 'Vary', 'Cache-Control', 'Expires'];
10
+ function requestAcceptsTextHtml(req) {
11
+ const accept = (req.headers.get('Accept') ?? '')
12
+ .split(',')
13
+ .map(x => x.split(';')[0]);
14
+ if (!accept.includes('text/html') && !accept.includes('*/*') && accept.includes('*')) {
15
+ return false;
16
+ }
17
+ return true;
18
+ }
19
+ export class PublisherServer {
20
+ constructor(serverConfig, contentAssets) {
21
+ this.serverConfig = serverConfig;
22
+ this.contentAssets = contentAssets;
23
+ this.staticItems = serverConfig.staticItems
24
+ .map((x, i) => {
25
+ if (x.startsWith('re:')) {
26
+ const fragments = x.slice(3).match(/\/(.*?)\/([a-z]*)?$/i);
27
+ if (fragments == null) {
28
+ console.warn(`Cannot parse staticItems item index ${i}: '${x}', skipping...`);
29
+ return '';
30
+ }
31
+ return new RegExp(fragments[1], fragments[2] || '');
32
+ }
33
+ return x;
34
+ })
35
+ .filter(x => Boolean(x));
36
+ }
37
+ getMatchingAsset(path) {
38
+ const assetKey = this.serverConfig.publicDirPrefix + path;
39
+ if (!assetKey.endsWith('/')) {
40
+ // A path that does not end in a slash can match an asset directly
41
+ const asset = this.contentAssets.getAsset(assetKey);
42
+ if (asset != null) {
43
+ return asset;
44
+ }
45
+ // ... or, we can try auto-ext:
46
+ // looks for an asset that has the specified suffix (usually extension, such as .html)
47
+ for (const extEntry of this.serverConfig.autoExt) {
48
+ let assetKeyWithExt = assetKey + extEntry;
49
+ const asset = this.contentAssets.getAsset(assetKeyWithExt);
50
+ if (asset != null) {
51
+ return asset;
52
+ }
53
+ }
54
+ }
55
+ if (this.serverConfig.autoIndex.length > 0) {
56
+ // try auto-index:
57
+ // treats the path as a directory, and looks for an asset with the specified
58
+ // suffix (usually an index file, such as index.html)
59
+ let assetNameAsDir = assetKey;
60
+ // remove all slashes from end, and add one trailing slash
61
+ while (assetNameAsDir.endsWith('/')) {
62
+ assetNameAsDir = assetNameAsDir.slice(0, -1);
63
+ }
64
+ assetNameAsDir = assetNameAsDir + '/';
65
+ for (const indexEntry of this.serverConfig.autoIndex) {
66
+ let assetKeyIndex = assetNameAsDir + indexEntry;
67
+ const asset = this.contentAssets.getAsset(assetKeyIndex);
68
+ if (asset != null) {
69
+ return asset;
70
+ }
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+ findAcceptEncodings(request) {
76
+ if (this.serverConfig.compression.length === 0) {
77
+ return [];
78
+ }
79
+ const found = (request.headers.get('accept-encoding') ?? '')
80
+ .split(',')
81
+ .map(x => {
82
+ let [encodingValue, qValueStr] = x.trim().split(';');
83
+ let qValue; // q value multiplied by 1000
84
+ if (qValueStr == null || !qValueStr.startsWith('q=')) {
85
+ // use default of 1.0
86
+ qValue = 1000;
87
+ }
88
+ else {
89
+ qValueStr = qValueStr.slice(2); // remove the q=
90
+ qValue = parseFloat(qValueStr);
91
+ if (Number.isNaN(qValue) || qValue > 1) {
92
+ qValue = 1;
93
+ }
94
+ if (qValue < 0) {
95
+ qValue = 0;
96
+ }
97
+ // q values can have up to 3 decimal digits
98
+ qValue = Math.floor(qValue * 1000);
99
+ }
100
+ return [encodingValue.trim(), qValue];
101
+ })
102
+ .filter(([encoding]) => this.serverConfig.compression.includes(encoding));
103
+ const priorityMap = new Map;
104
+ for (const [encoding, qValue] of found) {
105
+ let typesForQValue = priorityMap.get(qValue);
106
+ if (typesForQValue == null) {
107
+ typesForQValue = [];
108
+ priorityMap.set(qValue, typesForQValue);
109
+ }
110
+ typesForQValue.push(encoding);
111
+ }
112
+ // Sort keys, larger numbers to come first
113
+ const keysSorted = [...priorityMap.keys()]
114
+ .sort((qValueA, qValueB) => qValueB - qValueA);
115
+ return keysSorted
116
+ .map(qValue => priorityMap.get(qValue));
117
+ }
118
+ testExtendedCache(pathname) {
119
+ return this.staticItems
120
+ .some(x => {
121
+ if (x instanceof RegExp) {
122
+ return x.test(pathname);
123
+ }
124
+ if (x.endsWith('/')) {
125
+ return pathname.startsWith(x);
126
+ }
127
+ return x === pathname;
128
+ });
129
+ }
130
+ handlePreconditions(request, asset, responseHeaders) {
131
+ // Handle preconditions according to https://httpwg.org/specs/rfc9110.html#rfc.section.13.2.2
132
+ // A recipient cache or origin server MUST evaluate the request preconditions defined by this specification in the following order:
133
+ // 1. When recipient is the origin server and If-Match is present, evaluate the If-Match precondition:
134
+ // - if true, continue to step 3
135
+ // - if false, respond 412 (Precondition Failed) unless it can be determined that the state-changing request has already succeeded (see Section 13.1.1)
136
+ // 2. When recipient is the origin server, If-Match is not present, and If-Unmodified-Since is present, evaluate the If-Unmodified-Since precondition:
137
+ // - if true, continue to step 3
138
+ // - if false, respond 412 (Precondition Failed) unless it can be determined that the state-changing request has already succeeded (see Section 13.1.4)
139
+ // 3. When If-None-Match is present, evaluate the If-None-Match precondition:
140
+ // - if true, continue to step 5
141
+ // - if false for GET/HEAD, respond 304 (Not Modified)
142
+ // - if false for other methods, respond 412 (Precondition Failed)
143
+ let skipIfNoneMatch = false;
144
+ {
145
+ const headerValue = getIfNoneMatchHeader(request);
146
+ if (headerValue.length > 0) {
147
+ const result = checkIfNoneMatch(responseHeaders['ETag'], headerValue);
148
+ if (result) {
149
+ skipIfNoneMatch = true;
150
+ }
151
+ else {
152
+ return new Response(null, {
153
+ status: 304,
154
+ headers: buildHeadersSubset(responseHeaders, headersToPreserveForUnmodified),
155
+ });
156
+ }
157
+ }
158
+ }
159
+ // 4. When the method is GET or HEAD, If-None-Match is not present, and If-Modified-Since is present, evaluate the
160
+ // If-Modified-Since precondition:
161
+ // - if true, continue to step 5
162
+ // - if false, respond 304 (Not Modified)
163
+ if (!skipIfNoneMatch) {
164
+ // For us, method is always GET or HEAD here.
165
+ const headerValue = getIfModifiedSinceHeader(request);
166
+ if (headerValue != null) {
167
+ const result = checkIfModifiedSince(asset, headerValue);
168
+ if (!result) {
169
+ return new Response(null, {
170
+ status: 304,
171
+ headers: buildHeadersSubset(responseHeaders, headersToPreserveForUnmodified),
172
+ });
173
+ }
174
+ }
175
+ }
176
+ // 5. When the method is GET and both Range and If-Range are present, evaluate the If-Range precondition:
177
+ // - if true and the Range is applicable to the selected representation, respond 206 (Partial Content)
178
+ // - otherwise, ignore the Range header field and respond 200 (OK)
179
+ // 6. Otherwise,
180
+ // - perform the requested method and respond according to its success or failure.
181
+ return null;
182
+ }
183
+ async serveAsset(request, asset, init) {
184
+ const metadata = asset.getMetadata();
185
+ const headers = {
186
+ 'Content-Type': metadata.contentType,
187
+ };
188
+ Object.assign(headers, init?.headers);
189
+ if (init?.cache != null) {
190
+ let cacheControlValue;
191
+ switch (init.cache) {
192
+ case 'extended':
193
+ cacheControlValue = 'max-age=31536000';
194
+ break;
195
+ case 'never':
196
+ cacheControlValue = 'no-store';
197
+ break;
198
+ }
199
+ headers['Cache-Control'] = cacheControlValue;
200
+ }
201
+ const acceptEncodings = this.findAcceptEncodings(request);
202
+ const storeEntry = await asset.getStoreEntry(acceptEncodings);
203
+ if (storeEntry.contentEncoding != null) {
204
+ headers['Content-Encoding'] = storeEntry.contentEncoding;
205
+ }
206
+ headers['ETag'] = `"${storeEntry.hash}"`;
207
+ if (metadata.lastModifiedTime !== 0) {
208
+ headers['Last-Modified'] = (new Date(metadata.lastModifiedTime * 1000)).toUTCString();
209
+ }
210
+ const preconditionResponse = this.handlePreconditions(request, asset, headers);
211
+ if (preconditionResponse != null) {
212
+ return preconditionResponse;
213
+ }
214
+ return new Response(storeEntry.body, {
215
+ status: init?.status ?? 200,
216
+ headers,
217
+ });
218
+ }
219
+ async serveRequest(request) {
220
+ // Only handle GET and HEAD
221
+ if (request.method !== 'GET' && request.method !== 'HEAD') {
222
+ return null;
223
+ }
224
+ const url = new URL(request.url);
225
+ const pathname = url.pathname;
226
+ const asset = this.getMatchingAsset(pathname);
227
+ if (asset != null) {
228
+ return this.serveAsset(request, asset, {
229
+ cache: this.testExtendedCache(pathname) ? 'extended' : null,
230
+ });
231
+ }
232
+ // fallback HTML responses, like SPA and "not found" pages
233
+ if (requestAcceptsTextHtml(request)) {
234
+ // These are raw asset paths, not relative to public path
235
+ const { spaFile } = this.serverConfig;
236
+ if (spaFile != null) {
237
+ const asset = this.contentAssets.getAsset(spaFile);
238
+ if (asset != null) {
239
+ return this.serveAsset(request, asset, {
240
+ cache: 'never',
241
+ });
242
+ }
243
+ }
244
+ const { notFoundPageFile } = this.serverConfig;
245
+ if (notFoundPageFile != null) {
246
+ const asset = this.contentAssets.getAsset(notFoundPageFile);
247
+ if (asset != null) {
248
+ return this.serveAsset(request, asset, {
249
+ status: 404,
250
+ cache: 'never',
251
+ });
252
+ }
253
+ }
254
+ }
255
+ return null;
256
+ }
257
+ }
@@ -0,0 +1,4 @@
1
+ import { ContentAsset } from "../../types/index.js";
2
+ export declare function getIfModifiedSinceHeader(request: Request): number | null;
3
+ export declare function checkIfModifiedSince(asset: ContentAsset, ifModifiedSince: number): boolean;
4
+ //# sourceMappingURL=if-modified-since.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"if-modified-since.d.ts","sourceRoot":"","sources":["../../../src/server/serve-preconditions/if-modified-since.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAgBxE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAW1F"}
@@ -0,0 +1,26 @@
1
+ // https://httpwg.org/specs/rfc9110.html#field.if-modified-since
2
+ export function getIfModifiedSinceHeader(request) {
3
+ // A recipient MUST ignore the If-Modified-Since header field if the received
4
+ // field value is not a valid HTTP-date, the field value has more than one
5
+ // member, or if the request method is neither GET nor HEAD.
6
+ const headerValue = request.headers.get('If-Modified-Since');
7
+ if (headerValue == null || headerValue === '') {
8
+ return null;
9
+ }
10
+ const dateValueMs = Date.parse(headerValue);
11
+ if (Number.isNaN(dateValueMs)) {
12
+ // Date.parse returns NaN if the date cannot be parsed.
13
+ return null;
14
+ }
15
+ // We want to return this as a number of seconds;
16
+ return Math.floor(dateValueMs / 1000);
17
+ }
18
+ export function checkIfModifiedSince(asset, ifModifiedSince) {
19
+ // 1. If the selected representation's last modification date is earlier or equal to the
20
+ // date provided in the field value, the condition is false.
21
+ if (asset.getMetadata().lastModifiedTime <= ifModifiedSince) {
22
+ return false;
23
+ }
24
+ // 2. Otherwise, the condition is true.
25
+ return true;
26
+ }
@@ -0,0 +1,3 @@
1
+ export declare function getIfNoneMatchHeader(request: Request): string[];
2
+ export declare function checkIfNoneMatch(etag: string, headerValue: string[]): boolean;
3
+ //# sourceMappingURL=if-none-match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"if-none-match.d.ts","sourceRoot":"","sources":["../../../src/server/serve-preconditions/if-none-match.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,CAO/D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAmB7E"}
@@ -0,0 +1,24 @@
1
+ // https://httpwg.org/specs/rfc9110.html#field.if-none-match
2
+ export function getIfNoneMatchHeader(request) {
3
+ return (request.headers.get('If-None-Match') ?? '')
4
+ .split(',')
5
+ .map(x => x.trim())
6
+ .filter(x => Boolean(x));
7
+ }
8
+ export function checkIfNoneMatch(etag, headerValue) {
9
+ // 1. If the field value is "*", the condition is false if the origin server has a
10
+ // current representation for the target resource.
11
+ if (headerValue.includes('*')) {
12
+ return false;
13
+ }
14
+ // 2. If the field value is a list of entity tags, the condition is false if one of the listed tags matches the
15
+ // entity tag of the selected representation. A recipient MUST use the weak comparison function when comparing
16
+ // entity tags for If-None-Match (Section 8.8.3.2), since weak entity tags can be used for cache validation even
17
+ // if there have been changes to the representation data.
18
+ // But in our system we don't use weak tags, so we do a compare
19
+ if (headerValue.includes(etag)) {
20
+ return false;
21
+ }
22
+ // 3. Otherwise, the condition is true.
23
+ return true;
24
+ }
@@ -0,0 +1,2 @@
1
+ export declare function buildHeadersSubset(responseHeaders: Record<string, string>, keys: Readonly<string[]>): Record<string, string>;
2
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/server/util/http.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,0BAQnG"}
@@ -0,0 +1,9 @@
1
+ export function buildHeadersSubset(responseHeaders, keys) {
2
+ const resultHeaders = {};
3
+ for (const value of keys) {
4
+ if (value in responseHeaders) {
5
+ resultHeaders[value] = responseHeaders[value];
6
+ }
7
+ }
8
+ return resultHeaders;
9
+ }
@@ -0,0 +1,11 @@
1
+ export interface StoreEntry {
2
+ readonly body: ReadableStream<Uint8Array> | null;
3
+ readonly bodyUsed: boolean;
4
+ arrayBuffer(): Promise<ArrayBuffer>;
5
+ json(): Promise<any>;
6
+ text(): Promise<string>;
7
+ readonly contentEncoding: string | null;
8
+ readonly hash: string;
9
+ readonly size: number;
10
+ }
11
+ //# sourceMappingURL=compute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../src/types/compute.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAGpC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IACrB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ import type { ContentAssetInclusionTest, ExcludeDirTest, ModuleAssetInclusionTest } from "./config.js";
2
+ import type { ContentTypeDef } from "./content-types.js";
3
+ import type { ContentCompressionTypes } from "../constants/compression.js";
4
+ export type ContentAssetInclusionResultNormalized = {
5
+ includeContent: boolean;
6
+ inline: boolean;
7
+ };
8
+ export type ModuleAssetInclusionResultNormalized = {
9
+ includeModule: boolean;
10
+ useStaticImport: boolean;
11
+ };
12
+ export type StaticPublisherConfigNormalized = {
13
+ rootDir: string;
14
+ objectStore: string | null;
15
+ excludeDirs: ExcludeDirTest[];
16
+ excludeDotFiles: boolean;
17
+ includeWellKnown: boolean;
18
+ contentAssetInclusionTest: ContentAssetInclusionTest | null;
19
+ contentCompression: ContentCompressionTypes[];
20
+ moduleAssetInclusionTest: ModuleAssetInclusionTest | null;
21
+ contentTypes: ContentTypeDef[];
22
+ server: PublisherServerConfigNormalized | null;
23
+ };
24
+ export type PublisherServerConfigNormalized = {
25
+ publicDirPrefix: string;
26
+ staticItems: string[];
27
+ compression: ContentCompressionTypes[];
28
+ spaFile: string | null;
29
+ notFoundPageFile: string | null;
30
+ autoExt: string[];
31
+ autoIndex: string[];
32
+ };
33
+ //# sourceMappingURL=config-normalized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-normalized.d.ts","sourceRoot":"","sources":["../../src/types/config-normalized.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,MAAM,MAAM,qCAAqC,GAAG;IAClD,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yBAAyB,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC5D,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;IAC9C,wBAAwB,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC1D,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,MAAM,EAAE,+BAA+B,GAAG,IAAI,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACvC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CAErB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { ContentTypeDef } from "./content-types.js";
2
+ export interface ExcludeDirTest {
3
+ test(name: string): boolean;
4
+ }
5
+ export type ContentAssetInclusionResult = {
6
+ includeContent?: boolean;
7
+ inline?: boolean;
8
+ };
9
+ export type ContentAssetInclusionTest = (assetKey: string, contentType?: string) => ContentAssetInclusionResult | true | 'inline' | false | null;
10
+ export type ModuleAssetInclusionResult = {
11
+ includeModule?: boolean;
12
+ useStaticImport?: boolean;
13
+ };
14
+ export type ModuleAssetInclusionTest = (assetKey: string, contentType?: string) => ModuleAssetInclusionResult | true | false | 'static-import' | null;
15
+ export type StaticPublisherConfig = {
16
+ rootDir: string;
17
+ objectStore?: string | false | null;
18
+ excludeDirs?: (string | ExcludeDirTest)[] | string | ExcludeDirTest | null;
19
+ excludeDotFiles?: boolean;
20
+ includeWellKnown?: boolean;
21
+ contentAssetInclusionTest?: ContentAssetInclusionTest | null;
22
+ contentCompression?: ('br' | 'gzip')[];
23
+ moduleAssetInclusionTest?: ModuleAssetInclusionTest | null;
24
+ contentTypes?: ContentTypeDef[];
25
+ server?: PublisherServerConfig | null;
26
+ };
27
+ export type PublisherServerConfig = {
28
+ publicDirPrefix?: string;
29
+ staticItems?: string[] | string | false | null;
30
+ compression?: ('br' | 'gzip')[];
31
+ spaFile?: string | false | null;
32
+ notFoundPageFile?: string | false | null;
33
+ autoExt?: string[] | string | false | null;
34
+ autoIndex?: string[] | string | false | null;
35
+ };
36
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,2BAA2B,GAAG;IAOxC,cAAc,CAAC,EAAE,OAAO,CAAC;IAKzB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,yBAAyB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,2BAA2B,GAAG,IAAI,GAAG,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC;AAEjJ,MAAM,MAAM,0BAA0B,GAAG;IAMvC,aAAa,CAAC,EAAE,OAAO,CAAC;IAOxB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAGF,MAAM,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,0BAA0B,GAAG,IAAI,GAAG,KAAK,GAAG,eAAe,GAAG,IAAI,CAAC;AAEtJ,MAAM,MAAM,qBAAqB,GAAG;IAElC,OAAO,EAAE,MAAM,CAAC;IAIhB,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAMpC,WAAW,CAAC,EAAE,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,CAAC;IAI3E,eAAe,CAAC,EAAE,OAAO,CAAC;IAI1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAG3B,yBAAyB,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAI7D,kBAAkB,CAAC,EAAE,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC;IAGvC,wBAAwB,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAG3D,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAGhC,MAAM,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACvC,CAAC;AAOF,MAAM,MAAM,qBAAqB,GAAG;IAGlC,eAAe,CAAC,EAAE,MAAM,CAAC;IAQzB,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAK/C,WAAW,CAAC,EAAE,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC;IAIhC,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAIhC,gBAAgB,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAIzC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAI3C,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;CAI9C,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { ContentCompressionTypes } from "../constants/compression.js";
2
+ import type { StoreEntry } from "../types/compute.js";
3
+ export type CompressedFileInfos<TData> = Partial<Record<ContentCompressionTypes, TData>>;
4
+ export type ContentFileInfo = {
5
+ hash: string;
6
+ size: number;
7
+ staticFilePath: string;
8
+ };
9
+ export type ContentFileInfoForObjectStore = ContentFileInfo & {
10
+ objectStoreKey: string;
11
+ };
12
+ export type ContentAssetMetadataMapEntryBase<TFileInfo> = {
13
+ assetKey: string;
14
+ contentType: string;
15
+ text: boolean;
16
+ lastModifiedTime: number;
17
+ fileInfo: TFileInfo;
18
+ compressedFileInfos: CompressedFileInfos<TFileInfo>;
19
+ };
20
+ export type ContentAssetMetadataMapEntryInline = {
21
+ isInline: true;
22
+ } & ContentAssetMetadataMapEntryBase<ContentFileInfo>;
23
+ export type ContentAssetMetadataMapEntryObjectStore = {
24
+ isInline: false;
25
+ } & ContentAssetMetadataMapEntryBase<ContentFileInfoForObjectStore>;
26
+ export type ContentAssetMetadataMapEntry = ContentAssetMetadataMapEntryInline | ContentAssetMetadataMapEntryObjectStore;
27
+ export type ContentAssetMetadataMap = {
28
+ [assetKey: string]: ContentAssetMetadataMapEntry;
29
+ };
30
+ export interface ContentAsset {
31
+ readonly assetKey: string;
32
+ getMetadata(): ContentAssetMetadataMapEntry;
33
+ getStoreEntry(acceptEncodingsGroups?: ContentCompressionTypes[][]): Promise<StoreEntry>;
34
+ getBytes(): Uint8Array;
35
+ getText(): string;
36
+ readonly isInline: boolean;
37
+ }
38
+ //# sourceMappingURL=content-assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-assets.d.ts","sourceRoot":"","sources":["../../src/types/content-assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,MAAM,mBAAmB,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEzF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,eAAe,GAAG;IAC5D,cAAc,EAAE,MAAM,CAAC;CACxB,CAAA;AAED,MAAM,MAAM,gCAAgC,CAAC,SAAS,IAAI;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,mBAAmB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;CACpD,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,QAAQ,EAAE,IAAI,CAAC;CAChB,GAAG,gCAAgC,CAAC,eAAe,CAAC,CAAC;AAEtD,MAAM,MAAM,uCAAuC,GAAG;IACpD,QAAQ,EAAE,KAAK,CAAC;CACjB,GAAG,gCAAgC,CAAC,6BAA6B,CAAC,CAAC;AAEpE,MAAM,MAAM,4BAA4B,GACtC,kCAAkC,GAAG,uCAAuC,CAAC;AAE/E,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,QAAQ,EAAE,MAAM,GAAG,4BAA4B,CAAC;CAClD,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,WAAW,IAAI,4BAA4B,CAAC;IAC5C,aAAa,CAAC,qBAAqB,CAAC,EAAE,uBAAuB,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACxF,QAAQ,IAAI,UAAU,CAAC;IACvB,OAAO,IAAI,MAAM,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ export type ContentTypeTest = (name: string) => boolean;
2
+ export type ContentTypeDef = {
3
+ test: RegExp | ContentTypeTest;
4
+ contentType: string;
5
+ text?: boolean;
6
+ };
7
+ export type ContentTypeTestResult = {
8
+ contentType: string;
9
+ text: boolean;
10
+ };
11
+ //# sourceMappingURL=content-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/types/content-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAGxD,MAAM,MAAM,cAAc,GAAG;IAE3B,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;IAG/B,WAAW,EAAE,MAAM,CAAC;IAIpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export type { StoreEntry, } from './compute.js';
2
+ export type { StaticPublisherConfig, ContentAssetInclusionTest, ContentAssetInclusionResult, ModuleAssetInclusionTest, ModuleAssetInclusionResult, } from './config.js';
3
+ export type { ContentAssetMetadataMap, ContentAssetMetadataMapEntry, ContentAsset, } from './content-assets.js';
4
+ export type { ModuleAssetMap, ModuleAssetMapEntry, ModuleAsset, } from './module-assets.js';
5
+ export type { ContentTypeTest, ContentTypeDef, ContentTypeTestResult, } from './content-types.js';
6
+ export type { PublisherServerConfigNormalized, } from './config-normalized.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,uBAAuB,EACvB,4BAA4B,EAC5B,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,eAAe,EACf,cAAc,EACd,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,+BAA+B,GAChC,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ export type ModuleAssetMapEntry = {
2
+ isStaticImport: boolean;
3
+ module: any | null;
4
+ loadModule: () => Promise<any>;
5
+ };
6
+ export type ModuleAssetMap = {
7
+ [assetKey: string]: ModuleAssetMapEntry;
8
+ };
9
+ export interface ModuleAsset {
10
+ readonly assetKey: string;
11
+ getModule(): Promise<any>;
12
+ getStaticModule(): any | null;
13
+ readonly isStaticImport: boolean;
14
+ }
15
+ //# sourceMappingURL=module-assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-assets.d.ts","sourceRoot":"","sources":["../../src/types/module-assets.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CAChC,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAAC;CACzC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,eAAe,IAAI,GAAG,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export type Merge<T, U> = {
2
+ [TKey in keyof T]: TKey extends keyof U ? (T[TKey] | U[TKey]) : T[TKey];
3
+ };
4
+ export type Unmerge<T, U> = Required<{
5
+ [TKey in keyof T]: TKey extends keyof U ? (Exclude<T[TKey], U[TKey]>) : T[TKey];
6
+ }>;
7
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/types/util.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI;KACvB,IAAI,IAAI,MAAM,CAAC,GAAG,IAAI,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;CACxE,CAAC;AAEF,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC;KAClC,IAAI,IAAI,MAAM,CAAC,GAAG,IAAI,SAAS,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;CAChF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { ContentTypeDef, ContentTypeTestResult } from "../types/content-types.js";
2
+ export declare function getDefaultContentTypes(): ContentTypeDef[];
3
+ export declare function mergeContentTypes(contentTypes: ContentTypeDef[]): ContentTypeDef[];
4
+ export declare function testFileContentType(contentTypes: ContentTypeDef[] | null | undefined, assetKey: string): ContentTypeTestResult | null;
5
+ //# sourceMappingURL=content-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/util/content-types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAoCnC,wBAAgB,sBAAsB,qBAErC;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,cAAc,EAAE,oBAmD/D;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,cAAc,EAAE,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAcrI"}