json-canvas-viewer 3.4.3 → 4.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.
Files changed (50) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +51 -107
  3. package/dist/chimp.js +1 -1
  4. package/dist/index.d.ts +609 -0
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/package.json +15 -48
  8. package/dist/bridges.js +0 -2
  9. package/dist/bridges.js.map +0 -1
  10. package/dist/dev.js +0 -2
  11. package/dist/dev.js.map +0 -1
  12. package/dist/index-BPBGNZi4.js +0 -2
  13. package/dist/index-BPBGNZi4.js.map +0 -1
  14. package/dist/interactionHandler-CrVH9u7P.js +0 -2
  15. package/dist/interactionHandler-CrVH9u7P.js.map +0 -1
  16. package/dist/modules.js +0 -2
  17. package/dist/modules.js.map +0 -1
  18. package/dist/react.js +0 -2
  19. package/dist/react.js.map +0 -1
  20. package/dist/renderToString-Dp8A-Rka.js +0 -2
  21. package/dist/renderToString-Dp8A-Rka.js.map +0 -1
  22. package/dist/renderer-BGA72dN1.js +0 -2
  23. package/dist/renderer-BGA72dN1.js.map +0 -1
  24. package/dist/types/bridges/reactComponent.d.ts +0 -12
  25. package/dist/types/bridges/renderToString.d.ts +0 -6
  26. package/dist/types/bridges/vitePlugin.d.ts +0 -8
  27. package/dist/types/bridges/vueComponent.vue.d.ts +0 -28
  28. package/dist/types/bridges/webpackPlugin.d.ts +0 -7
  29. package/dist/types/bridges.d.ts +0 -3
  30. package/dist/types/chimp.d.ts +0 -7
  31. package/dist/types/core/baseModule.d.ts +0 -19
  32. package/dist/types/core/controller.d.ts +0 -35
  33. package/dist/types/core/dataManager.d.ts +0 -59
  34. package/dist/types/core/declarations.d.ts +0 -105
  35. package/dist/types/core/index.d.ts +0 -25
  36. package/dist/types/core/interactionHandler.d.ts +0 -39
  37. package/dist/types/core/overlayManager.d.ts +0 -44
  38. package/dist/types/core/renderer.d.ts +0 -32
  39. package/dist/types/core/styleManager.d.ts +0 -49
  40. package/dist/types/core/utilities.d.ts +0 -25
  41. package/dist/types/dev.d.ts +0 -9
  42. package/dist/types/index.d.ts +0 -2
  43. package/dist/types/modules/controls/index.d.ts +0 -38
  44. package/dist/types/modules/debugPanel/index.d.ts +0 -9
  45. package/dist/types/modules/minimap/index.d.ts +0 -32
  46. package/dist/types/modules/mistouchPreventer/index.d.ts +0 -25
  47. package/dist/types/modules.d.ts +0 -4
  48. package/dist/vue.js +0 -2
  49. package/dist/vue.js.map +0 -1
  50. package/dist/webpackLoader.js +0 -33
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Hesprs
3
+ Copyright (c) 2025-2026 Hesprs (Hēsperus)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <h1 align="center">
2
- <img src="assets/logo.svg" alt="JSON Canvas Viewer logo" width="280px">
2
+ <img src="../../assets/logo.svg" alt="JSON Canvas Viewer logo" width="280px">
3
3
  <br />
4
4
  JSON Canvas Viewer
5
5
  <br />
@@ -8,137 +8,81 @@
8
8
  <h4 align="center">An extensible web-based viewer for JSON Canvas</h4>
9
9
 
10
10
  <p align="center">
11
- <a href="https://www.npmjs.com/package/json-canvas-viewer">
12
- <img src="https://img.shields.io/npm/v/json-canvas-viewer?logo=npm&labelColor=red&logoColor=white&color=333333" alt="npm">
13
- </a>
14
- <a href="https://bundlephobia.com/package/json-canvas-viewer">
15
- <img src="https://img.shields.io/bundlejs/size/json-canvas-viewer?format=minzip&style=flat&logo=webpack&logoColor=white&label=Minzipped%20Size&labelColor=orange&color=333333" alt="Gzipped + Minified Size">
16
- </a>
17
- <a href="https://github.com/hesprs/json-canvas-viewer/actions">
18
- <img src="https://img.shields.io/github/actions/workflow/status/hesprs/json-canvas-viewer/ci.yml?style=flat&logo=github&logoColor=white&label=CI&labelColor=d4ab00&color=333333" alt="ci">
19
- </a>
20
- <a href="https://www.codefactor.io/repository/github/hesprs/json-canvas-viewer">
21
- <img src="https://img.shields.io/codefactor/grade/github/hesprs/json-canvas-viewer?style=flat&logo=codefactor&logoColor=white&label=Code%20Quality&labelColor=17b37a&color=333333" alt="CodeFactor">
22
- </a>
23
- <img src="https://img.shields.io/badge/Types-Strict-333333?logo=typescript&labelColor=blue&logoColor=white" alt="TypeScript">
24
- <a href="https://snyk.io/test/npm/json-canvas-viewer">
25
- <img src="https://img.shields.io/badge/Snyk%20Security-Monitored-333333?logo=snyk&style=flat&labelColor=8A2BE2&logoColor=white" alt="Snyk Security">
26
- </a>
27
- <a href="https://github.com/hesprs/json-canvas-viewer/wiki">
28
- <img src="https://img.shields.io/badge/Documentation-Ready-333333?labelColor=5C73E7&logo=github&logoColor=white" alt="Documentation">
29
- </a>
30
- <img src="https://img.shields.io/badge/%F0%9F%96%90%EF%B8%8F%20Made%20by-Humans-333333?labelColor=25C260" alt="Made by Humans">
31
- </p>
32
-
33
- <img align="center" src="./assets/preview.png" alt="preview image with light and dark theme">
34
-
35
- <p align="center">
36
- <a href="https://hesprs.github.io/json-canvas-viewer">
37
- <strong>Demo</strong>
38
- </a> •
39
11
  <a href="https://github.com/hesprs/json-canvas-viewer/wiki">
40
12
  <strong>Documentation</strong>
41
13
  </a> •
42
- <a href="https://jsoncanvas.org/">
43
- <strong>About JSON Canvas</strong>
14
+ <strong>Vanilla</strong>
15
+ <a href="https://www.npmjs.com/package/vite-plugin-json-canvas">
16
+ <strong>Vite Plugin</strong>
17
+ </a> •
18
+ <a href="https://www.npmjs.com/package/@json-canvas-viewer/react">
19
+ <strong>React Component</strong>
20
+ </a> •
21
+ <a href="https://www.npmjs.com/package/@json-canvas-viewer/vue">
22
+ <strong>Vue Component</strong>
23
+ </a> •
24
+ <a href="https://www.npmjs.com/package/@json-canvas-viewer/preact">
25
+ <strong>Preact Component</strong>
44
26
  </a>
45
27
  </p>
46
28
 
47
- ## 🐶 Features
29
+ ## ✏️ Description
48
30
 
49
- - View JSON Canvas files (`.canvas`) in a web browser
50
- - Embed into websites easily
51
- - Interactive pan and zoom functionality
52
- - Can display 100% of canvas features described in the [official spec](https://jsoncanvas.org/spec/1.0/)
53
- - Responsive design with mobile and touchpad adaptation
54
- - Supports Lazy loading
55
- - TypeScript native
56
- - Modern aesthetics with light and dark mode support
57
- - A [chimp version](https://github.com/hesprs/json-canvas-viewer/wiki/1-%F0%9F%9A%80-Quick-Start#-chimpanzee-version) specially designed for fast trial is available
58
- - 🔥 More performant than rendering canvases in Obsidian!
59
- - 🧩 Out-of-the-box extensibility and tree-shaking, current optional modules include:
60
- - [`Minimap`](https://github.com/hesprs/json-canvas-viewer/wiki/3-%F0%9F%A7%A9-Modules#minimap) for easy navigation
61
- - [`Controls`](https://github.com/hesprs/json-canvas-viewer/wiki/3-%F0%9F%A7%A9-Modules#controls) displays zoom in/out and fullscreen buttons
62
- - [`MistouchPreventer`](https://github.com/hesprs/json-canvas-viewer/wiki/3-%F0%9F%A7%A9-Modules#mistouch-preventer) prevents the canvas from intercepting page scroll.
63
- - [`DebugPanel`](https://github.com/hesprs/json-canvas-viewer/wiki/3-%F0%9F%A7%A9-Modules#debug-panel) displays scale and position data.
31
+ This is the core package of JSON Canvas Viewer, contains the vanilla viewer class, all modules and development kit.
64
32
 
65
- ## 🧩 Integration with Existing Paradigms
33
+ Install this package if you want to use JSON Canvas Viewer in a **vanilla JavaScript / TypeScript** project. If you are using a framework, please head to the corresponding package in the navigation bar above.
66
34
 
67
- JSON Canvas Viewer currently can work seamlessly with the following techstacks / technologies (including but not limited to):
35
+ ## 📦 Installation
68
36
 
69
- - Vanilla JS/TS: natural support
70
- - ✅ Prerendering: [`renderToString`](https://github.com/hesprs/json-canvas-viewer/wiki/4-%F0%9F%96%87%EF%B8%8F-Prerendering-and-Bridges#prerendering)
71
- - ✅ Vite: [Vite Plugin](https://github.com/hesprs/json-canvas-viewer/wiki/1-%F0%9F%9A%80-Quick-Start#vite)
72
- - ✅ Webpack: [Webpack Loader & Plugin](https://github.com/hesprs/json-canvas-viewer/wiki/1-%F0%9F%9A%80-Quick-Start#webpack)
73
- - ✅ Vue: [Vue Component](https://github.com/hesprs/json-canvas-viewer/wiki/4-%F0%9F%96%87%EF%B8%8F-Prerendering-and-Bridges#vue-component)
74
- - ✅ React: [React Component](https://github.com/hesprs/json-canvas-viewer/wiki/4-%F0%9F%96%87%EF%B8%8F-Prerendering-and-Bridges#react-component)
37
+ Install with your favorite package manager:
75
38
 
76
- 🙌 Contributions are welcomed!
39
+ ```bash
40
+ npm add json-canvas-viewer
77
41
 
78
- ## 🦾 It's the Age of Agents
42
+ # or
43
+ pnpm add json-canvas-viewer
79
44
 
80
- Your time is expensive, do not spend it on reading the lengthy docs of a niche library. Nowadays coding agents are smart enough to handle the viewer well.
45
+ # or
46
+ yarn add json-canvas-viewer
81
47
 
82
- Copy and paste the following prompt to OpenCode, ClaudeCode, Cursor or even a chat bot, replace the placeholder to your task, let it handle everything for you:
48
+ # or
49
+ bun add json-canvas-viewer
50
+ ```
83
51
 
84
- ```markdown
85
- I'm using `json-canvas-viewer`, a library to view JSON Canvas (from Obsidian) interactively in a browser. Read its documentations, figure out wether to use `chimp` version or `full` version, and help me with my requirements.
52
+ Now you have two options: **build-time** canvas parsing or **client-side** canvas parsing.
86
53
 
87
- **Documentations**:
54
+ ### Build-time Canvas Parsing
88
55
 
89
- [Readme](https://github.com/hesprs/json-canvas-viewer/raw/refs/heads/main/README.md)
90
- [Quick Start](https://github.com/hesprs/json-canvas-viewer/raw/refs/heads/main/docs/1-%F0%9F%9A%80-Quick-Start.md)
91
- [Construction Details](https://github.com/hesprs/json-canvas-viewer/raw/refs/heads/main/docs/2-%F0%9F%8F%97%EF%B8%8F-Construction-Details.md)
92
- [Modules](https://github.com/hesprs/json-canvas-viewer/raw/refs/heads/main/docs/3-%F0%9F%A7%A9-Modules.md)
93
- [Prerendering, Vue, and React Integration](https://github.com/hesprs/json-canvas-viewer/raw/refs/heads/main/docs/4-%F0%9F%96%87%EF%B8%8F-Prerendering-and-Bridges.md)
56
+ This is the recommended way to parse canvas data, it will result in significantly smaller bundle size and faster load times.
94
57
 
95
- **Requirements**:
58
+ Firstly, you need a bundler. JSON Canvas Viewer currently supports [Vite](https://vitejs.dev/) only. Please install [Vite Plugin](https://www.npmjs.com/package/vite-plugin-json-canvas) and setup it.
96
59
 
97
- <!-- your requirements here -->
98
- ```
60
+ After bundler setup, you can directly import a canvas file and use it in viewer instantiation:
99
61
 
100
- ## 🚀 Manual Trial in 5 Seconds
101
-
102
- The HTML snippet below uses the `chimp` version of JSON Canvas Viewer. You also need to prepare a canvas file, if you don't have one, you can download one at [here](https://github.com/hesprs/json-canvas-viewer/blob/main/test/demo.canvas).
103
-
104
- ```HTML
105
- <!DOCTYPE html>
106
- <html lang="en">
107
- <head>
108
- <meta charset="UTF-8" />
109
- <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
110
- <title>🐒 Canvas Viewer</title>
111
- <style>
112
- body, html {
113
- margin: 0;
114
- padding: 0;
115
- width: 100%;
116
- height: 100%;
117
- }
118
- </style>
119
- </head>
120
- <body></body>
121
- <script type="module">
122
- import { JSONCanvasViewer, parser, loadCanvas } from 'https://unpkg.com/json-canvas-viewer';
123
- new JSONCanvasViewer({
124
- container: document.body, // The element to attach the viewer to
125
- canvas: loadCanvas('path/to/your.canvas'), // remember to prepare your canvas
126
- markdownParser: parser,
127
- });
128
- </script>
129
- </html>
62
+ ```Typescript
63
+ import { JSONCanvasViewer } from 'json-canvas-viewer';
64
+ import canvas from 'path/to/your.canvas';
65
+
66
+ const container = document.getElementById('container') as HTMLElement;
67
+ new JSONCanvasViewer({ canvas, container });
130
68
  ```
131
69
 
132
- For full elaboration about the instantiation and APIs, please refer to [the documentation](https://github.com/hesprs/json-canvas-viewer/wiki).
70
+ ### Client-side Canvas Parsing
71
+
72
+ This method doesn't require any bundler setup. You just need to import the parser and fetch the canvas file:
133
73
 
134
- ## 🤝 Get Involved
74
+ ```Typescript
75
+ import { parser, fetchCanvas, JSONCanvasViewer } from 'json-canvas-viewer';
135
76
 
136
- This project welcomes anyone that have ideas to improve it.
77
+ const container = document.getElementById('container') as HTMLElement;
78
+ new JSONCanvasViewer({
79
+ container,
80
+ parser,
81
+ canvas: await fetchCanvas('path/to/your.canvas'),
82
+ });
83
+ ```
137
84
 
138
- - [Open a pull request](https://github.com/hesprs/pointeract/compare) for a new module, documentation update, and so on.
139
- - [Open an issue](https://github.com/hesprs/pointeract/issues/new) if you find a bug.
140
- - [Start a new thread in Discussions](https://github.com/hesprs/pointeract/discussions/new) if you have feature requests or questions, please avoid posting them in Issues.
141
- - [Report a vulnerability](https://github.com/hesprs/pointeract/security/advisories/new) if you find one, please do not disclose it publicly.
85
+ Refer to the [documentation](https://github.com/hesprs/json-canvas-viewer/wiki/) for more details.
142
86
 
143
87
  ## 📝 Copyright & License
144
88