@neta-art/cohub 9.0.1 → 11.0.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/README.md +108 -102
- package/dist/board/editor/align.d.ts +11 -0
- package/dist/board/editor/align.js +72 -0
- package/dist/board/editor/animation.d.ts +17 -0
- package/dist/board/editor/animation.js +187 -0
- package/dist/board/editor/camera.d.ts +32 -0
- package/dist/board/editor/camera.js +137 -0
- package/dist/board/editor/clipboard.d.ts +41 -0
- package/dist/board/editor/clipboard.js +129 -0
- package/dist/board/editor/connection-ports.d.ts +19 -0
- package/dist/board/editor/connection-ports.js +85 -0
- package/dist/board/editor/context.d.ts +111 -0
- package/dist/board/editor/context.js +30 -0
- package/dist/board/editor/copy.d.ts +17 -0
- package/dist/board/editor/copy.js +121 -0
- package/dist/board/editor/creation.d.ts +51 -0
- package/dist/board/editor/creation.js +225 -0
- package/dist/board/editor/deletion.d.ts +9 -0
- package/dist/board/editor/deletion.js +90 -0
- package/dist/board/editor/document-edits.d.ts +22 -0
- package/dist/board/editor/document-edits.js +193 -0
- package/dist/board/editor/document.d.ts +41 -0
- package/dist/board/editor/document.js +302 -0
- package/dist/board/editor/editor.d.ts +225 -0
- package/dist/board/editor/editor.js +439 -0
- package/dist/board/editor/index.d.ts +18 -0
- package/dist/board/editor/index.js +12 -0
- package/dist/board/editor/interaction.d.ts +115 -0
- package/dist/board/editor/interaction.js +584 -0
- package/dist/board/editor/query.d.ts +27 -0
- package/dist/board/editor/query.js +203 -0
- package/dist/board/editor/remote.d.ts +11 -0
- package/dist/board/editor/remote.js +55 -0
- package/dist/board/editor/selection-transform.d.ts +24 -0
- package/dist/board/editor/selection-transform.js +81 -0
- package/dist/board/editor/selection.d.ts +33 -0
- package/dist/board/editor/selection.js +197 -0
- package/dist/board/editor/snapping.d.ts +33 -0
- package/dist/board/editor/snapping.js +75 -0
- package/dist/board/editor/snapshots.d.ts +27 -0
- package/dist/board/editor/snapshots.js +132 -0
- package/dist/board/editor/spatial.d.ts +41 -0
- package/dist/board/editor/spatial.js +191 -0
- package/dist/board/editor/state.d.ts +12 -0
- package/dist/board/editor/state.js +49 -0
- package/dist/board/editor/tool.d.ts +10 -0
- package/dist/board/editor/tool.js +19 -0
- package/dist/board/editor/wheel.d.ts +5 -0
- package/dist/board/editor/wheel.js +17 -0
- package/dist/board/export/index.d.ts +28 -6
- package/dist/board/export/index.js +47 -13
- package/dist/board/export/node/index.d.ts +56 -0
- package/dist/board/{headless → export/node}/index.js +26 -21
- package/dist/board/export/node/scripts.d.ts +16 -0
- package/dist/board/export/node/scripts.js +258 -0
- package/dist/board/export/scene.d.ts +8 -5
- package/dist/board/export/scene.js +24 -9
- package/dist/board/{animation.d.ts → model/animation.d.ts} +8 -5
- package/dist/board/{animation.js → model/animation.js} +37 -10
- package/dist/board/{core → model}/arrow-geometry.d.ts +2 -2
- package/dist/board/{core → model}/arrow-geometry.js +2 -2
- package/dist/board/model/authoring.d.ts +20 -0
- package/dist/board/model/authoring.js +185 -0
- package/dist/board/{core → model}/draw-geometry.d.ts +2 -2
- package/dist/board/{core → model}/draw-geometry.js +1 -1
- package/dist/board/model/draw-input.d.ts +14 -0
- package/dist/board/model/draw-input.js +28 -0
- package/dist/board/{core → model}/export-assets.d.ts +1 -1
- package/dist/board/{core → model}/export-assets.js +1 -1
- package/dist/board/{core → model}/export-plan.d.ts +2 -2
- package/dist/board/{core → model}/export-plan.js +3 -2
- package/dist/board/{core → model}/file-preview.d.ts +1 -1
- package/dist/board/{core → model}/file-preview.js +2 -2
- package/dist/board/{core → model}/file-snapshot.d.ts +1 -1
- package/dist/board/{core → model}/file-snapshot.js +4 -3
- package/dist/board/{geometry.d.ts → model/geometry.d.ts} +3 -3
- package/dist/board/{geometry.js → model/geometry.js} +1 -1
- package/dist/board/{image-key.d.ts → model/image-key.d.ts} +2 -2
- package/dist/board/{image-key.js → model/image-key.js} +7 -3
- package/dist/board/model/index.d.ts +42 -0
- package/dist/board/model/index.js +39 -0
- package/dist/board/model/items/builtin.d.ts +5 -0
- package/dist/board/model/items/builtin.js +119 -0
- package/dist/board/model/items/create.d.ts +61 -0
- package/dist/board/model/items/create.js +272 -0
- package/dist/board/model/items/definition.d.ts +35 -0
- package/dist/board/model/items/definition.js +18 -0
- package/dist/board/model/items/id.d.ts +5 -0
- package/dist/board/model/items/id.js +11 -0
- package/dist/board/model/items/index.d.ts +6 -0
- package/dist/board/model/items/index.js +6 -0
- package/dist/board/model/items/registry.d.ts +35 -0
- package/dist/board/model/items/registry.js +84 -0
- package/dist/board/{media-playback.d.ts → model/media-playback.d.ts} +4 -3
- package/dist/board/{media-playback.js → model/media-playback.js} +15 -5
- package/dist/board/{media.d.ts → model/media.d.ts} +1 -1
- package/dist/board/{media.js → model/media.js} +8 -2
- package/dist/board/{core → model}/palette.d.ts +1 -1
- package/dist/board/{core → model}/palette.js +1 -1
- package/dist/board/{presets.d.ts → model/presets.d.ts} +3 -3
- package/dist/board/{presets.js → model/presets.js} +1 -1
- package/dist/board/{replay.d.ts → model/replay.d.ts} +5 -5
- package/dist/board/{replay.js → model/replay.js} +2 -2
- package/dist/board/model/sampling.d.ts +19 -0
- package/dist/board/model/sampling.js +96 -0
- package/dist/board/{core → model}/scene.d.ts +1 -1
- package/dist/board/{core → model}/scene.js +1 -1
- package/dist/board/model/script-example.d.ts +4 -0
- package/dist/board/model/script-example.js +21 -0
- package/dist/board/model/script-hit.d.ts +10 -0
- package/dist/board/model/script-hit.js +52 -0
- package/dist/board/model/script-index.d.ts +7 -0
- package/dist/board/model/script-index.js +15 -0
- package/dist/board/model/script-scene.d.ts +24 -0
- package/dist/board/model/script-scene.js +267 -0
- package/dist/board/model/script.d.ts +105 -0
- package/dist/board/model/script.js +1 -0
- package/dist/board/model/shape-types.d.ts +8 -0
- package/dist/board/model/shape-types.js +8 -0
- package/dist/board/{task.d.ts → model/task.d.ts} +4 -4
- package/dist/board/{task.js → model/task.js} +3 -3
- package/dist/board/{core → model}/text-metrics.d.ts +1 -1
- package/dist/board/{core → model}/text-metrics.js +1 -1
- package/dist/board/{core → model}/tool-styles.d.ts +1 -1
- package/dist/board/{core → model}/tool-styles.js +1 -1
- package/dist/board/{runtime/board-player.d.ts → player/index.d.ts} +2 -2
- package/dist/board/{runtime/board-player.js → player/index.js} +5 -4
- package/dist/board/render/board-background.d.ts +1 -1
- package/dist/board/render/clip.d.ts +1 -1
- package/dist/board/render/css-color.d.ts +6 -1
- package/dist/board/render/css-color.js +34 -20
- package/dist/board/render/diagnostics.d.ts +20 -0
- package/dist/board/render/diagnostics.js +117 -0
- package/dist/board/render/index.d.ts +9 -6
- package/dist/board/render/index.js +10 -7
- package/dist/board/render/media-interaction.d.ts +2 -2
- package/dist/board/render/media-interaction.js +1 -1
- package/dist/board/render/palette.d.ts +3 -2
- package/dist/board/render/palette.js +7 -3
- package/dist/board/render/renderers/arrow-card-renderer.js +4 -3
- package/dist/board/render/renderers/audio-card-renderer.js +2 -1
- package/dist/board/render/renderers/board-renderer-registry.d.ts +20 -10
- package/dist/board/render/renderers/board-renderer-registry.js +17 -17
- package/dist/board/render/renderers/custom-card-renderer.d.ts +5 -0
- package/dist/board/render/renderers/{sketch-card-renderer.js → custom-card-renderer.js} +16 -15
- package/dist/board/render/renderers/draw-card-renderer.js +4 -3
- package/dist/board/render/renderers/effect-card-renderer.js +22 -5
- package/dist/board/render/renderers/far-plate.js +1 -1
- package/dist/board/render/renderers/file-card-renderer.d.ts +1 -1
- package/dist/board/render/renderers/file-card-renderer.js +2 -2
- package/dist/board/render/renderers/frame-card-renderer.js +30 -14
- package/dist/board/render/renderers/image-card-renderer.d.ts +1 -1
- package/dist/board/render/renderers/image-card-renderer.js +43 -4
- package/dist/board/render/renderers/shape-card-renderer.js +11 -28
- package/dist/board/render/renderers/task-card-renderer.js +1 -1
- package/dist/board/render/renderers/text-card-renderer.js +6 -4
- package/dist/board/render/renderers/unknown-card-renderer.js +1 -0
- package/dist/board/render/renderers/video-card-renderer.d.ts +1 -1
- package/dist/board/render/renderers/video-card-renderer.js +2 -1
- package/dist/board/render/sampling.d.ts +22 -0
- package/dist/board/render/sampling.js +21 -0
- package/dist/board/render/script-export.d.ts +11 -0
- package/dist/board/render/script-export.js +86 -0
- package/dist/board/render/script-host.d.ts +31 -0
- package/dist/board/render/script-host.js +421 -0
- package/dist/board/render/script-modules.d.ts +2 -0
- package/dist/board/render/script-modules.js +2 -0
- package/dist/board/render/script-runtime.d.ts +29 -0
- package/dist/board/render/script-runtime.js +213 -0
- package/dist/board/render/script-sandbox.d.ts +4 -0
- package/dist/board/render/script-sandbox.js +173 -0
- package/dist/board/render/stroke.d.ts +3 -2
- package/dist/board/render/stroke.js +23 -2
- package/dist/board/render/text-measurement.js +2 -2
- package/dist/board/replica/index.d.ts +70 -0
- package/dist/board/replica/index.js +276 -0
- package/dist/board/stage/assets.d.ts +41 -0
- package/dist/board/stage/assets.js +355 -0
- package/dist/board/stage/index.d.ts +8 -0
- package/dist/board/stage/index.js +8 -0
- package/dist/board/stage/lru.d.ts +32 -0
- package/dist/board/stage/lru.js +29 -0
- package/dist/board/stage/maintenance.d.ts +5 -0
- package/dist/board/stage/maintenance.js +11 -0
- package/dist/board/stage/pointer.d.ts +8 -0
- package/dist/board/stage/pointer.js +33 -0
- package/dist/board/stage/scene.d.ts +85 -0
- package/dist/board/stage/scene.js +515 -0
- package/dist/board/stage/script-pointer.d.ts +19 -0
- package/dist/board/stage/script-pointer.js +35 -0
- package/dist/board/stage/stage.d.ts +76 -0
- package/dist/board/stage/stage.js +774 -0
- package/dist/board/stage/texture-pool.d.ts +24 -0
- package/dist/board/stage/texture-pool.js +153 -0
- package/dist/board/stage/views.d.ts +38 -0
- package/dist/board/stage/views.js +93 -0
- package/dist/chunks/environment.d.ts +289 -23
- package/dist/chunks/host-bridge.d.ts +2 -2
- package/dist/chunks/http.d.ts +185 -71
- package/dist/chunks/http.js +368 -269
- package/dist/chunks/transport.js +3 -1
- package/dist/chunks/websocket.d.ts +9 -1
- package/dist/chunks/websocket.js +16 -2
- package/dist/host-bridge.js +2 -1
- package/dist/http.d.ts +2 -2
- package/dist/index.d.ts +182 -4
- package/dist/index.js +1393 -129
- package/dist/media.d.ts +1 -10
- package/dist/media.js +16 -27
- package/dist/protocol/dist/board-assets.d.ts +1 -0
- package/dist/protocol/dist/board-constants.js +2 -2
- package/dist/protocol/dist/board-model.d.ts +201 -11
- package/dist/protocol/dist/board-model.js +33 -14
- package/dist/protocol/dist/board-patch.js +3 -2
- package/dist/protocol/dist/board-schema.d.ts +4 -2
- package/dist/protocol/dist/board-schema.js +18 -4
- package/dist/protocol/dist/board-script-modules.d.ts +25 -0
- package/dist/protocol/dist/board-script-modules.js +127 -0
- package/dist/protocol/dist/board.d.ts +28 -2
- package/dist/protocol/dist/board.js +3 -1
- package/dist/protocol/dist/core/media.d.ts +5 -0
- package/dist/protocol/dist/core/media.js +39 -0
- package/dist/protocol/dist/display/index.d.ts +1 -0
- package/dist/protocol/dist/index.d.ts +7 -5
- package/dist/protocol/dist/realtime/types.d.ts +1 -0
- package/dist/protocol/dist/rtc/index.d.ts +1 -0
- package/dist/types.d.ts +1 -1
- package/package.json +21 -8
- package/dist/board/core/shape-definition.d.ts +0 -23
- package/dist/board/core/shape-definition.js +0 -45
- package/dist/board/core/shape-types.d.ts +0 -38
- package/dist/board/core/shape-types.js +0 -22
- package/dist/board/headless/index.d.ts +0 -55
- package/dist/board/headless/sketch.d.ts +0 -19
- package/dist/board/headless/sketch.js +0 -146
- package/dist/board/index.d.ts +0 -30
- package/dist/board/index.js +0 -29
- package/dist/board/render/renderers/sketch-card-renderer.d.ts +0 -5
- package/dist/board/render/sketch-host.d.ts +0 -14
- package/dist/board/render/sketch-host.js +0 -216
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BOARD_CAMERA_TARGET, BoardAnimationHeaderSchema, BoardColorSchema, BoardPatchSchema, BoardSettingsSchema, BoardTrackSchema, BoardVec2Schema, boardItemSchema, isBuiltinItemType, parseBoardItem } from "./board-model.js";
|
|
2
|
-
import { boardJsonEquals } from "./board-json.js";
|
|
3
2
|
import { applyMatrix, arrowBindings, createBoardLayout, invertMatrix, isArrowBinding } from "./board-layout.js";
|
|
3
|
+
import { boardJsonEquals } from "./board-json.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
//#region ../protocol/dist/board-patch.js
|
|
6
6
|
function slot(map, key) {
|
|
@@ -82,7 +82,8 @@ const NOT_ANIMATABLE = /* @__PURE__ */ new Set([
|
|
|
82
82
|
"parent",
|
|
83
83
|
"z",
|
|
84
84
|
"locked",
|
|
85
|
-
"metadata"
|
|
85
|
+
"metadata",
|
|
86
|
+
"script"
|
|
86
87
|
]);
|
|
87
88
|
const CAMERA_PROPERTIES = {
|
|
88
89
|
focus: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region ../protocol/dist/board-schema.d.ts
|
|
2
2
|
type JsonSchema = Record<string, unknown>;
|
|
3
|
-
declare const BOARD_SCHEMA_TARGETS: readonly ["board", "animation", "track", "camera", ...("arrow" | "audio" | "draw" | "effect" | "file" | "frame" | "image" | "shape" | "
|
|
3
|
+
declare const BOARD_SCHEMA_TARGETS: readonly ["board", "animation", "track", "camera", ...("arrow" | "audio" | "custom" | "draw" | "effect" | "file" | "frame" | "image" | "shape" | "task" | "text" | "video")[]];
|
|
4
4
|
type BoardJsonSchemaResult = {
|
|
5
5
|
schema?: JsonSchema;
|
|
6
6
|
properties?: Array<{
|
|
@@ -11,6 +11,7 @@ type BoardJsonSchemaResult = {
|
|
|
11
11
|
description: string;
|
|
12
12
|
parameters: Record<string, string>;
|
|
13
13
|
}>;
|
|
14
|
+
semantics?: Record<string, string>;
|
|
14
15
|
};
|
|
15
16
|
declare function boardJsonSchema(target: string): BoardJsonSchemaResult | null;
|
|
16
17
|
declare function boardSchemaOverview(): {
|
|
@@ -19,7 +20,8 @@ declare function boardSchemaOverview(): {
|
|
|
19
20
|
rotation: string;
|
|
20
21
|
length: string;
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
+
coordinates: string;
|
|
24
|
+
types: ("arrow" | "audio" | "custom" | "draw" | "effect" | "file" | "frame" | "image" | "shape" | "task" | "text" | "video")[];
|
|
23
25
|
colors: {
|
|
24
26
|
tokens: readonly ["brand", "neutral", "black", "white", "blue", "green", "amber", "violet", "rose"];
|
|
25
27
|
css: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BOARD_CAMERA_TARGET, BOARD_COLOR_TOKENS, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BoardAnimationHeaderSchema, BoardSettingsSchema, BoardTrackSchema, isBuiltinItemType } from "./board-model.js";
|
|
1
|
+
import { BOARD_CAMERA_TARGET, BOARD_COLOR_TOKENS, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BoardAnimationHeaderSchema, BoardKeySchema, BoardSettingsSchema, BoardTrackSchema, isBuiltinItemType } from "./board-model.js";
|
|
2
2
|
import { listBoardProperties } from "./board-patch.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region ../protocol/dist/board-schema.js
|
|
@@ -19,13 +19,26 @@ const BOARD_SCHEMA_TARGETS = [
|
|
|
19
19
|
function boardJsonSchema(target) {
|
|
20
20
|
if (target === "board") return { schema: toJsonSchema(BoardSettingsSchema) };
|
|
21
21
|
if (target === "animation") return {
|
|
22
|
-
schema: toJsonSchema(BoardAnimationHeaderSchema.extend({ tracks: z.record(
|
|
23
|
-
properties: listBoardProperties("animation")
|
|
22
|
+
schema: toJsonSchema(BoardAnimationHeaderSchema.extend({ tracks: z.record(BoardKeySchema, BoardTrackSchema).optional() })),
|
|
23
|
+
properties: listBoardProperties("animation"),
|
|
24
|
+
semantics: { composition: "Target another animation's time property to drive its local clock. Parent markers control pauses; child markers are not automatically promoted." }
|
|
25
|
+
};
|
|
26
|
+
if (target === "track") return {
|
|
27
|
+
schema: toJsonSchema(BoardTrackSchema),
|
|
28
|
+
semantics: {
|
|
29
|
+
boundary: "Before the first keyframe and after the last, the value is held. Use opacity tracks to control visibility.",
|
|
30
|
+
easing: "Defaults to linear. The destination keyframe controls the incoming segment. Supports CSS easing keywords, cubic-bezier() and steps().",
|
|
31
|
+
composition: "replace: the most recently started track wins; ties use the lexicographically larger track ID. Before any start, the nearest upcoming track wins. add: numbers and positions add; opacity and scale multiply.",
|
|
32
|
+
interpolation: "auto interpolates numbers, colors and vectors; other values step. spline smooths vector motion. orient follows the position tangent."
|
|
33
|
+
}
|
|
24
34
|
};
|
|
25
|
-
if (target === "track") return { schema: toJsonSchema(BoardTrackSchema) };
|
|
26
35
|
if (target === "effect") return {
|
|
27
36
|
schema: toJsonSchema(BOARD_ITEM_SCHEMAS.effect),
|
|
28
37
|
properties: listBoardProperties("effect"),
|
|
38
|
+
semantics: {
|
|
39
|
+
follow: "follow is used by trail only. Parent a particle effect to a decoration:none frame to move it with other items.",
|
|
40
|
+
time: "Effects use animation time in milliseconds. trail samples target history; seed makes procedural particles repeatable."
|
|
41
|
+
},
|
|
29
42
|
kinds: Object.fromEntries(BOARD_EFFECT_KINDS.map((kind) => [kind, BOARD_EFFECT_KIND_INFO[kind]]))
|
|
30
43
|
};
|
|
31
44
|
if (target === "camera") return { properties: listBoardProperties(BOARD_CAMERA_TARGET) };
|
|
@@ -42,6 +55,7 @@ function boardSchemaOverview() {
|
|
|
42
55
|
rotation: "degrees",
|
|
43
56
|
length: "board units (1 = 1 CSS px at zoom 1)"
|
|
44
57
|
},
|
|
58
|
+
coordinates: "Positions, draw points and unbound arrow endpoints are relative to their parent frame; without a parent they are world coordinates. Shape paths are fitted to the item size.",
|
|
45
59
|
types: BOARD_ITEM_TYPES,
|
|
46
60
|
colors: {
|
|
47
61
|
tokens: BOARD_COLOR_TOKENS,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region ../protocol/dist/board-script-modules.d.ts
|
|
2
|
+
declare const BOARD_SCRIPT_MAX_BYTES = 2000000;
|
|
3
|
+
type BoardScriptSource = {
|
|
4
|
+
code: string;
|
|
5
|
+
imports: Array<{
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
path: string;
|
|
9
|
+
dynamic: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
type BoardScriptSources = Record<string, BoardScriptSource>;
|
|
13
|
+
declare function createBoardScriptModuleReader(read: (path: string) => Promise<string>, timeoutMs?: number): {
|
|
14
|
+
read(path: string): Promise<string>;
|
|
15
|
+
invalidate(path?: string): void;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
};
|
|
18
|
+
declare function resolveScriptImport(from: string, specifier: string): string;
|
|
19
|
+
declare function loadBoardScriptSources(src: string, read: (path: string) => Promise<string>, timeoutMs?: number): Promise<BoardScriptSources>;
|
|
20
|
+
declare function scriptModuleUrls(sources: BoardScriptSources): {
|
|
21
|
+
urls: Record<string, string>;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { BOARD_SCRIPT_MAX_BYTES, BoardScriptSource, BoardScriptSources, createBoardScriptModuleReader, loadBoardScriptSources, resolveScriptImport, scriptModuleUrls };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { isSafeBoardSourcePath } from "./board-model.js";
|
|
2
|
+
//#region ../protocol/dist/board-script-modules.js
|
|
3
|
+
const BOARD_SCRIPT_MAX_BYTES = 2e6;
|
|
4
|
+
function createBoardScriptModuleReader(read, timeoutMs = 15e3) {
|
|
5
|
+
const cache = /* @__PURE__ */ new Map();
|
|
6
|
+
const queue = [];
|
|
7
|
+
let active = 0;
|
|
8
|
+
let disposed = false;
|
|
9
|
+
function pump() {
|
|
10
|
+
while (active < 4 && queue.length) queue.shift()?.();
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
read(path) {
|
|
14
|
+
if (disposed) return Promise.reject(/* @__PURE__ */ new Error("Module reader is disposed."));
|
|
15
|
+
const cached = cache.get(path);
|
|
16
|
+
if (cached) return cached;
|
|
17
|
+
const promise = new Promise((resolve, reject) => {
|
|
18
|
+
queue.push(() => {
|
|
19
|
+
if (disposed) {
|
|
20
|
+
reject(/* @__PURE__ */ new Error("Module reader is disposed."));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
active++;
|
|
24
|
+
let timer;
|
|
25
|
+
const timeout = new Promise((_resolve, rejectRead) => {
|
|
26
|
+
timer = setTimeout(() => rejectRead(/* @__PURE__ */ new Error(`Module read timed out: ${path}`)), timeoutMs);
|
|
27
|
+
});
|
|
28
|
+
Promise.race([Promise.resolve().then(() => read(path)), timeout]).then(resolve, reject).finally(() => {
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
active--;
|
|
31
|
+
pump();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
pump();
|
|
35
|
+
});
|
|
36
|
+
cache.set(path, promise);
|
|
37
|
+
promise.catch(() => {
|
|
38
|
+
if (cache.get(path) === promise) cache.delete(path);
|
|
39
|
+
});
|
|
40
|
+
return promise;
|
|
41
|
+
},
|
|
42
|
+
invalidate(path) {
|
|
43
|
+
if (path) cache.delete(path);
|
|
44
|
+
else cache.clear();
|
|
45
|
+
},
|
|
46
|
+
destroy() {
|
|
47
|
+
disposed = true;
|
|
48
|
+
cache.clear();
|
|
49
|
+
for (const job of queue.splice(0)) job();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function resolveScriptImport(from, specifier) {
|
|
54
|
+
if (!specifier.startsWith("./") && !specifier.startsWith("../")) throw new Error(`Only relative module imports are supported: ${specifier}`);
|
|
55
|
+
const parts = from.split("/").slice(0, -1);
|
|
56
|
+
for (const part of specifier.split("/")) {
|
|
57
|
+
if (part === ".") continue;
|
|
58
|
+
if (part === "..") {
|
|
59
|
+
if (!parts.length) throw new Error("Module import leaves the Space.");
|
|
60
|
+
parts.pop();
|
|
61
|
+
} else parts.push(part);
|
|
62
|
+
}
|
|
63
|
+
const path = parts.join("/");
|
|
64
|
+
if (!isSafeBoardSourcePath(path) || !/\.m?js$/.test(path)) throw new Error(`Invalid module path: ${path}`);
|
|
65
|
+
return path;
|
|
66
|
+
}
|
|
67
|
+
async function loadBoardScriptSources(src, read, timeoutMs = 15e3) {
|
|
68
|
+
if (!isSafeBoardSourcePath(src) || !/\.m?js$/.test(src)) throw new Error("Invalid script entry path.");
|
|
69
|
+
const { init, parse } = await import("es-module-lexer");
|
|
70
|
+
await init;
|
|
71
|
+
const sources = {};
|
|
72
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
73
|
+
let bytes = 0;
|
|
74
|
+
async function visit(path) {
|
|
75
|
+
if (visiting.has(path)) throw new Error(`Circular module dependency: ${path}`);
|
|
76
|
+
if (sources[path]) return;
|
|
77
|
+
if (Object.keys(sources).length + visiting.size >= 64) throw new Error("A script may load at most 64 modules.");
|
|
78
|
+
visiting.add(path);
|
|
79
|
+
let timer;
|
|
80
|
+
const code = await Promise.race([Promise.resolve().then(() => read(path)), new Promise((_resolve, reject) => {
|
|
81
|
+
timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Module read timed out: ${path}`)), timeoutMs);
|
|
82
|
+
})]).finally(() => clearTimeout(timer));
|
|
83
|
+
bytes += new TextEncoder().encode(code).byteLength;
|
|
84
|
+
if (bytes > 2e6) throw new Error("Script modules exceed the 2 MB limit.");
|
|
85
|
+
const [imports] = parse(code, path);
|
|
86
|
+
const resolved = [];
|
|
87
|
+
for (const entry of imports) {
|
|
88
|
+
if (entry.d === -2) throw new Error("import.meta is not available in Board scripts.");
|
|
89
|
+
if (entry.n === void 0) throw new Error("Dynamic imports must use a literal relative path.");
|
|
90
|
+
const dependency = resolveScriptImport(path, entry.n);
|
|
91
|
+
await visit(dependency);
|
|
92
|
+
resolved.push({
|
|
93
|
+
start: entry.s,
|
|
94
|
+
end: entry.e,
|
|
95
|
+
path: dependency,
|
|
96
|
+
dynamic: entry.d >= 0
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
sources[path] = {
|
|
100
|
+
code,
|
|
101
|
+
imports: resolved
|
|
102
|
+
};
|
|
103
|
+
visiting.delete(path);
|
|
104
|
+
}
|
|
105
|
+
await visit(src);
|
|
106
|
+
return sources;
|
|
107
|
+
}
|
|
108
|
+
function scriptModuleUrls(sources) {
|
|
109
|
+
const urls = {};
|
|
110
|
+
for (const [path, source] of Object.entries(sources)) {
|
|
111
|
+
let code = source.code;
|
|
112
|
+
for (const entry of [...source.imports].reverse()) {
|
|
113
|
+
const url = urls[entry.path];
|
|
114
|
+
if (!url) throw new Error(`Unresolved module: ${entry.path}`);
|
|
115
|
+
code = code.slice(0, entry.start) + (entry.dynamic ? JSON.stringify(url) : url) + code.slice(entry.end);
|
|
116
|
+
}
|
|
117
|
+
urls[path] = URL.createObjectURL(new Blob([`${code}\n//# sourceURL=cohub-script/${path.split("/").map(encodeURIComponent).join("/")}`], { type: "text/javascript" }));
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
urls,
|
|
121
|
+
dispose: () => {
|
|
122
|
+
for (const url of Object.values(urls)) URL.revokeObjectURL(url);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { BOARD_SCRIPT_MAX_BYTES, createBoardScriptModuleReader, loadBoardScriptSources, resolveScriptImport, scriptModuleUrls };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { BoardDelta, BoardPatch } from "./board-model.js";
|
|
1
|
+
import { BoardDelta, BoardDiagnostic, BoardPatch } from "./board-model.js";
|
|
2
2
|
import { RequestSource } from "./provenance.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region ../protocol/dist/board.d.ts
|
|
5
|
+
declare const BOARD_CLIPBOARD_KIND: "cohub.board.clipboard";
|
|
6
|
+
declare const BOARD_CLIPBOARD_MIME: "application/x-cohub-board";
|
|
5
7
|
declare const BoardManifestSchema: z.ZodObject<{
|
|
6
8
|
kind: z.ZodLiteral<"cohub.board.manifest">;
|
|
7
9
|
version: z.ZodLiteral<1>;
|
|
@@ -12,6 +14,30 @@ type BoardManifest = z.infer<typeof BoardManifestSchema>;
|
|
|
12
14
|
declare function parseBoardManifest(input: string | unknown): BoardManifest;
|
|
13
15
|
declare function serializeBoardManifest(manifest: BoardManifest): string;
|
|
14
16
|
declare function isBoardPath(path: string): boolean;
|
|
17
|
+
type BoardReadResult = {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
version: number;
|
|
21
|
+
updatedAt: string | null;
|
|
22
|
+
board: Record<string, unknown>;
|
|
23
|
+
items?: Record<string, Record<string, unknown>>;
|
|
24
|
+
animations?: Record<string, Record<string, unknown>>;
|
|
25
|
+
playback: BoardPlaybackSnapshot | null;
|
|
26
|
+
next?: string;
|
|
27
|
+
};
|
|
28
|
+
type BoardChangeSummary = {
|
|
29
|
+
board: boolean;
|
|
30
|
+
items: string[];
|
|
31
|
+
animations: string[];
|
|
32
|
+
};
|
|
33
|
+
type BoardApplyResult = {
|
|
34
|
+
mutationId: string;
|
|
35
|
+
status: "applied" | "unchanged" | "validated";
|
|
36
|
+
replayed: boolean;
|
|
37
|
+
version: number;
|
|
38
|
+
changed: BoardChangeSummary;
|
|
39
|
+
diagnostics: BoardDiagnostic[];
|
|
40
|
+
};
|
|
15
41
|
type BoardTransactionRecord = {
|
|
16
42
|
id: string;
|
|
17
43
|
mutationId: string;
|
|
@@ -68,4 +94,4 @@ declare const BoardPlaybackCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
68
94
|
}, z.core.$strict>], "type">;
|
|
69
95
|
type BoardPlaybackCommand = z.infer<typeof BoardPlaybackCommandSchema>;
|
|
70
96
|
//#endregion
|
|
71
|
-
export { BoardHistoryPage, BoardManifest, BoardManifestSchema, BoardPlaybackCommand, BoardPlaybackCommandSchema, BoardPlaybackSnapshot, BoardPlaybackStatus, BoardTransactionRecord, isBoardPath, parseBoardManifest, serializeBoardManifest };
|
|
97
|
+
export { BOARD_CLIPBOARD_KIND, BOARD_CLIPBOARD_MIME, BoardApplyResult, BoardChangeSummary, BoardHistoryPage, BoardManifest, BoardManifestSchema, type BoardPatch, BoardPlaybackCommand, BoardPlaybackCommandSchema, BoardPlaybackSnapshot, BoardPlaybackStatus, BoardReadResult, BoardTransactionRecord, isBoardPath, parseBoardManifest, serializeBoardManifest };
|
|
@@ -3,6 +3,8 @@ import { z } from "zod";
|
|
|
3
3
|
//#region ../protocol/dist/board.js
|
|
4
4
|
const BOARD_EXTENSION = ".board";
|
|
5
5
|
const BOARD_MANIFEST_KIND = "cohub.board.manifest";
|
|
6
|
+
const BOARD_CLIPBOARD_KIND = "cohub.board.clipboard";
|
|
7
|
+
const BOARD_CLIPBOARD_MIME = "application/x-cohub-board";
|
|
6
8
|
const BoardManifestSchema = z.object({
|
|
7
9
|
kind: z.literal(BOARD_MANIFEST_KIND),
|
|
8
10
|
version: z.literal(1),
|
|
@@ -104,4 +106,4 @@ z.discriminatedUnion("type", [
|
|
|
104
106
|
}).strict()
|
|
105
107
|
]);
|
|
106
108
|
//#endregion
|
|
107
|
-
export { BOARD_EXTENSION, BOARD_MANIFEST_KIND, BOARD_READ_SECTIONS, BoardManifestSchema, InvalidBoardFileError, isBoardPath, parseBoardManifest, serializeBoardManifest };
|
|
109
|
+
export { BOARD_CLIPBOARD_KIND, BOARD_CLIPBOARD_MIME, BOARD_EXTENSION, BOARD_MANIFEST_KIND, BOARD_READ_SECTIONS, BoardManifestSchema, InvalidBoardFileError, isBoardPath, parseBoardManifest, serializeBoardManifest };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region ../protocol/dist/core/media.js
|
|
2
|
+
const MEDIA_HOSTS = /* @__PURE__ */ new Map([
|
|
3
|
+
["router-files.neta.art", {
|
|
4
|
+
transform: "oss",
|
|
5
|
+
metaHeaders: true
|
|
6
|
+
}],
|
|
7
|
+
["public.cohub.live", { transform: "oss" }],
|
|
8
|
+
["cca.neta.art", { transform: "cloudflare" }]
|
|
9
|
+
]);
|
|
10
|
+
const parseHttpsUrl = (url) => {
|
|
11
|
+
if (!/^https:\/\//i.test(url)) return null;
|
|
12
|
+
try {
|
|
13
|
+
return new URL(url);
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function mediaHost(url) {
|
|
19
|
+
const parsed = parseHttpsUrl(url);
|
|
20
|
+
return parsed ? MEDIA_HOSTS.get(parsed.hostname) : void 0;
|
|
21
|
+
}
|
|
22
|
+
const OSS_PROCESS_PATTERN = /[?&]x-oss-process=/;
|
|
23
|
+
/** Append an OSS process to `url`, keeping its query and hash. */
|
|
24
|
+
function ossProcessUrl(url, process) {
|
|
25
|
+
if (/^(data|blob):/i.test(url) || OSS_PROCESS_PATTERN.test(url)) return url;
|
|
26
|
+
const hashIndex = url.indexOf("#");
|
|
27
|
+
const base = hashIndex >= 0 ? url.slice(0, hashIndex) : url;
|
|
28
|
+
const hash = hashIndex >= 0 ? url.slice(hashIndex) : "";
|
|
29
|
+
return `${base}${base.includes("?") ? "&" : "?"}x-oss-process=${process}${hash}`;
|
|
30
|
+
}
|
|
31
|
+
const MODEL_IMAGE = {
|
|
32
|
+
maxEdge: 1280,
|
|
33
|
+
quality: 75
|
|
34
|
+
};
|
|
35
|
+
const { maxEdge, quality } = MODEL_IMAGE;
|
|
36
|
+
`${maxEdge}${maxEdge}${quality}`;
|
|
37
|
+
`${maxEdge}${maxEdge}${quality}`;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { MODEL_IMAGE, OSS_PROCESS_PATTERN, mediaHost, ossProcessUrl };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import { BOARD_ANCHOR_SIDES, BOARD_ARROW_ROUTES, BOARD_CAMERA_TARGET, BOARD_COLOR_TOKENS, BOARD_DASHES, BOARD_DERIVED_SIZE_TYPES, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ENTER_PRESETS, BOARD_EXTENSION_TYPE_PATTERN, BOARD_GRID_DEFAULT_SIZE, BOARD_GRID_MAX_SIZE, BOARD_GRID_MIN_SIZE, BOARD_ID_MAX_LENGTH, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BOARD_PLAY_MODES, BOARD_SHAPE_GEOMETRIES, BOARD_TASK_ARTIFACT_LIMIT, BOARD_TEXT_ALIGNS, BoardAnchorSide, BoardAnimation, BoardAnimationHeader, BoardAnimationHeaderSchema, BoardAnimationSchema, BoardArrowAnchor, BoardArrowAnchorSchema, BoardArrowBinding, BoardArrowBindingSchema, BoardArrowEnd, BoardArrowEndSchema, BoardArrowItem, BoardArrowItemSchema, BoardArrowRoute, BoardAudioItem, BoardAudioItemSchema, BoardBackgroundSchema, BoardBuiltinItem, BoardBuiltinItemType, BoardColor, BoardColorSchema, BoardColorToken, BoardCropSchema, BoardCustomItem, BoardCustomItemSchema, BoardDash, BoardDelta, BoardDiagnostic, BoardDocument, BoardDrawItem, BoardDrawItemSchema, BoardDrawPoint, BoardDrawPointSchema, BoardEaseSchema, BoardEffectItem, BoardEffectItemSchema, BoardEffectKind, BoardEnterPreset, BoardExtensionItem, BoardExtensionItemSchema, BoardFileBackedItem, BoardFileItem, BoardFileItemSchema, BoardFrameItem, BoardFrameItemSchema, BoardIdSchema, BoardImageItem, BoardImageItemSchema, BoardItem, BoardItemType, BoardKeySchema, BoardKeyframe, BoardKeyframeSchema, BoardMarker, BoardMarkerSchema, BoardMediaSnapshot, BoardMediaSnapshotSchema, BoardMediaSource, BoardMediaSourceSchema, BoardPatch, BoardPatchSchema, BoardPlayMode, BoardScript, BoardScriptSchema, BoardSettings, BoardSettingsSchema, BoardShapeGeometry, BoardShapeItem, BoardShapeItemSchema, BoardSize, BoardSizeSchema, BoardStyle, BoardStyleSchema, BoardTaskArtifact, BoardTaskArtifactSchema, BoardTaskItem, BoardTaskItemSchema, BoardTaskSnapshot, BoardTaskSnapshotSchema, BoardTextItem, BoardTextItemSchema, BoardTrack, BoardTrackSchema, BoardVec2, BoardVec2Schema, BoardVideoItem, BoardVideoItemSchema, boardItemSchema, emptyBoardDocument, hasAuthoredSize, isBoardColorString, isBoardEase, isBuiltinItem, isBuiltinItemType, isEmptyBoardDelta, isFileBackedItem, isMediaItem, isSafeBoardSourcePath, parseBoardItem, parseBoardMediaSource } from "./board-model.js";
|
|
2
|
+
import { BoardFrame, BoardItemLookup, BoardLayout, BoardMatrix, BoardRect, BoardTextLayout, BoardTextMeasurer, IDENTITY_MATRIX, anchorPoint, applyMatrix, arrowBindings, autoAnchorSide, bendControl, clampBoardFontSize, createBoardLayout, createDocumentLayout, drawPointsBounds, drawSampleRadius, estimateTextWidth, framePoint, invertMatrix, isArrowBinding, layoutBoardText, multiplyMatrix, pointsRect, rotateAround, scaleVector, setBoardTextMeasurer, sideAnchor } from "./board-layout.js";
|
|
3
|
+
import { BoardApplyOptions, BoardPatchResult, BoardPropertySpec, BoardState, BoardValueKind, applyBoardDelta, applyBoardPatch, applyBoardPatchToDocument, boardPatchTouches, createDocumentState, diffBoardDocuments, diffMergePatch, isEmptyBoardPatch, listBoardProperties, mergePatch, parseBoardDocument, pruneBoardTrack, resolveBoardProperty, trackReferences } from "./board-patch.js";
|
|
1
4
|
import "./app-authorization.js";
|
|
2
|
-
import { BOARD_ANCHOR_SIDES, BOARD_ARROW_ROUTES, BOARD_CAMERA_TARGET, BOARD_COLOR_TOKENS, BOARD_DASHES, BOARD_DERIVED_SIZE_TYPES, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ENTER_PRESETS, BOARD_EXTENSION_TYPE_PATTERN, BOARD_GRID_DEFAULT_SIZE, BOARD_GRID_MAX_SIZE, BOARD_GRID_MIN_SIZE, BOARD_ID_MAX_LENGTH, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BOARD_PLAY_MODES, BOARD_SHAPE_GEOMETRIES, BOARD_TASK_ARTIFACT_LIMIT, BOARD_TEXT_ALIGNS, BoardAnchorSide, BoardAnimation, BoardAnimationHeader, BoardAnimationHeaderSchema, BoardAnimationSchema, BoardArrowAnchor, BoardArrowAnchorSchema, BoardArrowBinding, BoardArrowBindingSchema, BoardArrowEnd, BoardArrowEndSchema, BoardArrowItem, BoardArrowItemSchema, BoardArrowRoute, BoardAudioItem, BoardAudioItemSchema, BoardBackgroundSchema, BoardBuiltinItem, BoardBuiltinItemType, BoardColor, BoardColorSchema, BoardColorToken, BoardCropSchema, BoardDash, BoardDelta, BoardDiagnostic, BoardDocument, BoardDrawItem, BoardDrawItemSchema, BoardDrawPoint, BoardDrawPointSchema, BoardEaseSchema, BoardEffectItem, BoardEffectItemSchema, BoardEffectKind, BoardEnterPreset, BoardExtensionItem, BoardExtensionItemSchema, BoardFileBackedItem, BoardFileItem, BoardFileItemSchema, BoardFrameItem, BoardFrameItemSchema, BoardIdSchema, BoardImageItem, BoardImageItemSchema, BoardItem, BoardItemType, BoardKeyframe, BoardKeyframeSchema, BoardMarker, BoardMarkerSchema, BoardMediaSnapshot, BoardMediaSnapshotSchema, BoardPatch, BoardPatchSchema, BoardPlayMode, BoardSettings, BoardSettingsSchema, BoardShapeGeometry, BoardShapeItem, BoardShapeItemSchema, BoardSize, BoardSizeSchema, BoardSketchItem, BoardSketchItemSchema, BoardStyle, BoardStyleSchema, BoardTaskArtifact, BoardTaskArtifactSchema, BoardTaskItem, BoardTaskItemSchema, BoardTaskSnapshot, BoardTaskSnapshotSchema, BoardTextItem, BoardTextItemSchema, BoardTrack, BoardTrackSchema, BoardVec2, BoardVec2Schema, BoardVideoItem, BoardVideoItemSchema, boardItemSchema, emptyBoardDocument, hasAuthoredSize, isBoardColorString, isBoardEase, isBuiltinItem, isBuiltinItemType, isEmptyBoardDelta, isFileBackedItem, isMediaItem, isSafeBoardSourcePath, parseBoardItem } from "./board-model.js";
|
|
3
5
|
import { RequestSource, RequestSourceVia } from "./provenance.js";
|
|
4
|
-
import { BoardHistoryPage, BoardManifest, BoardManifestSchema, BoardPlaybackCommand, BoardPlaybackCommandSchema, BoardPlaybackSnapshot, BoardPlaybackStatus, BoardTransactionRecord, isBoardPath, parseBoardManifest, serializeBoardManifest } from "./board.js";
|
|
6
|
+
import { BOARD_CLIPBOARD_KIND, BOARD_CLIPBOARD_MIME, BoardApplyResult, BoardChangeSummary, BoardHistoryPage, BoardManifest, BoardManifestSchema, BoardPlaybackCommand, BoardPlaybackCommandSchema, BoardPlaybackSnapshot, BoardPlaybackStatus, BoardReadResult, BoardTransactionRecord, isBoardPath, parseBoardManifest, serializeBoardManifest } from "./board.js";
|
|
5
7
|
import { BOARD_STROKE_MAX_SIZE, BOARD_STROKE_MIN_SIZE, clampBoardStrokeSize } from "./board-constants.js";
|
|
6
8
|
import "./board-content.js";
|
|
7
|
-
import
|
|
8
|
-
import { BoardApplyOptions, BoardPatchResult, BoardPropertySpec, BoardState, BoardValueKind, applyBoardDelta, applyBoardPatch, applyBoardPatchToDocument, boardPatchTouches, createDocumentState, diffBoardDocuments, diffMergePatch, isEmptyBoardPatch, listBoardProperties, mergePatch, parseBoardDocument, pruneBoardTrack, resolveBoardProperty, trackReferences } from "./board-patch.js";
|
|
9
|
+
import "./board-assets.js";
|
|
9
10
|
import { BOARD_SCHEMA_TARGETS, BoardJsonSchemaResult, boardJsonSchema, boardSchemaOverview } from "./board-schema.js";
|
|
10
11
|
import "./board-upgrade.js";
|
|
11
12
|
import { isPublicBoardRemoteAddress, normalizeBoardRemoteUrl } from "./board-url.js";
|
|
13
|
+
import "./rtc/index.js";
|
|
12
14
|
import "./display/index.js";
|
|
13
15
|
import "./runtime/index.js";
|
|
14
16
|
import "./model/turn.js";
|
|
@@ -18,4 +20,4 @@ import "./app.js";
|
|
|
18
20
|
import "./realtime/types.js";
|
|
19
21
|
import "./app-catalog.js";
|
|
20
22
|
import "./host-bridge.js";
|
|
21
|
-
export { BOARD_ANCHOR_SIDES, BOARD_ARROW_ROUTES, BOARD_CAMERA_TARGET, BOARD_COLOR_TOKENS, BOARD_DASHES, BOARD_DERIVED_SIZE_TYPES, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ENTER_PRESETS, BOARD_EXTENSION_TYPE_PATTERN, BOARD_GRID_DEFAULT_SIZE, BOARD_GRID_MAX_SIZE, BOARD_GRID_MIN_SIZE, BOARD_ID_MAX_LENGTH, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BOARD_PLAY_MODES, BOARD_SCHEMA_TARGETS, BOARD_SHAPE_GEOMETRIES, BOARD_STROKE_MAX_SIZE, BOARD_STROKE_MIN_SIZE, BOARD_TASK_ARTIFACT_LIMIT, BOARD_TEXT_ALIGNS, BoardAnchorSide, BoardAnimation, BoardAnimationHeader, BoardAnimationHeaderSchema, BoardAnimationSchema, BoardApplyOptions, BoardArrowAnchor, BoardArrowAnchorSchema, BoardArrowBinding, BoardArrowBindingSchema, BoardArrowEnd, BoardArrowEndSchema, BoardArrowItem, BoardArrowItemSchema, BoardArrowRoute, BoardAudioItem, BoardAudioItemSchema, BoardBackgroundSchema, BoardBuiltinItem, BoardBuiltinItemType, BoardColor, BoardColorSchema, BoardColorToken, BoardCropSchema, BoardDash, BoardDelta, BoardDiagnostic, BoardDocument, BoardDrawItem, BoardDrawItemSchema, BoardDrawPoint, BoardDrawPointSchema, BoardEaseSchema, BoardEffectItem, BoardEffectItemSchema, BoardEffectKind, BoardEnterPreset, BoardExtensionItem, BoardExtensionItemSchema, BoardFileBackedItem, BoardFileItem, BoardFileItemSchema, BoardFrame, BoardFrameItem, BoardFrameItemSchema, BoardHistoryPage, BoardIdSchema, BoardImageItem, BoardImageItemSchema, BoardItem, BoardItemLookup, BoardItemType, BoardJsonSchemaResult, BoardKeyframe, BoardKeyframeSchema, BoardLayout, BoardManifest, BoardManifestSchema, BoardMarker, BoardMarkerSchema, BoardMatrix, BoardMediaSnapshot, BoardMediaSnapshotSchema, BoardPatchResult, BoardPatchSchema, BoardPlayMode, BoardPlaybackCommand, BoardPlaybackCommandSchema, BoardPlaybackSnapshot, BoardPlaybackStatus, BoardPropertySpec, BoardRect, BoardSettings, BoardSettingsSchema, BoardShapeGeometry, BoardShapeItem, BoardShapeItemSchema, BoardSize, BoardSizeSchema,
|
|
23
|
+
export { BOARD_ANCHOR_SIDES, BOARD_ARROW_ROUTES, BOARD_CAMERA_TARGET, BOARD_CLIPBOARD_KIND, BOARD_CLIPBOARD_MIME, BOARD_COLOR_TOKENS, BOARD_DASHES, BOARD_DERIVED_SIZE_TYPES, BOARD_EFFECT_KINDS, BOARD_EFFECT_KIND_INFO, BOARD_ENTER_PRESETS, BOARD_EXTENSION_TYPE_PATTERN, BOARD_GRID_DEFAULT_SIZE, BOARD_GRID_MAX_SIZE, BOARD_GRID_MIN_SIZE, BOARD_ID_MAX_LENGTH, BOARD_ITEM_SCHEMAS, BOARD_ITEM_TYPES, BOARD_PLAY_MODES, BOARD_SCHEMA_TARGETS, BOARD_SHAPE_GEOMETRIES, BOARD_STROKE_MAX_SIZE, BOARD_STROKE_MIN_SIZE, BOARD_TASK_ARTIFACT_LIMIT, BOARD_TEXT_ALIGNS, BoardAnchorSide, BoardAnimation, BoardAnimationHeader, BoardAnimationHeaderSchema, BoardAnimationSchema, BoardApplyOptions, BoardApplyResult, BoardArrowAnchor, BoardArrowAnchorSchema, BoardArrowBinding, BoardArrowBindingSchema, BoardArrowEnd, BoardArrowEndSchema, BoardArrowItem, BoardArrowItemSchema, BoardArrowRoute, BoardAudioItem, BoardAudioItemSchema, BoardBackgroundSchema, BoardBuiltinItem, BoardBuiltinItemType, BoardChangeSummary, BoardColor, BoardColorSchema, BoardColorToken, BoardCropSchema, BoardCustomItem, BoardCustomItemSchema, BoardDash, BoardDelta, BoardDiagnostic, BoardDocument, BoardDrawItem, BoardDrawItemSchema, BoardDrawPoint, BoardDrawPointSchema, BoardEaseSchema, BoardEffectItem, BoardEffectItemSchema, BoardEffectKind, BoardEnterPreset, BoardExtensionItem, BoardExtensionItemSchema, BoardFileBackedItem, BoardFileItem, BoardFileItemSchema, BoardFrame, BoardFrameItem, BoardFrameItemSchema, BoardHistoryPage, BoardIdSchema, BoardImageItem, BoardImageItemSchema, BoardItem, BoardItemLookup, BoardItemType, BoardJsonSchemaResult, BoardKeySchema, BoardKeyframe, BoardKeyframeSchema, BoardLayout, BoardManifest, BoardManifestSchema, BoardMarker, BoardMarkerSchema, BoardMatrix, BoardMediaSnapshot, BoardMediaSnapshotSchema, BoardMediaSource, BoardMediaSourceSchema, BoardPatch, BoardPatchResult, BoardPatchSchema, BoardPlayMode, BoardPlaybackCommand, BoardPlaybackCommandSchema, BoardPlaybackSnapshot, BoardPlaybackStatus, BoardPropertySpec, BoardReadResult, BoardRect, BoardScript, BoardScriptSchema, BoardSettings, BoardSettingsSchema, BoardShapeGeometry, BoardShapeItem, BoardShapeItemSchema, BoardSize, BoardSizeSchema, BoardState, BoardStyle, BoardStyleSchema, BoardTaskArtifact, BoardTaskArtifactSchema, BoardTaskItem, BoardTaskItemSchema, BoardTaskSnapshot, BoardTaskSnapshotSchema, BoardTextItem, BoardTextItemSchema, BoardTextLayout, BoardTextMeasurer, BoardTrack, BoardTrackSchema, BoardTransactionRecord, BoardValueKind, BoardVec2, BoardVec2Schema, BoardVideoItem, BoardVideoItemSchema, IDENTITY_MATRIX, RequestSource, RequestSourceVia, anchorPoint, applyBoardDelta, applyBoardPatch, applyBoardPatchToDocument, applyMatrix, arrowBindings, autoAnchorSide, bendControl, boardItemSchema, boardJsonSchema, boardPatchTouches, boardSchemaOverview, clampBoardFontSize, clampBoardStrokeSize, createBoardLayout, createDocumentLayout, createDocumentState, diffBoardDocuments, diffMergePatch, drawPointsBounds, drawSampleRadius, emptyBoardDocument, estimateTextWidth, framePoint, hasAuthoredSize, invertMatrix, isArrowBinding, isBoardColorString, isBoardEase, isBoardPath, isBuiltinItem, isBuiltinItemType, isEmptyBoardDelta, isEmptyBoardPatch, isFileBackedItem, isMediaItem, isPublicBoardRemoteAddress, isSafeBoardSourcePath, layoutBoardText, listBoardProperties, mergePatch, multiplyMatrix, normalizeBoardRemoteUrl, parseBoardDocument, parseBoardItem, parseBoardManifest, parseBoardMediaSource, pointsRect, pruneBoardTrack, resolveBoardProperty, rotateAround, scaleVector, serializeBoardManifest, setBoardTextMeasurer, sideAnchor, trackReferences };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { z } from "zod";
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BoardAnimation, BoardAnimationHeader, BoardColor, BoardDelta, BoardDiagnostic, BoardDocument, BoardItem, BoardKeyframe, BoardMarker, BoardPatch, BoardSettings, BoardStyle, BoardTrack } from "./protocol/dist/board-model.js";
|
|
2
|
-
import { BoardHistoryPage, BoardManifest, BoardPlaybackCommand, BoardPlaybackSnapshot, BoardTransactionRecord } from "./protocol/dist/board.js";
|
|
2
|
+
import { BoardApplyResult, BoardChangeSummary, BoardHistoryPage, BoardManifest, BoardPlaybackCommand, BoardPlaybackSnapshot, BoardReadResult, BoardTransactionRecord } from "./protocol/dist/board.js";
|
|
3
3
|
import "./protocol/dist/model/session.js";
|
|
4
4
|
import "./protocol/dist/index.js";
|
|
5
5
|
//#region src/types.d.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Cohub SDK for spaces, sessions, boards, and realtime agent collaboration.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -58,24 +58,36 @@
|
|
|
58
58
|
"import": "./dist/media.js"
|
|
59
59
|
},
|
|
60
60
|
"./board": {
|
|
61
|
-
"types": "./dist/board/index.d.ts",
|
|
62
|
-
"import": "./dist/board/index.js"
|
|
61
|
+
"types": "./dist/board/model/index.d.ts",
|
|
62
|
+
"import": "./dist/board/model/index.js"
|
|
63
|
+
},
|
|
64
|
+
"./board/editor": {
|
|
65
|
+
"types": "./dist/board/editor/index.d.ts",
|
|
66
|
+
"import": "./dist/board/editor/index.js"
|
|
67
|
+
},
|
|
68
|
+
"./board/replica": {
|
|
69
|
+
"types": "./dist/board/replica/index.d.ts",
|
|
70
|
+
"import": "./dist/board/replica/index.js"
|
|
63
71
|
},
|
|
64
72
|
"./board/player": {
|
|
65
|
-
"types": "./dist/board/
|
|
66
|
-
"import": "./dist/board/
|
|
73
|
+
"types": "./dist/board/player/index.d.ts",
|
|
74
|
+
"import": "./dist/board/player/index.js"
|
|
67
75
|
},
|
|
68
76
|
"./board/render": {
|
|
69
77
|
"types": "./dist/board/render/index.d.ts",
|
|
70
78
|
"import": "./dist/board/render/index.js"
|
|
71
79
|
},
|
|
80
|
+
"./board/stage": {
|
|
81
|
+
"types": "./dist/board/stage/index.d.ts",
|
|
82
|
+
"import": "./dist/board/stage/index.js"
|
|
83
|
+
},
|
|
72
84
|
"./board/export": {
|
|
73
85
|
"types": "./dist/board/export/index.d.ts",
|
|
74
86
|
"import": "./dist/board/export/index.js"
|
|
75
87
|
},
|
|
76
|
-
"./board/
|
|
77
|
-
"types": "./dist/board/
|
|
78
|
-
"import": "./dist/board/
|
|
88
|
+
"./board/export/node": {
|
|
89
|
+
"types": "./dist/board/export/node/index.d.ts",
|
|
90
|
+
"import": "./dist/board/export/node/index.js"
|
|
79
91
|
}
|
|
80
92
|
},
|
|
81
93
|
"types": "./dist/index.d.ts",
|
|
@@ -86,6 +98,7 @@
|
|
|
86
98
|
"NOTICE"
|
|
87
99
|
],
|
|
88
100
|
"dependencies": {
|
|
101
|
+
"es-module-lexer": "2.3.2",
|
|
89
102
|
"perfect-freehand": "1.2.3",
|
|
90
103
|
"zod": "^4.6.5"
|
|
91
104
|
},
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Rect, WorldPoint } from "../geometry.js";
|
|
2
|
-
import { BoardSceneItem } from "./scene.js";
|
|
3
|
-
import { ShapeCapabilities, ShapeGeometry, ShapeHandle, ShapeResizeMode } from "./shape-types.js";
|
|
4
|
-
//#region src/board/core/shape-definition.d.ts
|
|
5
|
-
type ShapeDefinition = {
|
|
6
|
-
type: string;
|
|
7
|
-
capabilities: ShapeCapabilities;
|
|
8
|
-
getBounds?: (item: BoardSceneItem) => Rect;
|
|
9
|
-
hitTest?: (item: BoardSceneItem, point: WorldPoint) => boolean;
|
|
10
|
-
getHandles?: (item: BoardSceneItem) => ShapeHandle[];
|
|
11
|
-
getGeometry?: (item: BoardSceneItem) => ShapeGeometry;
|
|
12
|
-
};
|
|
13
|
-
declare function registerShapeDefinition(definition: ShapeDefinition): void;
|
|
14
|
-
declare function getShapeDefinition(type: string): ShapeDefinition | undefined;
|
|
15
|
-
declare const unknownShapeDefinition: ShapeDefinition;
|
|
16
|
-
declare function definitionForItem(item: BoardSceneItem): ShapeDefinition;
|
|
17
|
-
declare function shapeBounds(item: BoardSceneItem): Rect;
|
|
18
|
-
declare function shapeHitTest(item: BoardSceneItem, point: WorldPoint): boolean;
|
|
19
|
-
declare function shapeHandles(item: BoardSceneItem): ShapeHandle[];
|
|
20
|
-
declare function shapeCapabilities(item: BoardSceneItem): ShapeCapabilities;
|
|
21
|
-
declare function shapeResizeMode(item: BoardSceneItem): ShapeResizeMode;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { ShapeDefinition, definitionForItem, getShapeDefinition, registerShapeDefinition, shapeBounds, shapeCapabilities, shapeHandles, shapeHitTest, shapeResizeMode, unknownShapeDefinition };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { frameContainsPoint, itemBounds } from "../geometry.js";
|
|
2
|
-
import { resizeModeForCapabilities } from "./shape-types.js";
|
|
3
|
-
//#region src/board/core/shape-definition.ts
|
|
4
|
-
const definitions = /* @__PURE__ */ new Map();
|
|
5
|
-
function registerShapeDefinition(definition) {
|
|
6
|
-
definitions.set(definition.type, definition);
|
|
7
|
-
}
|
|
8
|
-
function getShapeDefinition(type) {
|
|
9
|
-
return definitions.get(type);
|
|
10
|
-
}
|
|
11
|
-
const unknownShapeDefinition = {
|
|
12
|
-
type: "__unknown__",
|
|
13
|
-
capabilities: {
|
|
14
|
-
canMove: true,
|
|
15
|
-
canResize: true,
|
|
16
|
-
aspectLocked: false,
|
|
17
|
-
canRotate: true,
|
|
18
|
-
canEdit: false,
|
|
19
|
-
canConnect: true,
|
|
20
|
-
canSnap: true,
|
|
21
|
-
canLock: true
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
function definitionForItem(item) {
|
|
25
|
-
return definitions.get(item.type) ?? unknownShapeDefinition;
|
|
26
|
-
}
|
|
27
|
-
function shapeBounds(item) {
|
|
28
|
-
return definitionForItem(item).getBounds?.(item) ?? itemBounds(item.frame);
|
|
29
|
-
}
|
|
30
|
-
function shapeHitTest(item, point) {
|
|
31
|
-
const definition = definitionForItem(item);
|
|
32
|
-
if (definition.hitTest) return definition.hitTest(item, point);
|
|
33
|
-
return frameContainsPoint(item.frame, point);
|
|
34
|
-
}
|
|
35
|
-
function shapeHandles(item) {
|
|
36
|
-
return definitionForItem(item).getHandles?.(item) ?? [];
|
|
37
|
-
}
|
|
38
|
-
function shapeCapabilities(item) {
|
|
39
|
-
return definitionForItem(item).capabilities;
|
|
40
|
-
}
|
|
41
|
-
function shapeResizeMode(item) {
|
|
42
|
-
return resizeModeForCapabilities(shapeCapabilities(item));
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { definitionForItem, getShapeDefinition, registerShapeDefinition, shapeBounds, shapeCapabilities, shapeHandles, shapeHitTest, shapeResizeMode, unknownShapeDefinition };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BoardShapeGeometry } from "../../protocol/dist/board-model.js";
|
|
2
|
-
import { BoardFrame } from "../../protocol/dist/board-layout.js";
|
|
3
|
-
import "../../protocol/dist/index.js";
|
|
4
|
-
import { Rect, WorldPoint } from "../geometry.js";
|
|
5
|
-
//#region src/board/core/shape-types.d.ts
|
|
6
|
-
type ShapeGeometry = {
|
|
7
|
-
bounds: Rect;
|
|
8
|
-
containsWorldPoint?: (frame: BoardFrame, point: WorldPoint) => boolean;
|
|
9
|
-
};
|
|
10
|
-
type ShapeHandleId = string;
|
|
11
|
-
type ShapeHandle = {
|
|
12
|
-
id: ShapeHandleId;
|
|
13
|
-
x: number;
|
|
14
|
-
y: number;
|
|
15
|
-
radius?: number;
|
|
16
|
-
};
|
|
17
|
-
type HandleDragResult = {
|
|
18
|
-
frame?: BoardFrame;
|
|
19
|
-
props?: Record<string, unknown>;
|
|
20
|
-
};
|
|
21
|
-
type ShapeCapabilities = {
|
|
22
|
-
canMove: boolean;
|
|
23
|
-
canResize: boolean;
|
|
24
|
-
aspectLocked: boolean;
|
|
25
|
-
canRotate: boolean;
|
|
26
|
-
canEdit: boolean;
|
|
27
|
-
canConnect: boolean;
|
|
28
|
-
canSnap: boolean;
|
|
29
|
-
canLock: boolean;
|
|
30
|
-
};
|
|
31
|
-
type ShapeResizeMode = "none" | "uniform" | "free";
|
|
32
|
-
declare function resizeModeForCapabilities(capabilities: ShapeCapabilities): ShapeResizeMode;
|
|
33
|
-
declare const FULL_CAPABILITIES: ShapeCapabilities;
|
|
34
|
-
type ShapeKind = Exclude<BoardShapeGeometry, "path">;
|
|
35
|
-
declare const SHAPE_KINDS: ShapeKind[];
|
|
36
|
-
declare function isShapeKind(value: unknown): value is ShapeKind;
|
|
37
|
-
//#endregion
|
|
38
|
-
export { FULL_CAPABILITIES, HandleDragResult, SHAPE_KINDS, ShapeCapabilities, ShapeGeometry, ShapeHandle, ShapeHandleId, ShapeKind, ShapeResizeMode, isShapeKind, resizeModeForCapabilities };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BOARD_SHAPE_GEOMETRIES } from "../../protocol/dist/board-model.js";
|
|
2
|
-
//#region src/board/core/shape-types.ts
|
|
3
|
-
function resizeModeForCapabilities(capabilities) {
|
|
4
|
-
if (!capabilities.canResize) return "none";
|
|
5
|
-
return capabilities.aspectLocked ? "uniform" : "free";
|
|
6
|
-
}
|
|
7
|
-
const FULL_CAPABILITIES = {
|
|
8
|
-
canMove: true,
|
|
9
|
-
canResize: true,
|
|
10
|
-
aspectLocked: false,
|
|
11
|
-
canRotate: true,
|
|
12
|
-
canEdit: false,
|
|
13
|
-
canConnect: true,
|
|
14
|
-
canSnap: true,
|
|
15
|
-
canLock: true
|
|
16
|
-
};
|
|
17
|
-
const SHAPE_KINDS = BOARD_SHAPE_GEOMETRIES.filter((kind) => kind !== "path");
|
|
18
|
-
function isShapeKind(value) {
|
|
19
|
-
return typeof value === "string" && SHAPE_KINDS.includes(value);
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { FULL_CAPABILITIES, SHAPE_KINDS, isShapeKind, resizeModeForCapabilities };
|