mce 0.1.2 → 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.
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
@@ -4201,20 +4201,23 @@ class Ae extends Dt {
4201
4201
  });
4202
4202
  }
4203
4203
  _setuped = !1;
4204
- setup = () => {
4205
- this._setuped || (this._setuped = !0, this._setups.forEach((e) => {
4206
- try {
4207
- e();
4208
- } catch (t) {
4209
- console.error("Failed to setup mixin", t);
4210
- }
4211
- }), this.plugins.forEach((e) => {
4212
- try {
4213
- e.setup?.();
4214
- } catch (t) {
4215
- console.error(`Failed to setup ${e.name} plugin`, t);
4216
- }
4217
- }), this.emit("ready"));
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"));
4218
4221
  };
4219
4222
  install = (e) => {
4220
4223
  e.provide(Ae.injectionKey, this);
@@ -6344,23 +6347,6 @@ const Is = Yt({
6344
6347
  ], 2));
6345
6348
  }
6346
6349
  });
6347
- async function Ni() {
6348
- if (!("serviceWorker" in navigator)) {
6349
- console.warn("Service Worker is not supported in this browser/environment");
6350
- return;
6351
- }
6352
- try {
6353
- await new Promise((e) => {
6354
- document.readyState === "complete" || document.readyState === "interactive" ? e() : window.addEventListener("load", () => e(), { once: !0 });
6355
- });
6356
- const o = await navigator.serviceWorker.register("./sw.js", {
6357
- scope: "/"
6358
- });
6359
- console.log("Editor sw registered", o);
6360
- } catch (o) {
6361
- console.error("Editor sw registration failed", o);
6362
- }
6363
- }
6364
6350
  export {
6365
6351
  en as Doc,
6366
6352
  Pi as Drawboard,
@@ -6406,7 +6392,6 @@ export {
6406
6392
  Yt as propsFactory,
6407
6393
  Ii as provideEditor,
6408
6394
  $s as provideOverlay,
6409
- Ni as registerSw,
6410
6395
  so as uint32,
6411
6396
  re as useEditor,
6412
6397
  Es as useIcon,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.1.2",
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>;