@fastly/compute-js-static-publish 3.1.0 → 3.2.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":"AAkBA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAchD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBAqP5F"}
1
+ {"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../src/build-static.ts"],"names":[],"mappings":"AAkBA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAchD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBAmP5F"}
@@ -151,22 +151,20 @@ export async function buildStaticLoader(commandLineValues) {
151
151
  }
152
152
  }
153
153
  // Serve static files by copying them into the static content dir and using includeBytes()
154
- let staticFileExt, staticFileTypeDesc, isBinary;
154
+ let staticFileExt, staticFileType;
155
155
  if (contentDef == null || contentDef.binary) {
156
156
  staticFileExt = '.bin';
157
- staticFileTypeDesc = 'binary';
158
- isBinary = true;
157
+ staticFileType = 'binary';
159
158
  }
160
159
  else {
161
160
  staticFileExt = '.txt';
162
- staticFileTypeDesc = 'text';
163
- isBinary = false;
161
+ staticFileType = 'string';
164
162
  }
165
163
  const staticFilePath = `${staticContentDir}/file${index}${staticFileExt}`;
166
164
  fs.cpSync(file, staticFilePath);
167
- console.log(`✔️ Copied static ${staticFileTypeDesc} file "${file}" to "${staticFilePath}".`);
165
+ console.log(`✔️ Copied static ${staticFileType} file "${file}" to "${staticFilePath}".`);
168
166
  let content = `includeBytes("${staticFilePath}")`;
169
- if (!isBinary) {
167
+ if (staticFileType === 'string') {
170
168
  content = `textDecoder.decode(${content})`;
171
169
  }
172
170
  let module;
@@ -176,7 +174,7 @@ export async function buildStaticLoader(commandLineValues) {
176
174
  else {
177
175
  module = 'null';
178
176
  }
179
- fileContents += ` ${JSON.stringify(filePath)}: { contentType: ${JSON.stringify(type)}, content: ${content}, module: ${module}, isStatic: ${JSON.stringify(isStatic)} },\n`;
177
+ fileContents += ` ${JSON.stringify(filePath)}: { type: ${JSON.stringify(staticFileType)}, contentType: ${JSON.stringify(type)}, content: ${content}, module: ${module}, isStatic: ${JSON.stringify(isStatic)} },\n`;
180
178
  }
181
179
  fileContents += '};\n';
182
180
  let spaFile = (_h = config.spa) !== null && _h !== void 0 ? _h : false;
package/build/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export type { Asset, AssetsMap, Config } from './types.js';
1
+ export type { Asset, AssetBase, AssetsMap, BinaryAsset, Config, StringAsset } from './types.js';
2
2
  export { StaticAssets } from './static-assets.js';
3
3
  //# 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,MAAM,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
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"}
package/build/types.d.ts CHANGED
@@ -12,12 +12,20 @@ export declare type DefaultContentTypesModule = {
12
12
  mergeContentTypes: (contentTypes: ContentTypeDef[]) => ContentTypeDef[];
13
13
  testFileContentType: (contentTypes: ContentTypeDef[], file: string) => ContentTypeMatch;
14
14
  };
15
- export declare type Asset = {
15
+ export declare type AssetBase = {
16
16
  contentType: string;
17
- content: ArrayBuffer | string;
18
- module: unknown | null;
17
+ module: any | null;
19
18
  isStatic: boolean;
20
19
  };
20
+ export declare type StringAsset = AssetBase & {
21
+ type: 'string';
22
+ content: string;
23
+ };
24
+ export declare type BinaryAsset = AssetBase & {
25
+ type: 'binary';
26
+ content: Uint8Array;
27
+ };
28
+ export declare type Asset = StringAsset | BinaryAsset;
21
29
  export declare type AssetsMap = {
22
30
  [filePath: string]: Asset;
23
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,aAAK,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAExC,oBAAY,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IACtC,iBAAiB,EAAE,CAAC,YAAY,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,CAAC;IACxE,mBAAmB,EAAE,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,MAAM,KAAK,gBAAgB,CAAC;CACzF,CAAC;AAEF,oBAAY,KAAK,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,WAAW,GAAG,MAAM,CAAC;IAC9B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oBAAY,SAAS,GAAG;IACtB,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC;CAC3B,CAAC;AAEF,oBAAY,MAAM,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,EAA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 "version": "3.2.1",
5
5
  "description": "Static Publisher for Compute@Edge JavaScript",
6
6
  "main": "./build/index.js",
7
7
  "types": "./build/index.d.ts",
@@ -2,22 +2,8 @@
2
2
  * Generated by @fastly/compute-js-static-publish.
3
3
  */
4
4
 
5
- type AssetBase = {
6
- contentType: string,
7
- module: any | null,
8
- isStatic: boolean,
9
- };
10
- type StringAsset = AssetBase & {
11
- type: 'string',
12
- content: string,
13
- };
14
- type BinaryAsset = AssetBase & {
15
- type: 'binary',
16
- content: Uint8Array,
17
- };
18
- type Asset = StringAsset | BinaryAsset;
19
- import { StaticAssets } from "@fastly/compute-js-static-publish";
20
- export declare const assets: Record<string, Asset>;
5
+ import type { AssetsMap, StaticAssets } from "@fastly/compute-js-static-publish";
6
+ export declare const assets: AssetsMap;
21
7
  export declare const spaFile: string | false;
22
8
  export declare const notFoundPageFile: string | false;
23
9
  export declare const autoIndex: string[] | false;