@burger-editor/client 4.0.0-alpha.72 → 4.0.0-alpha.74

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 (85) 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.js +323 -133
  7. package/dist/client.js.map +1 -1
  8. package/dist/commands/register-engine-commands.d.ts +2 -1
  9. package/dist/commands/register-engine-commands.d.ts.map +1 -1
  10. package/dist/components/block-catalog.d.ts +3 -5
  11. package/dist/components/block-catalog.d.ts.map +1 -1
  12. package/dist/components/block-menu-button.d.ts +1 -1
  13. package/dist/components/block-menu-view.d.ts +7 -3
  14. package/dist/components/block-menu-view.d.ts.map +1 -1
  15. package/dist/components/block-menu.d.ts +2 -5
  16. package/dist/components/block-menu.d.ts.map +1 -1
  17. package/dist/components/block-options.d.ts +4 -6
  18. package/dist/components/block-options.d.ts.map +1 -1
  19. package/dist/components/draft-switcher.d.ts +11 -10
  20. package/dist/components/draft-switcher.d.ts.map +1 -1
  21. package/dist/components/editable-area-view.d.ts +11 -14
  22. package/dist/components/editable-area-view.d.ts.map +1 -1
  23. package/dist/components/file-list.d.ts +9 -9
  24. package/dist/components/file-list.d.ts.map +1 -1
  25. package/dist/components/file-uploader.d.ts +6 -6
  26. package/dist/components/file-uploader.d.ts.map +1 -1
  27. package/dist/components/front-matter-editor.d.ts +43 -11
  28. package/dist/components/front-matter-editor.d.ts.map +1 -1
  29. package/dist/components/index.d.ts +2 -2
  30. package/dist/components/index.d.ts.map +1 -1
  31. package/dist/components/initial-insertion-button.d.ts +7 -2
  32. package/dist/components/initial-insertion-button.d.ts.map +1 -1
  33. package/dist/components/item-editor-host.d.ts +7 -6
  34. package/dist/components/item-editor-host.d.ts.map +1 -1
  35. package/dist/components/preview.d.ts +4 -7
  36. package/dist/components/preview.d.ts.map +1 -1
  37. package/dist/components/table-editor.d.ts.map +1 -1
  38. package/dist/components/wysiwyg-field.d.ts +11 -1
  39. package/dist/components/wysiwyg-field.d.ts.map +1 -1
  40. package/dist/editable-area-view-DssYcTqQ.js +2941 -0
  41. package/dist/editable-area-view-DssYcTqQ.js.map +1 -0
  42. package/dist/editor-dialog.d.ts +16 -7
  43. package/dist/editor-dialog.d.ts.map +1 -1
  44. package/dist/{editable-area-view-C00DSDVk.js → engine-context-gX6mWHke.js} +199 -1951
  45. package/dist/engine-context-gX6mWHke.js.map +1 -0
  46. package/dist/engine-context.d.ts +40 -0
  47. package/dist/engine-context.d.ts.map +1 -0
  48. package/dist/file-browser/store.d.ts +127 -0
  49. package/dist/file-browser/store.d.ts.map +1 -0
  50. package/dist/file-browser/use-external-file-selection.d.ts +39 -0
  51. package/dist/file-browser/use-external-file-selection.d.ts.map +1 -0
  52. package/dist/file-browser/use-file-browser.d.ts +17 -0
  53. package/dist/file-browser/use-file-browser.d.ts.map +1 -0
  54. package/dist/form/text-field.d.ts +3 -1
  55. package/dist/form/text-field.d.ts.map +1 -1
  56. package/dist/index.d.ts +4 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/mount.d.ts +6 -1
  59. package/dist/mount.d.ts.map +1 -1
  60. package/dist/root-error-boundary.d.ts +34 -0
  61. package/dist/root-error-boundary.d.ts.map +1 -0
  62. package/dist/testing/create-mock-engine.d.ts +30 -0
  63. package/dist/testing/create-mock-engine.d.ts.map +1 -0
  64. package/dist/testing/index.d.ts +4 -0
  65. package/dist/testing/index.d.ts.map +1 -0
  66. package/dist/testing/render-with-engine.d.ts +20 -0
  67. package/dist/testing/render-with-engine.d.ts.map +1 -0
  68. package/dist/testing/suppress-console-error.d.ts +24 -0
  69. package/dist/testing/suppress-console-error.d.ts.map +1 -0
  70. package/dist/testing.js +119 -0
  71. package/dist/testing.js.map +1 -0
  72. package/dist/ui.d.ts +7 -1
  73. package/dist/ui.d.ts.map +1 -1
  74. package/dist/ui.js +1618 -537
  75. package/dist/ui.js.map +1 -1
  76. package/dist/use-command.d.ts +13 -4
  77. package/dist/use-command.d.ts.map +1 -1
  78. package/dist/use-engine.d.ts +16 -32
  79. package/dist/use-engine.d.ts.map +1 -1
  80. package/dist/use-mount-effect.d.ts +20 -0
  81. package/dist/use-mount-effect.d.ts.map +1 -0
  82. package/dist/view/create-react-view.d.ts +33 -9
  83. package/dist/view/create-react-view.d.ts.map +1 -1
  84. package/package.json +45 -18
  85. package/dist/editable-area-view-C00DSDVk.js.map +0 -1
@@ -1,15 +1,24 @@
1
1
  import { BurgerCommandEvent } from '@burger-editor/core';
2
- import { RefObject } from 'react';
2
+ import { RefCallback } from 'react';
3
3
  export type CommandHandlers = {
4
4
  readonly [command: `--${string}`]: (event: BurgerCommandEvent) => void;
5
5
  };
6
6
  /**
7
7
  * Receive Invoker Commands API `command` events on the element the returned
8
- * ref is attached to. Buttons address the element with
8
+ * ref callback is attached to. Buttons address the element with
9
9
  * `commandfor={idOfElement}`; `CommandEvent` does not bubble, so the ref
10
10
  * must be on the exact `commandfor` target.
11
+ *
12
+ * Returns a ref **callback** (not a `RefObject`) so the listener attaches
13
+ * as soon as the element mounts, including when the element appears later
14
+ * from a conditional render — a `useRef` + `useEffect(..., [])` pair only
15
+ * reads `ref.current` once, at the first commit, and would miss an
16
+ * element that shows up afterward. `handlers` is read through
17
+ * `useEffectEvent` so the listener always calls the latest render's
18
+ * closure without needing `handlers` in the attach effect's deps (and
19
+ * without re-attaching the DOM listener on every render).
11
20
  * @param handlers - Map of custom command names to handlers
12
- * @returns A ref to attach to the receiving element
21
+ * @returns A ref callback to attach to the receiving element
13
22
  * @example
14
23
  * ```tsx
15
24
  * const rootId = useId();
@@ -25,5 +34,5 @@ export type CommandHandlers = {
25
34
  * );
26
35
  * ```
27
36
  */
28
- export declare function useCommand<T extends HTMLElement>(handlers: CommandHandlers): RefObject<T | null>;
37
+ export declare function useCommand<T extends HTMLElement>(handlers: CommandHandlers): RefCallback<T>;
29
38
  //# sourceMappingURL=use-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-command.d.ts","sourceRoot":"","sources":["../src/use-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAC/C,QAAQ,EAAE,eAAe,GACvB,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAwBrB"}
1
+ {"version":3,"file":"use-command.d.ts","sourceRoot":"","sources":["../src/use-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIzC,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACvE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAC/C,QAAQ,EAAE,eAAe,GACvB,WAAW,CAAC,CAAC,CAAC,CAoBhB"}
@@ -1,53 +1,37 @@
1
- import { Actions, BurgerEditorEngine, UIState } from '@burger-editor/core';
1
+ import { UIState } from '@burger-editor/core';
2
2
  /**
3
3
  * Subscribe to the engine's UI state store.
4
4
  *
5
- * `useSyncExternalStore` の配線(subscribe/getSnapshot)を毎回書かずに
6
- * 済ませるための薄いラッパー。スナップショットは変更ごとに差し替わる
7
- * 不変オブジェクトなので、参照比較だけで再レンダーが決まる。
8
- * @param engine - The engine instance
5
+ * Wraps `useSyncExternalStoreWithSelector` so call sites don't repeat the
6
+ * subscribe/getSnapshot/selector wiring. `engine.uiState.subscribe` and
7
+ * `.getSnapshot` are stable per-instance methods (see `UIStateStore`), so
8
+ * passing them directly — instead of a new inline closure each render —
9
+ * means React doesn't unsubscribe and resubscribe on every render. The
10
+ * engine is read from the nearest `EngineProvider`.
9
11
  * @returns The current UI state snapshot
10
12
  * @example
11
13
  * ```tsx
12
- * const { openDialog } = useUIState(engine);
13
- * return <ItemEditorHost engine={engine} item={openDialog?.type === 'item-editor' ? openDialog.item : null} />;
14
+ * const { openDialog } = useUIState();
15
+ * return <ItemEditorHost item={openDialog?.type === 'item-editor' ? openDialog.item : null} />;
14
16
  * ```
15
17
  */
16
- export declare function useUIState(engine: BurgerEditorEngine): UIState;
18
+ export declare function useUIState(): UIState;
17
19
  /**
18
20
  * Subscribe to a projection of the engine's UI state store.
19
21
  *
20
22
  * 選択的な状態(`processing` や `sourceMode[type]` など)だけを読む
21
23
  * コンポーネントは、`selector` でそのフィールドだけを取り出すと無関係な
22
- * 状態変化(例: ダイアログの開閉)での再レンダーを避けられる。selector
23
- * が返す値はプリミティブか、`UIStateStore` 内部で不変のうちは同一参照を
24
- * 保つネスト構造(`sourceMode` など)に限る — selector 内でオブジェクト
25
- * を新規生成すると `useSyncExternalStore` が毎回「変化した」と判定して
26
- * 無限レンダーを引き起こす。
27
- * @param engine - The engine instance
24
+ * 状態変化(例: ダイアログの開閉)での再レンダーを避けられる —
25
+ * `useSyncExternalStoreWithSelector` が選択後の値を `Object.is` で比較し、
26
+ * 変化がなければ再レンダーをスキップする(selector 自体は毎レンダー
27
+ * 新しい関数でよい。比較されるのは戻り値であって関数の同一性ではない)。
28
28
  * @param selector - Projection of the snapshot
29
29
  * @returns The selected value
30
30
  * @example
31
31
  * ```tsx
32
32
  * // 無関係な状態変化での再レンダーを避ける
33
- * const processing = useUIState(engine, (s) => s.processing);
33
+ * const processing = useUIState((s) => s.processing);
34
34
  * ```
35
35
  */
36
- export declare function useUIState<T>(engine: BurgerEditorEngine, selector: (state: UIState) => T): T;
37
- /**
38
- * Subscribe to a component observer action for the lifetime of the
39
- * component. The handler always sees the latest render's closure.
40
- * @param engine - The engine instance
41
- * @param action - The action name to listen for
42
- * @param handler - Callback receiving the typed payload
43
- * @example
44
- * ```tsx
45
- * useComponentEvent(engine, 'file-select', ({ path, isEmpty }) => {
46
- * if (!isEmpty) {
47
- * setState((prev) => ({ ...prev, path }));
48
- * }
49
- * });
50
- * ```
51
- */
52
- export declare function useComponentEvent<A extends keyof Actions>(engine: BurgerEditorEngine, action: A, handler: (payload: Actions[A]) => void): void;
36
+ export declare function useUIState<T>(selector: (state: UIState) => T): T;
53
37
  //# sourceMappingURL=use-engine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-engine.d.ts","sourceRoot":"","sources":["../src/use-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAIhF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC;AAChE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC3B,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,GAC7B,CAAC,CAAC;AAcL;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,OAAO,EACxD,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,QAatC"}
1
+ {"version":3,"file":"use-engine.d.ts","sourceRoot":"","sources":["../src/use-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAQnD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAAC;AACtC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Run `fn` exactly once, when the component mounts, always reading `fn`'s
3
+ * latest closure (via `useEffectEvent`) rather than the one captured at
4
+ * mount time.
5
+ *
6
+ * Exists so a mount-only effect can honestly declare `useEffect(fn, [])`
7
+ * without an `eslint-disable-next-line react-hooks/exhaustive-deps` — that
8
+ * suppression is also a React Compiler bailout condition for the whole
9
+ * component containing it (see ARCHITECTURE.md's negative-knowledge note
10
+ * on React Compiler).
11
+ * @param fn - Called once on mount
12
+ * @example
13
+ * ```tsx
14
+ * useMountEffect(() => {
15
+ * fileBrowser.select(fileType, state.path ?? '', size);
16
+ * });
17
+ * ```
18
+ */
19
+ export declare function useMountEffect(fn: () => void): void;
20
+ //# sourceMappingURL=use-mount-effect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mount-effect.d.ts","sourceRoot":"","sources":["../src/use-mount-effect.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAKnD"}
@@ -1,17 +1,41 @@
1
1
  import { BurgerEditorView } from '@burger-editor/core';
2
+ import { ReactNode } from 'react';
2
3
  /**
3
- * The React implementation of the engine's view port. Each editable
4
- * area is rendered as an {@link EditableAreaView} React root appended
5
- * to the engine's view area; `createAreaHost` resolves once the area's
6
- * content container exists.
4
+ * A `ReactView` extends the core {@link BurgerEditorView} contract with a
5
+ * client-only escape hatch: `mountChrome` lets `createBurgerEditorClient`
6
+ * render the dialog chrome into the *same* React root the editable areas
7
+ * use, once the engine has finished constructing. `core` never sees this
8
+ * method — it only calls `createAreaHost` through the narrower
9
+ * `BurgerEditorView` type.
10
+ */
11
+ export interface ReactView extends BurgerEditorView {
12
+ /**
13
+ * Render additional UI (currently: `BurgerEditorRoot`, the dialog
14
+ * chrome) into the single root this view owns. Replaces whatever was
15
+ * mounted by a previous call.
16
+ * @param node - The chrome to render
17
+ */
18
+ mountChrome(node: ReactNode): void;
19
+ }
20
+ /**
21
+ * The React implementation of the engine's view port.
22
+ *
23
+ * Unlike the pre-single-root design (one `createRoot` per editable area
24
+ * plus a separate dialog-host root), this view owns exactly **one** React
25
+ * root per engine. Editable areas are portaled into their own `<div>`
26
+ * (still a direct child of `engine.viewArea`, preserving the DOM contract
27
+ * `viewAreaClassList` consumers rely on) so each area keeps its own
28
+ * subtree identity; the dialog chrome renders inline. Sharing one root
29
+ * means `EngineProvider` only needs to wrap the tree once, and every
30
+ * component below it — areas, block menu, dialogs — reads the engine via
31
+ * `useEngine()` instead of taking it as a prop.
7
32
  * @returns The view to pass to `BurgerEditorEngine.new`
8
33
  * @example
9
34
  * ```ts
10
- * const engine = await BurgerEditorEngine.new({
11
- * ...options,
12
- * view: createReactView(),
13
- * });
35
+ * const view = createReactView();
36
+ * const engine = await BurgerEditorEngine.new({ ...options, view });
37
+ * view.mountChrome(<EngineProvider engine={engine}><BurgerEditorRoot /></EngineProvider>);
14
38
  * ```
15
39
  */
16
- export declare function createReactView(): BurgerEditorView;
40
+ export declare function createReactView(): ReactView;
17
41
  //# sourceMappingURL=create-react-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-react-view.d.ts","sourceRoot":"","sources":["../../src/view/create-react-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAO5D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,IAAI,gBAAgB,CAyClD"}
1
+ {"version":3,"file":"create-react-view.d.ts","sourceRoot":"","sources":["../../src/view/create-react-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,gBAAgB,EAIhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUvC;;;;;;;GAOG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB;IAClD;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;CACnC;AAaD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAgG3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burger-editor/client",
3
- "version": "4.0.0-alpha.72",
3
+ "version": "4.0.0-alpha.74",
4
4
  "description": "BurgerEditor client package",
5
5
  "author": "D-ZERO",
6
6
  "license": "(MIT OR Apache-2.0)",
@@ -22,6 +22,10 @@
22
22
  "import": "./dist/ui.js",
23
23
  "types": "./dist/ui.d.ts"
24
24
  },
25
+ "./testing": {
26
+ "import": "./dist/testing.js",
27
+ "types": "./dist/testing/index.d.ts"
28
+ },
25
29
  "./style": {
26
30
  "import": "./dist/client.css"
27
31
  }
@@ -36,26 +40,49 @@
36
40
  "dev": "vite build --watch"
37
41
  },
38
42
  "dependencies": {
39
- "@burger-editor/core": "4.0.0-alpha.72",
40
- "@burger-editor/custom-element": "4.0.0-alpha.72",
41
- "@burger-editor/migrator": "4.0.0-alpha.72",
42
- "@burger-editor/utils": "4.0.0-alpha.72",
43
- "@tabler/icons-react": "3.46.0"
43
+ "@burger-editor/core": "4.0.0-alpha.74",
44
+ "@burger-editor/custom-element": "4.0.0-alpha.74",
45
+ "@burger-editor/migrator": "4.0.0-alpha.74",
46
+ "@burger-editor/utils": "4.0.0-alpha.74",
47
+ "@tabler/icons-react": "3.46.0",
48
+ "react-error-boundary": "6.1.5",
49
+ "use-sync-external-store": "1.7.0"
44
50
  },
45
51
  "devDependencies": {
46
- "@testing-library/dom": "10.4.1",
47
- "@testing-library/react": "16.3.2",
48
- "@types/react": "19.2.18",
49
- "@types/react-dom": "19.2.5",
50
- "@vitejs/plugin-react": "6.0.5",
51
- "react": "19.2.8",
52
- "react-dom": "19.2.8",
53
- "vite": "8.2.1",
54
- "vite-plugin-dts": "5.0.3"
52
+ "@babel/core": "7.29.7",
53
+ "@babel/preset-typescript": "7.29.7",
54
+ "@rolldown/plugin-babel": "0.2.4",
55
+ "@testing-library/dom": "10.4.2",
56
+ "@testing-library/react": "16.3.3",
57
+ "@types/babel__core": "7.20.5",
58
+ "@types/react": "19.3.0",
59
+ "@types/react-dom": "19.3.0",
60
+ "@types/use-sync-external-store": "1.7.0",
61
+ "@vitejs/plugin-react": "6.1.1",
62
+ "babel-plugin-react-compiler": "1.0.0",
63
+ "react": "19.3.0",
64
+ "react-dom": "19.3.0",
65
+ "vite": "8.3.0",
66
+ "vite-plugin-dts": "5.1.0",
67
+ "vitest": "4.1.11"
55
68
  },
56
69
  "peerDependencies": {
57
- "react": "19.2.8",
58
- "react-dom": "19.2.8"
70
+ "@testing-library/dom": "10.4.2",
71
+ "@testing-library/react": "16.3.3",
72
+ "react": "19.3.0",
73
+ "react-dom": "19.3.0",
74
+ "vitest": "4.1.11"
75
+ },
76
+ "peerDependenciesMeta": {
77
+ "@testing-library/dom": {
78
+ "optional": true
79
+ },
80
+ "@testing-library/react": {
81
+ "optional": true
82
+ },
83
+ "vitest": {
84
+ "optional": true
85
+ }
59
86
  },
60
- "gitHead": "091b61b028704219fc058374f4b0004ce8e2c091"
87
+ "gitHead": "348dfe93cb5aca7fce0628d37d25e9046684845e"
61
88
  }