@grida/svg-editor 1.0.0-alpha.21 → 1.0.0-alpha.22

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.
@@ -1,4 +1,4 @@
1
- import { S as is_text_input_focused, a as paint, c as hit_shape_svg, d as NudgeDwellWatcher, f as TranslateOrchestrator, h as transform, i as TOOL_CURSOR, l as RotateOrchestrator, m as group, n as insertions, o as ResizeOrchestrator, s as resize_pipeline, t as PathModel, w as default_nudge_handler, x as array_shallow_equal } from "./model-C6jCFK_p.mjs";
1
+ import { S as is_text_input_focused, a as paint, c as hit_shape_svg, d as NudgeDwellWatcher, f as TranslateOrchestrator, h as transform, i as TOOL_CURSOR, l as RotateOrchestrator, m as group, n as insertions, o as ResizeOrchestrator, s as resize_pipeline, t as PathModel, w as default_nudge_handler, x as array_shallow_equal } from "./model-zMPCOVAr.mjs";
2
2
  import cmath from "@grida/cmath";
3
3
  import { svg_parse } from "@grida/svg/parse";
4
4
  import { SVGShapes } from "@grida/svg/pathdata";
@@ -3192,7 +3192,7 @@ var DomSurface = class DomSurface {
3192
3192
  mods: next
3193
3193
  });
3194
3194
  if ((prev.shift !== next.shift || prev.alt !== next.alt) && this.translate_orchestrator.has_active_session()) this.translate_orchestrator.redrive_modifiers(this.current_translate_modifiers());
3195
- if (prev.shift !== next.shift && this.resize_orchestrator.has_active_session()) this.resize_orchestrator.redrive_modifiers(this.current_resize_modifiers());
3195
+ if ((prev.shift !== next.shift || prev.alt !== next.alt) && this.resize_orchestrator.has_active_session()) this.resize_orchestrator.redrive_modifiers(this.current_resize_modifiers());
3196
3196
  if (prev.shift !== next.shift && this.rotate_orchestrator.has_active_session()) this.rotate_orchestrator.redrive_modifiers(this.current_rotate_modifiers());
3197
3197
  let cursor_changed = response.cursorChanged;
3198
3198
  let hover_changed = response.hoverChanged;
@@ -3690,8 +3690,10 @@ var DomSurface = class DomSurface {
3690
3690
  /** Snapshot of HUD modifier state mapped to `ResizeModifiers`. Same
3691
3691
  * pull-at-consume discipline as `current_translate_modifiers`. */
3692
3692
  current_resize_modifiers() {
3693
+ const mods = this.hud.modifiers();
3693
3694
  return {
3694
- aspect_lock: this.hud.modifiers().shift ? "uniform" : "off",
3695
+ aspect_lock: mods.shift ? "uniform" : "off",
3696
+ from_center: mods.alt,
3695
3697
  force_disable_snap: false
3696
3698
  };
3697
3699
  }
@@ -1,4 +1,4 @@
1
- const require_model = require("./model-DVwjrVYp.js");
1
+ const require_model = require("./model-HEKGO-56.js");
2
2
  let _grida_cmath = require("@grida/cmath");
3
3
  _grida_cmath = require_model.__toESM(_grida_cmath);
4
4
  let _grida_svg_parse = require("@grida/svg/parse");
@@ -3194,7 +3194,7 @@ var DomSurface = class DomSurface {
3194
3194
  mods: next
3195
3195
  });
3196
3196
  if ((prev.shift !== next.shift || prev.alt !== next.alt) && this.translate_orchestrator.has_active_session()) this.translate_orchestrator.redrive_modifiers(this.current_translate_modifiers());
3197
- if (prev.shift !== next.shift && this.resize_orchestrator.has_active_session()) this.resize_orchestrator.redrive_modifiers(this.current_resize_modifiers());
3197
+ if ((prev.shift !== next.shift || prev.alt !== next.alt) && this.resize_orchestrator.has_active_session()) this.resize_orchestrator.redrive_modifiers(this.current_resize_modifiers());
3198
3198
  if (prev.shift !== next.shift && this.rotate_orchestrator.has_active_session()) this.rotate_orchestrator.redrive_modifiers(this.current_rotate_modifiers());
3199
3199
  let cursor_changed = response.cursorChanged;
3200
3200
  let hover_changed = response.hoverChanged;
@@ -3692,8 +3692,10 @@ var DomSurface = class DomSurface {
3692
3692
  /** Snapshot of HUD modifier state mapped to `ResizeModifiers`. Same
3693
3693
  * pull-at-consume discipline as `current_translate_modifiers`. */
3694
3694
  current_resize_modifiers() {
3695
+ const mods = this.hud.modifiers();
3695
3696
  return {
3696
- aspect_lock: this.hud.modifiers().shift ? "uniform" : "off",
3697
+ aspect_lock: mods.shift ? "uniform" : "off",
3698
+ from_center: mods.alt,
3697
3699
  force_disable_snap: false
3698
3700
  };
3699
3701
  }
package/dist/dom.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_dom = require("./dom-CuK0LFUY.js");
2
+ const require_dom = require("./dom-H4PvmPe3.js");
3
3
  exports.Camera = require_dom.Camera;
4
4
  exports.DEFAULT_SNAP_OPTIONS = require_dom.DEFAULT_SNAP_OPTIONS;
5
5
  exports.Gestures = require_dom.Gestures;
package/dist/dom.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as project_point_through_ctm, c as MemoizedGeometryProvider, i as project_delta_inverse_ctm, l as Camera, n as install_font_load_geometry_bump, o as Gestures, r as inverse_project_rect, s as DEFAULT_SNAP_OPTIONS, t as attach_dom_surface } from "./dom-DHaTIObb.mjs";
1
+ import { a as project_point_through_ctm, c as MemoizedGeometryProvider, i as project_delta_inverse_ctm, l as Camera, n as install_font_load_geometry_bump, o as Gestures, r as inverse_project_rect, s as DEFAULT_SNAP_OPTIONS, t as attach_dom_surface } from "./dom-BIjCxCgx.mjs";
2
2
  export { Camera, DEFAULT_SNAP_OPTIONS, Gestures, MemoizedGeometryProvider, attach_dom_surface, install_font_load_geometry_bump, inverse_project_rect, project_delta_inverse_ctm, project_point_through_ctm };
@@ -1,4 +1,4 @@
1
- import { C as TOOL_SET, S as is_text_input_focused, T as registerDefaultCommands, _ as SVG_NS, a as paint, b as XMLNS_NS, g as subtree, h as transform, i as TOOL_CURSOR, m as group, n as insertions, p as translate_pipeline, r as DEFAULT_STYLE, s as resize_pipeline, u as rotate_pipeline, v as SvgDocument, x as array_shallow_equal, y as WELL_KNOWN_NS_PREFIXES } from "./model-C6jCFK_p.mjs";
1
+ import { C as TOOL_SET, S as is_text_input_focused, T as registerDefaultCommands, _ as SVG_NS, a as paint, b as XMLNS_NS, g as subtree, h as transform, i as TOOL_CURSOR, m as group, n as insertions, p as translate_pipeline, r as DEFAULT_STYLE, s as resize_pipeline, u as rotate_pipeline, v as SvgDocument, x as array_shallow_equal, y as WELL_KNOWN_NS_PREFIXES } from "./model-zMPCOVAr.mjs";
2
2
  import { HistoryImpl } from "@grida/history";
3
3
  import { KeyCode, M, chunkKey, eventToChunk, getKeyboardOS, kb, keybindingsToKeyCodes } from "@grida/keybinding";
4
4
  import cmath from "@grida/cmath";
@@ -1,4 +1,4 @@
1
- const require_model = require("./model-DVwjrVYp.js");
1
+ const require_model = require("./model-HEKGO-56.js");
2
2
  let _grida_history = require("@grida/history");
3
3
  let _grida_keybinding = require("@grida/keybinding");
4
4
  let _grida_cmath = require("@grida/cmath");
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_model = require("./model-DVwjrVYp.js");
3
- const require_editor = require("./editor-BlByfVyF.js");
2
+ const require_model = require("./model-HEKGO-56.js");
3
+ const require_editor = require("./editor-DFvojUwn.js");
4
4
  exports.DEFAULT_STYLE = require_model.DEFAULT_STYLE;
5
5
  exports.PathModel = require_model.PathModel;
6
6
  exports.TOOL_CURSOR = require_model.TOOL_CURSOR;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as createSvgEditor } from "./editor-CJ3ROm0G.mjs";
2
- import { i as TOOL_CURSOR, r as DEFAULT_STYLE, t as PathModel } from "./model-C6jCFK_p.mjs";
1
+ import { t as createSvgEditor } from "./editor-DCDQl18y.mjs";
2
+ import { i as TOOL_CURSOR, r as DEFAULT_STYLE, t as PathModel } from "./model-zMPCOVAr.mjs";
3
3
  export { DEFAULT_STYLE, PathModel, TOOL_CURSOR, createSvgEditor };
@@ -3518,9 +3518,12 @@ let resize_capability;
3518
3518
  }
3519
3519
  }
3520
3520
  _resize_capability.origin_of_direction = origin_of_direction;
3521
- function effective(baseline, dir, sx_gesture, sy_gesture) {
3521
+ function effective(baseline, dir, sx_gesture, sy_gesture, from_center = false) {
3522
3522
  const bbox = baseline.bbox;
3523
- const origin = origin_of_direction(bbox, dir);
3523
+ const origin = from_center ? {
3524
+ x: bbox.x + bbox.width / 2,
3525
+ y: bbox.y + bbox.height / 2
3526
+ } : origin_of_direction(bbox, dir);
3524
3527
  const c = constraint(baseline, dir, sx_gesture, sy_gesture);
3525
3528
  const mask = direction_mask(dir);
3526
3529
  const rect = {
@@ -3678,7 +3681,7 @@ let resize_pipeline;
3678
3681
  for (const a of baseline.raw) doc.set_attr(id, a.name, a.value);
3679
3682
  }
3680
3683
  _intent.restore = restore;
3681
- function compute_factors(baseline, dir, dx, dy, shift) {
3684
+ function compute_factors(baseline, dir, dx, dy, shift, from_center = false) {
3682
3685
  const b = baseline.bbox;
3683
3686
  let anchorX = 0;
3684
3687
  let anchorY = 0;
@@ -3740,6 +3743,10 @@ let resize_pipeline;
3740
3743
  affectsY = false;
3741
3744
  break;
3742
3745
  }
3746
+ if (from_center) {
3747
+ anchorX = b.x + b.width / 2;
3748
+ anchorY = b.y + b.height / 2;
3749
+ }
3743
3750
  const newHX = baseHX + (affectsX ? dx : 0);
3744
3751
  const newHY = baseHY + (affectsY ? dy : 0);
3745
3752
  const denomX = baseHX - anchorX;
@@ -3962,7 +3969,7 @@ let resize_pipeline;
3962
3969
  if (ctx.modifiers.aspect_lock !== "uniform") return { plan };
3963
3970
  if (!resize_capability.is_corner(plan.direction)) return { plan };
3964
3971
  const pbase = pipeline_baseline(plan);
3965
- const locked = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, true);
3972
+ const locked = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, true, ctx.modifiers.from_center);
3966
3973
  const bbox = pbase.bbox;
3967
3974
  const Hx_base = corner_x_of(bbox, plan.direction);
3968
3975
  const Hy_base = corner_y_of(bbox, plan.direction);
@@ -3982,8 +3989,8 @@ let resize_pipeline;
3982
3989
  if (!ctx.snap_session) return { plan };
3983
3990
  if (!ctx.options.snap_enabled) return { plan };
3984
3991
  const pbase = pipeline_baseline(plan);
3985
- const f = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, false);
3986
- const eff = resize_capability.effective(pbase, plan.direction, f.sx, f.sy);
3992
+ const f = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, false, ctx.modifiers.from_center);
3993
+ const eff = resize_capability.effective(pbase, plan.direction, f.sx, f.sy, ctx.modifiers.from_center);
3987
3994
  if (eff.no_op) return { plan };
3988
3995
  const r = ctx.snap_session.snap_resize(eff.rect, {
3989
3996
  x: eff.mask.x_edge,
@@ -4035,8 +4042,8 @@ let resize_pipeline;
4035
4042
  const q = ctx.options.pixel_grid_quantum;
4036
4043
  if (q === null || q <= 0) return { plan };
4037
4044
  const pbase = pipeline_baseline(plan);
4038
- const f = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, false);
4039
- const eff = resize_capability.effective(pbase, plan.direction, f.sx, f.sy);
4045
+ const f = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, false, ctx.modifiers.from_center);
4046
+ const eff = resize_capability.effective(pbase, plan.direction, f.sx, f.sy, ctx.modifiers.from_center);
4040
4047
  if (eff.no_op) return { plan };
4041
4048
  const target_Hx = eff.mask.affects_x ? Math.round(eff.moving_corner.x / q) * q : eff.moving_corner.x;
4042
4049
  const target_Hy = eff.mask.affects_y ? Math.round(eff.moving_corner.y / q) * q : eff.moving_corner.y;
@@ -4071,7 +4078,7 @@ let resize_pipeline;
4071
4078
  }
4072
4079
  _resize_pipeline.run = run;
4073
4080
  function apply(doc, plan, phase = "commit") {
4074
- const f = intent.compute_factors(plan.baseline, plan.direction, plan.dx, plan.dy, false);
4081
+ const f = intent.compute_factors(plan.baseline, plan.direction, plan.dx, plan.dy, false, plan.from_center ?? false);
4075
4082
  const members = plan.members ?? [{
4076
4083
  id: plan.id,
4077
4084
  baseline: plan.baseline
@@ -4196,7 +4203,8 @@ var ResizeOrchestrator = class {
4196
4203
  members: session.members,
4197
4204
  direction: session.direction,
4198
4205
  dx,
4199
- dy
4206
+ dy,
4207
+ from_center: modifiers.from_center
4200
4208
  };
4201
4209
  const ctx = {
4202
4210
  input: {
@@ -3484,9 +3484,12 @@ let resize_capability;
3484
3484
  }
3485
3485
  }
3486
3486
  _resize_capability.origin_of_direction = origin_of_direction;
3487
- function effective(baseline, dir, sx_gesture, sy_gesture) {
3487
+ function effective(baseline, dir, sx_gesture, sy_gesture, from_center = false) {
3488
3488
  const bbox = baseline.bbox;
3489
- const origin = origin_of_direction(bbox, dir);
3489
+ const origin = from_center ? {
3490
+ x: bbox.x + bbox.width / 2,
3491
+ y: bbox.y + bbox.height / 2
3492
+ } : origin_of_direction(bbox, dir);
3490
3493
  const c = constraint(baseline, dir, sx_gesture, sy_gesture);
3491
3494
  const mask = direction_mask(dir);
3492
3495
  const rect = {
@@ -3644,7 +3647,7 @@ let resize_pipeline;
3644
3647
  for (const a of baseline.raw) doc.set_attr(id, a.name, a.value);
3645
3648
  }
3646
3649
  _intent.restore = restore;
3647
- function compute_factors(baseline, dir, dx, dy, shift) {
3650
+ function compute_factors(baseline, dir, dx, dy, shift, from_center = false) {
3648
3651
  const b = baseline.bbox;
3649
3652
  let anchorX = 0;
3650
3653
  let anchorY = 0;
@@ -3706,6 +3709,10 @@ let resize_pipeline;
3706
3709
  affectsY = false;
3707
3710
  break;
3708
3711
  }
3712
+ if (from_center) {
3713
+ anchorX = b.x + b.width / 2;
3714
+ anchorY = b.y + b.height / 2;
3715
+ }
3709
3716
  const newHX = baseHX + (affectsX ? dx : 0);
3710
3717
  const newHY = baseHY + (affectsY ? dy : 0);
3711
3718
  const denomX = baseHX - anchorX;
@@ -3928,7 +3935,7 @@ let resize_pipeline;
3928
3935
  if (ctx.modifiers.aspect_lock !== "uniform") return { plan };
3929
3936
  if (!resize_capability.is_corner(plan.direction)) return { plan };
3930
3937
  const pbase = pipeline_baseline(plan);
3931
- const locked = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, true);
3938
+ const locked = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, true, ctx.modifiers.from_center);
3932
3939
  const bbox = pbase.bbox;
3933
3940
  const Hx_base = corner_x_of(bbox, plan.direction);
3934
3941
  const Hy_base = corner_y_of(bbox, plan.direction);
@@ -3948,8 +3955,8 @@ let resize_pipeline;
3948
3955
  if (!ctx.snap_session) return { plan };
3949
3956
  if (!ctx.options.snap_enabled) return { plan };
3950
3957
  const pbase = pipeline_baseline(plan);
3951
- const f = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, false);
3952
- const eff = resize_capability.effective(pbase, plan.direction, f.sx, f.sy);
3958
+ const f = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, false, ctx.modifiers.from_center);
3959
+ const eff = resize_capability.effective(pbase, plan.direction, f.sx, f.sy, ctx.modifiers.from_center);
3953
3960
  if (eff.no_op) return { plan };
3954
3961
  const r = ctx.snap_session.snap_resize(eff.rect, {
3955
3962
  x: eff.mask.x_edge,
@@ -4001,8 +4008,8 @@ let resize_pipeline;
4001
4008
  const q = ctx.options.pixel_grid_quantum;
4002
4009
  if (q === null || q <= 0) return { plan };
4003
4010
  const pbase = pipeline_baseline(plan);
4004
- const f = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, false);
4005
- const eff = resize_capability.effective(pbase, plan.direction, f.sx, f.sy);
4011
+ const f = intent.compute_factors(pbase, plan.direction, plan.dx, plan.dy, false, ctx.modifiers.from_center);
4012
+ const eff = resize_capability.effective(pbase, plan.direction, f.sx, f.sy, ctx.modifiers.from_center);
4006
4013
  if (eff.no_op) return { plan };
4007
4014
  const target_Hx = eff.mask.affects_x ? Math.round(eff.moving_corner.x / q) * q : eff.moving_corner.x;
4008
4015
  const target_Hy = eff.mask.affects_y ? Math.round(eff.moving_corner.y / q) * q : eff.moving_corner.y;
@@ -4037,7 +4044,7 @@ let resize_pipeline;
4037
4044
  }
4038
4045
  _resize_pipeline.run = run;
4039
4046
  function apply(doc, plan, phase = "commit") {
4040
- const f = intent.compute_factors(plan.baseline, plan.direction, plan.dx, plan.dy, false);
4047
+ const f = intent.compute_factors(plan.baseline, plan.direction, plan.dx, plan.dy, false, plan.from_center ?? false);
4041
4048
  const members = plan.members ?? [{
4042
4049
  id: plan.id,
4043
4050
  baseline: plan.baseline
@@ -4162,7 +4169,8 @@ var ResizeOrchestrator = class {
4162
4169
  members: session.members,
4163
4170
  direction: session.direction,
4164
4171
  dx,
4165
- dy
4172
+ dy,
4173
+ from_center: modifiers.from_center
4166
4174
  };
4167
4175
  const ctx = {
4168
4176
  input: {
package/dist/presets.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_model = require("./model-DVwjrVYp.js");
3
- const require_dom = require("./dom-CuK0LFUY.js");
2
+ const require_model = require("./model-HEKGO-56.js");
3
+ const require_dom = require("./dom-H4PvmPe3.js");
4
4
  //#region src/presets/keynote.ts
5
5
  var keynote_exports = /* @__PURE__ */ require_model.__exportAll({ attach: () => attach });
6
6
  /**
package/dist/presets.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-D7D4PA-g.mjs";
2
- import { t as attach_dom_surface } from "./dom-DHaTIObb.mjs";
2
+ import { t as attach_dom_surface } from "./dom-BIjCxCgx.mjs";
3
3
  //#region src/presets/keynote.ts
4
4
  var keynote_exports = /* @__PURE__ */ __exportAll({ attach: () => attach });
5
5
  /**
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_editor = require("./editor-BlByfVyF.js");
4
- const require_dom = require("./dom-CuK0LFUY.js");
3
+ const require_editor = require("./editor-DFvojUwn.js");
4
+ const require_dom = require("./dom-H4PvmPe3.js");
5
5
  let react = require("react");
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
7
  //#region src/react.tsx
package/dist/react.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { t as createSvgEditor } from "./editor-CJ3ROm0G.mjs";
3
- import { t as attach_dom_surface } from "./dom-DHaTIObb.mjs";
2
+ import { t as createSvgEditor } from "./editor-DCDQl18y.mjs";
3
+ import { t as attach_dom_surface } from "./dom-BIjCxCgx.mjs";
4
4
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/react.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grida/svg-editor",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.22",
4
4
  "description": "Headless SVG editor (experimental).",
5
5
  "keywords": [
6
6
  "bezier",
@@ -59,13 +59,13 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@grida/cmath": "0.2.3",
62
- "@grida/keybinding": "0.2.1",
62
+ "@grida/color": "0.1.0",
63
63
  "@grida/history": "0.1.2",
64
- "@grida/hud": "0.2.3",
65
- "@grida/vn": "0.1.0",
64
+ "@grida/keybinding": "0.2.1",
65
+ "@grida/hud": "0.2.4",
66
66
  "@grida/svg": "0.2.0",
67
67
  "@grida/text-editor": "0.1.2",
68
- "@grida/color": "0.1.0"
68
+ "@grida/vn": "0.1.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/react": "^19",