sketchmark 2.1.3 → 2.1.5

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/bin/editor-ui.cjs CHANGED
@@ -686,7 +686,7 @@ function renderInspector() {
686
686
  const element = findElement(selectedId);
687
687
  const exportPanel = renderExportPanel();
688
688
  if (!element) {
689
- inspector.innerHTML = exportPanel + "<div class='muted'>Select an element.</div>";
689
+ inspector.innerHTML = "<div class='muted'>Select an element.</div>" + exportPanel;
690
690
  bindPanelStates(inspector);
691
691
  bindExportButtons();
692
692
  return;
@@ -753,20 +753,20 @@ function renderInspector() {
753
753
  paintRows +
754
754
  paintHint;
755
755
  const contentRows = pathRows + textRows + sourceRows;
756
- const keyframeRows =
757
- "<div class='row'><label>Time<input id='kfTime' type='number' step='0.05' value='" + currentTime.toFixed(2) + "'></label><div></div></div>" +
756
+ const keyframeRows =
757
+ "<div class='row'><label>Time<input id='kfTime' type='number' step='0.05' value='" + currentTime.toFixed(2) + "'></label><div></div></div>" +
758
758
  "<p class='tiny'>Changing sidebar values updates keyframes at the current time.</p>" +
759
759
  "<p class='tiny'>Interpolation curves are edited from timeline badges.</p>" +
760
- "<p class='tiny'>Drag to move. Use the square to scale and the round handle to rotate.</p>";
760
+ "<p class='tiny'>Drag to move. Use the square to scale and the round handle to rotate.</p>";
761
761
  inspector.innerHTML =
762
- exportPanel +
763
762
  panelDetails("inspector-selected", "Selected", selectedRows, { defaultOpen: true, meta: element.type }) +
764
- panelDetails("inspector-transform", "Transform", transformRows, { defaultOpen: false }) +
765
- panelDetails("inspector-appearance", "Appearance", appearanceRows, { defaultOpen: false }) +
766
- (contentRows ? panelDetails("inspector-content", "Path / Content", contentRows, { defaultOpen: false }) : "") +
767
- (supportsEffects ? panelDetails("inspector-effects", "Effects", effectsRows, { defaultOpen: false }) : "") +
768
- (structuredPaintRows ? panelDetails("inspector-structured-paint", "Structured Paint", structuredPaintRows, { defaultOpen: false }) : "") +
769
- panelDetails("inspector-keyframe", "Keyframe", keyframeRows, { defaultOpen: false });
763
+ panelDetails("inspector-transform", "Transform", transformRows, { defaultOpen: false }) +
764
+ panelDetails("inspector-appearance", "Appearance", appearanceRows, { defaultOpen: false }) +
765
+ (contentRows ? panelDetails("inspector-content", "Path / Content", contentRows, { defaultOpen: false }) : "") +
766
+ (supportsEffects ? panelDetails("inspector-effects", "Effects", effectsRows, { defaultOpen: false }) : "") +
767
+ (structuredPaintRows ? panelDetails("inspector-structured-paint", "Structured Paint", structuredPaintRows, { defaultOpen: false }) : "") +
768
+ panelDetails("inspector-keyframe", "Keyframe", keyframeRows, { defaultOpen: false }) +
769
+ exportPanel;
770
770
  bindPanelStates(inspector);
771
771
  bindExportButtons();
772
772
  if (supportsPaint) {
package/dist/src/edit.js CHANGED
@@ -9,6 +9,7 @@ exports.listTimelineTracks = listTimelineTracks;
9
9
  exports.roundedRectClipPath = roundedRectClipPath;
10
10
  exports.imageRoundedClip = imageRoundedClip;
11
11
  const animatable_1 = require("./animatable");
12
+ const keyframes_1 = require("./keyframes");
12
13
  const utils_1 = require("./utils");
13
14
  const validate_1 = require("./validate");
14
15
  function listElementReferences(document) {
@@ -29,6 +30,7 @@ function findElementById(document, id) {
29
30
  }
30
31
  function setElementProperty(document, id, property, value) {
31
32
  const next = (0, utils_1.clone)(document);
33
+ repairLegacyTimelineCurves(next);
32
34
  const element = requireElement(next, id);
33
35
  applyProperty(element, property, value);
34
36
  assertValid(next);
@@ -39,6 +41,7 @@ function setTimelineKeyframe(document, id, property, time, value, options = {})
39
41
  if (!(0, utils_1.isFiniteNumber)(time) || time < 0)
40
42
  throw new Error("Keyframe time must be a non-negative finite number.");
41
43
  const next = (0, utils_1.clone)(document);
44
+ repairLegacyTimelineCurves(next);
42
45
  const element = requireElement(next, id);
43
46
  element.timeline ?? (element.timeline = {});
44
47
  (_a = element.timeline).tracks ?? (_a.tracks = {});
@@ -157,6 +160,42 @@ function assertValid(document) {
157
160
  throw new Error(first ? `${first.path}: ${first.message}` : "Invalid visual document.");
158
161
  }
159
162
  }
163
+ function repairLegacyTimelineCurves(document) {
164
+ visitElements(document.elements ?? [], (element) => {
165
+ for (const track of Object.values(element.timeline?.tracks ?? {})) {
166
+ repairTrackCurve(track);
167
+ for (const frame of track.keyframes ?? [])
168
+ repairKeyframeCurve(frame);
169
+ }
170
+ });
171
+ }
172
+ function repairTrackCurve(track) {
173
+ const record = track;
174
+ if (typeof record.curve === "string") {
175
+ const curve = legacyCurve(record.curve);
176
+ if (curve)
177
+ record.curve = curve;
178
+ else
179
+ delete record.curve;
180
+ }
181
+ }
182
+ function repairKeyframeCurve(frame) {
183
+ if (Array.isArray(frame))
184
+ return;
185
+ const record = frame;
186
+ for (const key of ["in", "out", "interpolation"]) {
187
+ if (typeof record[key] !== "string")
188
+ continue;
189
+ const curve = legacyCurve(record[key]);
190
+ if (curve)
191
+ record[key] = curve;
192
+ else
193
+ delete record[key];
194
+ }
195
+ }
196
+ function legacyCurve(value) {
197
+ return (0, keyframes_1.timelineCurvePreset)(value);
198
+ }
160
199
  function finiteOrZero(value) {
161
200
  return (0, utils_1.isFiniteNumber)(value) ? value : 0;
162
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sketchmark",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "Render kernel for Sketchmark visual documents.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",