talizen 0.2.18 → 0.2.20
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 -9
- package/i18n.js +2 -1
- package/package.json +1 -1
- package/server-runtime.d.ts +0 -6
package/README.md
CHANGED
|
@@ -157,23 +157,24 @@ await invoke("booking", { email: "hi@talizen.com" });
|
|
|
157
157
|
|
|
158
158
|
### Server-side page context
|
|
159
159
|
|
|
160
|
-
In `getServerSideProps`, use the injected server context for request metadata
|
|
161
|
-
|
|
162
|
-
call Func from server-side page code:
|
|
160
|
+
In `getServerSideProps`, use the injected server context for request metadata
|
|
161
|
+
and cookies. Do not import `talizen/auth` or `talizen/func`, and do not read
|
|
162
|
+
auth state or call Func from server-side page code:
|
|
163
163
|
|
|
164
164
|
```ts
|
|
165
165
|
import type { TalizenServerSideContext } from "talizen/server-runtime";
|
|
166
166
|
|
|
167
167
|
export async function getServerSideProps(ctx: TalizenServerSideContext) {
|
|
168
|
-
|
|
169
|
-
return { props: { path: ctx.request.path, user } };
|
|
168
|
+
return { props: { path: ctx.request.path } };
|
|
170
169
|
}
|
|
171
170
|
```
|
|
172
171
|
|
|
173
|
-
Server-side context supports `ctx.request
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
Server-side context supports `ctx.request` and `ctx.cookies`. It intentionally
|
|
173
|
+
does not expose `ctx.auth`, `ctx.db`, `ctx.cache`, or `ctx.func`. This keeps
|
|
174
|
+
HTML render caching predictable: cookie reads can use cookie-vary, cookie
|
|
175
|
+
writes are no-store, and user-specific auth/Func reads do not become hidden SSR
|
|
176
|
+
cache dependencies. Put login UI, private business data access, writes, and
|
|
177
|
+
custom backend actions in browser-side SDK/Func/API flows.
|
|
177
178
|
|
|
178
179
|
### Write function runtime code
|
|
179
180
|
|
package/i18n.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { getTalizenConfig, subscribeTalizenConfig } from "./core.js";
|
|
3
|
+
const emptyMessages = {};
|
|
3
4
|
let lastSnapshot = null;
|
|
4
5
|
let lastSnapshotI18n;
|
|
5
6
|
let lastSnapshotMessages;
|
|
@@ -8,7 +9,7 @@ function readI18nRuntimeConfig() {
|
|
|
8
9
|
const fallbackI18n = typeof globalThis !== "undefined" ? globalThis.__TALIZEN_I18N__ : undefined;
|
|
9
10
|
const fallbackMessages = typeof globalThis !== "undefined" ? globalThis.__TALIZEN_MESSAGES__ : undefined;
|
|
10
11
|
const i18n = config.i18n ?? fallbackI18n;
|
|
11
|
-
const messages = config.messages ?? fallbackMessages ??
|
|
12
|
+
const messages = config.messages ?? fallbackMessages ?? emptyMessages;
|
|
12
13
|
if (lastSnapshot && lastSnapshotI18n === i18n && lastSnapshotMessages === messages) {
|
|
13
14
|
return lastSnapshot;
|
|
14
15
|
}
|
package/package.json
CHANGED
package/server-runtime.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AuthUser } from "./auth.js";
|
|
2
1
|
export interface ServerReadonlyStringMap {
|
|
3
2
|
get(name: string): string | null;
|
|
4
3
|
}
|
|
@@ -28,10 +27,6 @@ export interface TalizenServerCookieRuntime {
|
|
|
28
27
|
ok?: boolean;
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
|
-
export interface TalizenServerAuthRuntime {
|
|
32
|
-
currentUser(): AuthUser | null;
|
|
33
|
-
requireUser(): AuthUser;
|
|
34
|
-
}
|
|
35
30
|
export interface TalizenServerSideContext {
|
|
36
31
|
query: Record<string, string | string[]>;
|
|
37
32
|
searchParams: Record<string, string | string[]>;
|
|
@@ -42,5 +37,4 @@ export interface TalizenServerSideContext {
|
|
|
42
37
|
request: TalizenServerRequestRuntime;
|
|
43
38
|
req: TalizenServerRequestRuntime;
|
|
44
39
|
cookies: TalizenServerCookieRuntime;
|
|
45
|
-
auth: TalizenServerAuthRuntime;
|
|
46
40
|
}
|