@lotics/app-sdk 0.100.1 → 0.101.1
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/AGENTS.md +32 -47
- package/dist/agent_stream.d.ts +131 -0
- package/dist/ask_ai.d.ts +27 -0
- package/dist/attachments.d.ts +58 -0
- package/dist/chunk-ARV5FAU5.js +1132 -0
- package/dist/comments.d.ts +89 -0
- package/dist/error_report.d.ts +9 -0
- package/dist/folder_pick.d.ts +8 -0
- package/dist/geolocation.d.ts +42 -0
- package/dist/hooks.d.ts +251 -0
- package/dist/{src/index.d.ts → index.d.ts} +13 -22
- package/dist/index.js +31331 -0
- package/dist/index.js.LEGAL.txt +11 -0
- package/dist/members.d.ts +32 -0
- package/dist/mock.d.ts +37 -0
- package/dist/mount.d.ts +19 -0
- package/dist/new_record.d.ts +37 -0
- package/dist/open_app.d.ts +12 -0
- package/dist/open_external.d.ts +10 -0
- package/dist/overlay.d.ts +25 -0
- package/dist/queries.d.ts +231 -0
- package/dist/recording.d.ts +47 -0
- package/dist/recording_state.d.ts +43 -0
- package/dist/rename_file.d.ts +13 -0
- package/dist/router.d.ts +10 -0
- package/dist/router.js +97 -0
- package/dist/row.d.ts +87 -0
- package/dist/rpc.d.ts +114 -0
- package/dist/select.d.ts +24 -0
- package/dist/shared_types.d.ts +8 -0
- package/dist/store.d.ts +43 -0
- package/dist/types.d.ts +36 -0
- package/dist/upload/optimize.d.ts +30 -0
- package/dist/upload/pipeline.d.ts +36 -0
- package/dist/upload/transport.d.ts +19 -0
- package/dist/url_params.d.ts +55 -0
- package/dist/use_recents.d.ts +15 -0
- package/dist/{src/use_url_state.d.ts → use_url_state.d.ts} +0 -2
- package/dist/viewer.d.ts +41 -0
- package/dist/written.d.ts +79 -0
- package/docs/ai.md +74 -133
- package/docs/data_fetching.md +209 -290
- package/docs/files.md +61 -51
- package/docs/members_and_options.md +92 -62
- package/docs/mutations.md +136 -205
- package/docs/navigation_and_state.md +26 -35
- package/docs/queries.md +144 -207
- package/docs/recipes.md +21 -45
- package/docs/runtime.md +74 -137
- package/docs/security.md +8 -11
- package/docs/workflows.md +189 -174
- package/package.json +27 -28
- package/dist/src/agent_stream.d.ts +0 -200
- package/dist/src/agent_stream.js +0 -314
- package/dist/src/ask_ai.d.ts +0 -40
- package/dist/src/ask_ai.js +0 -35
- package/dist/src/attachments.d.ts +0 -68
- package/dist/src/attachments.js +0 -93
- package/dist/src/comments.d.ts +0 -127
- package/dist/src/comments.js +0 -192
- package/dist/src/download.js +0 -54
- package/dist/src/geolocation.d.ts +0 -64
- package/dist/src/geolocation.js +0 -96
- package/dist/src/hooks.d.ts +0 -781
- package/dist/src/hooks.js +0 -860
- package/dist/src/index.js +0 -34
- package/dist/src/members.d.ts +0 -105
- package/dist/src/members.js +0 -62
- package/dist/src/mock.d.ts +0 -118
- package/dist/src/mock.js +0 -124
- package/dist/src/mount.d.ts +0 -47
- package/dist/src/mount.js +0 -34
- package/dist/src/new_record.d.ts +0 -74
- package/dist/src/new_record.js +0 -117
- package/dist/src/open_app.d.ts +0 -15
- package/dist/src/open_app.js +0 -18
- package/dist/src/open_external.d.ts +0 -16
- package/dist/src/open_external.js +0 -19
- package/dist/src/recording.d.ts +0 -59
- package/dist/src/recording.js +0 -30
- package/dist/src/recording_state.d.ts +0 -59
- package/dist/src/recording_state.js +0 -94
- package/dist/src/router.d.ts +0 -17
- package/dist/src/router.js +0 -144
- package/dist/src/row.d.ts +0 -159
- package/dist/src/row.js +0 -254
- package/dist/src/rpc.d.ts +0 -207
- package/dist/src/rpc.js +0 -904
- package/dist/src/select.d.ts +0 -48
- package/dist/src/select.js +0 -40
- package/dist/src/types.d.ts +0 -115
- package/dist/src/types.js +0 -1
- package/dist/src/upload/optimize.d.ts +0 -54
- package/dist/src/upload/optimize.js +0 -207
- package/dist/src/upload/pipeline.d.ts +0 -55
- package/dist/src/upload/pipeline.js +0 -52
- package/dist/src/upload/transport.d.ts +0 -42
- package/dist/src/upload/transport.js +0 -128
- package/dist/src/url_params.d.ts +0 -93
- package/dist/src/url_params.js +0 -215
- package/dist/src/use_optimistic.d.ts +0 -27
- package/dist/src/use_optimistic.js +0 -27
- package/dist/src/use_recents.d.ts +0 -19
- package/dist/src/use_recents.js +0 -71
- package/dist/src/use_url_state.js +0 -73
- package/dist/src/viewer.d.ts +0 -26
- package/dist/src/viewer.js +0 -47
- /package/dist/{src/download.d.ts → download.d.ts} +0 -0
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
# Navigation & client state
|
|
2
2
|
|
|
3
3
|
How an app's screens and view-state live in the URL, and how small client-side
|
|
4
|
-
state persists across sessions
|
|
5
|
-
|
|
6
|
-
**`urlParam`** codecs (a typed, declared slice of filters/search/sort/tab kept
|
|
7
|
-
in the address bar), and **`useRecents`** (a localStorage-backed recently-used
|
|
8
|
-
list). Read this when an app has more than one screen, when a filtered view
|
|
9
|
-
must survive refresh or be shareable as a link, or when a picker should
|
|
10
|
-
remember what the user chose last.
|
|
4
|
+
state persists across sessions: **`AppRouter`**, **`useUrlState`** + the
|
|
5
|
+
**`urlParam`** codecs, **`useRecents`**, and **`useFolderPick`**.
|
|
11
6
|
|
|
12
7
|
## The two URL layers
|
|
13
8
|
|
|
@@ -24,14 +19,8 @@ Neither is server state — `useUrlState` values are *client* state that you fee
|
|
|
24
19
|
into a query's *server* params (see [named-query params](./queries.md) and the
|
|
25
20
|
[data-fetching hooks](./data_fetching.md) they drive).
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
the
|
|
29
|
-
its own app-host page (see [runtime](./runtime.md)). Both mechanisms
|
|
30
|
-
expose the same API in both modes with no per-mode code (the few behavioral
|
|
31
|
-
differences — embedded first-paint hydration, cross-screen persistence — are
|
|
32
|
-
flagged below); mode is detected automatically (from the `lotics_host` param
|
|
33
|
-
the host puts on the iframe src — `isEmbedded()` from the main entry exposes it
|
|
34
|
-
if you need it).
|
|
22
|
+
Both mechanisms expose one API embedded and standalone ([runtime](./runtime.md));
|
|
23
|
+
the few differences are flagged below.
|
|
35
24
|
|
|
36
25
|
## `AppRouter` — in-app routing
|
|
37
26
|
|
|
@@ -57,12 +46,9 @@ export default function App() {
|
|
|
57
46
|
routes, and splats all work. Inside the tree, use react-router normally:
|
|
58
47
|
`useNavigate`, `useParams`, `useLocation`, `<Link>`, `<Outlet>`.
|
|
59
48
|
|
|
60
|
-
- **
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(`^7 || ^8` — the canonical package; the `react-router-dom` shim's tree also
|
|
64
|
-
satisfies it) is an **optional peer dependency** — an app that imports the
|
|
65
|
-
router entry must install it itself; nothing else in the SDK needs it.
|
|
49
|
+
- **Its own entry.** `AppRouter` ships from `@lotics/app-sdk/router`
|
|
50
|
+
(signature: `dist/router.d.ts`), apart from the hooks; its
|
|
51
|
+
`react-router` peer is `^7 || ^8`.
|
|
66
52
|
- **An address no route claims says so.** `AppRouter` appends a catch-all at
|
|
67
53
|
every level of the tree, so such a path renders a not-found screen — a
|
|
68
54
|
message naming the path and a link to the first route — instead of an empty
|
|
@@ -140,7 +126,7 @@ yourself; undeclared keys are already preserved automatically (see below).
|
|
|
140
126
|
|
|
141
127
|
Save a declared slice of view-state into the address bar so a filtered view
|
|
142
128
|
survives refresh and is shareable/bookmarkable as a link. Exported from the
|
|
143
|
-
main entry (signature: `dist/
|
|
129
|
+
main entry (signature: `dist/use_url_state.d.ts`):
|
|
144
130
|
|
|
145
131
|
```tsx
|
|
146
132
|
import { urlParam, useUrlState } from "@lotics/app-sdk";
|
|
@@ -157,8 +143,6 @@ setFilters({ status: "won" }); // merge into the address bar → ?status=won
|
|
|
157
143
|
setFilters({ page: 2 }); // merge; replaces in place — no history entry
|
|
158
144
|
```
|
|
159
145
|
|
|
160
|
-
Semantics — each of these is load-bearing:
|
|
161
|
-
|
|
162
146
|
- **The URL is the only store.** `filters` is decoded fresh from the current
|
|
163
147
|
params each render — don't mirror it into `useState`; there is no second
|
|
164
148
|
copy to drift.
|
|
@@ -204,7 +188,7 @@ required — absent (or unparseable) decodes to `fallback`, and a value equal to
|
|
|
204
188
|
`fallback` is kept out of the URL. Equality for `withDefault` compares dates by
|
|
205
189
|
timestamp and arrays element-wise, so `withDefault([])` and
|
|
206
190
|
`withDefault(new Date(...))` behave correctly. Types are in
|
|
207
|
-
`dist/
|
|
191
|
+
`dist/url_params.d.ts`.
|
|
208
192
|
|
|
209
193
|
| Builder | Decoded type | URL form | Decode rules |
|
|
210
194
|
| --- | --- | --- | --- |
|
|
@@ -264,7 +248,7 @@ A small, most-recent-first list persisted across sessions — the "recently
|
|
|
264
248
|
used" affordance a search box or picker shows when focused but empty (pair it
|
|
265
249
|
with a combobox's recent-options slot; see the picker pattern in
|
|
266
250
|
[data fetching](./data_fetching.md)). Exported from the main entry (signature:
|
|
267
|
-
`dist/
|
|
251
|
+
`dist/use_recents.d.ts`):
|
|
268
252
|
|
|
269
253
|
```tsx
|
|
270
254
|
const { recents, remember, forget, clear } = useRecents<Item>("item-picker", {
|
|
@@ -300,13 +284,20 @@ default `JSON.stringify`) and `max` (default **5**).
|
|
|
300
284
|
live; a tab sees them only when a hook next mounts (or its `key` changes).
|
|
301
285
|
Concurrent tabs last-write-win.
|
|
302
286
|
|
|
303
|
-
##
|
|
287
|
+
## `useFolderPick` — the folder a viewer works inside
|
|
288
|
+
|
|
289
|
+
A screen scoped to one row of another table — a project, a branch, a season —
|
|
290
|
+
keeps which one the viewer works inside by its record id, per folder table:
|
|
291
|
+
|
|
292
|
+
```tsx
|
|
293
|
+
const { picked, pick } = useFolderPick(projectsTableId);
|
|
294
|
+
// picked: undefined while it is read, null where none is picked, else the row's id
|
|
295
|
+
pick("rec_…"); // or pick(null) to leave for the list of folders
|
|
296
|
+
```
|
|
304
297
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
| `isEmbedded` | `@lotics/app-sdk` | `dist/src/rpc.d.ts` |
|
|
312
|
-
| `openApp` | `@lotics/app-sdk` | `dist/src/open_app.d.ts` |
|
|
298
|
+
- **The host keeps it for the viewer**, so every app of theirs scoped to the
|
|
299
|
+
same table opens in the same folder — each app is served from its own origin,
|
|
300
|
+
and only the host sees them all. Standalone, the app's own origin keeps it.
|
|
301
|
+
- **An id only.** Read the row itself for its name and picture, and drop the
|
|
302
|
+
pick (`pick(null)`) when that read finds no row: a folder deleted, or no
|
|
303
|
+
longer the viewer's to read.
|