@burger-editor/client 4.0.0-alpha.71 → 4.0.0-alpha.73

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 (87) hide show
  1. package/README.md +22 -9
  2. package/dist/__tests__/setup.d.ts +2 -0
  3. package/dist/__tests__/setup.d.ts.map +1 -0
  4. package/dist/burger-editor-root.d.ts +3 -7
  5. package/dist/burger-editor-root.d.ts.map +1 -1
  6. package/dist/client.css +1 -0
  7. package/dist/client.js +24180 -29905
  8. package/dist/client.js.map +1 -1
  9. package/dist/commands/register-engine-commands.d.ts +2 -1
  10. package/dist/commands/register-engine-commands.d.ts.map +1 -1
  11. package/dist/components/block-catalog.d.ts +3 -5
  12. package/dist/components/block-catalog.d.ts.map +1 -1
  13. package/dist/components/block-menu-button.d.ts +1 -1
  14. package/dist/components/block-menu-view.d.ts +82 -0
  15. package/dist/components/block-menu-view.d.ts.map +1 -0
  16. package/dist/components/block-menu.d.ts +7 -5
  17. package/dist/components/block-menu.d.ts.map +1 -1
  18. package/dist/components/block-options.d.ts +4 -6
  19. package/dist/components/block-options.d.ts.map +1 -1
  20. package/dist/components/draft-switcher.d.ts +11 -10
  21. package/dist/components/draft-switcher.d.ts.map +1 -1
  22. package/dist/components/editable-area-view.d.ts +11 -14
  23. package/dist/components/editable-area-view.d.ts.map +1 -1
  24. package/dist/components/file-list.d.ts +9 -9
  25. package/dist/components/file-list.d.ts.map +1 -1
  26. package/dist/components/file-uploader.d.ts +6 -6
  27. package/dist/components/file-uploader.d.ts.map +1 -1
  28. package/dist/components/front-matter-editor.d.ts +104 -0
  29. package/dist/components/front-matter-editor.d.ts.map +1 -0
  30. package/dist/components/index.d.ts +5 -0
  31. package/dist/components/index.d.ts.map +1 -1
  32. package/dist/components/initial-insertion-button.d.ts +7 -2
  33. package/dist/components/initial-insertion-button.d.ts.map +1 -1
  34. package/dist/components/item-editor-host.d.ts +7 -6
  35. package/dist/components/item-editor-host.d.ts.map +1 -1
  36. package/dist/components/preview.d.ts +4 -7
  37. package/dist/components/preview.d.ts.map +1 -1
  38. package/dist/components/table-editor.d.ts.map +1 -1
  39. package/dist/components/wysiwyg-field.d.ts +11 -1
  40. package/dist/components/wysiwyg-field.d.ts.map +1 -1
  41. package/dist/editable-area-view-DssYcTqQ.js +2941 -0
  42. package/dist/editable-area-view-DssYcTqQ.js.map +1 -0
  43. package/dist/editor-dialog.d.ts +16 -7
  44. package/dist/editor-dialog.d.ts.map +1 -1
  45. package/dist/engine-context-gX6mWHke.js +15758 -0
  46. package/dist/engine-context-gX6mWHke.js.map +1 -0
  47. package/dist/engine-context.d.ts +40 -0
  48. package/dist/engine-context.d.ts.map +1 -0
  49. package/dist/file-browser/store.d.ts +127 -0
  50. package/dist/file-browser/store.d.ts.map +1 -0
  51. package/dist/file-browser/use-external-file-selection.d.ts +39 -0
  52. package/dist/file-browser/use-external-file-selection.d.ts.map +1 -0
  53. package/dist/file-browser/use-file-browser.d.ts +17 -0
  54. package/dist/file-browser/use-file-browser.d.ts.map +1 -0
  55. package/dist/form/text-field.d.ts +3 -1
  56. package/dist/form/text-field.d.ts.map +1 -1
  57. package/dist/index.d.ts +7 -3
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/mount.d.ts +14 -8
  60. package/dist/mount.d.ts.map +1 -1
  61. package/dist/root-error-boundary.d.ts +34 -0
  62. package/dist/root-error-boundary.d.ts.map +1 -0
  63. package/dist/testing/create-mock-engine.d.ts +30 -0
  64. package/dist/testing/create-mock-engine.d.ts.map +1 -0
  65. package/dist/testing/index.d.ts +4 -0
  66. package/dist/testing/index.d.ts.map +1 -0
  67. package/dist/testing/render-with-engine.d.ts +20 -0
  68. package/dist/testing/render-with-engine.d.ts.map +1 -0
  69. package/dist/testing/suppress-console-error.d.ts +24 -0
  70. package/dist/testing/suppress-console-error.d.ts.map +1 -0
  71. package/dist/testing.js +119 -0
  72. package/dist/testing.js.map +1 -0
  73. package/dist/ui.d.ts +7 -1
  74. package/dist/ui.d.ts.map +1 -1
  75. package/dist/ui.js +2680 -956
  76. package/dist/ui.js.map +1 -1
  77. package/dist/use-command.d.ts +13 -4
  78. package/dist/use-command.d.ts.map +1 -1
  79. package/dist/use-engine.d.ts +16 -32
  80. package/dist/use-engine.d.ts.map +1 -1
  81. package/dist/use-mount-effect.d.ts +20 -0
  82. package/dist/use-mount-effect.d.ts.map +1 -0
  83. package/dist/view/create-react-view.d.ts +33 -9
  84. package/dist/view/create-react-view.d.ts.map +1 -1
  85. package/package.json +44 -17
  86. package/dist/initial-insertion-button-DMGBvuDE.js +0 -9147
  87. package/dist/initial-insertion-button-DMGBvuDE.js.map +0 -1
@@ -0,0 +1,40 @@
1
+ import { BurgerEditorEngine } from '@burger-editor/core';
2
+ import { ReactNode } from 'react';
3
+ /**
4
+ * Wrap a subtree with the engine instance it belongs to. Every component
5
+ * rendered under a `BurgerEditorRoot` / editable-area tree reads the engine
6
+ * through {@link useEngine} instead of taking it as a prop — this is the
7
+ * single dependency-injection point for the whole client UI.
8
+ * @param root0
9
+ * @param root0.engine
10
+ * @param root0.children
11
+ * @example
12
+ * ```tsx
13
+ * <EngineProvider engine={engine}>
14
+ * <BurgerEditorRoot />
15
+ * </EngineProvider>
16
+ * ```
17
+ */
18
+ export declare function EngineProvider({ engine, children, }: {
19
+ readonly engine: BurgerEditorEngine;
20
+ readonly children: ReactNode;
21
+ }): import('react').FunctionComponentElement<import('react').ProviderProps<BurgerEditorEngine | null>>;
22
+ /**
23
+ * Read the engine instance from the nearest {@link EngineProvider}.
24
+ *
25
+ * Every root the client mounts (`BurgerEditorRoot`, the editable-area
26
+ * tree, `DraftSwitcher`) wraps itself in an `EngineProvider`, so item
27
+ * `Editor` components and every `@burger-editor/client/ui` component can
28
+ * call this instead of taking `engine` as a prop.
29
+ * @returns The engine instance
30
+ * @throws {Error} When called outside an `EngineProvider`
31
+ * @example
32
+ * ```tsx
33
+ * function MyField() {
34
+ * const engine = useEngine();
35
+ * return <button onClick={() => engine.save()}>Save</button>;
36
+ * }
37
+ * ```
38
+ */
39
+ export declare function useEngine(): BurgerEditorEngine;
40
+ //# sourceMappingURL=engine-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-context.d.ts","sourceRoot":"","sources":["../src/engine-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,EAC9B,MAAM,EACN,QAAQ,GACR,EAAE;IACF,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC7B,sGAEA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,IAAI,kBAAkB,CAM9C"}
@@ -0,0 +1,127 @@
1
+ import { BurgerEditorEngine, FileListResult, FileType } from '@burger-editor/core';
2
+ /**
3
+ * A file currently selected for a given `FileType` inside a dialog — the
4
+ * path the item editor should apply, plus the byte size the old
5
+ * `file-select` component-observer payload used to carry.
6
+ */
7
+ export interface SelectedFile {
8
+ readonly path: string;
9
+ readonly fileSize: number;
10
+ }
11
+ /**
12
+ * One upload in flight. Kept in the store (not local component state) so
13
+ * `FileList` and `Preview` — siblings under the same item editor — both
14
+ * see the same synthetic "uploading…" row / progress bar without a
15
+ * broadcast bus.
16
+ */
17
+ export interface UploadProgress {
18
+ readonly fileType: FileType;
19
+ readonly blob: string;
20
+ readonly uploaded: number;
21
+ readonly total: number;
22
+ }
23
+ export interface FileBrowserQuery {
24
+ readonly fileType: FileType;
25
+ readonly page: number;
26
+ readonly filter: string;
27
+ }
28
+ interface FileBrowserState {
29
+ readonly selected: {
30
+ readonly [K in FileType]?: SelectedFile;
31
+ };
32
+ readonly uploads: readonly UploadProgress[];
33
+ }
34
+ type Listener = () => void;
35
+ /**
36
+ * Per-engine file-browser state: paginated/filtered `getFileList` query
37
+ * results (cached by query, read through `use()`), the file currently
38
+ * selected per `FileType`, and in-flight upload progress.
39
+ *
40
+ * React-independent so it can be constructed once per engine and shared
41
+ * by every component that opens onto the same file browser (`FileList`,
42
+ * `FileUploader`, `Preview`, and the item's own `Editor`) without a
43
+ * window-level broadcast bus — see {@link getFileBrowserStore}.
44
+ * @example
45
+ * ```tsx
46
+ * const store = getFileBrowserStore(engine);
47
+ * const result = use(store.read({ fileType: 'image', page: 0, filter: '' }));
48
+ * const selected = useSyncExternalStore(store.subscribe, store.getSnapshot);
49
+ * ```
50
+ */
51
+ export declare class FileBrowserStore {
52
+ #private;
53
+ readonly getSnapshot: () => FileBrowserState;
54
+ readonly subscribe: (listener: Listener) => (() => void);
55
+ /** Whether the engine's `serverAPI` supports deleting files. */
56
+ get canDelete(): boolean;
57
+ constructor(engine: BurgerEditorEngine);
58
+ /**
59
+ * Delete a file from the server and invalidate `fileType`'s cached
60
+ * pages so the list reflects the deletion on next read.
61
+ * @param fileType - The file type the file belongs to
62
+ * @param url - The file's URL
63
+ * @throws {Error} When the server reports the deletion failed
64
+ */
65
+ deleteFile(fileType: FileType, url: string): Promise<void>;
66
+ /**
67
+ * Drop every cached page for `fileType` and notify subscribers, so the
68
+ * next `read()` for that type issues a fresh request (after an upload
69
+ * or a delete changes the underlying list).
70
+ * @param fileType - The file type whose cached pages should be dropped
71
+ */
72
+ invalidate(fileType: FileType): void;
73
+ /**
74
+ * Read (and cache) one page of the file list. The returned promise is
75
+ * stable per `{fileType, page, filter}` plus whether this particular
76
+ * read sent `selected` (see below) — safe to pass to `use()` directly
77
+ * from render, repeated calls with the same query return the same
78
+ * promise instead of re-suspending.
79
+ *
80
+ * The very first read for a given `fileType` also sends the currently
81
+ * selected file's path as `selected`, so the server can jump straight
82
+ * to the page that already contains it (e.g. re-opening an image item
83
+ * whose file isn't on page 0) instead of always starting at `page`.
84
+ * Later reads for that `fileType` (explicit pagination, search, or a
85
+ * post-upload/-delete refetch via {@link invalidate}) omit it — always
86
+ * including it would silently override the page the caller asked for.
87
+ *
88
+ * Because that jump means the response's actual page can differ from
89
+ * the requested one, `selected` is folded into the cache key (see
90
+ * {@link queryKey}): a later item opening the same `fileType` and
91
+ * nominal page never transparently receives the first item's
92
+ * page-jumped response — it misses the cache and gets a real page.
93
+ * @param query - The file type, page and filter to query
94
+ * @returns The (possibly still-pending, cached) file list page
95
+ */
96
+ read(query: FileBrowserQuery): Promise<FileListResult>;
97
+ /**
98
+ * Record the file currently selected for `fileType` — a no-op when the
99
+ * path is unchanged, so callers can call this unconditionally (e.g.
100
+ * every render) without causing redundant notifications.
101
+ * @param fileType - The file type being selected for
102
+ * @param path - The selected file's path, or `''` for "nothing selected"
103
+ * @param fileSize - The selected file's byte size, when known
104
+ */
105
+ select(fileType: FileType, path: string, fileSize?: number): void;
106
+ /**
107
+ * Upload a file, tracking progress in `uploads` (so `FileList` and
108
+ * `Preview` can both show it) and selecting the resulting URL once the
109
+ * server responds — a blob URL is selected immediately so the UI has
110
+ * something to show while the upload is in flight.
111
+ * @param fileType - The file type to upload into
112
+ * @param file - The file to upload
113
+ * @throws {Error} When no `postFile` API is configured, or the server
114
+ * reports the upload failed
115
+ */
116
+ upload(fileType: FileType, file: File): Promise<void>;
117
+ }
118
+ /**
119
+ * Get (creating on first access) the `FileBrowserStore` for `engine`. One
120
+ * store per engine, shared by every component under it — see
121
+ * {@link FileBrowserStore}.
122
+ * @param engine - The engine to get the store for
123
+ * @returns That engine's file-browser store
124
+ */
125
+ export declare function getFileBrowserStore(engine: BurgerEditorEngine): FileBrowserStore;
126
+ export {};
127
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/file-browser/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,kBAAkB,EAClB,cAAc,EACd,QAAQ,EAER,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,gBAAgB;IACzB,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,EAAE,YAAY;KAAE,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;CAC5C;AAQD,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAwB3B;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,gBAAgB;;IAC5B,QAAQ,CAAC,WAAW,QAAO,gBAAgB,CAAgB;IAE3D,QAAQ,CAAC,SAAS,GAAI,UAAU,QAAQ,KAAG,CAAC,MAAM,IAAI,CAAC,CAKrD;IAYF,gEAAgE;IAChE,IAAI,SAAS,IAAI,OAAO,CAEvB;gBAEW,MAAM,EAAE,kBAAkB;IAItC;;;;;;OAMG;IACG,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYhE;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAUpC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BtD;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,IAAI;IAU5D;;;;;;;;;OASG;IACG,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAyC3D;AAID;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,GAAG,gBAAgB,CAOhF"}
@@ -0,0 +1,39 @@
1
+ import { SelectedFile } from './store.js';
2
+ /**
3
+ * React to a file becoming selected from outside the item's own `Editor`
4
+ * (i.e. via `FileList`, in the same `FileBrowserStore` the item's own
5
+ * `fileType` uses) — `onExternalChange` is called with the new selection.
6
+ *
7
+ * `selected` is shared per-engine across every item that opens onto the
8
+ * same `fileType`, so it can still hold a *previous* item's selection at
9
+ * the moment a new `Editor` instance mounts. This hook's first effect run
10
+ * is always skipped for that reason — reacting to it would load that
11
+ * stale, unrelated selection into the freshly-mounted item's own state,
12
+ * racing the item's own mount-time `fileBrowser.select(fileType, ownPath)`
13
+ * call (whichever one's async work — if any — finishes last wins,
14
+ * corrupting the item with a different item's file). Callers still need
15
+ * their own mount effect to register their own current path with the
16
+ * store; this hook only covers reacting to *later* external changes.
17
+ * @param selected - The `fileType`'s current selection (from
18
+ * `useSyncExternalStore(fileBrowser.subscribe, () =>
19
+ * fileBrowser.getSnapshot().selected[fileType])`)
20
+ * @param getCurrentPath - Returns the item's own current path at call
21
+ * time (a function, not a plain value, so the effect doesn't need it in
22
+ * its dependency array and can stay `[selected]`-only)
23
+ * @param onExternalChange - Called when `selected` changes to a path
24
+ * different from `getCurrentPath()`, after the initial mount is skipped
25
+ * @example
26
+ * ```tsx
27
+ * const selected = useSyncExternalStore(
28
+ * fileBrowser.subscribe,
29
+ * () => fileBrowser.getSnapshot().selected.image,
30
+ * );
31
+ * useExternalFileSelection(
32
+ * selected,
33
+ * () => state.path ?? '',
34
+ * (next) => setState((prev) => ({ ...prev, path: next.path })),
35
+ * );
36
+ * ```
37
+ */
38
+ export declare function useExternalFileSelection(selected: SelectedFile | undefined, getCurrentPath: () => string, onExternalChange: (selected: SelectedFile) => void): void;
39
+ //# sourceMappingURL=use-external-file-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-external-file-selection.d.ts","sourceRoot":"","sources":["../../src/file-browser/use-external-file-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,wBAAwB,CACvC,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,cAAc,EAAE,MAAM,MAAM,EAC5B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,GAChD,IAAI,CAmBN"}
@@ -0,0 +1,17 @@
1
+ import { FileBrowserStore } from './store.js';
2
+ /**
3
+ * Get the current engine's `FileBrowserStore` — file-list query cache,
4
+ * current selection and upload progress shared by `FileList`,
5
+ * `FileUploader`, `Preview` and the item's own `Editor`.
6
+ * @returns The engine's file-browser store
7
+ * @example
8
+ * ```tsx
9
+ * const fileBrowser = useFileBrowser();
10
+ * const selected = useSyncExternalStore(
11
+ * fileBrowser.subscribe,
12
+ * () => fileBrowser.getSnapshot().selected.image,
13
+ * );
14
+ * ```
15
+ */
16
+ export declare function useFileBrowser(): FileBrowserStore;
17
+ //# sourceMappingURL=use-file-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-file-browser.d.ts","sourceRoot":"","sources":["../../src/file-browser/use-file-browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMnD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAGjD"}
@@ -13,6 +13,7 @@
13
13
  * @param root0.name
14
14
  * @param root0.disabled
15
15
  * @param root0.placeholder
16
+ * @param root0.describedBy
16
17
  * @example
17
18
  * ```tsx
18
19
  * <TextField
@@ -23,7 +24,7 @@
23
24
  * />
24
25
  * ```
25
26
  */
26
- export declare function TextField({ label, value, onChange, type, name, disabled, placeholder, }: {
27
+ export declare function TextField({ label, value, onChange, type, name, disabled, placeholder, describedBy, }: {
27
28
  readonly label: string;
28
29
  readonly value: string;
29
30
  readonly onChange: (value: string) => void;
@@ -31,5 +32,6 @@ export declare function TextField({ label, value, onChange, type, name, disabled
31
32
  readonly name?: string;
32
33
  readonly disabled?: boolean;
33
34
  readonly placeholder?: string;
35
+ readonly describedBy?: string;
34
36
  }): import("react").JSX.Element;
35
37
  //# sourceMappingURL=text-field.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text-field.d.ts","sourceRoot":"","sources":["../../src/form/text-field.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,EACzB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,IAAa,EACb,IAAI,EACJ,QAAQ,EACR,WAAW,GACX,EAAE;IACF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B,+BAcA"}
1
+ {"version":3,"file":"text-field.d.ts","sourceRoot":"","sources":["../../src/form/text-field.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,SAAS,CAAC,EACzB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,IAAa,EACb,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,WAAW,GACX,EAAE;IACF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B,+BAeA"}
package/dist/index.d.ts CHANGED
@@ -5,6 +5,10 @@ export declare const version: string;
5
5
  *
6
6
  * `createBurgerEditorClient` に含めず分離しているのは、配置位置
7
7
  * (エディタの外側のどこに置くか)がアプリケーション側の判断のため。
8
+ * 単一rootの対象外(`engine.viewArea`の外側、任意のDOM位置に置かれる
9
+ * ため): `createReactView()`が持つ単一rootとは別の独立したReact root
10
+ * を持つが、`EngineProvider`で包むため`DraftSwitcher`自体は
11
+ * `useEngine()`で取得する(propsは受け取らない)。
8
12
  * @param engine - 対象エンジン。下書きが無い構成では何もしない
9
13
  * @returns マウントハンドル(`cleanUp`でアンマウント)。下書きが無い場合はnull
10
14
  * @example
@@ -13,9 +17,9 @@ export declare const version: string;
13
17
  * attachDraftSwitcher(engine);
14
18
  * ```
15
19
  */
16
- export declare function attachDraftSwitcher(engine: BurgerEditorEngine): {
17
- cleanUp: () => void;
18
- } | null;
20
+ export declare function attachDraftSwitcher(engine: BurgerEditorEngine): (Disposable & {
21
+ cleanUp(): void;
22
+ }) | null;
19
23
  /**
20
24
  * BurgerEditorのクライアントUIを組み立てるメインエントリ
21
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AASzD,OAAO,gBAAgB,CAAC;AAExB,eAAO,MAAM,OAAO,QAAc,CAAC;AAEnC;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB;;SAS7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC;;GA+BhD;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAWzD,OAAO,gBAAgB,CAAC;AAExB,eAAO,MAAM,OAAO,QAAc,CAAC;AAEnC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB;;UAgB7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,MAAM,CAAC;;GAsChD;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/mount.d.ts CHANGED
@@ -1,18 +1,24 @@
1
1
  import { ReactNode } from 'react';
2
2
  /**
3
- * Mount a React node into a DOM container and return a cleanup handle,
4
- * matching the `UICreator` contract shape used across the engine.
3
+ * Mount a React node into a DOM container and return a `Disposable`
4
+ * teardown handle, matching the `UICreator` contract shape used across
5
+ * the engine.
5
6
  * @param node - The React node to render
6
7
  * @param target - The DOM container
7
- * @returns An object whose `cleanUp` unmounts the root
8
+ * @returns A handle that unmounts the root, via `using` or `cleanUp()`
8
9
  * @example
9
10
  * ```tsx
10
- * const { cleanUp } = reactMount(<DraftSwitcher engine={engine} />, container);
11
- * // When the UI is torn down:
12
- * cleanUp();
11
+ * using mount = reactMount(
12
+ * <EngineProvider engine={engine}>
13
+ * <DraftSwitcher />
14
+ * </EngineProvider>,
15
+ * container,
16
+ * );
17
+ * // Root is unmounted automatically when `mount` goes out of scope.
13
18
  * ```
14
19
  */
15
- export declare function reactMount(node: ReactNode, target: HTMLElement): {
16
- cleanUp: () => void;
20
+ export declare function reactMount(node: ReactNode, target: HTMLElement): Disposable & {
21
+ /** @deprecated Use a `using` declaration instead. */
22
+ cleanUp(): void;
17
23
  };
18
24
  //# sourceMappingURL=mount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW;;EAQ9D"}
1
+ {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CACzB,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,WAAW,GACjB,UAAU,GAAG;IACf,qDAAqD;IACrD,OAAO,IAAI,IAAI,CAAC;CAChB,CAaA"}
@@ -0,0 +1,34 @@
1
+ import { BurgerEditorEngine } from '@burger-editor/core';
2
+ import { ReactNode } from 'react';
3
+ /**
4
+ * Report a render error onto the engine element as `bge:error`. This is
5
+ * the only way an in-tree failure reaches code outside React — `core`
6
+ * never reads the event, platform layers (e.g. `local`) may log it.
7
+ * @param engine - The engine instance to report on
8
+ * @param error - The thrown value
9
+ * @param componentStack - The React component stack, when available
10
+ */
11
+ export declare function reportRenderError(engine: BurgerEditorEngine, error: unknown, componentStack?: string): void;
12
+ /**
13
+ * Reusable error boundary for the client UI tree: reports the caught
14
+ * error as `bge:error` and blanks only its own subtree. Deliberately not
15
+ * scoped to any one tree position — `createReactView` places one around
16
+ * the whole single-root tree as a last resort, and one more per editable
17
+ * area so a failure in one area (or the `BlockMenu` inside it) does not
18
+ * blank sibling areas or the dialog chrome. `EditorDialog` places its own
19
+ * around each dialog's body for the same reason at that granularity.
20
+ * @param root0
21
+ * @param root0.children
22
+ * @example
23
+ * ```tsx
24
+ * <EngineProvider engine={engine}>
25
+ * <RootErrorBoundary>
26
+ * <BurgerEditorRoot />
27
+ * </RootErrorBoundary>
28
+ * </EngineProvider>
29
+ * ```
30
+ */
31
+ export declare function RootErrorBoundary({ children }: {
32
+ readonly children: ReactNode;
33
+ }): import("react").JSX.Element;
34
+ //# sourceMappingURL=root-error-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-error-boundary.d.ts","sourceRoot":"","sources":["../src/root-error-boundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,OAAO,EACd,cAAc,CAAC,EAAE,MAAM,QAGvB;AAuBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAE/E"}
@@ -0,0 +1,30 @@
1
+ import { BurgerEditorEngine } from '@burger-editor/core';
2
+ /**
3
+ * テストやStorybookでコンポーネントを描画するための最小限のfake engineを作る。
4
+ *
5
+ * `uiState`/`commandBus`は本物のインスタンスをそのまま使う(`BurgerEditorEngine`は
6
+ * private constructorのため直接`new`できず、キャストで代用する)。コンポーネントが
7
+ * 実際に呼ぶメソッド・プロパティだけを`overrides`で個別に差し込む。
8
+ *
9
+ * `overrides`にgetterを渡した場合はライブなアクセサとして保持される(単純な
10
+ * オブジェクトスプレッドだとgetterがマージ時点の値へ固定されてしまうため、
11
+ * `Object.defineProperties`でプロパティ記述子ごと合成する)。
12
+ * @param overrides - コンポーネントが必要とする追加プロパティ・メソッド
13
+ * @example
14
+ * ```ts
15
+ * const engine = createMockEngine({ content: { type: 'draft' } });
16
+ * ```
17
+ * @example
18
+ * ```ts
19
+ * // uiStateのprocessingを都度反映するライブなgetterを差し込む
20
+ * const uiState = new UIStateStore();
21
+ * const engine = createMockEngine({
22
+ * uiState,
23
+ * get isProcessed() {
24
+ * return uiState.getSnapshot().processing;
25
+ * },
26
+ * });
27
+ * ```
28
+ */
29
+ export declare function createMockEngine(overrides?: Record<string, unknown>): BurgerEditorEngine;
30
+ //# sourceMappingURL=create-mock-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-mock-engine.d.ts","sourceRoot":"","sources":["../../src/testing/create-mock-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAI9D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAC/B,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,kBAAkB,CA8BpB"}
@@ -0,0 +1,4 @@
1
+ export { createMockEngine } from './create-mock-engine.js';
2
+ export { renderWithEngine } from './render-with-engine.js';
3
+ export { suppressConsoleErrors } from './suppress-console-error.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { BurgerEditorEngine } from '@burger-editor/core';
2
+ import { RenderOptions } from '@testing-library/react';
3
+ import { ReactElement } from 'react';
4
+ /**
5
+ * `@testing-library/react`'s `render`, pre-wrapped in an `EngineProvider`.
6
+ * Every client UI component under test reads its engine via `useEngine()`
7
+ * now, so this is the standard entry point for component specs — pass
8
+ * the same fake/mock engine object the spec already builds.
9
+ * @param engine - The (mock) engine to provide
10
+ * @param ui - The element to render
11
+ * @param options - Forwarded to Testing Library's `render`
12
+ * @returns The Testing Library render result
13
+ * @example
14
+ * ```tsx
15
+ * const engine = createMockEngine();
16
+ * renderWithEngine(engine, <FileList fileType="image" />);
17
+ * ```
18
+ */
19
+ export declare function renderWithEngine(engine: BurgerEditorEngine, ui: ReactElement, options?: RenderOptions): import('@testing-library/react').RenderResult<typeof import("@testing-library/dom/types/queries.js"), HTMLElement, HTMLElement>;
20
+ //# sourceMappingURL=render-with-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-with-engine.d.ts","sourceRoot":"","sources":["../../src/testing/render-with-engine.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAM1C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,kBAAkB,EAC1B,EAAE,EAAE,YAAY,EAChB,OAAO,CAAC,EAAE,aAAa,mIAGvB"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Silence `console.error` for the current test file only (registers its
3
+ * own `beforeEach`/`afterEach`, so this must be called at a describe/
4
+ * module's top level, not inside a `test()`).
5
+ *
6
+ * Several Browser Mode specs hit known false-positive React warnings
7
+ * (act-wrapping noise around a real browser async event, or a
8
+ * Suspense/act warning from reading an already-fulfilled-tagged
9
+ * thenable) that don't indicate a real bug — see each call site's own
10
+ * comment for which warning and why. Scoped per-file instead of a
11
+ * global `setup.ts` override, so an unrelated regression's act warning
12
+ * elsewhere still surfaces.
13
+ * @param patterns - Substrings to match against `console.error`'s first
14
+ * argument; matching calls are dropped, everything else passes through.
15
+ * Omit to silence every `console.error` call in this file instead (e.g.
16
+ * when the test intentionally throws and React's own double-logging of
17
+ * an already-caught error is the only thing to silence).
18
+ * @example
19
+ * ```ts
20
+ * suppressConsoleErrors('was not wrapped in act(...)');
21
+ * ```
22
+ */
23
+ export declare function suppressConsoleErrors(patterns?: readonly string[]): void;
24
+ //# sourceMappingURL=suppress-console-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suppress-console-error.d.ts","sourceRoot":"","sources":["../../src/testing/suppress-console-error.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAuBxE"}
@@ -0,0 +1,119 @@
1
+ import { a as UIStateStore, c as CommandBus, t as EngineProvider } from "./engine-context-gX6mWHke.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { render } from "@testing-library/react";
4
+ import { afterEach, beforeEach, vi } from "vitest";
5
+ //#region src/testing/create-mock-engine.ts
6
+ /**
7
+ * テストやStorybookでコンポーネントを描画するための最小限のfake engineを作る。
8
+ *
9
+ * `uiState`/`commandBus`は本物のインスタンスをそのまま使う(`BurgerEditorEngine`は
10
+ * private constructorのため直接`new`できず、キャストで代用する)。コンポーネントが
11
+ * 実際に呼ぶメソッド・プロパティだけを`overrides`で個別に差し込む。
12
+ *
13
+ * `overrides`にgetterを渡した場合はライブなアクセサとして保持される(単純な
14
+ * オブジェクトスプレッドだとgetterがマージ時点の値へ固定されてしまうため、
15
+ * `Object.defineProperties`でプロパティ記述子ごと合成する)。
16
+ * @param overrides - コンポーネントが必要とする追加プロパティ・メソッド
17
+ * @example
18
+ * ```ts
19
+ * const engine = createMockEngine({ content: { type: 'draft' } });
20
+ * ```
21
+ * @example
22
+ * ```ts
23
+ * // uiStateのprocessingを都度反映するライブなgetterを差し込む
24
+ * const uiState = new UIStateStore();
25
+ * const engine = createMockEngine({
26
+ * uiState,
27
+ * get isProcessed() {
28
+ * return uiState.getSnapshot().processing;
29
+ * },
30
+ * });
31
+ * ```
32
+ */
33
+ function createMockEngine(overrides = {}) {
34
+ const base = {
35
+ el: document.createElement("div"),
36
+ uiState: new UIStateStore(),
37
+ commandBus: new CommandBus(),
38
+ content: { type: "main" },
39
+ isProcessed: false,
40
+ serverAPI: {},
41
+ save: () => {},
42
+ clearCurrentBlock: () => {},
43
+ showMain: () => {},
44
+ showDraft: () => {},
45
+ hasDraft: () => false,
46
+ getContentStylesheet: () => Promise.resolve(""),
47
+ getCustomProperties: () => /* @__PURE__ */ new Map(),
48
+ getRepeatMinInlineSizeVariants: () => null,
49
+ getEditableContent: () => null,
50
+ commitSourceEdit: async () => {}
51
+ };
52
+ return Object.defineProperties(base, Object.getOwnPropertyDescriptors(overrides));
53
+ }
54
+ //#endregion
55
+ //#region src/testing/render-with-engine.tsx
56
+ /**
57
+ * `@testing-library/react`'s `render`, pre-wrapped in an `EngineProvider`.
58
+ * Every client UI component under test reads its engine via `useEngine()`
59
+ * now, so this is the standard entry point for component specs — pass
60
+ * the same fake/mock engine object the spec already builds.
61
+ * @param engine - The (mock) engine to provide
62
+ * @param ui - The element to render
63
+ * @param options - Forwarded to Testing Library's `render`
64
+ * @returns The Testing Library render result
65
+ * @example
66
+ * ```tsx
67
+ * const engine = createMockEngine();
68
+ * renderWithEngine(engine, <FileList fileType="image" />);
69
+ * ```
70
+ */
71
+ function renderWithEngine(engine, ui, options) {
72
+ return render(/* @__PURE__ */ jsx(EngineProvider, {
73
+ engine,
74
+ children: ui
75
+ }), options);
76
+ }
77
+ //#endregion
78
+ //#region src/testing/suppress-console-error.ts
79
+ /**
80
+ * Silence `console.error` for the current test file only (registers its
81
+ * own `beforeEach`/`afterEach`, so this must be called at a describe/
82
+ * module's top level, not inside a `test()`).
83
+ *
84
+ * Several Browser Mode specs hit known false-positive React warnings
85
+ * (act-wrapping noise around a real browser async event, or a
86
+ * Suspense/act warning from reading an already-fulfilled-tagged
87
+ * thenable) that don't indicate a real bug — see each call site's own
88
+ * comment for which warning and why. Scoped per-file instead of a
89
+ * global `setup.ts` override, so an unrelated regression's act warning
90
+ * elsewhere still surfaces.
91
+ * @param patterns - Substrings to match against `console.error`'s first
92
+ * argument; matching calls are dropped, everything else passes through.
93
+ * Omit to silence every `console.error` call in this file instead (e.g.
94
+ * when the test intentionally throws and React's own double-logging of
95
+ * an already-caught error is the only thing to silence).
96
+ * @example
97
+ * ```ts
98
+ * suppressConsoleErrors('was not wrapped in act(...)');
99
+ * ```
100
+ */
101
+ function suppressConsoleErrors(patterns) {
102
+ let spy;
103
+ beforeEach(() => {
104
+ const originalConsoleError = console.error.bind(console);
105
+ spy = vi.spyOn(console, "error").mockImplementation((...args) => {
106
+ if (!patterns) return;
107
+ const [first] = args;
108
+ if (typeof first === "string" && patterns.some((pattern) => first.includes(pattern))) return;
109
+ originalConsoleError(...args);
110
+ });
111
+ });
112
+ afterEach(() => {
113
+ spy.mockRestore();
114
+ });
115
+ }
116
+ //#endregion
117
+ export { createMockEngine, renderWithEngine, suppressConsoleErrors };
118
+
119
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","names":["CommandBus","UIStateStore","createMockEngine","overrides","el","document","createElement","base","uiState","commandBus","content","type","isProcessed","serverAPI","save","clearCurrentBlock","showMain","showDraft","hasDraft","getContentStylesheet","Promise","resolve","getCustomProperties","Map","getRepeatMinInlineSizeVariants","getEditableContent","commitSourceEdit","Object","defineProperties","getOwnPropertyDescriptors","render","EngineProvider","renderWithEngine","engine","ui","options","afterEach","beforeEach","vi","suppressConsoleErrors","patterns","spy","originalConsoleError","console","error","bind","spyOn","mockImplementation","args","first","some","pattern","includes","mockRestore"],"sources":["../src/testing/create-mock-engine.ts","../src/testing/render-with-engine.tsx","../src/testing/suppress-console-error.ts"],"sourcesContent":["import type { BurgerEditorEngine } from '@burger-editor/core';\n\nimport { CommandBus, UIStateStore } from '@burger-editor/core';\n\n/**\n * テストやStorybookでコンポーネントを描画するための最小限のfake engineを作る。\n *\n * `uiState`/`commandBus`は本物のインスタンスをそのまま使う(`BurgerEditorEngine`は\n * private constructorのため直接`new`できず、キャストで代用する)。コンポーネントが\n * 実際に呼ぶメソッド・プロパティだけを`overrides`で個別に差し込む。\n *\n * `overrides`にgetterを渡した場合はライブなアクセサとして保持される(単純な\n * オブジェクトスプレッドだとgetterがマージ時点の値へ固定されてしまうため、\n * `Object.defineProperties`でプロパティ記述子ごと合成する)。\n * @param overrides - コンポーネントが必要とする追加プロパティ・メソッド\n * @example\n * ```ts\n * const engine = createMockEngine({ content: { type: 'draft' } });\n * ```\n * @example\n * ```ts\n * // uiStateのprocessingを都度反映するライブなgetterを差し込む\n * const uiState = new UIStateStore();\n * const engine = createMockEngine({\n * uiState,\n * get isProcessed() {\n * return uiState.getSnapshot().processing;\n * },\n * });\n * ```\n */\nexport function createMockEngine(\n\toverrides: Record<string, unknown> = {},\n): BurgerEditorEngine {\n\tconst el = document.createElement('div');\n\n\tconst base = {\n\t\tel,\n\t\tuiState: new UIStateStore(),\n\t\tcommandBus: new CommandBus(),\n\t\tcontent: { type: 'main' },\n\t\tisProcessed: false,\n\t\tserverAPI: {},\n\t\tsave: () => {},\n\t\tclearCurrentBlock: () => {},\n\t\tshowMain: () => {},\n\t\tshowDraft: () => {},\n\t\thasDraft: () => false,\n\t\tgetContentStylesheet: () => Promise.resolve(''),\n\t\tgetCustomProperties: () => new Map(),\n\t\tgetRepeatMinInlineSizeVariants: () => null,\n\t\tgetEditableContent: () => null,\n\t\t// EditableAreaViewはソースモードを抜けるたびにこれを呼ぶため、\n\t\t// スタブし忘れると`commitSourceEdit is not a function`でstory/testが\n\t\t// 落ちる。実際にreplaceContents→saveの経路を検証したいテストは\n\t\t// このデフォルトごと`commitSourceEdit`をoverrideすること\n\t\tcommitSourceEdit: async () => {},\n\t};\n\n\treturn Object.defineProperties(\n\t\tbase,\n\t\tObject.getOwnPropertyDescriptors(overrides),\n\t) as unknown as BurgerEditorEngine;\n}\n","import type { BurgerEditorEngine } from '@burger-editor/core';\nimport type { RenderOptions } from '@testing-library/react';\nimport type { ReactElement } from 'react';\n\nimport { render } from '@testing-library/react';\n\nimport { EngineProvider } from '../engine-context.js';\n\n/**\n * `@testing-library/react`'s `render`, pre-wrapped in an `EngineProvider`.\n * Every client UI component under test reads its engine via `useEngine()`\n * now, so this is the standard entry point for component specs — pass\n * the same fake/mock engine object the spec already builds.\n * @param engine - The (mock) engine to provide\n * @param ui - The element to render\n * @param options - Forwarded to Testing Library's `render`\n * @returns The Testing Library render result\n * @example\n * ```tsx\n * const engine = createMockEngine();\n * renderWithEngine(engine, <FileList fileType=\"image\" />);\n * ```\n */\nexport function renderWithEngine(\n\tengine: BurgerEditorEngine,\n\tui: ReactElement,\n\toptions?: RenderOptions,\n) {\n\treturn render(<EngineProvider engine={engine}>{ui}</EngineProvider>, options);\n}\n","import { afterEach, beforeEach, vi } from 'vitest';\n\n/**\n * Silence `console.error` for the current test file only (registers its\n * own `beforeEach`/`afterEach`, so this must be called at a describe/\n * module's top level, not inside a `test()`).\n *\n * Several Browser Mode specs hit known false-positive React warnings\n * (act-wrapping noise around a real browser async event, or a\n * Suspense/act warning from reading an already-fulfilled-tagged\n * thenable) that don't indicate a real bug — see each call site's own\n * comment for which warning and why. Scoped per-file instead of a\n * global `setup.ts` override, so an unrelated regression's act warning\n * elsewhere still surfaces.\n * @param patterns - Substrings to match against `console.error`'s first\n * argument; matching calls are dropped, everything else passes through.\n * Omit to silence every `console.error` call in this file instead (e.g.\n * when the test intentionally throws and React's own double-logging of\n * an already-caught error is the only thing to silence).\n * @example\n * ```ts\n * suppressConsoleErrors('was not wrapped in act(...)');\n * ```\n */\nexport function suppressConsoleErrors(patterns?: readonly string[]): void {\n\tlet spy: ReturnType<typeof vi.spyOn>;\n\n\tbeforeEach(() => {\n\t\tconst originalConsoleError = console.error.bind(console);\n\t\tspy = vi.spyOn(console, 'error').mockImplementation((...args: unknown[]) => {\n\t\t\tif (!patterns) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst [first] = args;\n\t\t\tif (\n\t\t\t\ttypeof first === 'string' &&\n\t\t\t\tpatterns.some((pattern) => first.includes(pattern))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toriginalConsoleError(...args);\n\t\t});\n\t});\n\n\tafterEach(() => {\n\t\tspy.mockRestore();\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,SAAgBE,iBACfC,YAAqC,CAAC,GACjB;CAGrB,MAAMI,OAAO;EACZH,IAHUC,SAASC,cAAc,KAGjCF;EACAI,SAAS,IAAIP,aAAa;EAC1BQ,YAAY,IAAIT,WAAW;EAC3BU,SAAS,EAAEC,MAAM,OAAO;EACxBC,aAAa;EACbC,WAAW,CAAC;EACZC,YAAY,CAAC;EACbC,yBAAyB,CAAC;EAC1BC,gBAAgB,CAAC;EACjBC,iBAAiB,CAAC;EAClBC,gBAAgB;EAChBC,4BAA4BC,QAAQC,QAAQ,EAAE;EAC9CC,2CAA2B,IAAIC,IAAI;EACnCC,sCAAsC;EACtCC,0BAA0B;EAK1BC,kBAAkB,YAAY,CAAC;CAChC;CAEA,OAAOC,OAAOC,iBACbrB,MACAoB,OAAOE,0BAA0B1B,SAAS,CAC3C;AACD;;;;;;;;;;;;;;;;;;ACxCA,SAAgB6B,iBACfC,QACAC,IACAC,SACC;CACD,OAAOL,OAAO,oBAAC,gBAAD;EAAwBG;EAASC,UAAAA;CAAmB,CAAA,GAAGC,OAAO;AAC7E;;;;;;;;;;;;;;;;;;;;;;;;;ACLA,SAAgBI,sBAAsBC,UAAoC;CACzE,IAAIC;CAEJJ,iBAAiB;EAChB,MAAMK,uBAAuBC,QAAQC,MAAMC,KAAKF,OAAO;EACvDF,MAAMH,GAAGQ,MAAMH,SAAS,OAAO,CAAC,CAACI,oBAAoB,GAAGC,SAAoB;GAC3E,IAAI,CAACR,UACJ;GAED,MAAM,CAACS,SAASD;GAChB,IACC,OAAOC,UAAU,YACjBT,SAASU,MAAMC,YAAYF,MAAMG,SAASD,OAAO,CAAC,GAElD;GAEDT,qBAAqB,GAAGM,IAAI;EAC7B,CAAC;CACF,CAAC;CAEDZ,gBAAgB;EACfK,IAAIY,YAAY;CACjB,CAAC;AACF"}
package/dist/ui.d.ts CHANGED
@@ -1,10 +1,16 @@
1
1
  export type { InvokerCommandAttributes } from './invoker-commands.js';
2
2
  export { EditorDialog } from './editor-dialog.js';
3
+ export { EngineProvider, useEngine } from './engine-context.js';
3
4
  export { reactMount } from './mount.js';
4
5
  export { registerEngineCommands } from './commands/register-engine-commands.js';
5
6
  export * from './components/index.js';
7
+ export { RootErrorBoundary, reportRenderError } from './root-error-boundary.js';
6
8
  export { useCommand } from './use-command.js';
7
9
  export type { CommandHandlers } from './use-command.js';
8
- export { useComponentEvent, useUIState } from './use-engine.js';
10
+ export { useMountEffect } from './use-mount-effect.js';
11
+ export { useUIState } from './use-engine.js';
12
+ export { useFileBrowser } from './file-browser/use-file-browser.js';
13
+ export { useExternalFileSelection } from './file-browser/use-external-file-selection.js';
14
+ export type { FileBrowserStore, FileBrowserQuery, SelectedFile, UploadProgress, } from './file-browser/store.js';
9
15
  export * from './form/index.js';
10
16
  //# sourceMappingURL=ui.d.ts.map