@softr/sdk 1.12.1 → 1.13.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.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - `LogoIcon`, from the new `@softr/sdk/logo-icon` entrypoint, is the Lucide icon that `logo.icon` in `softr.json` names, or `layers` when Lucide has none by that name. The `softr()` Vite plugin picks it when the app builds, so the app ships that one icon and the server renders it.
8
+
3
9
  ## 1.12.1
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,16 @@
1
+ import { ComponentType, SVGProps } from "react";
2
+
3
+ //#region src/logo-icon.d.ts
4
+ /** What the logo's icon takes: a Lucide icon's props. */
5
+ type LogoIconProps = SVGProps<SVGSVGElement> & {
6
+ size?: number | string;
7
+ strokeWidth?: number | string;
8
+ absoluteStrokeWidth?: boolean;
9
+ };
10
+ /**
11
+ * The Lucide icon `logo.icon` in softr.json names, or "layers" when Lucide has none by that name.
12
+ * It is picked when the app builds, so it renders on the server and only that icon ships.
13
+ */
14
+ declare const LogoIcon: ComponentType<LogoIconProps>;
15
+ //#endregion
16
+ export { LogoIcon, LogoIconProps };
@@ -0,0 +1,11 @@
1
+ import icon from "virtual:softr/logo-icon";
2
+
3
+ //#region src/logo-icon.ts
4
+ /**
5
+ * The Lucide icon `logo.icon` in softr.json names, or "layers" when Lucide has none by that name.
6
+ * It is picked when the app builds, so it renders on the server and only that icon ships.
7
+ */
8
+ const LogoIcon = icon;
9
+
10
+ //#endregion
11
+ export { LogoIcon };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.12.1";
2
+ var version = "1.13.0";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/dist/vite.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { SOFTR_CONFIG_FILE, loadSoftrConfig } from "./softr-config.schema.js";
2
+ import { createRequire } from "node:module";
2
3
  import path from "node:path";
3
4
 
4
5
  //#region src/vite.ts
5
6
  function softr() {
6
- return [softrConfig()];
7
+ return [softrConfig(), softrLogoIcon()];
7
8
  }
8
9
  function softrConfig() {
9
10
  let root;
@@ -22,6 +23,35 @@ function softrConfig() {
22
23
  }
23
24
  };
24
25
  }
26
+ const LOGO_ICON = "virtual:softr/logo-icon";
27
+ const RESOLVED_LOGO_ICON = `\0${LOGO_ICON}`;
28
+ const DEFAULT_LOGO_ICON = "layers";
29
+ function softrLogoIcon() {
30
+ let root;
31
+ return {
32
+ name: "softr:logo-icon",
33
+ configResolved(config) {
34
+ root = config.root;
35
+ },
36
+ resolveId(id) {
37
+ return id === LOGO_ICON ? RESOLVED_LOGO_ICON : void 0;
38
+ },
39
+ load(id) {
40
+ if (id !== RESOLVED_LOGO_ICON) return void 0;
41
+ const lucide = createRequire(path.join(root, "package.json"))("lucide-react");
42
+ const exported = [loadSoftrConfig(root).logo.icon, DEFAULT_LOGO_ICON].map(exportName).find((name) => Object.hasOwn(lucide, name));
43
+ if (exported === void 0) throw new Error(`lucide-react in ${root} has no "${DEFAULT_LOGO_ICON}" icon to draw the logo with`);
44
+ return `export { ${exported} as default } from "lucide-react";`;
45
+ }
46
+ };
47
+ }
48
+ /**
49
+ * The name lucide-react exports this icon under: "paw-print" is PawPrintIcon. Every icon and alias has
50
+ * one. Lucide's one other export that ends in Icon is Icon itself, and no icon name maps to it.
51
+ */
52
+ function exportName(icon) {
53
+ return `${icon.replace(/(?:^|-)([a-z0-9])/g, (_, letter) => letter.toUpperCase())}Icon`;
54
+ }
25
55
 
26
56
  //#endregion
27
57
  export { softr };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@softr/sdk",
3
- "version": "1.12.1",
3
+ "version": "1.13.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
7
7
  "./client": { "types": "./dist/client.d.ts", "import": "./dist/client.js" },
8
8
  "./server": { "types": "./dist/server.d.ts", "import": "./dist/server.js" },
9
- "./vite": { "types": "./dist/vite.d.ts", "import": "./dist/vite.js" }
9
+ "./vite": { "types": "./dist/vite.d.ts", "import": "./dist/vite.js" },
10
+ "./logo-icon": { "types": "./dist/logo-icon.d.ts", "import": "./dist/logo-icon.js" }
10
11
  },
11
12
  "bin": { "softr-sdk": "./dist/cli.js" },
12
13
  "files": ["dist", "schema", "skills", "!skills/_artifacts", "CHANGELOG.md"],
@@ -1,24 +1,24 @@
1
1
  ---
2
2
  name: softr-sdk
3
3
  description: >-
4
- Entry point for @softr/sdk: its four entrypoints (@softr/sdk, /server,
5
- /client, /vite) and their client-server boundary, softrAuthMiddleware and the
6
- Softr context, embedding the app in another site's iframe, the app's favicon,
7
- the app's logo in softr.json, and which sub-skill covers each task. Load it
8
- when unsure which sub-skill applies, when touching the wiring, when the user
9
- wants the app embedded elsewhere, when the favicon set in Studio does not
10
- show, or when the app's logo changes.
4
+ Entry point for @softr/sdk: its five entrypoints (@softr/sdk, /server,
5
+ /client, /vite, /logo-icon) and their client-server boundary,
6
+ softrAuthMiddleware and the Softr context, embedding the app in another site's
7
+ iframe, the app's favicon, the app's logo in softr.json, and which sub-skill
8
+ covers each task. Load it when unsure which sub-skill applies, when touching
9
+ the wiring, when the user wants the app embedded elsewhere, when the favicon
10
+ set in Studio does not show, or when the app's logo changes.
11
11
  metadata:
12
12
  type: core
13
13
  library: softr-sdk
14
- library_version: 1.12.1
14
+ library_version: 1.13.0
15
15
  ---
16
16
 
17
17
  # Softr SDK core
18
18
 
19
19
  `@softr/sdk` is how a Softr application talks to Softr. The visitor's identity, who may see a route, records in a datasource, signing in: all of it goes through this package. Everything else is an ordinary TanStack Start app. Routes, server functions, loaders and middleware are Start's, not Softr's.
20
20
 
21
- > **CRITICAL**: The SDK is split across four entrypoints and the split is enforced. `ds` and `auth` exist only on `@softr/sdk/server` and only run inside a `createServerFn` handler. Importing them anywhere else fails the build.
21
+ > **CRITICAL**: The SDK is split across five entrypoints and the split is enforced. `ds` and `auth` exist only on `@softr/sdk/server` and only run inside a `createServerFn` handler. Importing them anywhere else fails the build.
22
22
  >
23
23
  > **CRITICAL**: Every route file must declare its settings with `definePage`, guard itself with them in `beforeLoad` and render them in `head`. There is no default and nothing is inherited from a sibling.
24
24
  >
@@ -38,6 +38,7 @@ Each sub-skill stands alone for its task and repeats the boundary above, so most
38
38
  | `@softr/sdk/server` | Server only | `ds`, `auth`, `workflow`, `integration`, `ai` |
39
39
  | `@softr/sdk/client` | Browser only | `useFileUpload` |
40
40
  | `@softr/sdk/vite` | Build | `softr()`, already in `vite.config.ts` |
41
+ | `@softr/sdk/logo-icon` | Both, built by `softr()` | `LogoIcon` |
41
42
 
42
43
  ## Sub-Skills
43
44
 
@@ -199,6 +200,6 @@ The app's logo is `logo` in `softr.json`. The Logo field in Studio writes it, an
199
200
  ```
200
201
 
201
202
  - `source` is what the app shows, `"image"` or `"icon"`. The file keeps both, so a switch back loses nothing.
202
- - `icon` is a Lucide icon name in kebab case, like `"layers"`. It is always set, and it shows when `source` is `"image"` and no image fits.
203
+ - `icon` is a Lucide icon name in kebab case, like `"layers"`. It is always set, and it shows when `source` is `"image"` and no image fits. `LogoIcon` from `@softr/sdk/logo-icon` draws it: the `softr()` Vite plugin picks that one icon when the app builds, or `layers` when Lucide has none by that name. Draw the logo's icon with it, never with a Lucide icon looked up by name.
203
204
  - `image.square` is the logo without the app's name, about square. `image.horizontal` is the logo with the name in it, wide. Either may be missing. Each has `onLight`, and `onDark` for dark backgrounds, which falls back to `onLight`. A file is a path under `public/`, like `"/logo.svg"`, or an https URL.
204
205
  - An app without the key gets `{ "source": "icon", "icon": "layers", "image": {} }`. A field this SDK does not know is ignored, and an unknown `source` shows the icon. An `icon` that is not a kebab-case name, an image without `onLight` or a file that is neither a path under `public/` nor an https URL fails the build, naming the key.
@@ -13,7 +13,7 @@ description: >-
13
13
  metadata:
14
14
  type: sub-skill
15
15
  library: softr-sdk
16
- library_version: 1.12.1
16
+ library_version: 1.13.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.
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 1.12.1
13
+ library_version: 1.13.0
14
14
  ---
15
15
 
16
16
  **Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 1.12.1
13
+ library_version: 1.13.0
14
14
  ---
15
15
 
16
16
  **Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. A helper that calls `ds` outside a handler goes in `createServerOnlyFn` from `@tanstack/react-start` (the `record-queries` boundary). `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
@@ -11,7 +11,7 @@ description: >-
11
11
  metadata:
12
12
  type: sub-skill
13
13
  library: softr-sdk
14
- library_version: 1.12.1
14
+ library_version: 1.13.0
15
15
  ---
16
16
 
17
17
  # The current user
@@ -12,7 +12,7 @@ description: >-
12
12
  metadata:
13
13
  type: sub-skill
14
14
  library: softr-sdk
15
- library_version: 1.12.1
15
+ library_version: 1.13.0
16
16
  ---
17
17
 
18
18
  **Boundary.** `email` and `EmailError` live on `@softr/sdk/server` and run only inside a `createServerFn` handler — importing them into a component fails the build. `defineEmailAction` 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.12.1
10
+ library_version: 1.13.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.12.1
11
+ library_version: 1.13.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.12.1
10
+ library_version: 1.13.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.12.1
12
+ library_version: 1.13.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.12.1
12
+ library_version: 1.13.0
13
13
  ---
14
14
 
15
15
  # Push notifications
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 1.12.1
13
+ library_version: 1.13.0
14
14
  ---
15
15
 
16
16
  # Installing the app
@@ -10,7 +10,7 @@ description: >-
10
10
  metadata:
11
11
  type: sub-skill
12
12
  library: softr-sdk
13
- library_version: 1.12.1
13
+ library_version: 1.13.0
14
14
  ---
15
15
 
16
16
  **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.
@@ -11,7 +11,7 @@ description: >-
11
11
  metadata:
12
12
  type: sub-skill
13
13
  library: softr-sdk
14
- library_version: 1.12.1
14
+ library_version: 1.13.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. A route `loader` also runs in the browser, so it calls a server function, never `ds`. A helper that calls `ds` outside a handler, in this file or in another one, goes in `createServerOnlyFn` from `@tanstack/react-start`, or inside the handler. An exported helper without it keeps the server-only import in the browser bundle, and every page stops loading until it moves. Do not make such a helper a server function when it takes an id: any visitor can call a server function with any id. `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.12.1
12
+ library_version: 1.13.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.12.1
12
+ library_version: 1.13.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.12.1
12
+ library_version: 1.13.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.