@colixsystems/widget-sdk 0.149.1 → 0.150.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.
@@ -91,6 +91,11 @@ export function normaliseThemeComponents(raw) {
91
91
  }
92
92
 
93
93
 
94
+ // Long enough for a hex, an enum value or a font name; short enough that a
95
+ // hand-edited theme_config cannot smuggle a payload into every widget.
96
+ // Named because the Mason plan gate prints it when it rejects a value.
97
+ export const MAX_STYLE_STRING_LENGTH = 64;
98
+
94
99
  // Values are assigned onto plain object literals, so `__proto__` would set a
95
100
  // PROTOTYPE rather than a style field. Refused at every level.
96
101
  const UNSAFE_STYLE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
@@ -117,9 +122,9 @@ function coerceWidgetStyleValue(value, depth = 0) {
117
122
  const { maxValueDepth, maxValueEntries } = CONTRACT.themeWidgetStyles;
118
123
  if (typeof value === "string") {
119
124
  const trimmed = value.trim();
120
- // Long enough for a hex, an enum value or a font name; short enough that a
121
- // hand-edited theme_config cannot smuggle a payload into every widget.
122
- return trimmed && trimmed.length <= 64 ? trimmed : undefined;
125
+ return trimmed && trimmed.length <= MAX_STYLE_STRING_LENGTH
126
+ ? trimmed
127
+ : undefined;
123
128
  }
124
129
  if (typeof value === "number") return Number.isFinite(value) ? value : undefined;
125
130
  if (typeof value === "boolean") return value;
@@ -157,7 +162,7 @@ function coerceWidgetStyleValue(value, depth = 0) {
157
162
  }
158
163
 
159
164
  // What the value actually costs the cold-start read and the baked export.
160
- function styleValueBytes(value) {
165
+ export function styleValueBytes(value) {
161
166
  const json = JSON.stringify(value);
162
167
  return typeof json === "string" ? json.length : Infinity;
163
168
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.149.1",
3
+ "version": "0.150.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",