@pixerate/editor-svelte 0.213.6 → 0.214.0

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.
@@ -28,13 +28,18 @@ export { button, chip } from '../brushes/styles.js';
28
28
  export declare const panel = "flex flex-col gap-2 text-xs text-slate-200";
29
29
  /** Runs `fn` and returns the error message it threw (or a rejected promise's, through `onAsync`). */
30
30
  export declare function attempt(fn: () => unknown, onError: (msg: string | null) => void): void;
31
- /** The controller's effects provider as a rune, following `setEffectsProvider`. */
31
+ /**
32
+ * The effects the panel offers as a rune: the controller's provider with the painting's authored
33
+ * effects (`controller.effectsCatalog`), following `setEffectsProvider` and saved or removed
34
+ * authored effects.
35
+ */
32
36
  export declare function paintEffectsProvider(controller: () => PaintEditorController): {
33
37
  readonly current: EffectProvider | null;
34
38
  };
35
39
  /**
36
40
  * Registers the paint editor's provider-effect tools (`set_paper_effect`, `add_effect_layer`,
37
41
  * `fill_layer_with_effect`, `apply_effect`, …) for the lifetime of the calling component. Before
38
- * an effects provider is registered the read tools say so and the write tools refuse.
42
+ * an effects provider is registered the read tools say so and the write tools refuse. Also
43
+ * registers the effect authoring tools (`open_effect_authoring`, `save_authored_effect`, …).
39
44
  */
40
45
  export declare function usePaintEffectsTools(registry: ToolRegistry | null | undefined | (() => ToolRegistry | null | undefined), controller: PaintEditorController, options?: PaintEffectsToolProviderOptions): void;
@@ -1,5 +1,5 @@
1
1
  import { untrack } from 'svelte';
2
- import { createPaintEditorDocument, createPaintEffectsToolProvider, PaintDirector, PaintEditorController, PaintPresence } from '@pixerate/editor/paint-editor';
2
+ import { createPaintEditorDocument, createPaintEffectAuthoringToolProvider, createPaintEffectsToolProvider, PaintDirector, PaintEditorController, PaintPresence } from '@pixerate/editor/paint-editor';
3
3
  /**
4
4
  * A `PaintEditorController` (created from `options`, or the one given) with its state as a
5
5
  * rune: `editor.state` updates after every change. Call `destroy()` to unsubscribe.
@@ -73,16 +73,26 @@ export function attempt(fn, onError) {
73
73
  onError(e instanceof Error ? e.message : String(e));
74
74
  }
75
75
  }
76
- /** The controller's effects provider as a rune, following `setEffectsProvider`. */
76
+ /**
77
+ * The effects the panel offers as a rune: the controller's provider with the painting's authored
78
+ * effects (`controller.effectsCatalog`), following `setEffectsProvider` and saved or removed
79
+ * authored effects.
80
+ */
77
81
  export function paintEffectsProvider(controller) {
78
- let provider = $state.raw(controller().effectsProvider);
82
+ let provider = $state.raw(controller().effectsCatalog);
79
83
  $effect(() => {
80
84
  const c = controller();
81
85
  return untrack(() => {
82
- provider = c.effectsProvider;
83
- return c.effects.subscribe((p) => {
84
- provider = p;
85
- });
86
+ const sync = () => {
87
+ provider = c.effectsCatalog;
88
+ };
89
+ sync();
90
+ const a = c.effects.subscribe(sync);
91
+ const b = c.subscribe(sync);
92
+ return () => {
93
+ a();
94
+ b();
95
+ };
86
96
  });
87
97
  });
88
98
  return {
@@ -94,13 +104,20 @@ export function paintEffectsProvider(controller) {
94
104
  /**
95
105
  * Registers the paint editor's provider-effect tools (`set_paper_effect`, `add_effect_layer`,
96
106
  * `fill_layer_with_effect`, `apply_effect`, …) for the lifetime of the calling component. Before
97
- * an effects provider is registered the read tools say so and the write tools refuse.
107
+ * an effects provider is registered the read tools say so and the write tools refuse. Also
108
+ * registers the effect authoring tools (`open_effect_authoring`, `save_authored_effect`, …).
98
109
  */
99
110
  export function usePaintEffectsTools(registry, controller, options = {}) {
100
111
  $effect(() => {
101
112
  const target = typeof registry === 'function' ? registry() : registry;
102
113
  if (!target)
103
114
  return;
104
- return target.register(createPaintEffectsToolProvider(controller, options));
115
+ const a = target.register(createPaintEffectsToolProvider(controller, options));
116
+ const { id, namespace } = options;
117
+ const b = target.register(createPaintEffectAuthoringToolProvider(controller, { ...options, id: id ? `${id}-authoring` : undefined, namespace: namespace === undefined ? undefined : namespace && `${namespace}-authoring` }));
118
+ return () => {
119
+ a();
120
+ b();
121
+ };
105
122
  });
106
123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-svelte",
3
- "version": "0.213.6",
3
+ "version": "0.214.0",
4
4
  "description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -184,7 +184,7 @@
184
184
  "**/*.css"
185
185
  ],
186
186
  "dependencies": {
187
- "@pixerate/editor": "0.287.0"
187
+ "@pixerate/editor": "0.289.0"
188
188
  },
189
189
  "peerDependencies": {
190
190
  "@dagrejs/dagre": "^1.1.4",