@fastly/compute-js-static-publish 4.0.0-alpha.4 → 4.1.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.
- package/README.md +51 -27
- package/build/cli/commands/build-static.d.ts.map +1 -1
- package/build/cli/commands/build-static.js +5 -4
- package/build/cli/commands/clean-object-store.d.ts.map +1 -1
- package/build/cli/commands/init-app.d.ts.map +1 -1
- package/build/cli/commands/init-app.js +0 -1
- package/build/cli/index.js +2 -0
- package/build/cli/presets/implementations/astro.d.ts +7 -0
- package/build/cli/presets/implementations/astro.d.ts.map +1 -0
- package/build/cli/presets/implementations/astro.js +23 -0
- package/build/cli/presets/implementations/vue.d.ts +7 -0
- package/build/cli/presets/implementations/vue.d.ts.map +1 -0
- package/build/cli/presets/implementations/vue.js +24 -0
- package/build/cli/presets/index.d.ts.map +1 -1
- package/build/cli/presets/index.js +4 -0
- package/build/compute-js.d.ts +3 -0
- package/build/compute-js.d.ts.map +1 -0
- package/build/compute-js.js +2 -0
- package/build/server/assets/asset-manager.d.ts +1 -0
- package/build/server/assets/asset-manager.d.ts.map +1 -1
- package/build/server/assets/asset-manager.js +3 -0
- package/build/server/assets/content-asset-object-store.d.ts +18 -0
- package/build/server/assets/content-asset-object-store.d.ts.map +1 -0
- package/build/server/assets/content-asset-object-store.js +67 -0
- package/build/server/assets/content-asset-wasm-inline.d.ts +17 -0
- package/build/server/assets/content-asset-wasm-inline.d.ts.map +1 -0
- package/build/server/assets/content-asset-wasm-inline.js +48 -0
- package/build/server/assets/content-assets-runtime.d.ts +2 -0
- package/build/server/assets/content-assets-runtime.d.ts.map +1 -0
- package/build/server/assets/content-assets.d.ts +33 -21
- package/build/server/assets/content-assets.d.ts.map +1 -1
- package/build/server/assets/content-assets.js +39 -85
- package/build/types/content-assets.d.ts +23 -7
- package/build/types/content-assets.d.ts.map +1 -1
- package/build/util/metadata.js +1 -1
- package/package.json +1 -1
- package/build/assets/asset-manager.d.ts +0 -7
- package/build/assets/asset-manager.d.ts.map +0 -1
- package/build/assets/asset-manager.js +0 -11
- package/build/assets/content-assets.d.ts +0 -29
- package/build/assets/content-assets.d.ts.map +0 -1
- package/build/assets/content-assets.js +0 -88
- package/build/assets/module-assets.d.ts +0 -23
- package/build/assets/module-assets.d.ts.map +0 -1
- package/build/assets/module-assets.js +0 -45
- package/build/cli/build-static.d.ts +0 -3
- package/build/cli/build-static.d.ts.map +0 -1
- package/build/cli/build-static.js +0 -524
- package/build/cli/clean-object-store.d.ts +0 -2
- package/build/cli/clean-object-store.d.ts.map +0 -1
- package/build/cli/cli.d.ts +0 -3
- package/build/cli/cli.d.ts.map +0 -1
- package/build/cli/cli.js +0 -77
- package/build/cli/init-app.d.ts +0 -3
- package/build/cli/init-app.d.ts.map +0 -1
- package/build/cli/init-app.js +0 -283
- package/build/presets/implementations/create-react-app.d.ts +0 -16
- package/build/presets/implementations/create-react-app.d.ts.map +0 -1
- package/build/presets/implementations/create-react-app.js +0 -34
- package/build/presets/implementations/docusaurus.d.ts +0 -11
- package/build/presets/implementations/docusaurus.d.ts.map +0 -1
- package/build/presets/implementations/docusaurus.js +0 -13
- package/build/presets/implementations/gatsby.d.ts +0 -11
- package/build/presets/implementations/gatsby.d.ts.map +0 -1
- package/build/presets/implementations/gatsby.js +0 -13
- package/build/presets/implementations/next.d.ts +0 -11
- package/build/presets/implementations/next.d.ts.map +0 -1
- package/build/presets/implementations/next.js +0 -13
- package/build/presets/implementations/sveltekit.d.ts +0 -11
- package/build/presets/implementations/sveltekit.d.ts.map +0 -1
- package/build/presets/implementations/sveltekit.js +0 -13
- package/build/presets/implementations/vite.d.ts +0 -11
- package/build/presets/implementations/vite.d.ts.map +0 -1
- package/build/presets/implementations/vite.js +0 -13
- package/build/presets/index.d.ts +0 -3
- package/build/presets/index.d.ts.map +0 -1
- package/build/presets/index.js +0 -16
- package/build/presets/preset-base.d.ts +0 -18
- package/build/presets/preset-base.d.ts.map +0 -1
- package/build/presets/preset-base.js +0 -1
- package/build/server/object-store/include-bytes-store-entry.d.ts +0 -19
- package/build/server/object-store/include-bytes-store-entry.d.ts.map +0 -1
- package/build/server/object-store/include-bytes-store-entry.js +0 -87
- package/build/util/data.d.ts +0 -7
- package/build/util/data.d.ts.map +0 -1
- package/build/util/data.js +0 -58
- package/build/util/fastly-api.d.ts +0 -10
- package/build/util/fastly-api.d.ts.map +0 -1
- package/build/util/fastly-api.js +0 -47
- package/build/util/files.d.ts +0 -10
- package/build/util/files.d.ts.map +0 -1
- package/build/util/files.js +0 -32
- package/build/util/hash.d.ts +0 -2
- package/build/util/hash.d.ts.map +0 -1
- package/build/util/hash.js +0 -8
- package/build/util/id.d.ts +0 -3
- package/build/util/id.d.ts.map +0 -1
- package/build/util/id.js +0 -17
- package/build/util/object-store.d.ts +0 -12
- package/build/util/object-store.d.ts.map +0 -1
- package/build/util/object-store.js +0 -80
- /package/build/{cli/clean-object-store.js → server/assets/content-assets-runtime.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-assets.d.ts","sourceRoot":"","sources":["../../../src/server/assets/content-assets.ts"],"names":[],"mappings":"
|
|
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,0B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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,9 +1,7 @@
|
|
|
1
|
-
import { includeBytes } from "fastly:experimental";
|
|
2
|
-
import { ObjectStore } from "fastly:object-store";
|
|
3
1
|
import { AssetManager } from "./asset-manager.js";
|
|
4
2
|
import { InlineStoreEntry } from "../object-store/inline-store-entry.js";
|
|
5
3
|
const decoder = new TextDecoder();
|
|
6
|
-
function findMatchingSourceAndInfo(acceptEncodingsGroups, defaultSourceAndInfo, sourceAndInfoForEncodingFn) {
|
|
4
|
+
export function findMatchingSourceAndInfo(acceptEncodingsGroups, defaultSourceAndInfo, sourceAndInfoForEncodingFn) {
|
|
7
5
|
let sourceAndInfo;
|
|
8
6
|
let contentEncoding = null;
|
|
9
7
|
if (acceptEncodingsGroups != null) {
|
|
@@ -27,32 +25,20 @@ function findMatchingSourceAndInfo(acceptEncodingsGroups, defaultSourceAndInfo,
|
|
|
27
25
|
sourceAndInfo ?? (sourceAndInfo = defaultSourceAndInfo);
|
|
28
26
|
return { sourceAndInfo, contentEncoding };
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
constructor(metadata) {
|
|
32
|
-
this.isInline = true;
|
|
28
|
+
class ContentRuntimeAsset {
|
|
29
|
+
constructor(metadata, sourceAndInfo) {
|
|
33
30
|
this.metadata = metadata;
|
|
34
|
-
this.sourceAndInfo =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
this.compressedSourcesAndInfo = Object.entries(metadata.compressedFileInfos)
|
|
40
|
-
.reduce((obj, [key, value]) => {
|
|
41
|
-
obj[key] = {
|
|
42
|
-
source: includeBytes(value.staticFilePath),
|
|
43
|
-
hash: value.hash,
|
|
44
|
-
size: value.size,
|
|
45
|
-
};
|
|
46
|
-
return obj;
|
|
47
|
-
}, {});
|
|
31
|
+
this.sourceAndInfo = sourceAndInfo;
|
|
32
|
+
}
|
|
33
|
+
get isLocal() {
|
|
34
|
+
return true;
|
|
48
35
|
}
|
|
49
36
|
get assetKey() {
|
|
50
37
|
return this.metadata.assetKey;
|
|
51
38
|
}
|
|
52
|
-
async getStoreEntry(
|
|
53
|
-
const {
|
|
54
|
-
|
|
55
|
-
return new InlineStoreEntry(source, contentEncoding, hash, size);
|
|
39
|
+
async getStoreEntry() {
|
|
40
|
+
const { source, hash, size } = this.sourceAndInfo;
|
|
41
|
+
return new InlineStoreEntry(source, null, hash, size);
|
|
56
42
|
}
|
|
57
43
|
getBytes() {
|
|
58
44
|
return this.sourceAndInfo.source;
|
|
@@ -67,76 +53,44 @@ export class ContentInlineAsset {
|
|
|
67
53
|
return this.metadata;
|
|
68
54
|
}
|
|
69
55
|
}
|
|
70
|
-
export class
|
|
71
|
-
constructor(metadata
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.objectStoreName = objectStoreName;
|
|
75
|
-
this.sourceAndInfo = {
|
|
76
|
-
source: metadata.fileInfo.objectStoreKey,
|
|
56
|
+
export class ContentBytesAsset extends ContentRuntimeAsset {
|
|
57
|
+
constructor(metadata) {
|
|
58
|
+
super(metadata, {
|
|
59
|
+
source: metadata.fileInfo.bytes,
|
|
77
60
|
hash: metadata.fileInfo.hash,
|
|
78
61
|
size: metadata.fileInfo.size,
|
|
79
|
-
};
|
|
80
|
-
this.
|
|
81
|
-
.reduce((obj, [key, value]) => {
|
|
82
|
-
obj[key] = {
|
|
83
|
-
source: value.objectStoreKey,
|
|
84
|
-
hash: value.hash,
|
|
85
|
-
size: value.size,
|
|
86
|
-
};
|
|
87
|
-
return obj;
|
|
88
|
-
}, {});
|
|
89
|
-
}
|
|
90
|
-
get assetKey() {
|
|
91
|
-
return this.metadata.assetKey;
|
|
92
|
-
}
|
|
93
|
-
async getStoreEntry(acceptEncodingsGroups = []) {
|
|
94
|
-
const { sourceAndInfo, contentEncoding } = findMatchingSourceAndInfo(acceptEncodingsGroups, this.sourceAndInfo, encoding => this.compressedSourcesAndInfo[encoding]);
|
|
95
|
-
const objectStore = new ObjectStore(this.objectStoreName);
|
|
96
|
-
let retries = 3;
|
|
97
|
-
while (retries > 0) {
|
|
98
|
-
const storeEntry = await objectStore.get(sourceAndInfo.source);
|
|
99
|
-
if (storeEntry != null) {
|
|
100
|
-
const { hash, size } = sourceAndInfo;
|
|
101
|
-
return Object.assign(storeEntry, { contentEncoding, hash, size });
|
|
102
|
-
}
|
|
103
|
-
// Note the null does NOT mean 404. The fact that we are here means
|
|
104
|
-
// metadata exists for this path, and we're just trying to get the data from
|
|
105
|
-
// the object store.
|
|
106
|
-
// So if we're here then the data is either not available yet (in which case
|
|
107
|
-
// we can wait just a bit and try again), or the data was deleted.
|
|
108
|
-
retries--;
|
|
109
|
-
// We're going to wait 250ms/500ms/750ms and try again.
|
|
110
|
-
const delay = (3 - retries) * 250;
|
|
111
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
112
|
-
}
|
|
113
|
-
throw new Error("Asset could not be retrieved from the Object Store.");
|
|
62
|
+
});
|
|
63
|
+
this.type = 'bytes';
|
|
114
64
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
65
|
+
}
|
|
66
|
+
class ContentStringAsset extends ContentRuntimeAsset {
|
|
67
|
+
constructor(metadata) {
|
|
68
|
+
super(metadata, {
|
|
69
|
+
source: ContentStringAsset.encoder.encode(metadata.fileInfo.content),
|
|
70
|
+
hash: metadata.fileInfo.hash,
|
|
71
|
+
size: metadata.fileInfo.size,
|
|
72
|
+
});
|
|
73
|
+
this.type = 'string';
|
|
123
74
|
}
|
|
124
75
|
}
|
|
125
|
-
|
|
126
|
-
|
|
76
|
+
ContentStringAsset.encoder = new TextEncoder();
|
|
77
|
+
export { ContentStringAsset };
|
|
78
|
+
class ContentAssets extends AssetManager {
|
|
79
|
+
constructor(contentAssetMetadataMap, assetBuilderContext = {}) {
|
|
127
80
|
super();
|
|
128
81
|
for (const [assetKey, metadata] of Object.entries(contentAssetMetadataMap)) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
asset = new ContentInlineAsset(metadata);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
if (objectStoreName == null) {
|
|
135
|
-
throw new Error("Unexpected! Object Store should be specified!!");
|
|
136
|
-
}
|
|
137
|
-
asset = new ContentObjectStoreAsset(metadata, objectStoreName);
|
|
82
|
+
if (!(metadata.type in ContentAssets.builders)) {
|
|
83
|
+
throw new Error(`Unknown content asset type '${metadata.type}'`);
|
|
138
84
|
}
|
|
85
|
+
const asset = ContentAssets.builders[metadata.type](metadata, assetBuilderContext);
|
|
139
86
|
this.initAsset(assetKey, asset);
|
|
140
87
|
}
|
|
141
88
|
}
|
|
89
|
+
static registerAssetBuilder(type, builder) {
|
|
90
|
+
this.builders[type] = builder;
|
|
91
|
+
}
|
|
142
92
|
}
|
|
93
|
+
ContentAssets.builders = {};
|
|
94
|
+
export { ContentAssets };
|
|
95
|
+
ContentAssets.registerAssetBuilder('bytes', metadata => new ContentBytesAsset(metadata));
|
|
96
|
+
ContentAssets.registerAssetBuilder('string', metadata => new ContentStringAsset(metadata));
|
|
@@ -4,9 +4,18 @@ export type CompressedFileInfos<TData> = Partial<Record<ContentCompressionTypes,
|
|
|
4
4
|
export type ContentFileInfo = {
|
|
5
5
|
hash: string;
|
|
6
6
|
size: number;
|
|
7
|
+
};
|
|
8
|
+
export type ContentFileInfoForBytes = ContentFileInfo & {
|
|
9
|
+
bytes: Uint8Array;
|
|
10
|
+
};
|
|
11
|
+
export type ContentFileInfoForString = ContentFileInfo & {
|
|
12
|
+
content: string;
|
|
13
|
+
};
|
|
14
|
+
export type ContentFileInfoForStaticPublishing = ContentFileInfo & {
|
|
7
15
|
staticFilePath: string;
|
|
8
16
|
};
|
|
9
|
-
export type
|
|
17
|
+
export type ContentFileInfoForWasmInline = ContentFileInfoForStaticPublishing;
|
|
18
|
+
export type ContentFileInfoForObjectStore = ContentFileInfoForStaticPublishing & {
|
|
10
19
|
objectStoreKey: string;
|
|
11
20
|
};
|
|
12
21
|
export type ContentAssetMetadataMapEntryBase<TFileInfo> = {
|
|
@@ -17,22 +26,29 @@ export type ContentAssetMetadataMapEntryBase<TFileInfo> = {
|
|
|
17
26
|
fileInfo: TFileInfo;
|
|
18
27
|
compressedFileInfos: CompressedFileInfos<TFileInfo>;
|
|
19
28
|
};
|
|
20
|
-
export type
|
|
21
|
-
|
|
22
|
-
} & ContentAssetMetadataMapEntryBase<
|
|
29
|
+
export type ContentAssetMetadataMapEntryBytes = {
|
|
30
|
+
type: 'bytes';
|
|
31
|
+
} & ContentAssetMetadataMapEntryBase<ContentFileInfoForBytes>;
|
|
32
|
+
export type ContentAssetMetadataMapEntryString = {
|
|
33
|
+
type: 'string';
|
|
34
|
+
} & ContentAssetMetadataMapEntryBase<ContentFileInfoForString>;
|
|
35
|
+
export type ContentAssetMetadataMapEntryWasmInline = {
|
|
36
|
+
type: 'wasm-inline';
|
|
37
|
+
} & ContentAssetMetadataMapEntryBase<ContentFileInfoForWasmInline>;
|
|
23
38
|
export type ContentAssetMetadataMapEntryObjectStore = {
|
|
24
|
-
|
|
39
|
+
type: 'object-store';
|
|
25
40
|
} & ContentAssetMetadataMapEntryBase<ContentFileInfoForObjectStore>;
|
|
26
|
-
export type ContentAssetMetadataMapEntry =
|
|
41
|
+
export type ContentAssetMetadataMapEntry = ContentAssetMetadataMapEntryBytes | ContentAssetMetadataMapEntryString | ContentAssetMetadataMapEntryWasmInline | ContentAssetMetadataMapEntryObjectStore;
|
|
27
42
|
export type ContentAssetMetadataMap = {
|
|
28
43
|
[assetKey: string]: ContentAssetMetadataMapEntry;
|
|
29
44
|
};
|
|
30
45
|
export interface ContentAsset {
|
|
46
|
+
readonly type: string;
|
|
47
|
+
readonly isLocal: boolean;
|
|
31
48
|
readonly assetKey: string;
|
|
32
49
|
getMetadata(): ContentAssetMetadataMapEntry;
|
|
33
50
|
getStoreEntry(acceptEncodingsGroups?: ContentCompressionTypes[][]): Promise<StoreEntry>;
|
|
34
51
|
getBytes(): Uint8Array;
|
|
35
52
|
getText(): string;
|
|
36
|
-
readonly isInline: boolean;
|
|
37
53
|
}
|
|
38
54
|
//# sourceMappingURL=content-assets.d.ts.map
|
|
@@ -1 +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;
|
|
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,EAA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M,MAAM,uBAAuB,GAAG;IACpC,CAAC,QAAQ,EAAE,MAAM,GAAG,4BAA4B,CAAC;CAClD,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,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;CACnB"}
|
package/build/util/metadata.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function getObjectStoreKeysFromMetadata(contentAssetMetadataMap) {
|
|
2
2
|
const results = new Set();
|
|
3
3
|
for (const metadata of Object.values(contentAssetMetadataMap)) {
|
|
4
|
-
if (
|
|
4
|
+
if (metadata.type === 'object-store') {
|
|
5
5
|
results.add(metadata.fileInfo.objectStoreKey);
|
|
6
6
|
for (const fileInfo of Object.values(metadata.compressedFileInfos)) {
|
|
7
7
|
results.add(fileInfo.objectStoreKey);
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asset-manager.d.ts","sourceRoot":"","sources":["../../src/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"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AssetManager } from "./asset-manager.js";
|
|
2
|
-
import type { StoreEntry } from "../types/compute.js";
|
|
3
|
-
import type { ContentAsset, ContentAssetMetadataMap, ContentAssetMetadataMapEntry, ContentAssetMetadataMapEntryInline, ContentAssetMetadataMapEntryObjectStore } from "../types/content-assets.js";
|
|
4
|
-
export declare class ContentInlineAsset implements ContentAsset {
|
|
5
|
-
readonly isInline: boolean;
|
|
6
|
-
private readonly metadata;
|
|
7
|
-
private readonly bytes;
|
|
8
|
-
constructor(metadata: ContentAssetMetadataMapEntryInline, bytes: Uint8Array);
|
|
9
|
-
get assetKey(): string;
|
|
10
|
-
getStoreEntry(): Promise<StoreEntry>;
|
|
11
|
-
getBytes(): Uint8Array;
|
|
12
|
-
getText(): string;
|
|
13
|
-
getMetadata(): ContentAssetMetadataMapEntry;
|
|
14
|
-
}
|
|
15
|
-
export declare class ContentObjectStoreAsset implements ContentAsset {
|
|
16
|
-
readonly isInline: boolean;
|
|
17
|
-
private readonly metadata;
|
|
18
|
-
private readonly objectStoreName;
|
|
19
|
-
constructor(metadata: ContentAssetMetadataMapEntryObjectStore, objectStoreName: string);
|
|
20
|
-
get assetKey(): string;
|
|
21
|
-
getStoreEntry(): Promise<StoreEntry>;
|
|
22
|
-
getBytes(): Uint8Array;
|
|
23
|
-
getText(): string;
|
|
24
|
-
getMetadata(): ContentAssetMetadataMapEntry;
|
|
25
|
-
}
|
|
26
|
-
export declare class ContentAssets extends AssetManager<ContentAsset> {
|
|
27
|
-
constructor(objectStoreName: string | null, contentAssetMetadataMap: ContentAssetMetadataMap);
|
|
28
|
-
}
|
|
29
|
-
//# source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F"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { includeBytes } from "fastly:experimental";
|
|
2
|
-
import { ObjectStore } from "fastly:object-store";
|
|
3
|
-
import { AssetManager } from "./asset-manager.js";
|
|
4
|
-
import { IncludeBytesStoreEntry } from "../server/object-store/include-bytes-store-entry.js";
|
|
5
|
-
const decoder = new TextDecoder();
|
|
6
|
-
export class ContentInlineAsset {
|
|
7
|
-
constructor(metadata, bytes) {
|
|
8
|
-
this.isInline = true;
|
|
9
|
-
this.metadata = metadata;
|
|
10
|
-
this.bytes = bytes;
|
|
11
|
-
}
|
|
12
|
-
get assetKey() {
|
|
13
|
-
return this.metadata.assetKey;
|
|
14
|
-
}
|
|
15
|
-
getStoreEntry() {
|
|
16
|
-
return Promise.resolve(new IncludeBytesStoreEntry(this.bytes));
|
|
17
|
-
}
|
|
18
|
-
getBytes() {
|
|
19
|
-
return this.bytes;
|
|
20
|
-
}
|
|
21
|
-
getText() {
|
|
22
|
-
if (!this.metadata.text) {
|
|
23
|
-
throw new Error("Can't getText() for non-text content");
|
|
24
|
-
}
|
|
25
|
-
return decoder.decode(this.bytes);
|
|
26
|
-
}
|
|
27
|
-
getMetadata() {
|
|
28
|
-
return this.metadata;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export class ContentObjectStoreAsset {
|
|
32
|
-
constructor(metadata, objectStoreName) {
|
|
33
|
-
this.isInline = false;
|
|
34
|
-
this.metadata = metadata;
|
|
35
|
-
this.objectStoreName = objectStoreName;
|
|
36
|
-
}
|
|
37
|
-
get assetKey() {
|
|
38
|
-
return this.metadata.assetKey;
|
|
39
|
-
}
|
|
40
|
-
async getStoreEntry() {
|
|
41
|
-
const objectStore = new ObjectStore(this.objectStoreName);
|
|
42
|
-
let retries = 3;
|
|
43
|
-
while (retries > 0) {
|
|
44
|
-
const entry = await objectStore.get(this.metadata.objectStoreKey);
|
|
45
|
-
if (entry != null) {
|
|
46
|
-
return entry;
|
|
47
|
-
}
|
|
48
|
-
// Note the null does NOT mean 404. The fact that we are here means
|
|
49
|
-
// metadata exists for this path, and we're just trying to get the data from
|
|
50
|
-
// the object store.
|
|
51
|
-
// So if we're here then the data is either not available yet (in which case
|
|
52
|
-
// we can wait just a bit and try again), or the data was deleted.
|
|
53
|
-
retries--;
|
|
54
|
-
// We're going to wait 250ms/500ms/750ms and try again.
|
|
55
|
-
const delay = (3 - retries) * 250;
|
|
56
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
57
|
-
}
|
|
58
|
-
throw new Error("Asset could not be retrieved from the Object Store.");
|
|
59
|
-
}
|
|
60
|
-
getBytes() {
|
|
61
|
-
throw new Error("Can't getBytes() for Object Store asset");
|
|
62
|
-
}
|
|
63
|
-
getText() {
|
|
64
|
-
throw new Error("Can't getText() for Object Store asset");
|
|
65
|
-
}
|
|
66
|
-
getMetadata() {
|
|
67
|
-
return this.metadata;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export class ContentAssets extends AssetManager {
|
|
71
|
-
constructor(objectStoreName, contentAssetMetadataMap) {
|
|
72
|
-
super();
|
|
73
|
-
for (const [assetKey, metadata] of Object.entries(contentAssetMetadataMap)) {
|
|
74
|
-
let asset;
|
|
75
|
-
if (metadata.isInline) {
|
|
76
|
-
const bytes = includeBytes(metadata.staticFilePath);
|
|
77
|
-
asset = new ContentInlineAsset(metadata, bytes);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
if (objectStoreName == null) {
|
|
81
|
-
throw new Error("Unexpected! Object Store should be specified!!");
|
|
82
|
-
}
|
|
83
|
-
asset = new ContentObjectStoreAsset(metadata, objectStoreName);
|
|
84
|
-
}
|
|
85
|
-
this.setAsset(assetKey, asset);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -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/assets/module-assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE7E,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.setAsset(assetKey, asset);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../../src/cli/build-static.ts"],"names":[],"mappings":"AAuCA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAoKhD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBA4d5F"}
|