@lotics/app-sdk 0.132.0 → 0.133.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/AGENTS.md CHANGED
@@ -24,7 +24,7 @@ This file is the index. The **exact type** of anything is its shipped declaratio
24
24
  | [docs/navigation_and_state.md](./docs/navigation_and_state.md) | `AppRouter` (embedded/standalone URL model, the screens and `drawers` it reports to the host, opening at `/` when the person opens the app from the host: `openRequested`, `subscribeOpen`), `useUrlState` + `urlParam` codecs, `useRecents`, `useFolderPick`. |
25
25
  | [docs/ai.md](./docs/ai.md) | `useAgentRun` (structured vs free-text, streaming parts, the agent's ask-back), `askAi`, `useAiContext`, and what the member's own chat agent can do with the app while it is open. |
26
26
  | [docs/security.md](./docs/security.md) | **Read before shipping** — the owner-principal model, `is_current_member` scoping, write attribution, group gates, public-app bounds, why a per-input bound is a tenancy floor rather than an authorization check. |
27
- | [docs/runtime.md](./docs/runtime.md) | `mount()` and the errors it reports to the host (`reportAppError`), the two transports, the API address a standalone bundle reads out of its own page (`<meta name="lotics-api-base">`), `rpc()` (and its `holdsCover` option), `holdDrawn` (keep the host's loading cover up), `installPageHost` (a page that is never an app's answers every op, hears its notifications, keeps its address in memory and saves its files through one host: `PageHost`, `PageHostRefusal`, `saveFileFromUrl`, `ApiRefusal`, `preparedForUpload` with `IMAGE_FIDELITIES`), the mock harness (`fixture` + `?__mock=1` — queries, workflows and agents, a mocked agent's run played line by line), `openExternal`/`downloadFile`, geofencing, the peer dependencies. |
27
+ | [docs/runtime.md](./docs/runtime.md) | `mount()` and the errors it reports to the host (`reportAppError`), the two transports, the API address a standalone bundle reads out of its own page (`<meta name="lotics-api-base">`), `rpc()` (and its `holdsCover` option), `holdDrawn` (keep the host's loading cover up), `installPageHost` (a page that is never an app's answers every op, hears its notifications, keeps its address in memory and saves its files through one host: `PageHost`, `queriesChanged` (what a host tells the app when a table moved), `PageHostRefusal`, `saveFileFromUrl`, `ApiRefusal`, `preparedForUpload` with `IMAGE_FIDELITIES`), the mock harness (`fixture` + `?__mock=1` — queries, workflows and agents, a mocked agent's run played line by line), `openExternal`/`downloadFile`, geofencing, the peer dependencies. |
28
28
 
29
29
  ## Non-negotiables (each detailed in its doc)
30
30
 
@@ -1493,7 +1493,10 @@ var mountedAliases = /* @__PURE__ */ new Map();
1493
1493
  function notifyLocalWrite(reads) {
1494
1494
  const aliases = reads === void 0 ? [...mountedAliases.keys()] : [...reads];
1495
1495
  if (aliases.length === 0) return;
1496
- for (const cb of refetchSubscribers) cb(aliases);
1496
+ queriesChanged(aliases);
1497
+ }
1498
+ function queriesChanged(aliases) {
1499
+ for (const cb of refetchSubscribers) cb([...aliases]);
1497
1500
  }
1498
1501
  var pending = /* @__PURE__ */ new Map();
1499
1502
  var streaming = /* @__PURE__ */ new Map();
@@ -1518,8 +1521,7 @@ function ensureListener() {
1518
1521
  return;
1519
1522
  }
1520
1523
  if (msg.type === "queriesChanged" && Array.isArray(msg.aliases)) {
1521
- const aliases = msg.aliases.filter((a) => typeof a === "string");
1522
- for (const cb of refetchSubscribers) cb(aliases);
1524
+ queriesChanged(msg.aliases.filter((a) => typeof a === "string"));
1523
1525
  return;
1524
1526
  }
1525
1527
  if (msg.type === "recordingChanged") {
@@ -2240,6 +2242,7 @@ export {
2240
2242
  subscribeOpen,
2241
2243
  postHostNotification,
2242
2244
  subscribeQueriesChanged,
2245
+ queriesChanged,
2243
2246
  holdDrawn,
2244
2247
  releaseAllHolds,
2245
2248
  rpcAgentRun,
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ export type { UseRecording, UseRecordings } from "./recording.js";
22
22
  export type { RecordingState, RecordingInputs } from "./recording_state.js";
23
23
  export { requestGeofencedLocation, isWithinZone } from "./geolocation.js";
24
24
  export type { GeofenceZone, GeoCoords, GeofenceOutcome, GeofenceOptions } from "./geolocation.js";
25
- export { rpc, hostSpec, holdDrawn, isEmbedded, installPageHost, openRequested, subscribeOpen, ApiRefusal, PageHostRefusal } from "./rpc.js";
25
+ export { rpc, hostSpec, holdDrawn, isEmbedded, installPageHost, openRequested, subscribeOpen, queriesChanged, ApiRefusal, PageHostRefusal } from "./rpc.js";
26
26
  export type { RpcOp, RpcTransport, HostSpec, AiContextValue, AiContextRecordRef, PageHost, PageAgentRun, PageAgentRunStream, HostNotification, AgentRunHandle, AgentRunPayload, AgentRunContinuePayload } from "./rpc.js";
27
27
  export { openExternal } from "./open_external.js";
28
28
  export { askAi, type AskAiArgs } from "./ask_ai.js";
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ import {
42
42
  postHostNotification,
43
43
  powerDecimal,
44
44
  preparedForUpload,
45
+ queriesChanged,
45
46
  readRecordingSnapshot,
46
47
  recordingStateOf,
47
48
  recordingsVersion,
@@ -60,7 +61,7 @@ import {
60
61
  subtractDecimal,
61
62
  sumDecimal,
62
63
  urlParam
63
- } from "./chunk-JV4BYIBG.js";
64
+ } from "./chunk-J3UN4AJW.js";
64
65
 
65
66
  // src/mount.tsx
66
67
  import { createRoot } from "react-dom/client";
@@ -178,9 +179,10 @@ function installVisibleErrorHandlers(container) {
178
179
  releaseAllHolds();
179
180
  };
180
181
  window.addEventListener("error", (e) => {
181
- if (e.error !== null && e.error !== void 0) showError(`Uncaught error: ${e.message}
182
- ${e.error?.stack ?? ""}`);
183
- reportAppError("uncaught", e.error ?? e.message);
182
+ if (e.error === null || e.error === void 0) return;
183
+ showError(`Uncaught error: ${e.message}
184
+ ${e.error instanceof Error ? e.error.stack ?? "" : String(e.error)}`);
185
+ reportAppError("uncaught", e.error);
184
186
  });
185
187
  window.addEventListener("unhandledrejection", (e) => {
186
188
  const reason = e.reason instanceof Error ? `${e.reason.message}
@@ -15514,6 +15516,7 @@ export {
15514
15516
  openExternal,
15515
15517
  openRequested,
15516
15518
  preparedForUpload,
15519
+ queriesChanged,
15517
15520
  queryAll,
15518
15521
  readCreatedAt,
15519
15522
  readFiles,
package/dist/router.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  setUrlParams,
7
7
  settleOpen,
8
8
  subscribeOpen
9
- } from "./chunk-JV4BYIBG.js";
9
+ } from "./chunk-J3UN4AJW.js";
10
10
 
11
11
  // src/router.tsx
12
12
  import { useEffect, useLayoutEffect, useRef } from "react";
package/dist/rpc.d.ts CHANGED
@@ -178,6 +178,8 @@ export declare function registerQueryAlias(alias: string): () => void;
178
178
  * tables a workflow touched.
179
179
  */
180
180
  export declare function notifyLocalWrite(reads?: readonly string[]): void;
181
+ /** What a host tells the app: the queries named are stale, and every mounted hook of one reads again. */
182
+ export declare function queriesChanged(aliases: readonly string[]): void;
181
183
  /**
182
184
  * Keeps the loading cover up until the returned release runs, for a page that has not yet drawn what its requests will
183
185
  * feed. Releasing the last hold starts the two-frame check; releasing again does nothing.
package/docs/runtime.md CHANGED
@@ -25,7 +25,7 @@ mount(<App />);
25
25
  stack) above the app — a render crash or an unhandled promise rejection is
26
26
  visible in the iframe itself. Embedded, each also reaches Lotics through the
27
27
  host (`reportAppError`: the error's class, a bounded message and its first
28
- frame, with no origin, query or fragment; the first five per page load).
28
+ frame, with no origin, query or fragment; the first five per page load). An `error` event that carries no error value is a browser notice and is not reported, nor counted in the five; a thrown value of any kind, and an unhandled rejection, are.
29
29
  Banners are informational only; they are not removed automatically.
30
30
  4. **Renders the tree** with React 19's `createRoot`.
31
31
 
@@ -284,7 +284,7 @@ what the app tells its host (`HostNotification`) and `{ type: "drawn" }` once it
284
284
  where set, keeps the router in memory starting there, since the page has no address of its own; `agentRun` answers a
285
285
  run's stream (absent, a run is refused with `PageHostRefusal`): its `done` rejecting before any chunk is a refusal, and
286
286
  resolving with no `finish` chunk is a cut stream `useAgentRun` reads to its end from `agentRun.get`, so a host that
287
- carries no stream hands over the run's id and resolves; `save` saves a made file the app holds a link to. `agentRun`
287
+ carries no stream hands over the run's id and resolves; `save` saves a made file the app holds a link to. `queriesChanged(aliases)` is what a page host tells its app when a table moved: the queries named are stale, and every mounted hook of one reads again. `agentRun`
288
288
  takes a `PageAgentRun` (`agentRun` with an `AgentRunPayload` — `alias`, `session_id`, `input` — or `agentRunContinue` with
289
289
  an `AgentRunContinuePayload`) and a `PageAgentRunStream` (`onText` per raw chunk, `onRunId` once the run's id is known),
290
290
  and answers an `AgentRunHandle` (`done`, `abort`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.132.0",
3
+ "version": "0.133.0",
4
4
  "description": "The SDK a Lotics custom-code app reads and writes through — typed hooks over the host bridge, cell readers, mount() and AppRouter",
5
5
  "type": "module",
6
6
  "exports": {