crossnote 0.9.34 → 0.9.36

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 (51) hide show
  1. package/README.md +79 -0
  2. package/bin/crossnote.js +9 -0
  3. package/out/cjs/index.cjs +307 -266
  4. package/out/cli/index.cjs +39029 -0
  5. package/out/esm/index.mjs +286 -245
  6. package/out/server-app/server-app.css +1 -0
  7. package/out/server-app/server-app.js +44 -0
  8. package/out/styles/prism_theme/github-dark.css +1 -1
  9. package/out/styles/style-template.css +1 -1
  10. package/out/types/src/cli/index.d.ts +20 -0
  11. package/out/types/src/index.d.ts +2 -0
  12. package/out/types/src/markdown-engine/index.d.ts +6 -0
  13. package/out/types/src/notebook/index.d.ts +1 -0
  14. package/out/types/src/notebook/types.d.ts +1 -0
  15. package/out/types/src/serve/config-writer.d.ts +5 -0
  16. package/out/types/src/serve/config.d.ts +27 -0
  17. package/out/types/src/serve/index.d.ts +18 -0
  18. package/out/types/src/serve/markdown-files.d.ts +11 -0
  19. package/out/types/src/serve/sse.d.ts +14 -0
  20. package/out/types/src/serve/static.d.ts +4 -0
  21. package/out/types/src/serve/watcher.d.ts +18 -0
  22. package/out/types/src/server-app/App.d.ts +2 -0
  23. package/out/types/src/server-app/components/FilePicker.d.ts +9 -0
  24. package/out/types/src/server-app/components/LayoutView.d.ts +29 -0
  25. package/out/types/src/server-app/components/PreviewFrame.d.ts +10 -0
  26. package/out/types/src/server-app/components/TabStrip.d.ts +14 -0
  27. package/out/types/src/server-app/components/TitleBar.d.ts +7 -0
  28. package/out/types/src/server-app/components/Welcome.d.ts +9 -0
  29. package/out/types/src/server-app/lib/api.d.ts +45 -0
  30. package/out/types/src/server-app/lib/fuzzy.d.ts +16 -0
  31. package/out/types/src/server-app/server-app.d.ts +1 -0
  32. package/out/types/src/server-app/types.d.ts +37 -0
  33. package/out/types/src/webview/containers/preview.d.ts +2 -0
  34. package/out/types/src/wiki/index.d.ts +28 -0
  35. package/out/types/src/wiki-app/wiki-app.d.ts +17 -0
  36. package/out/types/test/cli/cli.test.d.ts +1 -0
  37. package/out/types/test/code-block-line-highlight.test.d.ts +1 -0
  38. package/out/types/test/runtime-compat.test.d.ts +1 -0
  39. package/out/types/test/serve/serve.test.d.ts +1 -0
  40. package/out/types/test/server-app/api.test.d.ts +1 -0
  41. package/out/types/test/wiki/build-wiki.test.d.ts +1 -0
  42. package/out/types/tsconfig.tsbuildinfo +1 -1
  43. package/out/webview/backlinks.css +1 -1
  44. package/out/webview/backlinks.js +7 -7
  45. package/out/webview/graph-view.css +1 -1
  46. package/out/webview/graph-view.js +4 -4
  47. package/out/webview/preview.css +1 -1
  48. package/out/webview/preview.js +188 -188
  49. package/out/wiki-app/wiki-app.css +1 -0
  50. package/out/wiki-app/wiki-app.js +18 -0
  51. package/package.json +14 -5
package/README.md CHANGED
@@ -99,6 +99,85 @@ If your notebook has `.crossnote` directory, then when you run `await Notebook.i
99
99
  └── style.less
100
100
  ```
101
101
 
102
+ ## CLI: `crossnote serve`
103
+
104
+ Crossnote ships a small CLI that serves a directory of markdown notes as a
105
+ standalone preview app in your browser:
106
+
107
+ ```sh
108
+ $ npx crossnote serve [directory...] # defaults to the cwd
109
+ $ pnpm crossnote serve ~/notes --port 8080
110
+ $ crossnote serve docs wiki # multiple folders, like a VS Code multi-root workspace
111
+ $ crossnote serve . --vscode # reuse VS Code markdown-preview-enhanced settings
112
+ ```
113
+
114
+ Open the printed URL (default `http://127.0.0.1:3000`) and you get a VS
115
+ Code–like editor layout running the exact same preview as the extension:
116
+
117
+ - Press `Ctrl/Cmd+P` for the fuzzy file picker. With multiple directories
118
+ every file keeps its own folder's `.crossnote` config, and picker entries
119
+ are prefixed with the folder name.
120
+ - Tabs, split panes, and drag & drop (drag a tab onto a pane edge to split
121
+ there, `Ctrl/Cmd+\` splits right, `Alt+W` closes a tab).
122
+ - Files are watched on disk — previews update live as you save, and edits
123
+ from the in-preview editor are written straight back to the file.
124
+ - The preview context menu keeps working; changing the preview/code block
125
+ theme persists it (see config resolution below). Host-only features such
126
+ as "Open in Browser" and exports are hidden.
127
+
128
+ Config resolution mirrors the
129
+ [VS Code extension](https://github.com/shd101wyy/vscode-markdown-preview-enhanced):
130
+ `defaults ← VS Code user settings (only with --vscode) ← global crossnote
131
+ config (~/.crossnote or $XDG_CONFIG_HOME/crossnote) ← <directory>/.crossnote`.
132
+ Theme changes are persisted to VS Code `settings.json` (a comment-preserving
133
+ surgical edit) in `--vscode` mode, and to the global crossnote `config.js`
134
+ otherwise.
135
+
136
+ Options: `--port <n>` (default 3000, auto-increments when busy), `--host`
137
+ (default 127.0.0.1), `--vscode`, `--vscode-settings <path>` (explicit
138
+ settings.json, auto-detected otherwise).
139
+
140
+ The server is built for local use: it binds to `127.0.0.1` by default and
141
+ only accepts requests whose `Host`/`Origin` name the server itself, so
142
+ websites open in the same browser cannot drive its command endpoint (which
143
+ runs code chunks and writes files) or read its responses via DNS rebinding.
144
+ HTML/SVG/XML files from the served directories are delivered with a
145
+ sandboxing CSP, so a document from an untrusted repository can never execute
146
+ same-origin script against the app.
147
+
148
+ ## CLI: `crossnote build-wiki`
149
+
150
+ `crossnote build-wiki` packs the directories' markdown notes into a single
151
+ standalone HTML file — a read-only snapshot of the serve experience, like a
152
+ TiddlyWiki: a file list with a fuzzy filter, one note at a time, and note-to-note
153
+ links that keep working inside the file.
154
+
155
+ ```sh
156
+ $ npx crossnote build-wiki [directory...] # default output ./index.html
157
+ $ crossnote build-wiki ~/notes -o ~/public/wiki.html
158
+ $ crossnote build-wiki docs wiki --vscode # reuse VS Code settings, too
159
+ ```
160
+
161
+ - Every note is rendered through the regular HTML export pipeline: CDN-hosted
162
+ assets (KaTeX/MathJax, mermaid, wavedrom, vega, …) load when the reader is
163
+ online, and local images/SVGs are embedded as data URIs so the file travels
164
+ on its own (front matter `html: { embed_local_images: false }` opts out).
165
+ - Notes are pre-rendered and shown inside a sandboxed iframe — the wiki has
166
+ no write channel at all. Task-list checkboxes are disabled, external links
167
+ open new tabs, and links to notes that are not part of the wiki explain so
168
+ instead of navigating away.
169
+ - Config resolution is the same as `serve`
170
+ (`defaults ← VS Code settings with --vscode ← global crossnote config ←
171
+ <directory>/.crossnote`), per directory.
172
+ - The preview context menu (in `serve` and in the VS Code extension) has an
173
+ "Export standalone HTML (wiki)" item that builds the same file: the server
174
+ writes it next to the notes as `crossnote-wiki.html` (never overwriting a
175
+ previous export); the extension asks where to save it.
176
+
177
+ The file is a full snapshot — for very large note collections (thousands of
178
+ notes with big images) it can get large; the build reports its size and any
179
+ note that failed to render (failures are skipped, not fatal).
180
+
102
181
  ## markdown_yo (Experimental)
103
182
 
104
183
  Crossnote supports an optional high-performance markdown renderer called [markdown_yo](https://github.com/shd101wyy/markdown_yo), written in the [Yo programming language](https://github.com/shd101wyy/Yo) and compiled to WebAssembly. When enabled, it replaces markdown-it for HTML rendering while markdown-it is still used for token-based operations (backlink extraction, note mention processing, etc.).
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ // `require.main === module` inside out/cli/index.cjs is false on this path
3
+ // (this bin is the main module), so main() has to be called from here.
4
+ require('../out/cli/index.cjs')
5
+ .main()
6
+ .catch((error) => {
7
+ console.error(error);
8
+ process.exit(1);
9
+ });