@pixerate/editor 0.177.0 → 0.177.1

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.
@@ -597,6 +597,11 @@ var EFFECT_USE_LABELS = {
597
597
  };
598
598
  var HEX2 = /^#[0-9a-f]{6}([0-9a-f]{2})?$/i;
599
599
  var typeOf = (s) => Array.isArray(s.type) ? s.type.find((t) => t !== "null") : s.type;
600
+ function hexColour(value) {
601
+ if (typeof value === "string") return HEX2.test(value) ? value : void 0;
602
+ if (!Array.isArray(value) || value.length !== 3 && value.length !== 4 || !value.every((n) => typeof n === "number" && Number.isFinite(n))) return void 0;
603
+ return `#${value.map((n) => Math.round(Math.min(1, Math.max(0, n)) * 255).toString(16).padStart(2, "0")).join("")}`;
604
+ }
600
605
  function isEffectFontControl(schema) {
601
606
  return typeOf(schema) === "string" && (schema.format === "font" || schema["x-pixerate-control"] === "font");
602
607
  }
@@ -649,7 +654,10 @@ function effectFontFamilies(description, values = {}) {
649
654
  }
650
655
  return out;
651
656
  }
652
- var effectFieldValue = (field, value) => value === void 0 || value === null || typeof value === "object" && !Array.isArray(value) ? field.default : value;
657
+ var effectFieldValue = (field, value) => {
658
+ if (field.type === "color") return _nullishCoalesce(hexColour(value), () => ( field.default));
659
+ return value === void 0 || value === null || typeof value === "object" && !Array.isArray(value) ? field.default : value;
660
+ };
653
661
  function effectSamplePicture(width, height, variant = 0) {
654
662
  const p = _chunkA3A5TI6Rcjs.createEffectPixels.call(void 0, width, height);
655
663
  for (let y = 0, i = 0; y < height; y++) {
@@ -597,6 +597,11 @@ var EFFECT_USE_LABELS = {
597
597
  };
598
598
  var HEX2 = /^#[0-9a-f]{6}([0-9a-f]{2})?$/i;
599
599
  var typeOf = (s) => Array.isArray(s.type) ? s.type.find((t) => t !== "null") : s.type;
600
+ function hexColour(value) {
601
+ if (typeof value === "string") return HEX2.test(value) ? value : void 0;
602
+ if (!Array.isArray(value) || value.length !== 3 && value.length !== 4 || !value.every((n) => typeof n === "number" && Number.isFinite(n))) return void 0;
603
+ return `#${value.map((n) => Math.round(Math.min(1, Math.max(0, n)) * 255).toString(16).padStart(2, "0")).join("")}`;
604
+ }
600
605
  function isEffectFontControl(schema) {
601
606
  return typeOf(schema) === "string" && (schema.format === "font" || schema["x-pixerate-control"] === "font");
602
607
  }
@@ -649,7 +654,10 @@ function effectFontFamilies(description, values = {}) {
649
654
  }
650
655
  return out;
651
656
  }
652
- var effectFieldValue = (field, value) => value === void 0 || value === null || typeof value === "object" && !Array.isArray(value) ? field.default : value;
657
+ var effectFieldValue = (field, value) => {
658
+ if (field.type === "color") return hexColour(value) ?? field.default;
659
+ return value === void 0 || value === null || typeof value === "object" && !Array.isArray(value) ? field.default : value;
660
+ };
653
661
  function effectSamplePicture(width, height, variant = 0) {
654
662
  const p = createEffectPixels(width, height);
655
663
  for (let y = 0, i = 0; y < height; y++) {
@@ -27,7 +27,10 @@ export declare function effectParameterFields(description: Pick<EffectDescriptio
27
27
  * to load with `ensureFontsLoaded` before rendering a title preview.
28
28
  */
29
29
  export declare function effectFontFamilies(description: Pick<EffectDescription, 'controls' | 'defaults'>, values?: Readonly<Record<string, unknown>>): string[];
30
- /** A saved value as a field shows it (`ParameterValue`), or the field's default. */
30
+ /**
31
+ * A saved value as a field shows it (`ParameterValue`), or the field's default. Colour fields show
32
+ * channel arrays as hex, and the default for values they can't show (`"currentColor"`, `rgb(…)`).
33
+ */
31
34
  export declare const effectFieldValue: (field: ParameterField, value: unknown) => ParameterValue;
32
35
  /**
33
36
  * A colourful, deterministic picture for previews of filters and transitions (`variant` 0 and 1
@@ -27,7 +27,10 @@ export declare function effectParameterFields(description: Pick<EffectDescriptio
27
27
  * to load with `ensureFontsLoaded` before rendering a title preview.
28
28
  */
29
29
  export declare function effectFontFamilies(description: Pick<EffectDescription, 'controls' | 'defaults'>, values?: Readonly<Record<string, unknown>>): string[];
30
- /** A saved value as a field shows it (`ParameterValue`), or the field's default. */
30
+ /**
31
+ * A saved value as a field shows it (`ParameterValue`), or the field's default. Colour fields show
32
+ * channel arrays as hex, and the default for values they can't show (`"currentColor"`, `rgb(…)`).
33
+ */
31
34
  export declare const effectFieldValue: (field: ParameterField, value: unknown) => ParameterValue;
32
35
  /**
33
36
  * A colourful, deterministic picture for previews of filters and transitions (`variant` 0 and 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.177.0",
3
+ "version": "0.177.1",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -49,6 +49,11 @@ For general error reporting and undo conventions, see `pixerate-agent-tools`.
49
49
 
50
50
  - **Batch parameter changes.** Set all related control values in a single `effect_authoring_set_values`
51
51
  call so they apply cleanly in a single undo step.
52
+ - **Write colours as hex.** A control with `type: "color"` in `effect_authoring_describe` takes
53
+ `#rrggbb` (or `#rrggbbaa` when `alpha` is true), even when the provider's schema also accepts 0–1
54
+ channel arrays or CSS colour strings (Flair's colours do). Hex keyframes blend smoothly. A control
55
+ that is in `values` but has no entry in `controls` has a shape no field can edit. Set it only with a
56
+ value that matches the provider's schema.
52
57
  - **Check compile issues.** When editing source code via `effect_authoring_set_source`, always verify
53
58
  the returned `issues` array. Fix errors before attempting to preview or set controls.
54
59
  - **Keyframe animation tracks.** Controls with active keyframes calculate their values dynamically