@colixsystems/widget-sdk 0.308.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,13 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
90
90
 
91
91
  ## Status
92
92
 
93
- `v0.308.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.
94
100
 
95
101
  ### What's new in 0.308.0 (contract 1.252.0)
96
102
 
@@ -3871,7 +3877,9 @@ here. Derives `supportedPlatforms: ["web", "native"]`.
3871
3877
  **2. Split implementation — `widget.web.jsx` + `widget.native.jsx`.** Pick this
3872
3878
  when the widget needs a package that only runs on ONE platform. Each file
3873
3879
  targets its platform and imports the package that works there; shared logic
3874
- 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
3875
3883
  pattern** for graphics, media, and any platform-divergent library:
3876
3884
 
3877
3885
  | Capability | `widget.native.jsx` | `widget.web.jsx` |
package/dist/contract.cjs CHANGED
@@ -5168,6 +5168,8 @@ const ALLOWED_BARE_IMPORTS = [
5168
5168
  // * react-native, lucide-react-native, react-native-svg,
5169
5169
  // react-native-qrcode-svg: share the host's react-native-web instance
5170
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).
5171
5173
  // * date-fns and the maths set: an agent widget is transpiled, not
5172
5174
  // bundled, so the host must resolve its bare imports (sc-7191).
5173
5175
  const HOST_EXTERNAL_SPECIFIERS = [
@@ -5182,6 +5184,7 @@ const HOST_EXTERNAL_SPECIFIERS = [
5182
5184
  "date-fns",
5183
5185
  "react-native-qrcode-svg",
5184
5186
  "react-native",
5187
+ "react-native-safe-area-context",
5185
5188
  "decimal.js",
5186
5189
  "d3-scale",
5187
5190
  "d3-shape",
@@ -6945,7 +6948,9 @@ const CONTRACT = deepFreeze({
6945
6948
  // `filterList` condition and a query's array-form `filter` take
6946
6949
  // `{ operator: "in", value: [a, b] }`; on a list column it matches a row
6947
6950
  // holding any of the values. At most 100; no `valueMode` applies.
6948
- version: "1.252.0",
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",
6949
6954
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6950
6955
  hooks: HOOKS,
6951
6956
  primitives: PRIMITIVES,
package/dist/contract.js CHANGED
@@ -5163,6 +5163,8 @@ const ALLOWED_BARE_IMPORTS = [
5163
5163
  // * react-native, lucide-react-native, react-native-svg,
5164
5164
  // react-native-qrcode-svg: share the host's react-native-web instance
5165
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).
5166
5168
  // * date-fns and the maths set: an agent widget is transpiled, not
5167
5169
  // bundled, so the host must resolve its bare imports (sc-7191).
5168
5170
  const HOST_EXTERNAL_SPECIFIERS = [
@@ -5177,6 +5179,7 @@ const HOST_EXTERNAL_SPECIFIERS = [
5177
5179
  "date-fns",
5178
5180
  "react-native-qrcode-svg",
5179
5181
  "react-native",
5182
+ "react-native-safe-area-context",
5180
5183
  "decimal.js",
5181
5184
  "d3-scale",
5182
5185
  "d3-shape",
@@ -6940,7 +6943,9 @@ const CONTRACT = deepFreeze({
6940
6943
  // `filterList` condition and a query's array-form `filter` take
6941
6944
  // `{ operator: "in", value: [a, b] }`; on a list column it matches a row
6942
6945
  // holding any of the values. At most 100; no `valueMode` applies.
6943
- version: "1.252.0",
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",
6944
6949
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6945
6950
  hooks: HOOKS,
6946
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.308.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
@@ -5163,6 +5163,8 @@ const ALLOWED_BARE_IMPORTS = [
5163
5163
  // * react-native, lucide-react-native, react-native-svg,
5164
5164
  // react-native-qrcode-svg: share the host's react-native-web instance
5165
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).
5166
5168
  // * date-fns and the maths set: an agent widget is transpiled, not
5167
5169
  // bundled, so the host must resolve its bare imports (sc-7191).
5168
5170
  const HOST_EXTERNAL_SPECIFIERS = [
@@ -5177,6 +5179,7 @@ const HOST_EXTERNAL_SPECIFIERS = [
5177
5179
  "date-fns",
5178
5180
  "react-native-qrcode-svg",
5179
5181
  "react-native",
5182
+ "react-native-safe-area-context",
5180
5183
  "decimal.js",
5181
5184
  "d3-scale",
5182
5185
  "d3-shape",
@@ -6940,7 +6943,9 @@ const CONTRACT = deepFreeze({
6940
6943
  // `filterList` condition and a query's array-form `filter` take
6941
6944
  // `{ operator: "in", value: [a, b] }`; on a list column it matches a row
6942
6945
  // holding any of the values. At most 100; no `valueMode` applies.
6943
- version: "1.252.0",
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",
6944
6949
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6945
6950
  hooks: HOOKS,
6946
6951
  primitives: PRIMITIVES,