@tvolden/block-code-editor 0.1.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/ThemeContext.d.ts +3 -0
- package/dist/block-editor.cjs +1 -0
- package/dist/block-editor.js +2636 -0
- package/dist/blockRegistry.d.ts +29 -0
- package/dist/blocks-org.json +367 -0
- package/dist/blocks.json +161 -0
- package/dist/carddesigner/CardCanvas.d.ts +10 -0
- package/dist/carddesigner/CardDesigner.d.ts +47 -0
- package/dist/carddesigner/CardPreview.d.ts +11 -0
- package/dist/carddesigner/cardDesignTypes.d.ts +85 -0
- package/dist/components/BlockPalette.d.ts +14 -0
- package/dist/components/BlockRenderer.d.ts +22 -0
- package/dist/components/Canvas.d.ts +18 -0
- package/dist/components/ThemeSwitcher.d.ts +6 -0
- package/dist/editor/BlockEditor.d.ts +54 -0
- package/dist/index.d.ts +7 -0
- package/dist/packages/hand-limit.json +67 -0
- package/dist/packages/motion-ops.json +246 -0
- package/dist/packages/scoring.json +66 -0
- package/dist/packages.json +23 -0
- package/dist/theme.d.ts +48 -0
- package/dist/types.d.ts +53 -0
- package/dist/utils/blockLayout.d.ts +29 -0
- package/dist/utils/blockShapes.d.ts +9 -0
- package/dist/vite.svg +1 -0
- package/package.json +48 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Built-in primitive types. Any other string is a custom value type (e.g. 'Card', 'Player', 'Deck'). */
|
|
2
|
+
export type ParamType = string;
|
|
3
|
+
export type BlockType = 'command' | 'query' | 'start';
|
|
4
|
+
export interface BlockParam {
|
|
5
|
+
name: string;
|
|
6
|
+
type: ParamType;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A guarantee that a particular query block (`id`) will return valid data
|
|
10
|
+
* when used inside a handler chained to this event block. The block is not
|
|
11
|
+
* an output of the event — it is a context promise.
|
|
12
|
+
*
|
|
13
|
+
* Dragging the pill attached to the event block places the referenced query
|
|
14
|
+
* on the canvas. If that query is used outside any providing event, the
|
|
15
|
+
* renderer marks it as out-of-scope (like a missing-collection block).
|
|
16
|
+
*/
|
|
17
|
+
export interface BlockProvide {
|
|
18
|
+
name: string;
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
export interface BlockDefinition {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
blockType: BlockType;
|
|
25
|
+
returnType?: ParamType;
|
|
26
|
+
params: BlockParam[];
|
|
27
|
+
/** Context queries this event guarantees are valid. Only meaningful on start blocks. */
|
|
28
|
+
provides?: BlockProvide[];
|
|
29
|
+
category: string;
|
|
30
|
+
color: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ParamSlot {
|
|
33
|
+
textValue: string | null;
|
|
34
|
+
queryBlockId: string | null;
|
|
35
|
+
}
|
|
36
|
+
export interface PlacedBlock {
|
|
37
|
+
instanceId: string;
|
|
38
|
+
definitionId: string;
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
nextBlockId: string | null;
|
|
42
|
+
parentBlockId: string | null;
|
|
43
|
+
embeddedInBlockId: string | null;
|
|
44
|
+
embeddedSlotIndex: number;
|
|
45
|
+
paramSlots: ParamSlot[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Serialized form of the block canvas — safe to JSON.stringify/parse and
|
|
49
|
+
* store externally (e.g. on a server). Pass back as `initialState` to restore.
|
|
50
|
+
*/
|
|
51
|
+
export interface SerializedCanvas {
|
|
52
|
+
blocks: [string, PlacedBlock][];
|
|
53
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BlockDefinition, ParamType, ParamSlot, PlacedBlock } from '../types';
|
|
2
|
+
export declare const BLOCK_H = 36;
|
|
3
|
+
export declare const HAT_H = 50;
|
|
4
|
+
export declare const QUERY_H = 24;
|
|
5
|
+
export declare const NOTCH_H = 4;
|
|
6
|
+
/** Height of each scope-output pill rendered in the event block's variable panel. */
|
|
7
|
+
export declare const OUTPUT_PILL_H = 20;
|
|
8
|
+
/**
|
|
9
|
+
* Vertical space consumed by one output row: pill height + gap below it.
|
|
10
|
+
* The bottom-padding of the last row is baked into getBlockHeight, not here.
|
|
11
|
+
*/
|
|
12
|
+
export declare const OUTPUT_ROW_H = 26;
|
|
13
|
+
/** Types whose shape already communicates the type; no text label needed. */
|
|
14
|
+
export declare const PRIMITIVE_TYPES: Set<string>;
|
|
15
|
+
export interface SocketInfo {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
w: number;
|
|
19
|
+
h: number;
|
|
20
|
+
type: ParamType;
|
|
21
|
+
index: number;
|
|
22
|
+
}
|
|
23
|
+
/** Minimum pill width based on label text only (type is implicit in the query block itself). */
|
|
24
|
+
export declare function getPillWidth(name: string): number;
|
|
25
|
+
/** Width of a block, accounting for embedded query blocks in param slots */
|
|
26
|
+
export declare function getBlockWidth(def: BlockDefinition, paramSlots?: ParamSlot[], allBlocks?: Map<string, PlacedBlock>): number;
|
|
27
|
+
export declare function getBlockHeight(def: BlockDefinition): number;
|
|
28
|
+
/** Socket positions relative to block (x, y) */
|
|
29
|
+
export declare function getSocketPositions(def: BlockDefinition, paramSlots?: ParamSlot[], allBlocks?: Map<string, PlacedBlock>): SocketInfo[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ParamType } from '../types';
|
|
2
|
+
export declare function commandBlockPath(w: number, h: number): string;
|
|
3
|
+
export declare function hatBlockPath(w: number, h: number): string;
|
|
4
|
+
export declare function numberQueryPath(w: number, h: number): string;
|
|
5
|
+
export declare function boolQueryPath(w: number, h: number): string;
|
|
6
|
+
export declare function stringQueryPath(w: number, h: number): string;
|
|
7
|
+
export declare function objectQueryPath(w: number, h: number): string;
|
|
8
|
+
export declare function queryBlockPath(returnType: ParamType, w: number, h: number): string;
|
|
9
|
+
export declare function socketPath(paramType: ParamType, w: number, h: number): string;
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tvolden/block-code-editor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/block-editor.cjs",
|
|
6
|
+
"module": "./dist/block-editor.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/block-editor.js",
|
|
12
|
+
"require": "./dist/block-editor.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "vite",
|
|
20
|
+
"build": "vite build --config vite.lib.config.ts && tsc --project tsconfig.lib.json",
|
|
21
|
+
"build:app": "tsc -b && vite build",
|
|
22
|
+
"build:embed": "tsc -b && vite build --config vite.embed.config.ts",
|
|
23
|
+
"lint": "eslint .",
|
|
24
|
+
"preview": "vite preview"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": "^19.0.0",
|
|
28
|
+
"react-dom": "^19.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@eslint/js": "^9.39.1",
|
|
32
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
33
|
+
"@types/node": "^24.10.1",
|
|
34
|
+
"@types/react": "^19.2.7",
|
|
35
|
+
"@types/react-dom": "^19.2.3",
|
|
36
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
37
|
+
"eslint": "^9.0.0",
|
|
38
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
39
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
40
|
+
"globals": "^16.5.0",
|
|
41
|
+
"react": "^19.2.0",
|
|
42
|
+
"react-dom": "^19.2.0",
|
|
43
|
+
"tailwindcss": "^4.1.18",
|
|
44
|
+
"typescript": "~5.9.3",
|
|
45
|
+
"typescript-eslint": "^8.48.0",
|
|
46
|
+
"vite": "^7.3.1"
|
|
47
|
+
}
|
|
48
|
+
}
|