@pixerate/editor-react 0.94.0 → 0.96.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.
Files changed (56) hide show
  1. package/README.md +3 -1
  2. package/dist/animation-editor/index.cjs +1240 -195
  3. package/dist/animation-editor/index.js +4 -2
  4. package/dist/canvas/index.cjs +1419 -372
  5. package/dist/canvas/index.js +9 -4
  6. package/dist/canvas/useMermaidDiagram.d.cts +7 -1
  7. package/dist/canvas/useMermaidDiagram.d.ts +7 -1
  8. package/dist/chunk-3I7FOSLF.js +988 -0
  9. package/dist/{chunk-OTGJEYHV.js → chunk-5LFQ2UQZ.js} +75 -68
  10. package/dist/{chunk-5R67YSSD.js → chunk-GLSOQNQR.js} +1 -1
  11. package/dist/{chunk-6YRSQW2V.js → chunk-IY6YOY5B.js} +1 -1
  12. package/dist/chunk-KIRIU53A.js +72 -0
  13. package/dist/{chunk-NNM633RN.js → chunk-R7MEGRPV.js} +23 -0
  14. package/dist/color/ColorPicker.d.cts +30 -0
  15. package/dist/color/ColorPicker.d.ts +30 -0
  16. package/dist/color/DualColorPicker.d.cts +29 -0
  17. package/dist/color/DualColorPicker.d.ts +29 -0
  18. package/dist/color/index.cjs +1067 -0
  19. package/dist/color/index.d.cts +7 -0
  20. package/dist/color/index.d.ts +7 -0
  21. package/dist/color/index.js +14 -0
  22. package/dist/color/useColorScheme.d.cts +16 -0
  23. package/dist/color/useColorScheme.d.ts +16 -0
  24. package/dist/effects/index.cjs +1169 -124
  25. package/dist/effects/index.js +4 -2
  26. package/dist/gradient/FillPicker.d.cts +27 -0
  27. package/dist/gradient/FillPicker.d.ts +27 -0
  28. package/dist/gradient/GradientEditor.d.cts +21 -0
  29. package/dist/gradient/GradientEditor.d.ts +21 -0
  30. package/dist/gradient/index.cjs +1601 -0
  31. package/dist/gradient/index.d.cts +6 -0
  32. package/dist/gradient/index.d.ts +6 -0
  33. package/dist/gradient/index.js +617 -0
  34. package/dist/gradient/useGradientController.d.cts +10 -0
  35. package/dist/gradient/useGradientController.d.ts +10 -0
  36. package/dist/image-editor/index.cjs +1742 -697
  37. package/dist/image-editor/index.js +5 -3
  38. package/dist/index.cjs +2181 -1115
  39. package/dist/index.js +9 -5
  40. package/dist/paint-editor/index.cjs +1233 -188
  41. package/dist/paint-editor/index.js +4 -2
  42. package/dist/parameters/fields.d.cts +1 -1
  43. package/dist/parameters/fields.d.ts +1 -1
  44. package/dist/parameters/index.cjs +1218 -173
  45. package/dist/parameters/index.js +3 -1
  46. package/dist/persistence/index.cjs +25 -4
  47. package/dist/persistence/index.d.cts +1 -0
  48. package/dist/persistence/index.d.ts +1 -0
  49. package/dist/persistence/index.js +5 -3
  50. package/dist/persistence/useEditorAutosave.d.cts +17 -0
  51. package/dist/persistence/useEditorAutosave.d.ts +17 -0
  52. package/dist/vector/index.cjs +1219 -174
  53. package/dist/vector/index.js +4 -2
  54. package/dist/video-editor/index.cjs +1230 -185
  55. package/dist/video-editor/index.js +4 -2
  56. package/package.json +29 -3
@@ -15,7 +15,9 @@ import {
15
15
  ParameterVector,
16
16
  parameterButtonClass,
17
17
  parameterInputClass
18
- } from "../chunk-OTGJEYHV.js";
18
+ } from "../chunk-5LFQ2UQZ.js";
19
+ import "../chunk-KIRIU53A.js";
20
+ import "../chunk-3I7FOSLF.js";
19
21
  import {
20
22
  PresenceLayer,
21
23
  useAgentPlayback
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var persistence_exports = {};
22
22
  __export(persistence_exports, {
23
23
  RecoveryPrompt: () => RecoveryPrompt,
24
- useAutosave: () => useAutosave
24
+ useAutosave: () => useAutosave,
25
+ useEditorAutosave: () => useEditorAutosave
25
26
  });
26
27
  module.exports = __toCommonJS(persistence_exports);
27
28
 
@@ -129,8 +130,27 @@ function useAutosave(options) {
129
130
  return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
130
131
  }
131
132
 
132
- // src/persistence/RecoveryPrompt.tsx
133
+ // src/persistence/useEditorAutosave.ts
134
+ var import_react2 = require("react");
133
135
  var import_persistence2 = require("@pixerate/editor/persistence");
136
+ function useEditorAutosave(doc, options) {
137
+ const autosave = useAutosave({
138
+ ...options,
139
+ key: options.key ?? doc.kind,
140
+ getSnapshot: () => (0, import_persistence2.toEditorDocumentFile)(doc),
141
+ deserialize: (text) => (0, import_persistence2.parseEditorDocument)(text, { kind: doc.kind }),
142
+ history: doc
143
+ });
144
+ const take = autosave.restore;
145
+ const restore = (0, import_react2.useCallback)(() => {
146
+ const snapshot = take();
147
+ return snapshot ? doc.loadDocument(snapshot, { history: "reset" }) : void 0;
148
+ }, [take, doc]);
149
+ return { ...autosave, restore };
150
+ }
151
+
152
+ // src/persistence/RecoveryPrompt.tsx
153
+ var import_persistence3 = require("@pixerate/editor/persistence");
134
154
  var import_jsx_runtime = require("react/jsx-runtime");
135
155
  var RecoveryPrompt = ({
136
156
  recovery,
@@ -152,7 +172,7 @@ var RecoveryPrompt = ({
152
172
  className: `flex flex-wrap items-center gap-3 rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground shadow-sm ${className}`,
153
173
  children: [
154
174
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "min-w-0 flex-1", children: [
155
- (0, import_persistence2.formatRecoveryMessage)(recovery.meta, formatTime),
175
+ (0, import_persistence3.formatRecoveryMessage)(recovery.meta, formatTime),
156
176
  name ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ml-1 text-xs text-muted-foreground", children: [
157
177
  "(",
158
178
  name,
@@ -186,5 +206,6 @@ var RecoveryPrompt = ({
186
206
  // Annotate the CommonJS export names for ESM import in node:
187
207
  0 && (module.exports = {
188
208
  RecoveryPrompt,
189
- useAutosave
209
+ useAutosave,
210
+ useEditorAutosave
190
211
  });
@@ -1,2 +1,3 @@
1
1
  export * from './useAutosave.cjs';
2
+ export * from './useEditorAutosave.cjs';
2
3
  export * from './RecoveryPrompt.cjs';
@@ -1,2 +1,3 @@
1
1
  export * from './useAutosave.js';
2
+ export * from './useEditorAutosave.js';
2
3
  export * from './RecoveryPrompt.js';
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  RecoveryPrompt,
3
- useAutosave
4
- } from "../chunk-NNM633RN.js";
3
+ useAutosave,
4
+ useEditorAutosave
5
+ } from "../chunk-R7MEGRPV.js";
5
6
  export {
6
7
  RecoveryPrompt,
7
- useAutosave
8
+ useAutosave,
9
+ useEditorAutosave
8
10
  };
@@ -0,0 +1,17 @@
1
+ import { type EditorDocument, type EditorDocumentFile, type LoadReport } from '@pixerate/editor/persistence';
2
+ import { type UseAutosaveOptions, type UseAutosaveResult } from './useAutosave.cjs';
3
+ export interface UseEditorAutosaveOptions extends Omit<UseAutosaveOptions<EditorDocumentFile>, 'key' | 'getSnapshot' | 'serialize' | 'deserialize' | 'history'> {
4
+ /** Snapshot key (default the document's `kind`). */
5
+ key?: string;
6
+ }
7
+ export interface UseEditorAutosaveResult extends Omit<UseAutosaveResult<EditorDocumentFile>, 'restore'> {
8
+ /** Loads the recovered snapshot into the document and starts autosaving. */
9
+ restore: () => LoadReport | undefined;
10
+ }
11
+ /**
12
+ * `useAutosave` for any editor's `EditorDocument` (e.g. `useMermaidDiagram().editorDocument`):
13
+ * snapshots it as an `EditorDocumentFile` after each change, and `restore` loads a
14
+ * recovered snapshot straight into the editor. Render `<RecoveryPrompt>` with
15
+ * `recovery`, `restore` and `discard`. Pass a stable `doc`.
16
+ */
17
+ export declare function useEditorAutosave(doc: EditorDocument, options: UseEditorAutosaveOptions): UseEditorAutosaveResult;
@@ -0,0 +1,17 @@
1
+ import { type EditorDocument, type EditorDocumentFile, type LoadReport } from '@pixerate/editor/persistence';
2
+ import { type UseAutosaveOptions, type UseAutosaveResult } from './useAutosave.js';
3
+ export interface UseEditorAutosaveOptions extends Omit<UseAutosaveOptions<EditorDocumentFile>, 'key' | 'getSnapshot' | 'serialize' | 'deserialize' | 'history'> {
4
+ /** Snapshot key (default the document's `kind`). */
5
+ key?: string;
6
+ }
7
+ export interface UseEditorAutosaveResult extends Omit<UseAutosaveResult<EditorDocumentFile>, 'restore'> {
8
+ /** Loads the recovered snapshot into the document and starts autosaving. */
9
+ restore: () => LoadReport | undefined;
10
+ }
11
+ /**
12
+ * `useAutosave` for any editor's `EditorDocument` (e.g. `useMermaidDiagram().editorDocument`):
13
+ * snapshots it as an `EditorDocumentFile` after each change, and `restore` loads a
14
+ * recovered snapshot straight into the editor. Render `<RecoveryPrompt>` with
15
+ * `recovery`, `restore` and `discard`. Pass a stable `doc`.
16
+ */
17
+ export declare function useEditorAutosave(doc: EditorDocument, options: UseEditorAutosaveOptions): UseEditorAutosaveResult;