create-ncblock 0.0.36 → 0.0.38
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/package.json
CHANGED
package/sdk-version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.0.
|
|
1
|
+
{"version":"0.0.36"}
|
|
@@ -42,6 +42,7 @@ type NotionInitFixture =
|
|
|
42
42
|
| "invalid-ready"
|
|
43
43
|
| "invalid-manifest"
|
|
44
44
|
| "unsupported-protocol-version"
|
|
45
|
+
| "legacy-ready-v1"
|
|
45
46
|
type TrackedPage = {
|
|
46
47
|
page: NotionPage
|
|
47
48
|
draftTitle: string
|
|
@@ -56,6 +57,11 @@ const metaTextClass =
|
|
|
56
57
|
"font-mono text-[11px] font-normal normal-case tracking-normal text-(--muted)"
|
|
57
58
|
const HOST_NO_READY_ERROR_DELAY_SECONDS = 5
|
|
58
59
|
|
|
60
|
+
function makeMockDataSourceId(value: number): NotionDataSourceId {
|
|
61
|
+
return `00000000-0000-4000-8000-${String(value).padStart(12, "0")}` as NotionDataSourceId
|
|
62
|
+
}
|
|
63
|
+
const DEFAULT_QUERY_DATA_SOURCE_ID = makeMockDataSourceId(1)
|
|
64
|
+
|
|
59
65
|
function App() {
|
|
60
66
|
const blockId = useBlockId()
|
|
61
67
|
const parent = useParent()
|
|
@@ -286,7 +292,8 @@ function DevOnlyInvalidManifestFixture() {
|
|
|
286
292
|
window.parent.postMessage(
|
|
287
293
|
{
|
|
288
294
|
type: "ready",
|
|
289
|
-
|
|
295
|
+
status: "success",
|
|
296
|
+
bridgeProtocolVersion: 2,
|
|
290
297
|
manifest: {
|
|
291
298
|
version: 1,
|
|
292
299
|
dataSources: {
|
|
@@ -339,6 +346,7 @@ function DevOnlyUnsupportedProtocolVersionFixture() {
|
|
|
339
346
|
window.parent.postMessage(
|
|
340
347
|
{
|
|
341
348
|
type: "ready",
|
|
349
|
+
status: "success",
|
|
342
350
|
bridgeProtocolVersion: 1,
|
|
343
351
|
manifest: null,
|
|
344
352
|
},
|
|
@@ -369,6 +377,49 @@ function DevOnlyUnsupportedProtocolVersionFixture() {
|
|
|
369
377
|
)
|
|
370
378
|
}
|
|
371
379
|
|
|
380
|
+
function DevOnlyLegacyReadyV1Fixture() {
|
|
381
|
+
useEffect(() => {
|
|
382
|
+
if (window.parent === window) {
|
|
383
|
+
return
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Dev-only fixture for local manual testing of Notion host init error UI.
|
|
387
|
+
// This intentionally bypasses the SDK and sends the legacy protocol-v1
|
|
388
|
+
// ready shape that existed before ready messages carried `status`.
|
|
389
|
+
window.parent.postMessage(
|
|
390
|
+
{
|
|
391
|
+
type: "ready",
|
|
392
|
+
bridgeProtocolVersion: 1,
|
|
393
|
+
manifest: null,
|
|
394
|
+
},
|
|
395
|
+
"*",
|
|
396
|
+
)
|
|
397
|
+
}, [])
|
|
398
|
+
|
|
399
|
+
return (
|
|
400
|
+
<div className="min-h-screen bg-(--app-bg) p-8 text-(--foreground)">
|
|
401
|
+
<div className={cardClass}>
|
|
402
|
+
<div className={labelClass}>Local init fixture</div>
|
|
403
|
+
<h1 className="mt-2 text-[24px] font-semibold">
|
|
404
|
+
Legacy ready protocol v1
|
|
405
|
+
</h1>
|
|
406
|
+
<p className="mt-2 text-sm leading-6 text-(--muted)">
|
|
407
|
+
This dev-only fixture posts the old <code>ready</code> message shape
|
|
408
|
+
without a <code>status</code> field and with bridge protocol version{" "}
|
|
409
|
+
<code>1</code>. It does not mount the SDK provider. Use it only for
|
|
410
|
+
local manual testing of Notion host init error UI.
|
|
411
|
+
</p>
|
|
412
|
+
<DevOnlyHostErrorExpectation>
|
|
413
|
+
This page is the pre-error fixture, not the Notion error state. In the
|
|
414
|
+
Notion host, set the host minimum bridge protocol version above{" "}
|
|
415
|
+
<code>1</code>; the host-owned unsupported protocol version error
|
|
416
|
+
should cover this page.
|
|
417
|
+
</DevOnlyHostErrorExpectation>
|
|
418
|
+
</div>
|
|
419
|
+
</div>
|
|
420
|
+
)
|
|
421
|
+
}
|
|
422
|
+
|
|
372
423
|
function DevOnlyHostErrorExpectation(props: { children: React.ReactNode }) {
|
|
373
424
|
return (
|
|
374
425
|
<div className="mt-3 rounded-md border border-(--border) bg-(--app-bg) px-3 py-2 text-sm leading-6 text-(--foreground)">
|
|
@@ -407,7 +458,8 @@ function getNotionInitFixture(): NotionInitFixture {
|
|
|
407
458
|
fixture === "no-ready" ||
|
|
408
459
|
fixture === "invalid-ready" ||
|
|
409
460
|
fixture === "invalid-manifest" ||
|
|
410
|
-
fixture === "unsupported-protocol-version"
|
|
461
|
+
fixture === "unsupported-protocol-version" ||
|
|
462
|
+
fixture === "legacy-ready-v1"
|
|
411
463
|
) {
|
|
412
464
|
return fixture
|
|
413
465
|
}
|
|
@@ -1453,7 +1505,8 @@ const PRESETS: {
|
|
|
1453
1505
|
label: "ready",
|
|
1454
1506
|
createMessage: () => ({
|
|
1455
1507
|
type: "ready",
|
|
1456
|
-
|
|
1508
|
+
status: "success",
|
|
1509
|
+
bridgeProtocolVersion: 2,
|
|
1457
1510
|
manifest: null,
|
|
1458
1511
|
}),
|
|
1459
1512
|
},
|
|
@@ -1471,7 +1524,11 @@ const PRESETS: {
|
|
|
1471
1524
|
createMessage: () => ({
|
|
1472
1525
|
type: "queryDataSource",
|
|
1473
1526
|
requestId: "debug-query",
|
|
1474
|
-
|
|
1527
|
+
snapshotId: JSON.stringify({
|
|
1528
|
+
dataSourceId: DEFAULT_QUERY_DATA_SOURCE_ID,
|
|
1529
|
+
limit: 20,
|
|
1530
|
+
}),
|
|
1531
|
+
dataSourceId: DEFAULT_QUERY_DATA_SOURCE_ID,
|
|
1475
1532
|
limit: 20,
|
|
1476
1533
|
}),
|
|
1477
1534
|
},
|
|
@@ -2189,6 +2246,7 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
|
2189
2246
|
{notionInitFixture === "unsupported-protocol-version" && (
|
|
2190
2247
|
<DevOnlyUnsupportedProtocolVersionFixture />
|
|
2191
2248
|
)}
|
|
2249
|
+
{notionInitFixture === "legacy-ready-v1" && <DevOnlyLegacyReadyV1Fixture />}
|
|
2192
2250
|
{notionInitFixture === "normal" && (
|
|
2193
2251
|
<NotionCustomBlock errorFallback={DebugInitErrorFallback}>
|
|
2194
2252
|
<App />
|
|
@@ -451,7 +451,8 @@ function App() {
|
|
|
451
451
|
const manifest = useManifest()
|
|
452
452
|
const activeDataSourceKey =
|
|
453
453
|
Object.keys(manifest?.dataSources ?? {})[0] ?? "default"
|
|
454
|
-
const
|
|
454
|
+
const [queryLimit, setQueryLimit] = React.useState(20)
|
|
455
|
+
const query = useDataSource(activeDataSourceKey, { limit: queryLimit })
|
|
455
456
|
const colorTheme = theme === "dark" ? "dark" : "light"
|
|
456
457
|
const mappedAnalysis = analyzeRadarSchema(query.items)
|
|
457
458
|
const isUsingFallbackData = !mappedAnalysis.isReady
|
|
@@ -522,7 +523,7 @@ function App() {
|
|
|
522
523
|
queryError={query.error?.message}
|
|
523
524
|
hasMore={query.hasMore}
|
|
524
525
|
isLoading={query.isLoading}
|
|
525
|
-
onFetchMore={
|
|
526
|
+
onFetchMore={() => setQueryLimit(limit => limit + 20)}
|
|
526
527
|
/>
|
|
527
528
|
</div>
|
|
528
529
|
)
|
|
@@ -1704,7 +1704,8 @@ function App() {
|
|
|
1704
1704
|
}, [activeDataSourceKey, dataSourceKeys])
|
|
1705
1705
|
|
|
1706
1706
|
const queryKey = dataSourceKeys.length === 0 ? "default" : activeDataSourceKey
|
|
1707
|
-
const
|
|
1707
|
+
const [queryLimit, setQueryLimit] = React.useState(20)
|
|
1708
|
+
const query = useDataSource(queryKey, { limit: queryLimit })
|
|
1708
1709
|
const colorTheme = theme === "dark" ? "dark" : "light"
|
|
1709
1710
|
|
|
1710
1711
|
const mappedItems = query.items as TableRow[]
|
|
@@ -1800,7 +1801,7 @@ function App() {
|
|
|
1800
1801
|
onSelectDataSource={setActiveDataSourceKey}
|
|
1801
1802
|
hasMore={query.hasMore}
|
|
1802
1803
|
isLoading={query.isLoading}
|
|
1803
|
-
onFetchMore={
|
|
1804
|
+
onFetchMore={() => setQueryLimit(limit => limit + 20)}
|
|
1804
1805
|
isUsingFallbackData={isUsingFallbackData}
|
|
1805
1806
|
isCollectionEmpty={isCollectionEmpty}
|
|
1806
1807
|
queryError={query.error?.message}
|