@astrale-os/adapter-cloudflare 0.5.0-beta.152 → 0.5.0-beta.154
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 +20 -0
- package/dist/build/index.d.ts +1 -0
- package/dist/build/index.js +1 -0
- package/dist/build/material.d.ts +10 -0
- package/dist/build/material.js +25 -0
- package/package.json +2 -2
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.
|
package/dist/build/index.d.ts
CHANGED
package/dist/build/index.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.5.0-beta.154",
|
|
4
4
|
"description": "Deploy an Astrale application through Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"registry": "https://registry.npmjs.org/"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@astrale-os/sdk": "0.5.0-beta.
|
|
56
|
+
"@astrale-os/sdk": "0.5.0-beta.151",
|
|
57
57
|
"@noble/hashes": "2.3.0",
|
|
58
58
|
"hono": "^4.6.20",
|
|
59
59
|
"jose": "^6.1.3",
|