@concavejs/runtime-cf 0.0.1-alpha.4
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.
Potentially problematic release.
This version of @concavejs/runtime-cf might be problematic. Click here for more details.
- package/README.md +53 -0
- package/dist/index.js +34902 -0
- package/dist/internal.js +3773 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @concavejs/runtime-cf
|
|
2
|
+
|
|
3
|
+
Cloudflare Workers runtime for Concave with explicit composition.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {
|
|
9
|
+
defineConcaveRuntime,
|
|
10
|
+
resolveNamespaceBinding,
|
|
11
|
+
createScopedNamespace,
|
|
12
|
+
DODocStore,
|
|
13
|
+
R2BlobStore,
|
|
14
|
+
UdfExecInline,
|
|
15
|
+
UdfExecIsolated,
|
|
16
|
+
} from "@concavejs/runtime-cf";
|
|
17
|
+
|
|
18
|
+
const runtime = defineConcaveRuntime({
|
|
19
|
+
worker: {
|
|
20
|
+
bindings: {
|
|
21
|
+
getConcaveNamespace: (env, ctx) => {
|
|
22
|
+
const ns = resolveNamespaceBinding(env, ctx, "CONCAVE_DO", "ConcaveDO");
|
|
23
|
+
if (!ns) return undefined;
|
|
24
|
+
return env.CONCAVE_PROJECT_ID ? createScopedNamespace(ns, env.CONCAVE_PROJECT_ID) : ns;
|
|
25
|
+
},
|
|
26
|
+
getSyncNamespace: (env, ctx) => {
|
|
27
|
+
const ns = resolveNamespaceBinding(env, ctx, "SYNC_DO", "SyncDO");
|
|
28
|
+
if (!ns) return undefined;
|
|
29
|
+
return env.CONCAVE_PROJECT_ID ? createScopedNamespace(ns, env.CONCAVE_PROJECT_ID) : ns;
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
durableObject: {
|
|
34
|
+
docstore: ({ state }) => new DODocStore(state),
|
|
35
|
+
blobstore: ({ env }) => (env.STORAGE_BUCKET ? new R2BlobStore(env.STORAGE_BUCKET, env.R2_PUBLIC_URL) : undefined),
|
|
36
|
+
udfExecutor: ({ env, instance, docstore, blobstore }) => {
|
|
37
|
+
const disableIsolated = env.DISABLE_ISOLATED_EXECUTION === "true" || env.DISABLE_ISOLATED_EXECUTION === true;
|
|
38
|
+
if (env.UDF_WORKER && !disableIsolated) {
|
|
39
|
+
return new UdfExecIsolated({
|
|
40
|
+
stub: env.UDF_WORKER,
|
|
41
|
+
instance,
|
|
42
|
+
projectId: env.CONCAVE_PROJECT_ID ?? "default",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return new UdfExecInline(docstore, blobstore, env.R2_PUBLIC_URL);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const ConcaveDO = runtime.ConcaveDO;
|
|
51
|
+
export const SyncDO = runtime.SyncDO;
|
|
52
|
+
export default runtime.worker;
|
|
53
|
+
```
|