@burger-editor/client 4.0.0-alpha.8 → 4.0.0-alpha.80
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.
- package/README.md +169 -2
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/animate-insertion.d.ts +17 -0
- package/dist/animate-insertion.d.ts.map +1 -0
- package/dist/block-swap-view-transition-css.d.ts +7 -0
- package/dist/block-swap-view-transition-css.d.ts.map +1 -0
- package/dist/burger-editor-root.d.ts +7 -0
- package/dist/burger-editor-root.d.ts.map +1 -0
- package/dist/client.css +981 -573
- package/dist/client.js +28193 -14074
- package/dist/client.js.map +1 -1
- package/dist/commands/register-engine-commands.d.ts +18 -0
- package/dist/commands/register-engine-commands.d.ts.map +1 -0
- package/dist/components/block-catalog.d.ts +18 -0
- package/dist/components/block-catalog.d.ts.map +1 -0
- package/dist/components/block-menu-anchors.d.ts +25 -0
- package/dist/components/block-menu-anchors.d.ts.map +1 -0
- package/dist/components/block-menu-button.d.ts +33 -0
- package/dist/components/block-menu-button.d.ts.map +1 -0
- package/dist/components/block-menu-view.d.ts +88 -0
- package/dist/components/block-menu-view.d.ts.map +1 -0
- package/dist/components/block-menu.d.ts +25 -0
- package/dist/components/block-menu.d.ts.map +1 -0
- package/dist/components/block-options.d.ts +23 -0
- package/dist/components/block-options.d.ts.map +1 -0
- package/dist/components/draft-switcher.d.ts +24 -0
- package/dist/components/draft-switcher.d.ts.map +1 -0
- package/dist/components/editable-area-view.d.ts +41 -0
- package/dist/components/editable-area-view.d.ts.map +1 -0
- package/dist/components/file-list.d.ts +19 -0
- package/dist/components/file-list.d.ts.map +1 -0
- package/dist/components/file-uploader.d.ts +18 -0
- package/dist/components/file-uploader.d.ts.map +1 -0
- package/dist/components/front-matter-editor.d.ts +115 -0
- package/dist/components/front-matter-editor.d.ts.map +1 -0
- package/dist/components/index.d.ts +23 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/initial-insertion-button.d.ts +15 -0
- package/dist/components/initial-insertion-button.d.ts.map +1 -0
- package/dist/components/item-editor-host.d.ts +24 -0
- package/dist/components/item-editor-host.d.ts.map +1 -0
- package/dist/components/preview.d.ts +15 -0
- package/dist/components/preview.d.ts.map +1 -0
- package/dist/components/table-editor.d.ts +28 -0
- package/dist/components/table-editor.d.ts.map +1 -0
- package/dist/components/tabs.d.ts +27 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/thumbnail-button.d.ts +39 -0
- package/dist/components/thumbnail-button.d.ts.map +1 -0
- package/dist/components/thumbnail.d.ts +17 -0
- package/dist/components/thumbnail.d.ts.map +1 -0
- package/dist/components/wysiwyg-field.d.ts +50 -0
- package/dist/components/wysiwyg-field.d.ts.map +1 -0
- package/dist/create-mock-engine-BloCpuEu.js +87 -0
- package/dist/create-mock-engine-BloCpuEu.js.map +1 -0
- package/dist/dist-DYydjVsL.js +16188 -0
- package/dist/dist-DYydjVsL.js.map +1 -0
- package/dist/editable-area-view-DhEipEQV.js +2962 -0
- package/dist/editable-area-view-DhEipEQV.js.map +1 -0
- package/dist/editor-dialog.d.ts +50 -0
- package/dist/editor-dialog.d.ts.map +1 -0
- package/dist/engine-context-oEEsvNSx.js +49 -0
- package/dist/engine-context-oEEsvNSx.js.map +1 -0
- package/dist/engine-context.d.ts +43 -0
- package/dist/engine-context.d.ts.map +1 -0
- package/dist/file-browser/store.d.ts +132 -0
- package/dist/file-browser/store.d.ts.map +1 -0
- package/dist/file-browser/use-external-file-selection.d.ts +39 -0
- package/dist/file-browser/use-external-file-selection.d.ts.map +1 -0
- package/dist/file-browser/use-file-browser.d.ts +17 -0
- package/dist/file-browser/use-file-browser.d.ts.map +1 -0
- package/dist/form/checkbox.d.ts +34 -0
- package/dist/form/checkbox.d.ts.map +1 -0
- package/dist/form/fieldset.d.ts +31 -0
- package/dist/form/fieldset.d.ts.map +1 -0
- package/dist/form/index.d.ts +8 -0
- package/dist/form/index.d.ts.map +1 -0
- package/dist/form/number-field.d.ts +37 -0
- package/dist/form/number-field.d.ts.map +1 -0
- package/dist/form/radio-group.d.ts +38 -0
- package/dist/form/radio-group.d.ts.map +1 -0
- package/dist/form/select-field.d.ts +41 -0
- package/dist/form/select-field.d.ts.map +1 -0
- package/dist/form/text-area.d.ts +33 -0
- package/dist/form/text-area.d.ts.map +1 -0
- package/dist/form/text-field.d.ts +47 -0
- package/dist/form/text-field.d.ts.map +1 -0
- package/dist/index.d.ts +42 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/interest-hints.d.ts +21 -0
- package/dist/interest-hints.d.ts.map +1 -0
- package/dist/invoker-commands.d.ts +24 -0
- package/dist/invoker-commands.d.ts.map +1 -0
- package/dist/mount.d.ts +24 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/replace-element.d.ts +12 -4
- package/dist/replace-element.d.ts.map +1 -1
- package/dist/root-error-boundary.d.ts +34 -0
- package/dist/root-error-boundary.d.ts.map +1 -0
- package/dist/testing/create-mock-engine.d.ts +33 -0
- package/dist/testing/create-mock-engine.d.ts.map +1 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/render-with-engine.d.ts +20 -0
- package/dist/testing/render-with-engine.d.ts.map +1 -0
- package/dist/testing/suppress-console-error.d.ts +24 -0
- package/dist/testing/suppress-console-error.d.ts.map +1 -0
- package/dist/testing-mock-engine.js +1 -0
- package/dist/testing.js +68 -0
- package/dist/testing.js.map +1 -0
- package/dist/ui.d.ts +17 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +2830 -0
- package/dist/ui.js.map +1 -0
- package/dist/use-command.d.ts +38 -0
- package/dist/use-command.d.ts.map +1 -0
- package/dist/use-engine.d.ts +37 -0
- package/dist/use-engine.d.ts.map +1 -0
- package/dist/use-mount-effect.d.ts +20 -0
- package/dist/use-mount-effect.d.ts.map +1 -0
- package/dist/view/create-react-view.d.ts +41 -0
- package/dist/view/create-react-view.d.ts.map +1 -0
- package/package.json +61 -16
- package/dist/block-catalog.svelte.d.ts +0 -1
- package/dist/block-menu-button.svelte.d.ts +0 -1
- package/dist/block-menu.svelte.d.ts +0 -1
- package/dist/block-options.svelte.d.ts +0 -1
- package/dist/draft-switcher.svelte.d.ts +0 -1
- package/dist/file-list.svelte.d.ts +0 -1
- package/dist/file-uploader.svelte.d.ts +0 -1
- package/dist/preview.svelte.d.ts +0 -1
- package/dist/svelte-mount.d.ts +0 -10
- package/dist/svelte-mount.d.ts.map +0 -1
- package/dist/table-editor.svelte.d.ts +0 -1
- package/dist/tabs.svelte.d.ts +0 -1
- package/dist/thumbnail.svelte.d.ts +0 -1
package/dist/mount.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
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.
|
|
6
|
+
* @param node - The React node to render
|
|
7
|
+
* @param target - The DOM container
|
|
8
|
+
* @returns A handle that unmounts the root, via `using` or `cleanUp()`
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
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.
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function reactMount(node: ReactNode, target: HTMLElement): Disposable & {
|
|
21
|
+
/** @deprecated Use a `using` declaration instead. */
|
|
22
|
+
cleanUp(): void;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CACzB,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,WAAW,GACjB,UAAU,GAAG;IACf,qDAAqD;IACrD,OAAO,IAAI,IAAI,CAAC;CAChB,CAaA"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Swap two adjacent sibling blocks with a View Transition, then wait until it
|
|
3
|
+
* finishes so `beginProcessing()` covers the same window as before.
|
|
2
4
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param
|
|
5
|
+
* Animation length and `prefers-reduced-motion: reduce` are controlled by CSS
|
|
6
|
+
* injected into the editable-area iframe (`editable-area-view.tsx`), not here.
|
|
7
|
+
* @param elA - First sibling element
|
|
8
|
+
* @param elB - Second sibling element (same parent as `elA`)
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* await replaceElement(currentBlock.el, currentBlock.el.nextElementSibling as HTMLElement);
|
|
12
|
+
* // The two blocks have exchanged positions in the DOM.
|
|
13
|
+
* ```
|
|
6
14
|
*/
|
|
7
|
-
export declare function replaceElement(elA: HTMLElement, elB: HTMLElement
|
|
15
|
+
export declare function replaceElement(elA: HTMLElement, elB: HTMLElement): Promise<void>;
|
|
8
16
|
//# sourceMappingURL=replace-element.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace-element.d.ts","sourceRoot":"","sources":["../src/replace-element.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replace-element.d.ts","sourceRoot":"","sources":["../src/replace-element.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAwCtF"}
|
|
@@ -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,33 @@
|
|
|
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
|
+
* `config`は必須のキーだけを持つ最小の値を既定にする(エディタが`useEngine().config`を
|
|
10
|
+
* 読むため)。別の設定を試すときは`overrides`で`config`を渡す。
|
|
11
|
+
*
|
|
12
|
+
* `overrides`にgetterを渡した場合はライブなアクセサとして保持される(単純な
|
|
13
|
+
* オブジェクトスプレッドだとgetterがマージ時点の値へ固定されてしまうため、
|
|
14
|
+
* `Object.defineProperties`でプロパティ記述子ごと合成する)。
|
|
15
|
+
* @param overrides - コンポーネントが必要とする追加プロパティ・メソッド
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const engine = createMockEngine({ content: { type: 'draft' } });
|
|
19
|
+
* ```
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // uiStateのprocessingを都度反映するライブなgetterを差し込む
|
|
23
|
+
* const uiState = new UIStateStore();
|
|
24
|
+
* const engine = createMockEngine({
|
|
25
|
+
* uiState,
|
|
26
|
+
* get isProcessed() {
|
|
27
|
+
* return uiState.getSnapshot().processing;
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function createMockEngine(overrides?: Record<string, unknown>): BurgerEditorEngine;
|
|
33
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAC/B,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,kBAAkB,CAoCpB"}
|
|
@@ -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 @@
|
|
|
1
|
+
export { t as createMockEngine } from "./create-mock-engine-BloCpuEu.js";
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { t as createMockEngine } from "./create-mock-engine-BloCpuEu.js";
|
|
2
|
+
import { t as EngineProvider } from "./engine-context-oEEsvNSx.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { render } from "@testing-library/react";
|
|
5
|
+
import { afterEach, beforeEach, vi } from "vitest";
|
|
6
|
+
// src/testing/render-with-engine.tsx
|
|
7
|
+
/**
|
|
8
|
+
* `@testing-library/react`'s `render`, pre-wrapped in an `EngineProvider`.
|
|
9
|
+
* Every client UI component under test reads its engine via `useEngine()`
|
|
10
|
+
* now, so this is the standard entry point for component specs — pass
|
|
11
|
+
* the same fake/mock engine object the spec already builds.
|
|
12
|
+
* @param engine - The (mock) engine to provide
|
|
13
|
+
* @param ui - The element to render
|
|
14
|
+
* @param options - Forwarded to Testing Library's `render`
|
|
15
|
+
* @returns The Testing Library render result
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const engine = createMockEngine();
|
|
19
|
+
* renderWithEngine(engine, <FileList fileType="image" />);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
function renderWithEngine(engine, ui, options) {
|
|
23
|
+
return render(/* @__PURE__ */ jsx(EngineProvider, {
|
|
24
|
+
engine,
|
|
25
|
+
children: ui
|
|
26
|
+
}), options);
|
|
27
|
+
}
|
|
28
|
+
// src/testing/suppress-console-error.ts
|
|
29
|
+
/**
|
|
30
|
+
* Silence `console.error` for the current test file only (registers its
|
|
31
|
+
* own `beforeEach`/`afterEach`, so this must be called at a describe/
|
|
32
|
+
* module's top level, not inside a `test()`).
|
|
33
|
+
*
|
|
34
|
+
* Several Browser Mode specs hit known false-positive React warnings
|
|
35
|
+
* (act-wrapping noise around a real browser async event, or a
|
|
36
|
+
* Suspense/act warning from reading an already-fulfilled-tagged
|
|
37
|
+
* thenable) that don't indicate a real bug — see each call site's own
|
|
38
|
+
* comment for which warning and why. Scoped per-file instead of a
|
|
39
|
+
* global `setup.ts` override, so an unrelated regression's act warning
|
|
40
|
+
* elsewhere still surfaces.
|
|
41
|
+
* @param patterns - Substrings to match against `console.error`'s first
|
|
42
|
+
* argument; matching calls are dropped, everything else passes through.
|
|
43
|
+
* Omit to silence every `console.error` call in this file instead (e.g.
|
|
44
|
+
* when the test intentionally throws and React's own double-logging of
|
|
45
|
+
* an already-caught error is the only thing to silence).
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* suppressConsoleErrors('was not wrapped in act(...)');
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
function suppressConsoleErrors(patterns) {
|
|
52
|
+
let spy;
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
const originalConsoleError = console.error.bind(console);
|
|
55
|
+
spy = vi.spyOn(console, "error").mockImplementation((...args) => {
|
|
56
|
+
if (!patterns) return;
|
|
57
|
+
const [first] = args;
|
|
58
|
+
if (typeof first === "string" && patterns.some((pattern) => first.includes(pattern))) return;
|
|
59
|
+
originalConsoleError(...args);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
afterEach(() => {
|
|
63
|
+
spy.mockRestore();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export { createMockEngine, renderWithEngine, suppressConsoleErrors };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","names":["render","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/render-with-engine.tsx","../src/testing/suppress-console-error.ts"],"sourcesContent":["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":";;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgBC,iBACfC,QACAC,IACAC,SACC;CACD,OAAOJ,OAAO,oBAAC,gBAAD;EAAwBE;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
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { InvokerCommandAttributes } from './invoker-commands.js';
|
|
2
|
+
export type { InterestHintAttributes } from './interest-hints.js';
|
|
3
|
+
export { EditorDialog } from './editor-dialog.js';
|
|
4
|
+
export { EngineProvider, useEngine } from './engine-context.js';
|
|
5
|
+
export { reactMount } from './mount.js';
|
|
6
|
+
export { registerEngineCommands } from './commands/register-engine-commands.js';
|
|
7
|
+
export * from './components/index.js';
|
|
8
|
+
export { RootErrorBoundary, reportRenderError } from './root-error-boundary.js';
|
|
9
|
+
export { useCommand } from './use-command.js';
|
|
10
|
+
export type { CommandHandlers } from './use-command.js';
|
|
11
|
+
export { useMountEffect } from './use-mount-effect.js';
|
|
12
|
+
export { useUIState } from './use-engine.js';
|
|
13
|
+
export { useFileBrowser } from './file-browser/use-file-browser.js';
|
|
14
|
+
export { useExternalFileSelection } from './file-browser/use-external-file-selection.js';
|
|
15
|
+
export type { FileBrowserStore, FileBrowserQuery, SelectedFile, UploadProgress, } from './file-browser/store.js';
|
|
16
|
+
export * from './form/index.js';
|
|
17
|
+
//# sourceMappingURL=ui.d.ts.map
|
package/dist/ui.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,qBAAqB,CAAC;AAE7B,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,YAAY,EACX,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,cAAc,GACd,MAAM,yBAAyB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|