@fastly/compute-js-static-publish 4.0.0 → 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.
Files changed (91) hide show
  1. package/README.md +4 -4
  2. package/build/cli/commands/build-static.d.ts.map +1 -1
  3. package/build/cli/commands/build-static.js +5 -4
  4. package/build/cli/commands/clean-object-store.d.ts.map +1 -1
  5. package/build/compute-js.d.ts +3 -0
  6. package/build/compute-js.d.ts.map +1 -0
  7. package/build/compute-js.js +2 -0
  8. package/build/server/assets/asset-manager.d.ts +1 -0
  9. package/build/server/assets/asset-manager.d.ts.map +1 -1
  10. package/build/server/assets/asset-manager.js +3 -0
  11. package/build/server/assets/content-asset-object-store.d.ts +18 -0
  12. package/build/server/assets/content-asset-object-store.d.ts.map +1 -0
  13. package/build/server/assets/content-asset-object-store.js +67 -0
  14. package/build/server/assets/content-asset-wasm-inline.d.ts +17 -0
  15. package/build/server/assets/content-asset-wasm-inline.d.ts.map +1 -0
  16. package/build/server/assets/content-asset-wasm-inline.js +48 -0
  17. package/build/server/assets/content-assets-runtime.d.ts +2 -0
  18. package/build/server/assets/content-assets-runtime.d.ts.map +1 -0
  19. package/build/server/assets/content-assets.d.ts +33 -21
  20. package/build/server/assets/content-assets.d.ts.map +1 -1
  21. package/build/server/assets/content-assets.js +39 -85
  22. package/build/types/content-assets.d.ts +23 -7
  23. package/build/types/content-assets.d.ts.map +1 -1
  24. package/build/util/metadata.js +1 -1
  25. package/package.json +1 -1
  26. package/build/assets/asset-manager.d.ts +0 -7
  27. package/build/assets/asset-manager.d.ts.map +0 -1
  28. package/build/assets/asset-manager.js +0 -11
  29. package/build/assets/content-assets.d.ts +0 -29
  30. package/build/assets/content-assets.d.ts.map +0 -1
  31. package/build/assets/content-assets.js +0 -88
  32. package/build/assets/module-assets.d.ts +0 -23
  33. package/build/assets/module-assets.d.ts.map +0 -1
  34. package/build/assets/module-assets.js +0 -45
  35. package/build/cli/build-static.d.ts +0 -3
  36. package/build/cli/build-static.d.ts.map +0 -1
  37. package/build/cli/build-static.js +0 -524
  38. package/build/cli/clean-object-store.d.ts +0 -2
  39. package/build/cli/clean-object-store.d.ts.map +0 -1
  40. package/build/cli/cli.d.ts +0 -3
  41. package/build/cli/cli.d.ts.map +0 -1
  42. package/build/cli/cli.js +0 -77
  43. package/build/cli/init-app.d.ts +0 -3
  44. package/build/cli/init-app.d.ts.map +0 -1
  45. package/build/cli/init-app.js +0 -283
  46. package/build/presets/implementations/create-react-app.d.ts +0 -16
  47. package/build/presets/implementations/create-react-app.d.ts.map +0 -1
  48. package/build/presets/implementations/create-react-app.js +0 -34
  49. package/build/presets/implementations/docusaurus.d.ts +0 -11
  50. package/build/presets/implementations/docusaurus.d.ts.map +0 -1
  51. package/build/presets/implementations/docusaurus.js +0 -13
  52. package/build/presets/implementations/gatsby.d.ts +0 -11
  53. package/build/presets/implementations/gatsby.d.ts.map +0 -1
  54. package/build/presets/implementations/gatsby.js +0 -13
  55. package/build/presets/implementations/next.d.ts +0 -11
  56. package/build/presets/implementations/next.d.ts.map +0 -1
  57. package/build/presets/implementations/next.js +0 -13
  58. package/build/presets/implementations/sveltekit.d.ts +0 -11
  59. package/build/presets/implementations/sveltekit.d.ts.map +0 -1
  60. package/build/presets/implementations/sveltekit.js +0 -13
  61. package/build/presets/implementations/vite.d.ts +0 -11
  62. package/build/presets/implementations/vite.d.ts.map +0 -1
  63. package/build/presets/implementations/vite.js +0 -13
  64. package/build/presets/index.d.ts +0 -3
  65. package/build/presets/index.d.ts.map +0 -1
  66. package/build/presets/index.js +0 -16
  67. package/build/presets/preset-base.d.ts +0 -18
  68. package/build/presets/preset-base.d.ts.map +0 -1
  69. package/build/presets/preset-base.js +0 -1
  70. package/build/server/object-store/include-bytes-store-entry.d.ts +0 -19
  71. package/build/server/object-store/include-bytes-store-entry.d.ts.map +0 -1
  72. package/build/server/object-store/include-bytes-store-entry.js +0 -87
  73. package/build/util/data.d.ts +0 -7
  74. package/build/util/data.d.ts.map +0 -1
  75. package/build/util/data.js +0 -58
  76. package/build/util/fastly-api.d.ts +0 -10
  77. package/build/util/fastly-api.d.ts.map +0 -1
  78. package/build/util/fastly-api.js +0 -47
  79. package/build/util/files.d.ts +0 -10
  80. package/build/util/files.d.ts.map +0 -1
  81. package/build/util/files.js +0 -32
  82. package/build/util/hash.d.ts +0 -2
  83. package/build/util/hash.d.ts.map +0 -1
  84. package/build/util/hash.js +0 -8
  85. package/build/util/id.d.ts +0 -3
  86. package/build/util/id.d.ts.map +0 -1
  87. package/build/util/id.js +0 -17
  88. package/build/util/object-store.d.ts +0 -12
  89. package/build/util/object-store.d.ts.map +0 -1
  90. package/build/util/object-store.js +0 -80
  91. /package/build/{cli/clean-object-store.js → server/assets/content-assets-runtime.js} +0 -0
@@ -1,283 +0,0 @@
1
- // This program creates a Compute@Edge JavaScript application
2
- // in a subfolder named compute-js.
3
- // This project can be served using fastly compute serve
4
- // or deployed to a Compute@Edge service using fastly compute publish.
5
- import * as child_process from "child_process";
6
- import * as path from "path";
7
- import * as fs from "fs";
8
- import * as url from 'url';
9
- import { presets } from './presets/index.js';
10
- const defaultOptions = {
11
- 'public-dir': undefined,
12
- 'static-dir': undefined,
13
- spa: undefined,
14
- 'not-found-page': '[public-dir]/404.html',
15
- 'auto-index': ['index.html', 'index.htm'],
16
- 'auto-ext': ['.html', '.htm'],
17
- author: 'you@example.com',
18
- name: 'compute-js-static-site',
19
- description: 'Compute@Edge static site',
20
- 'service-id': undefined,
21
- };
22
- function pickKeys(keys, object) {
23
- const result = {};
24
- for (const key of keys) {
25
- if (object[key] !== undefined) {
26
- result[key] = object[key];
27
- }
28
- }
29
- return result;
30
- }
31
- function applyPublicDir(optionValue, publicDir) {
32
- if (optionValue == null) {
33
- return optionValue;
34
- }
35
- return optionValue.replace('[public-dir]', publicDir);
36
- }
37
- export function initApp(commandLineValues) {
38
- let options = defaultOptions;
39
- let preset = null;
40
- const presetName = commandLineValues['preset'] ?? 'none';
41
- if (presetName !== 'none') {
42
- const presetClass = presets[presetName];
43
- if (presetClass == null) {
44
- console.error('Unknown preset name.');
45
- console.error("--preset must be one of: none, " + (Object.keys(presets).join(', ')));
46
- process.exitCode = 1;
47
- return;
48
- }
49
- preset = new presetClass();
50
- }
51
- let packageJson;
52
- try {
53
- const packageJsonText = fs.readFileSync("./package.json", "utf-8");
54
- packageJson = JSON.parse(packageJsonText);
55
- }
56
- catch {
57
- console.log("Can't read/parse package.json in current directory, making no assumptions!");
58
- packageJson = null;
59
- }
60
- options = {
61
- ...options,
62
- ...(preset != null ? preset.defaultOptions : {}),
63
- ...pickKeys(['author', 'name', 'description'], packageJson ?? {}),
64
- ...pickKeys(['public-dir', 'static-dir', 'spa', 'not-found-page', 'auto-index', 'auto-ext', 'author', 'name', 'description', 'service-id'], commandLineValues)
65
- };
66
- if (preset != null) {
67
- if (!preset.check(packageJson, options)) {
68
- console.log("Failed preset check.");
69
- process.exitCode = 1;
70
- return;
71
- }
72
- }
73
- const COMPUTE_JS_DIR = commandLineValues.output;
74
- const computeJsDir = path.resolve(COMPUTE_JS_DIR);
75
- const PUBLIC_DIR = options['public-dir'];
76
- if (PUBLIC_DIR == null) {
77
- console.error("❌ required parameter --public-dir not provided.");
78
- process.exitCode = 1;
79
- return;
80
- }
81
- const publicDir = path.resolve(PUBLIC_DIR);
82
- const BUILD_STATIC_DIR = applyPublicDir(options['static-dir'], PUBLIC_DIR);
83
- const buildStaticDir = BUILD_STATIC_DIR != null ? path.resolve(BUILD_STATIC_DIR) : null;
84
- const spa = applyPublicDir(options['spa'], PUBLIC_DIR);
85
- const notFoundPage = applyPublicDir(options['not-found-page'], PUBLIC_DIR);
86
- const autoIndex = options['auto-index'];
87
- const autoExt = options['auto-ext'];
88
- let spaFilename = spa;
89
- // Specifically check for null instead of undefined
90
- if (spa === null) {
91
- spaFilename = path.resolve(publicDir, './index.html');
92
- let rel = path.relative(path.resolve(), spaFilename);
93
- if (!rel.startsWith('..')) {
94
- rel = './' + rel;
95
- }
96
- console.log('--spa provided with no value, assuming ' + rel);
97
- }
98
- if (spaFilename != null) {
99
- spaFilename = path.resolve(spaFilename);
100
- if (!spaFilename.startsWith(publicDir)) {
101
- console.error(`❌ SPA file '${spaFilename}' not inside public directory!`);
102
- process.exitCode = 1;
103
- return;
104
- }
105
- }
106
- let notFoundPageFilename = notFoundPage;
107
- // Specifically check for null instead of undefined
108
- if (notFoundPage === null) {
109
- notFoundPageFilename = path.resolve(publicDir, './404.html');
110
- let rel = path.relative(path.resolve(), notFoundPageFilename);
111
- if (!rel.startsWith('..')) {
112
- rel = './' + rel;
113
- }
114
- console.log('--not-found-page provided with no value, assuming ' + rel);
115
- }
116
- if (notFoundPageFilename != null) {
117
- notFoundPageFilename = path.resolve(notFoundPageFilename);
118
- if (!notFoundPageFilename.startsWith(publicDir)) {
119
- console.error(`❌ --not-found-page file '${notFoundPageFilename}' not inside public directory!`);
120
- process.exitCode = 1;
121
- return;
122
- }
123
- }
124
- const exists = fs.existsSync(computeJsDir);
125
- if (exists) {
126
- console.error(`❌ '${COMPUTE_JS_DIR}' directory already exists!`);
127
- process.exitCode = 1;
128
- return;
129
- }
130
- const author = options['author'];
131
- const name = options['name'];
132
- const description = options['description'];
133
- const fastlyServiceId = options['service-id'];
134
- let spaRel = spaFilename != null ? path.relative(path.resolve(), spaFilename) : null;
135
- if (spaRel != null && !spaRel.startsWith('..')) {
136
- spaRel = './' + spaRel;
137
- }
138
- let notFoundRel = notFoundPageFilename != null ? path.relative(path.resolve(), notFoundPageFilename) : null;
139
- if (notFoundRel != null && !notFoundRel.startsWith('..')) {
140
- notFoundRel = './' + notFoundRel;
141
- }
142
- console.log('');
143
- console.log('Public Dir :', PUBLIC_DIR);
144
- console.log('Static Dir :', BUILD_STATIC_DIR ?? '(None)');
145
- console.log('SPA :', spaRel ?? '(None)');
146
- console.log('404 Page :', notFoundRel ?? '(None)');
147
- console.log('Auto-Index :', autoIndex ?? '(None)');
148
- console.log('Auto-Ext :', autoExt ?? '(None)');
149
- console.log('name :', name);
150
- console.log('author :', author);
151
- console.log('description :', description);
152
- console.log('Service ID :', fastlyServiceId ?? '(None)');
153
- console.log('');
154
- console.log("Initializing Compute@Edge Application in " + computeJsDir + "...");
155
- fs.mkdirSync(computeJsDir);
156
- fs.mkdirSync(path.resolve(computeJsDir, './src'));
157
- // .gitignore
158
- const gitIgnoreContent = `\
159
- /node_modules
160
- /bin
161
- /pkg
162
- /src/statics.js
163
- /src/statics.d.ts
164
- /src/statics-metadata.js
165
- /src/statics-metadata.d.ts
166
- /src/static-content
167
- `;
168
- const gitIgnorePath = path.resolve(computeJsDir, '.gitignore');
169
- fs.writeFileSync(gitIgnorePath, gitIgnoreContent, "utf-8");
170
- // package.json
171
- // language=JSON
172
- const packageJsonContent = `\
173
- {
174
- "name": ${JSON.stringify(name)},
175
- "description": ${JSON.stringify(description)},
176
- "author": ${JSON.stringify(author)},
177
- "devDependencies": {
178
- "@fastly/compute-js-static-publish": "^4.0.0-alpha.0",
179
- "webpack": "^5.75.0",
180
- "webpack-cli": "^5.0.0"
181
- },
182
- "dependencies": {
183
- "@fastly/js-compute": "^1.4.0"
184
- },
185
- "engines": {
186
- "node": ">=16.0.0"
187
- },
188
- "license": "MIT",
189
- "private": true,
190
- "main": "src/index.js",
191
- "scripts": {
192
- "deploy": "fastly compute deploy",
193
- "prebuild": "npx @fastly/compute-js-static-publish --build-static && webpack",
194
- "build": "js-compute-runtime ./bin/index.js ./bin/main.wasm"
195
- },
196
- "version": "0.2.1"
197
- }
198
- `;
199
- const packageJsonPath = path.resolve(computeJsDir, 'package.json');
200
- fs.writeFileSync(packageJsonPath, packageJsonContent, "utf-8");
201
- // fastly.toml
202
- // language=toml
203
- const fastlyTomlContent = `\
204
- # This file describes a Fastly Compute@Edge package. To learn more visit:
205
- # https://developer.fastly.com/reference/fastly-toml/
206
-
207
- authors = [ "${author}" ]
208
- description = "${description}"
209
- language = "javascript"
210
- manifest_version = 2
211
- name = "${name}"
212
- ${fastlyServiceId != null ? `service_id = "${fastlyServiceId}"
213
- ` : ''}
214
- [scripts]
215
- build = "npm run build"
216
- `;
217
- const fastlyTomlPath = path.resolve(computeJsDir, 'fastly.toml');
218
- fs.writeFileSync(fastlyTomlPath, fastlyTomlContent, "utf-8");
219
- // static-publish.rc.js
220
- const publicDirRel = path.relative(computeJsDir, publicDir);
221
- const staticDirs = [];
222
- if (buildStaticDir != null) {
223
- staticDirs.push(buildStaticDir);
224
- }
225
- const staticDirsRel = [];
226
- for (const staticDir of staticDirs) {
227
- const rel = path.relative(publicDir, staticDir);
228
- if (rel.startsWith('../')) {
229
- // we can't have a path outside the public dir, so we ignore it
230
- console.warn(`Specified static dir '${staticDir}' is not inside public directory, ignoring...`);
231
- continue;
232
- }
233
- staticDirsRel.push('./' + rel);
234
- }
235
- let spaFileRel = false;
236
- if (spaFilename != null) {
237
- spaFileRel = '/' + path.relative(publicDir, spaFilename);
238
- }
239
- let notFoundFileRel = false;
240
- if (notFoundPageFilename != null) {
241
- notFoundFileRel = '/' + path.relative(publicDir, notFoundPageFilename);
242
- }
243
- const staticPublishJsContent = `\
244
- /** @type {import('@fastly/compute-js-static-publish').StaticPublisherConfig} */
245
- module.exports = {
246
- publicDir: ${JSON.stringify(publicDirRel)},
247
- excludeDirs: [ './node_modules' ],
248
- includeDirs: [ './.well-known' ],
249
- staticDirs: ${JSON.stringify(staticDirsRel)},
250
- spa: ${JSON.stringify(spaFileRel)},
251
- notFoundPage: ${JSON.stringify(notFoundFileRel)},
252
- autoIndex: ${JSON.stringify(autoIndex)},
253
- autoExt: ${JSON.stringify(autoExt)},
254
- };`;
255
- const staticPublishJsonPath = path.resolve(computeJsDir, 'static-publish.rc.js');
256
- fs.writeFileSync(staticPublishJsonPath, staticPublishJsContent, "utf-8");
257
- // Copy resource files
258
- const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
259
- // webpack.config.js
260
- const webpackConfigJsSrcPath = path.resolve(__dirname, '../../resources/webpack.config.js');
261
- const webpackConfigJsPath = path.resolve(computeJsDir, 'webpack.config.js');
262
- fs.copyFileSync(webpackConfigJsSrcPath, webpackConfigJsPath);
263
- // src/index.js
264
- const indexJsSrcPath = path.resolve(__dirname, '../../resources/index.js');
265
- const indexJsPath = path.resolve(computeJsDir, './src/index.js');
266
- fs.copyFileSync(indexJsSrcPath, indexJsPath);
267
- console.log("🚀 Compute@Edge application created!");
268
- console.log('Installing dependencies...');
269
- console.log(`npm --prefix ${COMPUTE_JS_DIR} install`);
270
- child_process.spawnSync('npm', ['--prefix', COMPUTE_JS_DIR, 'install'], { stdio: 'inherit' });
271
- console.log('');
272
- console.log('');
273
- console.log('To run your Compute@Edge application locally:');
274
- console.log('');
275
- console.log(' cd ' + COMPUTE_JS_DIR);
276
- console.log(' fastly compute serve');
277
- console.log('');
278
- console.log('To build and deploy to your Compute@Edge service:');
279
- console.log('');
280
- console.log(' cd ' + COMPUTE_JS_DIR);
281
- console.log(' fastly compute publish');
282
- console.log('');
283
- }
@@ -1,16 +0,0 @@
1
- import { IPresetBase } from '../preset-base.js';
2
- export declare class CreateReactAppPreset implements IPresetBase {
3
- name: string;
4
- defaultOptions: {
5
- 'public-dir': string;
6
- 'static-dir': string;
7
- name: string;
8
- description: string;
9
- };
10
- check(packageJson: any): boolean;
11
- }
12
- export declare class CreateReactAppEjectedPreset extends CreateReactAppPreset {
13
- name: string;
14
- check(): boolean;
15
- }
16
- //# sourceMappingURL=create-react-app.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-react-app.d.ts","sourceRoot":"","sources":["../../../src/presets/implementations/create-react-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,oBAAqB,YAAW,WAAW;IACtD,IAAI,SAAsB;IAC1B,cAAc;;;;;MAKZ;IAEF,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,OAAO;CAejC;AAED,qBAAa,2BAA4B,SAAQ,oBAAoB;IACnE,IAAI,SAAgC;IACpC,KAAK;CAGN"}
@@ -1,34 +0,0 @@
1
- export class CreateReactAppPreset {
2
- constructor() {
3
- this.name = 'Create React App';
4
- this.defaultOptions = {
5
- 'public-dir': './build',
6
- 'static-dir': '[public-dir]/static',
7
- name: 'my-create-react-app',
8
- description: 'Compute@Edge static site from create-react-app',
9
- };
10
- }
11
- check(packageJson) {
12
- if (packageJson == null) {
13
- console.error("❌ Can't read/parse package.json");
14
- console.error("Run this from a create-react-app project directory.");
15
- return false;
16
- }
17
- if (packageJson?.dependencies?.['react-scripts'] == null) {
18
- console.error("❌ Can't find react-scripts in dependencies");
19
- console.error("Run this from a create-react-app project directory.");
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.");
21
- return false;
22
- }
23
- return true;
24
- }
25
- }
26
- export class CreateReactAppEjectedPreset extends CreateReactAppPreset {
27
- constructor() {
28
- super(...arguments);
29
- this.name = 'Create React App (Ejected)';
30
- }
31
- check() {
32
- return true;
33
- }
34
- }
@@ -1,11 +0,0 @@
1
- import { IPresetBase } from '../preset-base.js';
2
- export declare class DocusaurusPreset implements IPresetBase {
3
- name: string;
4
- defaultOptions: {
5
- 'public-dir': string;
6
- name: string;
7
- description: string;
8
- };
9
- check(): boolean;
10
- }
11
- //# sourceMappingURL=docusaurus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"docusaurus.d.ts","sourceRoot":"","sources":["../../../src/presets/implementations/docusaurus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,gBAAiB,YAAW,WAAW;IAClD,IAAI,SAAgB;IACpB,cAAc;;;;MAIZ;IACF,KAAK;CAGN"}
@@ -1,13 +0,0 @@
1
- export class DocusaurusPreset {
2
- constructor() {
3
- this.name = 'Docusaurus';
4
- this.defaultOptions = {
5
- 'public-dir': './build',
6
- name: 'my-docusaurus-app',
7
- description: 'Compute@Edge static site from docusaurus',
8
- };
9
- }
10
- check() {
11
- return true;
12
- }
13
- }
@@ -1,11 +0,0 @@
1
- import { IPresetBase } from '../preset-base.js';
2
- export declare class GatsbyPreset implements IPresetBase {
3
- name: string;
4
- defaultOptions: {
5
- 'public-dir': string;
6
- name: string;
7
- description: string;
8
- };
9
- check(): boolean;
10
- }
11
- //# sourceMappingURL=gatsby.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gatsby.d.ts","sourceRoot":"","sources":["../../../src/presets/implementations/gatsby.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,YAAa,YAAW,WAAW;IAC9C,IAAI,SAAY;IAChB,cAAc;;;;MAIZ;IACF,KAAK;CAGN"}
@@ -1,13 +0,0 @@
1
- export class GatsbyPreset {
2
- constructor() {
3
- this.name = 'Gatsby';
4
- this.defaultOptions = {
5
- 'public-dir': './public',
6
- name: 'my-gatsby-app',
7
- description: 'Compute@Edge static site from Gatsby',
8
- };
9
- }
10
- check() {
11
- return true;
12
- }
13
- }
@@ -1,11 +0,0 @@
1
- import { IPresetBase } from '../preset-base.js';
2
- export declare class NextJsPreset implements IPresetBase {
3
- name: string;
4
- defaultOptions: {
5
- 'public-dir': string;
6
- name: string;
7
- description: string;
8
- };
9
- check(): boolean;
10
- }
11
- //# sourceMappingURL=next.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../../src/presets/implementations/next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,YAAa,YAAW,WAAW;IAC9C,IAAI,SAAa;IACjB,cAAc;;;;MAIZ;IACF,KAAK;CAGN"}
@@ -1,13 +0,0 @@
1
- export class NextJsPreset {
2
- constructor() {
3
- this.name = 'Next.js';
4
- this.defaultOptions = {
5
- 'public-dir': './out',
6
- name: 'my-next-app',
7
- description: 'Compute@Edge static site from Next.js',
8
- };
9
- }
10
- check() {
11
- return true;
12
- }
13
- }
@@ -1,11 +0,0 @@
1
- import { IPresetBase } from '../preset-base.js';
2
- export declare class SvelteKitPreset implements IPresetBase {
3
- name: string;
4
- defaultOptions: {
5
- 'public-dir': string;
6
- name: string;
7
- description: string;
8
- };
9
- check(): boolean;
10
- }
11
- //# sourceMappingURL=sveltekit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sveltekit.d.ts","sourceRoot":"","sources":["../../../src/presets/implementations/sveltekit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,eAAgB,YAAW,WAAW;IACjD,IAAI,SAAe;IACnB,cAAc;;;;MAIZ;IACF,KAAK;CAGN"}
@@ -1,13 +0,0 @@
1
- export class SvelteKitPreset {
2
- constructor() {
3
- this.name = 'SvelteKit';
4
- this.defaultOptions = {
5
- 'public-dir': './dist',
6
- name: 'my-sveltekit-app',
7
- description: 'Compute@Edge static site from SvelteKit',
8
- };
9
- }
10
- check() {
11
- return true;
12
- }
13
- }
@@ -1,11 +0,0 @@
1
- import { IPresetBase } from '../preset-base.js';
2
- export declare class VitePreset implements IPresetBase {
3
- name: string;
4
- defaultOptions: {
5
- 'public-dir': string;
6
- name: string;
7
- description: string;
8
- };
9
- check(): boolean;
10
- }
11
- //# sourceMappingURL=vite.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../src/presets/implementations/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,UAAW,YAAW,WAAW;IAC5C,IAAI,SAAU;IACd,cAAc;;;;MAIZ;IACF,KAAK;CAGN"}
@@ -1,13 +0,0 @@
1
- export class VitePreset {
2
- constructor() {
3
- this.name = 'Vite';
4
- this.defaultOptions = {
5
- 'public-dir': './dist',
6
- name: 'my-vite-app',
7
- description: 'Compute@Edge static site from Vite',
8
- };
9
- }
10
- check() {
11
- return true;
12
- }
13
- }
@@ -1,3 +0,0 @@
1
- import { IPresetBase } from './preset-base.js';
2
- export declare const presets: Record<string, new () => IPresetBase>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/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"}
@@ -1,16 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
1
- export type AppOptions = {
2
- 'public-dir': string | undefined;
3
- 'static-dir': string | undefined;
4
- spa: string | null | undefined;
5
- 'not-found-page': string | null | undefined;
6
- 'auto-index': string[] | null | undefined;
7
- 'auto-ext': string[] | null | undefined;
8
- name: string;
9
- author: string;
10
- description: string;
11
- 'service-id': string | undefined;
12
- };
13
- export interface IPresetBase {
14
- name: string;
15
- defaultOptions: Partial<AppOptions>;
16
- check(packageJson: any | null, options: AppOptions): boolean;
17
- }
18
- //# sourceMappingURL=preset-base.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { StoreEntry } from "../../types/compute.js";
2
- export declare class IncludeBytesStoreEntry implements StoreEntry {
3
- _consumed: boolean;
4
- _body: ReadableStreamForBytes;
5
- constructor(array: Uint8Array);
6
- get body(): ReadableStream<Uint8Array>;
7
- get bodyUsed(): boolean;
8
- arrayBuffer(): Promise<ArrayBuffer>;
9
- static decoder: TextDecoder;
10
- text(): Promise<string>;
11
- json(): Promise<any>;
12
- }
13
- declare class ReadableStreamForBytes extends ReadableStream<Uint8Array> {
14
- _disturbed: boolean;
15
- constructor(array: Uint8Array);
16
- getReader(): ReadableStreamDefaultReader<Uint8Array>;
17
- }
18
- export {};
19
- //# sourceMappingURL=include-bytes-store-entry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"include-bytes-store-entry.d.ts","sourceRoot":"","sources":["../../../src/server/object-store/include-bytes-store-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKpD,qBAAa,sBAAuB,YAAW,UAAU;IACvD,SAAS,EAAE,OAAO,CAAC;IAEnB,KAAK,EAAE,sBAAsB,CAAC;gBAElB,KAAK,EAAE,UAAU;IAK7B,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;CAI3B;AAED,cAAM,sBAAuB,SAAQ,cAAc,CAAC,UAAU,CAAC;IAG7D,UAAU,UAAS;gBAEP,KAAK,EAAE,UAAU;IASpB,SAAS,IAAI,2BAA2B,CAAC,UAAU,CAAC;CA6B9D"}
@@ -1,87 +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
- export class IncludeBytesStoreEntry {
4
- constructor(array) {
5
- this._body = new ReadableStreamForBytes(array);
6
- this._consumed = false;
7
- }
8
- get body() {
9
- return this._body;
10
- }
11
- get bodyUsed() {
12
- return this._consumed;
13
- }
14
- async arrayBuffer() {
15
- if (this._consumed) {
16
- throw new Error('Body has already been consumed');
17
- }
18
- if (this._body.locked) {
19
- throw new Error('The ReadableStream body is already locked and can\'t be consumed');
20
- }
21
- if (this._body._disturbed) {
22
- throw new Error('Body object should not be disturbed or locked');
23
- }
24
- this._consumed = true;
25
- let result = new Uint8Array(0);
26
- const reader = this._body.getReader();
27
- try {
28
- while (true) {
29
- const { done, value } = await reader.read();
30
- if (done) {
31
- break;
32
- }
33
- const newResult = new Uint8Array(result.length + value.length);
34
- newResult.set(result);
35
- newResult.set(value, result.length);
36
- result = newResult;
37
- }
38
- return result;
39
- }
40
- finally {
41
- reader.releaseLock();
42
- }
43
- }
44
- async text() {
45
- const data = await this.arrayBuffer();
46
- return IncludeBytesStoreEntry.decoder.decode(data);
47
- }
48
- async json() {
49
- const text = await this.text();
50
- return JSON.parse(text);
51
- }
52
- }
53
- IncludeBytesStoreEntry.decoder = new TextDecoder();
54
- class ReadableStreamForBytes extends ReadableStream {
55
- constructor(array) {
56
- super({
57
- async start(controller) {
58
- controller.enqueue(array);
59
- controller.close();
60
- },
61
- });
62
- // Closest we can get to the "disturbed" flag
63
- this._disturbed = false;
64
- }
65
- getReader() {
66
- const reader = super.getReader();
67
- const stream = this;
68
- // Monkey-patch read
69
- const _read = reader.read;
70
- reader.read = async () => {
71
- const result = await _read.call(reader);
72
- if (result.done) {
73
- // NOTE: C@E Request body does not seem to get marked as "disturbed" until
74
- // end of stream is reached either...
75
- stream._disturbed = true;
76
- }
77
- return result;
78
- };
79
- // Monkey-patch cancel
80
- const _cancel = reader.cancel;
81
- reader.cancel = async (reason) => {
82
- await _cancel.call(reader, reason);
83
- stream._disturbed = true;
84
- };
85
- return reader;
86
- }
87
- }