zero-com 1.13.0 → 1.13.1

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.
Files changed (2) hide show
  1. package/README.md +33 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -212,6 +212,37 @@ When `getFullName` is called from the client:
212
212
  4. `getFirstName` executes directly (no transport) with the same context
213
213
  5. Both functions can access `context()` with the same data
214
214
 
215
+ ## File boundary rule
216
+
217
+ Any file that contains `func()` exports is treated as a **server-only module**. On the client build the plugin replaces the **entire file** with lightweight RPC stubs — only the `func()` exports survive, everything else in that file is discarded.
218
+
219
+ This means you must not mix `func()` declarations with client-side code (state, UI utilities, etc.) in the same file. The pattern is the same as Next.js `"use server"` files: one side of the boundary per file.
220
+
221
+ **Wrong** — `connect` will be `undefined` on the client because the whole file is replaced:
222
+
223
+ ```ts
224
+ // store.ts ❌
225
+ import { func } from 'zero-com'
226
+ import { createStore } from './create-store'
227
+
228
+ export const { connect, useStore } = createStore(...) // lost on client
229
+
230
+ export const getPhones = func(async () => { ... })
231
+ ```
232
+
233
+ **Right** — separate the RPC calls from client state:
234
+
235
+ ```ts
236
+ // funcs.ts ✅ (replaced with stubs on client)
237
+ import { func } from 'zero-com'
238
+ export const getPhones = func(async () => { ... })
239
+
240
+ // store.ts ✅ (untouched on client)
241
+ import { createStore } from './create-store'
242
+ export const { connect, useStore } = createStore(...)
243
+ export * from './funcs'
244
+ ```
245
+
215
246
  ## Plugin options
216
247
 
217
248
  | Option | Type | Description |
@@ -301,7 +332,8 @@ export const getPhones = func(async (name: string) => {
301
332
  // server.ts
302
333
  import express from 'express';
303
334
  import { handle } from 'zero-com';
304
- import './src/server/api/phones.js'; // Make sure to import the server-side modules
335
+ // No manual imports needed the plugin automatically registers all func() files
336
+ // when it transforms any file that calls handle()
305
337
 
306
338
  const app = express();
307
339
  app.use(express.json());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zero-com",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/yosbelms/zero-com",
6
6
  "keywords": [