@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,13 @@
1
+ export class NextJsPreset {
2
+ constructor() {
3
+ this.name = 'Next.js';
4
+ this.defaultOptions = {
5
+ rootDir: './out',
6
+ name: 'my-next-app',
7
+ description: 'Compute@Edge static site from Next.js',
8
+ };
9
+ }
10
+ check() {
11
+ return true;
12
+ }
13
+ }
@@ -0,0 +1,7 @@
1
+ import { AppOptions, IPresetBase } from '../preset-base.js';
2
+ export declare class SvelteKitPreset implements IPresetBase {
3
+ name: string;
4
+ defaultOptions: Partial<AppOptions>;
5
+ check(): boolean;
6
+ }
7
+ //# sourceMappingURL=sveltekit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sveltekit.d.ts","sourceRoot":"","sources":["../../../../src/cli/presets/implementations/sveltekit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5D,qBAAa,eAAgB,YAAW,WAAW;IACjD,IAAI,SAAe;IACnB,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAIjC;IACF,KAAK;CAGN"}
@@ -0,0 +1,13 @@
1
+ export class SvelteKitPreset {
2
+ constructor() {
3
+ this.name = 'SvelteKit';
4
+ this.defaultOptions = {
5
+ rootDir: './dist',
6
+ name: 'my-sveltekit-app',
7
+ description: 'Compute@Edge static site from SvelteKit',
8
+ };
9
+ }
10
+ check() {
11
+ return true;
12
+ }
13
+ }
@@ -0,0 +1,7 @@
1
+ import { AppOptions, IPresetBase } from '../preset-base.js';
2
+ export declare class VitePreset implements IPresetBase {
3
+ name: string;
4
+ defaultOptions: Partial<AppOptions>;
5
+ check(): boolean;
6
+ }
7
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../../src/cli/presets/implementations/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5D,qBAAa,UAAW,YAAW,WAAW;IAC5C,IAAI,SAAU;IACd,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAIjC;IACF,KAAK;CAGN"}
@@ -0,0 +1,13 @@
1
+ export class VitePreset {
2
+ constructor() {
3
+ this.name = 'Vite';
4
+ this.defaultOptions = {
5
+ rootDir: './dist',
6
+ name: 'my-vite-app',
7
+ description: 'Compute@Edge static site from Vite',
8
+ };
9
+ }
10
+ check() {
11
+ return true;
12
+ }
13
+ }
@@ -0,0 +1,3 @@
1
+ import { IPresetBase } from './preset-base.js';
2
+ export declare const presets: Record<string, new () => IPresetBase>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/presets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQ/C,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAS,WAAW,CASxD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { CreateReactAppPreset, CreateReactAppEjectedPreset } from './implementations/create-react-app.js';
2
+ import { VitePreset } from './implementations/vite.js';
3
+ import { SvelteKitPreset } from './implementations/sveltekit.js';
4
+ import { NextJsPreset } from './implementations/next.js';
5
+ import { GatsbyPreset } from './implementations/gatsby.js';
6
+ import { DocusaurusPreset } from './implementations/docusaurus.js';
7
+ export const presets = {
8
+ 'cra': CreateReactAppPreset,
9
+ 'create-react-app': CreateReactAppPreset,
10
+ 'cra-eject': CreateReactAppEjectedPreset,
11
+ 'vite': VitePreset,
12
+ 'sveltekit': SvelteKitPreset,
13
+ 'next': NextJsPreset,
14
+ 'gatsby': GatsbyPreset,
15
+ 'docusaurus': DocusaurusPreset,
16
+ };
@@ -0,0 +1,19 @@
1
+ export type AppOptions = {
2
+ rootDir: string | undefined;
3
+ publicDir: string | undefined;
4
+ staticDirs: string[];
5
+ spa: string | undefined;
6
+ notFoundPage: string | undefined;
7
+ autoIndex: string[];
8
+ autoExt: string[];
9
+ name: string | undefined;
10
+ author: string | undefined;
11
+ description: string | undefined;
12
+ serviceId: string | undefined;
13
+ };
14
+ export interface IPresetBase {
15
+ name: string;
16
+ defaultOptions: Partial<AppOptions>;
17
+ check(packageJson: any | null, options: AppOptions): boolean;
18
+ }
19
+ //# sourceMappingURL=preset-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset-base.d.ts","sourceRoot":"","sources":["../../../src/cli/presets/preset-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9D"}
@@ -0,0 +1,7 @@
1
+ export type NormalizeAction<T> = (value: any, errors: string[]) => T | null;
2
+ export declare function buildNormalizeFunctionForObject<TObject>(action: NormalizeAction<TObject>): (obj: any, errCtx?: string[]) => TObject | null;
3
+ export declare function buildNormalizeFunctionForArray<TEntry>(action: NormalizeAction<TEntry>): (obj: any, errCtx?: string[]) => TEntry[] | null;
4
+ export declare function isStringAndNotEmpty(str: unknown): str is string;
5
+ export declare function isSpecified(obj: any, key: string): boolean;
6
+ export declare function applyDefaults<T extends Record<string, unknown>>(data: Partial<T> | null, defaults: T): T & Partial<T>;
7
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/cli/util/data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;AAE5E,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,SAE1E,GAAG,WAAU,MAAM,EAAE,KAAQ,OAAO,GAAG,IAAI,CAmBzD;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,SAEvE,GAAG,WAAU,MAAM,EAAE,KAAQ,MAAM,EAAE,GAAG,IAAI,CAgC1D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAE/D;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAC,GAAG,EAAE,GAAG,EAAE,MAAM,WAE/C;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,kBAYpG"}
@@ -0,0 +1,58 @@
1
+ export function buildNormalizeFunctionForObject(action) {
2
+ return (obj, errCtx = []) => {
3
+ if (obj == null) {
4
+ errCtx.push('obj cannot be null.');
5
+ return null;
6
+ }
7
+ const errors = [];
8
+ const normalizedObj = action(obj, errors);
9
+ for (const error of errors) {
10
+ errCtx.push(error);
11
+ }
12
+ return normalizedObj;
13
+ };
14
+ }
15
+ export function buildNormalizeFunctionForArray(action) {
16
+ return (obj, errCtx = []) => {
17
+ if (!Array.isArray(obj)) {
18
+ errCtx.push('obj must be array.');
19
+ return null;
20
+ }
21
+ const errors = [];
22
+ let normalizedEntries = [];
23
+ for (const [index, entry] of obj.entries()) {
24
+ const innerErrors = [];
25
+ const normalizedEntry = action(entry, innerErrors);
26
+ if (normalizedEntry != null) {
27
+ normalizedEntries.push(normalizedEntry);
28
+ }
29
+ else {
30
+ errors.push(`Item [${index + 1}]:`);
31
+ errors.push(...innerErrors);
32
+ }
33
+ }
34
+ if (errors.length > 0) {
35
+ normalizedEntries = null;
36
+ }
37
+ for (const error of errors) {
38
+ errCtx.push(error);
39
+ }
40
+ return normalizedEntries;
41
+ };
42
+ }
43
+ export function isStringAndNotEmpty(str) {
44
+ return typeof str === 'string' && str !== '';
45
+ }
46
+ export function isSpecified(obj, key) {
47
+ return key in obj;
48
+ }
49
+ export function applyDefaults(data, defaults) {
50
+ // Remove undefined values
51
+ const temp = Object.assign({}, data);
52
+ for (const [key, value] of Object.entries(temp)) {
53
+ if (value === undefined) {
54
+ delete temp[key];
55
+ }
56
+ }
57
+ return Object.assign({}, defaults, temp);
58
+ }
@@ -0,0 +1,10 @@
1
+ export interface FastlyApiContext {
2
+ apiToken: string;
3
+ }
4
+ export type LoadApiKeyResult = {
5
+ apiToken: string;
6
+ source: string;
7
+ };
8
+ export declare function loadApiKey(): LoadApiKeyResult | null;
9
+ export declare function callFastlyApi(fastlyApiContext: FastlyApiContext, endpoint: string, queryParams?: URLSearchParams | null, requestInit?: RequestInit): Promise<Response>;
10
+ //# sourceMappingURL=fastly-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fastly-api.d.ts","sourceRoot":"","sources":["../../../src/cli/util/fastly-api.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,UAAU,IAAI,gBAAgB,GAAG,IAAI,CA+BpD;AAED,wBAAsB,aAAa,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,eAAe,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsB5K"}
@@ -0,0 +1,47 @@
1
+ import { execSync } from 'child_process';
2
+ ;
3
+ export function loadApiKey() {
4
+ let apiToken = null;
5
+ let source = '';
6
+ // Try to get API key from FASTLY_API_TOKEN
7
+ apiToken = process.env.FASTLY_API_TOKEN || null;
8
+ if (apiToken != null) {
9
+ source = 'env';
10
+ }
11
+ if (apiToken == null) {
12
+ // Try to get API key from fastly cli
13
+ try {
14
+ apiToken = execSync('fastly profile token', {
15
+ encoding: 'utf-8',
16
+ })?.trim() || null;
17
+ }
18
+ catch {
19
+ apiToken = null;
20
+ }
21
+ if (apiToken != null) {
22
+ source = 'fastly-profile-token';
23
+ }
24
+ }
25
+ if (apiToken == null) {
26
+ return null;
27
+ }
28
+ return { apiToken, source };
29
+ }
30
+ export async function callFastlyApi(fastlyApiContext, endpoint, queryParams, requestInit) {
31
+ let finalEndpoint = endpoint;
32
+ if (queryParams != null) {
33
+ const queryString = String(queryParams);
34
+ if (queryString.length > 0) {
35
+ finalEndpoint += '?' + queryString;
36
+ }
37
+ }
38
+ const url = new URL(finalEndpoint, 'https://api.fastly.com/');
39
+ const headers = new Headers(requestInit?.headers);
40
+ headers.set('Fastly-Key', fastlyApiContext.apiToken);
41
+ const request = new Request(url, {
42
+ ...requestInit,
43
+ headers,
44
+ });
45
+ const response = await fetch(request);
46
+ return response;
47
+ }
@@ -0,0 +1,11 @@
1
+ export interface FilenameTest {
2
+ test(name: string): boolean;
3
+ }
4
+ export type GetFilesOpts = {
5
+ publicDirRoot: string;
6
+ excludeDirs: FilenameTest[];
7
+ excludeDotFiles: boolean;
8
+ includeWellKnown: boolean;
9
+ };
10
+ export declare function getFiles(dir: string, opts: GetFilesOpts): string[];
11
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/cli/util/files.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,YAIvD"}
@@ -0,0 +1,33 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ export function getFiles(dir, opts) {
4
+ const results = [];
5
+ getFilesWorker(results, dir, opts);
6
+ return results;
7
+ }
8
+ function getFilesWorker(results, dir, opts) {
9
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
10
+ for (const entry of entries) {
11
+ const { name } = entry;
12
+ const { publicDirRoot, excludeDirs, excludeDotFiles, includeWellKnown, } = opts;
13
+ const fullpath = path.resolve(dir, name);
14
+ const relative = '/' + path.relative(publicDirRoot, fullpath);
15
+ if (excludeDirs.some(excludeDir => excludeDir.test(relative))) {
16
+ continue;
17
+ }
18
+ if (excludeDotFiles && name.startsWith('.')) {
19
+ if (includeWellKnown && name === '.well-known') {
20
+ // ok
21
+ }
22
+ else {
23
+ continue;
24
+ }
25
+ }
26
+ if (entry.isDirectory()) {
27
+ getFilesWorker(results, fullpath, opts);
28
+ }
29
+ else {
30
+ results.push(fullpath);
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,5 @@
1
+ export declare function calculateFileSizeAndHash(filename: string): {
2
+ size: number;
3
+ hash: string;
4
+ };
5
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/cli/util/hash.ts"],"names":[],"mappings":"AAGA,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM;;;EAUxD"}
@@ -0,0 +1,9 @@
1
+ import crypto from 'crypto';
2
+ import fs from 'fs';
3
+ export function calculateFileSizeAndHash(filename) {
4
+ const fileBuffer = fs.readFileSync(filename);
5
+ const size = fileBuffer.length;
6
+ const hash = crypto.createHash('sha256');
7
+ hash.update(fileBuffer);
8
+ return { size, hash: hash.digest('hex') };
9
+ }
@@ -0,0 +1,3 @@
1
+ export declare function createStringId(): string;
2
+ export declare function uuidToString(uuid: string): string;
3
+ //# sourceMappingURL=id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../../src/cli/util/id.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,WAE7B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,UAYxC"}
@@ -0,0 +1,17 @@
1
+ import crypto from "crypto";
2
+ const ID_SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
3
+ const ID_SYMBOLS_BASE = BigInt(ID_SYMBOLS.length);
4
+ export function createStringId() {
5
+ return uuidToString(crypto.randomUUID());
6
+ }
7
+ export function uuidToString(uuid) {
8
+ const uuidWithoutHyphens = uuid.replace(/-/g, '');
9
+ let number = BigInt('0x' + uuidWithoutHyphens);
10
+ let result = '';
11
+ do {
12
+ const [quotient, remainder] = [number / ID_SYMBOLS_BASE, Number(number % ID_SYMBOLS_BASE)];
13
+ result = ID_SYMBOLS.charAt(remainder) + result;
14
+ number = quotient;
15
+ } while (number > 0n);
16
+ return result;
17
+ }
@@ -0,0 +1,16 @@
1
+ import { FastlyApiContext } from "./fastly-api.js";
2
+ export declare function getObjectStoreIdForNameMap(fastlyApiContext: FastlyApiContext): Promise<Record<string, string>>;
3
+ export declare function getObjectStoreIdForName(fastlyApiContext: FastlyApiContext, objectStoreName: string): Promise<string | null>;
4
+ type ObjectStoreInfo = {
5
+ id: string;
6
+ name: string;
7
+ };
8
+ export declare function getObjectStoreInfos(fastlyApiContext: FastlyApiContext): Promise<ObjectStoreInfo[]>;
9
+ type ObjectStoreEntryInfo = string;
10
+ export declare const _getObjectStoreKeys: (fastlyApiContext: FastlyApiContext, objectStoreId: string) => Promise<string[]>;
11
+ export declare function getObjectStoreKeys(fastlyApiContext: FastlyApiContext, objectStoreName: string): Promise<ObjectStoreEntryInfo[] | null>;
12
+ export declare function objectStoreEntryExists(fastlyApiContext: FastlyApiContext, objectStoreName: string, key: string): Promise<boolean>;
13
+ export declare function objectStoreSubmitFile(fastlyApiContext: FastlyApiContext, objectStoreName: string, key: string, data: Uint8Array | string): Promise<void>;
14
+ export declare function objectStoreDeleteFile(fastlyApiContext: FastlyApiContext, objectStoreName: string, key: string): Promise<void>;
15
+ export {};
16
+ //# sourceMappingURL=object-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-store.d.ts","sourceRoot":"","sources":["../../../src/cli/util/object-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AASlE,wBAAsB,0BAA0B,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkBpH;AAED,wBAAsB,uBAAuB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIjI;AA8CD,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAIF,wBAAsB,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAcxG;AAED,KAAK,oBAAoB,GAAG,MAAM,CAAC;AAEnC,eAAO,MAAM,mBAAmB,qBA3DY,gBAAgB,6CA2DiH,CAAC;AAE9K,wBAAsB,kBAAkB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,CAQ5I;AAED,wBAAsB,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAavI;AAGD,wBAAsB,qBAAqB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB9J;AAED,wBAAsB,qBAAqB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBnI"}
@@ -0,0 +1,108 @@
1
+ import { callFastlyApi } from "./fastly-api.js";
2
+ const cache = new WeakMap();
3
+ export async function getObjectStoreIdForNameMap(fastlyApiContext) {
4
+ const cacheEntry = cache.get(fastlyApiContext);
5
+ let objectStoreNameMap = cacheEntry?.objectStoreNameMap;
6
+ if (objectStoreNameMap != null) {
7
+ return objectStoreNameMap;
8
+ }
9
+ const objectStoreInfos = await getObjectStoreInfos(fastlyApiContext);
10
+ objectStoreNameMap = {};
11
+ for (const { id, name } of objectStoreInfos) {
12
+ objectStoreNameMap[name] = id;
13
+ }
14
+ cache.set(fastlyApiContext, { ...cacheEntry, objectStoreNameMap });
15
+ return objectStoreNameMap;
16
+ }
17
+ export async function getObjectStoreIdForName(fastlyApiContext, objectStoreName) {
18
+ const objectStoreNameMap = await getObjectStoreIdForNameMap(fastlyApiContext);
19
+ return objectStoreNameMap[objectStoreName] ?? null;
20
+ }
21
+ function createArrayGetter() {
22
+ return function (fn) {
23
+ return async function (fastlyApiContext, ...args) {
24
+ const results = [];
25
+ let cursor = null;
26
+ while (true) {
27
+ const queryParams = new URLSearchParams();
28
+ if (cursor != null) {
29
+ queryParams.set('cursor', cursor);
30
+ }
31
+ const endpoint = fn(...args);
32
+ const response = await callFastlyApi(fastlyApiContext, endpoint, queryParams);
33
+ if (response.status !== 200) {
34
+ throw new Error('Unexpected data format');
35
+ }
36
+ const infos = await response.json();
37
+ for (const item of infos.data) {
38
+ results.push(item);
39
+ }
40
+ if (infos.meta.next_cursor === undefined) {
41
+ break;
42
+ }
43
+ cursor = infos.meta.next_cursor;
44
+ }
45
+ return results;
46
+ };
47
+ };
48
+ }
49
+ const _getObjectStoreInfos = createArrayGetter()(() => `/resources/stores/object`);
50
+ export async function getObjectStoreInfos(fastlyApiContext) {
51
+ const cacheEntry = cache.get(fastlyApiContext);
52
+ let objectStoreInfos = cacheEntry?.objectStoreInfos;
53
+ if (objectStoreInfos != null) {
54
+ return objectStoreInfos;
55
+ }
56
+ objectStoreInfos = await _getObjectStoreInfos(fastlyApiContext);
57
+ cache.set(fastlyApiContext, { ...cacheEntry, objectStoreInfos });
58
+ return objectStoreInfos;
59
+ }
60
+ export const _getObjectStoreKeys = createArrayGetter()((objectStoreId) => `/resources/stores/object/${encodeURIComponent(objectStoreId)}/keys`);
61
+ export async function getObjectStoreKeys(fastlyApiContext, objectStoreName) {
62
+ const objectStoreId = await getObjectStoreIdForName(fastlyApiContext, objectStoreName);
63
+ if (objectStoreId == null) {
64
+ return null;
65
+ }
66
+ return await _getObjectStoreKeys(fastlyApiContext, objectStoreId);
67
+ }
68
+ export async function objectStoreEntryExists(fastlyApiContext, objectStoreName, key) {
69
+ const objectStoreId = await getObjectStoreIdForName(fastlyApiContext, objectStoreName);
70
+ if (objectStoreId == null) {
71
+ return false;
72
+ }
73
+ const endpoint = `/resources/stores/object/${encodeURIComponent(objectStoreId)}/keys/${encodeURIComponent(key)}`;
74
+ const response = await callFastlyApi(fastlyApiContext, endpoint, null, { method: 'HEAD' });
75
+ return response.status === 200;
76
+ }
77
+ const encoder = new TextEncoder();
78
+ export async function objectStoreSubmitFile(fastlyApiContext, objectStoreName, key, data) {
79
+ const objectStoreId = await getObjectStoreIdForName(fastlyApiContext, objectStoreName);
80
+ if (objectStoreId == null) {
81
+ throw new Error('Object store not found');
82
+ }
83
+ const endpoint = `/resources/stores/object/${encodeURIComponent(objectStoreId)}/keys/${encodeURIComponent(key)}`;
84
+ const body = typeof data === 'string' ? encoder.encode(data) : data;
85
+ const response = await callFastlyApi(fastlyApiContext, endpoint, null, {
86
+ method: 'PUT',
87
+ headers: {
88
+ 'content-type': 'application/octet-stream',
89
+ },
90
+ body,
91
+ });
92
+ if (response.status !== 200) {
93
+ throw new Error(`Submitting item ${key} gave error: ${response.status}`);
94
+ }
95
+ }
96
+ export async function objectStoreDeleteFile(fastlyApiContext, objectStoreName, key) {
97
+ const objectStoreId = await getObjectStoreIdForName(fastlyApiContext, objectStoreName);
98
+ if (objectStoreId == null) {
99
+ throw new Error('Object store not found');
100
+ }
101
+ const endpoint = `/resources/stores/object/${encodeURIComponent(objectStoreId)}/keys/${encodeURIComponent(key)}`;
102
+ const response = await callFastlyApi(fastlyApiContext, endpoint, null, {
103
+ method: 'DELETE',
104
+ });
105
+ if (response.status < 200 || response.status >= 300) {
106
+ throw new Error(`Deleting item '${key}' gave error: ${response.status}`);
107
+ }
108
+ }
@@ -0,0 +1,5 @@
1
+ export declare function generateOrLoadPublishId(): {
2
+ publishId: string;
3
+ created: boolean;
4
+ };
5
+ //# sourceMappingURL=publish-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-id.d.ts","sourceRoot":"","sources":["../../../src/cli/util/publish-id.ts"],"names":[],"mappings":"AAGA,wBAAgB,uBAAuB;;;EA8BtC"}
@@ -0,0 +1,26 @@
1
+ import fs from "fs";
2
+ import { createStringId } from "./id.js";
3
+ export function generateOrLoadPublishId() {
4
+ let created = false;
5
+ const filename = './.publish-id';
6
+ let contents;
7
+ try {
8
+ contents = fs.readFileSync(filename, 'utf-8');
9
+ }
10
+ catch {
11
+ contents = null;
12
+ }
13
+ let publishId = null;
14
+ if (contents != null) {
15
+ publishId = contents
16
+ .split('\n')
17
+ .find(line => line.length > 0 && !line.startsWith('#')) ?? null;
18
+ }
19
+ if (publishId == null) {
20
+ publishId = createStringId();
21
+ created = true;
22
+ const fileContents = `# Generated by @fastly/compute-js-static-publish.\n${publishId}\n`;
23
+ fs.writeFileSync(filename, fileContents, 'utf-8');
24
+ }
25
+ return { publishId, created };
26
+ }
@@ -0,0 +1,3 @@
1
+ export declare const compressionTypes: readonly ["br", "gzip"];
2
+ export type ContentCompressionTypes = typeof compressionTypes[number];
3
+ //# sourceMappingURL=compression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compression.d.ts","sourceRoot":"","sources":["../../src/constants/compression.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,yBAGnB,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export const compressionTypes = [
2
+ 'br',
3
+ 'gzip',
4
+ ];
package/build/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- export type { Asset, AssetBase, AssetsMap, BinaryAsset, Config, StringAsset } from './types.js';
2
- export { StaticAssets } from './static-assets.js';
1
+ export * from './types/index.js';
2
+ export * from './util/index.js';
3
+ export { ContentAssets } from './server/assets/content-assets.js';
4
+ export { ModuleAssets } from './server/assets/module-assets.js';
5
+ export { PublisherServer } from './server/publisher-server.js';
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC"}
package/build/index.js CHANGED
@@ -1,2 +1,6 @@
1
1
  /// <reference types="@fastly/js-compute" />
2
- export { StaticAssets } from './static-assets.js';
2
+ export * from './types/index.js';
3
+ export * from './util/index.js';
4
+ export { ContentAssets } from './server/assets/content-assets.js';
5
+ export { ModuleAssets } from './server/assets/module-assets.js';
6
+ export { PublisherServer } from './server/publisher-server.js';
@@ -9,13 +9,12 @@ export class CreateReactAppPreset {
9
9
  };
10
10
  }
11
11
  check(packageJson) {
12
- var _a;
13
12
  if (packageJson == null) {
14
13
  console.error("❌ Can't read/parse package.json");
15
14
  console.error("Run this from a create-react-app project directory.");
16
15
  return false;
17
16
  }
18
- if (((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['react-scripts']) == null) {
17
+ if (packageJson?.dependencies?.['react-scripts'] == null) {
19
18
  console.error("❌ Can't find react-scripts in dependencies");
20
19
  console.error("Run this from a create-react-app project directory.");
21
20
  console.log("If this is a project created with create-react-app and has since been ejected, specify preset cra-eject to skip this check.");
@@ -1,4 +1,4 @@
1
- export declare type AppOptions = {
1
+ export type AppOptions = {
2
2
  'public-dir': string | undefined;
3
3
  'static-dir': string | undefined;
4
4
  spa: string | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"preset-base.d.ts","sourceRoot":"","sources":["../../src/presets/preset-base.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9D"}
1
+ {"version":3,"file":"preset-base.d.ts","sourceRoot":"","sources":["../../src/presets/preset-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9D"}
@@ -0,0 +1,7 @@
1
+ export declare abstract class AssetManager<TAsset> {
2
+ protected readonly assets: Record<string, TAsset>;
3
+ protected constructor();
4
+ setAsset(assetKey: string, asset: TAsset): void;
5
+ getAsset(assetKey: string): TAsset | null;
6
+ }
7
+ //# sourceMappingURL=asset-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-manager.d.ts","sourceRoot":"","sources":["../../../src/server/assets/asset-manager.ts"],"names":[],"mappings":"AAAA,8BAAsB,YAAY,CAAC,MAAM;IAEvC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElD,SAAS;IAIT,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAI1C"}
@@ -0,0 +1,11 @@
1
+ export class AssetManager {
2
+ constructor() {
3
+ this.assets = {};
4
+ }
5
+ setAsset(assetKey, asset) {
6
+ this.assets[assetKey] = asset;
7
+ }
8
+ getAsset(assetKey) {
9
+ return this.assets[assetKey] ?? null;
10
+ }
11
+ }