mce 0.1.1 → 0.1.3

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.
@@ -39,7 +39,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
39
39
  readonly handles?: ("move" | "rotate-top-left" | "rotate-top-right" | "rotate-bottom-left" | "rotate-bottom-right" | "resize-top" | "resize-right" | "resize-bottom" | "resize-left" | "resize-top-left" | "resize-top-right" | "resize-bottom-left" | "resize-bottom-right")[] | undefined;
40
40
  readonly initialSize?: boolean | undefined;
41
41
  readonly borderStyle?: "solid" | "dashed" | undefined;
42
- readonly tip?: ((type: "size") => string) | undefined;
42
+ readonly tipFormat?: ((type: "size") => string) | undefined;
43
43
  readonly onMove?: ((args_0: OrientedBoundingBox, args_1: OrientedBoundingBox) => any) | undefined;
44
44
  readonly onEnd?: ((args_0: OrientedBoundingBox) => any) | undefined;
45
45
  readonly onStart?: ((args_0: OrientedBoundingBox) => any) | undefined;
@@ -75,7 +75,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
75
75
  handles?: ("move" | "rotate-top-left" | "rotate-top-right" | "rotate-bottom-left" | "rotate-bottom-right" | "resize-top" | "resize-right" | "resize-bottom" | "resize-left" | "resize-top-left" | "resize-top-right" | "resize-bottom-left" | "resize-bottom-right")[];
76
76
  initialSize?: boolean;
77
77
  borderStyle?: "solid" | "dashed";
78
- tip?: (type: "size") => string;
78
+ tipFormat?: (type: "size") => string;
79
79
  }> & Readonly<{
80
80
  onMove?: ((args_0: OrientedBoundingBox, args_1: OrientedBoundingBox) => any) | undefined;
81
81
  onEnd?: ((args_0: OrientedBoundingBox) => any) | undefined;
@@ -150,7 +150,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
150
150
  handles?: ("move" | "rotate-top-left" | "rotate-top-right" | "rotate-bottom-left" | "rotate-bottom-right" | "resize-top" | "resize-right" | "resize-bottom" | "resize-left" | "resize-top-left" | "resize-top-right" | "resize-bottom-left" | "resize-bottom-right")[];
151
151
  initialSize?: boolean;
152
152
  borderStyle?: "solid" | "dashed";
153
- tip?: (type: "size") => string;
153
+ tipFormat?: (type: "size") => string;
154
154
  }> & Readonly<{
155
155
  onMove?: ((args_0: OrientedBoundingBox, args_1: OrientedBoundingBox) => any) | undefined;
156
156
  onEnd?: ((args_0: OrientedBoundingBox) => any) | undefined;
@@ -16,7 +16,7 @@ type __VLS_Props = {
16
16
  handles?: Handle[];
17
17
  initialSize?: boolean;
18
18
  borderStyle?: 'solid' | 'dashed';
19
- tip?: (type: 'size') => string;
19
+ tipFormat?: (type: 'size') => string;
20
20
  };
21
21
  declare function start(event?: MouseEvent, index?: number): boolean;
22
22
  declare var __VLS_7: {
package/dist/editor.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare class Editor extends Observable<Events> {
17
17
  config: RemovableRef<Mce.Config>;
18
18
  onEmit?: <K extends keyof Events & string>(event: K, ...args: Events[K]) => void;
19
19
  plugins: Map<string, PluginObject>;
20
- protected _setups: (() => void)[];
20
+ protected _setups: (() => void | Promise<void>)[];
21
21
  constructor(options?: Options);
22
22
  protected _setupObservable(): void;
23
23
  log: (...args: any[]) => void;
@@ -26,7 +26,7 @@ export declare class Editor extends Observable<Events> {
26
26
  protected _useMixins(mixins: Mixin[], options: Options): void;
27
27
  use(plugins: Plugin[], options: Options): void;
28
28
  protected _setuped: boolean;
29
- setup: () => void;
29
+ setup: () => Promise<void>;
30
30
  install: (app: App) => void;
31
31
  }
32
32
  export declare function createEditor(options?: Options): Editor;
@@ -40,9 +40,9 @@ export interface PluginObject {
40
40
  hotkeys?: Mce.Hotkey[];
41
41
  loaders?: Mce.Loader[];
42
42
  exporters?: Mce.Exporter[];
43
- setup?: () => void;
43
+ setup?: () => void | Promise<void>;
44
44
  }
45
45
  export type Plugin = PluginObject | ((editor: Editor, options: Options) => PluginObject);
46
46
  export declare function definePlugin(cb: Plugin): Plugin;
47
- export type Mixin = (editor: Editor, options: Options) => (() => void) | Mixin[] | Record<string, any> | undefined | void;
47
+ export type Mixin = (editor: Editor, options: Options) => (() => (void | Promise<void>)) | Mixin[] | Record<string, any> | undefined | void;
48
48
  export declare function defineMixin(cb: Mixin): Mixin;
package/dist/index.d.ts CHANGED
@@ -7,7 +7,6 @@ export * from './editor';
7
7
  export * from './mixins';
8
8
  export * from './models';
9
9
  export * from './plugins';
10
- export * from './sw';
11
10
  export * from './types';
12
11
  export * from './utils';
13
12
  export type { Camera2D, Element2D, Engine } from 'modern-canvas';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ref as V, computed as O, watch as he, markRaw as de, reactive as et, nextTick as Fe, inject as Ve, provide as Le, defineComponent as H, createVNode as W, mergeProps as Ie, createElementVNode as I, toValue as rn, getCurrentInstance as St, onScopeDispose as ln, createElementBlock as R, openBlock as $, Fragment as oe, renderList as pe, unref as M, normalizeStyle as K, normalizeClass as ve, renderSlot as ne, useAttrs as zt, createBlock as te, resolveDynamicComponent as Ot, useTemplateRef as le, onMounted as He, onBeforeUnmount as ge, Teleport as cn, createCommentVNode as Z, mergeModels as Pe, useModel as xe, useId as un, shallowRef as dn, resolveComponent as hn, withCtx as ue, createTextVNode as mn, toDisplayString as G, createSlots as rt, normalizeProps as lt, guardReactiveProps as ct, withDirectives as Ee, vShow as De, vModelText as fn, withModifiers as Xe, onBeforeMount as ut, isRef as pn } from "vue";
1
+ import { ref as V, computed as O, watch as he, markRaw as de, reactive as et, nextTick as Fe, inject as Ve, provide as Le, defineComponent as H, createVNode as W, mergeProps as Ie, createElementVNode as I, toValue as rn, getCurrentInstance as St, onScopeDispose as ln, createElementBlock as R, openBlock as $, Fragment as oe, renderList as pe, unref as M, normalizeStyle as K, normalizeClass as ve, renderSlot as ne, useAttrs as zt, createBlock as te, resolveDynamicComponent as Ot, useTemplateRef as le, onMounted as He, onBeforeUnmount as ge, Teleport as cn, createCommentVNode as J, mergeModels as Pe, useModel as xe, useId as un, shallowRef as dn, resolveComponent as hn, withCtx as ue, createTextVNode as mn, toDisplayString as G, createSlots as rt, normalizeProps as lt, guardReactiveProps as ct, withDirectives as Ee, vShow as De, vModelText as fn, withModifiers as Xe, onBeforeMount as ut, isRef as pn } from "vue";
2
2
  import { useFileDialog as $t, useEventListener as Ft, isClient as vn, useResizeObserver as It, useLocalStorage as gn, onClickOutside as yn, useMouse as bn, useDebounceFn as Pt } from "@vueuse/core";
3
3
  import { Timeline as wn, Engine as xn, Camera2D as _n, DrawboardEffect as kn, Element2D as q, IN_BROWSER as Nt, clamp as Cn, assets as Bt, TimelineNode as Tn, Transform2D as En, DEG_TO_RAD as An, Node as vt, render as Ye, Animation as Mn } from "modern-canvas";
4
4
  import { getObjectValueByPath as Sn, setObjectValueByPath as zn, normalizeTextContent as On, idGenerator as dt, normalizeElement as Rt, Observable as Dt, Reactivable as $n, property as je } from "modern-idoc";
@@ -336,9 +336,9 @@ const Un = (o) => {
336
336
  return Object.assign(o, {
337
337
  frames: n,
338
338
  frameThumbs: i,
339
- activeFrameIndex: s,
340
- activeFrame: a,
341
- activeFrameAabb: r,
339
+ currentFrameIndex: s,
340
+ currentFrame: a,
341
+ currentFrameAabb: r,
342
342
  isFrame: c,
343
343
  getAncestorFrame: l
344
344
  }), () => {
@@ -917,7 +917,7 @@ const ho = (o) => {
917
917
  const {
918
918
  renderEngine: e,
919
919
  rootAabb: t,
920
- activeFrameAabb: n,
920
+ currentFrameAabb: n,
921
921
  config: s
922
922
  } = o, a = O(() => s.value.viewMode === "frame" ? n.value : t.value);
923
923
  function r(i, c) {
@@ -939,7 +939,7 @@ const ho = (o) => {
939
939
  }), () => {
940
940
  const {
941
941
  root: i,
942
- activeFrame: c,
942
+ currentFrame: c,
943
943
  on: l,
944
944
  exec: u
945
945
  } = o;
@@ -958,7 +958,7 @@ const ho = (o) => {
958
958
  }
959
959
  u("zoomToFit");
960
960
  }
961
- he(() => s.value.viewMode, d), l("setActiveFrame", d), l("setDoc", d);
961
+ he(() => s.value.viewMode, d), l("setCurrentFrame", d), l("setDoc", d);
962
962
  };
963
963
  }, yo = (o) => {
964
964
  const {
@@ -1053,7 +1053,7 @@ const ho = (o) => {
1053
1053
  const {
1054
1054
  doc: e,
1055
1055
  rootAabb: t,
1056
- activeFrame: n,
1056
+ currentFrame: n,
1057
1057
  emit: s,
1058
1058
  textFontSizeToFit: a,
1059
1059
  textToFit: r,
@@ -1093,7 +1093,7 @@ const ho = (o) => {
1093
1093
  if (_) {
1094
1094
  const { width: _e, height: ke } = _.style, ye = _e / 2, me = ke / 2;
1095
1095
  if (Y.style.width || (Y.style.width = ye), Y.style.height || (Y.style.height = me), E) {
1096
- const J = Y.style.width / Y.style.height, ce = J > 1 ? ye : me * J, U = J > 1 ? ye / J : me;
1096
+ const Z = Y.style.width / Y.style.height, ce = Z > 1 ? ye : me * Z, U = Z > 1 ? ye / Z : me;
1097
1097
  k(
1098
1098
  Y,
1099
1099
  ce / Y.style.width,
@@ -1170,7 +1170,7 @@ const ho = (o) => {
1170
1170
  doc: e,
1171
1171
  root: t,
1172
1172
  rootAabb: n,
1173
- activeFrameIndex: s,
1173
+ currentFrameIndex: s,
1174
1174
  frameThumbs: a,
1175
1175
  emit: r,
1176
1176
  selection: i,
@@ -1215,14 +1215,14 @@ const ho = (o) => {
1215
1215
  function g(v = s.value) {
1216
1216
  v = Math.max(0, Math.min(c.value.length - 1, v));
1217
1217
  const m = s.value;
1218
- s.value = v, l.value.viewMode === "edgeless" ? i.value = [c.value[v]] : i.value = [], r("setActiveFrame", v, m);
1218
+ s.value = v, l.value.viewMode === "edgeless" ? i.value = [c.value[v]] : i.value = [], r("setCurrentFrame", v, m);
1219
1219
  }
1220
1220
  Object.assign(o, {
1221
1221
  addFrame: u,
1222
1222
  duplicateFrame: d,
1223
1223
  moveFrame: y,
1224
1224
  deleteFrame: h,
1225
- setActiveFrame: g
1225
+ setCurrentFrame: g
1226
1226
  });
1227
1227
  };
1228
1228
  function Me(o) {
@@ -1750,7 +1750,7 @@ const Vo = (o, e) => {
1750
1750
  renderEngine: s,
1751
1751
  emit: a,
1752
1752
  selection: r,
1753
- setActiveFrame: i,
1753
+ setCurrentFrame: i,
1754
1754
  state: c,
1755
1755
  to: l,
1756
1756
  waitUntilFontLoad: u,
@@ -1788,19 +1788,13 @@ const Vo = (o, e) => {
1788
1788
  const {
1789
1789
  doc: f
1790
1790
  } = e;
1791
- v(f || {
1792
- style: {
1793
- width: 1920,
1794
- height: 1080
1795
- },
1796
- children: []
1797
- });
1791
+ f && v(f);
1798
1792
  };
1799
1793
  }, jo = (o) => {
1800
1794
  const {
1801
1795
  renderEngine: e,
1802
1796
  frames: t,
1803
- activeFrameAabb: n,
1797
+ currentFrameAabb: n,
1804
1798
  camera: s,
1805
1799
  frameThumbs: a,
1806
1800
  log: r,
@@ -1880,7 +1874,7 @@ const Vo = (o, e) => {
1880
1874
  }
1881
1875
  }
1882
1876
  v.root.on("appendChild", m);
1883
- }), h("setActiveFrame", (v, m) => {
1877
+ }), h("setCurrentFrame", (v, m) => {
1884
1878
  g.value.frameScreenshot && d(m);
1885
1879
  });
1886
1880
  };
@@ -2642,7 +2636,7 @@ function Qe(o) {
2642
2636
  }
2643
2637
  const qo = (o) => {
2644
2638
  const {
2645
- activeFrame: e,
2639
+ currentFrame: e,
2646
2640
  selection: t,
2647
2641
  state: n,
2648
2642
  getObbInDrawboard: s,
@@ -3326,7 +3320,7 @@ const qo = (o) => {
3326
3320
  };
3327
3321
  }, ss = (o) => {
3328
3322
  const {
3329
- activeFrameAabb: e,
3323
+ currentFrameAabb: e,
3330
3324
  selection: t,
3331
3325
  getAabb: n
3332
3326
  } = o;
@@ -4092,7 +4086,7 @@ const ps = (o) => {
4092
4086
  ],
4093
4087
  events: {
4094
4088
  setDoc: y,
4095
- setActiveFrame: () => {
4089
+ setCurrentFrame: () => {
4096
4090
  i.value.length ? g() : y();
4097
4091
  }
4098
4092
  },
@@ -4207,20 +4201,23 @@ class Ae extends Dt {
4207
4201
  });
4208
4202
  }
4209
4203
  _setuped = !1;
4210
- setup = () => {
4211
- this._setuped || (this._setuped = !0, this._setups.forEach((e) => {
4212
- try {
4213
- e();
4214
- } catch (t) {
4215
- console.error("Failed to setup mixin", t);
4216
- }
4217
- }), this.plugins.forEach((e) => {
4218
- try {
4219
- e.setup?.();
4220
- } catch (t) {
4221
- console.error(`Failed to setup ${e.name} plugin`, t);
4222
- }
4223
- }));
4204
+ setup = async () => {
4205
+ this._setuped || (this._setuped = !0, await Promise.all([
4206
+ ...this._setups.map(async (e) => {
4207
+ try {
4208
+ await e();
4209
+ } catch (t) {
4210
+ console.error("Failed to setup mixin", t);
4211
+ }
4212
+ }),
4213
+ ...[...this.plugins.values()].map(async (e) => {
4214
+ try {
4215
+ await e.setup?.();
4216
+ } catch (t) {
4217
+ console.error(`Failed to setup ${e.name} plugin`, t);
4218
+ }
4219
+ })
4220
+ ]), this.emit("ready"));
4224
4221
  };
4225
4222
  install = (e) => {
4226
4223
  e.provide(Ae.injectionKey, this);
@@ -4536,7 +4533,7 @@ const Is = Yt({
4536
4533
  style: g.value
4537
4534
  }, f.$attrs), [
4538
4535
  ne(f.$slots, "default")
4539
- ], 16)) : Z("", !0)
4536
+ ], 16)) : J("", !0)
4540
4537
  ], 8, ["disabled", "to"]))
4541
4538
  ], 64));
4542
4539
  }
@@ -4634,7 +4631,7 @@ const Is = Yt({
4634
4631
  F.checked ? ($(), te(we, {
4635
4632
  key: 0,
4636
4633
  icon: "$check"
4637
- })) : Z("", !0)
4634
+ })) : J("", !0)
4638
4635
  ]),
4639
4636
  I("div", Xs, [
4640
4637
  ne(f.$slots, "title", { item: F }, () => [
@@ -4643,7 +4640,7 @@ const Is = Yt({
4643
4640
  ]),
4644
4641
  F.children?.length ? ($(), R("div", Hs, [
4645
4642
  W(we, { icon: "$menuRight" })
4646
- ])) : Z("", !0)
4643
+ ])) : J("", !0)
4647
4644
  ], 10, js)
4648
4645
  ], 40, Vs))
4649
4646
  ], 64))), 128)),
@@ -4666,8 +4663,8 @@ const Is = Yt({
4666
4663
  ]),
4667
4664
  key: "0"
4668
4665
  } : void 0
4669
- ]), 1032, ["items", "model-value", "target"])) : Z("", !0)
4670
- ], 32)) : Z("", !0)
4666
+ ]), 1032, ["items", "model-value", "target"])) : J("", !0)
4667
+ ], 32)) : J("", !0)
4671
4668
  ]),
4672
4669
  _: 3
4673
4670
  }, 8, ["modelValue", "location", "offset", "target", "attach"]);
@@ -4732,7 +4729,7 @@ const Is = Yt({
4732
4729
  }, {
4733
4730
  title: ue(({ item: f }) => [
4734
4731
  I("span", qs, G(M(i)(f.key)), 1),
4735
- M(c).has(f.key) ? ($(), R("span", Gs, G(M(r)(f.key)), 1)) : Z("", !0)
4732
+ M(c).has(f.key) ? ($(), R("span", Gs, G(M(r)(f.key)), 1)) : J("", !0)
4736
4733
  ]),
4737
4734
  _: 1
4738
4735
  }, 8, ["modelValue", "target", "items", "style"]));
@@ -4767,8 +4764,8 @@ const Is = Yt({
4767
4764
  }),
4768
4765
  onMousedown: l
4769
4766
  }, [
4770
- M(t)?.content ? ($(), R("div", Ks, G(M(n)(M(t).content)), 1)) : Z("", !0)
4771
- ], 36)) : Z("", !0);
4767
+ M(t)?.content ? ($(), R("div", Ks, G(M(n)(M(t).content)), 1)) : J("", !0)
4768
+ ], 36)) : J("", !0);
4772
4769
  }
4773
4770
  }), Zs = /* @__PURE__ */ H({
4774
4771
  __name: "Floatbar",
@@ -4801,7 +4798,7 @@ const Is = Yt({
4801
4798
  "model-value": !0
4802
4799
  }, {
4803
4800
  default: ue(() => [
4804
- M(s).length > 0 ? ne(c.$slots, "default", { key: 0 }) : Z("", !0)
4801
+ M(s).length > 0 ? ne(c.$slots, "default", { key: 0 }) : J("", !0)
4805
4802
  ]),
4806
4803
  _: 3
4807
4804
  }, 8, ["location", "offset", "target"]));
@@ -4888,7 +4885,7 @@ const Is = Yt({
4888
4885
  }, [
4889
4886
  W(we, { icon: "$gps" }),
4890
4887
  I("span", null, G(M(a)("goBackSelectedArea")), 1)
4891
- ])) : Z("", !0);
4888
+ ])) : J("", !0);
4892
4889
  }
4893
4890
  }), na = ["data-name"], oa = /* @__PURE__ */ H({
4894
4891
  __name: "Hover",
@@ -4906,7 +4903,7 @@ const Is = Yt({
4906
4903
  borderColor: "currentcolor",
4907
4904
  ...M(Te)(s.value)
4908
4905
  })
4909
- }, null, 12, na)) : Z("", !0);
4906
+ }, null, 12, na)) : J("", !0);
4910
4907
  }
4911
4908
  }), sa = /* @__PURE__ */ H({
4912
4909
  __name: "Tooltip",
@@ -4938,7 +4935,7 @@ const Is = Yt({
4938
4935
  attach: t.attach
4939
4936
  }, rt({
4940
4937
  default: ue(() => [
4941
- n.value ? ne(r.$slots, "default", { key: 0 }) : Z("", !0)
4938
+ n.value ? ne(r.$slots, "default", { key: 0 }) : J("", !0)
4942
4939
  ]),
4943
4940
  _: 2
4944
4941
  }, [
@@ -5296,7 +5293,10 @@ const Is = Yt({
5296
5293
  }), null, 16, ["modelValue", "zoom", "length"])
5297
5294
  ], 64));
5298
5295
  }
5299
- }), ma = { class: "mce-transformable__svg" }, fa = { "pointer-events": "all" }, pa = ["x", "y", "width", "height", "aria-label", "fill"], va = ["cx", "cy", "r", "aria-label", "fill"], ga = ["x", "y", "width", "height", "aria-label", "cursor", "onPointerdown"], ya = { class: "mce-transformable__tip" }, ba = /* @__PURE__ */ H({
5296
+ }), ma = { class: "mce-transformable__svg" }, fa = { "pointer-events": "all" }, pa = ["x", "y", "width", "height", "aria-label", "fill"], va = ["cx", "cy", "r", "aria-label", "fill"], ga = ["x", "y", "width", "height", "aria-label", "cursor", "onPointerdown"], ya = {
5297
+ key: 0,
5298
+ class: "mce-transformable__tip"
5299
+ }, ba = /* @__PURE__ */ H({
5300
5300
  __name: "Transformable",
5301
5301
  props: {
5302
5302
  tag: { default: "div" },
@@ -5328,7 +5328,7 @@ const Is = Yt({
5328
5328
  ] },
5329
5329
  initialSize: { type: Boolean },
5330
5330
  borderStyle: {},
5331
- tip: {}
5331
+ tipFormat: {}
5332
5332
  },
5333
5333
  emits: ["update:modelValue", "start", "move", "end"],
5334
5334
  setup(o, { expose: e, emit: t }) {
@@ -5403,7 +5403,7 @@ const Is = Yt({
5403
5403
  ...y.value,
5404
5404
  transform: `matrix(${x}, ${E}, ${-E}, ${x}, ${p}, ${b})`
5405
5405
  };
5406
- }), g = O(() => n.visibility === "auto" && c.value), v = O(() => n.tip?.("size") ?? `${Math.floor(i.value.width)} × ${Math.floor(i.value.height)}`);
5406
+ }), g = O(() => n.visibility === "auto" && c.value), v = O(() => n.tipFormat?.("size"));
5407
5407
  function m(p, b) {
5408
5408
  if (p && p.button !== void 0 && p.button !== 0)
5409
5409
  return !1;
@@ -5435,7 +5435,7 @@ const Is = Yt({
5435
5435
  }
5436
5436
  !n.threshold && !c.value && _e();
5437
5437
  function ke(me) {
5438
- const J = {};
5438
+ const Z = {};
5439
5439
  Y || (Y = { x: me.clientX, y: me.clientY });
5440
5440
  const ce = {
5441
5441
  x: me.clientX - Y.x,
@@ -5453,13 +5453,13 @@ const Is = Yt({
5453
5453
  if (C) {
5454
5454
  if (!n.moveable)
5455
5455
  return;
5456
- J.left = U.x, J.top = U.y;
5456
+ Z.left = U.x, Z.top = U.y;
5457
5457
  } else if (N) {
5458
5458
  const Ce = Math.atan2(
5459
5459
  U.y - D.y,
5460
5460
  U.x - D.x
5461
5461
  ) / (Math.PI / 180);
5462
- J.rotate = (S + Ce - fe + 360) % 360;
5462
+ Z.rotate = (S + Ce - fe + 360) % 360;
5463
5463
  } else if (j) {
5464
5464
  const Ce = F(U, Q, -S), se = F(
5465
5465
  L ? { x: Ce.x, y: Q.y } : { x: Q.x, y: Ce.y },
@@ -5469,7 +5469,7 @@ const Is = Yt({
5469
5469
  x: se.x - (se.x - ee.x) / 2,
5470
5470
  y: se.y + (ee.y - se.y) / 2
5471
5471
  }, be = A(se, ee);
5472
- L ? (J.width = be, P && n.resizeStrategy === "aspectRatio" && (J.height = be / P)) : (J.height = be, P && n.resizeStrategy === "aspectRatio" && (J.width = be * P)), J.left = Be.x - (L ? be : x) / 2, J.top = Be.y - (L ? E : be) / 2;
5472
+ L ? (Z.width = be, P && n.resizeStrategy === "aspectRatio" && (Z.height = be / P)) : (Z.height = be, P && n.resizeStrategy === "aspectRatio" && (Z.width = be * P)), Z.left = Be.x - (L ? be : x) / 2, Z.top = Be.y - (L ? E : be) / 2;
5473
5473
  } else {
5474
5474
  if (P && (n.resizeStrategy === "aspectRatio" || n.resizeStrategy === "diagonalAspectRatio")) {
5475
5475
  let Ke = 1;
@@ -5485,11 +5485,11 @@ const Is = Yt({
5485
5485
  F(U, Ce, -S),
5486
5486
  F(ee, Ce, -S)
5487
5487
  ], [Be, be] = se[0].x > se[1].x ? [se[1].x, se[0].x] : [se[0].x, se[1].x], [pt, an] = se[0].y > se[1].y ? [se[1].y, se[0].y] : [se[0].y, se[1].y];
5488
- J.width = be - Be, J.height = an - pt, J.left = Be, J.top = pt;
5488
+ Z.width = be - Be, Z.height = an - pt, Z.left = Be, Z.top = pt;
5489
5489
  }
5490
- if ("width" in J && J.width <= 0 || "height" in J && J.height <= 0)
5490
+ if ("width" in Z && Z.width <= 0 || "height" in Z && Z.height <= 0)
5491
5491
  return;
5492
- const ie = { ...i.value }, Se = { ...i.value, ...J };
5492
+ const ie = { ...i.value }, Se = { ...i.value, ...Z };
5493
5493
  i.value = Se, s("move", Se, ie);
5494
5494
  }
5495
5495
  function ye() {
@@ -5600,7 +5600,7 @@ const Is = Yt({
5600
5600
  opacity: o.visibility === "none" || c.value && o.visibility !== "visible" ? 0 : void 0
5601
5601
  })
5602
5602
  }, null, 12, va))
5603
- ], 64)) : Z("", !0),
5603
+ ], 64)) : J("", !0),
5604
5604
  I("rect", {
5605
5605
  ref_for: !0,
5606
5606
  ref_key: "handlesRef",
@@ -5626,7 +5626,7 @@ const Is = Yt({
5626
5626
  ne(p.$slots, "svg", { box: i.value })
5627
5627
  ], 4)
5628
5628
  ])),
5629
- I("div", ya, G(v.value), 1)
5629
+ v.value ? ($(), R("div", ya, G(v.value), 1)) : J("", !0)
5630
5630
  ]),
5631
5631
  _: 3
5632
5632
  }, 8, ["style"]));
@@ -5715,7 +5715,7 @@ const Is = Yt({
5715
5715
  borderColor: "currentcolor",
5716
5716
  ...M(Te)(t.selectedArea)
5717
5717
  })
5718
- }, null, 4)) : Z("", !0),
5718
+ }, null, 4)) : J("", !0),
5719
5719
  ($(!0), R(oe, null, pe(f.value, (p, b) => ($(), R("div", {
5720
5720
  key: b,
5721
5721
  class: "mce-element-obb",
@@ -5735,7 +5735,7 @@ const Is = Yt({
5735
5735
  "handle-shape": M(g).handleShape,
5736
5736
  class: "mce-selection-obb",
5737
5737
  "border-style": M(a).length > 1 ? "dashed" : "solid",
5738
- tip: F,
5738
+ "tip-format": F,
5739
5739
  onMove: A[1] || (A[1] = () => !M(n) && (n.value = "transforming")),
5740
5740
  onEnd: A[2] || (A[2] = () => M(n) === "transforming" && (n.value = void 0))
5741
5741
  }, rt({ _: 2 }, [
@@ -5746,13 +5746,13 @@ const Is = Yt({
5746
5746
  ]),
5747
5747
  key: "0"
5748
5748
  } : void 0
5749
- ]), 1032, ["modelValue", "visibility", "moveable", "resize-strategy", "handle-shape", "border-style"])) : Z("", !0),
5749
+ ]), 1032, ["modelValue", "visibility", "moveable", "resize-strategy", "handle-shape", "border-style"])) : J("", !0),
5750
5750
  z.value.width && z.value.height && k.$slots.default ? ($(), R("div", {
5751
5751
  key: 2,
5752
5752
  style: K([{ position: "absolute" }, M(Te)(z.value)])
5753
5753
  }, [
5754
5754
  ne(k.$slots, "default", { box: z.value })
5755
- ], 4)) : Z("", !0)
5755
+ ], 4)) : J("", !0)
5756
5756
  ], 64));
5757
5757
  }
5758
5758
  }), xa = /* @__PURE__ */ H({
@@ -5779,7 +5779,7 @@ const Is = Yt({
5779
5779
  setup(o) {
5780
5780
  const e = xe(o, "modelValue");
5781
5781
  return (t, n) => ($(), R("div", _a, [
5782
- o.label ? ($(), R("span", ka, G(o.label), 1)) : Z("", !0),
5782
+ o.label ? ($(), R("span", ka, G(o.label), 1)) : J("", !0),
5783
5783
  I("div", Ca, [
5784
5784
  o.indeterminate ? ($(), R("div", Ta)) : ($(), R("div", {
5785
5785
  key: 0,
@@ -5863,7 +5863,7 @@ const Is = Yt({
5863
5863
  modelValue: M(a),
5864
5864
  "onUpdate:modelValue": i[0] || (i[0] = (c) => pn(a) ? a.value = c : null),
5865
5865
  label: M(t)("exporting")
5866
- }, null, 8, ["modelValue", "label"])) : Z("", !0)
5866
+ }, null, 8, ["modelValue", "label"])) : J("", !0)
5867
5867
  ])
5868
5868
  ]));
5869
5869
  }
@@ -5975,9 +5975,9 @@ const Is = Yt({
5975
5975
  ]]),
5976
5976
  style: K(t.value)
5977
5977
  }, [
5978
- o.active ? ($(), R("div", ei)) : Z("", !0),
5978
+ o.active ? ($(), R("div", ei)) : J("", !0),
5979
5979
  I("span", ti, G(e.node.name), 1),
5980
- o.active ? ($(), R("div", ni)) : Z("", !0)
5980
+ o.active ? ($(), R("div", ni)) : J("", !0)
5981
5981
  ], 6));
5982
5982
  }
5983
5983
  }), si = { class: "mce-track" }, ai = /* @__PURE__ */ H({
@@ -6258,7 +6258,7 @@ const Is = Yt({
6258
6258
  function me() {
6259
6259
  return !X && (Math.abs(D.x - j.x) >= 3 || Math.abs(D.y - j.y) >= 3);
6260
6260
  }
6261
- function J(U) {
6261
+ function Z(U) {
6262
6262
  D = { x: U.clientX, y: U.clientY }, Y ? me() && (X = !0, v("startTransform")) : L && !h(L) ? me() && (X = !0, _e(U), Fe(() => {
6263
6263
  Q || v("startTransform");
6264
6264
  })) : ke();
@@ -6274,9 +6274,9 @@ const Is = Yt({
6274
6274
  }
6275
6275
  x(C);
6276
6276
  }
6277
- i.value.off("pointermove", J), document.removeEventListener("pointerup", ce), Q = !0;
6277
+ i.value.off("pointermove", Z), document.removeEventListener("pointerup", ce), Q = !0;
6278
6278
  }
6279
- i.value.on("pointermove", J), document.addEventListener("pointerup", ce);
6279
+ i.value.on("pointermove", Z), document.addEventListener("pointerup", ce);
6280
6280
  }
6281
6281
  function S(C) {
6282
6282
  C.srcElement === r.value && (F.value = { x: C.clientX, y: C.clientY }, !(c.value.grabbing || C.button === 1 || d.value && d.value !== "typing") && x(C));
@@ -6320,7 +6320,7 @@ const Is = Yt({
6320
6320
  ]),
6321
6321
  _: 3
6322
6322
  }, 8, ["selected-area", "resize-strategy"]),
6323
- M(a).scrollbar ? ($(), te(ha, { key: 0 })) : Z("", !0),
6323
+ M(a).scrollbar ? ($(), te(ha, { key: 0 })) : J("", !0),
6324
6324
  C.$slots.floatbar ? ($(), te(Zs, {
6325
6325
  key: 1,
6326
6326
  target: M(d) === "typing" ? b.value?.textEditor : p.value?.transformable?.$el
@@ -6329,41 +6329,24 @@ const Is = Yt({
6329
6329
  ne(C.$slots, "floatbar")
6330
6330
  ]),
6331
6331
  _: 3
6332
- }, 8, ["target"])) : Z("", !0),
6332
+ }, 8, ["target"])) : J("", !0),
6333
6333
  W(Ws),
6334
6334
  M(a).bottombar ? ($(), te(Ls, { key: 2 }, {
6335
6335
  default: ue(() => [
6336
6336
  ne(C.$slots, "bottombar")
6337
6337
  ]),
6338
6338
  _: 3
6339
- })) : Z("", !0),
6339
+ })) : J("", !0),
6340
6340
  W(ta),
6341
6341
  ne(C.$slots, "default")
6342
6342
  ], 40, vi),
6343
- M(a).ruler ? ($(), te(ca, { key: 0 })) : Z("", !0),
6344
- M(a).timeline ? ($(), te(pi, { key: 1 })) : Z("", !0),
6345
- M(a).statusbar ? ($(), te(Ka, { key: 2 })) : Z("", !0),
6343
+ M(a).ruler ? ($(), te(ca, { key: 0 })) : J("", !0),
6344
+ M(a).timeline ? ($(), te(pi, { key: 1 })) : J("", !0),
6345
+ M(a).statusbar ? ($(), te(Ka, { key: 2 })) : J("", !0),
6346
6346
  I("div", yi, null, 512)
6347
6347
  ], 2));
6348
6348
  }
6349
6349
  });
6350
- async function Ni() {
6351
- if (!("serviceWorker" in navigator)) {
6352
- console.warn("Service Worker is not supported in this browser/environment");
6353
- return;
6354
- }
6355
- try {
6356
- await new Promise((e) => {
6357
- document.readyState === "complete" || document.readyState === "interactive" ? e() : window.addEventListener("load", () => e(), { once: !0 });
6358
- });
6359
- const o = await navigator.serviceWorker.register("./sw.js", {
6360
- scope: "/"
6361
- });
6362
- console.log("Editor sw registered", o);
6363
- } catch (o) {
6364
- console.error("Editor sw registration failed", o);
6365
- }
6366
- }
6367
6350
  export {
6368
6351
  en as Doc,
6369
6352
  Pi as Drawboard,
@@ -6409,7 +6392,6 @@ export {
6409
6392
  Yt as propsFactory,
6410
6393
  Ii as provideEditor,
6411
6394
  $s as provideOverlay,
6412
- Ni as registerSw,
6413
6395
  so as uint32,
6414
6396
  re as useEditor,
6415
6397
  Es as useIcon,
@@ -12,9 +12,9 @@ declare global {
12
12
  interface Editor {
13
13
  frameThumbs: Ref<FrameThumb[]>;
14
14
  frames: ComputedRef<Element2D[]>;
15
- activeFrameIndex: Ref<number>;
16
- activeFrame: ComputedRef<Element2D | undefined>;
17
- activeFrameAabb: ComputedRef<AxisAlignedBoundingBox>;
15
+ currentFrameIndex: Ref<number>;
16
+ currentFrame: ComputedRef<Element2D | undefined>;
17
+ currentFrameAabb: ComputedRef<AxisAlignedBoundingBox>;
18
18
  isFrame: (node: Node) => node is Element2D;
19
19
  getAncestorFrame: (element?: Element2D) => Element2D | undefined;
20
20
  }
@@ -6,14 +6,14 @@ declare global {
6
6
  duplicateFrame: (index?: number) => void;
7
7
  moveFrame: (fromIndex: number, toIndex: number) => void;
8
8
  deleteFrame: (index?: number) => void;
9
- setActiveFrame: (index?: number) => void;
9
+ setCurrentFrame: (index?: number) => void;
10
10
  }
11
11
  interface Events {
12
12
  addFrame: [index: number];
13
13
  duplicateFrame: [index: number];
14
14
  moveFrame: [fromIndex: number, toIndex: number];
15
15
  deleteFrame: [index: number];
16
- setActiveFrame: [index: number, oldIndex: number];
16
+ setCurrentFrame: [index: number, oldIndex: number];
17
17
  }
18
18
  }
19
19
  }
@@ -2,7 +2,9 @@ declare global {
2
2
  namespace Mce {
3
3
  interface Editor {}
4
4
  interface Options {}
5
- interface Events {}
5
+ interface Events {
6
+ ready: []
7
+ }
6
8
  interface Hotkeys {}
7
9
  interface Commands {}
8
10
  interface Exporters {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "description": "The headless canvas editor framework. only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",
package/dist/sw.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function registerSw(): Promise<void>;