@softr/sdk 1.1.0 → 1.1.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @softr/sdk
2
2
 
3
+ ## 1.1.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.1.0
4
10
 
5
11
  ### Minor Changes
@@ -1,9 +1,9 @@
1
1
  import { User } from "./user.js";
2
2
  import { Formatting } from "../formatting.js";
3
3
  import { SoftrContext } from "./context.js";
4
- import * as react0 from "react";
4
+ import * as react6 from "react";
5
5
  import { ReactNode } from "react";
6
- import * as _tanstack_react_start0 from "@tanstack/react-start";
6
+ import * as _tanstack_react_start2 from "@tanstack/react-start";
7
7
 
8
8
  //#region src/auth/isomorphic.d.ts
9
9
 
@@ -21,7 +21,7 @@ import * as _tanstack_react_start0 from "@tanstack/react-start";
21
21
  * requestMiddleware: [softrAuthMiddleware()],
22
22
  * }))
23
23
  */
24
- declare function softrAuthMiddleware(): _tanstack_react_start0.RequestMiddlewareAfterServer<{}, readonly [_tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>], {
24
+ declare function softrAuthMiddleware(): _tanstack_react_start2.RequestMiddlewareAfterServer<{}, readonly [_tanstack_react_start2.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start2.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start2.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start2.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start2.RequestMiddlewareAfterServer<{}, undefined, undefined>, _tanstack_react_start2.RequestMiddlewareAfterServer<{}, undefined, undefined>], {
25
25
  user: User | null;
26
26
  permissions: {
27
27
  datasources: {};
@@ -37,7 +37,7 @@ declare function softrAuthMiddleware(): _tanstack_react_start0.RequestMiddleware
37
37
  * beforeLoad: async () => await getSoftrContext(),
38
38
  * })
39
39
  */
40
- declare const getSoftrContext: _tanstack_react_start0.OptionalFetcher<undefined, undefined, Promise<SoftrContext>>;
40
+ declare const getSoftrContext: _tanstack_react_start2.OptionalFetcher<undefined, undefined, Promise<SoftrContext>>;
41
41
  /**
42
42
  * The context to hand `createRouter`, before any request has resolved one.
43
43
  *
@@ -85,7 +85,7 @@ type AuthOptions = {
85
85
  * staleTime: 60_000,
86
86
  * })
87
87
  */
88
- declare const getAuthSettings: _tanstack_react_start0.OptionalFetcher<undefined, undefined, Promise<AuthOptions>>;
88
+ declare const getAuthSettings: _tanstack_react_start2.OptionalFetcher<undefined, undefined, Promise<AuthOptions>>;
89
89
  /**
90
90
  * Makes the auth options readable with {@link useAuthSettings} anywhere below.
91
91
  *
@@ -105,7 +105,7 @@ declare function AuthSettingsProvider({
105
105
  }: {
106
106
  value: AuthOptions;
107
107
  children?: ReactNode;
108
- }): react0.JSX.Element;
108
+ }): react6.JSX.Element;
109
109
  /**
110
110
  * Which ways in this app offers. Requires an {@link AuthSettingsProvider}
111
111
  * above it.
@@ -1,4 +1,4 @@
1
- import * as react6 from "react";
1
+ import * as react5 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): react5.JSX.Element;
12
12
  //#endregion
13
13
  export { DefaultErrorOverlay };
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DatasourceAction } from "./action.js";
2
- import * as _tanstack_react_start8 from "@tanstack/react-start";
2
+ import * as _tanstack_react_start1 from "@tanstack/react-start";
3
3
 
4
4
  //#region src/mcp.d.ts
5
5
 
@@ -31,6 +31,6 @@ type SoftrMcpOptions = {
31
31
  * ],
32
32
  * }))
33
33
  */
34
- declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start8.RequestMiddlewareAfterServer<{}, undefined, undefined>;
34
+ declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start1.RequestMiddlewareAfterServer<{}, undefined, undefined>;
35
35
  //#endregion
36
36
  export { softrMcpMiddleware };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.1.0";
2
+ var version = "1.1.1-alpha.0";
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 react3 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(): react3.FunctionComponentElement<react3.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 });
@@ -64,8 +72,9 @@ function pwaMiddleware() {
64
72
  });
65
73
  }
66
74
  /**
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`.
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,35 @@ 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 ? null : createElement("meta", {
117
+ name: "apple-mobile-web-app-title",
118
+ content: iosHead.name
119
+ }), ...(iosHead?.startupImages ?? []).map((image) => createElement("link", {
120
+ key: image.href,
121
+ rel: "apple-touch-startup-image",
122
+ media: image.media,
123
+ href: image.href
124
+ })));
94
125
  }
95
126
  const installSchema = pwaSchema.shape.install;
96
127
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.1-alpha.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: core
11
11
  library: softr-sdk
12
- library_version: 1.1.0
12
+ library_version: 1.1.1-alpha.0
13
13
  ---
14
14
 
15
15
  # 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.1.0
16
+ library_version: 1.1.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.1.0
12
+ library_version: 1.1.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.1.0
12
+ library_version: 1.1.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.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 1.1.0
12
+ library_version: 1.1.1-alpha.0
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.1.0
10
+ library_version: 1.1.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.
@@ -8,7 +8,7 @@ description: >-
8
8
  metadata:
9
9
  type: sub-skill
10
10
  library: softr-sdk
11
- library_version: 1.1.0
11
+ library_version: 1.1.1-alpha.0
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.1.0
10
+ library_version: 1.1.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.1.0
12
+ library_version: 1.1.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.
@@ -9,7 +9,7 @@ description: >-
9
9
  metadata:
10
10
  type: sub-skill
11
11
  library: softr-sdk
12
- library_version: 1.1.0
12
+ library_version: 1.1.1-alpha.0
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.1.0
12
+ library_version: 1.1.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.1.0
12
+ library_version: 1.1.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.1.0
13
+ library_version: 1.1.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.1.0
12
+ library_version: 1.1.1-alpha.0
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.1.0
12
+ library_version: 1.1.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.1.0
12
+ library_version: 1.1.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.