@fastly/compute-js-static-publish 6.2.0 → 7.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +31 -575
  3. package/README.short.md +53 -0
  4. package/build/cli/commands/clean.d.ts +2 -0
  5. package/build/cli/commands/clean.d.ts.map +1 -0
  6. package/build/cli/commands/clean.js +121 -0
  7. package/build/cli/commands/collections/delete.d.ts +2 -0
  8. package/build/cli/commands/collections/delete.d.ts.map +1 -0
  9. package/build/cli/commands/collections/delete.js +88 -0
  10. package/build/cli/commands/collections/index.d.ts +2 -0
  11. package/build/cli/commands/collections/index.d.ts.map +1 -0
  12. package/build/cli/commands/collections/index.js +52 -0
  13. package/build/cli/commands/collections/list.d.ts +2 -0
  14. package/build/cli/commands/collections/list.d.ts.map +1 -0
  15. package/build/cli/commands/collections/list.js +62 -0
  16. package/build/cli/commands/index.d.ts +2 -0
  17. package/build/cli/commands/index.d.ts.map +1 -0
  18. package/build/cli/commands/index.js +67 -0
  19. package/build/cli/commands/init-app.d.ts +18 -2
  20. package/build/cli/commands/init-app.d.ts.map +1 -1
  21. package/build/cli/commands/init-app.js +291 -264
  22. package/build/cli/commands/publish-content.d.ts +2 -0
  23. package/build/cli/commands/publish-content.d.ts.map +1 -0
  24. package/build/cli/commands/publish-content.js +472 -0
  25. package/build/cli/compression/brotli.d.ts +1 -1
  26. package/build/cli/compression/brotli.d.ts.map +1 -1
  27. package/build/cli/compression/brotli.js +8 -11
  28. package/build/cli/compression/gzip.d.ts +1 -1
  29. package/build/cli/compression/gzip.d.ts.map +1 -1
  30. package/build/cli/compression/gzip.js +8 -11
  31. package/build/cli/compression/index.d.ts +3 -6
  32. package/build/cli/compression/index.d.ts.map +1 -1
  33. package/build/cli/compression/index.js +8 -9
  34. package/build/cli/fastly-api/api-token.d.ts +17 -0
  35. package/build/cli/fastly-api/api-token.d.ts.map +1 -0
  36. package/build/cli/fastly-api/api-token.js +94 -0
  37. package/build/cli/fastly-api/kv-store.d.ts +24 -0
  38. package/build/cli/fastly-api/kv-store.d.ts.map +1 -0
  39. package/build/cli/{util → fastly-api}/kv-store.js +42 -22
  40. package/build/cli/index.js +7 -91
  41. package/build/cli/util/args.d.ts +16 -0
  42. package/build/cli/util/args.d.ts.map +1 -0
  43. package/build/cli/util/args.js +55 -0
  44. package/build/cli/util/config.d.ts +13 -0
  45. package/build/cli/util/config.d.ts.map +1 -0
  46. package/build/cli/{load-config.js → util/config.js} +234 -187
  47. package/build/{util → cli/util}/content-types.d.ts +1 -2
  48. package/build/cli/util/content-types.d.ts.map +1 -0
  49. package/build/{util → cli/util}/content-types.js +38 -32
  50. package/build/cli/util/data.d.ts +3 -3
  51. package/build/cli/util/data.d.ts.map +1 -1
  52. package/build/cli/util/data.js +6 -2
  53. package/build/cli/util/files.d.ts +10 -2
  54. package/build/cli/util/files.d.ts.map +1 -1
  55. package/build/cli/util/files.js +53 -6
  56. package/build/cli/util/kv-store-items.d.ts +12 -0
  57. package/build/cli/util/kv-store-items.d.ts.map +1 -0
  58. package/build/cli/util/kv-store-items.js +161 -0
  59. package/build/cli/util/kv-store-local-server.d.ts +3 -0
  60. package/build/cli/util/kv-store-local-server.d.ts.map +1 -0
  61. package/build/cli/util/kv-store-local-server.js +35 -0
  62. package/build/cli/util/package.d.ts +9 -0
  63. package/build/cli/util/package.d.ts.map +1 -0
  64. package/build/cli/util/package.js +44 -0
  65. package/build/cli/util/retryable.d.ts +12 -0
  66. package/build/cli/util/retryable.d.ts.map +1 -0
  67. package/build/cli/util/retryable.js +43 -0
  68. package/build/cli/util/variants.d.ts +4 -0
  69. package/build/cli/util/variants.d.ts.map +1 -0
  70. package/build/cli/util/variants.js +27 -0
  71. package/build/index.d.ts +5 -5
  72. package/build/index.d.ts.map +1 -1
  73. package/build/index.js +7 -6
  74. package/build/models/assets/kvstore-assets.d.ts +17 -0
  75. package/build/models/assets/kvstore-assets.d.ts.map +1 -0
  76. package/build/models/assets/kvstore-assets.js +28 -0
  77. package/build/{constants/compression.d.ts → models/compression/index.d.ts} +2 -1
  78. package/build/models/compression/index.d.ts.map +1 -0
  79. package/build/models/compression/index.js +11 -0
  80. package/build/models/config/publish-content-config.d.ts +41 -0
  81. package/build/models/config/publish-content-config.d.ts.map +1 -0
  82. package/build/models/config/publish-content-config.js +5 -0
  83. package/build/models/config/publisher-server-config.d.ts +20 -0
  84. package/build/models/config/publisher-server-config.d.ts.map +1 -0
  85. package/build/models/config/publisher-server-config.js +5 -0
  86. package/build/models/config/static-publish-rc.d.ts +6 -0
  87. package/build/models/config/static-publish-rc.d.ts.map +1 -0
  88. package/build/models/config/static-publish-rc.js +5 -0
  89. package/build/server/collection-selector/from-config-store.d.ts +2 -0
  90. package/build/server/collection-selector/from-config-store.d.ts.map +1 -0
  91. package/build/server/collection-selector/from-config-store.js +15 -0
  92. package/build/server/collection-selector/from-cookie.d.ts +23 -0
  93. package/build/server/collection-selector/from-cookie.d.ts.map +1 -0
  94. package/build/server/collection-selector/from-cookie.js +98 -0
  95. package/build/server/collection-selector/from-request.d.ts +13 -0
  96. package/build/server/collection-selector/from-request.d.ts.map +1 -0
  97. package/build/server/collection-selector/from-request.js +22 -0
  98. package/build/server/collection-selector/index.d.ts +5 -0
  99. package/build/server/collection-selector/index.d.ts.map +1 -0
  100. package/build/server/collection-selector/index.js +7 -0
  101. package/build/server/collection-selector/request-collection-selector.d.ts +5 -0
  102. package/build/server/collection-selector/request-collection-selector.d.ts.map +1 -0
  103. package/build/server/collection-selector/request-collection-selector.js +5 -0
  104. package/build/server/publisher-server/index.d.ts +38 -0
  105. package/build/server/publisher-server/index.d.ts.map +1 -0
  106. package/build/server/publisher-server/index.js +415 -0
  107. package/build/server/publisher-server/serve-preconditions/if-modified-since.d.ts +3 -0
  108. package/build/server/publisher-server/serve-preconditions/if-modified-since.d.ts.map +1 -0
  109. package/build/server/{serve-preconditions → publisher-server/serve-preconditions}/if-modified-since.js +6 -2
  110. package/build/server/publisher-server/serve-preconditions/if-none-match.d.ts.map +1 -0
  111. package/build/server/{serve-preconditions → publisher-server/serve-preconditions}/if-none-match.js +4 -0
  112. package/build/server/util/cookies.d.ts +2 -0
  113. package/build/server/util/cookies.d.ts.map +1 -0
  114. package/build/server/util/cookies.js +14 -0
  115. package/build/server/util/kv-store.d.ts +3 -0
  116. package/build/server/util/kv-store.d.ts.map +1 -0
  117. package/build/server/util/kv-store.js +95 -0
  118. package/package.json +18 -10
  119. package/build/cli/commands/build-static.d.ts +0 -3
  120. package/build/cli/commands/build-static.d.ts.map +0 -1
  121. package/build/cli/commands/build-static.js +0 -541
  122. package/build/cli/commands/clean-kv-store.d.ts +0 -3
  123. package/build/cli/commands/clean-kv-store.d.ts.map +0 -1
  124. package/build/cli/commands/clean-kv-store.js +0 -55
  125. package/build/cli/load-config.d.ts +0 -6
  126. package/build/cli/load-config.d.ts.map +0 -1
  127. package/build/cli/presets/implementations/astro.d.ts +0 -7
  128. package/build/cli/presets/implementations/astro.d.ts.map +0 -1
  129. package/build/cli/presets/implementations/astro.js +0 -23
  130. package/build/cli/presets/implementations/create-react-app.d.ts +0 -11
  131. package/build/cli/presets/implementations/create-react-app.d.ts.map +0 -1
  132. package/build/cli/presets/implementations/create-react-app.js +0 -34
  133. package/build/cli/presets/implementations/docusaurus.d.ts +0 -7
  134. package/build/cli/presets/implementations/docusaurus.d.ts.map +0 -1
  135. package/build/cli/presets/implementations/docusaurus.js +0 -13
  136. package/build/cli/presets/implementations/gatsby.d.ts +0 -7
  137. package/build/cli/presets/implementations/gatsby.d.ts.map +0 -1
  138. package/build/cli/presets/implementations/gatsby.js +0 -13
  139. package/build/cli/presets/implementations/next.d.ts +0 -7
  140. package/build/cli/presets/implementations/next.d.ts.map +0 -1
  141. package/build/cli/presets/implementations/next.js +0 -13
  142. package/build/cli/presets/implementations/sveltekit.d.ts +0 -7
  143. package/build/cli/presets/implementations/sveltekit.d.ts.map +0 -1
  144. package/build/cli/presets/implementations/sveltekit.js +0 -13
  145. package/build/cli/presets/implementations/vite.d.ts +0 -7
  146. package/build/cli/presets/implementations/vite.d.ts.map +0 -1
  147. package/build/cli/presets/implementations/vite.js +0 -13
  148. package/build/cli/presets/implementations/vue.d.ts +0 -7
  149. package/build/cli/presets/implementations/vue.d.ts.map +0 -1
  150. package/build/cli/presets/implementations/vue.js +0 -24
  151. package/build/cli/presets/index.d.ts +0 -3
  152. package/build/cli/presets/index.d.ts.map +0 -1
  153. package/build/cli/presets/index.js +0 -20
  154. package/build/cli/presets/preset-base.d.ts +0 -21
  155. package/build/cli/presets/preset-base.d.ts.map +0 -1
  156. package/build/cli/presets/preset-base.js +0 -1
  157. package/build/cli/util/fastly-api.d.ts +0 -10
  158. package/build/cli/util/fastly-api.d.ts.map +0 -1
  159. package/build/cli/util/fastly-api.js +0 -47
  160. package/build/cli/util/hash.d.ts +0 -5
  161. package/build/cli/util/hash.d.ts.map +0 -1
  162. package/build/cli/util/hash.js +0 -9
  163. package/build/cli/util/id.d.ts +0 -3
  164. package/build/cli/util/id.d.ts.map +0 -1
  165. package/build/cli/util/id.js +0 -17
  166. package/build/cli/util/kv-store.d.ts +0 -16
  167. package/build/cli/util/kv-store.d.ts.map +0 -1
  168. package/build/cli/util/publish-id.d.ts +0 -5
  169. package/build/cli/util/publish-id.d.ts.map +0 -1
  170. package/build/cli/util/publish-id.js +0 -26
  171. package/build/compute-js.d.ts +0 -3
  172. package/build/compute-js.d.ts.map +0 -1
  173. package/build/compute-js.js +0 -2
  174. package/build/constants/compression.d.ts.map +0 -1
  175. package/build/constants/compression.js +0 -4
  176. package/build/server/assets/asset-manager.d.ts +0 -8
  177. package/build/server/assets/asset-manager.d.ts.map +0 -1
  178. package/build/server/assets/asset-manager.js +0 -14
  179. package/build/server/assets/content-asset-kv-store.d.ts +0 -19
  180. package/build/server/assets/content-asset-kv-store.d.ts.map +0 -1
  181. package/build/server/assets/content-asset-kv-store.js +0 -70
  182. package/build/server/assets/content-asset-wasm-inline.d.ts +0 -18
  183. package/build/server/assets/content-asset-wasm-inline.d.ts.map +0 -1
  184. package/build/server/assets/content-asset-wasm-inline.js +0 -52
  185. package/build/server/assets/content-assets.d.ts +0 -46
  186. package/build/server/assets/content-assets.d.ts.map +0 -1
  187. package/build/server/assets/content-assets.js +0 -100
  188. package/build/server/assets/module-assets.d.ts +0 -23
  189. package/build/server/assets/module-assets.d.ts.map +0 -1
  190. package/build/server/assets/module-assets.js +0 -45
  191. package/build/server/kv-store/inline-store-entry.d.ts +0 -25
  192. package/build/server/kv-store/inline-store-entry.d.ts.map +0 -1
  193. package/build/server/kv-store/inline-store-entry.js +0 -100
  194. package/build/server/publisher-server.d.ts +0 -23
  195. package/build/server/publisher-server.d.ts.map +0 -1
  196. package/build/server/publisher-server.js +0 -257
  197. package/build/server/serve-preconditions/if-modified-since.d.ts +0 -4
  198. package/build/server/serve-preconditions/if-modified-since.d.ts.map +0 -1
  199. package/build/server/serve-preconditions/if-none-match.d.ts.map +0 -1
  200. package/build/server/util/http.d.ts +0 -2
  201. package/build/server/util/http.d.ts.map +0 -1
  202. package/build/server/util/http.js +0 -9
  203. package/build/types/compute.d.ts +0 -11
  204. package/build/types/compute.d.ts.map +0 -1
  205. package/build/types/compute.js +0 -1
  206. package/build/types/config-normalized.d.ts +0 -34
  207. package/build/types/config-normalized.d.ts.map +0 -1
  208. package/build/types/config-normalized.js +0 -1
  209. package/build/types/config.d.ts +0 -37
  210. package/build/types/config.d.ts.map +0 -1
  211. package/build/types/config.js +0 -1
  212. package/build/types/content-assets.d.ts +0 -55
  213. package/build/types/content-assets.d.ts.map +0 -1
  214. package/build/types/content-assets.js +0 -1
  215. package/build/types/content-types.d.ts +0 -11
  216. package/build/types/content-types.d.ts.map +0 -1
  217. package/build/types/content-types.js +0 -1
  218. package/build/types/index.d.ts +0 -7
  219. package/build/types/index.d.ts.map +0 -1
  220. package/build/types/index.js +0 -1
  221. package/build/types/module-assets.d.ts +0 -15
  222. package/build/types/module-assets.d.ts.map +0 -1
  223. package/build/types/module-assets.js +0 -1
  224. package/build/types/util.d.ts +0 -7
  225. package/build/types/util.d.ts.map +0 -1
  226. package/build/types/util.js +0 -1
  227. package/build/util/content-types.d.ts.map +0 -1
  228. package/build/util/index.d.ts +0 -3
  229. package/build/util/index.d.ts.map +0 -1
  230. package/build/util/index.js +0 -2
  231. package/build/util/metadata.d.ts +0 -3
  232. package/build/util/metadata.d.ts.map +0 -1
  233. package/build/util/metadata.js +0 -12
  234. package/resources/README.md +0 -3
  235. package/resources/statics-metadata.d.ts +0 -10
  236. package/resources/statics.d.ts +0 -19
  237. package/resources/webpack.config.js +0 -33
  238. /package/build/server/{serve-preconditions → publisher-server/serve-preconditions}/if-none-match.d.ts +0 -0
@@ -1,52 +0,0 @@
1
- import { includeBytes } from "fastly:experimental";
2
- import { InlineStoreEntry } from "../kv-store/inline-store-entry.js";
3
- import { ContentAssets, findMatchingSourceAndInfo } from "./content-assets.js";
4
- const decoder = new TextDecoder();
5
- export class ContentWasmInlineAsset {
6
- constructor(metadata) {
7
- this.type = 'wasm-inline';
8
- this.metadata = metadata;
9
- this.sourceAndInfo = {
10
- source: includeBytes(metadata.fileInfo.staticFilePath),
11
- hash: metadata.fileInfo.hash,
12
- size: metadata.fileInfo.size,
13
- };
14
- this.compressedSourcesAndInfo = Object.entries(metadata.compressedFileInfos)
15
- .reduce((obj, [key, value]) => {
16
- obj[key] = {
17
- source: includeBytes(value.staticFilePath),
18
- hash: value.hash,
19
- size: value.size,
20
- };
21
- return obj;
22
- }, {});
23
- }
24
- get isLocal() {
25
- return true;
26
- }
27
- get assetKey() {
28
- return this.metadata.assetKey;
29
- }
30
- async getStoreEntry(acceptEncodingsGroups = []) {
31
- const { sourceAndInfo, contentEncoding } = findMatchingSourceAndInfo(acceptEncodingsGroups, this.sourceAndInfo, encoding => this.compressedSourcesAndInfo[encoding]);
32
- const { source, hash, size } = sourceAndInfo;
33
- return new InlineStoreEntry(source, contentEncoding, hash, size);
34
- }
35
- getBytes() {
36
- return this.sourceAndInfo.source;
37
- }
38
- getText() {
39
- if (!this.metadata.text) {
40
- throw new Error("Can't getText() for non-text content");
41
- }
42
- return decoder.decode(this.sourceAndInfo.source);
43
- }
44
- getJson() {
45
- const text = this.getText();
46
- return JSON.parse(text);
47
- }
48
- getMetadata() {
49
- return this.metadata;
50
- }
51
- }
52
- ContentAssets.registerAssetBuilder('wasm-inline', metadata => new ContentWasmInlineAsset(metadata));
@@ -1,46 +0,0 @@
1
- import { AssetManager } from "./asset-manager.js";
2
- import type { ContentAsset, ContentAssetMetadataMap, ContentAssetMetadataMapEntry, ContentAssetMetadataMapEntryBytes, ContentAssetMetadataMapEntryString } from "../../types/content-assets.js";
3
- import type { StoreEntry } from "../../types/compute.js";
4
- import type { ContentCompressionTypes } from "../../constants/compression.js";
5
- export type SourceAndInfo<TSource> = {
6
- source: TSource;
7
- hash: string;
8
- size: number;
9
- };
10
- type SourceAndInfoForEncodingFn<TSource> = (contentEncoding: ContentCompressionTypes) => SourceAndInfo<TSource> | undefined;
11
- export declare function findMatchingSourceAndInfo<TSource>(acceptEncodingsGroups: ContentCompressionTypes[][], defaultSourceAndInfo: SourceAndInfo<TSource>, sourceAndInfoForEncodingFn: SourceAndInfoForEncodingFn<TSource>): {
12
- sourceAndInfo: SourceAndInfo<TSource>;
13
- contentEncoding: "br" | "gzip" | null;
14
- };
15
- declare abstract class ContentRuntimeAsset<TMetadataMapEntry extends ContentAssetMetadataMapEntry> {
16
- protected readonly metadata: TMetadataMapEntry;
17
- protected sourceAndInfo: SourceAndInfo<Uint8Array>;
18
- protected constructor(metadata: TMetadataMapEntry, sourceAndInfo: SourceAndInfo<Uint8Array>);
19
- get isLocal(): boolean;
20
- get assetKey(): string;
21
- getStoreEntry(): Promise<StoreEntry>;
22
- getBytes(): Uint8Array;
23
- getText(): string;
24
- getJson<T = unknown>(): T;
25
- getMetadata(): ContentAssetMetadataMapEntry;
26
- }
27
- export declare class ContentBytesAsset extends ContentRuntimeAsset<ContentAssetMetadataMapEntryBytes> implements ContentAsset {
28
- readonly type = "bytes";
29
- constructor(metadata: ContentAssetMetadataMapEntryBytes);
30
- }
31
- export declare class ContentStringAsset extends ContentRuntimeAsset<ContentAssetMetadataMapEntryString> implements ContentAsset {
32
- readonly type = "string";
33
- static encoder: TextEncoder;
34
- constructor(metadata: ContentAssetMetadataMapEntryString);
35
- }
36
- export type AssetBuilder<TType extends string> = (metadata: ContentAssetMetadataMapEntry & {
37
- type: TType;
38
- }, assetBuilderContext: AssetBuilderContext) => ContentAsset;
39
- type AssetBuilderContext = any;
40
- export declare class ContentAssets extends AssetManager<ContentAsset> {
41
- static builders: Record<string, AssetBuilder<any>>;
42
- constructor(contentAssetMetadataMap: ContentAssetMetadataMap, assetBuilderContext?: AssetBuilderContext);
43
- static registerAssetBuilder<TType extends string>(type: TType, builder: AssetBuilder<TType>): void;
44
- }
45
- export {};
46
- //# sourceMappingURL=content-assets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-assets.d.ts","sourceRoot":"","sources":["../../../src/server/assets/content-assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,4BAA4B,EAC5B,iCAAiC,EACjC,kCAAkC,EACnC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAI9E,MAAM,MAAM,aAAa,CAAC,OAAO,IAAI;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,0BAA0B,CAAC,OAAO,IAAI,CAAC,eAAe,EAAE,uBAAuB,KAAK,aAAa,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;AAC5H,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,EAAE,EAAE,oBAAoB,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,0BAA0B,EAAE,0BAA0B,CAAC,OAAO,CAAC;;;EA6BnN;AAED,uBAAe,mBAAmB,CAAC,iBAAiB,SAAS,4BAA4B;IACvF,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAC/C,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACnD,SAAS,aAAa,QAAQ,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC;IAK3F,IAAI,OAAO,YAEV;IAED,IAAI,QAAQ,WAEX;IAEK,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC;IAK1C,QAAQ,IAAI,UAAU;IAItB,OAAO,IAAI,MAAM;IAOjB,OAAO,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC;IAKzB,WAAW,IAAI,4BAA4B;CAG5C;AAED,qBAAa,iBACT,SAAQ,mBAAmB,CAAC,iCAAiC,CAC7D,YAAW,YAAY;IACzB,QAAQ,CAAC,IAAI,WAAW;gBAEZ,QAAQ,EAAE,iCAAiC;CAOxD;AAED,qBAAa,kBACT,SAAQ,mBAAmB,CAAC,kCAAkC,CAC9D,YAAW,YAAY;IACzB,QAAQ,CAAC,IAAI,YAAY;IAEzB,MAAM,CAAC,OAAO,cAAqB;gBACvB,QAAQ,EAAE,kCAAkC;CAOzD;AAED,MAAM,MAAM,YAAY,CAAC,KAAK,SAAS,MAAM,IAAI,CAAC,QAAQ,EAAE,4BAA4B,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,EAAE,mBAAmB,EAAE,mBAAmB,KAAK,YAAY,CAAC;AACtK,KAAK,mBAAmB,GAAG,GAAG,CAAC;AAE/B,qBAAa,aAAc,SAAQ,YAAY,CAAC,YAAY,CAAC;IAE3D,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAM;gBAE5C,uBAAuB,EAAE,uBAAuB,EAAE,mBAAmB,GAAE,mBAAwB;IAc3G,MAAM,CAAC,oBAAoB,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC;CAG5F"}
@@ -1,100 +0,0 @@
1
- import { AssetManager } from "./asset-manager.js";
2
- import { InlineStoreEntry } from "../kv-store/inline-store-entry.js";
3
- const decoder = new TextDecoder();
4
- export function findMatchingSourceAndInfo(acceptEncodingsGroups, defaultSourceAndInfo, sourceAndInfoForEncodingFn) {
5
- let sourceAndInfo;
6
- let contentEncoding = null;
7
- if (acceptEncodingsGroups != null) {
8
- for (const encodingGroup of acceptEncodingsGroups) {
9
- const sourceAndInfosForEncodingsGroup = encodingGroup
10
- .map(encoding => ({ encoding, sourceAndInfo: sourceAndInfoForEncodingFn(encoding) }))
11
- .filter(x => x.sourceAndInfo != null);
12
- if (sourceAndInfosForEncodingsGroup.length === 0) {
13
- // If no encoding in this group is available then move to next group
14
- continue;
15
- }
16
- // Sort the items, putting the smallest size first
17
- sourceAndInfosForEncodingsGroup
18
- .sort((a, b) => a.sourceAndInfo.size - b.sourceAndInfo.size);
19
- // The first item is the one we want.
20
- sourceAndInfo = sourceAndInfosForEncodingsGroup[0].sourceAndInfo;
21
- contentEncoding = sourceAndInfosForEncodingsGroup[0].encoding;
22
- break;
23
- }
24
- }
25
- sourceAndInfo ?? (sourceAndInfo = defaultSourceAndInfo);
26
- return { sourceAndInfo, contentEncoding };
27
- }
28
- class ContentRuntimeAsset {
29
- constructor(metadata, sourceAndInfo) {
30
- this.metadata = metadata;
31
- this.sourceAndInfo = sourceAndInfo;
32
- }
33
- get isLocal() {
34
- return true;
35
- }
36
- get assetKey() {
37
- return this.metadata.assetKey;
38
- }
39
- async getStoreEntry() {
40
- const { source, hash, size } = this.sourceAndInfo;
41
- return new InlineStoreEntry(source, null, hash, size);
42
- }
43
- getBytes() {
44
- return this.sourceAndInfo.source;
45
- }
46
- getText() {
47
- if (!this.metadata.text) {
48
- throw new Error("Can't getText() for non-text content");
49
- }
50
- return decoder.decode(this.sourceAndInfo.source);
51
- }
52
- getJson() {
53
- const text = this.getText();
54
- return JSON.parse(text);
55
- }
56
- getMetadata() {
57
- return this.metadata;
58
- }
59
- }
60
- export class ContentBytesAsset extends ContentRuntimeAsset {
61
- constructor(metadata) {
62
- super(metadata, {
63
- source: metadata.fileInfo.bytes,
64
- hash: metadata.fileInfo.hash,
65
- size: metadata.fileInfo.size,
66
- });
67
- this.type = 'bytes';
68
- }
69
- }
70
- class ContentStringAsset extends ContentRuntimeAsset {
71
- constructor(metadata) {
72
- super(metadata, {
73
- source: ContentStringAsset.encoder.encode(metadata.fileInfo.content),
74
- hash: metadata.fileInfo.hash,
75
- size: metadata.fileInfo.size,
76
- });
77
- this.type = 'string';
78
- }
79
- }
80
- ContentStringAsset.encoder = new TextEncoder();
81
- export { ContentStringAsset };
82
- class ContentAssets extends AssetManager {
83
- constructor(contentAssetMetadataMap, assetBuilderContext = {}) {
84
- super();
85
- for (const [assetKey, metadata] of Object.entries(contentAssetMetadataMap)) {
86
- if (!(metadata.type in ContentAssets.builders)) {
87
- throw new Error(`Unknown content asset type '${metadata.type}'`);
88
- }
89
- const asset = ContentAssets.builders[metadata.type](metadata, assetBuilderContext);
90
- this.initAsset(assetKey, asset);
91
- }
92
- }
93
- static registerAssetBuilder(type, builder) {
94
- this.builders[type] = builder;
95
- }
96
- }
97
- ContentAssets.builders = {};
98
- export { ContentAssets };
99
- ContentAssets.registerAssetBuilder('bytes', metadata => new ContentBytesAsset(metadata));
100
- ContentAssets.registerAssetBuilder('string', metadata => new ContentStringAsset(metadata));
@@ -1,23 +0,0 @@
1
- import { AssetManager } from "./asset-manager.js";
2
- import type { ModuleAsset, ModuleAssetMap } from "../../types/module-assets.js";
3
- export declare class ModuleAssetDynamic implements ModuleAsset {
4
- readonly assetKey: string;
5
- readonly isStaticImport: boolean;
6
- private readonly loadModule;
7
- constructor(assetKey: string, loadModule: () => Promise<any>);
8
- private _modulePromise;
9
- getModule(): Promise<any>;
10
- getStaticModule(): any;
11
- }
12
- export declare class ModuleAssetStatic implements ModuleAsset {
13
- readonly assetKey: string;
14
- readonly isStaticImport: boolean;
15
- private readonly module;
16
- constructor(assetKey: string, module: any);
17
- getModule(): Promise<any>;
18
- getStaticModule(): any;
19
- }
20
- export declare class ModuleAssets extends AssetManager<ModuleAsset> {
21
- constructor(moduleAssetMap: ModuleAssetMap);
22
- }
23
- //# sourceMappingURL=module-assets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-assets.d.ts","sourceRoot":"","sources":["../../../src/server/assets/module-assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEhF,qBAAa,kBAAmB,YAAW,WAAW;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAS;IAEzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;gBAEpC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;IAK5D,OAAO,CAAC,cAAc,CAA2B;IACjD,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC;IAOzB,eAAe,IAAI,GAAG;CAIvB;AAED,qBAAa,iBAAkB,YAAW,WAAW;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAQ;IAExC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAM;gBACjB,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG;IAKzC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC;IAIzB,eAAe,IAAI,GAAG;CAIvB;AAED,qBAAa,YAAa,SAAQ,YAAY,CAAC,WAAW,CAAC;gBAE7C,cAAc,EAAE,cAAc;CAmB3C"}
@@ -1,45 +0,0 @@
1
- import { AssetManager } from "./asset-manager.js";
2
- export class ModuleAssetDynamic {
3
- constructor(assetKey, loadModule) {
4
- this.isStaticImport = false;
5
- this.assetKey = assetKey;
6
- this.loadModule = loadModule;
7
- }
8
- getModule() {
9
- if (this._modulePromise === undefined) {
10
- this._modulePromise = this.loadModule();
11
- }
12
- return this._modulePromise;
13
- }
14
- getStaticModule() {
15
- return null;
16
- }
17
- }
18
- export class ModuleAssetStatic {
19
- constructor(assetKey, module) {
20
- this.isStaticImport = true;
21
- this.assetKey = assetKey;
22
- this.module = module;
23
- }
24
- getModule() {
25
- return Promise.resolve(this.module);
26
- }
27
- getStaticModule() {
28
- return this.module;
29
- }
30
- }
31
- export class ModuleAssets extends AssetManager {
32
- constructor(moduleAssetMap) {
33
- super();
34
- for (const [assetKey, moduleEntry] of Object.entries(moduleAssetMap)) {
35
- let asset;
36
- if (moduleEntry.isStaticImport) {
37
- asset = new ModuleAssetStatic(assetKey, moduleEntry.module);
38
- }
39
- else {
40
- asset = new ModuleAssetDynamic(assetKey, moduleEntry.loadModule);
41
- }
42
- this.initAsset(assetKey, asset);
43
- }
44
- }
45
- }
@@ -1,25 +0,0 @@
1
- import { StoreEntry } from "../../types/compute.js";
2
- export declare class InlineStoreEntry implements StoreEntry {
3
- _consumed: boolean;
4
- _body: ReadableStreamForBytes;
5
- _contentEncoding: string | null;
6
- _hash: string;
7
- _size: number;
8
- constructor(array: Uint8Array, contentEncoding: string | null, hash: string, size: number);
9
- get body(): ReadableStream<Uint8Array>;
10
- get bodyUsed(): boolean;
11
- arrayBuffer(): Promise<ArrayBuffer>;
12
- static decoder: TextDecoder;
13
- text(): Promise<string>;
14
- json(): Promise<any>;
15
- get contentEncoding(): string | null;
16
- get hash(): string;
17
- get size(): number;
18
- }
19
- declare class ReadableStreamForBytes extends ReadableStream<Uint8Array> {
20
- _disturbed: boolean;
21
- constructor(array: Uint8Array);
22
- getReader(): ReadableStreamDefaultReader<Uint8Array>;
23
- }
24
- export {};
25
- //# sourceMappingURL=inline-store-entry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inline-store-entry.d.ts","sourceRoot":"","sources":["../../../src/server/kv-store/inline-store-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKpD,qBAAa,gBAAiB,YAAW,UAAU;IACjD,SAAS,EAAE,OAAO,CAAC;IAEnB,KAAK,EAAE,sBAAsB,CAAC;IAE9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAQzF,IAAI,IAAI,IAAI,cAAc,CAAC,UAAU,CAAC,CAErC;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAEK,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAiCzC,MAAM,CAAC,OAAO,cAAqB;IAC7B,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAKvB,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAK1B,IAAI,eAAe,kBAElB;IAED,IAAI,IAAI,WAEP;IAED,IAAI,IAAI,WAEP;CACF;AAED,cAAM,sBAAuB,SAAQ,cAAc,CAAC,UAAU,CAAC;IAG7D,UAAU,UAAS;gBAEP,KAAK,EAAE,UAAU;IASpB,SAAS,IAAI,2BAA2B,CAAC,UAAU,CAAC;CA6B9D"}
@@ -1,100 +0,0 @@
1
- // A class designed to give a Body-style interface to Uint8Array.
2
- // The intended use case is arrays brought in from includeBytes().
3
- class InlineStoreEntry {
4
- constructor(array, contentEncoding, hash, size) {
5
- this._body = new ReadableStreamForBytes(array);
6
- this._consumed = false;
7
- this._contentEncoding = contentEncoding;
8
- this._hash = hash;
9
- this._size = size;
10
- }
11
- get body() {
12
- return this._body;
13
- }
14
- get bodyUsed() {
15
- return this._consumed;
16
- }
17
- async arrayBuffer() {
18
- if (this._consumed) {
19
- throw new Error('Body has already been consumed');
20
- }
21
- if (this._body.locked) {
22
- throw new Error('The ReadableStream body is already locked and can\'t be consumed');
23
- }
24
- if (this._body._disturbed) {
25
- throw new Error('Body object should not be disturbed or locked');
26
- }
27
- this._consumed = true;
28
- let result = new Uint8Array(0);
29
- const reader = this._body.getReader();
30
- try {
31
- while (true) {
32
- const { done, value } = await reader.read();
33
- if (done) {
34
- break;
35
- }
36
- const newResult = new Uint8Array(result.length + value.length);
37
- newResult.set(result);
38
- newResult.set(value, result.length);
39
- result = newResult;
40
- }
41
- return result;
42
- }
43
- finally {
44
- reader.releaseLock();
45
- }
46
- }
47
- async text() {
48
- const data = await this.arrayBuffer();
49
- return InlineStoreEntry.decoder.decode(data);
50
- }
51
- async json() {
52
- const text = await this.text();
53
- return JSON.parse(text);
54
- }
55
- get contentEncoding() {
56
- return this._contentEncoding;
57
- }
58
- get hash() {
59
- return this._hash;
60
- }
61
- get size() {
62
- return this._size;
63
- }
64
- }
65
- InlineStoreEntry.decoder = new TextDecoder();
66
- export { InlineStoreEntry };
67
- class ReadableStreamForBytes extends ReadableStream {
68
- constructor(array) {
69
- super({
70
- async start(controller) {
71
- controller.enqueue(array);
72
- controller.close();
73
- },
74
- });
75
- // Closest we can get to the "disturbed" flag
76
- this._disturbed = false;
77
- }
78
- getReader() {
79
- const reader = super.getReader();
80
- const stream = this;
81
- // Monkey-patch read
82
- const _read = reader.read;
83
- reader.read = async () => {
84
- const result = await _read.call(reader);
85
- if (result.done) {
86
- // NOTE: C@E Request body does not seem to get marked as "disturbed" until
87
- // end of stream is reached either...
88
- stream._disturbed = true;
89
- }
90
- return result;
91
- };
92
- // Monkey-patch cancel
93
- const _cancel = reader.cancel;
94
- reader.cancel = async (reason) => {
95
- await _cancel.call(reader, reason);
96
- stream._disturbed = true;
97
- };
98
- return reader;
99
- }
100
- }
@@ -1,23 +0,0 @@
1
- import { ContentAssets } from "./assets/content-assets.js";
2
- import type { PublisherServerConfigNormalized } from "../types/config-normalized.js";
3
- import type { ContentAsset } from "../types/content-assets.js";
4
- import type { ContentCompressionTypes } from "../constants/compression.js";
5
- type AssetInit = {
6
- status?: number;
7
- headers?: Record<string, string>;
8
- cache?: 'extended' | 'never' | null;
9
- };
10
- export declare class PublisherServer {
11
- private readonly serverConfig;
12
- private readonly staticItems;
13
- private readonly contentAssets;
14
- constructor(serverConfig: PublisherServerConfigNormalized, contentAssets: ContentAssets);
15
- getMatchingAsset(path: string): ContentAsset | null;
16
- findAcceptEncodings(request: Request): ContentCompressionTypes[][];
17
- testExtendedCache(pathname: string): boolean;
18
- handlePreconditions(request: Request, asset: ContentAsset, responseHeaders: Record<string, string>): Response | null;
19
- serveAsset(request: Request, asset: ContentAsset, init?: AssetInit): Promise<Response>;
20
- serveRequest(request: Request): Promise<Response | null>;
21
- }
22
- export {};
23
- //# sourceMappingURL=publisher-server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publisher-server.d.ts","sourceRoot":"","sources":["../../src/server/publisher-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAK3D,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAmB3E,KAAK,SAAS,GAAG;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAkC;IAC/D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAChD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;gBAG5C,YAAY,EAAE,+BAA+B,EAC7C,aAAa,EAAE,aAAa;IAoB9B,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IA2CnD,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,uBAAuB,EAAE,EAAE;IAgDlE,iBAAiB,CAAC,QAAQ,EAAE,MAAM;IAalC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,GAAG,IAAI;IA6D9G,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;IA0CtF,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CA8C/D"}