@notionhq/custom-blocks 0.4.0 → 0.5.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.
- package/dist/bridge/SandboxBridge.d.ts +0 -16
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +0 -38
- package/dist/dataSources/bridge/resolveDataSourceQuery.js +3 -3
- package/dist/dataSources/bridge/resolveDataSources.js +4 -4
- package/dist/dataSources/filters/resolveFilter.d.ts.map +1 -1
- package/dist/dataSources/filters/resolveFilter.js +13 -3
- package/dist/dataSources/filters/types.d.ts +9 -3
- package/dist/dataSources/filters/types.d.ts.map +1 -1
- package/dist/dataSources/properties/resolvePropertyAddress.js +1 -1
- package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.js +1 -1
- package/dist/dataSources/resolvePageDataSource.js +2 -2
- package/dist/dataSources/subscribeToDataSource.d.ts +1 -4
- package/dist/dataSources/subscribeToDataSource.d.ts.map +1 -1
- package/dist/dataSources/subscribeToDataSource.js +2 -3
- package/dist/files/files.d.ts +2 -0
- package/dist/files/files.d.ts.map +1 -0
- package/dist/files/files.js +1 -0
- package/dist/files/icons.d.ts +2 -0
- package/dist/files/icons.d.ts.map +1 -0
- package/dist/files/icons.js +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/initialization/getInitBindingError.js +2 -2
- package/dist/manifest/types.d.ts +4 -3
- package/dist/manifest/types.d.ts.map +1 -1
- package/dist/pages/bridge/getPageForDataSource.js +1 -1
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts +4 -1
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts.map +1 -1
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts.map +1 -1
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.js +0 -2
- package/dist/pages/bridge/updatePage.js +1 -1
- package/dist/pages/properties/getPropertyByKey.js +2 -2
- package/dist/pages/types.d.ts +8 -10
- package/dist/pages/types.d.ts.map +1 -1
- package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.d.ts +530 -0
- package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.js +25 -0
- package/dist/protocol/compatibility/protocol3To5/bridgePage.d.ts +6 -7
- package/dist/protocol/compatibility/protocol3To5/bridgePage.js +3 -3
- package/dist/protocol/context/containingPage.d.ts +3 -0
- package/dist/protocol/context/messages/pageChanged.d.ts +3 -0
- package/dist/protocol/context/messages/parentChanged.d.ts +3 -0
- package/dist/protocol/context/parent.d.ts +3 -0
- package/dist/protocol/context/parent.js +6 -1
- package/dist/protocol/dataSources/bridgeDataSourceBinding.d.ts +3 -7
- package/dist/protocol/dataSources/bridgeDataSourceBinding.js +5 -5
- package/dist/protocol/dataSources/bridgeDataSourceBindings.d.ts +2 -6
- package/dist/protocol/dataSources/{collectionPointer.d.ts → dataSourcePointer.d.ts} +2 -2
- package/dist/protocol/dataSources/{collectionPointer.js → dataSourcePointer.js} +1 -1
- package/dist/protocol/dataSources/{collectionSchema.d.ts → dataSourceSchema.d.ts} +2 -6
- package/dist/protocol/dataSources/{collectionSchema.js → dataSourceSchema.js} +1 -1
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilter.d.ts +1458 -12
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.d.ts +729 -6
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.js +14 -2
- package/dist/protocol/dataSources/filters/peopleFilterOperator.d.ts +3 -3
- package/dist/protocol/dataSources/filters/peopleFilterOperator.js +1 -1
- package/dist/protocol/dataSources/filters/timestampFilterOperator.d.ts +354 -0
- package/dist/protocol/dataSources/filters/timestampFilterOperator.js +4 -0
- package/dist/protocol/dataSources/messages/dataSourcesChanged.d.ts +2 -6
- package/dist/protocol/dataSources/messages/queryDataSource.d.ts +1470 -26
- package/dist/protocol/dataSources/notionDataSource.d.ts +3 -11
- package/dist/protocol/dataSources/notionDataSource.js +5 -5
- package/dist/protocol/dataSources/properties/propertySchema.d.ts +4 -9
- package/dist/protocol/dataSources/properties/propertySchema.js +2 -4
- package/dist/protocol/dataSources/resolveDataSourceBinding.d.ts +4 -4
- package/dist/protocol/dataSources/resolveDataSourceBinding.js +2 -2
- package/dist/protocol/files.d.ts +32 -0
- package/dist/protocol/files.js +17 -0
- package/dist/protocol/handshake/connect.d.ts +1 -1
- package/dist/protocol/handshake/init.d.ts +9 -7
- package/dist/protocol/icons.d.ts +22 -7
- package/dist/protocol/icons.js +19 -7
- package/dist/protocol/index.d.ts +16 -14
- package/dist/protocol/index.js +10 -7
- package/dist/protocol/manifest/manifest.d.ts +9 -9
- package/dist/protocol/manifest/manifest.js +7 -7
- package/dist/protocol/messages/hostToSandbox.d.ts +100 -103
- package/dist/protocol/messages/sandboxToHost.d.ts +1471 -37
- package/dist/protocol/pages/bridgePage.d.ts +6 -7
- package/dist/protocol/pages/bridgePage.js +3 -3
- package/dist/protocol/pages/messages/createPage.d.ts +547 -40
- package/dist/protocol/pages/messages/createPage.js +27 -15
- package/dist/protocol/pages/messages/getPage.d.ts +18 -21
- package/dist/protocol/pages/messages/updatePage.d.ts +21 -28
- package/dist/protocol/pages/messages/updatePage.js +3 -3
- package/dist/protocol/pages/pageAppearance.d.ts +5 -59
- package/dist/protocol/pages/pageAppearance.js +11 -40
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +4 -12
- package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +2 -6
- package/dist/protocol/pages/properties/bridgePagePropertyValue.js +2 -7
- package/dist/protocol/utils/ids.d.ts +2 -0
- package/dist/protocol/utils/ids.js +1 -0
- package/dist/protocol/utils/protocolVersion.d.ts +2 -1
- package/dist/protocol/utils/protocolVersion.js +3 -1
- package/dist/react/NotionCustomBlock.d.ts.map +1 -1
- package/dist/react/NotionCustomBlock.js +1 -15
- package/dist/utils/version.js +1 -1
- package/docs/data-sources.md +74 -76
- package/docs/deployment.md +4 -5
- package/docs/pages.md +91 -55
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +0 -55
- package/src/dataSources/bridge/resolveDataSourceQuery.ts +3 -3
- package/src/dataSources/bridge/resolveDataSources.ts +4 -4
- package/src/dataSources/filters/resolveFilter.ts +12 -3
- package/src/dataSources/filters/types.ts +7 -4
- package/src/dataSources/properties/resolvePropertyAddress.ts +1 -1
- package/src/dataSources/properties/resolvePropertyWriteMapForDataSource.ts +1 -1
- package/src/dataSources/resolvePageDataSource.ts +2 -2
- package/src/dataSources/subscribeToDataSource.ts +7 -19
- package/src/files/files.ts +5 -0
- package/src/files/icons.ts +9 -0
- package/src/index.ts +6 -11
- package/src/initialization/getInitBindingError.ts +2 -2
- package/src/manifest/types.ts +9 -3
- package/src/pages/bridge/getPageForDataSource.ts +1 -1
- package/src/pages/bridge/toNotionPagePropertyFromBridgeProperty.ts +0 -2
- package/src/pages/bridge/updatePage.ts +1 -1
- package/src/pages/properties/getPropertyByKey.ts +2 -2
- package/src/pages/types.ts +9 -13
- package/src/react/NotionCustomBlock.tsx +1 -16
- package/dist/protocol/dataSources/filters/createdByFilterOperator.d.ts +0 -17
- package/dist/protocol/dataSources/filters/createdByFilterOperator.js +0 -11
- package/dist/protocol/pages/properties/fileInput.d.ts +0 -16
- package/dist/protocol/pages/properties/fileInput.js +0 -16
- package/dist/react/DebugMessageLog.d.ts +0 -2
- package/dist/react/DebugMessageLog.d.ts.map +0 -1
- package/dist/react/DebugMessageLog.js +0 -23
- package/src/react/DebugMessageLog.tsx +0 -34
|
@@ -18,8 +18,8 @@ export function getPropertyByKey(
|
|
|
18
18
|
: undefined
|
|
19
19
|
// Keep the captured mapping valid only while its key remains bound to the original database.
|
|
20
20
|
if (
|
|
21
|
-
!dataSource?.
|
|
22
|
-
currentDataSource?.
|
|
21
|
+
!dataSource?.dataSourcePointer ||
|
|
22
|
+
currentDataSource?.dataSourcePointer?.id !== dataSource.dataSourcePointer.id
|
|
23
23
|
) {
|
|
24
24
|
return null
|
|
25
25
|
}
|
package/src/pages/types.ts
CHANGED
|
@@ -14,27 +14,25 @@ import type {
|
|
|
14
14
|
} from "@notionhq/custom-blocks-protocol/pages/messages/openPage.js"
|
|
15
15
|
import type { CustomBlockUpdatePageErrorInfo } from "@notionhq/custom-blocks-protocol/pages/messages/updatePage.js"
|
|
16
16
|
import type {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
NotionPageIcon,
|
|
17
|
+
BridgePageCover,
|
|
18
|
+
BridgePageIcon,
|
|
20
19
|
} from "@notionhq/custom-blocks-protocol/pages/pageAppearance.js"
|
|
21
20
|
import type { NotionDateInput } from "@notionhq/custom-blocks-protocol/pages/properties/dateInput.js"
|
|
22
|
-
import type { NotionFileInput } from "@notionhq/custom-blocks-protocol/pages/properties/fileInput.js"
|
|
23
21
|
import type { NotionPlaceInput } from "@notionhq/custom-blocks-protocol/pages/properties/placeInput.js"
|
|
24
22
|
import type { NotionRelationInput } from "@notionhq/custom-blocks-protocol/pages/properties/relationInput.js"
|
|
25
23
|
import type { NotionRichTextItem } from "@notionhq/custom-blocks-protocol/pages/properties/richText.js"
|
|
26
24
|
import type { NotionSelectOptionInput } from "@notionhq/custom-blocks-protocol/pages/properties/selectOption.js"
|
|
27
25
|
import type { NotionUserInput } from "@notionhq/custom-blocks-protocol/pages/properties/userInput.js"
|
|
28
26
|
import type { NotionPageId } from "@notionhq/custom-blocks-protocol/utils/ids.js"
|
|
27
|
+
import type { NotionFilePropertyItem } from "../files/files.js"
|
|
29
28
|
import type { KeyedDataSourceParent } from "./parent.js"
|
|
30
29
|
|
|
31
|
-
export type {
|
|
32
|
-
NotionPageCover,
|
|
33
|
-
NotionPageIcon,
|
|
34
|
-
} from "@notionhq/custom-blocks-protocol/pages/pageAppearance.js"
|
|
35
30
|
// These leaf values intentionally share their SDK and protocol representation.
|
|
36
31
|
export type { NotionDateInput } from "@notionhq/custom-blocks-protocol/pages/properties/dateInput.js"
|
|
37
32
|
|
|
33
|
+
export type NotionPageIcon = BridgePageIcon
|
|
34
|
+
export type NotionPageCover = BridgePageCover
|
|
35
|
+
|
|
38
36
|
export type NotionPagePropertyValue = { id: string } & (
|
|
39
37
|
| { type: "title"; title: NotionRichTextItem[] }
|
|
40
38
|
| { type: "rich_text"; rich_text: NotionRichTextItem[] }
|
|
@@ -49,7 +47,7 @@ export type NotionPagePropertyValue = { id: string } & (
|
|
|
49
47
|
| { type: "date"; date: NotionDateInput | null }
|
|
50
48
|
| { type: "people"; people: NotionUserInput[] }
|
|
51
49
|
| { type: "relation"; relation: NotionRelationInput[]; has_more?: boolean }
|
|
52
|
-
| { type: "files"; files:
|
|
50
|
+
| { type: "files"; files: NotionFilePropertyItem[] }
|
|
53
51
|
| { type: "place"; place: NotionPlaceInput | null }
|
|
54
52
|
| { type: "created_time"; created_time: string | null }
|
|
55
53
|
| { type: "last_edited_time"; last_edited_time: string | null }
|
|
@@ -58,7 +56,6 @@ export type NotionPagePropertyValue = { id: string } & (
|
|
|
58
56
|
| { type: "unique_id"; unique_id: string }
|
|
59
57
|
| { type: "button"; button: string }
|
|
60
58
|
| { type: "formula"; formula: string }
|
|
61
|
-
| { type: "location"; location: string }
|
|
62
59
|
| { type: "rollup"; rollup: string }
|
|
63
60
|
| { type: "verification"; verification: string }
|
|
64
61
|
)
|
|
@@ -86,7 +83,6 @@ export type NotionPagePropertyInputValue =
|
|
|
86
83
|
| "unique_id"
|
|
87
84
|
| "button"
|
|
88
85
|
| "formula"
|
|
89
|
-
| "location"
|
|
90
86
|
| "rollup"
|
|
91
87
|
| "verification"
|
|
92
88
|
}
|
|
@@ -145,7 +141,7 @@ export type CreatePageResult =
|
|
|
145
141
|
*
|
|
146
142
|
* - `page_id`: Create a child page under the given Notion page.
|
|
147
143
|
* - `data_source_id`: Create a row inside the given Notion data source. The public API's
|
|
148
|
-
* `data_source_id` is the same UUID as the `
|
|
144
|
+
* `data_source_id` is the same UUID as the `dataSourcePointer.id` exposed in `dataSources`,
|
|
149
145
|
* so either value works here.
|
|
150
146
|
* - `data_source_key`: Create a row inside the data source that the custom block was configured with
|
|
151
147
|
* under this semantic key. The SDK resolves the key to a `data_source_id` locally before
|
|
@@ -158,7 +154,7 @@ export type { CreatePageParent } from "./parent.js"
|
|
|
158
154
|
*/
|
|
159
155
|
export type CreatePageArgs = {
|
|
160
156
|
properties: NotionPagePropertyInputMap
|
|
161
|
-
icon?:
|
|
157
|
+
icon?: NotionPageIcon
|
|
162
158
|
cover?: NotionPageCover
|
|
163
159
|
} & (
|
|
164
160
|
| {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { CustomBlockInitializationError } from "@notionhq/custom-blocks-protocol/handshake/init.js"
|
|
2
2
|
import type { ReactNode } from "react"
|
|
3
|
-
import { useEffect, useLayoutEffect
|
|
3
|
+
import { useEffect, useLayoutEffect } from "react"
|
|
4
4
|
import { getBridge } from "../bridge/getBridge.js"
|
|
5
5
|
import { useCustomBlockInit } from "../initialization/react/useCustomBlockInit.js"
|
|
6
6
|
import { autoResize } from "../layout/autoResize.js"
|
|
7
|
-
import { DebugMessageLog } from "./DebugMessageLog.js"
|
|
8
7
|
import { InitializationErrorDetails } from "./InitializationErrorDetails.js"
|
|
9
8
|
import { MissingHostScreen } from "./MissingHostScreen.js"
|
|
10
9
|
import "./InitializationErrorScreen.css"
|
|
@@ -51,7 +50,6 @@ export function NotionCustomBlock({
|
|
|
51
50
|
errorFallback,
|
|
52
51
|
}: NotionCustomBlockProps) {
|
|
53
52
|
const init = useCustomBlockInit()
|
|
54
|
-
const [debugOpen, setDebugOpen] = useState(false)
|
|
55
53
|
|
|
56
54
|
// Keep the host iframe height in sync with the block's content after initialization.
|
|
57
55
|
useEffect(() => {
|
|
@@ -61,16 +59,6 @@ export function NotionCustomBlock({
|
|
|
61
59
|
return autoResize({ target: document.getElementById("root") })
|
|
62
60
|
}, [init.isLoaded])
|
|
63
61
|
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
const onKeyDown = (e: KeyboardEvent) => {
|
|
66
|
-
if (e.key === "\\") {
|
|
67
|
-
setDebugOpen(prev => !prev)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
window.addEventListener("keydown", onKeyDown)
|
|
71
|
-
return () => window.removeEventListener("keydown", onKeyDown)
|
|
72
|
-
}, [])
|
|
73
|
-
|
|
74
62
|
useLayoutEffect(() => {
|
|
75
63
|
if (!init.isLoaded) {
|
|
76
64
|
return
|
|
@@ -80,9 +68,6 @@ export function NotionCustomBlock({
|
|
|
80
68
|
getBridge().completeInitialization()
|
|
81
69
|
}, [init.isLoaded])
|
|
82
70
|
|
|
83
|
-
if (debugOpen) {
|
|
84
|
-
return <DebugMessageLog />
|
|
85
|
-
}
|
|
86
71
|
if (init.error) {
|
|
87
72
|
if (errorFallback === undefined) {
|
|
88
73
|
return <DefaultInitErrorFallback error={init.error} />
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const customBlockCreatedByFilterOperatorSchema: v.UnionSchema<[v.StrictObjectSchema<{
|
|
3
|
-
readonly contains: v.StrictObjectSchema<{
|
|
4
|
-
readonly object: v.LiteralSchema<"user", undefined>;
|
|
5
|
-
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
6
|
-
}, undefined>;
|
|
7
|
-
}, undefined>, v.StrictObjectSchema<{
|
|
8
|
-
readonly does_not_contain: v.StrictObjectSchema<{
|
|
9
|
-
readonly object: v.LiteralSchema<"user", undefined>;
|
|
10
|
-
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
11
|
-
}, undefined>;
|
|
12
|
-
}, undefined>, v.StrictObjectSchema<{
|
|
13
|
-
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
14
|
-
}, undefined>, v.StrictObjectSchema<{
|
|
15
|
-
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
16
|
-
}, undefined>], undefined>;
|
|
17
|
-
export type CustomBlockCreatedByFilterOperator = v.InferOutput<typeof customBlockCreatedByFilterOperatorSchema>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
const customBlockCreatorFilterValueSchema = v.strictObject({
|
|
3
|
-
object: v.literal("user"),
|
|
4
|
-
id: v.pipe(v.string(), v.minLength(1), v.maxLength(2_000)),
|
|
5
|
-
});
|
|
6
|
-
export const customBlockCreatedByFilterOperatorSchema = v.union([
|
|
7
|
-
v.strictObject({ contains: customBlockCreatorFilterValueSchema }),
|
|
8
|
-
v.strictObject({ does_not_contain: customBlockCreatorFilterValueSchema }),
|
|
9
|
-
v.strictObject({ is_empty: v.literal(true) }),
|
|
10
|
-
v.strictObject({ is_not_empty: v.literal(true) }),
|
|
11
|
-
]);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export declare const notionFileInputSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
3
|
-
readonly type: v.LiteralSchema<"external", undefined>;
|
|
4
|
-
readonly name: v.StringSchema<undefined>;
|
|
5
|
-
readonly external: v.ObjectSchema<{
|
|
6
|
-
readonly url: v.StringSchema<undefined>;
|
|
7
|
-
}, undefined>;
|
|
8
|
-
}, undefined>, v.ObjectSchema<{
|
|
9
|
-
readonly type: v.LiteralSchema<"file", undefined>;
|
|
10
|
-
readonly name: v.StringSchema<undefined>;
|
|
11
|
-
readonly file: v.ObjectSchema<{
|
|
12
|
-
readonly url: v.StringSchema<undefined>;
|
|
13
|
-
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
14
|
-
}, undefined>;
|
|
15
|
-
}, undefined>], undefined>;
|
|
16
|
-
export type NotionFileInput = v.InferOutput<typeof notionFileInputSchema>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot";
|
|
2
|
-
export const notionFileInputSchema = v.union([
|
|
3
|
-
v.object({
|
|
4
|
-
type: v.literal("external"),
|
|
5
|
-
name: v.string(),
|
|
6
|
-
external: v.object({ url: v.string() }),
|
|
7
|
-
}),
|
|
8
|
-
v.object({
|
|
9
|
-
type: v.literal("file"),
|
|
10
|
-
name: v.string(),
|
|
11
|
-
file: v.object({
|
|
12
|
-
url: v.string(),
|
|
13
|
-
expiry_time: v.optional(v.string()),
|
|
14
|
-
}),
|
|
15
|
-
}),
|
|
16
|
-
]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DebugMessageLog.d.ts","sourceRoot":"","sources":["../../src/react/DebugMessageLog.tsx"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,gCAiB9B"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useSyncExternalStore } from "react";
|
|
3
|
-
import { getBridge } from "../bridge/getBridge.js";
|
|
4
|
-
export function DebugMessageLog() {
|
|
5
|
-
const bridge = getBridge();
|
|
6
|
-
const log = useSyncExternalStore(bridge.subscribeToMessageLog, bridge.getMessageLog);
|
|
7
|
-
const text = log
|
|
8
|
-
.map(entry => `[${entry.timestamp}] ${entry.direction}: ${JSON.stringify(entry.data)}`)
|
|
9
|
-
.join("\n");
|
|
10
|
-
return (_jsx("pre", { "data-testid": "debug-message-log", style: DEBUG_PRE_STYLE, children: text || "(no messages yet)" }));
|
|
11
|
-
}
|
|
12
|
-
const DEBUG_PRE_STYLE = {
|
|
13
|
-
margin: 0,
|
|
14
|
-
padding: "8px 12px",
|
|
15
|
-
fontSize: 12,
|
|
16
|
-
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
17
|
-
lineHeight: 1.5,
|
|
18
|
-
whiteSpace: "pre-wrap",
|
|
19
|
-
wordBreak: "break-all",
|
|
20
|
-
userSelect: "text",
|
|
21
|
-
background: "#1e1e1e",
|
|
22
|
-
color: "#d4d4d4",
|
|
23
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useSyncExternalStore } from "react"
|
|
2
|
-
import { getBridge } from "../bridge/getBridge.js"
|
|
3
|
-
|
|
4
|
-
export function DebugMessageLog() {
|
|
5
|
-
const bridge = getBridge()
|
|
6
|
-
const log = useSyncExternalStore(
|
|
7
|
-
bridge.subscribeToMessageLog,
|
|
8
|
-
bridge.getMessageLog,
|
|
9
|
-
)
|
|
10
|
-
const text = log
|
|
11
|
-
.map(
|
|
12
|
-
entry =>
|
|
13
|
-
`[${entry.timestamp}] ${entry.direction}: ${JSON.stringify(entry.data)}`,
|
|
14
|
-
)
|
|
15
|
-
.join("\n")
|
|
16
|
-
return (
|
|
17
|
-
<pre data-testid="debug-message-log" style={DEBUG_PRE_STYLE}>
|
|
18
|
-
{text || "(no messages yet)"}
|
|
19
|
-
</pre>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const DEBUG_PRE_STYLE = {
|
|
24
|
-
margin: 0,
|
|
25
|
-
padding: "8px 12px",
|
|
26
|
-
fontSize: 12,
|
|
27
|
-
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
28
|
-
lineHeight: 1.5,
|
|
29
|
-
whiteSpace: "pre-wrap" as const,
|
|
30
|
-
wordBreak: "break-all" as const,
|
|
31
|
-
userSelect: "text" as const,
|
|
32
|
-
background: "#1e1e1e",
|
|
33
|
-
color: "#d4d4d4",
|
|
34
|
-
}
|