zitejs 0.10.0-start.16 → 0.10.0-start.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/dist/cjs/auth/index.js +6 -0
- package/dist/cjs/auth/previewClaim.d.ts +7 -0
- package/dist/cjs/auth/previewClaim.js +16 -0
- package/dist/cjs/check/start/sourceRules.js +1 -1
- package/dist/esm/auth/index.js +6 -0
- package/dist/esm/auth/previewClaim.d.ts +7 -0
- package/dist/esm/auth/previewClaim.js +12 -0
- package/dist/esm/check/start/sourceRules.js +1 -1
- package/dist/esm/start/describe.js +12 -13
- package/dist/esm/start/previewClaim.d.ts +3 -6
- package/dist/esm/start/previewClaim.js +5 -14
- package/dist/esm/start/server.js +14 -12
- package/dist/esm/start/version.d.ts +1 -1
- package/dist/esm/start/version.js +1 -1
- package/package.json +9 -9
package/dist/cjs/auth/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const react_1 = require("react");
|
|
|
9
9
|
const react_2 = require("better-auth/react");
|
|
10
10
|
const plugins_1 = require("better-auth/client/plugins");
|
|
11
11
|
const constants_js_1 = require("./constants.js");
|
|
12
|
+
const previewClaim_js_1 = require("./previewClaim.js");
|
|
12
13
|
const config_js_1 = require("./config.js");
|
|
13
14
|
const authClient = (0, react_2.createAuthClient)({
|
|
14
15
|
baseURL: '',
|
|
@@ -97,6 +98,11 @@ function loginWithRedirect(opts) {
|
|
|
97
98
|
window._ziteUsageToken;
|
|
98
99
|
if (usageToken)
|
|
99
100
|
params.set(constants_js_1.USAGE_TOKEN_QUERY_PARAM, usageToken);
|
|
101
|
+
// A Start app's preview also needs its claim where the editor's frame dropped
|
|
102
|
+
// the cookie, as `loginHref()` sends it. Classic previews never have one.
|
|
103
|
+
const claim = (0, previewClaim_js_1.browserPreviewClaim)();
|
|
104
|
+
if (claim)
|
|
105
|
+
params.set(previewClaim_js_1.PREVIEW_CLAIM_PARAM, claim);
|
|
100
106
|
const query = params.toString();
|
|
101
107
|
window.location.href = query ? `/auth/login?${query}` : '/auth/login';
|
|
102
108
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const PREVIEW_CLAIM_PARAM = "zite_preview";
|
|
2
|
+
/**
|
|
3
|
+
* An editor preview's access in the browser, which the host keeps on the URL because the editor's frame may drop its
|
|
4
|
+
* cookie (WebKit drops even Partitioned ones). Read once, before a Start app's router hides it, and shared by
|
|
5
|
+
* `zitejs/start` and `zitejs/auth` so sign-in keeps it either way. A classic app's URL never carries one.
|
|
6
|
+
*/
|
|
7
|
+
export declare const browserPreviewClaim: () => string | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.browserPreviewClaim = exports.PREVIEW_CLAIM_PARAM = void 0;
|
|
4
|
+
// The host's name for it (apps/zite-host/src/previewClaim.ts).
|
|
5
|
+
exports.PREVIEW_CLAIM_PARAM = 'zite_preview';
|
|
6
|
+
let captured;
|
|
7
|
+
/**
|
|
8
|
+
* An editor preview's access in the browser, which the host keeps on the URL because the editor's frame may drop its
|
|
9
|
+
* cookie (WebKit drops even Partitioned ones). Read once, before a Start app's router hides it, and shared by
|
|
10
|
+
* `zitejs/start` and `zitejs/auth` so sign-in keeps it either way. A classic app's URL never carries one.
|
|
11
|
+
*/
|
|
12
|
+
const browserPreviewClaim = () => {
|
|
13
|
+
captured ??= new URL(window.location.href).searchParams.get(exports.PREVIEW_CLAIM_PARAM);
|
|
14
|
+
return captured ?? undefined;
|
|
15
|
+
};
|
|
16
|
+
exports.browserPreviewClaim = browserPreviewClaim;
|
|
@@ -736,7 +736,7 @@ function sourceProblems(sources, { internal = false } = {}) {
|
|
|
736
736
|
}
|
|
737
737
|
}
|
|
738
738
|
if (node.type === "MemberExpression" && nameOf(node.property) === "inputValidator" && !node.computed) {
|
|
739
|
-
report("input-validator", "
|
|
739
|
+
report("input-validator", "error", path, node, "inputValidator was removed in TanStack Start 1.0; call .validator(…)");
|
|
740
740
|
}
|
|
741
741
|
if (node.type === "CallExpression" && nameOf(node.callee) === "createEndpoint") {
|
|
742
742
|
report("classic-construct", "error", path, node, "createEndpoint is classic's; in a Start app, server code is a signedInFn/publicFn server function");
|
package/dist/esm/auth/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { useEffect } from 'react';
|
|
|
2
2
|
import { createAuthClient } from 'better-auth/react';
|
|
3
3
|
import { magicLinkClient, inferAdditionalFields, } from 'better-auth/client/plugins';
|
|
4
4
|
import { USAGE_TOKEN_QUERY_PARAM } from './constants.js';
|
|
5
|
+
import { browserPreviewClaim, PREVIEW_CLAIM_PARAM } from './previewClaim.js';
|
|
5
6
|
import { getAccessMode } from './config.js';
|
|
6
7
|
const authClient = createAuthClient({
|
|
7
8
|
baseURL: '',
|
|
@@ -90,6 +91,11 @@ export function loginWithRedirect(opts) {
|
|
|
90
91
|
window._ziteUsageToken;
|
|
91
92
|
if (usageToken)
|
|
92
93
|
params.set(USAGE_TOKEN_QUERY_PARAM, usageToken);
|
|
94
|
+
// A Start app's preview also needs its claim where the editor's frame dropped
|
|
95
|
+
// the cookie, as `loginHref()` sends it. Classic previews never have one.
|
|
96
|
+
const claim = browserPreviewClaim();
|
|
97
|
+
if (claim)
|
|
98
|
+
params.set(PREVIEW_CLAIM_PARAM, claim);
|
|
93
99
|
const query = params.toString();
|
|
94
100
|
window.location.href = query ? `/auth/login?${query}` : '/auth/login';
|
|
95
101
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const PREVIEW_CLAIM_PARAM = "zite_preview";
|
|
2
|
+
/**
|
|
3
|
+
* An editor preview's access in the browser, which the host keeps on the URL because the editor's frame may drop its
|
|
4
|
+
* cookie (WebKit drops even Partitioned ones). Read once, before a Start app's router hides it, and shared by
|
|
5
|
+
* `zitejs/start` and `zitejs/auth` so sign-in keeps it either way. A classic app's URL never carries one.
|
|
6
|
+
*/
|
|
7
|
+
export declare const browserPreviewClaim: () => string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The host's name for it (apps/zite-host/src/previewClaim.ts).
|
|
2
|
+
export const PREVIEW_CLAIM_PARAM = 'zite_preview';
|
|
3
|
+
let captured;
|
|
4
|
+
/**
|
|
5
|
+
* An editor preview's access in the browser, which the host keeps on the URL because the editor's frame may drop its
|
|
6
|
+
* cookie (WebKit drops even Partitioned ones). Read once, before a Start app's router hides it, and shared by
|
|
7
|
+
* `zitejs/start` and `zitejs/auth` so sign-in keeps it either way. A classic app's URL never carries one.
|
|
8
|
+
*/
|
|
9
|
+
export const browserPreviewClaim = () => {
|
|
10
|
+
captured ??= new URL(window.location.href).searchParams.get(PREVIEW_CLAIM_PARAM);
|
|
11
|
+
return captured ?? undefined;
|
|
12
|
+
};
|
|
@@ -733,7 +733,7 @@ export function sourceProblems(sources, { internal = false } = {}) {
|
|
|
733
733
|
}
|
|
734
734
|
}
|
|
735
735
|
if (node.type === "MemberExpression" && nameOf(node.property) === "inputValidator" && !node.computed) {
|
|
736
|
-
report("input-validator", "
|
|
736
|
+
report("input-validator", "error", path, node, "inputValidator was removed in TanStack Start 1.0; call .validator(…)");
|
|
737
737
|
}
|
|
738
738
|
if (node.type === "CallExpression" && nameOf(node.callee) === "createEndpoint") {
|
|
739
739
|
report("classic-construct", "error", path, node, "createEndpoint is classic's; in a Start app, server code is a signedInFn/publicFn server function");
|
|
@@ -44,20 +44,19 @@ const SERVER_ONLY = "server-only: nothing in the browser calls it, and a server
|
|
|
44
44
|
"Move the shared logic into a *.server.ts helper and call that.";
|
|
45
45
|
export async function describeFunction(id, request) {
|
|
46
46
|
const problems = [];
|
|
47
|
-
|
|
47
|
+
let own;
|
|
48
48
|
probe = { reached: false };
|
|
49
|
-
//
|
|
50
|
-
// Recording
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return
|
|
49
|
+
// TanStack appends the function's own chain to the global middleware with
|
|
50
|
+
// `concat`. Recording what it appends gives the exact chain it would have run.
|
|
51
|
+
const functionMiddleware = Object.assign([describeProbe], {
|
|
52
|
+
concat: (chain) => {
|
|
53
|
+
own = chain;
|
|
54
|
+
return [describeProbe, ...chain];
|
|
55
55
|
},
|
|
56
|
-
};
|
|
56
|
+
});
|
|
57
57
|
const startContext = {
|
|
58
58
|
request,
|
|
59
|
-
startOptions: { functionMiddleware
|
|
60
|
-
executedRequestMiddlewares,
|
|
59
|
+
startOptions: { functionMiddleware },
|
|
61
60
|
contextAfterGlobalMiddlewares: {},
|
|
62
61
|
handlerType: "serverFn",
|
|
63
62
|
getRouter: () => {
|
|
@@ -79,11 +78,11 @@ export async function describeFunction(id, request) {
|
|
|
79
78
|
}
|
|
80
79
|
const state = probe;
|
|
81
80
|
probe = null;
|
|
82
|
-
// Fails closed: if TanStack stops
|
|
81
|
+
// Fails closed: if TanStack stops appending, or the probe never runs, every
|
|
83
82
|
// function reports a problem and the build stops.
|
|
84
|
-
if (!state.reached ||
|
|
83
|
+
if (!state.reached || own === undefined)
|
|
85
84
|
problems.push("probe-not-first: chain could not be read");
|
|
86
|
-
const chain =
|
|
85
|
+
const chain = flattenMiddlewares((own ?? [])).filter((m) => m !== describeProbe);
|
|
87
86
|
if (!chain.some((m) => ziteMiddlewareKind(m)?.kind === "factory")) {
|
|
88
87
|
problems.push("raw-server-fn: define it with signedInFn or publicFn from zitejs/start");
|
|
89
88
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { PREVIEW_CLAIM_PARAM } from "../auth/previewClaim.js";
|
|
2
|
+
export { PREVIEW_CLAIM_PARAM };
|
|
2
3
|
export declare const PREVIEW_CLAIM_HEADER = "x-zite-preview";
|
|
3
|
-
/**
|
|
4
|
-
* An editor preview's access, which the host keeps on the URL because the editor's frame may drop its cookie (WebKit
|
|
5
|
-
* drops even Partitioned ones). On the server the host hands it over; in the browser it's on the URL the host sent
|
|
6
|
-
* the page to, read once, before the router hides it.
|
|
7
|
-
*/
|
|
4
|
+
/** An editor preview's access: on the server the host hands it over, in the browser it's on the URL. */
|
|
8
5
|
export declare const previewClaim: () => string | undefined;
|
|
9
6
|
/** Every same-origin fetch from the page carries the claim: server functions and the app's own routes alike. */
|
|
10
7
|
export declare const carryPreviewClaim: (claim: string) => void;
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
+
import { browserPreviewClaim, PREVIEW_CLAIM_PARAM } from "../auth/previewClaim.js";
|
|
1
2
|
import { currentHost } from "./host.js";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
export { PREVIEW_CLAIM_PARAM };
|
|
4
|
+
// The host's name (apps/zite-host/src/previewClaim.ts).
|
|
4
5
|
export const PREVIEW_CLAIM_HEADER = "x-zite-preview";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* An editor preview's access, which the host keeps on the URL because the editor's frame may drop its cookie (WebKit
|
|
8
|
-
* drops even Partitioned ones). On the server the host hands it over; in the browser it's on the URL the host sent
|
|
9
|
-
* the page to, read once, before the router hides it.
|
|
10
|
-
*/
|
|
11
|
-
export const previewClaim = () => {
|
|
12
|
-
if (typeof window === "undefined")
|
|
13
|
-
return currentHost()?.previewClaim;
|
|
14
|
-
captured ??= new URL(window.location.href).searchParams.get(PREVIEW_CLAIM_PARAM);
|
|
15
|
-
return captured ?? undefined;
|
|
16
|
-
};
|
|
6
|
+
/** An editor preview's access: on the server the host hands it over, in the browser it's on the URL. */
|
|
7
|
+
export const previewClaim = () => typeof window === "undefined" ? currentHost()?.previewClaim : browserPreviewClaim();
|
|
17
8
|
let carrying = false;
|
|
18
9
|
/** Every same-origin fetch from the page carries the claim: server functions and the app's own routes alike. */
|
|
19
10
|
export const carryPreviewClaim = (claim) => {
|
package/dist/esm/start/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// For the generated server entry only. Apps never import this.
|
|
2
|
-
import {
|
|
2
|
+
import { createServerEntry } from "@tanstack/react-start/server";
|
|
3
3
|
import { createSsrRpc } from "@tanstack/react-start/ssr-rpc";
|
|
4
4
|
import { runWithStartContext } from "@tanstack/start-storage-context";
|
|
5
5
|
import { asZiteError, isZiteErrorCode, ZiteError, ZITE_ERROR_STATUS } from "./errors.js";
|
|
@@ -232,17 +232,19 @@ async function invokeFunction(request, options) {
|
|
|
232
232
|
handlerType: "serverFn",
|
|
233
233
|
};
|
|
234
234
|
// In TanStack's request event too, which the function's own status setting reads.
|
|
235
|
-
return
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
235
|
+
return createServerEntry({
|
|
236
|
+
fetch: async () => {
|
|
237
|
+
try {
|
|
238
|
+
const answer = (await runWithStartContext(startContext, () => createSsrRpc(id)({ data: input, context: {} })));
|
|
239
|
+
if ("error" in answer)
|
|
240
|
+
throw answer.error;
|
|
241
|
+
return Response.json({ ok: true, output: answer.result ?? null });
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
return Response.json({ ok: false, error: errorOf(error) }, { status: 500 });
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
}).fetch(request, undefined);
|
|
246
248
|
}
|
|
247
249
|
// The host sends `{ op, input }`: `subscribe` with the platform's notification
|
|
248
250
|
// URL and secret, or `unsubscribe` with what `subscribe` returned.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ZITEJS_VERSION = "0.10.0-start.
|
|
1
|
+
export declare const ZITEJS_VERSION = "0.10.0-start.18";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Written by scripts/write-version.mjs from package.json.
|
|
2
|
-
export const ZITEJS_VERSION = "0.10.0-start.
|
|
2
|
+
export const ZITEJS_VERSION = "0.10.0-start.18";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zitejs",
|
|
3
|
-
"version": "0.10.0-start.
|
|
3
|
+
"version": "0.10.0-start.18",
|
|
4
4
|
"description": "The Zite framework — build apps on Zite Database",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -181,10 +181,10 @@
|
|
|
181
181
|
"peerDependencies": {
|
|
182
182
|
"@cloudflare/vite-plugin": ">=1",
|
|
183
183
|
"@tanstack/react-query": ">=5.102.0",
|
|
184
|
-
"@tanstack/react-router": "1.170.
|
|
184
|
+
"@tanstack/react-router": "1.170.45",
|
|
185
185
|
"@tanstack/react-router-ssr-query": "1.167.3",
|
|
186
|
-
"@tanstack/react-start": "1.
|
|
187
|
-
"@tanstack/start-storage-context": "1.167.
|
|
186
|
+
"@tanstack/react-start": "1.169.3",
|
|
187
|
+
"@tanstack/start-storage-context": "1.167.40",
|
|
188
188
|
"@vitejs/plugin-react": ">=5",
|
|
189
189
|
"react": ">=18",
|
|
190
190
|
"vite": ">=5"
|
|
@@ -221,17 +221,17 @@
|
|
|
221
221
|
"devDependencies": {
|
|
222
222
|
"@tanstack/query-core": "5.104.0",
|
|
223
223
|
"@tanstack/react-query": "5.104.0",
|
|
224
|
-
"@tanstack/react-router": "1.170.
|
|
224
|
+
"@tanstack/react-router": "1.170.45",
|
|
225
225
|
"@tanstack/react-router-ssr-query": "1.167.3",
|
|
226
|
-
"@tanstack/react-start": "1.
|
|
227
|
-
"@tanstack/start-storage-context": "1.167.
|
|
226
|
+
"@tanstack/react-start": "1.169.3",
|
|
227
|
+
"@tanstack/start-storage-context": "1.167.40",
|
|
228
228
|
"@types/node": "^25.9.1",
|
|
229
229
|
"@types/react": "^19.0.0",
|
|
230
230
|
"@vitejs/plugin-react": "^5.2.0",
|
|
231
231
|
"react": "^19.0.0",
|
|
232
232
|
"typescript": "^5.4.0",
|
|
233
|
-
"vite": "^
|
|
234
|
-
"vitest": "^
|
|
233
|
+
"vite": "^8.3.4",
|
|
234
|
+
"vitest": "^4.1.12"
|
|
235
235
|
},
|
|
236
236
|
"keywords": [
|
|
237
237
|
"zite",
|