@fragiola/flow 0.0.0-stage → 0.0.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 +12 -2
- package/dist/connect-session-nyEp02_P.js +375 -0
- package/dist/connect-session-nyEp02_P.js.map +1 -0
- package/dist/connection.d.ts +31 -0
- package/dist/connection.js +60 -0
- package/dist/connection.js.map +1 -0
- package/dist/core-queries-BPNbcM6k.js +452 -0
- package/dist/core-queries-BPNbcM6k.js.map +1 -0
- package/dist/document-schema-CPK5xkyO.js +369 -0
- package/dist/document-schema-CPK5xkyO.js.map +1 -0
- package/dist/drag.d.ts +19 -0
- package/dist/drag.js +175 -0
- package/dist/drag.js.map +1 -0
- package/dist/index.d.ts +876 -0
- package/dist/index.js +5711 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard-links-CVaTtlZg.js +8 -0
- package/dist/keyboard-links-CVaTtlZg.js.map +1 -0
- package/dist/keyboard.d.ts +40 -0
- package/dist/keyboard.js +342 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/minimap.d.ts +26 -0
- package/dist/minimap.js +206 -0
- package/dist/minimap.js.map +1 -0
- package/dist/node-moves-DyWe-4dj.js +36 -0
- package/dist/node-moves-DyWe-4dj.js.map +1 -0
- package/dist/part-attributes-DuBltA__.js +71 -0
- package/dist/part-attributes-DuBltA__.js.map +1 -0
- package/dist/path-format-2OU7Eiyy.js +43 -0
- package/dist/path-format-2OU7Eiyy.js.map +1 -0
- package/dist/reconnection.d.ts +15 -0
- package/dist/reconnection.js +138 -0
- package/dist/reconnection.js.map +1 -0
- package/dist/rect-CmoREaR6.js +92 -0
- package/dist/rect-CmoREaR6.js.map +1 -0
- package/dist/resize.d.ts +33 -0
- package/dist/resize.js +316 -0
- package/dist/resize.js.map +1 -0
- package/dist/rules-DLOMrPBG.js +102 -0
- package/dist/rules-DLOMrPBG.js.map +1 -0
- package/dist/selection.d.ts +38 -0
- package/dist/selection.js +392 -0
- package/dist/selection.js.map +1 -0
- package/dist/subflows.d.ts +9 -0
- package/dist/subflows.js +237 -0
- package/dist/subflows.js.map +1 -0
- package/dist/types-CLHcZVCb.d.ts +2660 -0
- package/dist/viewport-math-B-9Pn2kN.js +69 -0
- package/dist/viewport-math-B-9Pn2kN.js.map +1 -0
- package/package.json +93 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/geometry/viewport-math.ts
|
|
2
|
+
/** A number without the sign of a zero (`-0` is `0`). */
|
|
3
|
+
function unsigned(value) {
|
|
4
|
+
return value + 0;
|
|
5
|
+
}
|
|
6
|
+
/** A zoom kept between `min` and `max`. */
|
|
7
|
+
function clampZoom(zoom, min, max) {
|
|
8
|
+
return Math.min(Math.max(zoom, min), max);
|
|
9
|
+
}
|
|
10
|
+
/** A point on the screen (relative to the root) as a flow point. */
|
|
11
|
+
function toFlow(viewport, point) {
|
|
12
|
+
return {
|
|
13
|
+
x: (point.x - viewport.x) / viewport.zoom,
|
|
14
|
+
y: (point.y - viewport.y) / viewport.zoom
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** A flow point as a point on the screen (relative to the root). */
|
|
18
|
+
function toScreen(viewport, point) {
|
|
19
|
+
return {
|
|
20
|
+
x: point.x * viewport.zoom + viewport.x,
|
|
21
|
+
y: point.y * viewport.zoom + viewport.y
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The viewport at `zoom` that keeps the flow point under the screen point `around` where it is. */
|
|
25
|
+
function zoomAround(viewport, zoom, around) {
|
|
26
|
+
const anchor = toFlow(viewport, around);
|
|
27
|
+
return {
|
|
28
|
+
x: around.x - anchor.x * zoom,
|
|
29
|
+
y: around.y - anchor.y * zoom,
|
|
30
|
+
zoom
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** The flow rectangle the root shows. */
|
|
34
|
+
function viewRect(viewport, size) {
|
|
35
|
+
return {
|
|
36
|
+
x: unsigned(-viewport.x / viewport.zoom),
|
|
37
|
+
y: unsigned(-viewport.y / viewport.zoom),
|
|
38
|
+
width: size.width / viewport.zoom,
|
|
39
|
+
height: size.height / viewport.zoom
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** The viewport that centres the flow point `center` in the root at `zoom`. */
|
|
43
|
+
function centeredOn(center, zoom, size) {
|
|
44
|
+
return {
|
|
45
|
+
x: size.width / 2 - center.x * zoom,
|
|
46
|
+
y: size.height / 2 - center.y * zoom,
|
|
47
|
+
zoom
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A viewport moved as little as it takes for the root to show only the flow inside `extent`: an
|
|
52
|
+
* extent smaller than the view is centred in it.
|
|
53
|
+
*/
|
|
54
|
+
function keptInExtent(viewport, size, extent) {
|
|
55
|
+
const { zoom } = viewport;
|
|
56
|
+
const axis = (offset, start, length, room) => {
|
|
57
|
+
const scaled = length * zoom;
|
|
58
|
+
if (scaled <= room) return unsigned((room - scaled) / 2 - start * zoom);
|
|
59
|
+
return unsigned(Math.min(-start * zoom, Math.max(room - (start + length) * zoom, offset)));
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
x: axis(viewport.x, extent.x, extent.width, size.width),
|
|
63
|
+
y: axis(viewport.y, extent.y, extent.height, size.height),
|
|
64
|
+
zoom
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export { toScreen as a, toFlow as i, clampZoom as n, viewRect as o, keptInExtent as r, zoomAround as s, centeredOn as t };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=viewport-math-B-9Pn2kN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport-math-B-9Pn2kN.js","names":[],"sources":["../src/geometry/viewport-math.ts"],"sourcesContent":["// The viewport's math (D4): converting points between the screen and the flow, zooming around a\n// point, centring, and keeping the view inside a translate extent. Screen points here are\n// relative to the root's top-left corner, in pixels.\nimport type { XY } from \"../document/types\";\nimport type { Rect, Viewport } from \"./types\";\n\n/** The size of the root, in pixels. */\nexport interface Size {\n readonly width: number;\n readonly height: number;\n}\n\n/** A number without the sign of a zero (`-0` is `0`). */\nfunction unsigned(value: number): number {\n return value + 0;\n}\n\n/** A zoom kept between `min` and `max`. */\nexport function clampZoom(zoom: number, min: number, max: number): number {\n return Math.min(Math.max(zoom, min), max);\n}\n\n/** A point on the screen (relative to the root) as a flow point. */\nexport function toFlow(viewport: Viewport, point: XY): XY {\n return {\n x: (point.x - viewport.x) / viewport.zoom,\n y: (point.y - viewport.y) / viewport.zoom,\n };\n}\n\n/** A flow point as a point on the screen (relative to the root). */\nexport function toScreen(viewport: Viewport, point: XY): XY {\n return {\n x: point.x * viewport.zoom + viewport.x,\n y: point.y * viewport.zoom + viewport.y,\n };\n}\n\n/** The viewport at `zoom` that keeps the flow point under the screen point `around` where it is. */\nexport function zoomAround(\n viewport: Viewport,\n zoom: number,\n around: XY,\n): Viewport {\n const anchor = toFlow(viewport, around);\n return {\n x: around.x - anchor.x * zoom,\n y: around.y - anchor.y * zoom,\n zoom,\n };\n}\n\n/** The flow rectangle the root shows. */\nexport function viewRect(viewport: Viewport, size: Size): Rect {\n return {\n x: unsigned(-viewport.x / viewport.zoom),\n y: unsigned(-viewport.y / viewport.zoom),\n width: size.width / viewport.zoom,\n height: size.height / viewport.zoom,\n };\n}\n\n/** The viewport that centres the flow point `center` in the root at `zoom`. */\nexport function centeredOn(center: XY, zoom: number, size: Size): Viewport {\n return {\n x: size.width / 2 - center.x * zoom,\n y: size.height / 2 - center.y * zoom,\n zoom,\n };\n}\n\n/**\n * A viewport moved as little as it takes for the root to show only the flow inside `extent`: an\n * extent smaller than the view is centred in it.\n */\nexport function keptInExtent(\n viewport: Viewport,\n size: Size,\n extent: Rect,\n): Viewport {\n const { zoom } = viewport;\n const axis = (\n offset: number,\n start: number,\n length: number,\n room: number,\n ) => {\n const scaled = length * zoom;\n if (scaled <= room) {\n return unsigned((room - scaled) / 2 - start * zoom);\n }\n // the extent's start may not come right of the root's start, nor its end left of its end\n return unsigned(\n Math.min(\n -start * zoom,\n Math.max(room - (start + length) * zoom, offset),\n ),\n );\n };\n return {\n x: axis(viewport.x, extent.x, extent.width, size.width),\n y: axis(viewport.y, extent.y, extent.height, size.height),\n zoom,\n };\n}\n"],"mappings":";;AAaA,SAAS,SAAS,OAAuB;CACrC,OAAO,QAAQ;AACnB;;AAGA,SAAgB,UAAU,MAAc,KAAa,KAAqB;CACtE,OAAO,KAAK,IAAI,KAAK,IAAI,MAAM,GAAG,GAAG,GAAG;AAC5C;;AAGA,SAAgB,OAAO,UAAoB,OAAe;CACtD,OAAO;EACH,IAAI,MAAM,IAAI,SAAS,KAAK,SAAS;EACrC,IAAI,MAAM,IAAI,SAAS,KAAK,SAAS;CACzC;AACJ;;AAGA,SAAgB,SAAS,UAAoB,OAAe;CACxD,OAAO;EACH,GAAG,MAAM,IAAI,SAAS,OAAO,SAAS;EACtC,GAAG,MAAM,IAAI,SAAS,OAAO,SAAS;CAC1C;AACJ;;AAGA,SAAgB,WACZ,UACA,MACA,QACQ;CACR,MAAM,SAAS,OAAO,UAAU,MAAM;CACtC,OAAO;EACH,GAAG,OAAO,IAAI,OAAO,IAAI;EACzB,GAAG,OAAO,IAAI,OAAO,IAAI;EACzB;CACJ;AACJ;;AAGA,SAAgB,SAAS,UAAoB,MAAkB;CAC3D,OAAO;EACH,GAAG,SAAS,CAAC,SAAS,IAAI,SAAS,IAAI;EACvC,GAAG,SAAS,CAAC,SAAS,IAAI,SAAS,IAAI;EACvC,OAAO,KAAK,QAAQ,SAAS;EAC7B,QAAQ,KAAK,SAAS,SAAS;CACnC;AACJ;;AAGA,SAAgB,WAAW,QAAY,MAAc,MAAsB;CACvE,OAAO;EACH,GAAG,KAAK,QAAQ,IAAI,OAAO,IAAI;EAC/B,GAAG,KAAK,SAAS,IAAI,OAAO,IAAI;EAChC;CACJ;AACJ;;;;;AAMA,SAAgB,aACZ,UACA,MACA,QACQ;CACR,MAAM,EAAE,SAAS;CACjB,MAAM,QACF,QACA,OACA,QACA,SACC;EACD,MAAM,SAAS,SAAS;EACxB,IAAI,UAAU,MACV,OAAO,UAAU,OAAO,UAAU,IAAI,QAAQ,IAAI;EAGtD,OAAO,SACH,KAAK,IACD,CAAC,QAAQ,MACT,KAAK,IAAI,QAAQ,QAAQ,UAAU,MAAM,MAAM,CACnD,CACJ;CACJ;CACA,OAAO;EACH,GAAG,KAAK,SAAS,GAAG,OAAO,GAAG,OAAO,OAAO,KAAK,KAAK;EACtD,GAAG,KAAK,SAAS,GAAG,OAAO,GAAG,OAAO,QAAQ,KAAK,MAAM;EACxD;CACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,96 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fragiola/flow",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Headless node-based editors and diagrams core: the flow document and its JSON Schema, a typed model with commands, opt-in features (selection, sub-flows, drag, resize, connection, reconnection, keyboard, minimap), and the engine that binds a flow to the DOM.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"flow",
|
|
7
|
+
"node-editor",
|
|
8
|
+
"diagram",
|
|
9
|
+
"graph",
|
|
10
|
+
"headless"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Mauro de Souza",
|
|
16
|
+
"email": "maurodesouza.me@gmail.com",
|
|
17
|
+
"url": "https://github.com/maurodesouza"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/fragiola/flow.git",
|
|
22
|
+
"directory": "packages/core"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://fragiola.com/flow",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/fragiola/flow/issues"
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./selection": {
|
|
36
|
+
"types": "./dist/selection.d.ts",
|
|
37
|
+
"import": "./dist/selection.js",
|
|
38
|
+
"default": "./dist/selection.js"
|
|
39
|
+
},
|
|
40
|
+
"./subflows": {
|
|
41
|
+
"types": "./dist/subflows.d.ts",
|
|
42
|
+
"import": "./dist/subflows.js",
|
|
43
|
+
"default": "./dist/subflows.js"
|
|
44
|
+
},
|
|
45
|
+
"./drag": {
|
|
46
|
+
"types": "./dist/drag.d.ts",
|
|
47
|
+
"import": "./dist/drag.js",
|
|
48
|
+
"default": "./dist/drag.js"
|
|
49
|
+
},
|
|
50
|
+
"./resize": {
|
|
51
|
+
"types": "./dist/resize.d.ts",
|
|
52
|
+
"import": "./dist/resize.js",
|
|
53
|
+
"default": "./dist/resize.js"
|
|
54
|
+
},
|
|
55
|
+
"./connection": {
|
|
56
|
+
"types": "./dist/connection.d.ts",
|
|
57
|
+
"import": "./dist/connection.js",
|
|
58
|
+
"default": "./dist/connection.js"
|
|
59
|
+
},
|
|
60
|
+
"./reconnection": {
|
|
61
|
+
"types": "./dist/reconnection.d.ts",
|
|
62
|
+
"import": "./dist/reconnection.js",
|
|
63
|
+
"default": "./dist/reconnection.js"
|
|
64
|
+
},
|
|
65
|
+
"./keyboard": {
|
|
66
|
+
"types": "./dist/keyboard.d.ts",
|
|
67
|
+
"import": "./dist/keyboard.js",
|
|
68
|
+
"default": "./dist/keyboard.js"
|
|
69
|
+
},
|
|
70
|
+
"./minimap": {
|
|
71
|
+
"types": "./dist/minimap.d.ts",
|
|
72
|
+
"import": "./dist/minimap.js",
|
|
73
|
+
"default": "./dist/minimap.js"
|
|
74
|
+
},
|
|
75
|
+
"./package.json": "./package.json"
|
|
76
|
+
},
|
|
77
|
+
"files": [
|
|
78
|
+
"dist",
|
|
79
|
+
"README.md",
|
|
80
|
+
"LICENSE"
|
|
81
|
+
],
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@types/node": "24.13.6",
|
|
84
|
+
"jsdom": "30.1.1",
|
|
85
|
+
"tsdown": "0.23.0",
|
|
86
|
+
"typescript": "7.0.2",
|
|
87
|
+
"vitest": "5.0.2"
|
|
88
|
+
},
|
|
89
|
+
"scripts": {
|
|
90
|
+
"build": "tsdown",
|
|
91
|
+
"typecheck": "tsc --noEmit",
|
|
92
|
+
"test": "vitest run",
|
|
93
|
+
"bench": "vitest run --config vitest.bench.config.ts",
|
|
94
|
+
"generate:commands": "tsdown && node scripts/generate-command-docs.ts"
|
|
95
|
+
}
|
|
6
96
|
}
|