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
@@ -127,6 +127,7 @@ export interface WebviewConfig extends Partial<NotebookConfig> {
127
127
  imageUploader?: ImageUploader;
128
128
  isShowingTranslation?: boolean;
129
129
  locale?: string;
130
+ isServerApp?: boolean;
130
131
  }
131
132
  export declare enum PreviewMode {
132
133
  SinglePreview = "Single Preview",
@@ -0,0 +1,5 @@
1
+ import { NotebookConfig } from '../notebook';
2
+ export declare function detectVSCodeSettingsPath(explicitPath?: string): string | null;
3
+ export declare function loadVSCodeConfig(settingsPath: string | null): Promise<Partial<NotebookConfig> | null>;
4
+ export declare function updateVSCodeSetting(settingsPath: string, key: string, value: unknown): Promise<void>;
5
+ export declare function updateGlobalConfigKey(globalConfigDirectory: string, key: string, value: unknown): Promise<void>;
@@ -0,0 +1,27 @@
1
+ import { Notebook, NotebookConfig } from '../notebook';
2
+ export declare function getGlobalConfigDirectory(): string;
3
+ export interface ServerConfigOptions {
4
+ rootDirectory: string;
5
+ vscode?: boolean;
6
+ vscodeSettingsPath?: string;
7
+ globalConfigDirectory?: string;
8
+ }
9
+ export interface ServerConfigContext {
10
+ rootDirectory: string;
11
+ vscode: boolean;
12
+ globalConfigDirectory: string;
13
+ vscodeSettingsPath: string | null;
14
+ }
15
+ export declare function createConfigContext(options: ServerConfigOptions): Promise<ServerConfigContext>;
16
+ export declare function loadServerConfig(context: ServerConfigContext): Promise<Partial<NotebookConfig>>;
17
+ export declare function updateServerConfigKey(context: ServerConfigContext, key: string, value: unknown): Promise<Partial<NotebookConfig>>;
18
+ export interface DirectoryNotebooks {
19
+ rootDirectories: string[];
20
+ configContexts: ServerConfigContext[];
21
+ notebooks: Notebook[];
22
+ }
23
+ export declare function createNotebooksForDirectories(directories: string[], options?: {
24
+ vscode?: boolean;
25
+ vscodeSettingsPath?: string;
26
+ globalConfigDirectory?: string;
27
+ }): Promise<DirectoryNotebooks>;
@@ -0,0 +1,18 @@
1
+ export interface ServeOptions {
2
+ directories: string[];
3
+ port?: number;
4
+ host?: string;
5
+ vscode?: boolean;
6
+ vscodeSettingsPath?: string;
7
+ crossnoteBuildDirectory?: string;
8
+ globalConfigDirectory?: string;
9
+ }
10
+ export interface ServeServer {
11
+ url: string;
12
+ port: number;
13
+ host: string;
14
+ rootDirectories: string[];
15
+ rootDirectory: string;
16
+ close(): Promise<void>;
17
+ }
18
+ export declare function startServeServer(options: ServeOptions): Promise<ServeServer>;
@@ -0,0 +1,11 @@
1
+ export declare const MARKDOWN_EXTENSIONS: string[];
2
+ export declare function isMarkdownFile(filePath: string): boolean;
3
+ export declare function encodePathSegments(relativePath: string): string;
4
+ export declare function isPathWithinRoot(root: string, candidate: string): boolean;
5
+ export interface MarkdownFileInfo {
6
+ relativePath: string;
7
+ absolutePath: string;
8
+ mtimeMs: number;
9
+ rootPath?: string;
10
+ }
11
+ export declare function listMarkdownFiles(rootDirectory: string, limit?: number): Promise<MarkdownFileInfo[]>;
@@ -0,0 +1,14 @@
1
+ import * as http from 'http';
2
+ export interface SSEEvent {
3
+ type: string;
4
+ [key: string]: unknown;
5
+ }
6
+ export declare class SSEHub {
7
+ private clients;
8
+ private heartbeat;
9
+ addClient(response: http.ServerResponse): void;
10
+ broadcast(event: SSEEvent): void;
11
+ private broadcastRaw;
12
+ get clientCount(): number;
13
+ dispose(): void;
14
+ }
@@ -0,0 +1,4 @@
1
+ import * as http from 'http';
2
+ export declare const BASE_SECURITY_HEADERS: Record<string, string>;
3
+ export declare function resolveMountedFile(mountRoots: string[], urlPrefix: string, urlPath: string, preferredRootIndex: number | null): string | null;
4
+ export declare function serveFileFromPath(response: http.ServerResponse, filePath: string): void;
@@ -0,0 +1,18 @@
1
+ export interface FileChange {
2
+ absolutePath: string;
3
+ type: 'changed' | 'deleted';
4
+ }
5
+ export declare class MarkdownWatcher {
6
+ private readonly rootDirectory;
7
+ private readonly onChange;
8
+ private readonly pollIntervalMs;
9
+ private watcher;
10
+ private pollTimer;
11
+ private knownFiles;
12
+ private pendingEvents;
13
+ constructor(rootDirectory: string, onChange: (change: FileChange) => void, pollIntervalMs?: number);
14
+ start(): Promise<void>;
15
+ private poll;
16
+ private emitDebounced;
17
+ close(): void;
18
+ }
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export default function App(): React.JSX.Element | null;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface FilePickerProps {
3
+ open: boolean;
4
+ recents: string[];
5
+ rootDirectories: string[];
6
+ onClose: () => void;
7
+ onOpenFile: (file: string) => void;
8
+ }
9
+ export default function FilePicker({ open, recents, rootDirectories, onClose, onOpenFile, }: FilePickerProps): React.JSX.Element | null;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { LayoutNode } from '../types';
3
+ export type DropZone = 'left' | 'right' | 'top' | 'bottom' | 'center';
4
+ export interface LayoutActions {
5
+ activePaneId: string;
6
+ rootDirectories: string[];
7
+ vscode: boolean;
8
+ recents: string[];
9
+ dragActive: boolean;
10
+ onFocusPane: (paneId: string) => void;
11
+ onActivateTab: (paneId: string, tabId: string) => void;
12
+ onCloseTab: (paneId: string, tabId: string) => void;
13
+ onOpenPicker: (paneId: string) => void;
14
+ onOpenFile: (paneId: string, file: string) => void;
15
+ onSplitPane: (paneId: string, direction: 'horizontal' | 'vertical') => void;
16
+ onResizeSplit: (splitId: string, childIndex: number, ratio: number) => void;
17
+ registerFrame: (tabId: string, file: string, iframe: HTMLIFrameElement | null, reload: (() => void) | null) => void;
18
+ onFrameVisible: (tabId: string) => void;
19
+ onFrameFocus: (tabId: string) => void;
20
+ onTabDragStart: (paneId: string, tabId: string) => void;
21
+ onTabDragEnd: () => void;
22
+ onTabDrop: (paneId: string, insertionIndex: number) => void;
23
+ onPaneBodyDrop: (paneId: string, zone: DropZone) => void;
24
+ }
25
+ export declare function useLayoutActions(): LayoutActions;
26
+ export default function LayoutView({ node, actions, }: {
27
+ node: LayoutNode;
28
+ actions: LayoutActions;
29
+ }): React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export interface PreviewFrameProps {
3
+ tabId: string;
4
+ file: string;
5
+ visible: boolean;
6
+ onRegister: (tabId: string, file: string, iframe: HTMLIFrameElement | null, reload: (() => void) | null) => void;
7
+ onBecameVisible: (tabId: string) => void;
8
+ onFrameFocus: (tabId: string) => void;
9
+ }
10
+ export default function PreviewFrame({ tabId, file, visible, onRegister, onBecameVisible, onFrameFocus, }: PreviewFrameProps): React.JSX.Element;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { Tab } from '../types';
3
+ export interface TabStripProps {
4
+ tabs: Tab[];
5
+ activeTabId: string | null;
6
+ onActivate: (tabId: string) => void;
7
+ onClose: (tabId: string) => void;
8
+ onOpenPicker: () => void;
9
+ onSplit: (direction: 'horizontal' | 'vertical') => void;
10
+ onTabDragStart: (tabId: string) => void;
11
+ onTabDragEnd: () => void;
12
+ onTabDrop: (insertionIndex: number) => void;
13
+ }
14
+ export default function TabStrip({ tabs, activeTabId, onActivate, onClose, onOpenPicker, onSplit, onTabDragStart, onTabDragEnd, onTabDrop, }: TabStripProps): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export interface TitleBarProps {
3
+ rootDirectories: string[];
4
+ vscode: boolean;
5
+ onOpenPicker: () => void;
6
+ }
7
+ export default function TitleBar({ rootDirectories, vscode, onOpenPicker, }: TitleBarProps): React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface WelcomeProps {
3
+ rootDirectories: string[];
4
+ vscode: boolean;
5
+ recents: string[];
6
+ onOpenFile: (file: string) => void;
7
+ onOpenPicker: () => void;
8
+ }
9
+ export default function Welcome({ rootDirectories, vscode, recents, onOpenFile, onOpenPicker, }: WelcomeProps): React.JSX.Element;
@@ -0,0 +1,45 @@
1
+ export interface MarkdownFileInfo {
2
+ relativePath: string;
3
+ absolutePath: string;
4
+ mtimeMs: number;
5
+ rootPath?: string;
6
+ }
7
+ export interface ServerInfo {
8
+ rootDirectories: string[];
9
+ vscode: boolean;
10
+ url: string;
11
+ }
12
+ declare global {
13
+ interface Window {
14
+ __CROSSNOTE_SERVER__?: ServerInfo;
15
+ }
16
+ }
17
+ export declare function getServerInfo(): ServerInfo;
18
+ export declare function rootContaining(rootDirectories: string[], filePath: string): number;
19
+ export declare function fetchFiles(): Promise<MarkdownFileInfo[]>;
20
+ export declare function sendCommand(file: string, command: string, args: unknown[]): Promise<void>;
21
+ export declare function basename(filePath: string): string;
22
+ export declare function dirname(filePath: string): string;
23
+ export declare function resolveHref(rootDirectories: string[], sourceFile: string, href: string): string;
24
+ export declare function isMarkdownPath(filePath: string): boolean;
25
+ export declare function filePathToFilesUrl(rootDirectories: string[], absolutePath: string): string | null;
26
+ export interface WebviewCommandMessage {
27
+ command: string;
28
+ args?: unknown[];
29
+ }
30
+ export interface WebviewFinishLoadingArgs {
31
+ uri: string;
32
+ systemColorScheme: 'light' | 'dark';
33
+ }
34
+ export interface UpdateHtmlPayload {
35
+ 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
+ }
@@ -0,0 +1,16 @@
1
+ export interface FuzzyResult {
2
+ absolutePath: string;
3
+ relativePath: string;
4
+ score: number;
5
+ }
6
+ export interface IndexedFile {
7
+ absolutePath: string;
8
+ relativePath: string;
9
+ dir: string;
10
+ base: string;
11
+ }
12
+ export declare function indexFiles(files: {
13
+ absolutePath: string;
14
+ relativePath: string;
15
+ }[]): IndexedFile[];
16
+ export declare function rankFiles(query: string, indexed: IndexedFile[]): FuzzyResult[] | null;
@@ -0,0 +1 @@
1
+ import './index.css';
@@ -0,0 +1,37 @@
1
+ export interface Tab {
2
+ id: string;
3
+ file: string;
4
+ }
5
+ export interface PaneNode {
6
+ kind: 'pane';
7
+ id: string;
8
+ tabs: Tab[];
9
+ activeTabId: string | null;
10
+ }
11
+ export interface SplitNode {
12
+ kind: 'split';
13
+ id: string;
14
+ direction: 'horizontal' | 'vertical';
15
+ sizes: number[];
16
+ children: LayoutNode[];
17
+ }
18
+ export type LayoutNode = PaneNode | SplitNode;
19
+ export interface PersistedWorkspace {
20
+ layout: LayoutNode;
21
+ activePaneId: string;
22
+ recents: string[];
23
+ }
24
+ export declare function createId(prefix: string): string;
25
+ export declare function createPane(): PaneNode;
26
+ export declare function findPane(node: LayoutNode, paneId: string): PaneNode | null;
27
+ export declare function listPaneIds(node: LayoutNode): string[];
28
+ export declare function mapPanes(node: LayoutNode, map: (pane: PaneNode) => PaneNode): LayoutNode;
29
+ export declare function openFileInPane(node: LayoutNode, paneId: string, file: string): LayoutNode;
30
+ export declare function closeTabInPane(node: LayoutNode, paneId: string, tabId: string): LayoutNode;
31
+ export declare function closeFileEverywhere(node: LayoutNode, file: string): LayoutNode;
32
+ export declare function splitPane(node: LayoutNode, paneId: string, direction: 'horizontal' | 'vertical', position?: 'before' | 'after'): {
33
+ layout: LayoutNode;
34
+ newPaneId: string;
35
+ };
36
+ export declare function moveTab(node: LayoutNode, sourcePaneId: string, tabId: string, targetPaneId: string, targetIndex: number | null): LayoutNode;
37
+ export declare function resizeSplit(node: LayoutNode, splitId: string, childIndex: number, ratio: number): LayoutNode;
@@ -22,6 +22,7 @@ declare const PreviewContainer: import("unstated-next").Container<{
22
22
  isVSCodeWebExtension: boolean;
23
23
  markdown: string;
24
24
  markdownEditorExpanded: boolean;
25
+ notice: string | undefined;
25
26
  postMessage: (command: string, args?: unknown[]) => void;
26
27
  previewElement: import("react").RefObject<HTMLDivElement>;
27
28
  previewSyncSource: () => void;
@@ -29,6 +30,7 @@ declare const PreviewContainer: import("unstated-next").Container<{
29
30
  setHighlightElementBeingEdited: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>;
30
31
  setIsMouseOverPreview: import("react").Dispatch<import("react").SetStateAction<boolean>>;
31
32
  setMarkdownEditorExpanded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
33
+ setNotice: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
32
34
  setShowBacklinks: import("react").Dispatch<import("react").SetStateAction<boolean>>;
33
35
  setShowImageHelper: import("react").Dispatch<import("react").SetStateAction<boolean>>;
34
36
  showBacklinks: boolean;
@@ -0,0 +1,28 @@
1
+ export interface BuildWikiOptions {
2
+ directories: string[];
3
+ vscode?: boolean;
4
+ vscodeSettingsPath?: string;
5
+ globalConfigDirectory?: string;
6
+ crossnoteBuildDirectory?: string;
7
+ onProgress?: (info: {
8
+ rendered: number;
9
+ total: number;
10
+ root: string;
11
+ }) => void;
12
+ }
13
+ export interface WikiFileEntry {
14
+ path: string;
15
+ root: string;
16
+ title: string;
17
+ html: string;
18
+ }
19
+ export interface BuildWikiResult {
20
+ html: string;
21
+ files: Array<Pick<WikiFileEntry, 'path' | 'root' | 'title'>>;
22
+ rootDirectories: string[];
23
+ failures: Array<{
24
+ path: string;
25
+ error: string;
26
+ }>;
27
+ }
28
+ export declare function buildWiki(options: BuildWikiOptions): Promise<BuildWikiResult>;
@@ -0,0 +1,17 @@
1
+ import './wiki.css';
2
+ interface WikiFileMeta {
3
+ path: string;
4
+ root: string;
5
+ title: string;
6
+ html: string;
7
+ }
8
+ interface WikiData {
9
+ rootDirectories: string[];
10
+ files: WikiFileMeta[];
11
+ }
12
+ declare global {
13
+ interface Window {
14
+ __CROSSNOTE_WIKI__?: WikiData;
15
+ }
16
+ }
17
+ export {};
@@ -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 {};
@@ -0,0 +1 @@
1
+ export {};