@colixsystems/widget-sdk 0.307.0 → 0.309.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/README.md CHANGED
@@ -90,7 +90,17 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
90
90
 
91
91
  ## Status
92
92
 
93
- `v0.307.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
93
+ `v0.309.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
94
+
95
+ ### What's new in 0.309.0 (contract 1.253.0)
96
+
97
+ **Sibling files upload.** A package whose entry imports its own files (`import { step } from "./engine.js"`) now uploads, by npm or as a `.tgz`, instead of failing with `Could not resolve "./engine.js"`. Each entry has its siblings folded into it, so the web Player and the exported app both run one self-contained module. A sibling uses named exports only and is imported by name; a default export, `import * as`, a cycle or a `../` path is refused at upload with its file and line.
98
+
99
+ **`useSafeAreaInsets()` works on the web.** `react-native-safe-area-context` is now resolved by the host, like `react-native`, instead of being bundled into each widget. The web Player and the Studio canvas provide zero insets and the window as the frame, so `useSafeAreaInsets()` and `useSafeAreaFrame()` return values on the web as documented rather than throwing "No safe area value available". The exported app keeps the device's real insets. A widget bundled before this release carries its own copy and still throws on the web until it is published again.
100
+
101
+ ### What's new in 0.308.0 (contract 1.252.0)
102
+
103
+ **A filter can ask "is any of".** The records filter gains the `in` operator. In the array form, pass the values as an array: `filter: [{ column: "status", operator: "in", value: ["Open", "Waiting"] }]` keeps the rows whose status is either, in one request. On a list column (`STRING_ARRAY`, `INT_ARRAY`) it keeps the rows whose list holds any of the values, so a chip row with several picks needs one read, not one per pick or a fetched batch narrowed in JavaScript. It works on relation columns and `id`; it is refused on `created_at` / `updated_at`, on encrypted columns and with a `currentUser` / `currentUserGroup` value mode. At most 100 values, each valid for the column, or the read fails with `INVALID_FILTER`. An empty array throws a `ValidationError` instead of reading every row: leave the condition out when there is nothing to pick. A `filterList` property's conditions can use it too: the Studio's filter editor offers "is any of" and stores the values as an array. An array `value` with any other operator now throws a `ValidationError` instead of being sent as one joined value. Needs `@colixsystems/datastore-client` 0.27.0 in the host.
94
104
 
95
105
  ### What's new in 0.307.0 (contract 1.251.0)
96
106
 
@@ -3810,7 +3820,7 @@ export default function OpenTasks({ tableId, titleField, statusField }) {
3810
3820
  | `offset` | Rows to skip, for the next page. |
3811
3821
  | `includeCapabilities` | `true` stamps each row with `_capabilities`, what the signed-in user may do to it. |
3812
3822
 
3813
- The filter operators are `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `contains` (a case-insensitive substring), `empty` and `nempty` (no value). On a list column (`STRING_ARRAY`, `INT_ARRAY`), `eq` keeps the rows whose list holds the value exactly, `empty` / `nempty` test whether it holds any, and every other operator is refused. In the array form a condition may carry `valueMode`: `"currentUser"` or `"currentUserGroup"` with `eq` or `neq` matches the signed-in user (or their groups) on a USER or USER_GROUP column, and `"relativeDate"` with an ordering operator reads `value` as "that many days ago".
3823
+ The filter operators are `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `contains` (a case-insensitive substring), `in` (is any of), `empty` and `nempty` (no value). `in` takes an array `value` in the array form (`{ column, operator: "in", value: ["Open", "Waiting"] }`), at most 100 values; an empty array is refused (leave the condition out instead). On a list column (`STRING_ARRAY`, `INT_ARRAY`), `eq` keeps the rows whose list holds the value exactly, `in` the rows whose list holds any of the values, `empty` / `nempty` test whether it holds any, and every other operator is refused. In the array form a condition may carry `valueMode`: `"currentUser"` or `"currentUserGroup"` with `eq` or `neq` matches the signed-in user (or their groups) on a USER or USER_GROUP column, and `"relativeDate"` with an ordering operator reads `value` as "that many days ago".
3814
3824
 
3815
3825
  The result's `total` is how many rows match in all, not just this page. **A list that grows reads its rows with `usePagedDatastoreQuery(tableId, { pageSize, ...query })`**, which takes the same options bar `limit` / `offset`, sets those itself, and appends the next page on `loadMore()`. Declare `pageSize: PAGE_SIZE_PROPERTY` in the `propertySchema` so the maker sets the rows per page. For a count, a sum or an average, use `useDatastoreFigure(tableId, { aggregate, column, filter })` instead of reading rows.
3816
3826
 
@@ -3867,7 +3877,9 @@ here. Derives `supportedPlatforms: ["web", "native"]`.
3867
3877
  **2. Split implementation — `widget.web.jsx` + `widget.native.jsx`.** Pick this
3868
3878
  when the widget needs a package that only runs on ONE platform. Each file
3869
3879
  targets its platform and imports the package that works there; shared logic
3870
- lives in a sibling `./helper.js` both files import. This is the **canonical
3880
+ lives in a sibling `./helper.js` both files import (any entry may import
3881
+ sibling files; give them named exports only and import them by name, since the
3882
+ upload folds each into the entry that imports it). This is the **canonical
3871
3883
  pattern** for graphics, media, and any platform-divergent library:
3872
3884
 
3873
3885
  | Capability | `widget.native.jsx` | `widget.web.jsx` |
package/dist/contract.cjs CHANGED
@@ -1994,7 +1994,9 @@ const HOOKS = [
1994
1994
  "a write; the re-read is the same permission-checked read, and keeps the " +
1995
1995
  "rows on screen with loading false). Use it for lists other people " +
1996
1996
  "change: queues, bookings, chat, dashboards. Never poll with setInterval " +
1997
- "or wire useDatastoreSubscription for that.",
1997
+ "or wire useDatastoreSubscription for that. A `filter` condition " +
1998
+ "`{ column, operator: \"in\", value: [a, b] }` keeps rows whose value " +
1999
+ "is any of the list (a list column: holding any of it), at most 100 values.",
1998
2000
  returnShape: {
1999
2001
  data: "Record[]",
2000
2002
  total: "number | null",
@@ -2200,7 +2202,8 @@ const HOOKS = [
2200
2202
  },
2201
2203
  {
2202
2204
  name: "useAgent",
2203
- signature: "useAgent(agentRef, options?)",
2205
+ signature: "useAgent(agentRef, options)",
2206
+ optionalArgs: ["options"],
2204
2207
  description:
2205
2208
  "sc-7991 — hold a conversation with one of the WORKSPACE's own AI " +
2206
2209
  "agents (an author-written name + system prompt). IMPERATIVE: call " +
@@ -4083,6 +4086,8 @@ const ACTION_SCRIPT_GLOBALS = [
4083
4086
  "input",
4084
4087
  // sc-13843 — hands the app run its one JSON result.
4085
4088
  "respond",
4089
+ // sc-16548 — one turn of a workspace AI agent.
4090
+ "agents",
4086
4091
  ];
4087
4092
  // Mirrors action.service.js SCRIPT_MAX_BYTES.
4088
4093
  const ACTION_SCRIPT_MAX_BYTES = 200 * 1024;
@@ -5163,6 +5168,8 @@ const ALLOWED_BARE_IMPORTS = [
5163
5168
  // * react-native, lucide-react-native, react-native-svg,
5164
5169
  // react-native-qrcode-svg: share the host's react-native-web instance
5165
5170
  // (sc-1265, sc-6105).
5171
+ // * react-native-safe-area-context: its hooks read the host's provider,
5172
+ // which an inlined copy cannot see (sc-16577).
5166
5173
  // * date-fns and the maths set: an agent widget is transpiled, not
5167
5174
  // bundled, so the host must resolve its bare imports (sc-7191).
5168
5175
  const HOST_EXTERNAL_SPECIFIERS = [
@@ -5177,6 +5184,7 @@ const HOST_EXTERNAL_SPECIFIERS = [
5177
5184
  "date-fns",
5178
5185
  "react-native-qrcode-svg",
5179
5186
  "react-native",
5187
+ "react-native-safe-area-context",
5180
5188
  "decimal.js",
5181
5189
  "d3-scale",
5182
5190
  "d3-shape",
@@ -6936,7 +6944,13 @@ const CONTRACT = deepFreeze({
6936
6944
  // 1.251.0: additive (sc-16546) — `useAgent(agentRef, { files: true })`
6937
6945
  // reports `acceptsFiles` / `fileLimits`, `send(text, { files })` sends
6938
6946
  // images and PDFs, and the `agents` client gains `capabilities()`.
6939
- version: "1.251.0",
6947
+ // 1.252.0: additive — the records filter gains `in` ("is any of"). A
6948
+ // `filterList` condition and a query's array-form `filter` take
6949
+ // `{ operator: "in", value: [a, b] }`; on a list column it matches a row
6950
+ // holding any of the values. At most 100; no `valueMode` applies.
6951
+ // 1.253.0: fix (sc-16577) — `react-native-safe-area-context` is host-resolved,
6952
+ // so `useSafeAreaInsets()` returns zeros on web as documented instead of throwing.
6953
+ version: "1.253.0",
6940
6954
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6941
6955
  hooks: HOOKS,
6942
6956
  primitives: PRIMITIVES,
package/dist/contract.js CHANGED
@@ -1989,7 +1989,9 @@ const HOOKS = [
1989
1989
  "a write; the re-read is the same permission-checked read, and keeps the " +
1990
1990
  "rows on screen with loading false). Use it for lists other people " +
1991
1991
  "change: queues, bookings, chat, dashboards. Never poll with setInterval " +
1992
- "or wire useDatastoreSubscription for that.",
1992
+ "or wire useDatastoreSubscription for that. A `filter` condition " +
1993
+ "`{ column, operator: \"in\", value: [a, b] }` keeps rows whose value " +
1994
+ "is any of the list (a list column: holding any of it), at most 100 values.",
1993
1995
  returnShape: {
1994
1996
  data: "Record[]",
1995
1997
  total: "number | null",
@@ -2195,7 +2197,8 @@ const HOOKS = [
2195
2197
  },
2196
2198
  {
2197
2199
  name: "useAgent",
2198
- signature: "useAgent(agentRef, options?)",
2200
+ signature: "useAgent(agentRef, options)",
2201
+ optionalArgs: ["options"],
2199
2202
  description:
2200
2203
  "sc-7991 — hold a conversation with one of the WORKSPACE's own AI " +
2201
2204
  "agents (an author-written name + system prompt). IMPERATIVE: call " +
@@ -4078,6 +4081,8 @@ const ACTION_SCRIPT_GLOBALS = [
4078
4081
  "input",
4079
4082
  // sc-13843 — hands the app run its one JSON result.
4080
4083
  "respond",
4084
+ // sc-16548 — one turn of a workspace AI agent.
4085
+ "agents",
4081
4086
  ];
4082
4087
  // Mirrors action.service.js SCRIPT_MAX_BYTES.
4083
4088
  const ACTION_SCRIPT_MAX_BYTES = 200 * 1024;
@@ -5158,6 +5163,8 @@ const ALLOWED_BARE_IMPORTS = [
5158
5163
  // * react-native, lucide-react-native, react-native-svg,
5159
5164
  // react-native-qrcode-svg: share the host's react-native-web instance
5160
5165
  // (sc-1265, sc-6105).
5166
+ // * react-native-safe-area-context: its hooks read the host's provider,
5167
+ // which an inlined copy cannot see (sc-16577).
5161
5168
  // * date-fns and the maths set: an agent widget is transpiled, not
5162
5169
  // bundled, so the host must resolve its bare imports (sc-7191).
5163
5170
  const HOST_EXTERNAL_SPECIFIERS = [
@@ -5172,6 +5179,7 @@ const HOST_EXTERNAL_SPECIFIERS = [
5172
5179
  "date-fns",
5173
5180
  "react-native-qrcode-svg",
5174
5181
  "react-native",
5182
+ "react-native-safe-area-context",
5175
5183
  "decimal.js",
5176
5184
  "d3-scale",
5177
5185
  "d3-shape",
@@ -6931,7 +6939,13 @@ const CONTRACT = deepFreeze({
6931
6939
  // 1.251.0: additive (sc-16546) — `useAgent(agentRef, { files: true })`
6932
6940
  // reports `acceptsFiles` / `fileLimits`, `send(text, { files })` sends
6933
6941
  // images and PDFs, and the `agents` client gains `capabilities()`.
6934
- version: "1.251.0",
6942
+ // 1.252.0: additive — the records filter gains `in` ("is any of"). A
6943
+ // `filterList` condition and a query's array-form `filter` take
6944
+ // `{ operator: "in", value: [a, b] }`; on a list column it matches a row
6945
+ // holding any of the values. At most 100; no `valueMode` applies.
6946
+ // 1.253.0: fix (sc-16577) — `react-native-safe-area-context` is host-resolved,
6947
+ // so `useSafeAreaInsets()` returns zeros on web as documented instead of throwing.
6948
+ version: "1.253.0",
6935
6949
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6936
6950
  hooks: HOOKS,
6937
6951
  primitives: PRIMITIVES,
package/dist/devserver.js CHANGED
@@ -82,8 +82,11 @@ import { bundleWebEntry } from "./webbundle.js";
82
82
  import {
83
83
  findImportStatements,
84
84
  findRelativeImportStatements,
85
+ resolveRelativeImport,
85
86
  } from "./flatten-entry.js";
86
87
 
88
+ export { resolveRelativeImport };
89
+
87
90
  // Bare-import / relative-import detection. The loader rewrites bare specifiers
88
91
  // in the ENTRY to client-side blob shims, so they resolve fine. Relative
89
92
  // imports in a SINGLE-FILE entry have nowhere to resolve — single-file mode
@@ -172,35 +175,6 @@ export function findRelativeImports(source) {
172
175
  );
173
176
  }
174
177
 
175
- /**
176
- * Resolve a relative specifier (`./foo` / `../bar/baz`) into an absolute
177
- * `/file/<rel>` path under the widget directory. The result is what the dev
178
- * server serves and what the browser fetches. Returns null when the resolved
179
- * path escapes the widget directory — the caller refuses to bundle it.
180
- *
181
- * Specifiers without a `.jsx`/`.js`/`.json` extension get a `.jsx` default so
182
- * `import Helper from "./helper"` works without forcing the author to type
183
- * the extension (matches Vite / Metro behaviour).
184
- *
185
- * @param {string} fromRel the rel-path of the importing file (POSIX-style,
186
- * relative to the widget dir, e.g. "MapWidget.web.jsx" or "lib/util.jsx").
187
- * @param {string} specifier the relative specifier as written in source.
188
- * @returns {string | null} POSIX-style rel-path under the widget dir, or null
189
- * if the resolution escapes it.
190
- */
191
- export function resolveRelativeImport(fromRel, specifier) {
192
- if (!specifier.startsWith("./") && !specifier.startsWith("../")) return null;
193
- const fromDir = posix.dirname(fromRel.replace(/\\/g, "/"));
194
- const joined = posix.normalize(posix.join(fromDir, specifier));
195
- if (joined.startsWith("..") || joined.startsWith("/")) return null;
196
- // Default the extension when omitted. A specifier with a non-JS extension
197
- // (asset imports like `./icon.svg`) is rejected — the dev server only
198
- // serves JS modules; static asset bundling needs a real build step.
199
- if (/\.(jsx?|json)$/.test(joined)) return joined;
200
- if (/\.[A-Za-z0-9]+$/.test(joined)) return null;
201
- return `${joined}.jsx`;
202
- }
203
-
204
178
  /**
205
179
  * Rewrite imports inside a served file so the browser can resolve every
206
180
  * specifier without help from the host loader:
@@ -31,6 +31,7 @@
31
31
  // a declaration capturing another module's free reference is not detectable
32
32
  // without scope analysis this deliberately does not do.
33
33
 
34
+ import { posix } from "node:path";
34
35
  import { stripNonCode } from "./source-mask.js";
35
36
 
36
37
  // ---------------------------------------------------------------------------
@@ -815,3 +816,32 @@ export function flattenEntry({ entryRel, readModule, resolve, parse }) {
815
816
  // which parses cleanly and does the wrong thing.
816
817
  return { source: parts.join("\n;\n"), modules: [entryRel, ...siblings] };
817
818
  }
819
+
820
+ /**
821
+ * Resolve a relative specifier (`./foo` / `../bar/baz`) into a POSIX rel-path
822
+ * under the widget directory: what the dev server serves and what the
823
+ * packer and the hosted upload inline (sc-16577). Returns null when the resolved
824
+ * path escapes the widget directory — the caller refuses to bundle it.
825
+ *
826
+ * Specifiers without a `.jsx`/`.js`/`.json` extension get a `.jsx` default so
827
+ * `import Helper from "./helper"` works without forcing the author to type
828
+ * the extension (matches Vite / Metro behaviour).
829
+ *
830
+ * @param {string} fromRel the rel-path of the importing file (POSIX-style,
831
+ * relative to the widget dir, e.g. "MapWidget.web.jsx" or "lib/util.jsx").
832
+ * @param {string} specifier the relative specifier as written in source.
833
+ * @returns {string | null} POSIX-style rel-path under the widget dir, or null
834
+ * if the resolution escapes it.
835
+ */
836
+ export function resolveRelativeImport(fromRel, specifier) {
837
+ if (!specifier.startsWith("./") && !specifier.startsWith("../")) return null;
838
+ const fromDir = posix.dirname(fromRel.replace(/\\/g, "/"));
839
+ const joined = posix.normalize(posix.join(fromDir, specifier));
840
+ if (joined.startsWith("..") || joined.startsWith("/")) return null;
841
+ // Default the extension when omitted. A specifier with a non-JS extension
842
+ // (asset imports like `./icon.svg`) is rejected — the dev server only
843
+ // serves JS modules; static asset bundling needs a real build step.
844
+ if (/\.(jsx?|json)$/.test(joined)) return joined;
845
+ if (/\.[A-Za-z0-9]+$/.test(joined)) return null;
846
+ return `${joined}.jsx`;
847
+ }
package/dist/index.d.ts CHANGED
@@ -72,7 +72,8 @@ export type WidgetPropertyType =
72
72
  // (ordering operators on a DATE column — `value` is "N days ago"), or the
73
73
  // sc-6282 actor-scoped pair `currentUser` (USER column) / `currentUserGroup`
74
74
  // (USER_GROUP column), which drop `value` and let the SERVER scope the
75
- // condition to the signed-in app-user.
75
+ // condition to the signed-in app-user. The `in` operator ("is any of") takes
76
+ // an array `value` of at most 100 members and no `valueMode`.
76
77
  | "filterList";
77
78
 
78
79
  export interface WidgetPropertyDef {
@@ -1129,7 +1130,11 @@ export function hasCornerRadius(
1129
1130
 
1130
1131
  /** A record query the datastore applies on the server; see the README's "Querying records". */
1131
1132
  export interface Query {
1132
- /** `{ column: "op:value" }` (an array of expressions for a range), or `[{ column, operator, value, valueMode }]`. */
1133
+ /**
1134
+ * `{ column: "op:value" }` (an array of expressions for a range), or
1135
+ * `[{ column, operator, value, valueMode }]`. Operator `"in"` takes an array
1136
+ * `value` (at most 100) and keeps rows whose value is any of it.
1137
+ */
1133
1138
  filter?:
1134
1139
  | Record<string, string | string[]>
1135
1140
  | Array<{ column: string; operator?: string; value?: unknown; valueMode?: string }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.307.0",
3
+ "version": "0.309.0",
4
4
  "description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
5
5
  "homepage": "https://github.com/Colix-AB/AppStudio",
6
6
  "type": "module",
package/src/contract.js CHANGED
@@ -1989,7 +1989,9 @@ const HOOKS = [
1989
1989
  "a write; the re-read is the same permission-checked read, and keeps the " +
1990
1990
  "rows on screen with loading false). Use it for lists other people " +
1991
1991
  "change: queues, bookings, chat, dashboards. Never poll with setInterval " +
1992
- "or wire useDatastoreSubscription for that.",
1992
+ "or wire useDatastoreSubscription for that. A `filter` condition " +
1993
+ "`{ column, operator: \"in\", value: [a, b] }` keeps rows whose value " +
1994
+ "is any of the list (a list column: holding any of it), at most 100 values.",
1993
1995
  returnShape: {
1994
1996
  data: "Record[]",
1995
1997
  total: "number | null",
@@ -2195,7 +2197,8 @@ const HOOKS = [
2195
2197
  },
2196
2198
  {
2197
2199
  name: "useAgent",
2198
- signature: "useAgent(agentRef, options?)",
2200
+ signature: "useAgent(agentRef, options)",
2201
+ optionalArgs: ["options"],
2199
2202
  description:
2200
2203
  "sc-7991 — hold a conversation with one of the WORKSPACE's own AI " +
2201
2204
  "agents (an author-written name + system prompt). IMPERATIVE: call " +
@@ -4078,6 +4081,8 @@ const ACTION_SCRIPT_GLOBALS = [
4078
4081
  "input",
4079
4082
  // sc-13843 — hands the app run its one JSON result.
4080
4083
  "respond",
4084
+ // sc-16548 — one turn of a workspace AI agent.
4085
+ "agents",
4081
4086
  ];
4082
4087
  // Mirrors action.service.js SCRIPT_MAX_BYTES.
4083
4088
  const ACTION_SCRIPT_MAX_BYTES = 200 * 1024;
@@ -5158,6 +5163,8 @@ const ALLOWED_BARE_IMPORTS = [
5158
5163
  // * react-native, lucide-react-native, react-native-svg,
5159
5164
  // react-native-qrcode-svg: share the host's react-native-web instance
5160
5165
  // (sc-1265, sc-6105).
5166
+ // * react-native-safe-area-context: its hooks read the host's provider,
5167
+ // which an inlined copy cannot see (sc-16577).
5161
5168
  // * date-fns and the maths set: an agent widget is transpiled, not
5162
5169
  // bundled, so the host must resolve its bare imports (sc-7191).
5163
5170
  const HOST_EXTERNAL_SPECIFIERS = [
@@ -5172,6 +5179,7 @@ const HOST_EXTERNAL_SPECIFIERS = [
5172
5179
  "date-fns",
5173
5180
  "react-native-qrcode-svg",
5174
5181
  "react-native",
5182
+ "react-native-safe-area-context",
5175
5183
  "decimal.js",
5176
5184
  "d3-scale",
5177
5185
  "d3-shape",
@@ -6931,7 +6939,13 @@ const CONTRACT = deepFreeze({
6931
6939
  // 1.251.0: additive (sc-16546) — `useAgent(agentRef, { files: true })`
6932
6940
  // reports `acceptsFiles` / `fileLimits`, `send(text, { files })` sends
6933
6941
  // images and PDFs, and the `agents` client gains `capabilities()`.
6934
- version: "1.251.0",
6942
+ // 1.252.0: additive — the records filter gains `in` ("is any of"). A
6943
+ // `filterList` condition and a query's array-form `filter` take
6944
+ // `{ operator: "in", value: [a, b] }`; on a list column it matches a row
6945
+ // holding any of the values. At most 100; no `valueMode` applies.
6946
+ // 1.253.0: fix (sc-16577) — `react-native-safe-area-context` is host-resolved,
6947
+ // so `useSafeAreaInsets()` returns zeros on web as documented instead of throwing.
6948
+ version: "1.253.0",
6935
6949
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6936
6950
  hooks: HOOKS,
6937
6951
  primitives: PRIMITIVES,