@colixsystems/widget-sdk 0.126.0 → 0.127.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 +15 -1
- package/dist/contract.cjs +48 -1
- package/dist/contract.js +48 -1
- package/dist/dev-shims.js +8 -0
- package/package.json +1 -1
- package/src/dev-shims.js +8 -0
package/README.md
CHANGED
|
@@ -70,7 +70,21 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
70
70
|
|
|
71
71
|
## Status
|
|
72
72
|
|
|
73
|
-
`v0.
|
|
73
|
+
`v0.127.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**.
|
|
74
|
+
|
|
75
|
+
### What's new in 0.127.0 (contract 1.99.0)
|
|
76
|
+
|
|
77
|
+
**Widgets can do maths now — five pure-JS packages join the vetted import allowlist (sc-7191).** The list had 31 entries and exactly one non-UI utility (`date-fns`), so anything numeric a widget needed had to be hand-rolled in a sibling file. Two gaps in particular:
|
|
78
|
+
|
|
79
|
+
- `decimal.js` — exact decimal arithmetic. The platform has payments, invoicing and VAT, and a total accumulated in IEEE-754 floats drifts from what the backend actually charged. `new Decimal(a).plus(b).toFixed(2)` does not.
|
|
80
|
+
- `d3-scale` + `d3-shape` + `d3-array` — the scale, path-generator and domain maths a bespoke chart needs. `d3-shape` emits path strings you hand straight to the already-vetted `react-native-svg`'s `<Path d={…} />`, so a custom line/area/donut chart is ONE source file that renders identically in the Player and the Expo export.
|
|
81
|
+
- `simple-statistics` — mean/median/quantile/regression/correlation, for summarising a datastore table without shipping a maths framework.
|
|
82
|
+
|
|
83
|
+
All five are `platforms: ["web", "native"]` with no native module, so this is **full parity**, not a §8 native-only case. Each is host-shimmed in the Player and pinned in the export for the same reason `date-fns` is: an AI-agent widget is transpiled rather than bundled, so its bare import has to resolve at runtime on both hosts.
|
|
84
|
+
|
|
85
|
+
`mathjs` was considered and deliberately left off — 9.4 MB unpacked with nine transitive dependencies, and a web-vetted package is bundled into the Studio.
|
|
86
|
+
|
|
87
|
+
Additive: no existing entry, hook, primitive or `propertySchema` type changed shape. `CONTRACT.version` → `1.99.0`.
|
|
74
88
|
|
|
75
89
|
### What's new in 0.126.0 (contract 1.98.0)
|
|
76
90
|
|
package/dist/contract.cjs
CHANGED
|
@@ -2677,6 +2677,41 @@ const VETTED_IMPORTS = [
|
|
|
2677
2677
|
description:
|
|
2678
2678
|
"Device motion hardware on the Expo export: Accelerometer, Gyroscope, Magnetometer, DeviceMotion, Barometer, Pedometer and LightSensor, each read as an addListener subscription with setUpdateInterval — always remove the subscription on unmount, a sensor left running drains the battery. Expo SDK 56 ships 56.0.x. Native-only on purpose: the package's own web build derives acceleration from deviceorientation ANGLES rather than real motion, so a shake or tilt threshold tuned on one host would read differently on the other. Author it in widget.native.jsx and pair it with a widget.web.jsx reading window.DeviceMotionEvent (accelerationIncludingGravity / rotationRate), the browser API the same hardware exposes. Both hosts need a user gesture before readings start, and iOS Safari additionally needs an explicit DeviceMotionEvent.requestPermission() grant — so gate the reading behind a Pressable, never start it on mount.",
|
|
2679
2679
|
},
|
|
2680
|
+
{
|
|
2681
|
+
specifier: "decimal.js",
|
|
2682
|
+
platforms: ["web", "native"],
|
|
2683
|
+
category: "utility",
|
|
2684
|
+
description:
|
|
2685
|
+
"Arbitrary-precision decimal arithmetic. Reach for it whenever a widget computes MONEY: JavaScript numbers are binary floats, so a price total, a VAT line or a discount accumulated in `+`/`*` drifts by fractions of a cent and disagrees with what the backend charged. `new Decimal(a).plus(b).toFixed(2)` does not. Pure JS with zero dependencies, identical on both platforms. Not for general maths — it is slower than a number and only earns its cost where exactness is the point.",
|
|
2686
|
+
},
|
|
2687
|
+
{
|
|
2688
|
+
specifier: "d3-scale",
|
|
2689
|
+
platforms: ["web", "native"],
|
|
2690
|
+
category: "utility",
|
|
2691
|
+
description:
|
|
2692
|
+
"Maps data values to pixel positions — `scaleLinear`, `scaleTime`, `scaleBand`, `scaleOrdinal`, plus the `.ticks()` an axis is labelled from. The maths half of a custom chart; pair it with d3-shape for the path and react-native-svg to draw. Pure JS (its only deps are other d3 modules), so one implementation covers both platforms.",
|
|
2693
|
+
},
|
|
2694
|
+
{
|
|
2695
|
+
specifier: "d3-shape",
|
|
2696
|
+
platforms: ["web", "native"],
|
|
2697
|
+
category: "drawing",
|
|
2698
|
+
description:
|
|
2699
|
+
"SVG path generators — `line`, `area`, `arc`, `pie`, `curve*`. Each returns a path string you hand to the vetted react-native-svg's `<Path d={…} />`, so a bespoke line/area/donut chart renders identically in the Player and the Expo export from ONE source file. Pure JS.",
|
|
2700
|
+
},
|
|
2701
|
+
{
|
|
2702
|
+
specifier: "d3-array",
|
|
2703
|
+
platforms: ["web", "native"],
|
|
2704
|
+
category: "utility",
|
|
2705
|
+
description:
|
|
2706
|
+
"Array statistics and binning — `extent`, `min`/`max`, `bisect`, `bin`, `group`, `rollup`. Chiefly how you compute the domain d3-scale expects from a dataset. Pure JS.",
|
|
2707
|
+
},
|
|
2708
|
+
{
|
|
2709
|
+
specifier: "simple-statistics",
|
|
2710
|
+
platforms: ["web", "native"],
|
|
2711
|
+
category: "utility",
|
|
2712
|
+
description:
|
|
2713
|
+
"Descriptive statistics and simple models — mean/median/mode, standard deviation, quantiles, linear regression, correlation. Small and pure JS, so a widget can summarise a datastore table without shipping a maths framework. For exact decimal arithmetic (money) use decimal.js instead: this operates on JS numbers.",
|
|
2714
|
+
},
|
|
2680
2715
|
];
|
|
2681
2716
|
|
|
2682
2717
|
// sc-1064: CORE React infrastructure specifiers the host RESOLVES at runtime
|
|
@@ -3721,7 +3756,19 @@ const CONTRACT = deepFreeze({
|
|
|
3721
3756
|
// capability is the direction §8 forbids. The slice is OPTIONAL, so a host
|
|
3722
3757
|
// that brokers nothing degrades the hook to supported:false rather than
|
|
3723
3758
|
// throwing. Minor bump on the pre-1.0 channel.
|
|
3724
|
-
|
|
3759
|
+
// 1.99.0: additive (sc-7191) — the vetted import allowlist gains five PURE-JS
|
|
3760
|
+
// packages, the first non-UI maths available to a widget: `decimal.js`
|
|
3761
|
+
// (exact decimal arithmetic — the platform has payments, invoicing and
|
|
3762
|
+
// VAT, and float money math disagrees with what the backend charged),
|
|
3763
|
+
// `d3-scale` + `d3-shape` + `d3-array` (the scale/path/domain maths a
|
|
3764
|
+
// bespoke chart needs, drawn through the already-vetted react-native-svg),
|
|
3765
|
+
// and `simple-statistics`. All five are `["web", "native"]` with no native
|
|
3766
|
+
// module, so this is full parity, not a §8 native-only case. Each is
|
|
3767
|
+
// host-shimmed in widgetLoader.js and pinned in the export for the same
|
|
3768
|
+
// reason date-fns is: an AI-agent widget is transpiled, never bundled, so
|
|
3769
|
+
// its bare import must resolve at runtime on both hosts. No existing entry
|
|
3770
|
+
// changed shape — minor bump on the pre-1.0 channel.
|
|
3771
|
+
version: "1.99.0",
|
|
3725
3772
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
3726
3773
|
hooks: HOOKS,
|
|
3727
3774
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -2677,6 +2677,41 @@ const VETTED_IMPORTS = [
|
|
|
2677
2677
|
description:
|
|
2678
2678
|
"Device motion hardware on the Expo export: Accelerometer, Gyroscope, Magnetometer, DeviceMotion, Barometer, Pedometer and LightSensor, each read as an addListener subscription with setUpdateInterval — always remove the subscription on unmount, a sensor left running drains the battery. Expo SDK 56 ships 56.0.x. Native-only on purpose: the package's own web build derives acceleration from deviceorientation ANGLES rather than real motion, so a shake or tilt threshold tuned on one host would read differently on the other. Author it in widget.native.jsx and pair it with a widget.web.jsx reading window.DeviceMotionEvent (accelerationIncludingGravity / rotationRate), the browser API the same hardware exposes. Both hosts need a user gesture before readings start, and iOS Safari additionally needs an explicit DeviceMotionEvent.requestPermission() grant — so gate the reading behind a Pressable, never start it on mount.",
|
|
2679
2679
|
},
|
|
2680
|
+
{
|
|
2681
|
+
specifier: "decimal.js",
|
|
2682
|
+
platforms: ["web", "native"],
|
|
2683
|
+
category: "utility",
|
|
2684
|
+
description:
|
|
2685
|
+
"Arbitrary-precision decimal arithmetic. Reach for it whenever a widget computes MONEY: JavaScript numbers are binary floats, so a price total, a VAT line or a discount accumulated in `+`/`*` drifts by fractions of a cent and disagrees with what the backend charged. `new Decimal(a).plus(b).toFixed(2)` does not. Pure JS with zero dependencies, identical on both platforms. Not for general maths — it is slower than a number and only earns its cost where exactness is the point.",
|
|
2686
|
+
},
|
|
2687
|
+
{
|
|
2688
|
+
specifier: "d3-scale",
|
|
2689
|
+
platforms: ["web", "native"],
|
|
2690
|
+
category: "utility",
|
|
2691
|
+
description:
|
|
2692
|
+
"Maps data values to pixel positions — `scaleLinear`, `scaleTime`, `scaleBand`, `scaleOrdinal`, plus the `.ticks()` an axis is labelled from. The maths half of a custom chart; pair it with d3-shape for the path and react-native-svg to draw. Pure JS (its only deps are other d3 modules), so one implementation covers both platforms.",
|
|
2693
|
+
},
|
|
2694
|
+
{
|
|
2695
|
+
specifier: "d3-shape",
|
|
2696
|
+
platforms: ["web", "native"],
|
|
2697
|
+
category: "drawing",
|
|
2698
|
+
description:
|
|
2699
|
+
"SVG path generators — `line`, `area`, `arc`, `pie`, `curve*`. Each returns a path string you hand to the vetted react-native-svg's `<Path d={…} />`, so a bespoke line/area/donut chart renders identically in the Player and the Expo export from ONE source file. Pure JS.",
|
|
2700
|
+
},
|
|
2701
|
+
{
|
|
2702
|
+
specifier: "d3-array",
|
|
2703
|
+
platforms: ["web", "native"],
|
|
2704
|
+
category: "utility",
|
|
2705
|
+
description:
|
|
2706
|
+
"Array statistics and binning — `extent`, `min`/`max`, `bisect`, `bin`, `group`, `rollup`. Chiefly how you compute the domain d3-scale expects from a dataset. Pure JS.",
|
|
2707
|
+
},
|
|
2708
|
+
{
|
|
2709
|
+
specifier: "simple-statistics",
|
|
2710
|
+
platforms: ["web", "native"],
|
|
2711
|
+
category: "utility",
|
|
2712
|
+
description:
|
|
2713
|
+
"Descriptive statistics and simple models — mean/median/mode, standard deviation, quantiles, linear regression, correlation. Small and pure JS, so a widget can summarise a datastore table without shipping a maths framework. For exact decimal arithmetic (money) use decimal.js instead: this operates on JS numbers.",
|
|
2714
|
+
},
|
|
2680
2715
|
];
|
|
2681
2716
|
|
|
2682
2717
|
// sc-1064: CORE React infrastructure specifiers the host RESOLVES at runtime
|
|
@@ -3721,7 +3756,19 @@ const CONTRACT = deepFreeze({
|
|
|
3721
3756
|
// capability is the direction §8 forbids. The slice is OPTIONAL, so a host
|
|
3722
3757
|
// that brokers nothing degrades the hook to supported:false rather than
|
|
3723
3758
|
// throwing. Minor bump on the pre-1.0 channel.
|
|
3724
|
-
|
|
3759
|
+
// 1.99.0: additive (sc-7191) — the vetted import allowlist gains five PURE-JS
|
|
3760
|
+
// packages, the first non-UI maths available to a widget: `decimal.js`
|
|
3761
|
+
// (exact decimal arithmetic — the platform has payments, invoicing and
|
|
3762
|
+
// VAT, and float money math disagrees with what the backend charged),
|
|
3763
|
+
// `d3-scale` + `d3-shape` + `d3-array` (the scale/path/domain maths a
|
|
3764
|
+
// bespoke chart needs, drawn through the already-vetted react-native-svg),
|
|
3765
|
+
// and `simple-statistics`. All five are `["web", "native"]` with no native
|
|
3766
|
+
// module, so this is full parity, not a §8 native-only case. Each is
|
|
3767
|
+
// host-shimmed in widgetLoader.js and pinned in the export for the same
|
|
3768
|
+
// reason date-fns is: an AI-agent widget is transpiled, never bundled, so
|
|
3769
|
+
// its bare import must resolve at runtime on both hosts. No existing entry
|
|
3770
|
+
// changed shape — minor bump on the pre-1.0 channel.
|
|
3771
|
+
version: "1.99.0",
|
|
3725
3772
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
3726
3773
|
hooks: HOOKS,
|
|
3727
3774
|
primitives: PRIMITIVES,
|
package/dist/dev-shims.js
CHANGED
|
@@ -117,6 +117,14 @@ const HOST_EXTERNAL_SPECIFIERS = [
|
|
|
117
117
|
// bundle shares one RN-web (StyleSheet/context) instead of inlining a second
|
|
118
118
|
// copy. On native, Metro resolves the real react-native in the export.
|
|
119
119
|
"react-native",
|
|
120
|
+
// sc-7191: the vetted pure-JS maths set. Externalised for the same reason as
|
|
121
|
+
// date-fns — an AI-agent widget is transpiled, never bundled, so the host
|
|
122
|
+
// must resolve the bare import at runtime.
|
|
123
|
+
"decimal.js",
|
|
124
|
+
"d3-scale",
|
|
125
|
+
"d3-shape",
|
|
126
|
+
"d3-array",
|
|
127
|
+
"simple-statistics",
|
|
120
128
|
];
|
|
121
129
|
|
|
122
130
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.127.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/dev-shims.js
CHANGED
|
@@ -117,6 +117,14 @@ const HOST_EXTERNAL_SPECIFIERS = [
|
|
|
117
117
|
// bundle shares one RN-web (StyleSheet/context) instead of inlining a second
|
|
118
118
|
// copy. On native, Metro resolves the real react-native in the export.
|
|
119
119
|
"react-native",
|
|
120
|
+
// sc-7191: the vetted pure-JS maths set. Externalised for the same reason as
|
|
121
|
+
// date-fns — an AI-agent widget is transpiled, never bundled, so the host
|
|
122
|
+
// must resolve the bare import at runtime.
|
|
123
|
+
"decimal.js",
|
|
124
|
+
"d3-scale",
|
|
125
|
+
"d3-shape",
|
|
126
|
+
"d3-array",
|
|
127
|
+
"simple-statistics",
|
|
120
128
|
];
|
|
121
129
|
|
|
122
130
|
/**
|