@rsc-kit/core 0.2.0 → 0.4.0

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/dist/serve.js ADDED
@@ -0,0 +1,40 @@
1
+ // The renderer, for an app whose data lives in another process.
2
+ //
3
+ // createRscHandler already answers a Request with a Response. What every
4
+ // backed app then assembles by hand is the same four things: assets off disk,
5
+ // prerendered pages off disk, host calls over HTTP, and a build version. None
6
+ // of that is the app's decision, and a copy in every project is a copy that
7
+ // goes stale against the engine that produced it.
8
+ //
9
+ // The server itself stays in the app, because that genuinely differs — a port,
10
+ // a unix socket, TLS, whatever already supervises processes there.
11
+ //
12
+ // import { createBackedHandler } from '@rsc-kit/core/serve'
13
+ // import * as engine from './bootstrap/rsc/vite/dist/rsc/index.js'
14
+ //
15
+ // const handle = createBackedHandler({
16
+ // engine,
17
+ // assetsDir: 'public',
18
+ // hostCall: { endpoint: process.env.RSC_HOST_CALL_URL!, secret: process.env.RSC_HOST_CALL_SECRET! },
19
+ // })
20
+ //
21
+ // Bun.serve({ fetch: async (r) => (await handle(r)) ?? new Response('Not found', { status: 404 }) })
22
+ import { createRscHandler } from './host.js';
23
+ import { httpHostCalls } from './hostCalls.js';
24
+ import { assetsFrom, prerenderedFrom } from './files.js';
25
+ /**
26
+ * A handler for an app backed by another process.
27
+ */
28
+ export function createBackedHandler(options) {
29
+ return createRscHandler({
30
+ engine: options.engine,
31
+ version: options.version,
32
+ props: options.props,
33
+ assets: options.assetsDir
34
+ ? assetsFrom(options.assetsDir, options.assetsPrefix)
35
+ : undefined,
36
+ prerendered: options.prerenderedDir ? prerenderedFrom(options.prerenderedDir) : undefined,
37
+ hostCalls: httpHostCalls(options.hostCall),
38
+ });
39
+ }
40
+ //# sourceMappingURL=serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,EAAE;AACF,yEAAyE;AACzE,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,kDAAkD;AAClD,EAAE;AACF,+EAA+E;AAC/E,mEAAmE;AACnE,EAAE;AACF,gEAAgE;AAChE,uEAAuE;AACvE,EAAE;AACF,2CAA2C;AAC3C,gBAAgB;AAChB,6BAA6B;AAC7B,2GAA2G;AAC3G,SAAS;AACT,EAAE;AACF,yGAAyG;AAEzG,OAAO,EAAE,gBAAgB,EAAkB,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,aAAa,EAA6B,MAAM,gBAAgB,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAyDxD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAA6B;IAE7B,OAAO,gBAAgB,CAAC;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,SAAS;YACvB,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC;YACrD,CAAC,CAAC,SAAS;QACb,WAAW,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;QACzF,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC;KAC3C,CAAC,CAAA;AACJ,CAAC"}
package/dist/vite.d.ts CHANGED
@@ -10,6 +10,33 @@ export interface RscRoutesOptions {
10
10
  assetsDir?: string;
11
11
  /** Public URL the browser bundle is served from. Defaults to `/`. */
12
12
  assetsUrl?: string;
13
+ /**
14
+ * A file the dev server writes its own url into, and removes on shutdown.
15
+ *
16
+ * Laravel's convention, and the reason it is worth adopting: a dev server
17
+ * picks its port at runtime — 5173 is the most contended port on a developer's
18
+ * machine, and Vite silently moves to the next free one — so anything holding
19
+ * a fixed url is wrong the moment a second project is running. A backend that
20
+ * reads this file follows the server instead of guessing at it.
21
+ */
22
+ hotFile?: string;
23
+ /**
24
+ * Where `rpc()` goes while `vite dev` is serving.
25
+ *
26
+ * A built deployment installs this itself — the server that runs
27
+ * createRscHandler passes `hostCalls`. The dev server has no such server in
28
+ * front of it, so without this every rpc() during development is refused and
29
+ * any page whose data comes from the backend renders blank.
30
+ *
31
+ * Both halves default to the app's own .env, which for a Laravel app already
32
+ * has them: APP_URL for the backend and RSC_HOST_CALL_SECRET for the secret.
33
+ * That is the difference between "configure the dev server" and "it works".
34
+ */
35
+ hostCall?: {
36
+ endpoint?: string;
37
+ secret?: string;
38
+ path?: string;
39
+ };
13
40
  /**
14
41
  * This package's directory, holding the client runtime the browser entry
15
42
  * imports. Vite stages configs through node_modules/.vite-temp, so
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAU,YAAY,EAAkB,MAAM,MAAM,CAAA;AAGhE,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;;;OAQG;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