@ruvyxa/adapter-cloudflare 1.0.16 → 1.0.18

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
@@ -1,6 +1,6 @@
1
1
  # @ruvyxa/adapter-cloudflare
2
2
 
3
- Cloudflare Pages static deployment adapter for Ruvyxa production builds.
3
+ Cloudflare Workers deployment adapter for Ruvyxa production builds.
4
4
 
5
5
  ## Install
6
6
 
@@ -34,8 +34,10 @@ export default config({
34
34
  }
35
35
  ```
36
36
 
37
- `ruvyxa build` creates `.ruvyxa/deploy/cloudflare/` with `assets/` and `wrangler.jsonc`. Deploy that
38
- directory with Wrangler/Cloudflare Pages.
37
+ `ruvyxa build` creates `.ruvyxa/deploy/cloudflare/` with a Workers handler, `assets/`, and
38
+ `wrangler.jsonc`. Deploy that directory with Wrangler/Cloudflare Workers.
39
39
 
40
- This adapter safely supports static SSG/CSR output only. It rejects API, SSR, ISR, and PPR routes
41
- with `RUV2202`; a Workers request handler is not generated by the current Rust server.
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 static deployment 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
- * Create a Cloudflare Pages static deployment adapter for Ruvyxa.
23
+ * Create a Cloudflare Workers deployment adapter for Ruvyxa.
11
24
  *
12
- * Produces static assets ready for deployment via `wrangler` and generates a
13
- * `wrangler.jsonc` config reference. Dynamic routes are rejected at build time.
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({ workerEntry: "./src/worker.ts" })
36
+ * adapter: cloudflareAdapter()
22
37
  * })
23
38
  * ```
24
39
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA+B,MAAM,cAAc,CAAA;AAGxE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAmCjF;eAEc,iBAAiB"}
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
2
  /**
3
- * Create a Cloudflare Pages static deployment adapter for Ruvyxa.
3
+ * Worker fetch handler source code.
4
4
  *
5
- * Produces static assets ready for deployment via `wrangler` and generates a
6
- * `wrangler.jsonc` config reference. Dynamic routes are rejected at build time.
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
+ }
36
+ /**
37
+ * Create a Cloudflare Workers deployment adapter for Ruvyxa.
38
+ *
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({ workerEntry: "./src/worker.ts" })
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',
@@ -36,12 +86,38 @@ export function cloudflareAdapter(options = {}) {
36
86
  ...clientBuildOutput(ctx),
37
87
  configFiles: ['wrangler.jsonc'],
38
88
  artifacts: [
89
+ // Static assets served by Cloudflare's asset binding
39
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
40
98
  {
41
99
  kind: 'file',
42
100
  path: 'deploy/cloudflare/wrangler.jsonc',
43
- contents: '{\n "name": "ruvyxa-app",\n "assets": { "directory": "./assets" }\n}\n',
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',
44
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
+ ]),
45
121
  ],
46
122
  };
47
123
  },
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;AAUtE;;;;;;;;;;;;;;;GAeG;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,EAAE,YAAY;QAClB,MAAM,EAAE,MAAM;QACd,KAAK,CAAC,GAAiB;YACrB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAA;YAC9C,OAAO;gBACL,IAAI,EAAE,YAAY;gBAClB,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B;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.16",
3
+ "version": "1.0.18",
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.16"
41
+ "@ruvyxa/core": "^1.0.18"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsc -p tsconfig.json",