@colixsystems/widget-sdk 0.10.0 → 0.11.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
@@ -6,7 +6,12 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
6
6
 
7
7
  ## Status
8
8
 
9
- `v0.10.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**.
9
+ `v0.11.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**.
10
+
11
+ ### What's new in 0.11.0
12
+
13
+ - **`useNavigation()` is wired.** Returns the host-provided navigation surface `{ goTo, goBack, push, replace, back, currentRoute }` for internal page-to-page navigation. Missing methods degrade to no-ops on the Studio canvas preview. Additive.
14
+ - **`Linking` primitive re-exported.** `Linking.openURL(url)` opens an external URL with the OS handler — web (`react-native-web`) maps to `window.open` / `location.href`; native hands off to the system. Use this for external URLs; use `useNavigation().goTo(pageId)` for internal pages.
10
15
 
11
16
  ### What's new in 0.10.0
12
17
 
@@ -75,7 +80,7 @@ import { defineWidget, validateManifest, useDatastoreQuery, Text, View } from "@
75
80
 
76
81
  - `defineWidget({ manifest, component })` — validates the manifest and produces a widget module the host can register.
77
82
  - `validateManifest(m)` / `validatePropertySchema(s)` / `validateProps(schema, props)` — shape validation; no third-party deps.
78
- - `useDatastoreQuery`, `useDatastoreMutation`, `useDirectory`, `useWidgetEvent`, `usePayments`, `useTheme`, `useI18n`, `useUser` — hooks that read from the host-provided `WidgetContext`. `useDirectory(query?)` returns `{ users, loading, error, refetch }` (each user `{ id, name, role }`) and requires the `directory.read:users` scope. `usePayments()` returns `{ requestPayment, getPayment }` and requires the `payments.charge:appUser` scope; `requestPayment(...)` rejects with a `PaymentError`. `useUser()` returns the active end-user identity `{ id, email, displayName, roles, groupIds }` (`id` is `null` for anonymous / preview).
83
+ - `useDatastoreQuery`, `useDatastoreMutation`, `useDirectory`, `useWidgetEvent`, `usePayments`, `useTheme`, `useI18n`, `useUser`, `useNavigation` — hooks that read from the host-provided `WidgetContext`. `useDirectory(query?)` returns `{ users, loading, error, refetch }` (each user `{ id, name, role }`) and requires the `directory.read:users` scope. `usePayments()` returns `{ requestPayment, getPayment }` and requires the `payments.charge:appUser` scope; `requestPayment(...)` rejects with a `PaymentError`. `useUser()` returns the active end-user identity `{ id, email, displayName, roles, groupIds }` (`id` is `null` for anonymous / preview). `useNavigation()` returns `{ goTo, goBack, push, replace, back, currentRoute }` for internal page navigation — for external URLs use the `Linking` primitive (`Linking.openURL(url)`).
79
84
  - `Text`, `View`, `Pressable`, `Image`, `ScrollView`, `TextInput`, `FlatList`, `SectionList`, `ActivityIndicator`, `Switch`, `StyleSheet` — re-exported from `react-native`. The web build aliases `react-native` to `react-native-web` so widgets render in the browser without any per-platform code; the exported Expo app's Metro bundler resolves the real `react-native` library. See https://reactnative.dev/docs/ for per-component props.
80
85
  - `WidgetContextProvider` — React context provider that the host (Studio, Player, exported app) wraps widgets with.
81
86
 
package/dist/contract.cjs CHANGED
@@ -68,6 +68,20 @@ const HOOKS = [
68
68
  requiredContextSlice: ["user"],
69
69
  scopes: null,
70
70
  },
71
+ {
72
+ name: "useNavigation",
73
+ signature: "useNavigation()",
74
+ returnShape: {
75
+ goTo: "(pageId: string, params?: object) => void",
76
+ goBack: "() => void",
77
+ push: "(pageId: string, params?: object) => void",
78
+ replace: "(pageId: string, params?: object) => void",
79
+ back: "() => void",
80
+ currentRoute: "{ pageId: string, params: object }",
81
+ },
82
+ requiredContextSlice: ["navigation"],
83
+ scopes: null,
84
+ },
71
85
  {
72
86
  name: "useDatastoreQuery",
73
87
  signature: "useDatastoreQuery(tableId, options?)",
@@ -209,6 +223,13 @@ const PRIMITIVES = [
209
223
  rnComponent: "StyleSheet",
210
224
  docsUrl: "https://reactnative.dev/docs/stylesheet",
211
225
  },
226
+ {
227
+ name: "Linking",
228
+ description:
229
+ "Static API for external links. `Linking.openURL(url)` opens a URL with the OS handler (web: window.open / location.href via react-native-web). `canOpenURL` reports whether the scheme is registered. See https://reactnative.dev/docs/linking.",
230
+ rnComponent: "Linking",
231
+ docsUrl: "https://reactnative.dev/docs/linking",
232
+ },
212
233
  ];
213
234
 
214
235
  const CATEGORIES = [
package/dist/contract.js CHANGED
@@ -68,6 +68,20 @@ const HOOKS = [
68
68
  requiredContextSlice: ["user"],
69
69
  scopes: null,
70
70
  },
71
+ {
72
+ name: "useNavigation",
73
+ signature: "useNavigation()",
74
+ returnShape: {
75
+ goTo: "(pageId: string, params?: object) => void",
76
+ goBack: "() => void",
77
+ push: "(pageId: string, params?: object) => void",
78
+ replace: "(pageId: string, params?: object) => void",
79
+ back: "() => void",
80
+ currentRoute: "{ pageId: string, params: object }",
81
+ },
82
+ requiredContextSlice: ["navigation"],
83
+ scopes: null,
84
+ },
71
85
  {
72
86
  name: "useDatastoreQuery",
73
87
  signature: "useDatastoreQuery(tableId, options?)",
@@ -204,6 +218,13 @@ const PRIMITIVES = [
204
218
  rnComponent: "StyleSheet",
205
219
  docsUrl: "https://reactnative.dev/docs/stylesheet",
206
220
  },
221
+ {
222
+ name: "Linking",
223
+ description:
224
+ "Static API for external links. `Linking.openURL(url)` opens a URL with the OS handler (web: window.open / location.href via react-native-web). `canOpenURL` reports whether the scheme is registered. See https://reactnative.dev/docs/linking.",
225
+ rnComponent: "Linking",
226
+ docsUrl: "https://reactnative.dev/docs/linking",
227
+ },
207
228
  ];
208
229
 
209
230
  const CATEGORIES = [
package/dist/hooks.js CHANGED
@@ -370,6 +370,24 @@ export function useUser() {
370
370
  return ctx.user;
371
371
  }
372
372
 
373
+ /**
374
+ * Returns the host-provided navigation surface:
375
+ * `{ goTo, goBack, push, replace, back, currentRoute }`.
376
+ *
377
+ * `goTo(pageId, params?)` navigates to an internal app page. `goBack()`
378
+ * pops the stack. `push` / `replace` / `back` are aliases that map to
379
+ * the platform's native navigator (react-router on web, react-navigation
380
+ * on native). Missing methods degrade to no-ops on the Studio canvas
381
+ * preview, where there is no live router.
382
+ *
383
+ * For EXTERNAL URLs use the `Linking` primitive — `Linking.openURL(url)`
384
+ * works on both platforms.
385
+ */
386
+ export function useNavigation() {
387
+ const ctx = useWidgetContextOrThrow("useNavigation");
388
+ return ctx.navigation;
389
+ }
390
+
373
391
  /**
374
392
  * Structured error thrown by `usePayments` callbacks. Carries a stable
375
393
  * `code` so widgets can branch without parsing message strings.
package/dist/index.d.ts CHANGED
@@ -381,6 +381,32 @@ export function useUser(): {
381
381
  groupIds: string[];
382
382
  };
383
383
 
384
+ /**
385
+ * The host-provided navigation surface. `goTo(pageId, params?)` navigates
386
+ * to an internal app page; `goBack()` pops the stack. Missing methods
387
+ * degrade to no-ops on the Studio canvas preview where no live router is
388
+ * mounted. For external URLs use the `Linking` primitive.
389
+ */
390
+ export function useNavigation(): {
391
+ goTo(pageId: string, params?: Record<string, unknown>): void;
392
+ goBack(): void;
393
+ push(pageId: string, params?: Record<string, unknown>): void;
394
+ replace(pageId: string, params?: Record<string, unknown>): void;
395
+ back(): void;
396
+ currentRoute: { pageId: string; params: Record<string, unknown> };
397
+ };
398
+
399
+ /**
400
+ * Static API for external URLs. `openURL(url)` opens a URL with the OS
401
+ * handler (web: react-native-web maps to `window.open` / `location.href`;
402
+ * native: hands off to the system). `canOpenURL` reports whether the
403
+ * scheme is registered.
404
+ */
405
+ export const Linking: {
406
+ openURL(url: string): Promise<unknown>;
407
+ canOpenURL(url: string): Promise<boolean>;
408
+ };
409
+
384
410
  /**
385
411
  * Error class thrown by useDatastoreMutation callbacks (and surfaced by
386
412
  * useDatastoreQuery in its `error` slot). The `code` is a stable
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ export {
17
17
  useTheme,
18
18
  useI18n,
19
19
  useUser,
20
+ useNavigation,
20
21
  } from "./hooks.js";
21
22
  export {
22
23
  Text,
@@ -30,6 +31,7 @@ export {
30
31
  ActivityIndicator,
31
32
  Switch,
32
33
  StyleSheet,
34
+ Linking,
33
35
  } from "./primitives.js";
34
36
  export { lintSource, bannedIdentifiers } from "./linter.js";
35
37
  export { CONTRACT, isHookAllowed, requiredContextKeys } from "./contract.js";
@@ -17,6 +17,7 @@ export {
17
17
  useTheme,
18
18
  useI18n,
19
19
  useUser,
20
+ useNavigation,
20
21
  } from "./hooks.js";
21
22
  export {
22
23
  Text,
@@ -30,6 +31,7 @@ export {
30
31
  ActivityIndicator,
31
32
  Switch,
32
33
  StyleSheet,
34
+ Linking,
33
35
  } from "./primitives.native.js";
34
36
  export { lintSource, bannedIdentifiers } from "./linter.js";
35
37
  export { CONTRACT, isHookAllowed, requiredContextKeys } from "./contract.js";
@@ -55,3 +55,8 @@ export const SectionList = ReactNative.SectionList;
55
55
  export const ActivityIndicator = ReactNative.ActivityIndicator;
56
56
  export const Switch = ReactNative.Switch;
57
57
  export const StyleSheet = ReactNative.StyleSheet;
58
+ // Static API (not a component): `Linking.openURL(url)` opens an external
59
+ // URL — on web react-native-web uses window.open / location.href, on native
60
+ // the OS hands it off to the system handler. `canOpenURL` reports whether
61
+ // the URL scheme is registered.
62
+ export const Linking = ReactNative.Linking;
@@ -18,4 +18,5 @@ export {
18
18
  ActivityIndicator,
19
19
  Switch,
20
20
  StyleSheet,
21
+ Linking,
21
22
  } from "react-native";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",