@softr/sdk 1.2.1 → 1.2.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @softr/sdk
2
2
 
3
+ ## 1.2.2
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.1
4
10
 
5
11
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import * as react6 from "react";
1
+ import * as react0 from "react";
2
2
 
3
3
  //#region src/default-error-overlay.d.ts
4
4
  type Props = {
@@ -8,6 +8,6 @@ type Props = {
8
8
  declare function DefaultErrorOverlay({
9
9
  error,
10
10
  reset
11
- }: Props): react6.JSX.Element;
11
+ }: Props): react0.JSX.Element;
12
12
  //#endregion
13
13
  export { DefaultErrorOverlay };
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import * as react0 from "react";
2
+ import * as react1 from "react";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/formatting.d.ts
@@ -96,7 +96,7 @@ declare function FormattingScope({
96
96
  /** A BCP 47 locale, such as `de-DE`. It drops the app's fixed date format inside the scope. */
97
97
  locale?: string;
98
98
  children?: ReactNode;
99
- }): react0.FunctionComponentElement<react0.ProviderProps<Scope>>;
99
+ }): react1.FunctionComponentElement<react1.ProviderProps<Scope>>;
100
100
  /**
101
101
  * A date in the app's format, safe to render on the server. A timestamp whose
102
102
  * zone is not known yet renders `fallback` until the browser supplies it, so
@@ -118,6 +118,6 @@ declare function FormattedDate({
118
118
  time?: boolean;
119
119
  /** What renders while the visitor's zone is unknown. */
120
120
  fallback?: ReactNode;
121
- }): react0.FunctionComponentElement<react0.FragmentProps> | null;
121
+ }): react1.FunctionComponentElement<react1.FragmentProps> | null;
122
122
  //#endregion
123
123
  export { DateOptions, DateParts, DateSeparator, DateValue, FixedDateFormat, FormattedDate, Formatting, FormattingScope, WeekDay, formatDate, formatDateTime, formatNumber, useFormatting };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.2.1";
2
+ var version = "1.2.2";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/dist/pwa.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import * as react4 from "react";
1
+ import * as react5 from "react";
2
2
  import "@tanstack/react-start";
3
3
 
4
4
  //#region src/pwa.d.ts
5
5
 
6
6
  /**
7
- * The links that make the app installable: its manifest and its home screen
8
- * icon. Render it once, in `<head>` in the root route's `RootDocument`.
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 }) {
@@ -23,7 +24,7 @@ import "@tanstack/react-start";
23
24
  * )
24
25
  * }
25
26
  */
26
- declare function SoftrPwaHead(): react4.FunctionComponentElement<react4.FragmentProps>;
27
+ declare function SoftrPwaHead(): react5.FunctionComponentElement<react5.FragmentProps>;
27
28
  type PwaPlatform = "ios" | "android" | "desktop";
28
29
  type PwaInstall = {
29
30
  available: false;
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(pwa.install, { headers: { "cache-control": CACHE_CONTROL } });
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 });
@@ -63,9 +71,21 @@ function pwaMiddleware() {
63
71
  }
64
72
  });
65
73
  }
74
+ let pendingInstallInfo;
66
75
  /**
67
- * The links that make the app installable: its manifest and its home screen
68
- * icon. Render it once, in `<head>` in the root route's `RootDocument`.
76
+ * What `/_softr/pwa.json` answers, or `null` when it does not. Callers that ask
77
+ * while a request is in flight share it; the next caller after it settles asks again.
78
+ */
79
+ function fetchInstallInfo() {
80
+ pendingInstallInfo ??= globalThis.fetch(INSTALL_PATH, { headers: { accept: "application/json" } }).then((response) => response.ok ? response.json() : null).catch(() => null).finally(() => {
81
+ pendingInstallInfo = void 0;
82
+ });
83
+ return pendingInstallInfo;
84
+ }
85
+ /**
86
+ * The tags that make the app installable: its manifest, its home screen icon,
87
+ * and, while the app is installable, the name and launch screens iOS shows.
88
+ * Render it once, in `<head>` in the root route's `RootDocument`.
69
89
  *
70
90
  * @example
71
91
  * function RootDocument({ children }: { children: React.ReactNode }) {
@@ -84,13 +104,39 @@ function pwaMiddleware() {
84
104
  * }
85
105
  */
86
106
  function SoftrPwaHead() {
107
+ const [iosHead, setIosHead] = useState(null);
108
+ useEffect(() => {
109
+ if (detectPlatform() !== "ios") return;
110
+ let cancelled = false;
111
+ fetchInstallInfo().then((installInfo) => {
112
+ const parsed = iosHeadSchema.safeParse(installInfo);
113
+ if (!parsed.success || cancelled) return;
114
+ setIosHead(parsed.data);
115
+ });
116
+ return () => {
117
+ cancelled = true;
118
+ };
119
+ }, []);
87
120
  return createElement(Fragment, null, createElement("link", {
88
121
  rel: "manifest",
89
122
  href: MANIFEST_PATH
90
123
  }), createElement("link", {
91
124
  rel: "apple-touch-icon",
92
125
  href: ICON_PATH
93
- }));
126
+ }), ...iosHead === null ? [] : [createElement("meta", {
127
+ key: "capable",
128
+ name: "apple-mobile-web-app-capable",
129
+ content: "yes"
130
+ }), createElement("meta", {
131
+ key: "title",
132
+ name: "apple-mobile-web-app-title",
133
+ content: iosHead.name
134
+ })], ...(iosHead?.startupImages ?? []).map((image) => createElement("link", {
135
+ key: image.href,
136
+ rel: "apple-touch-startup-image",
137
+ media: image.media,
138
+ href: image.href
139
+ })));
94
140
  }
95
141
  const installSchema = pwaSchema.shape.install;
96
142
  /**
@@ -111,16 +157,15 @@ function usePwaInstall() {
111
157
  useEffect(() => {
112
158
  if (isStandalone()) return;
113
159
  let cancelled = false;
114
- globalThis.fetch(INSTALL_PATH, { headers: { accept: "application/json" } }).then(async (response) => {
115
- if (!response.ok) return;
116
- const parsed = installSchema.safeParse(await response.json());
160
+ fetchInstallInfo().then((installInfo) => {
161
+ const parsed = installSchema.safeParse(installInfo);
117
162
  if (!parsed.success || cancelled) return;
118
163
  setInstall({
119
164
  available: true,
120
165
  platform: detectPlatform(),
121
166
  ...parsed.data
122
167
  });
123
- }).catch(() => {});
168
+ });
124
169
  return () => {
125
170
  cancelled = true;
126
171
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: core
12
12
  library: softr-sdk
13
- library_version: 1.2.1
13
+ library_version: 1.2.2
14
14
  ---
15
15
 
16
16
  # Softr SDK core
@@ -13,7 +13,7 @@ description: >-
13
13
  metadata:
14
14
  type: sub-skill
15
15
  library: softr-sdk
16
- library_version: 1.2.1
16
+ library_version: 1.2.2
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.1
12
+ library_version: 1.2.2
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.1
12
+ library_version: 1.2.2
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.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 1.2.1
12
+ library_version: 1.2.2
13
13
  ---
14
14
 
15
15
  # The current user
@@ -7,7 +7,7 @@ description: >-
7
7
  metadata:
8
8
  type: sub-skill
9
9
  library: softr-sdk
10
- library_version: 1.2.1
10
+ library_version: 1.2.2
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.
@@ -8,7 +8,7 @@ description: >-
8
8
  metadata:
9
9
  type: sub-skill
10
10
  library: softr-sdk
11
- library_version: 1.2.1
11
+ library_version: 1.2.2
12
12
  ---
13
13
 
14
14
  # Dates, times and numbers
@@ -7,7 +7,7 @@ description: >-
7
7
  metadata:
8
8
  type: sub-skill
9
9
  library: softr-sdk
10
- library_version: 1.2.1
10
+ library_version: 1.2.2
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.1
12
+ library_version: 1.2.2
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.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 1.2.1
12
+ library_version: 1.2.2
13
13
  ---
14
14
 
15
15
  # Push notifications
@@ -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 icon links, usePwaInstall to decide whether to show an install
6
- button and which platform's steps to show, the PwaInstall and PwaPlatform
7
- types, and how to check that the app is installable. The manifest and icon are
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.1
12
+ library_version: 1.2.2
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.1
12
+ library_version: 1.2.2
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.1
13
+ library_version: 1.2.2
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.1
12
+ library_version: 1.2.2
13
13
  ---
14
14
 
15
15
  **Boundary.** `Audience` and `defineVisibility` 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.1
12
+ library_version: 1.2.2
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.1
12
+ library_version: 1.2.2
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.