@codecanvas-ide/engine 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +52 -2
- package/dist/codecanvas-engine.d.ts +1 -0
- package/dist/codecanvas-engine.js +693 -0
- package/dist/index.js +3928 -0
- package/dist/index.js.map +7 -0
- package/dist/types/arrange.d.ts +25 -0
- package/dist/types/canvas.d.ts +258 -0
- package/dist/types/conflicts.d.ts +37 -0
- package/dist/types/diff.d.ts +28 -0
- package/dist/types/edits.d.ts +38 -0
- package/dist/types/html.d.ts +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/layout.d.ts +82 -0
- package/dist/types/layoutRules.d.ts +73 -0
- package/dist/types/parse.d.ts +74 -0
- package/dist/types/project.d.ts +123 -0
- package/dist/types/projectServer.d.ts +20 -0
- package/dist/types/projectWorker.d.ts +14 -0
- package/dist/types/remoteProject.d.ts +33 -0
- package/dist/types/styles.d.ts +3 -0
- package/dist/types/types.d.ts +89 -0
- package/dist/types/workspace.d.ts +45 -0
- package/package.json +53 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniel Feliz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @codecanvas-ide/engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The canvas of [CodeCanvas](https://github.com/d-feliz/codecanvas-ide): it shows a TypeScript or JavaScript
|
|
4
|
+
file as a zoomable diagram and lets you edit it there. Every function, class, variable and import is a block;
|
|
5
|
+
usages are drawn as lines; anything changed on the canvas is written back to the text.
|
|
6
|
+
|
|
7
|
+
- Blocks with previews, nested blocks, and a stable layout you can save in the repo
|
|
8
|
+
- Usage lines, references across files, rename across files (TypeScript language service)
|
|
9
|
+
- Syntax and type errors on the blocks
|
|
10
|
+
- Changes against a base version (e.g. the last commit), and merge conflicts
|
|
11
|
+
- No framework: plain TypeScript and the DOM
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @codecanvas-ide/engine
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Use
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { CodeCanvas, Project } from '@codecanvas-ide/engine';
|
|
23
|
+
|
|
24
|
+
const project = new Project({ 'src/cart.ts': cartText, 'src/pricing.ts': pricingText });
|
|
25
|
+
const canvas = new CodeCanvas(document.getElementById('canvas')!, {
|
|
26
|
+
project,
|
|
27
|
+
createEditor: ({ parent, text, onChange, onClose }) => myEditor(parent, text, onChange, onClose),
|
|
28
|
+
onTextChange: (text) => saveFile('src/cart.ts', text),
|
|
29
|
+
onLayoutChange: (layout) => saveLayout('src/cart.ts', layout),
|
|
30
|
+
});
|
|
31
|
+
canvas.openFile('src/cart.ts', cartText);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Give the project the folder's TypeScript settings, so imports resolve as in the editor. In a monorepo,
|
|
35
|
+
pass every config file and `package.json`: each config gets its own program, and packages that import
|
|
36
|
+
each other by name resolve to their source.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
project.setWorkspace({
|
|
40
|
+
configFiles: [{ path: 'packages/web/tsconfig.json', text: webConfigText }],
|
|
41
|
+
packageFiles: { 'packages/utils/package.json': utilsManifestText },
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
To keep TypeScript work off the page's thread, run the project in a worker: `serveProject(self)` in the
|
|
46
|
+
worker script, and `connectProjectWorker(worker)` in place of `new Project()` on the page.
|
|
47
|
+
|
|
48
|
+
`dist/codecanvas-engine.js` is the same engine as one UMD file with TypeScript included, for hosts that
|
|
49
|
+
load scripts with an AMD loader.
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/index.js';
|