colonynote 0.0.0 → 1.0.0-beta.4
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.
- package/LICENSE +21 -0
- package/README.md +125 -0
- package/README.zh.md +125 -0
- package/bin/colonynote.js +167 -0
- package/dist/client/assets/__vite-browser-external-BIHI7g3E.js +1 -0
- package/dist/client/assets/_basePickBy-DK2BKD5W.js +1 -0
- package/dist/client/assets/_baseUniq-BO8bKM1W.js +1 -0
- package/dist/client/assets/arc-Cl3xpn3n.js +1 -0
- package/dist/client/assets/architectureDiagram-2XIMDMQ5-Bm5yRSmN.js +36 -0
- package/dist/client/assets/blockDiagram-WCTKOSBZ-D-Tq_aWr.js +132 -0
- package/dist/client/assets/c4Diagram-IC4MRINW-DMKph0TK.js +10 -0
- package/dist/client/assets/channel-CwphgqEx.js +1 -0
- package/dist/client/assets/chunk-4BX2VUAB-D5bHwYjW.js +1 -0
- package/dist/client/assets/chunk-55IACEB6-CAMatJwc.js +1 -0
- package/dist/client/assets/chunk-FMBD7UC4-I0pTD7LH.js +15 -0
- package/dist/client/assets/chunk-JSJVCQXG-DKFHhgC1.js +1 -0
- package/dist/client/assets/chunk-KX2RTZJC-BezIvtPy.js +1 -0
- package/dist/client/assets/chunk-NQ4KR5QH-fs8KRCok.js +220 -0
- package/dist/client/assets/chunk-QZHKN3VN-D_RBzrHh.js +1 -0
- package/dist/client/assets/chunk-WL4C6EOR-FHQiiE7L.js +189 -0
- package/dist/client/assets/classDiagram-VBA2DB6C-CXOHxcAr.js +1 -0
- package/dist/client/assets/classDiagram-v2-RAHNMMFH-CXOHxcAr.js +1 -0
- package/dist/client/assets/clone-3xQZ-KGT.js +1 -0
- package/dist/client/assets/cose-bilkent-S5V4N54A-BJq0I4zj.js +1 -0
- package/dist/client/assets/cytoscape.esm-BQaXIfA_.js +331 -0
- package/dist/client/assets/dagre-KLK3FWXG-DK0i7O07.js +4 -0
- package/dist/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/client/assets/diagram-E7M64L7V-Cidbuw8R.js +24 -0
- package/dist/client/assets/diagram-IFDJBPK2-Cgki5RHT.js +43 -0
- package/dist/client/assets/diagram-P4PSJMXO-DWzht2JH.js +24 -0
- package/dist/client/assets/erDiagram-INFDFZHY-HZxUbaWK.js +70 -0
- package/dist/client/assets/flowDiagram-PKNHOUZH-DiyMBQ96.js +162 -0
- package/dist/client/assets/ganttDiagram-A5KZAMGK-CNbqZLMK.js +292 -0
- package/dist/client/assets/gitGraphDiagram-K3NZZRJ6-B9-xoxGX.js +65 -0
- package/dist/client/assets/graph-B6oS1BDs.js +1 -0
- package/dist/client/assets/index-DERAej96.js +690 -0
- package/dist/client/assets/index-kembRYBc.css +1 -0
- package/dist/client/assets/infoDiagram-LFFYTUFH-DUpQBK9H.js +2 -0
- package/dist/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/client/assets/ishikawaDiagram-PHBUUO56-D-jjjs4Y.js +70 -0
- package/dist/client/assets/journeyDiagram-4ABVD52K-CPeLx61F.js +139 -0
- package/dist/client/assets/kanban-definition-K7BYSVSG-B_Fq0mUx.js +89 -0
- package/dist/client/assets/katex-B1X10hvy.js +261 -0
- package/dist/client/assets/layout-BZwEH1ta.js +1 -0
- package/dist/client/assets/linear-eMo4U_q6.js +1 -0
- package/dist/client/assets/mindmap-definition-YRQLILUH-DWAX8Exm.js +68 -0
- package/dist/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/client/assets/pieDiagram-SKSYHLDU-BCR81orb.js +30 -0
- package/dist/client/assets/quadrantDiagram-337W2JSQ-BHO__chl.js +7 -0
- package/dist/client/assets/requirementDiagram-Z7DCOOCP-D00SKztY.js +73 -0
- package/dist/client/assets/sankeyDiagram-WA2Y5GQK-Dv8IrDxh.js +10 -0
- package/dist/client/assets/sequenceDiagram-2WXFIKYE-CooKHBCx.js +145 -0
- package/dist/client/assets/stateDiagram-RAJIS63D-oC1ETpHy.js +1 -0
- package/dist/client/assets/stateDiagram-v2-FVOUBMTO-CA6bryFe.js +1 -0
- package/dist/client/assets/timeline-definition-YZTLITO2-C4yotI5m.js +61 -0
- package/dist/client/assets/treemap-KZPCXAKY-BM6sEdsl.js +162 -0
- package/dist/client/assets/vennDiagram-LZ73GAT5-D42K5tBK.js +34 -0
- package/dist/client/assets/xychartDiagram-JWTSCODW-2-1QVFgt.js +7 -0
- package/dist/client/index.html +22 -0
- package/dist/config.js +83 -0
- package/dist/server/api.js +249 -0
- package/dist/server/app.js +14 -0
- package/dist/server/index.js +78 -0
- package/dist/server/watcher.js +37 -0
- package/package.json +101 -10
- package/index.js +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { serve } from '@hono/node-server';
|
|
2
|
+
import { Hono } from 'hono';
|
|
3
|
+
import { cors } from 'hono/cors';
|
|
4
|
+
import { createFileRouter } from './api.js';
|
|
5
|
+
import { loadConfig } from '../config.js';
|
|
6
|
+
import { setupWatcher } from './watcher.js';
|
|
7
|
+
import { WebSocketServer, WebSocket } from 'ws';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
async function main() {
|
|
11
|
+
const config = await loadConfig();
|
|
12
|
+
const app = new Hono();
|
|
13
|
+
app.use('*', cors());
|
|
14
|
+
const fileRouter = createFileRouter(config);
|
|
15
|
+
app.route('/api/files', fileRouter);
|
|
16
|
+
app.get('/assets/*', async (c) => {
|
|
17
|
+
const filePath = c.req.path.replace('/assets', '');
|
|
18
|
+
const fullPath = path.join(new URL('../client/assets', import.meta.url).pathname, filePath);
|
|
19
|
+
try {
|
|
20
|
+
const content = fs.readFileSync(fullPath);
|
|
21
|
+
const ext = path.extname(filePath);
|
|
22
|
+
const contentType = ext === '.js' ? 'application/javascript' : ext === '.css' ? 'text/css' : 'text/plain';
|
|
23
|
+
return new Response(content, { headers: { 'Content-Type': contentType } });
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return c.notFound();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
app.get('*', async (c) => {
|
|
30
|
+
const indexPath = path.join(new URL('../client', import.meta.url).pathname, 'index.html');
|
|
31
|
+
try {
|
|
32
|
+
const content = fs.readFileSync(indexPath, 'utf-8');
|
|
33
|
+
return new Response(content, {
|
|
34
|
+
headers: { 'Content-Type': 'text/html' },
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return c.notFound();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const server = serve({
|
|
42
|
+
fetch: app.fetch,
|
|
43
|
+
port: config.port,
|
|
44
|
+
hostname: config.host,
|
|
45
|
+
});
|
|
46
|
+
const clients = new Set();
|
|
47
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
48
|
+
wss.on('connection', (ws) => {
|
|
49
|
+
clients.add(ws);
|
|
50
|
+
ws.on('close', () => clients.delete(ws));
|
|
51
|
+
});
|
|
52
|
+
server.on('upgrade', (request, socket, head) => {
|
|
53
|
+
if (request.url === '/ws') {
|
|
54
|
+
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
55
|
+
wss.emit('connection', ws, request);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
setupWatcher(config, {
|
|
60
|
+
onFileChange: (event, filePath) => {
|
|
61
|
+
const relativePath = filePath.replace(config.root, '');
|
|
62
|
+
const message = JSON.stringify({ type: 'file:change', event, path: relativePath });
|
|
63
|
+
clients.forEach((client) => {
|
|
64
|
+
if (client.readyState === WebSocket.OPEN) {
|
|
65
|
+
client.send(message);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
console.log(`\n ColonyDoc is running!\n`);
|
|
71
|
+
console.log(` Local: http://localhost:${config.port}`);
|
|
72
|
+
console.log(` Network: http://${config.host}:${config.port}`);
|
|
73
|
+
console.log(` Root: ${config.root}\n`);
|
|
74
|
+
}
|
|
75
|
+
main().catch((e) => {
|
|
76
|
+
console.error('Failed to start:', e);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import chokidar from 'chokidar';
|
|
2
|
+
export function setupWatcher(config, callbacks) {
|
|
3
|
+
const watcher = chokidar.watch(config.root, {
|
|
4
|
+
ignored: (path) => {
|
|
5
|
+
if (!config.showHiddenFiles && path.includes('/.') || path.startsWith('.'))
|
|
6
|
+
return true;
|
|
7
|
+
const ext = path.split('.').pop()?.toLowerCase() || '';
|
|
8
|
+
if (ext && !config.allowedExtensions.includes('.' + ext) && !path.includes('/')) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
},
|
|
13
|
+
persistent: true,
|
|
14
|
+
ignoreInitial: true,
|
|
15
|
+
depth: 99,
|
|
16
|
+
});
|
|
17
|
+
watcher
|
|
18
|
+
.on('add', (path) => {
|
|
19
|
+
if (config.allowedExtensions.some(ext => path.endsWith(ext))) {
|
|
20
|
+
callbacks.onFileChange('add', path);
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
.on('change', (path) => {
|
|
24
|
+
if (config.allowedExtensions.some(ext => path.endsWith(ext))) {
|
|
25
|
+
callbacks.onFileChange('change', path);
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
.on('unlink', (path) => {
|
|
29
|
+
if (config.allowedExtensions.some(ext => path.endsWith(ext))) {
|
|
30
|
+
callbacks.onFileChange('unlink', path);
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
.on('addDir', (path) => callbacks.onFileChange('addDir', path))
|
|
34
|
+
.on('unlinkDir', (path) => callbacks.onFileChange('unlinkDir', path))
|
|
35
|
+
.on('error', (error) => console.error('Watcher error:', error));
|
|
36
|
+
return watcher;
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,104 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "colonynote",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=18"
|
|
6
|
+
},
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"description": "Markdown online editor with real-time preview and LaTeX support",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"markdown",
|
|
11
|
+
"editor",
|
|
12
|
+
"latex",
|
|
13
|
+
"real-time",
|
|
14
|
+
"cli",
|
|
15
|
+
"document"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "岳晓亮 <hi@yuexiaoliang.com>",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/opencolony/note.git"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"bin": {
|
|
28
|
+
"colonynote": "./bin/colonynote.js"
|
|
8
29
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
30
|
+
"files": [
|
|
31
|
+
"bin",
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@hono/node-server": "^1.19.11",
|
|
36
|
+
"@milkdown/crepe": "^7.19.2",
|
|
37
|
+
"@milkdown/plugin-listener": "^7.19.2",
|
|
38
|
+
"@milkdown/prose": "^7.19.2",
|
|
39
|
+
"@milkdown/react": "^7.19.2",
|
|
40
|
+
"@milkdown/utils": "^7.19.2",
|
|
41
|
+
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
42
|
+
"@radix-ui/react-collapsible": "^1.1.12",
|
|
43
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
44
|
+
"@radix-ui/react-popover": "^1.1.15",
|
|
45
|
+
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
46
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
47
|
+
"@tailwindcss/typography": "^0.5.19",
|
|
48
|
+
"@tailwindcss/vite": "^4.2.2",
|
|
49
|
+
"@tiptap/extension-code-block-lowlight": "^3.20.4",
|
|
50
|
+
"@tiptap/extension-highlight": "^3.20.4",
|
|
51
|
+
"@tiptap/extension-image": "^3.20.4",
|
|
52
|
+
"@tiptap/extension-link": "^3.20.4",
|
|
53
|
+
"@tiptap/extension-placeholder": "^3.20.4",
|
|
54
|
+
"@tiptap/extension-table": "^3.20.4",
|
|
55
|
+
"@tiptap/extension-table-cell": "^3.20.4",
|
|
56
|
+
"@tiptap/extension-table-header": "^3.20.4",
|
|
57
|
+
"@tiptap/extension-table-row": "^3.20.4",
|
|
58
|
+
"@tiptap/extension-task-item": "^3.20.4",
|
|
59
|
+
"@tiptap/extension-task-list": "^3.20.4",
|
|
60
|
+
"@tiptap/extension-typography": "^3.20.4",
|
|
61
|
+
"@tiptap/extension-underline": "^3.20.4",
|
|
62
|
+
"@tiptap/pm": "^3.20.4",
|
|
63
|
+
"@tiptap/react": "^3.20.4",
|
|
64
|
+
"@tiptap/starter-kit": "^3.20.4",
|
|
65
|
+
"chokidar": "^4.0.3",
|
|
66
|
+
"class-variance-authority": "^0.7.1",
|
|
67
|
+
"clsx": "^2.1.1",
|
|
68
|
+
"flexsearch": "^0.8.212",
|
|
69
|
+
"hono": "^4.12.9",
|
|
70
|
+
"katex": "^0.16.40",
|
|
71
|
+
"lowlight": "^3.3.0",
|
|
72
|
+
"lucide-react": "^0.577.0",
|
|
73
|
+
"markdown-extensions": "^2.0.0",
|
|
74
|
+
"mermaid": "^11.13.0",
|
|
75
|
+
"react": "^18.3.1",
|
|
76
|
+
"react-dom": "^18.3.1",
|
|
77
|
+
"react-zoom-pan-pinch": "^3.7.0",
|
|
78
|
+
"tailwind-merge": "^3.5.0",
|
|
79
|
+
"tailwindcss": "^4.2.2",
|
|
80
|
+
"tiptap-markdown": "^0.9.0",
|
|
81
|
+
"ws": "^8.20.0"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@types/node": "^22.19.15",
|
|
85
|
+
"@types/react": "^18.3.28",
|
|
86
|
+
"@types/react-dom": "^18.3.7",
|
|
87
|
+
"@types/ws": "^8.18.1",
|
|
88
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
89
|
+
"bumpp": "^11.0.1",
|
|
90
|
+
"tsx": "^4.21.0",
|
|
91
|
+
"typescript": "^5.9.3",
|
|
92
|
+
"vite": "^6.4.1"
|
|
93
|
+
},
|
|
94
|
+
"scripts": {
|
|
95
|
+
"dev": "tsx src/dev.ts",
|
|
96
|
+
"dev:frontend": "vite",
|
|
97
|
+
"dev:backend": "tsx src/server/index.ts",
|
|
98
|
+
"build": "vite build && tsc -p tsconfig.server.json",
|
|
99
|
+
"preview": "vite preview",
|
|
100
|
+
"start": "node dist/server/index.js",
|
|
101
|
+
"typecheck": "tsc --noEmit",
|
|
102
|
+
"release": "bumpp"
|
|
103
|
+
}
|
|
104
|
+
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('hello')
|