crossnote 0.9.36 → 0.9.38

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 (41) hide show
  1. package/README.md +27 -14
  2. package/out/cjs/index.cjs +321 -295
  3. package/out/cli/index.cjs +753 -135
  4. package/out/esm/index.mjs +334 -308
  5. package/out/server-app/server-app.css +1 -1
  6. package/out/server-app/server-app.js +115 -7
  7. package/out/types/src/markdown-engine/index.d.ts +34 -3
  8. package/out/types/src/notebook/types.d.ts +1 -0
  9. package/out/types/src/serve/graph-host-shim.d.ts +6 -0
  10. package/out/types/src/serve/markdown-files.d.ts +1 -0
  11. package/out/types/src/serve/preview-host-shim.d.ts +1 -0
  12. package/out/types/src/server-app/components/FilePicker.d.ts +3 -1
  13. package/out/types/src/server-app/components/LayoutView.d.ts +4 -0
  14. package/out/types/src/server-app/components/PreviewFrame.d.ts +2 -1
  15. package/out/types/src/server-app/components/TabStrip.d.ts +3 -1
  16. package/out/types/src/server-app/components/TitleBar.d.ts +3 -1
  17. package/out/types/src/server-app/components/Welcome.d.ts +2 -1
  18. package/out/types/src/server-app/lib/api.d.ts +70 -10
  19. package/out/types/src/server-app/lib/preview-theme.d.ts +1 -0
  20. package/out/types/src/server-app/lib/wiki.d.ts +20 -0
  21. package/out/types/src/server-app/types.d.ts +4 -0
  22. package/out/types/src/utility.d.ts +1 -1
  23. package/out/types/src/webview/containers/preview.d.ts +1 -0
  24. package/out/types/src/webview/lib/utility.d.ts +4 -0
  25. package/out/types/src/wiki/index.d.ts +49 -1
  26. package/out/types/test/nul-character.test.d.ts +1 -0
  27. package/out/types/test/serve/markdown-files.test.d.ts +1 -0
  28. package/out/types/test/server-app/preview-theme.test.d.ts +1 -0
  29. package/out/types/test/server-app/types.test.d.ts +1 -0
  30. package/out/types/test/server-app/wiki.test.d.ts +1 -0
  31. package/out/types/tsconfig.tsbuildinfo +1 -1
  32. package/out/webview/backlinks.css +1 -1
  33. package/out/webview/backlinks.js +4 -4
  34. package/out/webview/graph-view.css +1 -1
  35. package/out/webview/graph-view.js +6 -6
  36. package/out/webview/preview.css +1 -1
  37. package/out/webview/preview.js +189 -189
  38. package/package.json +1 -1
  39. package/out/types/src/wiki-app/wiki-app.d.ts +0 -17
  40. package/out/wiki-app/wiki-app.css +0 -1
  41. package/out/wiki-app/wiki-app.js +0 -18
@@ -48,8 +48,38 @@ export declare class MarkdownEngine {
48
48
  private get protocolsWhiteListRegExp();
49
49
  cacheCodeChunkResult(id: string, result: string): void;
50
50
  private generateScriptsForPreview;
51
- private static AutoPrismThemeMap;
52
- private static AutoPrismThemeMapForPresentation;
51
+ static AutoPrismThemeMap: {
52
+ 'atom-dark.css': string;
53
+ 'atom-light.css': string;
54
+ 'atom-material.css': string;
55
+ 'github-dark.css': string;
56
+ 'github-light.css': string;
57
+ 'gothic.css': string;
58
+ 'medium.css': string;
59
+ 'monokai.css': string;
60
+ 'newsprint.css': string;
61
+ 'night.css': string;
62
+ 'one-dark.css': string;
63
+ 'one-light.css': string;
64
+ 'solarized-light.css': string;
65
+ 'solarized-dark.css': string;
66
+ 'vue.css': string;
67
+ 'vscode.css': string;
68
+ };
69
+ static AutoPrismThemeMapForPresentation: {
70
+ 'beige.css': string;
71
+ 'black.css': string;
72
+ 'blood.css': string;
73
+ 'league.css': string;
74
+ 'moon.css': string;
75
+ 'night.css': string;
76
+ 'serif.css': string;
77
+ 'simple.css': string;
78
+ 'sky.css': string;
79
+ 'solarized.css': string;
80
+ 'white.css': string;
81
+ 'vscode.css': string;
82
+ };
53
83
  private static resolveThemeForExport;
54
84
  private static PreviewThemeColorCounterparts;
55
85
  private static PrismThemeColorCounterparts;
@@ -59,7 +89,7 @@ export declare class MarkdownEngine {
59
89
  private generateStylesForPreview;
60
90
  private generateJSAndCssFilesForPreview;
61
91
  private isPathInsideProjectDirectory;
62
- generateHTMLTemplateForPreview({ inputString, body, webviewScript, scripts, styles, head, config, vscodePreviewPanel, contentSecurityPolicy, isVSCodeWebExtension, }: {
92
+ generateHTMLTemplateForPreview({ inputString, body, webviewScript, scripts, styles, head, config, vscodePreviewPanel, contentSecurityPolicy, isVSCodeWebExtension, parsedOutput, }: {
63
93
  inputString?: string;
64
94
  body?: string;
65
95
  webviewScript?: string;
@@ -70,6 +100,7 @@ export declare class MarkdownEngine {
70
100
  vscodePreviewPanel: vscode.WebviewPanel | null | undefined;
71
101
  contentSecurityPolicy?: string;
72
102
  isVSCodeWebExtension?: boolean;
103
+ parsedOutput?: MarkdownEngineOutput;
73
104
  }): Promise<string>;
74
105
  generateHTMLTemplateForGraphView({ vscodePreviewPanel, contentSecurityPolicy, }: {
75
106
  vscodePreviewPanel: vscode.WebviewPanel | null | undefined;
@@ -128,6 +128,7 @@ export interface WebviewConfig extends Partial<NotebookConfig> {
128
128
  isShowingTranslation?: boolean;
129
129
  locale?: string;
130
130
  isServerApp?: boolean;
131
+ isWiki?: boolean;
131
132
  }
132
133
  export declare enum PreviewMode {
133
134
  SinglePreview = "Single Preview",
@@ -0,0 +1,6 @@
1
+ export declare function graphHostShimScript(options: {
2
+ source: 'fetch' | 'embedded';
3
+ dataUrl?: string;
4
+ fileExpression?: string;
5
+ embeddedFileExpression?: string;
6
+ }): string;
@@ -2,6 +2,7 @@ export declare const MARKDOWN_EXTENSIONS: string[];
2
2
  export declare function isMarkdownFile(filePath: string): boolean;
3
3
  export declare function encodePathSegments(relativePath: string): string;
4
4
  export declare function isPathWithinRoot(root: string, candidate: string): boolean;
5
+ export declare function isPathWithinRootOn(platform: NodeJS.Platform, root: string, candidate: string): boolean;
5
6
  export interface MarkdownFileInfo {
6
7
  relativePath: string;
7
8
  absolutePath: string;
@@ -0,0 +1 @@
1
+ export declare function previewHostShimScript(targetOriginExpression: string): string;
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
+ import { MarkdownFileInfo } from '../lib/api';
2
3
  export interface FilePickerProps {
3
4
  open: boolean;
4
5
  recents: string[];
5
6
  rootDirectories: string[];
7
+ embeddedFiles?: MarkdownFileInfo[];
6
8
  onClose: () => void;
7
9
  onOpenFile: (file: string) => void;
8
10
  }
9
- export default function FilePicker({ open, recents, rootDirectories, onClose, onOpenFile, }: FilePickerProps): React.JSX.Element | null;
11
+ export default function FilePicker({ open, recents, rootDirectories, embeddedFiles, onClose, onOpenFile, }: FilePickerProps): React.JSX.Element | null;
@@ -6,10 +6,13 @@ export interface LayoutActions {
6
6
  rootDirectories: string[];
7
7
  vscode: boolean;
8
8
  recents: string[];
9
+ wikiNoteCount?: number;
9
10
  dragActive: boolean;
10
11
  onFocusPane: (paneId: string) => void;
11
12
  onActivateTab: (paneId: string, tabId: string) => void;
12
13
  onCloseTab: (paneId: string, tabId: string) => void;
14
+ canClosePane: (paneId: string) => boolean;
15
+ onClosePane: (paneId: string) => void;
13
16
  onOpenPicker: (paneId: string) => void;
14
17
  onOpenFile: (paneId: string, file: string) => void;
15
18
  onSplitPane: (paneId: string, direction: 'horizontal' | 'vertical') => void;
@@ -21,6 +24,7 @@ export interface LayoutActions {
21
24
  onTabDragEnd: () => void;
22
25
  onTabDrop: (paneId: string, insertionIndex: number) => void;
23
26
  onPaneBodyDrop: (paneId: string, zone: DropZone) => void;
27
+ frameDocument?: (file: string) => string | undefined;
24
28
  }
25
29
  export declare function useLayoutActions(): LayoutActions;
26
30
  export default function LayoutView({ node, actions, }: {
@@ -3,8 +3,9 @@ export interface PreviewFrameProps {
3
3
  tabId: string;
4
4
  file: string;
5
5
  visible: boolean;
6
+ documentProvider?: (file: string) => string | undefined;
6
7
  onRegister: (tabId: string, file: string, iframe: HTMLIFrameElement | null, reload: (() => void) | null) => void;
7
8
  onBecameVisible: (tabId: string) => void;
8
9
  onFrameFocus: (tabId: string) => void;
9
10
  }
10
- export default function PreviewFrame({ tabId, file, visible, onRegister, onBecameVisible, onFrameFocus, }: PreviewFrameProps): React.JSX.Element;
11
+ export default function PreviewFrame({ tabId, file, visible, documentProvider, onRegister, onBecameVisible, onFrameFocus, }: PreviewFrameProps): React.JSX.Element | null;
@@ -3,12 +3,14 @@ import { Tab } from '../types';
3
3
  export interface TabStripProps {
4
4
  tabs: Tab[];
5
5
  activeTabId: string | null;
6
+ canClose?: boolean;
6
7
  onActivate: (tabId: string) => void;
7
8
  onClose: (tabId: string) => void;
9
+ onClosePane: () => void;
8
10
  onOpenPicker: () => void;
9
11
  onSplit: (direction: 'horizontal' | 'vertical') => void;
10
12
  onTabDragStart: (tabId: string) => void;
11
13
  onTabDragEnd: () => void;
12
14
  onTabDrop: (insertionIndex: number) => void;
13
15
  }
14
- export default function TabStrip({ tabs, activeTabId, onActivate, onClose, onOpenPicker, onSplit, onTabDragStart, onTabDragEnd, onTabDrop, }: TabStripProps): React.JSX.Element;
16
+ export default function TabStrip({ tabs, activeTabId, canClose, onActivate, onClose, onClosePane, onOpenPicker, onSplit, onTabDragStart, onTabDragEnd, onTabDrop, }: TabStripProps): React.JSX.Element;
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  export interface TitleBarProps {
3
3
  rootDirectories: string[];
4
4
  vscode: boolean;
5
+ shellTheme: 'light' | 'dark';
6
+ onToggleShellTheme: () => void;
5
7
  onOpenPicker: () => void;
6
8
  }
7
- export default function TitleBar({ rootDirectories, vscode, onOpenPicker, }: TitleBarProps): React.JSX.Element;
9
+ export default function TitleBar({ rootDirectories, vscode, shellTheme, onToggleShellTheme, onOpenPicker, }: TitleBarProps): React.JSX.Element;
@@ -3,7 +3,8 @@ export interface WelcomeProps {
3
3
  rootDirectories: string[];
4
4
  vscode: boolean;
5
5
  recents: string[];
6
+ wikiNoteCount?: number;
6
7
  onOpenFile: (file: string) => void;
7
8
  onOpenPicker: () => void;
8
9
  }
9
- export default function Welcome({ rootDirectories, vscode, recents, onOpenFile, onOpenPicker, }: WelcomeProps): React.JSX.Element;
10
+ export default function Welcome({ rootDirectories, vscode, recents, wikiNoteCount, onOpenFile, onOpenPicker, }: WelcomeProps): React.JSX.Element;
@@ -9,12 +9,76 @@ export interface ServerInfo {
9
9
  vscode: boolean;
10
10
  url: string;
11
11
  }
12
+ export interface WikiNoteUpdate {
13
+ markdown: string;
14
+ html: string;
15
+ tocHTML: string;
16
+ totalLineCount: number;
17
+ sourceUri: string;
18
+ sourceScheme: string;
19
+ id: string;
20
+ class: string;
21
+ jsAndCssFiles?: string[];
22
+ }
23
+ export interface WikiFileMeta {
24
+ path: string;
25
+ root: string;
26
+ title: string;
27
+ mtimeMs: number;
28
+ html: string;
29
+ update: WikiNoteUpdate;
30
+ }
31
+ export interface WikiThemesPayload {
32
+ preview: Record<string, string>;
33
+ codeBlock: Record<string, string>;
34
+ reveal: Record<string, string>;
35
+ codeBlockAuto: Record<string, string>;
36
+ build: {
37
+ preview: string;
38
+ codeBlock: string;
39
+ reveal: string;
40
+ };
41
+ }
42
+ export interface WikiGraphData {
43
+ hash: string;
44
+ nodes: Array<{
45
+ id: string;
46
+ label: string;
47
+ }>;
48
+ links: Array<{
49
+ source: string;
50
+ target: string;
51
+ }>;
52
+ }
53
+ export interface WikiBacklink {
54
+ note: {
55
+ notebookPath: {
56
+ scheme: string;
57
+ path: string;
58
+ };
59
+ filePath: string;
60
+ title: string;
61
+ config?: Record<string, unknown>;
62
+ };
63
+ references: Array<Record<string, unknown>>;
64
+ referenceHtmls: string[];
65
+ }
66
+ export interface WikiData {
67
+ rootDirectories: string[];
68
+ assets: Record<string, string>;
69
+ themes: WikiThemesPayload;
70
+ graph: Record<string, WikiGraphData>;
71
+ backlinks: Record<string, WikiBacklink[]>;
72
+ files: WikiFileMeta[];
73
+ }
12
74
  declare global {
13
75
  interface Window {
14
76
  __CROSSNOTE_SERVER__?: ServerInfo;
77
+ __CROSSNOTE_WIKI__?: WikiData;
15
78
  }
16
79
  }
17
80
  export declare function getServerInfo(): ServerInfo;
81
+ export declare function getWikiData(): WikiData | null;
18
82
  export declare function rootContaining(rootDirectories: string[], filePath: string): number;
19
83
  export declare function fetchFiles(): Promise<MarkdownFileInfo[]>;
20
84
  export declare function sendCommand(file: string, command: string, args: unknown[]): Promise<void>;
@@ -22,24 +86,20 @@ export declare function basename(filePath: string): string;
22
86
  export declare function dirname(filePath: string): string;
23
87
  export declare function resolveHref(rootDirectories: string[], sourceFile: string, href: string): string;
24
88
  export declare function isMarkdownPath(filePath: string): boolean;
89
+ export declare function sameServeFile(a: string, b: string): boolean;
25
90
  export declare function filePathToFilesUrl(rootDirectories: string[], absolutePath: string): string | null;
26
91
  export interface WebviewCommandMessage {
27
92
  command: string;
28
93
  args?: unknown[];
29
94
  }
95
+ export declare const GRAPH_VIEW_TAB_PREFIX = "__crossnote-graph-view__:";
96
+ export declare function graphTabFile(anchorFile: string): string;
97
+ export declare function isGraphTab(file: string): boolean;
98
+ export declare function graphAnchorFile(file: string): string;
30
99
  export interface WebviewFinishLoadingArgs {
31
100
  uri: string;
32
101
  systemColorScheme: 'light' | 'dark';
33
102
  }
34
- export interface UpdateHtmlPayload {
103
+ export interface UpdateHtmlPayload extends WikiNoteUpdate {
35
104
  command?: string;
36
- markdown: string;
37
- html: string;
38
- tocHTML: string;
39
- totalLineCount: number;
40
- sourceUri: string;
41
- sourceScheme: string;
42
- id: string;
43
- class: string;
44
- jsAndCssFiles?: string[];
45
105
  }
@@ -0,0 +1 @@
1
+ export declare function previewThemeMode(theme: string | undefined): 'light' | 'dark' | null;
@@ -0,0 +1,20 @@
1
+ import { WikiData, WikiFileMeta } from './api';
2
+ export interface WikiThemeSelection {
3
+ preview: string;
4
+ codeBlock: string;
5
+ reveal: string;
6
+ }
7
+ export declare function assembleWikiDocument(data: WikiData, file: WikiFileMeta, themes?: WikiThemeSelection): string;
8
+ export declare function readWikiThemeSelection(data: WikiData, storage: Pick<Storage, 'getItem'>): WikiThemeSelection | null;
9
+ export declare function writeWikiThemeSelection(data: WikiData, storage: Pick<Storage, 'setItem'>, selection: WikiThemeSelection): void;
10
+ export declare function wikiKeyOf(filePath: string): string;
11
+ export declare function createWikiIndex(data: WikiData): Map<string, WikiFileMeta>;
12
+ export declare function resolveWikiHref(data: WikiData, sourceKey: string, href: string): string;
13
+ export declare function wikiFileList(data: WikiData): Array<{
14
+ absolutePath: string;
15
+ relativePath: string;
16
+ mtimeMs: number;
17
+ rootPath: string;
18
+ }>;
19
+ export declare const WIKI_GRAPH_VIEW_ASSETS: readonly ["graph-view.js", "graph-view.css"];
20
+ export declare function assembleWikiGraphDocument(data: WikiData, anchorKey: string): string;
@@ -33,5 +33,9 @@ export declare function splitPane(node: LayoutNode, paneId: string, direction: '
33
33
  layout: LayoutNode;
34
34
  newPaneId: string;
35
35
  };
36
+ export declare function removePane(node: LayoutNode, paneId: string): {
37
+ layout: LayoutNode;
38
+ removed: boolean;
39
+ };
36
40
  export declare function moveTab(node: LayoutNode, sourcePaneId: string, tabId: string, targetPaneId: string, targetIndex: number | null): LayoutNode;
37
41
  export declare function resizeSplit(node: LayoutNode, splitId: string, childIndex: number, ratio: number): LayoutNode;
@@ -14,7 +14,7 @@ export declare function sleep(ms: number): Promise<void>;
14
14
  export declare function parseYAML(yaml?: string): JsonObject;
15
15
  export declare function setCrossnoteBuildDirectory(path: string): void;
16
16
  export declare function getCrossnoteBuildDirectory(): string;
17
- export declare function useExternalAddFileProtocolFunction(func: (filePath: string, vscodePreviewPanel?: vscode.WebviewPanel | null) => string): void;
17
+ export declare function useExternalAddFileProtocolFunction(func: ((filePath: string, vscodePreviewPanel?: vscode.WebviewPanel | null) => string) | null): () => void;
18
18
  export declare function addFileProtocol(filePath: string, vscodePreviewPanel?: vscode.WebviewPanel | null): string;
19
19
  export declare function removeFileProtocol(filePath: string): string;
20
20
  export { uploadImage } from './tools/image-uploader';
@@ -20,6 +20,7 @@ declare const PreviewContainer: import("unstated-next").Container<{
20
20
  isShowingTranslation: boolean;
21
21
  isVSCode: boolean;
22
22
  isVSCodeWebExtension: boolean;
23
+ isWiki: boolean;
23
24
  markdown: string;
24
25
  markdownEditorExpanded: boolean;
25
26
  notice: string | undefined;
@@ -2,3 +2,7 @@ export declare function getElementBackgroundColor(element: HTMLElement): string;
2
2
  export declare function isBackgroundColorLight(element: HTMLElement): boolean;
3
3
  export declare function copyTextToClipboard(text: string): void;
4
4
  export declare function copyBlobToClipboard(blob: Blob): void;
5
+ export declare function readLocalStorage(key: string): string | null;
6
+ export declare function writeLocalStorage(key: string, value: string): void;
7
+ export declare function readSessionStorage(key: string): string | null;
8
+ export declare function writeSessionStorage(key: string, value: string): void;
@@ -14,11 +14,23 @@ export interface WikiFileEntry {
14
14
  path: string;
15
15
  root: string;
16
16
  title: string;
17
+ mtimeMs: number;
17
18
  html: string;
19
+ update: {
20
+ markdown: string;
21
+ html: string;
22
+ tocHTML: string;
23
+ totalLineCount: number;
24
+ sourceUri: string;
25
+ sourceScheme: string;
26
+ id: string;
27
+ class: string;
28
+ jsAndCssFiles: string[];
29
+ };
18
30
  }
19
31
  export interface BuildWikiResult {
20
32
  html: string;
21
- files: Array<Pick<WikiFileEntry, 'path' | 'root' | 'title'>>;
33
+ files: Array<Pick<WikiFileEntry, 'path' | 'root' | 'title' | 'mtimeMs'>>;
22
34
  rootDirectories: string[];
23
35
  failures: Array<{
24
36
  path: string;
@@ -26,3 +38,39 @@ export interface BuildWikiResult {
26
38
  }>;
27
39
  }
28
40
  export declare function buildWiki(options: BuildWikiOptions): Promise<BuildWikiResult>;
41
+ export interface WikiGraphPayload {
42
+ hash: string;
43
+ nodes: Array<{
44
+ id: string;
45
+ label: string;
46
+ }>;
47
+ links: Array<{
48
+ source: string;
49
+ target: string;
50
+ }>;
51
+ }
52
+ export interface WikiBacklinkPayload {
53
+ note: {
54
+ notebookPath: {
55
+ scheme: string;
56
+ path: string;
57
+ };
58
+ filePath: string;
59
+ title: string;
60
+ config?: Record<string, unknown>;
61
+ };
62
+ references: Array<Record<string, unknown>>;
63
+ referenceHtmls: string[];
64
+ }
65
+ export interface WikiThemesPayload {
66
+ preview: Record<string, string>;
67
+ codeBlock: Record<string, string>;
68
+ reveal: Record<string, string>;
69
+ codeBlockAuto: Record<string, string>;
70
+ build: {
71
+ preview: string;
72
+ codeBlock: string;
73
+ reveal: string;
74
+ };
75
+ }
76
+ export declare function embedRemoteImages(html: string, cache: Map<string, string | null>): Promise<string>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};