@softr/sdk 1.8.0-alpha.0 → 1.8.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.
- package/CHANGELOG.md +6 -0
- package/dist/datasource/record.js +4 -0
- package/dist/package.js +1 -1
- package/dist/pwa.js +12 -18
- package/package.json +1 -1
- package/skills/softr-sdk/SKILL.md +1 -1
- package/skills/softr-sdk/ai/SKILL.md +1 -1
- package/skills/softr-sdk/auth/SKILL.md +1 -1
- package/skills/softr-sdk/charts-and-metrics/SKILL.md +1 -1
- package/skills/softr-sdk/current-user/SKILL.md +1 -1
- package/skills/softr-sdk/email/SKILL.md +1 -1
- package/skills/softr-sdk/file-uploads/SKILL.md +1 -1
- package/skills/softr-sdk/formatting/SKILL.md +1 -1
- package/skills/softr-sdk/integrations/SKILL.md +1 -1
- package/skills/softr-sdk/mcp/SKILL.md +1 -1
- package/skills/softr-sdk/push-notifications/SKILL.md +1 -1
- package/skills/softr-sdk/pwa/SKILL.md +5 -4
- package/skills/softr-sdk/record-mutations/SKILL.md +1 -1
- package/skills/softr-sdk/record-queries/SKILL.md +1 -1
- package/skills/softr-sdk/region-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/routes-and-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/workflows/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -187,6 +187,10 @@ async function executeGet(query, id, filters) {
|
|
|
187
187
|
filterCriteria
|
|
188
188
|
})
|
|
189
189
|
});
|
|
190
|
+
if (res.status === 404) {
|
|
191
|
+
const body = await res.clone().json().catch(() => null);
|
|
192
|
+
if (typeof body === "object" && body !== null && "type" in body && body.type === "RECORD") return null;
|
|
193
|
+
}
|
|
190
194
|
if (!res.ok) throw new Error(`datasource get failed for action "${actionId}": ${await describeFailure(res)}`);
|
|
191
195
|
const contentLength = res.headers.get("Content-Length");
|
|
192
196
|
if (contentLength && parseInt(contentLength, 10) === 0) return null;
|
package/dist/package.js
CHANGED
package/dist/pwa.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fetch } from "./fetch.js";
|
|
|
4
4
|
import { sessionConfig } from "./auth/config.js";
|
|
5
5
|
import { readCached } from "./cache.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
import { Fragment, createElement, useEffect, useState, useSyncExternalStore } from "react";
|
|
7
|
+
import { Fragment, createElement, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
8
8
|
import { createMiddleware } from "@tanstack/react-start";
|
|
9
9
|
|
|
10
10
|
//#region src/pwa.ts
|
|
@@ -148,11 +148,9 @@ function setOfferedPrompt(next) {
|
|
|
148
148
|
offeredPrompt = next;
|
|
149
149
|
for (const listener of offerListeners) listener();
|
|
150
150
|
}
|
|
151
|
-
let installButtonCount = 0;
|
|
152
151
|
if (typeof window !== "undefined") {
|
|
153
152
|
window.addEventListener("beforeinstallprompt", (event) => {
|
|
154
153
|
if (!isInstallPromptEvent(event)) return;
|
|
155
|
-
if (installButtonCount > 0) event.preventDefault();
|
|
156
154
|
setOfferedPrompt(event);
|
|
157
155
|
});
|
|
158
156
|
window.addEventListener("appinstalled", () => setOfferedPrompt(null));
|
|
@@ -187,12 +185,6 @@ function usePwaInstall() {
|
|
|
187
185
|
offerListeners.add(listener);
|
|
188
186
|
return () => offerListeners.delete(listener);
|
|
189
187
|
}, () => offeredPrompt, () => null);
|
|
190
|
-
useEffect(() => {
|
|
191
|
-
installButtonCount++;
|
|
192
|
-
return () => {
|
|
193
|
-
installButtonCount--;
|
|
194
|
-
};
|
|
195
|
-
}, []);
|
|
196
188
|
useEffect(() => {
|
|
197
189
|
if (isStandalone()) return;
|
|
198
190
|
let cancelled = false;
|
|
@@ -221,15 +213,17 @@ function usePwaInstall() {
|
|
|
221
213
|
window.removeEventListener("appinstalled", hide);
|
|
222
214
|
};
|
|
223
215
|
}, []);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
216
|
+
return useMemo(() => {
|
|
217
|
+
if (!install.available || offered === null) return install;
|
|
218
|
+
return {
|
|
219
|
+
...install,
|
|
220
|
+
install: async () => {
|
|
221
|
+
await offered.prompt();
|
|
222
|
+
setOfferedPrompt(null);
|
|
223
|
+
return (await offered.userChoice).outcome;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}, [install, offered]);
|
|
233
227
|
}
|
|
234
228
|
function detectPlatform() {
|
|
235
229
|
const userAgent = navigator.userAgent;
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: sub-skill
|
|
15
15
|
library: softr-sdk
|
|
16
|
-
library_version: 1.8.
|
|
16
|
+
library_version: 1.8.1
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
**Boundary.** `ai` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineAiAction` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.8.
|
|
13
|
+
library_version: 1.8.1
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.8.
|
|
13
|
+
library_version: 1.8.1
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. A helper that calls `ds` outside a handler goes in `createServerOnlyFn` from `@tanstack/react-start` (the `record-queries` boundary). `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -12,7 +12,7 @@ description: >-
|
|
|
12
12
|
metadata:
|
|
13
13
|
type: sub-skill
|
|
14
14
|
library: softr-sdk
|
|
15
|
-
library_version: 1.8.
|
|
15
|
+
library_version: 1.8.1
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
**Boundary.** `email` and `EmailError` live on `@softr/sdk/server` and run only inside a `createServerFn` handler — importing them into a component fails the build. `defineEmailAction` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 1.8.
|
|
10
|
+
library_version: 1.8.1
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
**Boundary.** `upload` lives on `@softr/sdk/server` and runs inside server functions. `useFileUpload` and `FileItem` live on `@softr/sdk` and run in components. `FileAttachment` comes from `@softr/sdk` and can be imported anywhere.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 1.8.
|
|
10
|
+
library_version: 1.8.1
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
**Boundary.** `integration` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineIntegration` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.8.
|
|
12
|
+
library_version: 1.8.1
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `softrMcpMiddleware` lives on `@softr/sdk` and is registered once, in `src/start.ts`. The actions you hand it are the same `defineQuery` / `defineMutation` values the app's own pages use — declared wherever they already live, not duplicated for MCP.
|
|
@@ -4,12 +4,13 @@ description: >-
|
|
|
4
4
|
Let visitors install the app on their home screen: SoftrPwaHead for the
|
|
5
5
|
manifest, icon, iOS name and launch screen tags, usePwaInstall to decide
|
|
6
6
|
whether to show an install button, which platform's steps to show and, when
|
|
7
|
-
the browser offers it, install() for its own install dialog, the PwaInstall
|
|
8
|
-
|
|
7
|
+
the browser offers it, install() for its own install dialog, the PwaInstall
|
|
8
|
+
and PwaPlatform types, and how to check that the app is installable. The
|
|
9
|
+
manifest and icon are already served; never write them.
|
|
9
10
|
metadata:
|
|
10
11
|
type: sub-skill
|
|
11
12
|
library: softr-sdk
|
|
12
|
-
library_version: 1.8.
|
|
13
|
+
library_version: 1.8.1
|
|
13
14
|
---
|
|
14
15
|
|
|
15
16
|
# Installing the app
|
|
@@ -72,7 +73,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
|
|
|
72
73
|
|
|
73
74
|
It fetches after mount, so the first render, the server render included, always says `available: false`. It stays unavailable when the app is not installable, when the request fails, and when the app already runs installed from the home screen. Inside the Studio preview it says available, so the builder can see the button; installing itself only works on the published app.
|
|
74
75
|
|
|
75
|
-
`install` is there only while the browser offers its own install dialog: Chrome and Edge, on desktop and Android, and not in the Studio preview. Call it from a click. It rejects when the browser refuses the prompt, so open the steps then. It resolves with what the visitor chose, and the button disappears by itself once the app is installed.
|
|
76
|
+
`install` is there only while the browser offers its own install dialog: Chrome and Edge, on desktop and Android, and not in the Studio preview. Call it from a click. It rejects when the browser refuses the prompt, so open the steps then. It resolves with what the visitor chose, and the button disappears by itself once the app is installed. The browser shows its dialog only once per offer, so after the visitor closes it, `install` is gone until the browser offers again.
|
|
76
77
|
|
|
77
78
|
When `install` is missing, the button opens steps for `platform` instead: Share, then Add to Home Screen on iOS; the browser menu's Install app on Android and desktop. Safari and Firefox never offer the dialog. `name` and `iconUrl` tell the visitor what they are adding.
|
|
78
79
|
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.8.
|
|
13
|
+
library_version: 1.8.1
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineMutation` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -11,7 +11,7 @@ description: >-
|
|
|
11
11
|
metadata:
|
|
12
12
|
type: sub-skill
|
|
13
13
|
library: softr-sdk
|
|
14
|
-
library_version: 1.8.
|
|
14
|
+
library_version: 1.8.1
|
|
15
15
|
---
|
|
16
16
|
|
|
17
17
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. A route `loader` also runs in the browser, so it calls a server function, never `ds`. A helper that calls `ds` outside a handler, in this file or in another one, goes in `createServerOnlyFn` from `@tanstack/react-start`, or inside the handler. An exported helper without it keeps the server-only import in the browser bundle, and every page stops loading until it moves. Do not make such a helper a server function when it takes an id: any visitor can call a server function with any id. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.8.
|
|
12
|
+
library_version: 1.8.1
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `workflow` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineWorkflow` and every type come from `@softr/sdk` and can be imported anywhere.
|