crossnote 0.9.35 → 0.9.37

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 (53) hide show
  1. package/README.md +84 -0
  2. package/bin/crossnote.js +9 -0
  3. package/out/cjs/index.cjs +338 -282
  4. package/out/cli/index.cjs +39163 -0
  5. package/out/esm/index.mjs +324 -268
  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 +8 -1
  13. package/out/types/src/notebook/index.d.ts +1 -0
  14. package/out/types/src/notebook/types.d.ts +2 -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/preview-host-shim.d.ts +1 -0
  20. package/out/types/src/serve/sse.d.ts +14 -0
  21. package/out/types/src/serve/static.d.ts +4 -0
  22. package/out/types/src/serve/watcher.d.ts +18 -0
  23. package/out/types/src/server-app/App.d.ts +2 -0
  24. package/out/types/src/server-app/components/FilePicker.d.ts +11 -0
  25. package/out/types/src/server-app/components/LayoutView.d.ts +30 -0
  26. package/out/types/src/server-app/components/PreviewFrame.d.ts +11 -0
  27. package/out/types/src/server-app/components/TabStrip.d.ts +14 -0
  28. package/out/types/src/server-app/components/TitleBar.d.ts +7 -0
  29. package/out/types/src/server-app/components/Welcome.d.ts +9 -0
  30. package/out/types/src/server-app/lib/api.d.ts +62 -0
  31. package/out/types/src/server-app/lib/fuzzy.d.ts +16 -0
  32. package/out/types/src/server-app/lib/wiki.d.ts +10 -0
  33. package/out/types/src/server-app/server-app.d.ts +1 -0
  34. package/out/types/src/server-app/types.d.ts +37 -0
  35. package/out/types/src/utility.d.ts +1 -1
  36. package/out/types/src/webview/containers/preview.d.ts +1 -0
  37. package/out/types/src/webview/lib/utility.d.ts +4 -0
  38. package/out/types/src/wiki/index.d.ts +40 -0
  39. package/out/types/test/cli/cli.test.d.ts +1 -0
  40. package/out/types/test/code-block-line-highlight.test.d.ts +1 -0
  41. package/out/types/test/nul-character.test.d.ts +1 -0
  42. package/out/types/test/serve/serve.test.d.ts +1 -0
  43. package/out/types/test/server-app/api.test.d.ts +1 -0
  44. package/out/types/test/server-app/wiki.test.d.ts +1 -0
  45. package/out/types/test/wiki/build-wiki.test.d.ts +1 -0
  46. package/out/types/tsconfig.tsbuildinfo +1 -1
  47. package/out/webview/backlinks.css +1 -1
  48. package/out/webview/backlinks.js +7 -7
  49. package/out/webview/graph-view.css +1 -1
  50. package/out/webview/graph-view.js +6 -6
  51. package/out/webview/preview.css +1 -1
  52. package/out/webview/preview.js +190 -190
  53. package/package.json +10 -1
package/README.md CHANGED
@@ -99,6 +99,90 @@ 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: the file embeds the serve app itself (titlebar, tabs, split panes,
153
+ `Ctrl/Cmd+P` fuzzy file picker, zen mode) with every note pre-rendered as a
154
+ regular preview page, so it looks and behaves exactly like `crossnote serve`
155
+ with the writable parts removed.
156
+
157
+ ```sh
158
+ $ npx crossnote build-wiki [directory...] # default output ./index.html
159
+ $ crossnote build-wiki ~/notes -o ~/public/wiki.html
160
+ $ crossnote build-wiki docs wiki --vscode # reuse VS Code settings, too
161
+ ```
162
+
163
+ - Every note is the exact preview page the serve server renders, shown in a
164
+ sandboxed (`allow-scripts`) iframe: diagrams, math, the sidebar TOC and
165
+ zoom all work. Shared assets (the webview bundle, mermaid, themes, …) are
166
+ stored once and inlined when a note is opened; local images travel as data
167
+ URIs so the file works offline (except CDN-hosted math assets, which need
168
+ the reader to be online).
169
+ - The wiki is read-only by construction — nothing in the file can write
170
+ anywhere. Editing UI, code-chunk run buttons and task-list checkboxes are
171
+ hidden or inert, note-to-note links resolve inside the file, external
172
+ links open new tabs, and links to notes that are not part of the wiki
173
+ explain so instead of navigating away.
174
+ - Config resolution is the same as `serve`
175
+ (`defaults ← VS Code settings with --vscode ← global crossnote config ←
176
+ <directory>/.crossnote`), per directory.
177
+ - The preview context menu (in `serve` and in the VS Code extension) has an
178
+ **Export ▸ Wiki** item that builds the same file: the server writes it
179
+ next to the notes as `crossnote-wiki.html` (never overwriting a previous
180
+ export); the extension asks where to save it.
181
+
182
+ The file is a full snapshot — for very large note collections (thousands of
183
+ notes with big images) it can get large; the build reports its size and any
184
+ note that failed to render (failures are skipped, not fatal).
185
+
102
186
  ## markdown_yo (Experimental)
103
187
 
104
188
  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
+ });