@meltemi/diagrams-editor 0.0.0-stage → 1.10.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 +38 -2
- package/dist/add-icons.d.ts +44 -0
- package/dist/add-icons.d.ts.map +1 -0
- package/dist/add-icons.js +178 -0
- package/dist/add-icons.js.map +1 -0
- package/dist/analysis.d.ts +70 -0
- package/dist/analysis.d.ts.map +1 -0
- package/dist/analysis.js +59 -0
- package/dist/analysis.js.map +1 -0
- package/dist/arrange.d.ts +71 -0
- package/dist/arrange.d.ts.map +1 -0
- package/dist/arrange.js +285 -0
- package/dist/arrange.js.map +1 -0
- package/dist/asset-files.d.ts +46 -0
- package/dist/asset-files.d.ts.map +1 -0
- package/dist/asset-files.js +79 -0
- package/dist/asset-files.js.map +1 -0
- package/dist/assist.d.ts +61 -0
- package/dist/assist.d.ts.map +1 -0
- package/dist/assist.js +162 -0
- package/dist/assist.js.map +1 -0
- package/dist/c4.d.ts +120 -0
- package/dist/c4.d.ts.map +1 -0
- package/dist/c4.js +544 -0
- package/dist/c4.js.map +1 -0
- package/dist/canvas/arrange.d.ts +13 -0
- package/dist/canvas/arrange.d.ts.map +1 -0
- package/dist/canvas/arrange.js +61 -0
- package/dist/canvas/arrange.js.map +1 -0
- package/dist/canvas/geometry.d.ts +2 -0
- package/dist/canvas/geometry.d.ts.map +1 -0
- package/dist/canvas/geometry.js +3 -0
- package/dist/canvas/geometry.js.map +1 -0
- package/dist/canvas/index.d.ts +11 -0
- package/dist/canvas/index.d.ts.map +1 -0
- package/dist/canvas/index.js +14 -0
- package/dist/canvas/index.js.map +1 -0
- package/dist/canvas/keyboard.d.ts +41 -0
- package/dist/canvas/keyboard.d.ts.map +1 -0
- package/dist/canvas/keyboard.js +121 -0
- package/dist/canvas/keyboard.js.map +1 -0
- package/dist/canvas/palette.d.ts +42 -0
- package/dist/canvas/palette.d.ts.map +1 -0
- package/dist/canvas/palette.js +82 -0
- package/dist/canvas/palette.js.map +1 -0
- package/dist/canvas/protocol.d.ts +1100 -0
- package/dist/canvas/protocol.d.ts.map +1 -0
- package/dist/canvas/protocol.js +325 -0
- package/dist/canvas/protocol.js.map +1 -0
- package/dist/canvas/routes.d.ts +121 -0
- package/dist/canvas/routes.d.ts.map +1 -0
- package/dist/canvas/routes.js +361 -0
- package/dist/canvas/routes.js.map +1 -0
- package/dist/canvas/selection.d.ts +77 -0
- package/dist/canvas/selection.d.ts.map +1 -0
- package/dist/canvas/selection.js +183 -0
- package/dist/canvas/selection.js.map +1 -0
- package/dist/canvas/snapping.d.ts +44 -0
- package/dist/canvas/snapping.d.ts.map +1 -0
- package/dist/canvas/snapping.js +86 -0
- package/dist/canvas/snapping.js.map +1 -0
- package/dist/canvas/turning.d.ts +27 -0
- package/dist/canvas/turning.d.ts.map +1 -0
- package/dist/canvas/turning.js +58 -0
- package/dist/canvas/turning.js.map +1 -0
- package/dist/catalog.d.ts +44 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +182 -0
- package/dist/catalog.js.map +1 -0
- package/dist/clipboard.d.ts +27 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +273 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/drill.d.ts +55 -0
- package/dist/drill.d.ts.map +1 -0
- package/dist/drill.js +158 -0
- package/dist/drill.js.map +1 -0
- package/dist/effects.d.ts +27 -0
- package/dist/effects.d.ts.map +1 -0
- package/dist/effects.js +157 -0
- package/dist/effects.js.map +1 -0
- package/dist/exports.d.ts +115 -0
- package/dist/exports.d.ts.map +1 -0
- package/dist/exports.js +292 -0
- package/dist/exports.js.map +1 -0
- package/dist/git.d.ts +8 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +86 -0
- package/dist/git.js.map +1 -0
- package/dist/icons.d.ts +63 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +277 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/inspector.d.ts +31 -0
- package/dist/inspector.d.ts.map +1 -0
- package/dist/inspector.js +1437 -0
- package/dist/inspector.js.map +1 -0
- package/dist/json-edit.d.ts +16 -0
- package/dist/json-edit.d.ts.map +1 -0
- package/dist/json-edit.js +123 -0
- package/dist/json-edit.js.map +1 -0
- package/dist/layouts.d.ts +17 -0
- package/dist/layouts.d.ts.map +1 -0
- package/dist/layouts.js +39 -0
- package/dist/layouts.js.map +1 -0
- package/dist/messages/en.d.ts +392 -0
- package/dist/messages/en.d.ts.map +1 -0
- package/dist/messages/en.js +397 -0
- package/dist/messages/en.js.map +1 -0
- package/dist/messages/es.d.ts +3 -0
- package/dist/messages/es.d.ts.map +1 -0
- package/dist/messages/es.js +341 -0
- package/dist/messages/es.js.map +1 -0
- package/dist/messages/index.d.ts +341 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/index.js +12 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/messages/keys.d.ts +13 -0
- package/dist/messages/keys.d.ts.map +1 -0
- package/dist/messages/keys.js +152 -0
- package/dist/messages/keys.js.map +1 -0
- package/dist/messages/review.d.ts +11 -0
- package/dist/messages/review.d.ts.map +1 -0
- package/dist/messages/review.js +25 -0
- package/dist/messages/review.js.map +1 -0
- package/dist/messages/services.d.ts +717 -0
- package/dist/messages/services.d.ts.map +1 -0
- package/dist/messages/services.js +728 -0
- package/dist/messages/services.js.map +1 -0
- package/dist/move-file.d.ts +32 -0
- package/dist/move-file.d.ts.map +1 -0
- package/dist/move-file.js +58 -0
- package/dist/move-file.js.map +1 -0
- package/dist/node.d.ts +21 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +34 -0
- package/dist/node.js.map +1 -0
- package/dist/projects.d.ts +235 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +794 -0
- package/dist/projects.js.map +1 -0
- package/dist/render.d.ts +58 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +71 -0
- package/dist/render.js.map +1 -0
- package/dist/review.d.ts +50 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +232 -0
- package/dist/review.js.map +1 -0
- package/dist/sequence.d.ts +55 -0
- package/dist/sequence.d.ts.map +1 -0
- package/dist/sequence.js +593 -0
- package/dist/sequence.js.map +1 -0
- package/dist/services/actions.d.ts +18 -0
- package/dist/services/actions.d.ts.map +1 -0
- package/dist/services/actions.js +341 -0
- package/dist/services/actions.js.map +1 -0
- package/dist/services/completion.d.ts +26 -0
- package/dist/services/completion.d.ts.map +1 -0
- package/dist/services/completion.js +773 -0
- package/dist/services/completion.js.map +1 -0
- package/dist/services/docs.d.ts +12 -0
- package/dist/services/docs.d.ts.map +1 -0
- package/dist/services/docs.js +14 -0
- package/dist/services/docs.js.map +1 -0
- package/dist/services/entities.d.ts +28 -0
- package/dist/services/entities.d.ts.map +1 -0
- package/dist/services/entities.js +132 -0
- package/dist/services/entities.js.map +1 -0
- package/dist/services/format.d.ts +7 -0
- package/dist/services/format.d.ts.map +1 -0
- package/dist/services/format.js +26 -0
- package/dist/services/format.js.map +1 -0
- package/dist/services/hover.d.ts +15 -0
- package/dist/services/hover.d.ts.map +1 -0
- package/dist/services/hover.js +341 -0
- package/dist/services/hover.js.map +1 -0
- package/dist/services/navigation.d.ts +56 -0
- package/dist/services/navigation.d.ts.map +1 -0
- package/dist/services/navigation.js +380 -0
- package/dist/services/navigation.js.map +1 -0
- package/dist/services/profiles.d.ts +21 -0
- package/dist/services/profiles.d.ts.map +1 -0
- package/dist/services/profiles.js +145 -0
- package/dist/services/profiles.js.map +1 -0
- package/dist/services/stories.d.ts +43 -0
- package/dist/services/stories.d.ts.map +1 -0
- package/dist/services/stories.js +302 -0
- package/dist/services/stories.js.map +1 -0
- package/dist/services/tokens.d.ts +13 -0
- package/dist/services/tokens.d.ts.map +1 -0
- package/dist/services/tokens.js +127 -0
- package/dist/services/tokens.js.map +1 -0
- package/dist/session.d.ts +234 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +2427 -0
- package/dist/session.js.map +1 -0
- package/dist/story.d.ts +36 -0
- package/dist/story.d.ts.map +1 -0
- package/dist/story.js +95 -0
- package/dist/story.js.map +1 -0
- package/dist/syntax.d.ts +45 -0
- package/dist/syntax.d.ts.map +1 -0
- package/dist/syntax.js +162 -0
- package/dist/syntax.js.map +1 -0
- package/dist/targets.d.ts +54 -0
- package/dist/targets.d.ts.map +1 -0
- package/dist/targets.js +165 -0
- package/dist/targets.js.map +1 -0
- package/dist/text-places.d.ts +20 -0
- package/dist/text-places.d.ts.map +1 -0
- package/dist/text-places.js +362 -0
- package/dist/text-places.js.map +1 -0
- package/dist/themes.d.ts +34 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +200 -0
- package/dist/themes.js.map +1 -0
- package/package.json +57 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Architecture Studio contributors
|
|
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,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @meltemi/diagrams-editor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Host-neutral editor services: diagnostics, completion, hover, definitions, references, rename,
|
|
4
|
+
formatting, quick fixes, symbols and semantic tokens; project sessions; the canvas session and its
|
|
5
|
+
protocol; exports and catalogs (`./node`). The VS Code extension and the playground are built on
|
|
6
|
+
it.
|
|
7
|
+
|
|
8
|
+
It is part of [Meltemi Diagrams](https://github.com/askenaz-dev/meltemi-diagrams#readme), diagrams as code with a canvas, motion and
|
|
9
|
+
exports. Every package of the product has the same version.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @meltemi/diagrams-editor
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Node 22.12.0 or later. The package is an ES module with type declarations.
|
|
18
|
+
|
|
19
|
+
## Use
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { ProjectSessions } from "@meltemi/diagrams-editor/node";
|
|
23
|
+
|
|
24
|
+
const sessions = new ProjectSessions({ toolVersion: "1.0.0" });
|
|
25
|
+
const analysis = sessions.analyze("/work/shop/diagrams/overview.meltemi");
|
|
26
|
+
console.log(
|
|
27
|
+
analysis.diagnostics,
|
|
28
|
+
analysis.diagrams.map((d) => d.id),
|
|
29
|
+
);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
- [Editor guide](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/editor.md)
|
|
35
|
+
- [All documentation](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/README.md)
|
|
36
|
+
|
|
37
|
+
## Licence
|
|
38
|
+
|
|
39
|
+
MIT. Third-party components and their licences are listed in [THIRD_PARTY_LICENSES.md](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/THIRD_PARTY_LICENSES.md).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type IconRegistry } from "@meltemi/diagrams-assets";
|
|
2
|
+
import type { FlowDiagram } from "@meltemi/diagrams-model";
|
|
3
|
+
import type { AddedIconInfo, IconFileCheck, IconFileInput, IconPrefixCheck } from "./canvas/protocol.js";
|
|
4
|
+
import type { AssetSteps, ProjectStep } from "./projects.js";
|
|
5
|
+
/** The prefix the Add icon dialog offers first. */
|
|
6
|
+
export declare const DEFAULT_ICON_PREFIX = "project";
|
|
7
|
+
/**
|
|
8
|
+
* What the Add icon dialog may do with a prefix: put the icons in a new pack, or in a pack of the
|
|
9
|
+
* project read from a folder; never in a built-in pack, a plugin's, an Iconify file of the
|
|
10
|
+
* project (the dialog writes SVG files) or an alias of `project.json`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkIconPrefix(registry: IconRegistry | undefined, prefix: string): IconPrefixCheck;
|
|
13
|
+
/**
|
|
14
|
+
* Each file of the Add icon dialog as the dialog shows it: the name it gets (the one asked for, or
|
|
15
|
+
* one made of the file's name and free in the pack), a preview through the sanitiser, and what
|
|
16
|
+
* keeps it from being added: an SVG the sanitiser refuses, a name a reference cannot write, a name
|
|
17
|
+
* the pack or an earlier file has.
|
|
18
|
+
*/
|
|
19
|
+
export declare function checkIconFiles(registry: IconRegistry | undefined, prefix: string, files: readonly IconFileInput[]): IconFileCheck[];
|
|
20
|
+
/** What `addIcons` gives: the icons added, the files refused, and what to write. */
|
|
21
|
+
export interface AddedIcons {
|
|
22
|
+
readonly added: readonly AddedIconInfo[];
|
|
23
|
+
readonly refused: readonly {
|
|
24
|
+
readonly file: string;
|
|
25
|
+
readonly reason: string;
|
|
26
|
+
}[];
|
|
27
|
+
/** The files of the assets, and the statements that give the first icon to the targets. */
|
|
28
|
+
readonly assets: AssetSteps;
|
|
29
|
+
readonly steps: readonly ProjectStep[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The files and statements that add icons to the project: one `assets/icons/<prefix>/<name>.svg`
|
|
33
|
+
* per file that can be added, the pack's licence in `assets/licenses.json` when it has none, an
|
|
34
|
+
* item per icon in the project's library (`assets/libraries/project.json`, a category per
|
|
35
|
+
* prefix), and `style <id> { icon }` of the first icon on the targets that take one. A prefix the
|
|
36
|
+
* icons cannot go into, or a licence missing or malformed, refuses every file.
|
|
37
|
+
*/
|
|
38
|
+
export declare function addIcons(registry: IconRegistry | undefined, diagram: FlowDiagram | undefined, request: {
|
|
39
|
+
readonly prefix: string;
|
|
40
|
+
readonly licence?: string;
|
|
41
|
+
readonly files: readonly IconFileInput[];
|
|
42
|
+
readonly targets: readonly string[];
|
|
43
|
+
}): AddedIcons;
|
|
44
|
+
//# sourceMappingURL=add-icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-icons.d.ts","sourceRoot":"","sources":["../src/add-icons.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQ3D,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE7D,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAU7C;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,MAAM,EAAE,MAAM,GACb,eAAe,CAoBjB;AAQD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,aAAa,EAAE,GAC9B,aAAa,EAAE,CAkCjB;AAED,oFAAoF;AACpF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAChF,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;CACxC;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,OAAO,EAAE;IACP,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,GACA,UAAU,CAyEZ"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { PACK_PREFIX, geometrySvg, humanise, isIconName, sanitizeSvg, slugifyIconName, } from "@meltemi/diagrams-assets";
|
|
2
|
+
import { ICONS_FOLDER, LICENSES_FILE, PROJECT_LIBRARY_FILE, iconFilePath, } from "@meltemi/diagrams-project";
|
|
3
|
+
import { libraryCategoryId } from "./asset-files.js";
|
|
4
|
+
import { takesIcon } from "./icons.js";
|
|
5
|
+
import { messages } from "./messages/index.js";
|
|
6
|
+
/** The prefix the Add icon dialog offers first. */
|
|
7
|
+
export const DEFAULT_ICON_PREFIX = "project";
|
|
8
|
+
/** What a licence may be written as: an SPDX identifier or a `LicenseRef-` name. */
|
|
9
|
+
const LICENCE = /^(?:LicenseRef-[A-Za-z0-9.-]+|[A-Za-z0-9][A-Za-z0-9.+-]*)$/;
|
|
10
|
+
/** Whether a pack is one of the project's own, read from a folder or a file under `assets/icons`. */
|
|
11
|
+
function projectPack(pack) {
|
|
12
|
+
return pack.metadata.source.startsWith(`${ICONS_FOLDER}/`);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What the Add icon dialog may do with a prefix: put the icons in a new pack, or in a pack of the
|
|
16
|
+
* project read from a folder; never in a built-in pack, a plugin's, an Iconify file of the
|
|
17
|
+
* project (the dialog writes SVG files) or an alias of `project.json`.
|
|
18
|
+
*/
|
|
19
|
+
export function checkIconPrefix(registry, prefix) {
|
|
20
|
+
const words = messages().addIcons;
|
|
21
|
+
const fail = (problem) => ({
|
|
22
|
+
prefix,
|
|
23
|
+
problem,
|
|
24
|
+
existing: false,
|
|
25
|
+
licensed: false,
|
|
26
|
+
});
|
|
27
|
+
if (prefix === "")
|
|
28
|
+
return fail(words.prefixEmpty);
|
|
29
|
+
if (!PACK_PREFIX.test(prefix))
|
|
30
|
+
return fail(words.prefixInvalid(prefix));
|
|
31
|
+
const alias = registry?.aliasList()[prefix];
|
|
32
|
+
if (alias !== undefined)
|
|
33
|
+
return fail(words.prefixAlias(prefix, alias));
|
|
34
|
+
const pack = registry?.list().find((p) => p.prefix === prefix);
|
|
35
|
+
if (!pack)
|
|
36
|
+
return { prefix, existing: false, licensed: false };
|
|
37
|
+
if (pack.metadata.source === "built-in")
|
|
38
|
+
return fail(words.prefixBuiltIn(prefix));
|
|
39
|
+
if (!projectPack(pack))
|
|
40
|
+
return fail(words.prefixPlugin(prefix));
|
|
41
|
+
if (pack.metadata.source.endsWith(".json")) {
|
|
42
|
+
return fail(words.prefixIconify(prefix, pack.metadata.source));
|
|
43
|
+
}
|
|
44
|
+
return { prefix, existing: true, licensed: pack.metadata.license !== null };
|
|
45
|
+
}
|
|
46
|
+
/** The names a pack has, lower case: a file system may not tell `Logo.svg` from `logo.svg`. */
|
|
47
|
+
function takenNames(registry, prefix) {
|
|
48
|
+
const pack = registry?.list().find((p) => p.prefix === prefix);
|
|
49
|
+
return new Set((pack?.names() ?? []).map((n) => n.toLowerCase()));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Each file of the Add icon dialog as the dialog shows it: the name it gets (the one asked for, or
|
|
53
|
+
* one made of the file's name and free in the pack), a preview through the sanitiser, and what
|
|
54
|
+
* keeps it from being added: an SVG the sanitiser refuses, a name a reference cannot write, a name
|
|
55
|
+
* the pack or an earlier file has.
|
|
56
|
+
*/
|
|
57
|
+
export function checkIconFiles(registry, prefix, files) {
|
|
58
|
+
const words = messages().addIcons;
|
|
59
|
+
const taken = takenNames(registry, prefix);
|
|
60
|
+
const used = new Set();
|
|
61
|
+
return files.map((file) => {
|
|
62
|
+
let name = file.name?.trim() ?? "";
|
|
63
|
+
let problem;
|
|
64
|
+
if (file.name === undefined) {
|
|
65
|
+
// A name is offered: the file's own, made writable, then `-2`, `-3`… while it is taken.
|
|
66
|
+
const slug = slugifyIconName(file.file);
|
|
67
|
+
name = slug;
|
|
68
|
+
for (let n = 2; slug !== "" && (taken.has(name.toLowerCase()) || used.has(name.toLowerCase())); n++) {
|
|
69
|
+
name = `${slug}-${n}`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (name === "")
|
|
73
|
+
problem = words.nameEmpty;
|
|
74
|
+
else if (!isIconName(name))
|
|
75
|
+
problem = words.nameInvalid(name);
|
|
76
|
+
else if (taken.has(name.toLowerCase()))
|
|
77
|
+
problem = words.nameTaken(`${prefix}:${name}`);
|
|
78
|
+
else if (used.has(name.toLowerCase()))
|
|
79
|
+
problem = words.nameTwice(name);
|
|
80
|
+
if (name !== "")
|
|
81
|
+
used.add(name.toLowerCase());
|
|
82
|
+
let svg = null;
|
|
83
|
+
if (!/<svg[\s>]/i.test(file.svg)) {
|
|
84
|
+
problem = words.notSvg;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const result = sanitizeSvg(file.svg);
|
|
88
|
+
if (result.ok)
|
|
89
|
+
svg = geometrySvg(result.icon, 48, 48);
|
|
90
|
+
else
|
|
91
|
+
problem = words.unsafe(result.problem.message);
|
|
92
|
+
}
|
|
93
|
+
return { file: file.file, name, svg, ...(problem !== undefined ? { problem } : {}) };
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The files and statements that add icons to the project: one `assets/icons/<prefix>/<name>.svg`
|
|
98
|
+
* per file that can be added, the pack's licence in `assets/licenses.json` when it has none, an
|
|
99
|
+
* item per icon in the project's library (`assets/libraries/project.json`, a category per
|
|
100
|
+
* prefix), and `style <id> { icon }` of the first icon on the targets that take one. A prefix the
|
|
101
|
+
* icons cannot go into, or a licence missing or malformed, refuses every file.
|
|
102
|
+
*/
|
|
103
|
+
export function addIcons(registry, diagram, request) {
|
|
104
|
+
const words = messages().addIcons;
|
|
105
|
+
const none = { create: [], json: [] };
|
|
106
|
+
const refuseAll = (reason) => ({
|
|
107
|
+
added: [],
|
|
108
|
+
refused: request.files.map((f) => ({ file: f.file, reason })),
|
|
109
|
+
assets: none,
|
|
110
|
+
steps: [],
|
|
111
|
+
});
|
|
112
|
+
const prefix = checkIconPrefix(registry, request.prefix);
|
|
113
|
+
if (prefix.problem !== undefined)
|
|
114
|
+
return refuseAll(prefix.problem);
|
|
115
|
+
const licence = request.licence?.trim() ?? "";
|
|
116
|
+
if (!prefix.licensed) {
|
|
117
|
+
if (licence === "")
|
|
118
|
+
return refuseAll(words.licenceMissing);
|
|
119
|
+
if (!LICENCE.test(licence))
|
|
120
|
+
return refuseAll(words.licenceInvalid(licence));
|
|
121
|
+
}
|
|
122
|
+
const checks = checkIconFiles(registry, request.prefix, request.files.map((f) => ({ ...f, name: f.name ?? slugifyIconName(f.file) })));
|
|
123
|
+
const added = [];
|
|
124
|
+
const refused = [];
|
|
125
|
+
const create = [];
|
|
126
|
+
checks.forEach((check, i) => {
|
|
127
|
+
if (check.problem !== undefined) {
|
|
128
|
+
refused.push({ file: check.file, reason: check.problem });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const reference = `${request.prefix}:${check.name}`;
|
|
132
|
+
create.push({ path: iconFilePath(request.prefix, check.name), text: request.files[i].svg });
|
|
133
|
+
const icon = sanitizeSvg(request.files[i].svg);
|
|
134
|
+
added.push({
|
|
135
|
+
file: check.file,
|
|
136
|
+
reference,
|
|
137
|
+
label: humanise(check.name),
|
|
138
|
+
svg: icon.ok ? geometrySvg(icon.icon, 24, 24) : null,
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
if (added.length === 0)
|
|
142
|
+
return { added, refused, assets: none, steps: [] };
|
|
143
|
+
const json = [];
|
|
144
|
+
if (!prefix.licensed) {
|
|
145
|
+
json.push({
|
|
146
|
+
path: LICENSES_FILE,
|
|
147
|
+
change: { kind: "licence", prefix: request.prefix, licence },
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
json.push({
|
|
151
|
+
path: PROJECT_LIBRARY_FILE,
|
|
152
|
+
change: {
|
|
153
|
+
kind: "libraryItems",
|
|
154
|
+
category: libraryCategoryId(request.prefix),
|
|
155
|
+
title: request.prefix,
|
|
156
|
+
items: added.map((icon) => ({ icon: icon.reference, label: icon.label })),
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
const steps = [];
|
|
160
|
+
if (diagram) {
|
|
161
|
+
for (const target of request.targets) {
|
|
162
|
+
const element = diagram.elementsById.get(target);
|
|
163
|
+
if (!element || !takesIcon(diagram, element))
|
|
164
|
+
continue;
|
|
165
|
+
const operation = {
|
|
166
|
+
kind: "setStyleProperty",
|
|
167
|
+
diagram: diagram.id,
|
|
168
|
+
target,
|
|
169
|
+
targetKind: "element",
|
|
170
|
+
property: "icon",
|
|
171
|
+
value: added[0].reference,
|
|
172
|
+
};
|
|
173
|
+
steps.push({ file: null, operation });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return { added, refused, assets: { create, json }, steps };
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=add-icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-icons.js","sourceRoot":"","sources":["../src/add-icons.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,eAAe,GAGhB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,YAAY,GACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,mDAAmD;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE7C,oFAAoF;AACpF,MAAM,OAAO,GAAG,4DAA4D,CAAC;AAE7E,qGAAqG;AACrG,SAAS,WAAW,CAAC,IAAc;IACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,YAAY,GAAG,CAAC,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAkC,EAClC,MAAc;IAEd,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC,QAAQ,CAAC;IAClC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAmB,EAAE,CAAC,CAAC;QAClD,MAAM;QACN,OAAO;QACP,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IACH,IAAI,MAAM,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC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SAAS,EAAE,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type Library } from "@meltemi/diagrams-assets";
|
|
2
|
+
import type { IconRegistry } from "@meltemi/diagrams-assets";
|
|
3
|
+
import { type Diagnostic } from "@meltemi/diagrams-language";
|
|
4
|
+
import { type LayoutOptions, type LayoutResult } from "@meltemi/diagrams-layout";
|
|
5
|
+
import { type Compilation, type FlowDiagram, type LayoutMode, type ThemeDefinition } from "@meltemi/diagrams-model";
|
|
6
|
+
import type { FontProvider } from "@meltemi/diagrams-render";
|
|
7
|
+
/** One flow or free diagram of an analysed document. */
|
|
8
|
+
export interface DiagramView {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly title: string | null;
|
|
11
|
+
readonly mode: LayoutMode;
|
|
12
|
+
readonly diagram: FlowDiagram;
|
|
13
|
+
/** The layout with the document's options; null when the diagram has compile errors. */
|
|
14
|
+
readonly layout: LayoutResult | null;
|
|
15
|
+
}
|
|
16
|
+
/** Everything the services and the canvas need about one version of a document. */
|
|
17
|
+
export interface DocumentAnalysis {
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly revision: number;
|
|
20
|
+
readonly compilation: Compilation;
|
|
21
|
+
/** Compile, module, project and layout diagnostics, deduplicated and sorted. */
|
|
22
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
23
|
+
readonly diagrams: readonly DiagramView[];
|
|
24
|
+
readonly layoutOptions: LayoutOptions;
|
|
25
|
+
/** Themes in scope for the document: its own and the imported ones. */
|
|
26
|
+
readonly themes: readonly ThemeDefinition[];
|
|
27
|
+
readonly icons: IconRegistry | undefined;
|
|
28
|
+
/** The element libraries the document can create from: built-in, project and plugin ones. */
|
|
29
|
+
readonly libraries: readonly Library[];
|
|
30
|
+
/** Embeds fonts in rendered SVG; the same library that measures text. */
|
|
31
|
+
readonly fonts: FontProvider | undefined;
|
|
32
|
+
readonly formatOptions: {
|
|
33
|
+
readonly indent: number | "tab";
|
|
34
|
+
};
|
|
35
|
+
/** Image files of the project, relative to the document, for completion. */
|
|
36
|
+
readonly imageFiles: (() => readonly string[]) | undefined;
|
|
37
|
+
/** Lays out a diagram of another file of the project, for stories that show it. */
|
|
38
|
+
readonly importedView: ImportedViews | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** A diagram of another file and its layout with that file's themes and assets. */
|
|
41
|
+
export type ImportedViews = (file: string, diagram: string) => {
|
|
42
|
+
readonly diagram: FlowDiagram;
|
|
43
|
+
readonly layout: LayoutResult;
|
|
44
|
+
} | undefined;
|
|
45
|
+
export interface AnalysisInput {
|
|
46
|
+
readonly text: string;
|
|
47
|
+
readonly revision?: number;
|
|
48
|
+
/** The compilation of `text`, for example inside a project; compiled alone by default. */
|
|
49
|
+
readonly compilation?: Compilation;
|
|
50
|
+
/** Diagnostics of the compilation and its project; the compilation's own by default. */
|
|
51
|
+
readonly diagnostics?: readonly Diagnostic[];
|
|
52
|
+
/** Layout options; the ELK engine is used when no engine is given. */
|
|
53
|
+
readonly layout?: LayoutOptions;
|
|
54
|
+
readonly icons?: IconRegistry;
|
|
55
|
+
/** The libraries, or how to build them: built when first asked for, not on every analysis. */
|
|
56
|
+
readonly libraries?: readonly Library[] | (() => readonly Library[]);
|
|
57
|
+
readonly fonts?: FontProvider;
|
|
58
|
+
readonly formatOptions?: {
|
|
59
|
+
readonly indent: number | "tab";
|
|
60
|
+
};
|
|
61
|
+
/** Lists the project's image files relative to the document. */
|
|
62
|
+
readonly imageFiles?: () => readonly string[];
|
|
63
|
+
/** Lays out diagrams of other files of the project, for stories. */
|
|
64
|
+
readonly importedView?: ImportedViews;
|
|
65
|
+
}
|
|
66
|
+
/** Compiles (unless given a compilation), lays out every diagram and merges diagnostics. */
|
|
67
|
+
export declare function analyzeDocument(input: AnalysisInput): DocumentAnalysis;
|
|
68
|
+
/** The view of a diagram by id. */
|
|
69
|
+
export declare function diagramView(analysis: DocumentAnalysis, id: string): DiagramView | undefined;
|
|
70
|
+
//# sourceMappingURL=analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../src/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEhG,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CACtC;AAED,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,gFAAgF;IAChF,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,QAAQ,CA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AC9F,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,CAAC,MAAM,SAAS,OAAO,EAAE,CAAC,CAAC;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAC;IAC7D,gEAAgE;IAChE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC;IAC9C,oEAAoE;IACpE,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC;CACvC;AAMD,4FAA4F;AAC5F,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,gBAAgB,CA4CtE;AAED,mCAAmC;AACnC,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAE3F"}
|
package/dist/analysis.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {} from "@meltemi/diagrams-assets";
|
|
2
|
+
import { sortDiagnostics } from "@meltemi/diagrams-language";
|
|
3
|
+
import { layoutDiagram } from "@meltemi/diagrams-layout";
|
|
4
|
+
import { createElkEngine } from "@meltemi/diagrams-layout-elk";
|
|
5
|
+
import { compile, } from "@meltemi/diagrams-model";
|
|
6
|
+
let defaultEngine;
|
|
7
|
+
const key = (d) => `${d.code}@${d.range.start.offset}:${d.range.end.offset}`;
|
|
8
|
+
/** Compiles (unless given a compilation), lays out every diagram and merges diagnostics. */
|
|
9
|
+
export function analyzeDocument(input) {
|
|
10
|
+
const compilation = input.compilation ?? compile(input.text);
|
|
11
|
+
const layoutOptions = {
|
|
12
|
+
...input.layout,
|
|
13
|
+
engine: input.layout?.engine ?? (defaultEngine ??= createElkEngine()),
|
|
14
|
+
};
|
|
15
|
+
const diagnostics = [...(input.diagnostics ?? compilation.diagnostics)];
|
|
16
|
+
const seen = new Set(diagnostics.map(key));
|
|
17
|
+
const diagrams = compilation.document.diagrams.map((diagram) => {
|
|
18
|
+
const layout = diagram.hasErrors ? null : layoutDiagram(compilation, diagram, layoutOptions);
|
|
19
|
+
for (const d of layout?.diagnostics ?? []) {
|
|
20
|
+
if (seen.has(key(d)))
|
|
21
|
+
continue;
|
|
22
|
+
seen.add(key(d));
|
|
23
|
+
diagnostics.push(d);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
id: diagram.id,
|
|
27
|
+
title: diagram.properties.title,
|
|
28
|
+
mode: diagram.properties.layout,
|
|
29
|
+
diagram,
|
|
30
|
+
layout,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
const given = input.libraries ?? [];
|
|
34
|
+
let libraries = typeof given === "function" ? undefined : given;
|
|
35
|
+
return {
|
|
36
|
+
text: input.text,
|
|
37
|
+
revision: input.revision ?? 0,
|
|
38
|
+
compilation,
|
|
39
|
+
diagnostics: sortDiagnostics(diagnostics),
|
|
40
|
+
diagrams,
|
|
41
|
+
layoutOptions,
|
|
42
|
+
themes: layoutOptions.themes ?? compilation.document.themes,
|
|
43
|
+
icons: input.icons,
|
|
44
|
+
// Libraries read packs' categories (Tabler's are a 2 MB file): only the panel needs them.
|
|
45
|
+
get libraries() {
|
|
46
|
+
libraries ??= given();
|
|
47
|
+
return libraries;
|
|
48
|
+
},
|
|
49
|
+
fonts: input.fonts,
|
|
50
|
+
formatOptions: input.formatOptions ?? { indent: 2 },
|
|
51
|
+
imageFiles: input.imageFiles,
|
|
52
|
+
importedView: input.importedView,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** The view of a diagram by id. */
|
|
56
|
+
export function diagramView(analysis, id) {
|
|
57
|
+
return analysis.diagrams.find((d) => d.id === id);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=analysis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.js","sourceRoot":"","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;AAED,mCAAmC;AACnC,MAAM,UAAU,WAAW,CAAC,QAA0B,EAAE,EAAU;IAChE,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { EditOperation } from "@meltemi/diagrams-edit";
|
|
2
|
+
import { type Point } from "@meltemi/diagrams-model";
|
|
3
|
+
import { type DiagramView, type DocumentAnalysis } from "./analysis.js";
|
|
4
|
+
/**
|
|
5
|
+
* The interior origin of a group of a free diagram, which its children's places are measured
|
|
6
|
+
* from: the layout's origin of its children, or for an empty group its padding and its own header
|
|
7
|
+
* (the padding alone when it is untitled). (0, 0) for the top level and for flow diagrams, whose
|
|
8
|
+
* places are in diagram coordinates.
|
|
9
|
+
*/
|
|
10
|
+
export declare function interiorOf(view: DiagramView, group: string | null): Point;
|
|
11
|
+
/**
|
|
12
|
+
* The `convertToContainer` operation for a flow node or a free box, with the elements drawn
|
|
13
|
+
* stacked on it as its children: siblings declared after it on its layer whose box lies inside
|
|
14
|
+
* its own (the composition checks' stack rule). Free children are placed in the interior the
|
|
15
|
+
* group will have; the group keeps the size it is drawn with. Undefined when it is not drawn.
|
|
16
|
+
*/
|
|
17
|
+
export declare function containerOperation(view: DiagramView, id: string): {
|
|
18
|
+
readonly operation: EditOperation & {
|
|
19
|
+
kind: "convertToContainer";
|
|
20
|
+
};
|
|
21
|
+
readonly children: readonly string[];
|
|
22
|
+
} | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* The first moved element that lands stacked on a node or box of its layer, which is no
|
|
25
|
+
* container: the hint that converting the box would carry the element with it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function stackedAfterMove(view: DiagramView, ids: readonly string[], delta: Point): {
|
|
28
|
+
readonly inner: string;
|
|
29
|
+
readonly outer: string;
|
|
30
|
+
} | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The operations that keep the groups an element leaves or enters drawn where they are, for a
|
|
33
|
+
* move of `leaving` into `target` (null: the top level), in one edit with it:
|
|
34
|
+
*
|
|
35
|
+
* - a group left with no children that lacks `place` or `size` gets the place and the size it is
|
|
36
|
+
* drawn with, as an empty group needs both;
|
|
37
|
+
* - in a free diagram, a placed group without `size` that is left or entered gets the size it is
|
|
38
|
+
* drawn with, so that its interior, where its children are placed, does not move: the element
|
|
39
|
+
* lands where it was dropped and the other children stay.
|
|
40
|
+
*/
|
|
41
|
+
export declare function steadyGroups(view: DiagramView, leaving: readonly string[], target: string | null): EditOperation[];
|
|
42
|
+
/**
|
|
43
|
+
* The `arrange` operation that writes what ELK draws: the unplaced elements around the placed
|
|
44
|
+
* ones (`unplaced`, laid out as `assisted`), or every element anew (`all`, laid out as `auto`),
|
|
45
|
+
* with the bends of the drawn connectors. Undefined when the diagram cannot be arranged.
|
|
46
|
+
*/
|
|
47
|
+
export declare function arrangeOperation(analysis: DocumentAnalysis, diagramId: string, scope: "unplaced" | "all"): EditOperation | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* The `arrange` operation of `arrangeOperation`, or the first problem that keeps the diagram from
|
|
50
|
+
* being arranged: an error of the text or of the layout, as written in its diagnostic.
|
|
51
|
+
*/
|
|
52
|
+
export declare function arrangeAttempt(analysis: DocumentAnalysis, diagramId: string, scope: "unplaced" | "all"): {
|
|
53
|
+
readonly operation?: EditOperation;
|
|
54
|
+
readonly problem?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The `arrange` operation that writes the positions drawn now, so that an `auto` diagram
|
|
58
|
+
* becomes `assisted` without any box moving: the first step of a canvas gesture in `auto`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function materializeOperation(view: DiagramView): EditOperation | undefined;
|
|
61
|
+
/** A top-level id not used in the file: `base`, then `base_2`, `base_3`… */
|
|
62
|
+
export declare function freeDiagramId(analysis: DocumentAnalysis, base: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* The `convertToFree` operation that copies a flow diagram, as drawn now, into a new free diagram
|
|
65
|
+
* named `id` (`<diagram>_free` by default), or undefined when the diagram is not drawn.
|
|
66
|
+
*/
|
|
67
|
+
export declare function convertOperation(analysis: DocumentAnalysis, diagramId: string, id?: string): (EditOperation & {
|
|
68
|
+
kind: "convertToFree";
|
|
69
|
+
id: string;
|
|
70
|
+
}) | undefined;
|
|
71
|
+
//# sourceMappingURL=arrange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrange.d.ts","sourceRoot":"","sources":["../src/arrange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,OAAO,EAA8C,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAe,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAErF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAczE;AAKD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,WAAW,EACjB,EAAE,EAAE,MAAM,GAER;IACE,QAAQ,CAAC,SAAS,EAAE,aAAa,GAAG;QAAE,IAAI,EAAE,oBAAoB,CAAA;KAAE,CAAC;IACnE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,GACD,SAAS,CA2CZ;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,SAAS,MAAM,EAAE,EACtB,KAAK,EAAE,KAAK,GACX;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAuBhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY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