@ruvyxa/adapter-cloudflare 1.0.15 → 1.0.17
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 +10 -4
- package/dist/index.d.ts +19 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ruvyxa/adapter-cloudflare
|
|
2
2
|
|
|
3
|
-
Cloudflare
|
|
3
|
+
Cloudflare Workers deployment adapter for Ruvyxa production builds.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ export default config({
|
|
|
19
19
|
})
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Deployment Artifact
|
|
23
23
|
|
|
24
24
|
```json
|
|
25
25
|
{
|
|
@@ -30,8 +30,14 @@ export default config({
|
|
|
30
30
|
"assetsDir": ".ruvyxa/assets",
|
|
31
31
|
"clientDir": ".ruvyxa/client",
|
|
32
32
|
"chunkManifest": ".ruvyxa/client/chunk-manifest.json",
|
|
33
|
-
"configFiles": ["wrangler.
|
|
33
|
+
"configFiles": ["wrangler.jsonc"]
|
|
34
34
|
}
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
`ruvyxa build` creates `.ruvyxa/deploy/cloudflare/` with a Workers handler, `assets/`, and
|
|
38
|
+
`wrangler.jsonc`. Deploy that directory with Wrangler/Cloudflare Workers.
|
|
39
|
+
|
|
40
|
+
This adapter supports SSR, API, SSG, and CSR routes via the Edge runtime (`--target edge`). ISR and
|
|
41
|
+
PPR are rejected because the assets binding is read-only and the adapter does not configure a
|
|
42
|
+
persistent KV or Durable Object cache. Static assets are served through the assets binding; dynamic
|
|
43
|
+
routes use compiled edge modules loaded from a static registry in the Worker bundle.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import type { Adapter } from '@ruvyxa/core';
|
|
2
2
|
/**
|
|
3
|
-
* Options for the Cloudflare Workers adapter.
|
|
3
|
+
* Options for the Cloudflare Workers deployment adapter.
|
|
4
4
|
*/
|
|
5
5
|
export interface CloudflareAdapterOptions {
|
|
6
6
|
/** Custom worker entry point path. Defaults to `${outDir}/server/app`. */
|
|
7
7
|
workerEntry?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Also emit a `wrangler.jsonc` at the project root pointing at the
|
|
10
|
+
* generated Worker script and static assets, so `wrangler deploy` works
|
|
11
|
+
* right after `ruvyxa build` with no dashboard configuration. An existing
|
|
12
|
+
* project `wrangler.jsonc` is never overwritten.
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
projectConfig?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Cloudflare Workers compatibility date. This determines which runtime
|
|
18
|
+
* APIs are available. Defaults to the current date at build time.
|
|
19
|
+
*/
|
|
20
|
+
compatibilityDate?: string;
|
|
8
21
|
}
|
|
9
22
|
/**
|
|
10
23
|
* Create a Cloudflare Workers deployment adapter for Ruvyxa.
|
|
11
24
|
*
|
|
12
|
-
* Produces
|
|
13
|
-
*
|
|
25
|
+
* Produces a Worker fetch handler and static assets for deployment via
|
|
26
|
+
* `wrangler`. Supports SSR, API routes, SSG, and CSR. ISR and PPR are
|
|
27
|
+
* rejected with RUV2210 because they require persistent storage (KV/DO)
|
|
28
|
+
* which is not yet integrated.
|
|
14
29
|
*
|
|
15
30
|
* @example
|
|
16
31
|
* ```ts
|
|
@@ -18,7 +33,7 @@ export interface CloudflareAdapterOptions {
|
|
|
18
33
|
* import { cloudflareAdapter } from "@ruvyxa/adapter-cloudflare"
|
|
19
34
|
*
|
|
20
35
|
* export default config({
|
|
21
|
-
* adapter: cloudflareAdapter(
|
|
36
|
+
* adapter: cloudflareAdapter()
|
|
22
37
|
* })
|
|
23
38
|
* ```
|
|
24
39
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAgD,MAAM,cAAc,CAAA;AAGzF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAqCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAuFjF;eAEc,iBAAiB"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,45 @@
|
|
|
1
1
|
import { clientBuildOutput, validateBuildContext } from '@ruvyxa/core';
|
|
2
|
+
/**
|
|
3
|
+
* Worker fetch handler source code.
|
|
4
|
+
*
|
|
5
|
+
* This is the platform-specific entry that wraps the generic Ruvyxa serverless
|
|
6
|
+
* handler into a Cloudflare Workers `fetch` event handler. It reads the route
|
|
7
|
+
* manifest and delegates to the serverless handler for SSR/API/ISR/PPR.
|
|
8
|
+
*
|
|
9
|
+
* Static assets (client bundles, pre-rendered pages for SSG/CSR) are served
|
|
10
|
+
* by Cloudflare's `assets` binding; the Worker only handles dynamic routes.
|
|
11
|
+
*/
|
|
12
|
+
function workerHandlerSource() {
|
|
13
|
+
return `import { createHandler } from './serverless-handler.mjs';
|
|
14
|
+
import { loadRouteModule } from './route-modules.mjs';
|
|
15
|
+
import manifest from './manifest.json';
|
|
16
|
+
|
|
17
|
+
const handler = createHandler({
|
|
18
|
+
routes: manifest.routes,
|
|
19
|
+
importPage: loadRouteModule,
|
|
20
|
+
importApi: loadRouteModule,
|
|
21
|
+
readPrerendered: (pathname) => {
|
|
22
|
+
// In Workers, pre-rendered pages are served as static assets.
|
|
23
|
+
// ISR revalidation requires KV or Durable Objects (not yet supported).
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
26
|
+
supportedStrategies: ['ssr', 'ssg', 'csr', 'api'],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
async fetch(request, env, ctx) {
|
|
31
|
+
return handler(request);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
2
36
|
/**
|
|
3
37
|
* Create a Cloudflare Workers deployment adapter for Ruvyxa.
|
|
4
38
|
*
|
|
5
|
-
* Produces
|
|
6
|
-
*
|
|
39
|
+
* Produces a Worker fetch handler and static assets for deployment via
|
|
40
|
+
* `wrangler`. Supports SSR, API routes, SSG, and CSR. ISR and PPR are
|
|
41
|
+
* rejected with RUV2210 because they require persistent storage (KV/DO)
|
|
42
|
+
* which is not yet integrated.
|
|
7
43
|
*
|
|
8
44
|
* @example
|
|
9
45
|
* ```ts
|
|
@@ -11,7 +47,7 @@ import { clientBuildOutput, validateBuildContext } from '@ruvyxa/core';
|
|
|
11
47
|
* import { cloudflareAdapter } from "@ruvyxa/adapter-cloudflare"
|
|
12
48
|
*
|
|
13
49
|
* export default config({
|
|
14
|
-
* adapter: cloudflareAdapter(
|
|
50
|
+
* adapter: cloudflareAdapter()
|
|
15
51
|
* })
|
|
16
52
|
* ```
|
|
17
53
|
*/
|
|
@@ -25,8 +61,22 @@ export function cloudflareAdapter(options = {}) {
|
|
|
25
61
|
return {
|
|
26
62
|
name: 'cloudflare',
|
|
27
63
|
target: 'edge',
|
|
64
|
+
supports: ['ssr', 'ssg', 'csr', 'api'],
|
|
28
65
|
build(ctx) {
|
|
29
66
|
validateBuildContext(ctx, 'cloudflareAdapter');
|
|
67
|
+
const compatDate = options.compatibilityDate ?? new Date().toISOString().slice(0, 10);
|
|
68
|
+
const wranglerConfig = JSON.stringify({
|
|
69
|
+
name: 'ruvyxa-app',
|
|
70
|
+
main: './worker/index.mjs',
|
|
71
|
+
compatibility_date: compatDate,
|
|
72
|
+
assets: { directory: './assets' },
|
|
73
|
+
}, null, 2);
|
|
74
|
+
const projectWranglerConfig = JSON.stringify({
|
|
75
|
+
name: 'ruvyxa-app',
|
|
76
|
+
main: `${ctx.outDir}/deploy/cloudflare/worker/index.mjs`,
|
|
77
|
+
compatibility_date: compatDate,
|
|
78
|
+
assets: { directory: `${ctx.outDir}/deploy/cloudflare/assets` },
|
|
79
|
+
}, null, 2);
|
|
30
80
|
return {
|
|
31
81
|
name: 'cloudflare',
|
|
32
82
|
target: 'edge',
|
|
@@ -34,7 +84,41 @@ export function cloudflareAdapter(options = {}) {
|
|
|
34
84
|
entry: options.workerEntry ?? `${ctx.outDir}/server/app`,
|
|
35
85
|
assetsDir: `${ctx.outDir}/assets`,
|
|
36
86
|
...clientBuildOutput(ctx),
|
|
37
|
-
configFiles: ['wrangler.
|
|
87
|
+
configFiles: ['wrangler.jsonc'],
|
|
88
|
+
artifacts: [
|
|
89
|
+
// Static assets served by Cloudflare's asset binding
|
|
90
|
+
{ kind: 'static-site', path: 'deploy/cloudflare/assets' },
|
|
91
|
+
// Worker function bundle (SSR/API handler)
|
|
92
|
+
{
|
|
93
|
+
kind: 'function',
|
|
94
|
+
path: 'deploy/cloudflare/worker',
|
|
95
|
+
handlerSource: workerHandlerSource(),
|
|
96
|
+
},
|
|
97
|
+
// Wrangler config pointing at the Worker + assets
|
|
98
|
+
{
|
|
99
|
+
kind: 'file',
|
|
100
|
+
path: 'deploy/cloudflare/wrangler.jsonc',
|
|
101
|
+
contents: wranglerConfig + '\n',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
// Workers static assets read _headers from the asset directory;
|
|
105
|
+
// hashed client bundles are immutable.
|
|
106
|
+
kind: 'file',
|
|
107
|
+
path: 'deploy/cloudflare/assets/_headers',
|
|
108
|
+
contents: '/client/*\n Cache-Control: public, max-age=31536000, immutable\n',
|
|
109
|
+
},
|
|
110
|
+
...(options.projectConfig === false
|
|
111
|
+
? []
|
|
112
|
+
: [
|
|
113
|
+
{
|
|
114
|
+
kind: 'file',
|
|
115
|
+
path: 'wrangler.jsonc',
|
|
116
|
+
scope: 'project',
|
|
117
|
+
skipIfExists: true,
|
|
118
|
+
contents: projectWranglerConfig + '\n',
|
|
119
|
+
},
|
|
120
|
+
]),
|
|
121
|
+
],
|
|
38
122
|
};
|
|
39
123
|
},
|
|
40
124
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAuBtE;;;;;;;;;GASG;AACH,SAAS,mBAAmB;IAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;CAqBR,CAAA;AACD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAO,GAA6B,EAAE;IACtE,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QACjF,MAAM,IAAI,KAAK,CACb,oEAAoE,OAAO,OAAO,CAAC,WAAW,EAAE,CACjG,CAAA;IACH,CAAC;IAED,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC3E,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAA;IAC3F,CAAC;IAED,OAAO;QACL,IAAI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AI,EAAE,UAAU;wBAChB,IAAI,EAAE,0BAA0B;wBAChC,aAAa,EAAE,mBAAmB,EAAE;qBACrC;oBACD,kDAAkD;oBAClD;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,kCAAkC;wBACxC,QAAQ,EAAE,cAAc,GAAG,IAAI;qBAChC;oBACD;wBACE,gEAAgE;wBAChE,uCAAuC;wBACvC,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,mCAAmC;wBACzC,QAAQ,EAAE,mEAAmE;qBAC9E;oBACD,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,KAAK;wBACjC,CAAC,CAAC,EAAE;wBACJ,CAAC,CAAC;4BACE;gCACE,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,gBAAgB;gCACtB,KAAK,EAAE,SAAS;gCAChB,YAAY,EAAE,IAAI;gCAClB,QAAQ,EAAE,qBAAqB,GAAG,IAAI;6BACb;yBAC5B,CAAC;iBACP;aACF,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AAED,eAAe,iBAAiB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruvyxa/adapter-cloudflare",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Shape Ruvyxa builds for Cloudflare edge targets with typed worker and asset output metadata.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@ruvyxa/core": "^1.0.
|
|
41
|
+
"@ruvyxa/core": "^1.0.17"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc -p tsconfig.json",
|