@fastly/compute-js-static-publish 2.3.0-alpha.0 → 2.3.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../src/build-static.ts"],"names":[],"mappings":"AAcA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAchD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../src/build-static.ts"],"names":[],"mappings":"AAcA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAchD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBAsN5F"}
|
package/build/build-static.js
CHANGED
|
@@ -150,7 +150,7 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
150
150
|
content = 'Buffer.from(file' + index + ', "base64")';
|
|
151
151
|
}
|
|
152
152
|
else {
|
|
153
|
-
content = 'file' + index;
|
|
153
|
+
content = 'String(file' + index + ')';
|
|
154
154
|
}
|
|
155
155
|
let module;
|
|
156
156
|
if (loadModule) {
|
|
@@ -198,6 +198,7 @@ export async function buildStaticLoader(commandLineValues) {
|
|
|
198
198
|
fileContents += `\nexport const autoIndex = ${JSON.stringify(autoIndex)};\n`;
|
|
199
199
|
let autoExt = (_h = config.autoExt) !== null && _h !== void 0 ? _h : null;
|
|
200
200
|
fileContents += `\nexport const autoExt = ${JSON.stringify(autoExt)};\n`;
|
|
201
|
+
fileContents += '\nexport const staticAssets = new StaticAssets(assets);\n';
|
|
201
202
|
fs.writeFileSync('./src/statics.js', fileContents);
|
|
202
203
|
console.log("✅ Wrote static file loader for " + files.length + " file(s).");
|
|
203
204
|
}
|
package/build/static-assets.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { AssetsMap } from "./types.js";
|
|
|
3
3
|
export declare class StaticAssets {
|
|
4
4
|
readonly assetsMap: AssetsMap;
|
|
5
5
|
constructor(assetsMap: AssetsMap);
|
|
6
|
+
getAsset(key: string): import("./types.js").Asset;
|
|
6
7
|
serveAsset(event: FetchEvent, pathPrefix?: string): Response | null;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=static-assets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-assets.d.ts","sourceRoot":"","sources":["../src/static-assets.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,qBAAa,YAAY;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;gBAElB,SAAS,EAAE,SAAS;IAIzB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,GAAE,MAAW;CAqB7D"}
|
|
1
|
+
{"version":3,"file":"static-assets.d.ts","sourceRoot":"","sources":["../src/static-assets.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,qBAAa,YAAY;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;gBAElB,SAAS,EAAE,SAAS;IAIzB,QAAQ,CAAC,GAAG,EAAE,MAAM;IAIpB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,GAAE,MAAW;CAqB7D"}
|
package/build/static-assets.js
CHANGED
|
@@ -2,10 +2,13 @@ export class StaticAssets {
|
|
|
2
2
|
constructor(assetsMap) {
|
|
3
3
|
this.assetsMap = assetsMap;
|
|
4
4
|
}
|
|
5
|
+
getAsset(key) {
|
|
6
|
+
return this.assetsMap[key];
|
|
7
|
+
}
|
|
5
8
|
serveAsset(event, pathPrefix = '') {
|
|
6
9
|
const { request } = event;
|
|
7
10
|
const { pathname } = new URL(request.url);
|
|
8
|
-
const asset = this.
|
|
11
|
+
const asset = this.getAsset(`${pathPrefix}${pathname}`);
|
|
9
12
|
if (!asset) {
|
|
10
13
|
return null;
|
|
11
14
|
}
|
package/package.json
CHANGED