@astrale-os/adapter-cloudflare 0.5.0-beta.153 → 0.5.0-beta.155

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
@@ -53,3 +53,23 @@ This subpath is runtime-safe. `stagedWorkerName(providerDeployment)` addresses o
53
53
  candidate. The public Worker name and `/invoke` endpoint remain stable across compatible
54
54
  implementation and Schema updates. Provider staging identity never enters Release, Publication,
55
55
  Kernel routing, or graph identity.
56
+
57
+ ## Material for a custom Worker entrypoint
58
+
59
+ Workers with provider-specific routes or environment initialization can reuse the adapter's
60
+ material emission without adopting the entire generated entrypoint:
61
+
62
+ ```ts
63
+ import { generateBuildMaterialModule } from '@astrale-os/adapter-cloudflare/build'
64
+ import { writeFile } from 'node:fs/promises'
65
+
66
+ // build is an admitted Build returned by compile(application).
67
+ await writeFile('src/build-material.gen.ts', generateBuildMaterialModule(build))
68
+ ```
69
+
70
+ The generated TypeScript module exports `loadBuildMaterial()`. Call it from the
71
+ `load` callback of `generatedCloudflareWorkerEntry` alongside the application's Runtime.
72
+ It constructs the same verified, deduplicated material as the adapter's generated Service;
73
+ allocation is deferred until the factory is called and the SDK deep-freezes it before use.
74
+ The generated file needs only a type import from the SDK. Keep its compiler and runtime SDK
75
+ versions aligned, and regenerate it when either the Application or that SDK version changes.
@@ -1,3 +1,4 @@
1
+ export { generateBuildMaterialModule } from './material.js';
1
2
  export { artifact, materialize, prepareWorkerArtifact } from './artifact.js';
2
3
  export { loadWorkerArtifact } from './worker/index.js';
3
4
  export type { WorkerArtifact } from './worker/index.js';
@@ -1,3 +1,4 @@
1
+ export { generateBuildMaterialModule } from './material.js';
1
2
  export { artifact, materialize, prepareWorkerArtifact } from './artifact.js';
2
3
  export { loadWorkerArtifact } from './worker/index.js';
3
4
  export { resolveRouter, workerName } from './configuration.js';
@@ -0,0 +1,10 @@
1
+ import type { Build } from '@astrale-os/sdk/deployment/build';
2
+ /**
3
+ * Generate a TypeScript module exporting `loadBuildMaterial()` for a custom Worker entrypoint.
4
+ *
5
+ * The module uses the same verified shared literal as the adapter's generated Service. Its
6
+ * factory allocates the material on demand; `generatedCloudflareWorkerEntry` seals it before use.
7
+ * Write the source at build time and import its factory from the Worker. No authoring or
8
+ * compression dependency is needed by the generated module at runtime.
9
+ */
10
+ export declare function generateBuildMaterialModule(build: Build): string;
@@ -0,0 +1,25 @@
1
+ import { generatedMaterial } from '@astrale-os/sdk/deployment/build';
2
+ import { sharedLiteral, verifySharedLiteral } from './worker/codegen/literal.js';
3
+ /**
4
+ * Generate a TypeScript module exporting `loadBuildMaterial()` for a custom Worker entrypoint.
5
+ *
6
+ * The module uses the same verified shared literal as the adapter's generated Service. Its
7
+ * factory allocates the material on demand; `generatedCloudflareWorkerEntry` seals it before use.
8
+ * Write the source at build time and import its factory from the Worker. No authoring or
9
+ * compression dependency is needed by the generated module at runtime.
10
+ */
11
+ export function generateBuildMaterialModule(build) {
12
+ const generated = generatedMaterial(build);
13
+ const literal = sharedLiteral(generated);
14
+ verifySharedLiteral(literal, generated);
15
+ // An empty shared array otherwise has an implicit any[] type in strict TypeScript consumers.
16
+ const declarations = literal.declarations.map((line) => ` ${line.replace(/ = \[\]$/, ': readonly [] = []')}`);
17
+ return `// AUTO-GENERATED by @astrale-os/adapter-cloudflare — do not edit.
18
+ import type { GeneratedBuildMaterial } from '@astrale-os/sdk/deployment/build'
19
+
20
+ export function loadBuildMaterial(): GeneratedBuildMaterial {
21
+ ${declarations.join('\n')}
22
+ return ${literal.expression} as unknown as GeneratedBuildMaterial
23
+ }
24
+ `;
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/adapter-cloudflare",
3
- "version": "0.5.0-beta.153",
3
+ "version": "0.5.0-beta.155",
4
4
  "description": "Deploy an Astrale application through Cloudflare Workers",
5
5
  "keywords": [
6
6
  "adapter",
@@ -53,20 +53,20 @@
53
53
  "registry": "https://registry.npmjs.org/"
54
54
  },
55
55
  "dependencies": {
56
- "@astrale-os/sdk": "0.5.0-beta.150",
56
+ "@astrale-os/sdk": "0.6.0-beta.0",
57
57
  "@noble/hashes": "2.3.0",
58
58
  "hono": "^4.6.20",
59
59
  "jose": "^6.1.3",
60
60
  "wrangler": "4.123.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@astrale-os/ox": "0.1.3",
63
+ "@astrale-os/ox": "0.1.4",
64
64
  "@cloudflare/workers-types": "^5.20260820.1",
65
65
  "@types/node": "^22.0.0",
66
66
  "oxfmt": "0.63.0",
67
67
  "oxlint": "1.78.0",
68
68
  "typescript": "7.0.2",
69
- "vitest": "^4.1.10",
69
+ "vitest": "^5.0.1",
70
70
  "zod": "4.4.3"
71
71
  },
72
72
  "engines": {