@sqlrooms/blocks 0.29.0-rc.6
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/LICENSE.md +9 -0
- package/README.md +48 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2025 SQLRooms Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @sqlrooms/blocks
|
|
2
|
+
|
|
3
|
+
Shared contracts and vocabulary for composable SQLRooms blocks.
|
|
4
|
+
|
|
5
|
+
Blocks are reusable units of SQLRooms workspace state or behavior. A block can
|
|
6
|
+
be small and local, like a text or chart block, or stateful, like a dashboard,
|
|
7
|
+
pivot table, notebook, or app surface. This package defines the shared language
|
|
8
|
+
for those block-shaped resources without owning their concrete runtime.
|
|
9
|
+
|
|
10
|
+
This package intentionally contains no feature runtime, stores, or UI
|
|
11
|
+
implementations. Feature packages own concrete block definitions:
|
|
12
|
+
|
|
13
|
+
- `@sqlrooms/mosaic` owns dashboard/chart block implementations.
|
|
14
|
+
- `@sqlrooms/pivot` owns pivot block implementations.
|
|
15
|
+
- `@sqlrooms/documents` owns document and rich content block implementations.
|
|
16
|
+
- Notebook/canvas/app packages own their own stateful block implementations.
|
|
17
|
+
|
|
18
|
+
`@sqlrooms/blocks` provides the small shared contract layer that lets those
|
|
19
|
+
implementations be hosted consistently in artifacts, documents, notebooks, or
|
|
20
|
+
other block containers.
|
|
21
|
+
|
|
22
|
+
## Concepts
|
|
23
|
+
|
|
24
|
+
- `BlockInstance` identifies a block and stores portable block attributes.
|
|
25
|
+
- `BlockReference` points at state managed elsewhere and records whether that
|
|
26
|
+
state is owned, shared, or external.
|
|
27
|
+
- `StatefulBlockDefinition` describes how a feature package creates, ensures,
|
|
28
|
+
renames, deletes, closes, and renders its block state.
|
|
29
|
+
- `OrderedBlockContainer` and `GraphBlockContainer` describe common container
|
|
30
|
+
shapes: linear documents and DAG-like notebooks.
|
|
31
|
+
|
|
32
|
+
Concrete packages should keep their own state slices and renderers close to
|
|
33
|
+
their domain. For example, dashboard blocks remain owned by `@sqlrooms/mosaic`,
|
|
34
|
+
pivot blocks remain owned by `@sqlrooms/pivot`, and Markdown document blocks
|
|
35
|
+
remain owned by `@sqlrooms/documents`.
|
|
36
|
+
|
|
37
|
+
## Block Documents
|
|
38
|
+
|
|
39
|
+
The first rich ordered block container in SQLRooms is
|
|
40
|
+
[`BlockDocument`](../documents/README.md#block-documents) from
|
|
41
|
+
`@sqlrooms/documents`.
|
|
42
|
+
`BlockDocument` uses these shared contracts to host text, images, charts, and
|
|
43
|
+
stateful blocks while keeping the editor/document runtime in the documents
|
|
44
|
+
package.
|
|
45
|
+
|
|
46
|
+
Use `@sqlrooms/blocks` when defining cross-package contracts for block-shaped
|
|
47
|
+
resources. Use `@sqlrooms/documents` when you need the Tiptap-backed
|
|
48
|
+
`BlockDocument` editor, persistence slice, commands, or AI authoring tools.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared block contracts for SQLRooms packages.
|
|
3
|
+
*
|
|
4
|
+
* This package owns vocabulary and type shapes only. Concrete block
|
|
5
|
+
* implementations remain in the feature packages that own their state.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { ComponentType } from 'react';
|
|
10
|
+
export type BlockId = string;
|
|
11
|
+
export type BlockType = string;
|
|
12
|
+
export type BlockInstance<TAttrs extends Record<string, unknown> = Record<string, unknown>> = {
|
|
13
|
+
id: BlockId;
|
|
14
|
+
type: BlockType;
|
|
15
|
+
title?: string;
|
|
16
|
+
attrs?: TAttrs;
|
|
17
|
+
};
|
|
18
|
+
export type BlockCapability = 'stateful' | 'selectable' | 'embeddable' | 'executable' | 'participatesInDag' | 'producesRelation' | 'consumesRelation' | 'hasRuntimeCache';
|
|
19
|
+
export type BlockCapabilities = Partial<Record<BlockCapability, true>>;
|
|
20
|
+
export type BlockOwnership = 'owned' | 'shared' | 'external';
|
|
21
|
+
export type BlockReference = {
|
|
22
|
+
blockInstanceId: BlockId;
|
|
23
|
+
blockType: BlockType;
|
|
24
|
+
ownership?: BlockOwnership;
|
|
25
|
+
};
|
|
26
|
+
export type OrderedBlockContainer = {
|
|
27
|
+
blockIds: BlockId[];
|
|
28
|
+
};
|
|
29
|
+
export type GraphBlockEdgeKind = 'dependency' | 'manual' | (string & {});
|
|
30
|
+
export type GraphBlockEdge = {
|
|
31
|
+
id: string;
|
|
32
|
+
source: BlockId;
|
|
33
|
+
target: BlockId;
|
|
34
|
+
kind?: GraphBlockEdgeKind;
|
|
35
|
+
};
|
|
36
|
+
export type GraphBlockContainer = OrderedBlockContainer & {
|
|
37
|
+
edges: GraphBlockEdge[];
|
|
38
|
+
};
|
|
39
|
+
export type StatefulBlockContext<TRoomState = unknown> = {
|
|
40
|
+
blockId: BlockId;
|
|
41
|
+
blockType: BlockType;
|
|
42
|
+
title?: string;
|
|
43
|
+
attrs?: Record<string, unknown>;
|
|
44
|
+
getState: () => TRoomState;
|
|
45
|
+
};
|
|
46
|
+
export type StatefulBlockRenameContext<TRoomState = unknown> = StatefulBlockContext<TRoomState> & {
|
|
47
|
+
previousTitle: string;
|
|
48
|
+
title: string;
|
|
49
|
+
};
|
|
50
|
+
export type StatefulBlockRenderProps<TRoomState = unknown> = {
|
|
51
|
+
blockId: BlockId;
|
|
52
|
+
blockType: BlockType;
|
|
53
|
+
title?: string;
|
|
54
|
+
attrs?: Record<string, unknown>;
|
|
55
|
+
readOnly?: boolean;
|
|
56
|
+
getState?: () => TRoomState;
|
|
57
|
+
};
|
|
58
|
+
export type StatefulBlockDefinition<TRoomState = unknown> = {
|
|
59
|
+
type: BlockType;
|
|
60
|
+
label: string;
|
|
61
|
+
defaultTitle?: string;
|
|
62
|
+
icon?: ComponentType<{
|
|
63
|
+
className?: string;
|
|
64
|
+
}>;
|
|
65
|
+
capabilities?: BlockCapabilities;
|
|
66
|
+
createInstance?: (context: StatefulBlockContext<TRoomState>) => BlockInstance;
|
|
67
|
+
ensureState?: (context: StatefulBlockContext<TRoomState>) => void;
|
|
68
|
+
deleteState?: (context: StatefulBlockContext<TRoomState>) => void;
|
|
69
|
+
rename?: (context: StatefulBlockRenameContext<TRoomState>) => void;
|
|
70
|
+
close?: (context: StatefulBlockContext<TRoomState>) => void;
|
|
71
|
+
render: ComponentType<StatefulBlockRenderProps<TRoomState>>;
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAO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UAAU,CAAC,KAAK,IAAI,CAAC;IAClE,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAClE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,0BAA0B,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IACnE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAC5D,MAAM,EAAE,aAAa,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC,CAAC;CAC7D,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared block contracts for SQLRooms packages.
|
|
3
|
+
*
|
|
4
|
+
* This package owns vocabulary and type shapes only. Concrete block
|
|
5
|
+
* implementations remain in the feature packages that own their state.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG","sourcesContent":["/**\n * Shared block contracts for SQLRooms packages.\n *\n * This package owns vocabulary and type shapes only. Concrete block\n * implementations remain in the feature packages that own their state.\n *\n * @packageDocumentation\n */\n\nimport type {ComponentType} from 'react';\n\nexport type BlockId = string;\nexport type BlockType = string;\n\nexport type BlockInstance<\n TAttrs extends Record<string, unknown> = Record<string, unknown>,\n> = {\n id: BlockId;\n type: BlockType;\n title?: string;\n attrs?: TAttrs;\n};\n\nexport type BlockCapability =\n | 'stateful'\n | 'selectable'\n | 'embeddable'\n | 'executable'\n | 'participatesInDag'\n | 'producesRelation'\n | 'consumesRelation'\n | 'hasRuntimeCache';\n\nexport type BlockCapabilities = Partial<Record<BlockCapability, true>>;\n\nexport type BlockOwnership = 'owned' | 'shared' | 'external';\n\nexport type BlockReference = {\n blockInstanceId: BlockId;\n blockType: BlockType;\n ownership?: BlockOwnership;\n};\n\nexport type OrderedBlockContainer = {\n blockIds: BlockId[];\n};\n\nexport type GraphBlockEdgeKind = 'dependency' | 'manual' | (string & {});\n\nexport type GraphBlockEdge = {\n id: string;\n source: BlockId;\n target: BlockId;\n kind?: GraphBlockEdgeKind;\n};\n\nexport type GraphBlockContainer = OrderedBlockContainer & {\n edges: GraphBlockEdge[];\n};\n\nexport type StatefulBlockContext<TRoomState = unknown> = {\n blockId: BlockId;\n blockType: BlockType;\n title?: string;\n attrs?: Record<string, unknown>;\n getState: () => TRoomState;\n};\n\nexport type StatefulBlockRenameContext<TRoomState = unknown> =\n StatefulBlockContext<TRoomState> & {\n previousTitle: string;\n title: string;\n };\n\nexport type StatefulBlockRenderProps<TRoomState = unknown> = {\n blockId: BlockId;\n blockType: BlockType;\n title?: string;\n attrs?: Record<string, unknown>;\n readOnly?: boolean;\n getState?: () => TRoomState;\n};\n\nexport type StatefulBlockDefinition<TRoomState = unknown> = {\n type: BlockType;\n label: string;\n defaultTitle?: string;\n icon?: ComponentType<{className?: string}>;\n capabilities?: BlockCapabilities;\n createInstance?: (\n context: StatefulBlockContext<TRoomState>,\n ) => BlockInstance;\n ensureState?: (context: StatefulBlockContext<TRoomState>) => void;\n deleteState?: (context: StatefulBlockContext<TRoomState>) => void;\n rename?: (context: StatefulBlockRenameContext<TRoomState>) => void;\n close?: (context: StatefulBlockContext<TRoomState>) => void;\n render: ComponentType<StatefulBlockRenderProps<TRoomState>>;\n};\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sqlrooms/blocks",
|
|
3
|
+
"version": "0.29.0-rc.6",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/sqlrooms/sqlrooms.git"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "SQLRooms Contributors",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"module": "dist/index.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/react": "*"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": ">=18"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"dev": "tsc -w",
|
|
37
|
+
"lint": "eslint .",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"typedoc": "typedoc"
|
|
40
|
+
}
|
|
41
|
+
}
|