@meltemi/diagrams-project 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 +52 -2
- package/dist/assets.d.ts +81 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +633 -0
- package/dist/assets.js.map +1 -0
- package/dist/files.d.ts +25 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +50 -0
- package/dist/files.js.map +1 -0
- package/dist/host.d.ts +36 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +58 -0
- package/dist/host.js.map +1 -0
- package/dist/images.d.ts +50 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +106 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +45 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +167 -0
- package/dist/json.js.map +1 -0
- package/dist/manifest.d.ts +168 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +509 -0
- package/dist/manifest.js.map +1 -0
- package/dist/messages/en.d.ts +328 -0
- package/dist/messages/en.d.ts.map +1 -0
- package/dist/messages/en.js +329 -0
- package/dist/messages/en.js.map +1 -0
- package/dist/messages/es.d.ts +4 -0
- package/dist/messages/es.d.ts.map +1 -0
- package/dist/messages/es.js +255 -0
- package/dist/messages/es.js.map +1 -0
- package/dist/messages/index.d.ts +241 -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/node.d.ts +6 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +39 -0
- package/dist/node.js.map +1 -0
- package/dist/paths.d.ts +27 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +90 -0
- package/dist/paths.js.map +1 -0
- package/dist/plugins.d.ts +60 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +247 -0
- package/dist/plugins.js.map +1 -0
- package/dist/presence.d.ts +13 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +44 -0
- package/dist/presence.js.map +1 -0
- package/dist/program.d.ts +118 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +874 -0
- package/dist/program.js.map +1 -0
- package/dist/rename.d.ts +36 -0
- package/dist/rename.d.ts.map +1 -0
- package/dist/rename.js +108 -0
- package/dist/rename.js.map +1 -0
- package/dist/root.d.ts +10 -0
- package/dist/root.d.ts.map +1 -0
- package/dist/root.js +28 -0
- package/dist/root.js.map +1 -0
- package/dist/semver.d.ts +21 -0
- package/dist/semver.d.ts.map +1 -0
- package/dist/semver.js +71 -0
- package/dist/semver.js.map +1 -0
- package/dist/sources.d.ts +9 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/sources.js +50 -0
- package/dist/sources.js.map +1 -0
- package/dist/templates.d.ts +60 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +57 -0
- package/dist/templates.js.map +1 -0
- package/dist/workspace.d.ts +85 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +253 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +46 -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,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @meltemi/diagrams-project
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Projects of `.meltemi` files: `project.json`, relative imports with namespaces, shared themes,
|
|
4
|
+
models and stories across files, assets, plugins and limits, compiled incrementally through a
|
|
5
|
+
host that can be the file system, a browser's memory or an editor's buffers.
|
|
6
|
+
|
|
7
|
+
It is part of [Meltemi Diagrams](https://github.com/askenaz-dev/meltemi-diagrams#readme), diagrams as code with a canvas, motion and
|
|
8
|
+
exports. Every package of the product has the same version.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @meltemi/diagrams-project
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Node 22.12.0 or later. The package is an ES module with type declarations.
|
|
17
|
+
|
|
18
|
+
## Use
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { Workspace, createMemoryHost } from "@meltemi/diagrams-project";
|
|
22
|
+
|
|
23
|
+
const text = `language "0.2"
|
|
24
|
+
|
|
25
|
+
diagram shop: flow {
|
|
26
|
+
web["Web shop"]
|
|
27
|
+
api["Orders API"]
|
|
28
|
+
db[("Orders")]
|
|
29
|
+
web -> api: "HTTPS" as call
|
|
30
|
+
api -> db: "SQL" as store
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const host = createMemoryHost({
|
|
35
|
+
"/shop/project.json": '{ "name": "shop", "language": "0.2" }',
|
|
36
|
+
"/shop/diagrams/overview.meltemi": text,
|
|
37
|
+
});
|
|
38
|
+
const workspace = new Workspace(host, "/shop", { toolVersion: "1.0.0" });
|
|
39
|
+
const program = workspace.compileProject();
|
|
40
|
+
for (const [path, file] of program.files) {
|
|
41
|
+
console.log(path, file.compilation.diagnostics.length); // /shop/diagrams/overview.meltemi 0
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
|
|
47
|
+
- [Projects](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/language/projects.md)
|
|
48
|
+
- [Plugins](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/plugins.md)
|
|
49
|
+
- [All documentation](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/README.md)
|
|
50
|
+
|
|
51
|
+
## Licence
|
|
52
|
+
|
|
53
|
+
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).
|
package/dist/assets.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { IconRegistry, type AssetLock, type IconPack, type IconProblem, type Library } from "@meltemi/diagrams-assets";
|
|
2
|
+
import { type Diagnostic } from "@meltemi/diagrams-language";
|
|
3
|
+
import type { ProjectHost } from "./host.js";
|
|
4
|
+
import type { LoadedPlugin } from "./plugins.js";
|
|
5
|
+
import type { ManifestResult } from "./manifest.js";
|
|
6
|
+
/** Folders and files of a project's assets, relative to the root. */
|
|
7
|
+
export declare const ICONS_FOLDER = "assets/icons";
|
|
8
|
+
export declare const FONTS_FOLDER = "assets/fonts";
|
|
9
|
+
export declare const LICENSES_FILE = "assets/licenses.json";
|
|
10
|
+
/** The library file that names the icons added from the editor. */
|
|
11
|
+
export declare const PROJECT_LIBRARY_FILE = "assets/libraries/project.json";
|
|
12
|
+
/** The project path of an icon of an SVG folder pack: `assets/icons/<prefix>/<name>.svg`. */
|
|
13
|
+
export declare function iconFilePath(prefix: string, name: string): string;
|
|
14
|
+
/** What a host knows about a font file: its family and whether it may be embedded. */
|
|
15
|
+
export type FontInspection = {
|
|
16
|
+
readonly ok: true;
|
|
17
|
+
readonly family: string;
|
|
18
|
+
readonly weight: number;
|
|
19
|
+
readonly style: "normal" | "italic";
|
|
20
|
+
readonly restricted: boolean;
|
|
21
|
+
} | {
|
|
22
|
+
readonly ok: false;
|
|
23
|
+
readonly message: string;
|
|
24
|
+
};
|
|
25
|
+
/** Host services for assets: the built-in packs and font parsing (for example a `FontLibrary`). */
|
|
26
|
+
export interface AssetServices {
|
|
27
|
+
readonly builtInPacks?: readonly IconPack[];
|
|
28
|
+
readonly inspectFont?: (data: Uint8Array, path: string) => FontInspection;
|
|
29
|
+
}
|
|
30
|
+
export interface LicenseEntry {
|
|
31
|
+
readonly license: string;
|
|
32
|
+
readonly title?: string;
|
|
33
|
+
readonly version?: string;
|
|
34
|
+
readonly url?: string;
|
|
35
|
+
readonly author?: string;
|
|
36
|
+
readonly redistribute?: boolean;
|
|
37
|
+
readonly opticalScale?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface ProjectFontAsset {
|
|
40
|
+
/** Project path of the file. */
|
|
41
|
+
readonly path: string;
|
|
42
|
+
/** Path relative to the root, as written in locks and listings. */
|
|
43
|
+
readonly relative: string;
|
|
44
|
+
readonly family: string | null;
|
|
45
|
+
readonly weight: number | null;
|
|
46
|
+
readonly style: "normal" | "italic" | null;
|
|
47
|
+
readonly restricted: boolean;
|
|
48
|
+
readonly license: string | null;
|
|
49
|
+
readonly metadata: Partial<LicenseEntry>;
|
|
50
|
+
readonly integrity: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ProjectAssets {
|
|
53
|
+
readonly registry: IconRegistry;
|
|
54
|
+
/** Project packs with the project path of their file or folder. */
|
|
55
|
+
readonly packs: readonly {
|
|
56
|
+
readonly pack: IconPack;
|
|
57
|
+
readonly path: string;
|
|
58
|
+
}[];
|
|
59
|
+
/** Libraries of `assets/libraries/` and of plugins, in that order. */
|
|
60
|
+
readonly libraries: readonly Library[];
|
|
61
|
+
readonly fonts: readonly ProjectFontAsset[];
|
|
62
|
+
/** The lock describing the assets as they are now. */
|
|
63
|
+
readonly lock: AssetLock;
|
|
64
|
+
/** The lock written in `assets.lock.json`, or null when there is none. */
|
|
65
|
+
readonly writtenLock: AssetLock | null;
|
|
66
|
+
/** Diagnostics by the project path of the file they concern. */
|
|
67
|
+
readonly diagnostics: ReadonlyMap<string, readonly Diagnostic[]>;
|
|
68
|
+
/** Every file read, so editors know when to discover again. */
|
|
69
|
+
readonly files: readonly string[];
|
|
70
|
+
}
|
|
71
|
+
/** The diagnostic code of an icon that cannot be used. */
|
|
72
|
+
export declare function iconProblemCode(problem: IconProblem): string;
|
|
73
|
+
/**
|
|
74
|
+
* Discovers and checks the assets of a project: icon packs under `assets/icons/`, fonts under
|
|
75
|
+
* `assets/fonts/`, `assets/licenses.json`, the aliases of `project.json` and the lock.
|
|
76
|
+
*/
|
|
77
|
+
export declare function discoverAssets(host: ProjectHost, root: string, manifest: ManifestResult, services: AssetServices, readText: (path: string) => string | undefined, listFolder: (path: string) => readonly {
|
|
78
|
+
name: string;
|
|
79
|
+
kind: "file" | "directory";
|
|
80
|
+
}[], plugins?: readonly LoadedPlugin[]): ProjectAssets;
|
|
81
|
+
//# sourceMappingURL=assets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,YAAY,EASZ,KAAK,SAAS,EAGd,KAAK,QAAQ,EACb,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