json-canvas-viewer 3.2.0 → 3.2.1
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 +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/baseModule.d.ts +3 -4
- package/dist/types/controls/index.d.ts +1 -1
- package/dist/types/dataManager.d.ts +2 -3
- package/dist/types/declarations.d.ts +21 -14
- package/dist/types/index.d.ts +2 -0
- package/dist/types/interactionHandler.d.ts +2 -7
- package/dist/types/overlayManager.d.ts +8 -3
- package/dist/types/renderToString.d.ts +2 -0
- package/dist/types/shared.d.ts +0 -12
- package/dist/types/utilities.d.ts +10 -0
- package/package.json +2 -3
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { Container } from '@needle-di/core';
|
|
2
|
-
import type { DefaultOptions, Empty, GeneralFunction, GeneralObject
|
|
3
|
-
export type BaseArgs = [Container, GeneralObject
|
|
2
|
+
import type { DefaultOptions, Empty, GeneralFunction, GeneralObject } from './declarations';
|
|
3
|
+
export type BaseArgs = [Container, GeneralObject];
|
|
4
4
|
export type GeneralModuleCtor = typeof BaseModule<GeneralObject>;
|
|
5
5
|
export type GeneralModule = InstanceType<GeneralModuleCtor>;
|
|
6
6
|
export declare class BaseModule<O extends GeneralObject = Empty> {
|
|
7
7
|
protected container: Container;
|
|
8
|
-
|
|
9
|
-
constructor(container: Container, options: GeneralObject, utilities: Utilities);
|
|
8
|
+
constructor(container: Container, options: GeneralObject);
|
|
10
9
|
options: DefaultOptions & O;
|
|
11
10
|
dispose?: GeneralFunction;
|
|
12
11
|
}
|
|
@@ -20,7 +20,7 @@ export default class Controls extends BaseModule<Options> {
|
|
|
20
20
|
private get zoomInBtn();
|
|
21
21
|
private get resetViewBtn();
|
|
22
22
|
constructor(...args: BaseArgs);
|
|
23
|
-
toggleCollapse: () =>
|
|
23
|
+
toggleCollapse: () => void;
|
|
24
24
|
private zoomIn;
|
|
25
25
|
private zoomOut;
|
|
26
26
|
private slide;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Coordinates, NodeBounds } from './declarations';
|
|
2
1
|
import { BaseModule } from './baseModule';
|
|
2
|
+
import type { Coordinates, NodeBounds } from './declarations';
|
|
3
3
|
export default class DataManager extends BaseModule {
|
|
4
4
|
private spatialGrid;
|
|
5
5
|
hooks: {
|
|
@@ -17,7 +17,7 @@ export default class DataManager extends BaseModule {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
data: {
|
|
20
|
-
canvasData: JSONCanvas
|
|
20
|
+
canvasData: Required<JSONCanvas>;
|
|
21
21
|
nodeMap: Record<string, JSONCanvasNode>;
|
|
22
22
|
canvasBaseDir: string;
|
|
23
23
|
nodeBounds: NodeBounds;
|
|
@@ -27,7 +27,6 @@ export default class DataManager extends BaseModule {
|
|
|
27
27
|
container: HTMLDivElement;
|
|
28
28
|
};
|
|
29
29
|
loadCanvas: () => Promise<void>;
|
|
30
|
-
private resolvePath;
|
|
31
30
|
findNodeAt: (screenCoords: Coordinates) => JSONCanvasNode | null;
|
|
32
31
|
private judgeInteract;
|
|
33
32
|
private calculateNodeBounds;
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import type { GeneralModuleCtor } from './baseModule';
|
|
2
|
-
import type utilities from './utilities';
|
|
3
2
|
declare global {
|
|
4
|
-
interface
|
|
3
|
+
interface JSONCanvasGenericNode {
|
|
5
4
|
id: string;
|
|
6
5
|
type: 'group' | 'file' | 'text' | 'link';
|
|
7
6
|
x: number;
|
|
8
7
|
y: number;
|
|
9
8
|
width: number;
|
|
10
9
|
height: number;
|
|
10
|
+
styleAttributes?: Record<string, string>;
|
|
11
|
+
color?: string;
|
|
12
|
+
}
|
|
13
|
+
interface JSONCanvasGroupNode extends JSONCanvasGenericNode {
|
|
14
|
+
type: 'group';
|
|
11
15
|
label?: string;
|
|
12
16
|
background?: string;
|
|
13
17
|
backgroundStyle?: 'cover' | 'ratio' | 'repeat';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
file
|
|
18
|
+
}
|
|
19
|
+
interface JSONCanvasFileNode extends JSONCanvasGenericNode {
|
|
20
|
+
type: 'file';
|
|
21
|
+
file: string;
|
|
18
22
|
subpath?: string;
|
|
19
|
-
url?: string;
|
|
20
23
|
}
|
|
24
|
+
interface JSONCanvasTextNode extends JSONCanvasGenericNode {
|
|
25
|
+
type: 'text';
|
|
26
|
+
text: string;
|
|
27
|
+
}
|
|
28
|
+
interface JSONCanvasLinkNode extends JSONCanvasGenericNode {
|
|
29
|
+
type: 'link';
|
|
30
|
+
url: string;
|
|
31
|
+
}
|
|
32
|
+
type JSONCanvasNode = JSONCanvasGroupNode | JSONCanvasFileNode | JSONCanvasTextNode | JSONCanvasLinkNode;
|
|
21
33
|
interface JSONCanvasEdge {
|
|
22
34
|
id: string;
|
|
23
35
|
fromNode: string;
|
|
@@ -30,12 +42,8 @@ declare global {
|
|
|
30
42
|
color?: string;
|
|
31
43
|
}
|
|
32
44
|
interface JSONCanvas {
|
|
33
|
-
nodes
|
|
34
|
-
edges
|
|
35
|
-
metadata: {
|
|
36
|
-
version: string;
|
|
37
|
-
frontmatter: Record<string, string>;
|
|
38
|
-
};
|
|
45
|
+
nodes?: Array<JSONCanvasNode>;
|
|
46
|
+
edges?: Array<JSONCanvasEdge>;
|
|
39
47
|
}
|
|
40
48
|
}
|
|
41
49
|
export type Coordinates = {
|
|
@@ -73,7 +81,6 @@ export type DefaultOptions = {
|
|
|
73
81
|
container: HTMLElement;
|
|
74
82
|
canvasPath: string;
|
|
75
83
|
};
|
|
76
|
-
export type Utilities = typeof utilities;
|
|
77
84
|
export type ModuleInput = Array<GeneralModuleCtor>;
|
|
78
85
|
export type Options<T extends ModuleInput> = Omit<UnionToIntersection<AllModuleInstances<T>['options']>, keyof DefaultOptions> & DefaultOptions;
|
|
79
86
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { default as Controls } from './controls';
|
|
|
4
4
|
export { default as DebugPanel } from './debugPanel';
|
|
5
5
|
export { default as Minimap } from './minimap';
|
|
6
6
|
export { default as MistouchPreventer } from './mistouchPreventer';
|
|
7
|
+
export { default as renderToString } from './renderToString';
|
|
8
|
+
export { default as CanvasUtils } from './utilities';
|
|
7
9
|
import Controller from './controller';
|
|
8
10
|
import DataManager from './dataManager';
|
|
9
11
|
import InteractionHandler from './interactionHandler';
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { Pointeract } from 'pointeract';
|
|
1
|
+
import { Click, type Ctors, Drag, MultitouchPanZoom, Pointeract, type Options as PointeractOptions, PreventDefault, WheelPanZoom } from 'pointeract';
|
|
2
2
|
import { type BaseArgs, BaseModule } from './baseModule';
|
|
3
3
|
type Options = {
|
|
4
|
-
|
|
5
|
-
proControlSchema?: boolean;
|
|
6
|
-
zoomFactor?: number;
|
|
7
|
-
lockControlSchema?: boolean;
|
|
8
|
-
};
|
|
4
|
+
pointeract?: PointeractOptions<Ctors<[Click, Drag, WheelPanZoom, PreventDefault, MultitouchPanZoom]>>;
|
|
9
5
|
};
|
|
10
6
|
export default class InteractionHandler extends BaseModule<Options> {
|
|
11
7
|
private pointeract;
|
|
12
8
|
private DM;
|
|
13
|
-
private OM;
|
|
14
9
|
onClick: {
|
|
15
10
|
(args_0: string | null): void;
|
|
16
11
|
subs: Set<(args_0: string | null) => unknown>;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { micromark } from 'micromark';
|
|
1
2
|
import { type BaseArgs, BaseModule } from './baseModule';
|
|
2
|
-
|
|
3
|
+
type Options = {
|
|
4
|
+
micromark?: Parameters<typeof micromark>[1];
|
|
5
|
+
};
|
|
6
|
+
export default class OverlayManager extends BaseModule<Options> {
|
|
3
7
|
private _overlaysLayer;
|
|
4
8
|
private overlays;
|
|
5
9
|
private selectedId;
|
|
6
10
|
private eventListeners;
|
|
7
11
|
private DM;
|
|
8
12
|
private IH;
|
|
9
|
-
private
|
|
13
|
+
private parse;
|
|
10
14
|
private get overlaysLayer();
|
|
11
15
|
hooks: {
|
|
12
16
|
onInteractionStart: {
|
|
@@ -27,7 +31,8 @@ export default class OverlayManager extends BaseModule {
|
|
|
27
31
|
private select;
|
|
28
32
|
private loadMarkdownForNode;
|
|
29
33
|
private updateOverlays;
|
|
30
|
-
private
|
|
34
|
+
private updateOverlay;
|
|
31
35
|
private constructOverlay;
|
|
32
36
|
dispose: () => void;
|
|
33
37
|
}
|
|
38
|
+
export {};
|
package/dist/types/shared.d.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import type { GeneralArguments } from './declarations';
|
|
2
|
-
export declare const unexpectedError: Error;
|
|
3
1
|
export declare const destroyError: Error;
|
|
4
|
-
export interface RuntimeJSONCanvasNode extends JSONCanvasNode {
|
|
5
|
-
mdContent?: string;
|
|
6
|
-
mdFrontmatter?: Record<string, string>;
|
|
7
|
-
}
|
|
8
|
-
export declare function makeHook<Args extends GeneralArguments = []>(): {
|
|
9
|
-
(...args: Args): void;
|
|
10
|
-
subs: Set<(...args: Args) => unknown>;
|
|
11
|
-
subscribe(callback: (...args: Args) => unknown): void;
|
|
12
|
-
unsubscribe(callback: (...args: Args) => unknown): void;
|
|
13
|
-
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GeneralArguments } from './declarations';
|
|
1
2
|
declare const _default: {
|
|
2
3
|
round: typeof round;
|
|
3
4
|
resizeCanvasForDPR: typeof resizeCanvasForDPR;
|
|
@@ -5,6 +6,8 @@ declare const _default: {
|
|
|
5
6
|
drawRoundRect: typeof drawRoundRect;
|
|
6
7
|
getAnchorCoord: typeof getAnchorCoord;
|
|
7
8
|
getColor: typeof getColor;
|
|
9
|
+
resolvePath: typeof resolvePath;
|
|
10
|
+
makeHook: typeof makeHook;
|
|
8
11
|
};
|
|
9
12
|
export default _default;
|
|
10
13
|
declare function applyStyles(container: HTMLElement | ShadowRoot, styleString: string): void;
|
|
@@ -17,3 +20,10 @@ declare function getColor(colorIndex?: string): {
|
|
|
17
20
|
};
|
|
18
21
|
declare function resizeCanvasForDPR(canvas: HTMLCanvasElement, width: number, height: number): void;
|
|
19
22
|
declare function round(roundedNum: number, digits: number): number;
|
|
23
|
+
declare function resolvePath(path: string): string;
|
|
24
|
+
declare function makeHook<Args extends GeneralArguments = []>(): {
|
|
25
|
+
(...args: Args): void;
|
|
26
|
+
subs: Set<(...args: Args) => unknown>;
|
|
27
|
+
subscribe(callback: (...args: Args) => unknown): void;
|
|
28
|
+
unsubscribe(callback: (...args: Args) => unknown): void;
|
|
29
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-canvas-viewer",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "An extensible TypeScript-based viewer for JSON Canvas, easy to embed into websites.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@biomejs/biome": "^2.3.10",
|
|
35
35
|
"@types/node": "^25.0.3",
|
|
36
|
+
"micromark-extension-gfm": "^3.0.0",
|
|
36
37
|
"sass": "^1.97.1",
|
|
37
38
|
"tsc-alias": "^1.8.16",
|
|
38
39
|
"typescript": "^5.9.3",
|
|
@@ -43,9 +44,7 @@
|
|
|
43
44
|
],
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@needle-di/core": "^1.1.0",
|
|
46
|
-
"dompurify": "^3.3.1",
|
|
47
47
|
"micromark": "^4.0.2",
|
|
48
|
-
"micromark-extension-gfm": "^3.0.0",
|
|
49
48
|
"pointeract": "^1.0.1"
|
|
50
49
|
},
|
|
51
50
|
"scripts": {
|