@softr/sdk 1.2.0 → 1.2.1-alpha.0
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/package.js +1 -1
- package/dist/pwa.d.ts +3 -2
- package/dist/pwa.js +41 -5
- 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/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 +7 -7
- 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
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @softr/sdk
|
|
2
2
|
|
|
3
|
+
## 1.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `SoftrPwaHead` now gives iOS the app's home screen name and launch screens, so an installed app opens on its splash screen instead of white and Add to Home Screen suggests the app's name, not the page title. An app already on an iPhone home screen picks this up only after it is removed and added again.
|
|
8
|
+
|
|
3
9
|
## 1.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/package.js
CHANGED
package/dist/pwa.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import "@tanstack/react-start";
|
|
|
4
4
|
//#region src/pwa.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The
|
|
8
|
-
*
|
|
7
|
+
* The tags that make the app installable: its manifest, its home screen icon,
|
|
8
|
+
* and, while the app is installable, the name and launch screens iOS shows.
|
|
9
|
+
* Render it once, in `<head>` in the root route's `RootDocument`.
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
* function RootDocument({ children }: { children: React.ReactNode }) {
|
package/dist/pwa.js
CHANGED
|
@@ -18,8 +18,13 @@ const pwaSchema = z.object({
|
|
|
18
18
|
install: z.object({
|
|
19
19
|
name: z.string(),
|
|
20
20
|
iconUrl: z.string()
|
|
21
|
-
})
|
|
21
|
+
}),
|
|
22
|
+
startupImages: z.array(z.object({
|
|
23
|
+
media: z.string(),
|
|
24
|
+
href: z.string()
|
|
25
|
+
})).default([])
|
|
22
26
|
});
|
|
27
|
+
const iosHeadSchema = pwaSchema.pick({ startupImages: true }).extend({ name: z.string() });
|
|
23
28
|
let cached;
|
|
24
29
|
/** The app's PWA, or `null` when it is not installable right now. */
|
|
25
30
|
function readPwa() {
|
|
@@ -49,7 +54,10 @@ function pwaMiddleware() {
|
|
|
49
54
|
"content-type": "application/manifest+json",
|
|
50
55
|
"cache-control": CACHE_CONTROL
|
|
51
56
|
} });
|
|
52
|
-
if (pathname === INSTALL_PATH) return Response.json(
|
|
57
|
+
if (pathname === INSTALL_PATH) return Response.json({
|
|
58
|
+
...pwa.install,
|
|
59
|
+
startupImages: pwa.startupImages
|
|
60
|
+
}, { headers: { "cache-control": CACHE_CONTROL } });
|
|
53
61
|
try {
|
|
54
62
|
const iconResponse = await fetch(pwa.install.iconUrl);
|
|
55
63
|
if (!iconResponse.ok) return new Response(null, { status: 404 });
|
|
@@ -64,8 +72,9 @@ function pwaMiddleware() {
|
|
|
64
72
|
});
|
|
65
73
|
}
|
|
66
74
|
/**
|
|
67
|
-
* The
|
|
68
|
-
*
|
|
75
|
+
* The tags that make the app installable: its manifest, its home screen icon,
|
|
76
|
+
* and, while the app is installable, the name and launch screens iOS shows.
|
|
77
|
+
* Render it once, in `<head>` in the root route's `RootDocument`.
|
|
69
78
|
*
|
|
70
79
|
* @example
|
|
71
80
|
* function RootDocument({ children }: { children: React.ReactNode }) {
|
|
@@ -84,13 +93,40 @@ function pwaMiddleware() {
|
|
|
84
93
|
* }
|
|
85
94
|
*/
|
|
86
95
|
function SoftrPwaHead() {
|
|
96
|
+
const [iosHead, setIosHead] = useState(null);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (detectPlatform() !== "ios") return;
|
|
99
|
+
let cancelled = false;
|
|
100
|
+
globalThis.fetch(INSTALL_PATH, { headers: { accept: "application/json" } }).then(async (response) => {
|
|
101
|
+
if (!response.ok) return;
|
|
102
|
+
const parsed = iosHeadSchema.safeParse(await response.json());
|
|
103
|
+
if (!parsed.success || cancelled) return;
|
|
104
|
+
setIosHead(parsed.data);
|
|
105
|
+
}).catch(() => {});
|
|
106
|
+
return () => {
|
|
107
|
+
cancelled = true;
|
|
108
|
+
};
|
|
109
|
+
}, []);
|
|
87
110
|
return createElement(Fragment, null, createElement("link", {
|
|
88
111
|
rel: "manifest",
|
|
89
112
|
href: MANIFEST_PATH
|
|
90
113
|
}), createElement("link", {
|
|
91
114
|
rel: "apple-touch-icon",
|
|
92
115
|
href: ICON_PATH
|
|
93
|
-
})
|
|
116
|
+
}), ...iosHead === null ? [] : [createElement("meta", {
|
|
117
|
+
key: "capable",
|
|
118
|
+
name: "apple-mobile-web-app-capable",
|
|
119
|
+
content: "yes"
|
|
120
|
+
}), createElement("meta", {
|
|
121
|
+
key: "title",
|
|
122
|
+
name: "apple-mobile-web-app-title",
|
|
123
|
+
content: iosHead.name
|
|
124
|
+
})], ...(iosHead?.startupImages ?? []).map((image) => createElement("link", {
|
|
125
|
+
key: image.href,
|
|
126
|
+
rel: "apple-touch-startup-image",
|
|
127
|
+
media: image.media,
|
|
128
|
+
href: image.href
|
|
129
|
+
})));
|
|
94
130
|
}
|
|
95
131
|
const installSchema = pwaSchema.shape.install;
|
|
96
132
|
/**
|
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.2.0
|
|
16
|
+
library_version: 1.2.1-alpha.0
|
|
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.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.2.0
|
|
12
|
+
library_version: 1.2.1-alpha.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.2.0
|
|
12
|
+
library_version: 1.2.1-alpha.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. `defineQuery` 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.2.0
|
|
10
|
+
library_version: 1.2.1-alpha.0
|
|
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.2.0
|
|
10
|
+
library_version: 1.2.1-alpha.0
|
|
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.2.0
|
|
12
|
+
library_version: 1.2.1-alpha.0
|
|
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.
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
name: pwa
|
|
3
3
|
description: >-
|
|
4
4
|
Let visitors install the app on their home screen: SoftrPwaHead for the
|
|
5
|
-
manifest and
|
|
6
|
-
button and which platform's steps to show, the
|
|
7
|
-
types, and how to check that the app is
|
|
8
|
-
already served; never write them.
|
|
5
|
+
manifest, icon, iOS name and launch screen tags, usePwaInstall to decide
|
|
6
|
+
whether to show an install button and which platform's steps to show, the
|
|
7
|
+
PwaInstall and PwaPlatform types, and how to check that the app is
|
|
8
|
+
installable. The manifest and icon are already served; never write them.
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.2.0
|
|
12
|
+
library_version: 1.2.1-alpha.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
# Installing the app
|
|
16
16
|
|
|
17
17
|
The builder turns installing on in Studio, under Settings → Mobile app, and sets the name, colour and icon there. The app already answers with its manifest and icon once they do. What the app adds is two things: the links that point the browser at them, and a button that tells visitors how to install.
|
|
18
18
|
|
|
19
|
-
> **CRITICAL**: Never write a web app manifest, icon files, a service worker, or `manifest` / `apple-touch-icon` links of your own, in `public/` or in `head()`. The app already serves them from Studio's settings, and a file of your own shadows those settings.
|
|
19
|
+
> **CRITICAL**: Never write a web app manifest, icon files, a service worker, or `manifest` / `apple-touch-icon` / `apple-touch-startup-image` links or an `apple-mobile-web-app-title` meta of your own, in `public/` or in `head()`. The app already serves them from Studio's settings, and a file or tag of your own shadows those settings.
|
|
20
20
|
>
|
|
21
21
|
> **CRITICAL**: Render an install button only while `usePwaInstall()` returns `available: true`. Never show it unconditionally, never cache the answer, never replace the check with your own. Softr can switch installing off for an app, and this check is the only way that reaches the button.
|
|
22
22
|
|
|
@@ -48,7 +48,7 @@ The builder switches installing on in Studio, and `usePwaInstall()` reads that s
|
|
|
48
48
|
|
|
49
49
|
### The links: `<SoftrPwaHead />`
|
|
50
50
|
|
|
51
|
-
Render it once, in `<head>` next to `<HeadContent />`, in `RootDocument` in `src/routes/__root.tsx`.
|
|
51
|
+
Render it once, in `<head>` next to `<HeadContent />`, in `RootDocument` in `src/routes/__root.tsx`. While the app is installable it also renders the name iOS puts under the home screen icon and the iOS launch screens, so an installed app opens on its own splash screen instead of white.
|
|
52
52
|
|
|
53
53
|
```tsx
|
|
54
54
|
function RootDocument({ children }: { children: React.ReactNode }) {
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.2.0
|
|
12
|
+
library_version: 1.2.1-alpha.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**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.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.2.0
|
|
13
|
+
library_version: 1.2.1-alpha.0
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. The same holds for any helper that calls `ds`: declare it inside the handler. A function at module level that calls `ds` keeps the server-only import in the browser bundle, and every page stops loading until it moves. `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.2.0
|
|
12
|
+
library_version: 1.2.1-alpha.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `definePage`, `pageHead`, the access functions and the error predicates come from `@softr/sdk` and work anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.2.0
|
|
12
|
+
library_version: 1.2.1-alpha.0
|
|
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.
|