@astrale-os/adapter-cloudflare 0.5.0-beta.225 → 0.5.0-beta.227
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 +11 -0
- package/dist/build/bundler.d.ts +2 -0
- package/dist/build/bundler.js +8 -1
- package/dist/build/material.js +5 -5
- package/dist/build/worker/codegen/service.d.ts +1 -1
- package/dist/build/worker/codegen/service.js +4 -5
- package/dist/build/worker/execution.prepare.d.ts +2 -0
- package/dist/build/worker/execution.prepare.js +8 -6
- package/dist/namespace/deploy-release.js +1 -0
- package/dist/namespace/readiness.d.ts +2 -0
- package/dist/namespace/readiness.js +5 -1
- package/dist/worker/entry.d.ts +5 -5
- package/dist/wrangler/bundle.d.ts +10 -2
- package/dist/wrangler/bundle.js +11 -2
- package/dist/wrangler/process.d.ts +1 -1
- package/dist/wrangler/process.js +2 -2
- package/package.json +2 -2
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
|
|
@@ -237,6 +241,13 @@ import { writeFile } from 'node:fs/promises'
|
|
|
237
241
|
await writeFile('src/build-material.gen.ts', generateBuildMaterialModule(build))
|
|
238
242
|
```
|
|
239
243
|
|
|
244
|
+
Standard and custom generated Workers embed one Brotli-compressed Schema Bundle. The Release
|
|
245
|
+
identifies the canonical JSON by its existing size, digest and URL. Its canonical GET still returns
|
|
246
|
+
those exact bytes. When the compressed representation is smaller, the Release response also links
|
|
247
|
+
to an immutable `.br` artifact. Both routes support their own ETag and conditional GET.
|
|
248
|
+
The loader accepts historical v1 material. The synchronous `build.schema.bundle.bytes()` accessor
|
|
249
|
+
and the explicit `material(build)` export both produce canonical bytes.
|
|
250
|
+
|
|
240
251
|
The generated TypeScript module exports `loadBuildMaterial()`. Call it from the
|
|
241
252
|
`load` callback of `generatedCloudflareWorkerEntry` alongside the Domain's Runtime.
|
|
242
253
|
That callback loads deterministic local modules once per entrypoint. Concurrent execution and
|
package/dist/build/bundler.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { Bundle, BundleContext, Bundler } from '@astrale-os/sdk/deployment/adapter';
|
|
2
2
|
import type { frontend as frontendBuild } from '@astrale-os/sdk/deployment/build';
|
|
3
|
+
import type { ArtifactRef } from '@astrale-os/sdk/release';
|
|
3
4
|
import type { ReleaseModule } from './worker/execution.prepare.js';
|
|
4
5
|
/**
|
|
5
6
|
* Environment-free bytes of one generated Worker: its entry, the modules it loads (the execution
|
|
6
7
|
* Service, the deferred workflow engine and their WASM) and its frontend.
|
|
7
8
|
*/
|
|
8
9
|
export interface WorkerBytes {
|
|
10
|
+
readonly compactBundle?: ArtifactRef;
|
|
9
11
|
readonly entry: Uint8Array;
|
|
10
12
|
readonly modules: readonly ReleaseModule[];
|
|
11
13
|
readonly frontend: readonly frontendBuild.FrontendFile[];
|
package/dist/build/bundler.js
CHANGED
|
@@ -17,6 +17,7 @@ export const cloudflareWorkerBundler = Object.freeze({
|
|
|
17
17
|
const worker = await bundleWorker(context);
|
|
18
18
|
return Object.freeze({
|
|
19
19
|
entrypoint: RELEASE_ENTRY,
|
|
20
|
+
...(worker.compactBundle === undefined ? {} : { compactBundle: worker.compactBundle }),
|
|
20
21
|
files: Object.freeze([
|
|
21
22
|
{ path: RELEASE_ENTRY, content: worker.entry },
|
|
22
23
|
...worker.modules.map(({ path, content }) => ({ path, content })),
|
|
@@ -49,7 +50,12 @@ export async function bundleWorker(context) {
|
|
|
49
50
|
...(frontend.length === 0 ? {} : { frontendRevision: frontendRevision(frontend) }),
|
|
50
51
|
...(addressed.length === 0 ? {} : { frontendAddressed: addressed }),
|
|
51
52
|
});
|
|
52
|
-
return Object.freeze({
|
|
53
|
+
return Object.freeze({
|
|
54
|
+
entry: modules.entry,
|
|
55
|
+
modules: modules.modules,
|
|
56
|
+
frontend,
|
|
57
|
+
compactBundle: modules.compactBundle,
|
|
58
|
+
});
|
|
53
59
|
}
|
|
54
60
|
finally {
|
|
55
61
|
await rm(directory, { recursive: true, force: true });
|
|
@@ -90,6 +96,7 @@ export function bundledWorker(bundle, build) {
|
|
|
90
96
|
}
|
|
91
97
|
return Object.freeze({
|
|
92
98
|
entry,
|
|
99
|
+
...(bundle.compactBundle === undefined ? {} : { compactBundle: bundle.compactBundle }),
|
|
93
100
|
modules: Object.freeze(modules),
|
|
94
101
|
frontend: Object.freeze(frontend),
|
|
95
102
|
});
|
package/dist/build/material.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generatedCompactMaterial } from '@astrale-os/sdk/deployment/build/compact';
|
|
2
2
|
import { sharedLiteral, verifySharedLiteral } from './worker/codegen/literal.js';
|
|
3
3
|
/**
|
|
4
4
|
* Generate a TypeScript module exporting `loadBuildMaterial()` for a custom Worker entrypoint.
|
|
@@ -9,17 +9,17 @@ import { sharedLiteral, verifySharedLiteral } from './worker/codegen/literal.js'
|
|
|
9
9
|
* compression dependency is needed by the generated module at runtime.
|
|
10
10
|
*/
|
|
11
11
|
export function generateBuildMaterialModule(build) {
|
|
12
|
-
const generated =
|
|
12
|
+
const generated = generatedCompactMaterial(build);
|
|
13
13
|
const literal = sharedLiteral(generated);
|
|
14
14
|
verifySharedLiteral(literal, generated);
|
|
15
15
|
// An empty shared array otherwise has an implicit any[] type in strict TypeScript consumers.
|
|
16
16
|
const declarations = literal.declarations.map((line) => ` ${line.replace(/ = \[\]$/, ': readonly [] = []')}`);
|
|
17
17
|
return `// AUTO-GENERATED by @astrale-os/adapter-cloudflare — do not edit.
|
|
18
|
-
import type {
|
|
18
|
+
import type { GeneratedCompactBuildMaterial } from '@astrale-os/sdk/deployment/build'
|
|
19
19
|
|
|
20
|
-
export function loadBuildMaterial():
|
|
20
|
+
export function loadBuildMaterial(): GeneratedCompactBuildMaterial {
|
|
21
21
|
${declarations.join('\n')}
|
|
22
|
-
return ${literal.expression} as unknown as
|
|
22
|
+
return ${literal.expression} as unknown as GeneratedCompactBuildMaterial
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
25
|
}
|
|
@@ -11,4 +11,4 @@ export interface ExecutionCodegenOptions {
|
|
|
11
11
|
readonly durable?: boolean;
|
|
12
12
|
readonly restateSpecifier?: string;
|
|
13
13
|
}
|
|
14
|
-
export declare function generateExecutionService(options: ExecutionCodegenOptions): string;
|
|
14
|
+
export declare function generateExecutionService(options: ExecutionCodegenOptions, generated?: import("@astrale-os/sdk/deployment/build").GeneratedCompactBuildMaterial): string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generatedCompactMaterial } from '@astrale-os/sdk/deployment/build/compact';
|
|
2
2
|
import { sharedLiteral, verifySharedLiteral } from './literal.js';
|
|
3
|
-
export function generateExecutionService(options) {
|
|
3
|
+
export function generateExecutionService(options, generated = generatedCompactMaterial(options.build)) {
|
|
4
4
|
const workerSpecifier = options.workerSpecifier ?? '@astrale-os/adapter-cloudflare/worker';
|
|
5
|
-
const generated = generatedMaterial(options.build);
|
|
6
5
|
// JSON has no references, so a flat literal repeats every repeated subtree. A compiled Domain
|
|
7
6
|
// is dominated by pattern automata, of which a few expressions account for dozens of identical
|
|
8
7
|
// copies, so sharing them cuts what the isolate allocates and seals by an order of magnitude.
|
|
@@ -23,7 +22,7 @@ const RESTATE_SPECIFIER = ${JSON.stringify(options.restateSpecifier ?? './restat
|
|
|
23
22
|
// checkout characters into esbuild's minifier histogram, making identical Services differ.
|
|
24
23
|
return `// AUTO-GENERATED by @astrale-os/adapter-cloudflare — do not edit.
|
|
25
24
|
// Domain origin: ${options.origin}
|
|
26
|
-
import type { BuildMaterial,
|
|
25
|
+
import type { BuildMaterial, GeneratedCompactBuildMaterial } from '@astrale-os/sdk/deployment/build'
|
|
27
26
|
|
|
28
27
|
import { generatedCloudflareWorkerEntry, type CloudflareAdapterBindings } from ${JSON.stringify(workerSpecifier)}
|
|
29
28
|
import { decodeSigningIdentity, deploymentSettings, runtimeBindings } from ${JSON.stringify(workerSpecifier)}
|
|
@@ -38,7 +37,7 @@ export default generatedCloudflareWorkerEntry<WorkerEnv, RuntimeEnv>()({
|
|
|
38
37
|
${frontend}${options.frontendRevision === undefined ? '' : ` frontendRevision: ${JSON.stringify(options.frontendRevision)},\n`}${options.frontendAddressed === undefined ? '' : ` frontendAddressed: ${JSON.stringify(options.frontendAddressed)},\n`} load: async () => {
|
|
39
38
|
${materialDeclarations} return {
|
|
40
39
|
runtime: (await import(${JSON.stringify(options.runtimeSpecifier)})).default,
|
|
41
|
-
material: ${material.expression} as unknown as
|
|
40
|
+
material: ${material.expression} as unknown as GeneratedCompactBuildMaterial,
|
|
42
41
|
}
|
|
43
42
|
},
|
|
44
43
|
privateKey: (env) => decodeSigningIdentity(env.ASTRALE_SIGNING_IDENTITY),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BundleContext } from '@astrale-os/sdk/deployment/adapter';
|
|
2
|
+
import type { ArtifactRef } from '@astrale-os/sdk/release';
|
|
2
3
|
export declare const RELEASE_ENTRY = "bundle/index.mjs";
|
|
3
4
|
export declare const RELEASE_SERVICE = "bundle/service.mjs";
|
|
4
5
|
export declare const RELEASE_RESTATE = "bundle/restate.mjs";
|
|
@@ -16,5 +17,6 @@ export declare function prepareExecution(input: {
|
|
|
16
17
|
}): Promise<{
|
|
17
18
|
readonly entry: Uint8Array;
|
|
18
19
|
readonly modules: readonly ReleaseModule[];
|
|
20
|
+
readonly compactBundle: ArtifactRef;
|
|
19
21
|
}>;
|
|
20
22
|
export declare function declaresDurable(build: BundleContext['build']): boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generatedCompactMaterial } from '@astrale-os/sdk/deployment/build/compact';
|
|
2
2
|
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';
|
|
@@ -22,6 +22,7 @@ export async function prepareExecution(input) {
|
|
|
22
22
|
const runtimePath = resolve(input.context.projectDir, input.context.runtime.reference.path);
|
|
23
23
|
const runtimeSpecifier = moduleSpecifier(relative(input.directory, runtimePath));
|
|
24
24
|
const workerSpecifier = workerModuleSpecifier();
|
|
25
|
+
const generated = generatedCompactMaterial(input.context.build);
|
|
25
26
|
const serviceSource = generateExecutionService({
|
|
26
27
|
origin: input.context.build.schema.compiled.root.origin,
|
|
27
28
|
runtimeSpecifier,
|
|
@@ -34,7 +35,7 @@ export async function prepareExecution(input) {
|
|
|
34
35
|
...(input.frontendAddressed === undefined
|
|
35
36
|
? {}
|
|
36
37
|
: { frontendAddressed: input.frontendAddressed }),
|
|
37
|
-
});
|
|
38
|
+
}, generated);
|
|
38
39
|
const modules = [];
|
|
39
40
|
const bundle = async (name, path, source, admit) => {
|
|
40
41
|
const sourcePath = join(input.directory, `${name}.gen.ts`);
|
|
@@ -48,7 +49,7 @@ export async function prepareExecution(input) {
|
|
|
48
49
|
}));
|
|
49
50
|
const output = join(input.directory, `dist-${name}`);
|
|
50
51
|
await rm(output, { recursive: true, force: true });
|
|
51
|
-
const emitted = await
|
|
52
|
+
const emitted = await bundleGeneratedWorker({
|
|
52
53
|
projectDir: input.context.projectDir,
|
|
53
54
|
configPath,
|
|
54
55
|
outDir: output,
|
|
@@ -80,7 +81,7 @@ export async function prepareExecution(input) {
|
|
|
80
81
|
`export { ${DURABLE_ENGINE_EXPORTS.join(', ')} } from ${JSON.stringify(restateModuleSpecifier())}\nexport default {}\n`, admitDurableEngineBundle);
|
|
81
82
|
}
|
|
82
83
|
const sourcePath = join(input.directory, 'worker.gen.ts');
|
|
83
|
-
const frontend =
|
|
84
|
+
const frontend = input.context.build.frontend;
|
|
84
85
|
await writeFile(sourcePath, generateExecutionEntry('./service.mjs', {
|
|
85
86
|
frontSpecifier: frontModuleSpecifier(),
|
|
86
87
|
...(frontend === undefined ? {} : { frontend }),
|
|
@@ -98,7 +99,7 @@ export async function prepareExecution(input) {
|
|
|
98
99
|
}));
|
|
99
100
|
const output = join(input.directory, 'dist-prepare');
|
|
100
101
|
await rm(output, { recursive: true, force: true });
|
|
101
|
-
const emitted = await
|
|
102
|
+
const emitted = await bundleGeneratedWorker({
|
|
102
103
|
projectDir: input.context.projectDir,
|
|
103
104
|
configPath,
|
|
104
105
|
outDir: output,
|
|
@@ -112,6 +113,7 @@ export async function prepareExecution(input) {
|
|
|
112
113
|
return Object.freeze({
|
|
113
114
|
entry: new Uint8Array(await readFile(emitted.bundlePath)),
|
|
114
115
|
modules: Object.freeze(modules),
|
|
116
|
+
compactBundle: generated.material.schema.bundle.stored.ref,
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
119
|
function moduleSpecifier(input) {
|
|
@@ -143,6 +143,7 @@ class NamespaceDeployment {
|
|
|
143
143
|
try {
|
|
144
144
|
await waitForNamespaceReadiness({
|
|
145
145
|
release: this.context.release,
|
|
146
|
+
bundle: this.context.bundle,
|
|
146
147
|
version: deployed.version,
|
|
147
148
|
timeoutMs: deployed.activated ? ACTIVATION_READINESS_MS : ROTATION_READINESS_MS,
|
|
148
149
|
signal: this.context.signal,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Bundle } from '@astrale-os/sdk/deployment/adapter';
|
|
1
2
|
import type { Release } from '@astrale-os/sdk/deployment/release';
|
|
2
3
|
/**
|
|
3
4
|
* How long a deployment this deploy activated may take to serve: the dispatcher reads the label's
|
|
@@ -19,6 +20,7 @@ export declare const ROTATION_READINESS_MS = 30000;
|
|
|
19
20
|
export declare function waitForNamespaceReadiness(input: {
|
|
20
21
|
/** The sealed release the deployment must serve at its URL. */
|
|
21
22
|
readonly release: Release;
|
|
23
|
+
readonly bundle?: Bundle;
|
|
22
24
|
/** The provider version that must answer, in the UUID form the Worker reports. */
|
|
23
25
|
readonly version: string;
|
|
24
26
|
readonly timeoutMs: number;
|
|
@@ -24,7 +24,11 @@ export async function waitForNamespaceReadiness(input) {
|
|
|
24
24
|
fetcher: publicFetcher(input.fetch),
|
|
25
25
|
timeoutMs: input.timeoutMs,
|
|
26
26
|
signal: input.signal,
|
|
27
|
-
check: (fetch, signal) => verifyReadiness(input.release, {
|
|
27
|
+
check: (fetch, signal) => verifyReadiness(input.release, {
|
|
28
|
+
fetch,
|
|
29
|
+
signal,
|
|
30
|
+
...(input.bundle === undefined ? {} : { bundle: input.bundle }),
|
|
31
|
+
}).then(() => { }),
|
|
28
32
|
...(input.pause === undefined ? {} : { pause: input.pause }),
|
|
29
33
|
...(input.now === undefined ? {} : { now: input.now }),
|
|
30
34
|
});
|
package/dist/worker/entry.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { JsonWebKey } from '@astrale-os/sdk/auth';
|
|
2
|
-
import type { BuildMaterial, GeneratedBuildMaterial } from '@astrale-os/sdk/deployment/build/material';
|
|
2
|
+
import type { BuildMaterial, CompactBuildMaterial, GeneratedBuildMaterial, GeneratedCompactBuildMaterial } from '@astrale-os/sdk/deployment/build/material';
|
|
3
3
|
import type { DurableServingProvider, ExecutionContext } from '@astrale-os/sdk/execution';
|
|
4
4
|
import type { Runtime } from '@astrale-os/sdk/runtime';
|
|
5
5
|
import type { DurableWorkerOptions } from '../params.js';
|
|
6
6
|
import type { CloudflareAdapterBindings, CloudflareFrontDoorConfig, Fetcher } from './front.js';
|
|
7
7
|
import type { CloudflareWorkerSettings } from './settings.js';
|
|
8
8
|
export type { CloudflareAdapterBindings, Fetcher } from './front.js';
|
|
9
|
-
export interface CloudflareWorkerConfig<RuntimeValue extends Runtime, Bindings extends CloudflareAdapterBindings, Environment, Material = BuildMaterial> extends CloudflareFrontDoorConfig, CloudflareWorkerSettings<Bindings> {
|
|
9
|
+
export interface CloudflareWorkerConfig<RuntimeValue extends Runtime, Bindings extends CloudflareAdapterBindings, Environment, Material = BuildMaterial | CompactBuildMaterial> extends CloudflareFrontDoorConfig, CloudflareWorkerSettings<Bindings> {
|
|
10
10
|
/**
|
|
11
11
|
* Load the exact local Runtime and Build once per entrypoint, after the isolate has accepted a
|
|
12
12
|
* request or execution is prepared. Concurrent callers share the result, including a rejection;
|
|
@@ -32,7 +32,7 @@ export interface CloudflareWorkerConfig<RuntimeValue extends Runtime, Bindings e
|
|
|
32
32
|
/** Resolve the engine for this durable request with the deployment's captured options. */
|
|
33
33
|
readonly durable?: (bindings: Bindings, request: Request, options?: DurableWorkerOptions) => ReturnType<DurableServingProvider>;
|
|
34
34
|
}
|
|
35
|
-
export interface CloudflareWorkerSource<RuntimeValue extends Runtime, Material = BuildMaterial> {
|
|
35
|
+
export interface CloudflareWorkerSource<RuntimeValue extends Runtime, Material = BuildMaterial | CompactBuildMaterial> {
|
|
36
36
|
readonly runtime: RuntimeValue;
|
|
37
37
|
readonly material: Material;
|
|
38
38
|
}
|
|
@@ -42,6 +42,6 @@ export interface CloudflareWorker<Bindings> {
|
|
|
42
42
|
prepare?(): Promise<void>;
|
|
43
43
|
}
|
|
44
44
|
/** Compose one installed Domain implementation at its immutable deployment URL. */
|
|
45
|
-
export declare function cloudflareWorkerEntry<Bindings extends CloudflareAdapterBindings, Environment = Bindings>(): <RuntimeValue extends Runtime>(config: CloudflareWorkerConfig<RuntimeValue, Bindings, Environment, BuildMaterial>) => CloudflareWorker<Bindings>;
|
|
45
|
+
export declare function cloudflareWorkerEntry<Bindings extends CloudflareAdapterBindings, Environment = Bindings>(): <RuntimeValue extends Runtime>(config: CloudflareWorkerConfig<RuntimeValue, Bindings, Environment, BuildMaterial | CompactBuildMaterial>) => CloudflareWorker<Bindings>;
|
|
46
46
|
/** Compose generated execution code whose exact Build material carries build-owner evidence. */
|
|
47
|
-
export declare function generatedCloudflareWorkerEntry<Bindings extends CloudflareAdapterBindings, Environment = Bindings>(): <RuntimeValue extends Runtime>(config: CloudflareWorkerConfig<RuntimeValue, Bindings, Environment, GeneratedBuildMaterial>) => CloudflareWorker<Bindings>;
|
|
47
|
+
export declare function generatedCloudflareWorkerEntry<Bindings extends CloudflareAdapterBindings, Environment = Bindings>(): <RuntimeValue extends Runtime>(config: CloudflareWorkerConfig<RuntimeValue, Bindings, Environment, GeneratedBuildMaterial | GeneratedCompactBuildMaterial>) => CloudflareWorker<Bindings>;
|
|
@@ -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.227",
|
|
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.72",
|
|
65
65
|
"@noble/hashes": "2.3.0",
|
|
66
66
|
"@restatedev/restate-sdk-cloudflare-workers": "1.17.0",
|
|
67
67
|
"hono": "^4.13.11",
|