@samba425/diagramforge-react 0.1.0

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.
@@ -0,0 +1,191 @@
1
+ import { applySourceToCanvas } from '../services/sourceEditor';
2
+ import { ArrowStyle } from '../types';
3
+ import { buildShareUrl } from '../services/share/urlShare';
4
+ import { Camera } from '../types';
5
+ import { createEdge } from '../models/factory';
6
+ import { createLayer } from '../models/factory';
7
+ import { createPage } from '../models/factory';
8
+ import { createProject } from '../models/factory';
9
+ import { createShape } from '../models/factory';
10
+ import { CSSProperties } from 'react';
11
+ import { decodeShareHash } from '../services/share/urlShare';
12
+ import { DIAGRAM_TEMPLATES } from '../templates';
13
+ import { DiagramFile } from '../services/project/fileFormat';
14
+ import { DiagramTemplate } from '../templates';
15
+ import { Edge } from '../types';
16
+ import { EdgeEndpoint } from '../types';
17
+ import { EdgeRouter } from '../types';
18
+ import { encodeShareHash } from '../services/share/urlShare';
19
+ import { ExportFormat } from '../services/export';
20
+ import { exportJson } from '../services/export';
21
+ import { exportPdf } from '../services/export';
22
+ import { exportPng } from '../services/export';
23
+ import { exportSvg } from '../services/export';
24
+ import { exportZip } from '../services/export';
25
+ import { FILE_SIGNATURE } from '../services/project/fileFormat';
26
+ import { Layer } from '../types';
27
+ import { loadTemplate } from '../templates';
28
+ import { Page } from '../types';
29
+ import { parseProject } from '../services/project/fileFormat';
30
+ import { Plugin as Plugin_2 } from '../plugins/types';
31
+ import { pluginManager } from '../plugins/registry';
32
+ import { Point } from '../types';
33
+ import { Project } from '../types';
34
+ import { projectToSourceText } from '../services/sourceEditor';
35
+ import { RasterExportOptions } from '../services/export';
36
+ import { Rect } from '../types';
37
+ import { serializeProject } from '../services/project/fileFormat';
38
+ import { Shape } from '../types';
39
+ import { ShareLoadResult } from '../services/share/urlShare';
40
+ import { SourceFormat } from '../services/sourceEditor';
41
+ import { ThemeMode } from '../types';
42
+ import { ToolId } from '../types';
43
+
44
+ export { applySourceToCanvas }
45
+
46
+ export { ArrowStyle }
47
+
48
+ export { buildShareUrl }
49
+
50
+ export { Camera }
51
+
52
+ export { createEdge }
53
+
54
+ export { createLayer }
55
+
56
+ export { createPage }
57
+
58
+ export { createProject }
59
+
60
+ export { createShape }
61
+
62
+ export { decodeShareHash }
63
+
64
+ export { DIAGRAM_TEMPLATES }
65
+
66
+ /**
67
+ * Full DiagramForge editor as a React component.
68
+ *
69
+ * @example
70
+ * ```tsx
71
+ * import { DiagramEditor } from '@samba425/diagramforge-react';
72
+ * import '@samba425/diagramforge-react/styles.css';
73
+ *
74
+ * export function Page() {
75
+ * return (
76
+ * <DiagramEditor
77
+ * height="80vh"
78
+ * onChange={(project) => console.log('saved', project.id)}
79
+ * />
80
+ * );
81
+ * }
82
+ * ```
83
+ */
84
+ export declare function DiagramEditor({ initialProject, onChange, readOnly, apiBaseUrl, features, themeMode, height, width, style, className, standalone, }: DiagramEditorProps): React.JSX.Element;
85
+
86
+ /** Feature flags for embedded / standalone editor instances. */
87
+ export declare interface DiagramEditorFeatures {
88
+ /** Show AI generation panel. Default: true. */
89
+ ai?: boolean;
90
+ /** Enable F5 presentation mode. Default: true. */
91
+ presentation?: boolean;
92
+ /** JSON / YAML / Mermaid source editor. Default: true. */
93
+ sourceEditor?: boolean;
94
+ /** Canvas minimap. Default: true. */
95
+ minimap?: boolean;
96
+ /** Welcome / recovery dialog on startup. Default: false in embed, true in standalone. */
97
+ welcome?: boolean;
98
+ /** Autosave to IndexedDB. Default: false in embed, true in standalone. */
99
+ persistence?: boolean;
100
+ }
101
+
102
+ /** Props for {@link DiagramEditor}. */
103
+ export declare interface DiagramEditorProps {
104
+ /** Initial diagram document. Updates when the prop reference changes. */
105
+ initialProject?: Project;
106
+ /** Called whenever the document changes (debounced by React batching). */
107
+ onChange?: (project: Project) => void;
108
+ /** View-only mode — pan/zoom only. */
109
+ readOnly?: boolean;
110
+ /** Backend base URL for AI generation (overrides `VITE_API_BASE_URL`). */
111
+ apiBaseUrl?: string;
112
+ /** Feature toggles. Unlisted features default to enabled except welcome/persistence in embed mode. */
113
+ features?: DiagramEditorFeatures;
114
+ /** Color theme. Default: `system`. */
115
+ themeMode?: ThemeMode;
116
+ /** Container height. Default: `100%`. */
117
+ height?: CSSProperties['height'];
118
+ /** Container width. Default: `100%`. */
119
+ width?: CSSProperties['width'];
120
+ /** Additional wrapper styles. */
121
+ style?: CSSProperties;
122
+ /** Optional CSS class on the root wrapper. */
123
+ className?: string;
124
+ /**
125
+ * Standalone app mode — enables welcome dialog and IndexedDB autosave.
126
+ * Used by the first-party SPA; embed consumers usually leave this false.
127
+ */
128
+ standalone?: boolean;
129
+ }
130
+
131
+ export { DiagramFile }
132
+
133
+ export { DiagramTemplate }
134
+
135
+ export { Edge }
136
+
137
+ export { EdgeEndpoint }
138
+
139
+ export { EdgeRouter }
140
+
141
+ export { encodeShareHash }
142
+
143
+ export { ExportFormat }
144
+
145
+ export { exportJson }
146
+
147
+ export { exportPdf }
148
+
149
+ export { exportPng }
150
+
151
+ export { exportSvg }
152
+
153
+ export { exportZip }
154
+
155
+ export { FILE_SIGNATURE }
156
+
157
+ export { Layer }
158
+
159
+ export { loadTemplate }
160
+
161
+ export { Page }
162
+
163
+ export { parseProject }
164
+
165
+ export { Plugin_2 as Plugin }
166
+
167
+ export { pluginManager }
168
+
169
+ export { Point }
170
+
171
+ export { Project }
172
+
173
+ export { projectToSourceText }
174
+
175
+ export { RasterExportOptions }
176
+
177
+ export { Rect }
178
+
179
+ export { serializeProject }
180
+
181
+ export { Shape }
182
+
183
+ export { ShareLoadResult }
184
+
185
+ export { SourceFormat }
186
+
187
+ export { ThemeMode }
188
+
189
+ export { ToolId }
190
+
191
+ export { }
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@samba425/diagramforge-react",
3
+ "private": false,
4
+ "version": "0.1.0",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "type": "module",
9
+ "description": "Embeddable offline-first diagram editor for React — a draw.io alternative.",
10
+ "author": "samba425 <asiva325@gmail.com>",
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/samba425/Udraw.git",
15
+ "directory": "frontend"
16
+ },
17
+ "keywords": [
18
+ "diagram",
19
+ "flowchart",
20
+ "drawio",
21
+ "react",
22
+ "svg",
23
+ "editor",
24
+ "whiteboard"
25
+ ],
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/diagramforge.js",
30
+ "require": "./dist/diagramforge.umd.cjs"
31
+ },
32
+ "./styles.css": "./dist/diagramforge.css"
33
+ },
34
+ "main": "./dist/diagramforge.umd.cjs",
35
+ "module": "./dist/diagramforge.js",
36
+ "types": "./dist/index.d.ts",
37
+ "files": [
38
+ "dist/diagramforge.js",
39
+ "dist/diagramforge.umd.cjs",
40
+ "dist/diagramforge.css",
41
+ "dist/index.d.ts"
42
+ ],
43
+ "sideEffects": [
44
+ "**/*.css"
45
+ ],
46
+ "peerDependencies": {
47
+ "react": "^18.0.0 || ^19.0.0",
48
+ "react-dom": "^18.0.0 || ^19.0.0"
49
+ },
50
+ "scripts": {
51
+ "dev": "vite",
52
+ "build": "tsc -b && vite build",
53
+ "build:lib": "vite build --config vite.lib.config.ts",
54
+ "build:all": "npm run build && npm run build:lib",
55
+ "preview": "vite preview --host",
56
+ "lint": "eslint .",
57
+ "format": "prettier --write \"src/**/*.{ts,tsx,css}\"",
58
+ "typecheck": "tsc -b --noEmit",
59
+ "test": "vitest run",
60
+ "test:watch": "vitest",
61
+ "test:e2e": "playwright test"
62
+ },
63
+ "dependencies": {
64
+ "idb": "^8.0.0",
65
+ "js-yaml": "^5.2.1",
66
+ "jspdf": "^4.2.1",
67
+ "jszip": "^3.10.1",
68
+ "lucide-react": "^0.469.0",
69
+ "motion": "^11.15.0",
70
+ "nanoid": "^5.0.9",
71
+ "react": "^18.0.0 || ^19.0.0",
72
+ "react-dom": "^18.0.0 || ^19.0.0",
73
+ "react-hook-form": "^7.54.2",
74
+ "react-router-dom": "^7.1.1",
75
+ "zustand": "^5.0.2"
76
+ },
77
+ "devDependencies": {
78
+ "@eslint/js": "^9.17.0",
79
+ "@playwright/test": "^1.49.1",
80
+ "@tailwindcss/vite": "^4.0.0",
81
+ "@testing-library/jest-dom": "^6.6.3",
82
+ "@testing-library/react": "^16.1.0",
83
+ "@testing-library/user-event": "^14.5.2",
84
+ "@types/js-yaml": "^4.0.9",
85
+ "@types/node": "^22.10.2",
86
+ "@types/react": "^19.0.2",
87
+ "@types/react-dom": "^19.0.2",
88
+ "@vitejs/plugin-react": "^4.3.4",
89
+ "eslint": "^9.17.0",
90
+ "eslint-plugin-react-hooks": "^5.1.0",
91
+ "eslint-plugin-react-refresh": "^0.4.16",
92
+ "globals": "^15.14.0",
93
+ "jsdom": "^25.0.1",
94
+ "prettier": "^3.4.2",
95
+ "tailwindcss": "^4.0.0",
96
+ "typescript": "^5.7.2",
97
+ "typescript-eslint": "^8.18.1",
98
+ "vite": "^7.0.0",
99
+ "vite-plugin-dts": "^4.5.4",
100
+ "vite-plugin-pwa": "^1.3.0",
101
+ "vitest": "^3.0.0"
102
+ }
103
+ }