@astrale-os/adapter-cloudflare 0.5.0-beta.224 → 0.5.0-beta.226
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
CHANGED
|
@@ -19,6 +19,10 @@ Generated Worker modules are minified by default, including separately loaded ru
|
|
|
19
19
|
The Environment's `wrangler` overlay cannot change minification: every Environment of one source
|
|
20
20
|
must emit the same JavaScript bytes. `cloudflare({ wrangler: { minify: false } })` is rejected.
|
|
21
21
|
|
|
22
|
+
The generated Worker enables `nodejs_compat` and uses workerd's native Brotli decoder for compact
|
|
23
|
+
Domain Bundles. Custom Worker configurations keep Wrangler's normal platform resolution and can
|
|
24
|
+
use the Kernel Protocol's portable decoder.
|
|
25
|
+
|
|
22
26
|
## Host it yourself
|
|
23
27
|
|
|
24
28
|
Anyone with a Cloudflare account, Workers for Platforms and a domain of their own can host
|
|
@@ -3,7 +3,7 @@ import { DURABLE_ENGINE_EXPORTS } from '@astrale-os/sdk/execution';
|
|
|
3
3
|
import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { dirname, join, relative, resolve } from 'node:path';
|
|
5
5
|
import { SIGNING_IDENTITY_BINDING } from '../../identity/binding.js';
|
|
6
|
-
import {
|
|
6
|
+
import { bundleGeneratedWorker } from '../../wrangler/bundle.js';
|
|
7
7
|
import { admitDurableEngineBundle, admitWorkerBundle } from '../bundle/admit.js';
|
|
8
8
|
import { generateExecutionEntry, generateExecutionService } from '../codegen/execution.js';
|
|
9
9
|
import { generateWranglerConfig } from '../codegen/wrangler.js';
|
|
@@ -48,7 +48,7 @@ export async function prepareExecution(input) {
|
|
|
48
48
|
}));
|
|
49
49
|
const output = join(input.directory, `dist-${name}`);
|
|
50
50
|
await rm(output, { recursive: true, force: true });
|
|
51
|
-
const emitted = await
|
|
51
|
+
const emitted = await bundleGeneratedWorker({
|
|
52
52
|
projectDir: input.context.projectDir,
|
|
53
53
|
configPath,
|
|
54
54
|
outDir: output,
|
|
@@ -98,7 +98,7 @@ export async function prepareExecution(input) {
|
|
|
98
98
|
}));
|
|
99
99
|
const output = join(input.directory, 'dist-prepare');
|
|
100
100
|
await rm(output, { recursive: true, force: true });
|
|
101
|
-
const emitted = await
|
|
101
|
+
const emitted = await bundleGeneratedWorker({
|
|
102
102
|
projectDir: input.context.projectDir,
|
|
103
103
|
configPath,
|
|
104
104
|
outDir: output,
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
interface BundleArguments {
|
|
2
2
|
projectDir: string;
|
|
3
3
|
configPath: string;
|
|
4
4
|
outDir: string;
|
|
5
5
|
onLog?: (line: string) => void;
|
|
6
6
|
signal?: AbortSignal;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
|
+
/** Bundle a user-supplied Worker configuration using Wrangler's own platform conditions. */
|
|
9
|
+
export declare function runWranglerBundle(args: BundleArguments): Promise<{
|
|
8
10
|
readonly bundlePath: string;
|
|
9
11
|
readonly metafilePath: string;
|
|
10
12
|
}>;
|
|
13
|
+
/** The adapter's generated config guarantees nodejs_compat on its qualified workerd version. */
|
|
14
|
+
export declare function bundleGeneratedWorker(args: BundleArguments): Promise<{
|
|
15
|
+
readonly bundlePath: string;
|
|
16
|
+
readonly metafilePath: string;
|
|
17
|
+
}>;
|
|
18
|
+
export {};
|
package/dist/wrangler/bundle.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { readdirSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { runCapture, wranglerCommand } from './process.js';
|
|
4
|
-
|
|
4
|
+
/** Bundle a user-supplied Worker configuration using Wrangler's own platform conditions. */
|
|
5
|
+
export function runWranglerBundle(args) {
|
|
6
|
+
return bundle(args);
|
|
7
|
+
}
|
|
8
|
+
/** The adapter's generated config guarantees nodejs_compat on its qualified workerd version. */
|
|
9
|
+
export function bundleGeneratedWorker(args) {
|
|
10
|
+
const conditions = process.env.WRANGLER_BUILD_CONDITIONS ?? 'workerd,worker,browser';
|
|
11
|
+
return bundle(args, { WRANGLER_BUILD_CONDITIONS: `${conditions},astrale-bundle-brotli-native` });
|
|
12
|
+
}
|
|
13
|
+
async function bundle(args, environment) {
|
|
5
14
|
const { cmd, prefix } = wranglerCommand(args.projectDir);
|
|
6
15
|
const { code, out } = await runCapture(cmd, [
|
|
7
16
|
...prefix,
|
|
@@ -12,7 +21,7 @@ export async function runWranglerBundle(args) {
|
|
|
12
21
|
'--metafile',
|
|
13
22
|
'--config',
|
|
14
23
|
args.configPath,
|
|
15
|
-
], args.projectDir, args.onLog, args.signal);
|
|
24
|
+
], args.projectDir, args.onLog, args.signal, undefined, environment);
|
|
16
25
|
if (code !== 0)
|
|
17
26
|
throw new Error(`wrangler bundle failed (exit ${code}): ${out.slice(-400)}`);
|
|
18
27
|
const javascript = readdirSync(args.outDir).filter((file) => file.endsWith('.js'));
|
|
@@ -7,7 +7,7 @@ export declare function wranglerCommand(projectDir: string, runtime?: {
|
|
|
7
7
|
};
|
|
8
8
|
/** Keep Wrangler CLI diagnostic logs inside the generated project state. */
|
|
9
9
|
export declare function wranglerProcessEnv(projectDir: string): NodeJS.ProcessEnv;
|
|
10
|
-
export declare function runCapture(cmd: string, args: string[], cwd: string, onLog?: (line: string) => void, signal?: AbortSignal, redact?: (input: string) => string): Promise<{
|
|
10
|
+
export declare function runCapture(cmd: string, args: string[], cwd: string, onLog?: (line: string) => void, signal?: AbortSignal, redact?: (input: string) => string, environment?: NodeJS.ProcessEnv): Promise<{
|
|
11
11
|
code: number;
|
|
12
12
|
out: string;
|
|
13
13
|
stdout: string;
|
package/dist/wrangler/process.js
CHANGED
|
@@ -29,14 +29,14 @@ export function wranglerProcessEnv(projectDir) {
|
|
|
29
29
|
WRANGLER_LOG_PATH: process.env.WRANGLER_LOG_PATH || resolve(projectDir, '.astrale', 'logs', 'wrangler'),
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export function runCapture(cmd, args, cwd, onLog, signal, redact = (input) => input) {
|
|
32
|
+
export function runCapture(cmd, args, cwd, onLog, signal, redact = (input) => input, environment) {
|
|
33
33
|
if (signal?.aborted)
|
|
34
34
|
return Promise.reject(new Error('Wrangler process cancelled.'));
|
|
35
35
|
return new Promise((resolve, reject) => {
|
|
36
36
|
const child = spawn(cmd, args, {
|
|
37
37
|
cwd,
|
|
38
38
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
39
|
-
env: wranglerProcessEnv(cwd),
|
|
39
|
+
env: { ...wranglerProcessEnv(cwd), ...environment },
|
|
40
40
|
});
|
|
41
41
|
let out = '';
|
|
42
42
|
let stdout = '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/adapter-cloudflare",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.226",
|
|
4
4
|
"description": "Deploy an Astrale Domain through Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"registry": "https://registry.npmjs.org/"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@astrale-os/sdk": "0.6.0-beta.
|
|
64
|
+
"@astrale-os/sdk": "0.6.0-beta.71",
|
|
65
65
|
"@noble/hashes": "2.3.0",
|
|
66
66
|
"@restatedev/restate-sdk-cloudflare-workers": "1.17.0",
|
|
67
67
|
"hono": "^4.13.11",
|