@softr/sdk 1.8.0-alpha.0 → 1.8.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/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.8.0-alpha.0";
2
+ var version = "1.8.0";
3
3
 
4
4
  //#endregion
5
5
  export { version };
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
- if (!install.available || offered === null) return install;
225
- return {
226
- ...install,
227
- install: async () => {
228
- await offered.prompt();
229
- setOfferedPrompt(null);
230
- return (await offered.userChoice).outcome;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "1.8.0-alpha.0",
3
+ "version": "1.8.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
@@ -72,7 +72,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
72
72
 
73
73
  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
74
 
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. A browser lets one offer prompt once, so after the visitor closes the dialog `install` is gone until the browser offers again.
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. The browser shows its dialog only once per offer, so after the visitor closes it, `install` is gone until the browser offers again.
76
76
 
77
77
  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
78