@pixerate/editor-svelte 0.17.2 → 0.17.4

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.
@@ -17,6 +17,7 @@
17
17
  calculateCropDrag,
18
18
  hitTestAnnotation,
19
19
  } from '@pixerate/editor/image-editor';
20
+ import { onDestroy, untrack } from 'svelte';
20
21
  import { createReactiveImageEditor, type ReactiveImageEditor } from './imageEditorState.svelte.js';
21
22
 
22
23
  interface Props {
@@ -45,6 +46,7 @@
45
46
 
46
47
  const internalEditor = createReactiveImageEditor();
47
48
  const editor = $derived(propEditor || internalEditor);
49
+ onDestroy(() => internalEditor.destroy());
48
50
 
49
51
  let canvasEl = $state<HTMLCanvasElement | null>(null);
50
52
  let containerEl = $state<HTMLDivElement | null>(null);
@@ -147,11 +149,16 @@
147
149
  let currentPath: ImagePoint[] = [];
148
150
  let dragStartPoint: ImagePoint | null = null;
149
151
 
150
- // Update image when src changes
152
+ // Load the image when `src` changes. Only `src` is tracked: AI edits replace
153
+ // the editor's source with a data URL and must not be reverted to `src`.
154
+ let loadedSrc: string | undefined;
151
155
  $effect(() => {
152
- if (src && src !== editor.state.sourceUrl) {
153
- editor.loadImage(src);
154
- }
156
+ const next = src;
157
+ if (!next || next === loadedSrc) return;
158
+ loadedSrc = next;
159
+ untrack(() => {
160
+ if (next !== editor.state.sourceUrl) editor.loadImage(next);
161
+ });
155
162
  });
156
163
 
157
164
  async function renderCanvas(overrideAnnotation?: Annotation | null, overrideCrop?: CropBox | null) {
@@ -1 +1 @@
1
- {"version":3,"file":"ImageEditor.svelte.d.ts","sourceRoot":"","sources":["../../src/image-editor/ImageEditor.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIR,aAAa,EAGb,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,+BAA+B,CAAC;AAQzC,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGjG,UAAU,KAAK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AC,CAAC;AAClD,eAAe,WAAW,CAAC"}
@@ -45,6 +45,8 @@ export declare function createReactiveImageEditor(options?: ImageEditorOptions):
45
45
  }): Promise<string>;
46
46
  applyInpaintedImage(newDataUrl: string): Promise<void>;
47
47
  applyBackgroundRemovedImage(newDataUrl: string): Promise<void>;
48
+ /** Stops syncing controller state; call when the editor is no longer used. */
49
+ destroy(): void;
48
50
  };
49
51
  export type ReactiveImageEditor = ReturnType<typeof createReactiveImageEditor>;
50
52
  //# sourceMappingURL=imageEditorState.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"imageEditorState.svelte.d.ts","sourceRoot":"","sources":["../../src/image-editor/imageEditorState.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAC/B,KAAK,UAAU,EAChB,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,kBAAuB;;;;;kBA0BxD,eAAe;kBAGf,OAAO,GAAG,IAAI;2BAGL,WAAW;;oBAMlB,MAAM;yBAGD,MAAM;;;4BASH,OAAO,CAAC,gBAAgB,CAAC;;0BAM3B,OAAO,CAAC,gBAAgB,CAAC;;uBAM5B,uBAAuB;yBAGrB,MAAM,WAAW,OAAO,CAAC,UAAU,CAAC;yBAGpC,MAAM;;yBAMN,MAAM,GAAG,IAAI;;;;oBAYlB,MAAM;qBAGL,MAAM;;kBAMT,MAAM;gBAGR,UAAU;4BAGE,OAAO;mBAGhB,MAAM,GAAG,gBAAgB;qBAGvB,aAAa;kBAGhB,aAAa;;mBAMZ,0BAA0B;sBAGvB;QAAE,cAAc,CAAC,EAAE,OAAO,CAAC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AAO,CAAA;KAAE;oCAGpC,MAAM;4CAGE,MAAM;IAG9C,8EAA8E;;EAKjF;AAED,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -3,7 +3,7 @@ export function createReactiveImageEditor(options = {}) {
3
3
  const controller = new ImageEditorController(options);
4
4
  let state = $state(controller.getState());
5
5
  let historyTicks = $state(0);
6
- controller.subscribe((updated) => {
6
+ const unsubscribe = controller.subscribe((updated) => {
7
7
  state = { ...updated };
8
8
  historyTicks++;
9
9
  });
@@ -128,5 +128,9 @@ export function createReactiveImageEditor(options = {}) {
128
128
  applyBackgroundRemovedImage(newDataUrl) {
129
129
  return controller.applyBackgroundRemovedImage(newDataUrl);
130
130
  },
131
+ /** Stops syncing controller state; call when the editor is no longer used. */
132
+ destroy() {
133
+ unsubscribe();
134
+ },
131
135
  };
132
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-svelte",
3
- "version": "0.17.2",
3
+ "version": "0.17.4",
4
4
  "description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -52,7 +52,7 @@
52
52
  "@tiptap/extension-bubble-menu": "^2.11.5",
53
53
  "@tiptap/extension-placeholder": "^2.11.5",
54
54
  "@tiptap/starter-kit": "^2.11.5",
55
- "@pixerate/editor": "0.16.2"
55
+ "@pixerate/editor": "0.17.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@tiptap/core": "^2.11.5",