oxidejs 0.1.6 → 0.1.7
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 +4 -4
- package/dist/index.mjs +1 -1
- package/dist/rsbuild.mjs +1 -1
- package/dist/{src-CU7sBRGf.mjs → src-BWalutn_.mjs} +7 -2
- package/dist/vite.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ vite build
|
|
|
34
34
|
node dist/server.js
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
Default preset is `"fetch"`. No `index.html` → only `dist/server.js`. With `index.html` → client to `dist/client/`, then `/_action` (if you have `*.server.ts`) → `src/server.ts` (`undefined` continues) → static file → `index.html` for navigations. `public/` is copied next to the client. Hashed assets get `Cache-Control: immutable`. No `wrangler.jsonc`.
|
|
37
|
+
Default preset is `"fetch"`. No `index.html` → only `dist/server.js`. With `index.html` → client to `dist/client/`, then `/_action` (if you have a `*.server.{ts,tsx,js,jsx}` file) → `src/server.ts` (`undefined` continues) → static file → `index.html` for navigations. `public/` is copied next to the client. Hashed assets get `Cache-Control: immutable`. No `wrangler.jsonc`.
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
40
|
oxide({
|
|
@@ -47,7 +47,7 @@ oxide({
|
|
|
47
47
|
|
|
48
48
|
## Server actions
|
|
49
49
|
|
|
50
|
-
Install `tacho` if you use actions. Files named `*.server.ts
|
|
50
|
+
Install `tacho` if you use actions. Files named `*.server.ts`, `*.server.tsx`, `*.server.js`, or `*.server.jsx` are server-only. A client import is replaced with a tacho stub that POSTs `/_action`. The original module never enters the client graph. Server and Vite SSR (`import.meta.env.SSR === true`) keep the real functions. Methods are `<file>.<fn>` (`test.ping`). Call `useRequest()` inside an action for the inbound `Request`. `useCtx()` is tacho `ctx` (`{ req }` plus anything middleware or `createContext` added). On `preset: "celld"`, `useEnv()` and `useFetchCtx()` are the Worker `env` and `ctx` from `fetch(request, env, ctx)` — same values as `useCtx().env` / `useCtx().fetchCtx`. Return `undefined` from `src/server.ts` to fall through to static files. No server action files → the bundle does not import tacho.
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
53
|
// src/test.server.ts
|
|
@@ -152,9 +152,9 @@ The generated server serves static files from `dist/client/` (or the `public/` d
|
|
|
152
152
|
|
|
153
153
|
The generated `__asset` function uses `path.join` — not `path.resolve` — so a leading `/` in the relative path stays inside the asset root.
|
|
154
154
|
|
|
155
|
-
### Server actions (`*.server.ts`)
|
|
155
|
+
### Server actions (`*.server.{ts,tsx,js,jsx}`)
|
|
156
156
|
|
|
157
|
-
-
|
|
157
|
+
- Server action code is **never bundled into the client**. Client imports are replaced with tacho stubs that POST `/_action`. The original source stays server-only.
|
|
158
158
|
- `/_action` is POST-only. Non-POST requests return `405`.
|
|
159
159
|
- Method dispatch uses `Object.hasOwn`, blocking `__proto__` / `constructor` walks.
|
|
160
160
|
- Unknown or missing content-types → `415`.
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as useEnv, i as useCtx, n as unpluginFactory, o as useFetchCtx, r as vite, s as useRequest, t as oxidejs } from "./src-
|
|
1
|
+
import { a as useEnv, i as useCtx, n as unpluginFactory, o as useFetchCtx, r as vite, s as useRequest, t as oxidejs } from "./src-BWalutn_.mjs";
|
|
2
2
|
export { oxidejs as default, oxidejs, unpluginFactory, useCtx, useEnv, useFetchCtx, useRequest, vite };
|
package/dist/rsbuild.mjs
CHANGED
|
@@ -20,10 +20,15 @@ const IGNORE_DIRS = /* @__PURE__ */ new Set([
|
|
|
20
20
|
const EXPORT_RE = /^\s*export\s+(?:async\s+)?function\s*\*?\s+([A-Za-z_$][\w$]*)|^\s*export\s+const\s+([A-Za-z_$][\w$]*)\s*=/gm;
|
|
21
21
|
function isServerFileId(id) {
|
|
22
22
|
const file = id.split("?")[0]?.replace(/\\/g, "/") ?? "";
|
|
23
|
-
return
|
|
23
|
+
return [
|
|
24
|
+
".ts",
|
|
25
|
+
".tsx",
|
|
26
|
+
".js",
|
|
27
|
+
".jsx"
|
|
28
|
+
].some((ext) => file.endsWith(`.server${ext}`));
|
|
24
29
|
}
|
|
25
30
|
function moduleKey(absFile) {
|
|
26
|
-
return path.basename(absFile).replace(/\.server\.(
|
|
31
|
+
return path.basename(absFile).replace(/\.server\.(?:[jt]sx?)$/i, "");
|
|
27
32
|
}
|
|
28
33
|
function parseExportedNames(source) {
|
|
29
34
|
const names = /* @__PURE__ */ new Set();
|
package/dist/vite.mjs
CHANGED