@colixsystems/widget-sdk 0.1.0 → 0.2.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,7 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
6
6
 
7
7
  ## Status
8
8
 
9
- `v0.1.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.2.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
10
 
11
11
  ## Public API
12
12
 
package/dist/index.d.ts CHANGED
@@ -118,15 +118,38 @@ export interface WidgetContext<TProps = unknown> {
118
118
  };
119
119
  }
120
120
 
121
- export interface WidgetModule<TProps = unknown> {
121
+ /**
122
+ * The widget's component receives the author-authored props **as React
123
+ * props** — the same shape and calling convention every built-in widget
124
+ * uses (`<MetricWidget tableId={...} sumField={...} />`). Everything
125
+ * else from `WidgetContext` (datastore, user, workspace, navigation,
126
+ * i18n, …) is reachable via the SDK hooks (`useDatastoreMutation`,
127
+ * `useDatastoreQuery`, `useTheme`, `useI18n`, `useWidgetEvent`), which
128
+ * read from the host-mounted `WidgetContextProvider`.
129
+ *
130
+ * function Counter({ tableId }) { // ← props
131
+ * const mut = useDatastoreMutation(tableId); // ← rest via hook
132
+ * const { t } = useI18n();
133
+ * return ...;
134
+ * }
135
+ *
136
+ * Note: earlier versions of this typing passed the entire
137
+ * `WidgetContext` as the first argument. That was changed to the props-
138
+ * spread form so marketplace widgets follow the same interface as
139
+ * built-ins. Widgets that previously did `function Widget(ctx) { const
140
+ * { table } = ctx.props; }` should rewrite to
141
+ * `function Widget({ table }) { … }` and reach for hooks for anything
142
+ * else they need.
143
+ */
144
+ export interface WidgetModule<TProps = Record<string, unknown>> {
122
145
  manifest: WidgetManifest;
123
- component: (ctx: WidgetContext<TProps>) => JSX.Element;
146
+ component: (props: TProps) => JSX.Element;
124
147
  _kind: "appstudio-widget-module";
125
148
  }
126
149
 
127
- export function defineWidget<TProps = unknown>(opts: {
150
+ export function defineWidget<TProps = Record<string, unknown>>(opts: {
128
151
  manifest: WidgetManifest;
129
- component: (ctx: WidgetContext<TProps>) => JSX.Element;
152
+ component: (props: TProps) => JSX.Element;
130
153
  }): WidgetModule<TProps>;
131
154
 
132
155
  export function validateManifest(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.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",