@softr/sdk 0.0.48 → 0.0.49-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.
@@ -1,7 +1,19 @@
1
- import { useRef, useState } from "react";
1
+ import { useEffect, useRef, useState, useSyncExternalStore } from "react";
2
+ import { useRouter } from "@tanstack/react-router";
2
3
  import { jsx, jsxs } from "react/jsx-runtime";
3
4
 
4
5
  //#region src/default-error-overlay.tsx
6
+ function subscribeToAgentTurn(listener) {
7
+ const observer = new MutationObserver(listener);
8
+ observer.observe(document.documentElement, {
9
+ attributes: true,
10
+ attributeFilter: ["data-agent-turn"]
11
+ });
12
+ return () => observer.disconnect();
13
+ }
14
+ function isAgentTurnRunning() {
15
+ return document.documentElement.dataset.agentTurn === "running";
16
+ }
5
17
  function DefaultErrorOverlay({ error, reset }) {
6
18
  if (process.env.NODE_ENV === "production") return /* @__PURE__ */ jsx("div", {
7
19
  style: s.overlay,
@@ -26,6 +38,23 @@ function DefaultErrorOverlay({ error, reset }) {
26
38
  });
27
39
  }
28
40
  function DevView({ error, reset }) {
41
+ const running = useSyncExternalStore(subscribeToAgentTurn, isAgentTurnRunning, () => false);
42
+ const caughtDuringTurn = useRef(running);
43
+ const router = useRouter();
44
+ useEffect(() => {
45
+ if (running) {
46
+ caughtDuringTurn.current = true;
47
+ return;
48
+ }
49
+ if (!caughtDuringTurn.current) return;
50
+ const timer = setTimeout(() => void router.invalidate().then(() => reset?.()), 1e3);
51
+ return () => clearTimeout(timer);
52
+ }, [
53
+ running,
54
+ reset,
55
+ router
56
+ ]);
57
+ if (running) return /* @__PURE__ */ jsx(UpdatingView, {});
29
58
  return /* @__PURE__ */ jsx("div", {
30
59
  style: s.overlay,
31
60
  children: /* @__PURE__ */ jsxs("div", {
@@ -56,6 +85,38 @@ function DevView({ error, reset }) {
56
85
  })
57
86
  });
58
87
  }
88
+ function UpdatingView() {
89
+ return /* @__PURE__ */ jsx("div", {
90
+ style: s.overlay,
91
+ children: /* @__PURE__ */ jsxs("div", {
92
+ style: s.card,
93
+ children: [/* @__PURE__ */ jsx("div", {
94
+ style: s.pending,
95
+ children: /* @__PURE__ */ jsxs("svg", {
96
+ style: icon.md,
97
+ viewBox: "0 0 24 24",
98
+ fill: "none",
99
+ stroke: "currentColor",
100
+ strokeWidth: "2",
101
+ strokeLinecap: "round",
102
+ strokeLinejoin: "round",
103
+ children: [
104
+ /* @__PURE__ */ jsx("path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" }),
105
+ /* @__PURE__ */ jsx("path", { d: "M21 3v5h-5" }),
106
+ /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" }),
107
+ /* @__PURE__ */ jsx("path", { d: "M8 16H3v5" })
108
+ ]
109
+ })
110
+ }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h1", {
111
+ style: s.heading,
112
+ children: "Updating the app…"
113
+ }), /* @__PURE__ */ jsx("p", {
114
+ style: s.body,
115
+ children: "The agent is still working on this change. The preview will recover once it is complete."
116
+ })] })]
117
+ })
118
+ });
119
+ }
59
120
  function cleanStack(stack) {
60
121
  return stack.split("\n").slice(1).filter((line) => line.trim().startsWith("at ") && !line.includes("/node_modules/")).map((line) => line.replace(/https?:\/\/[^/]+\//, "").replace(/\?[^):]+/g, "")).join("\n");
61
122
  }
@@ -228,6 +289,17 @@ const s = {
228
289
  color: "var(--destructive, oklch(0.577 0.245 27.325))",
229
290
  flexShrink: 0
230
291
  },
292
+ pending: {
293
+ display: "flex",
294
+ alignItems: "center",
295
+ justifyContent: "center",
296
+ width: "2.5rem",
297
+ height: "2.5rem",
298
+ borderRadius: "var(--radius, 0.625rem)",
299
+ background: "var(--muted, oklch(0.97 0 0))",
300
+ color: "var(--muted-foreground, oklch(0.556 0 0))",
301
+ flexShrink: 0
302
+ },
231
303
  heading: {
232
304
  margin: 0,
233
305
  fontSize: "1rem",
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DatasourceAction } from "./action.js";
2
- import * as _tanstack_react_start2 from "@tanstack/react-start";
2
+ import * as _tanstack_react_start0 from "@tanstack/react-start";
3
3
 
4
4
  //#region src/mcp.d.ts
5
5
 
@@ -37,6 +37,6 @@ type SoftrMcpOptions = {
37
37
  * ],
38
38
  * }))
39
39
  */
40
- declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start2.RequestMiddlewareAfterServer<{}, undefined, undefined>;
40
+ declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>;
41
41
  //#endregion
42
42
  export { softrMcpMiddleware };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.0.48";
2
+ var version = "0.0.49-alpha.0";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "0.0.48",
3
+ "version": "0.0.49-alpha.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
@@ -11,7 +11,7 @@ description: >-
11
11
  metadata:
12
12
  type: core
13
13
  library: softr-sdk
14
- library_version: 0.0.48
14
+ library_version: 0.0.49-alpha.0
15
15
  ---
16
16
 
17
17
  # Softr SDK core
@@ -16,7 +16,7 @@ description: >-
16
16
  metadata:
17
17
  type: sub-skill
18
18
  library: softr-sdk
19
- library_version: 0.0.48
19
+ library_version: 0.0.49-alpha.0
20
20
  ---
21
21
 
22
22
  **Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
@@ -12,7 +12,7 @@ description: >-
12
12
  metadata:
13
13
  type: sub-skill
14
14
  library: softr-sdk
15
- library_version: 0.0.48
15
+ library_version: 0.0.49-alpha.0
16
16
  ---
17
17
 
18
18
  **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: 0.0.48
12
+ library_version: 0.0.49-alpha.0
13
13
  ---
14
14
 
15
15
  # The current user
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 0.0.48
13
+ library_version: 0.0.49-alpha.0
14
14
  ---
15
15
 
16
16
  **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.
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 0.0.48
13
+ library_version: 0.0.49-alpha.0
14
14
  ---
15
15
 
16
16
  **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: 0.0.48
12
+ library_version: 0.0.49-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.
@@ -11,7 +11,7 @@ description: >-
11
11
  metadata:
12
12
  type: sub-skill
13
13
  library: softr-sdk
14
- library_version: 0.0.48
14
+ library_version: 0.0.49-alpha.0
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. `defineMutation` and every type come from `@softr/sdk` and can be imported anywhere.
@@ -13,7 +13,7 @@ description: >-
13
13
  metadata:
14
14
  type: sub-skill
15
15
  library: softr-sdk
16
- library_version: 0.0.48
16
+ library_version: 0.0.49-alpha.0
17
17
  ---
18
18
 
19
19
  **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: 0.0.48
12
+ library_version: 0.0.49-alpha.0
13
13
  ---
14
14
 
15
15
  **Boundary.** `Audience` and `defineVisibility` come from `@softr/sdk` and work anywhere.
@@ -13,7 +13,7 @@ description: >-
13
13
  metadata:
14
14
  type: sub-skill
15
15
  library: softr-sdk
16
- library_version: 0.0.48
16
+ library_version: 0.0.49-alpha.0
17
17
  ---
18
18
 
19
19
  **Boundary.** `defineVisibility`, 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: 0.0.48
12
+ library_version: 0.0.49-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.