@formicoidea/labre-framework-c4 0.50.0 → 0.51.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/dist/interchange-headless.d.ts +37 -0
- package/dist/interchange-headless.js +43 -0
- package/dist/interchange.d.ts +2 -25
- package/dist/interchange.js +2 -32
- package/package.json +7 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { InterchangeFormat } from '@formicoidea/labre-core/interchange';
|
|
2
|
+
/**
|
|
3
|
+
* `@labre/affine-gfx-c4/interchange` — C4's format declaration, with no editor
|
|
4
|
+
* behind it (ADR 0012, P3 as amended 2026-10-14).
|
|
5
|
+
*
|
|
6
|
+
* C4 has one capability, mermaid OUT, and it is not here: the writer reads
|
|
7
|
+
* live element models (`c4BoardFrom` by `instanceof`, `roleIsA`), which is the
|
|
8
|
+
* editor graph this entry exists to leave out. What a host without an editor
|
|
9
|
+
* can still use is the declaration — which extension, which media type, which
|
|
10
|
+
* file name — to route or name a file. `interchange.ts` re-exports all of it.
|
|
11
|
+
*
|
|
12
|
+
* Held by `interchange-headless.unit.spec.ts` in `packages/affine/all`.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* mermaid C4 source. **Semantic** — the file carries a model, not a picture, so
|
|
16
|
+
* it takes the whole preservation contract the day an importer is written.
|
|
17
|
+
*
|
|
18
|
+
* `.mmd` is the extension the mermaid CLI and every editor plugin watch for.
|
|
19
|
+
* The format carries no `mime`, where `BPMN_XML_FORMAT` carries
|
|
20
|
+
* `application/xml`, and the difference is the truth rather than an oversight:
|
|
21
|
+
* mermaid has no registered media type, so there is none to declare. What a
|
|
22
|
+
* DOWNLOAD is served as is a different question with an answer — `text/plain`,
|
|
23
|
+
* because an invented type is a file some browsers refuse to save — and that
|
|
24
|
+
* answer is stated on the export result, where it belongs.
|
|
25
|
+
*
|
|
26
|
+
* The charset rides along with it because the text is the whole payload: unlike
|
|
27
|
+
* XML, a mermaid file has no prolog to declare its own encoding in.
|
|
28
|
+
*/
|
|
29
|
+
export declare const C4_MERMAID_EXTENSION = ".mmd";
|
|
30
|
+
export declare const C4_MERMAID_MIME = "text/plain;charset=utf-8";
|
|
31
|
+
export declare const C4_MERMAID_FORMAT: InterchangeFormat;
|
|
32
|
+
/**
|
|
33
|
+
* A name a file system will accept, minus the extension: the shared
|
|
34
|
+
* `safeFilename` with C4's fallback, `diagram`. Held to it by
|
|
35
|
+
* `safe-filename-parity.unit.spec.ts`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function c4SafeFilename(raw: string | undefined): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { safeFilename } from '@formicoidea/labre-core/shared/headless';
|
|
2
|
+
/**
|
|
3
|
+
* `@labre/affine-gfx-c4/interchange` — C4's format declaration, with no editor
|
|
4
|
+
* behind it (ADR 0012, P3 as amended 2026-10-14).
|
|
5
|
+
*
|
|
6
|
+
* C4 has one capability, mermaid OUT, and it is not here: the writer reads
|
|
7
|
+
* live element models (`c4BoardFrom` by `instanceof`, `roleIsA`), which is the
|
|
8
|
+
* editor graph this entry exists to leave out. What a host without an editor
|
|
9
|
+
* can still use is the declaration — which extension, which media type, which
|
|
10
|
+
* file name — to route or name a file. `interchange.ts` re-exports all of it.
|
|
11
|
+
*
|
|
12
|
+
* Held by `interchange-headless.unit.spec.ts` in `packages/affine/all`.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* mermaid C4 source. **Semantic** — the file carries a model, not a picture, so
|
|
16
|
+
* it takes the whole preservation contract the day an importer is written.
|
|
17
|
+
*
|
|
18
|
+
* `.mmd` is the extension the mermaid CLI and every editor plugin watch for.
|
|
19
|
+
* The format carries no `mime`, where `BPMN_XML_FORMAT` carries
|
|
20
|
+
* `application/xml`, and the difference is the truth rather than an oversight:
|
|
21
|
+
* mermaid has no registered media type, so there is none to declare. What a
|
|
22
|
+
* DOWNLOAD is served as is a different question with an answer — `text/plain`,
|
|
23
|
+
* because an invented type is a file some browsers refuse to save — and that
|
|
24
|
+
* answer is stated on the export result, where it belongs.
|
|
25
|
+
*
|
|
26
|
+
* The charset rides along with it because the text is the whole payload: unlike
|
|
27
|
+
* XML, a mermaid file has no prolog to declare its own encoding in.
|
|
28
|
+
*/
|
|
29
|
+
export const C4_MERMAID_EXTENSION = '.mmd';
|
|
30
|
+
export const C4_MERMAID_MIME = 'text/plain;charset=utf-8';
|
|
31
|
+
export const C4_MERMAID_FORMAT = {
|
|
32
|
+
id: 'mermaid',
|
|
33
|
+
tier: 'semantic',
|
|
34
|
+
extensions: [C4_MERMAID_EXTENSION],
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A name a file system will accept, minus the extension: the shared
|
|
38
|
+
* `safeFilename` with C4's fallback, `diagram`. Held to it by
|
|
39
|
+
* `safe-filename-parity.unit.spec.ts`.
|
|
40
|
+
*/
|
|
41
|
+
export function c4SafeFilename(raw) {
|
|
42
|
+
return safeFilename(raw, 'diagram');
|
|
43
|
+
}
|
package/dist/interchange.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { InterchangeCapability, InterchangeExportCapability
|
|
1
|
+
import type { InterchangeCapability, InterchangeExportCapability } from '@formicoidea/labre-core/blocks/surface';
|
|
2
2
|
import type { GfxPrimitiveElementModel } from '@formicoidea/labre-core/std/gfx';
|
|
3
3
|
import { type C4ExportBoard } from './export.js';
|
|
4
|
+
export { C4_MERMAID_EXTENSION, C4_MERMAID_FORMAT, C4_MERMAID_MIME, c4SafeFilename, } from './interchange-headless.js';
|
|
4
5
|
/**
|
|
5
6
|
* C4's entries in the interchange registry (`docs/adr/0012`, P1).
|
|
6
7
|
*
|
|
@@ -21,24 +22,6 @@ import { type C4ExportBoard } from './export.js';
|
|
|
21
22
|
* that hands over the whole surface gets every board, one document each, which
|
|
22
23
|
* is the honest whole-surface answer for this framework.
|
|
23
24
|
*/
|
|
24
|
-
/**
|
|
25
|
-
* mermaid C4 source. **Semantic** — the file carries a model, not a picture, so
|
|
26
|
-
* it takes the whole preservation contract the day an importer is written.
|
|
27
|
-
*
|
|
28
|
-
* `.mmd` is the extension the mermaid CLI and every editor plugin watch for.
|
|
29
|
-
* The format carries no `mime`, where `BPMN_XML_FORMAT` carries
|
|
30
|
-
* `application/xml`, and the difference is the truth rather than an oversight:
|
|
31
|
-
* mermaid has no registered media type, so there is none to declare. What a
|
|
32
|
-
* DOWNLOAD is served as is a different question with an answer — `text/plain`,
|
|
33
|
-
* because an invented type is a file some browsers refuse to save — and that
|
|
34
|
-
* answer is stated on the export result, where it belongs.
|
|
35
|
-
*
|
|
36
|
-
* The charset rides along with it because the text is the whole payload: unlike
|
|
37
|
-
* XML, a mermaid file has no prolog to declare its own encoding in.
|
|
38
|
-
*/
|
|
39
|
-
export declare const C4_MERMAID_EXTENSION = ".mmd";
|
|
40
|
-
export declare const C4_MERMAID_MIME = "text/plain;charset=utf-8";
|
|
41
|
-
export declare const C4_MERMAID_FORMAT: InterchangeFormat;
|
|
42
25
|
/**
|
|
43
26
|
* The artefacts the exporter speaks about, picked out of a list of elements and
|
|
44
27
|
* kept in the order they were given.
|
|
@@ -57,12 +40,6 @@ export declare const C4_MERMAID_FORMAT: InterchangeFormat;
|
|
|
57
40
|
* user can see.
|
|
58
41
|
*/
|
|
59
42
|
export declare function c4BoardFrom(elements: readonly GfxPrimitiveElementModel[]): C4ExportBoard;
|
|
60
|
-
/**
|
|
61
|
-
* A name a file system will accept, minus the extension: the shared
|
|
62
|
-
* `safeFilename` with C4's fallback, `diagram`. Held to it by
|
|
63
|
-
* `safe-filename-parity.unit.spec.ts`.
|
|
64
|
-
*/
|
|
65
|
-
export declare function c4SafeFilename(raw: string | undefined): string;
|
|
66
43
|
/** `c4:mermaid:export` — C4's first capability. */
|
|
67
44
|
export declare const C4_MERMAID_EXPORT: InterchangeExportCapability;
|
|
68
45
|
/** Everything C4 registers, in one list the view extension can hand over. */
|
package/dist/interchange.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { interchangeCapabilityId } from '@formicoidea/labre-core/blocks/surface';
|
|
2
2
|
import { C4BoardElementModel, C4BoundaryElementModel, C4NodeElementModel, ConnectorElementModel, GroupElementModel, TextElementModel, } from '@formicoidea/labre-core/model';
|
|
3
|
-
import { safeFilename } from '@formicoidea/labre-core/shared/utils';
|
|
4
3
|
import { exportC4Mermaid } from './export.js';
|
|
4
|
+
import { C4_MERMAID_EXTENSION, C4_MERMAID_FORMAT, C4_MERMAID_MIME, c4SafeFilename, } from './interchange-headless.js';
|
|
5
|
+
export { C4_MERMAID_EXTENSION, C4_MERMAID_FORMAT, C4_MERMAID_MIME, c4SafeFilename, } from './interchange-headless.js';
|
|
5
6
|
/**
|
|
6
7
|
* C4's entries in the interchange registry (`docs/adr/0012`, P1).
|
|
7
8
|
*
|
|
@@ -22,29 +23,6 @@ import { exportC4Mermaid } from './export.js';
|
|
|
22
23
|
* that hands over the whole surface gets every board, one document each, which
|
|
23
24
|
* is the honest whole-surface answer for this framework.
|
|
24
25
|
*/
|
|
25
|
-
/* ── The format ───────────────────────────────────────────────────────── */
|
|
26
|
-
/**
|
|
27
|
-
* mermaid C4 source. **Semantic** — the file carries a model, not a picture, so
|
|
28
|
-
* it takes the whole preservation contract the day an importer is written.
|
|
29
|
-
*
|
|
30
|
-
* `.mmd` is the extension the mermaid CLI and every editor plugin watch for.
|
|
31
|
-
* The format carries no `mime`, where `BPMN_XML_FORMAT` carries
|
|
32
|
-
* `application/xml`, and the difference is the truth rather than an oversight:
|
|
33
|
-
* mermaid has no registered media type, so there is none to declare. What a
|
|
34
|
-
* DOWNLOAD is served as is a different question with an answer — `text/plain`,
|
|
35
|
-
* because an invented type is a file some browsers refuse to save — and that
|
|
36
|
-
* answer is stated on the export result, where it belongs.
|
|
37
|
-
*
|
|
38
|
-
* The charset rides along with it because the text is the whole payload: unlike
|
|
39
|
-
* XML, a mermaid file has no prolog to declare its own encoding in.
|
|
40
|
-
*/
|
|
41
|
-
export const C4_MERMAID_EXTENSION = '.mmd';
|
|
42
|
-
export const C4_MERMAID_MIME = 'text/plain;charset=utf-8';
|
|
43
|
-
export const C4_MERMAID_FORMAT = {
|
|
44
|
-
id: 'mermaid',
|
|
45
|
-
tier: 'semantic',
|
|
46
|
-
extensions: [C4_MERMAID_EXTENSION],
|
|
47
|
-
};
|
|
48
26
|
/* ── Pure board helpers ───────────────────────────────────────────────── */
|
|
49
27
|
/**
|
|
50
28
|
* The artefacts the exporter speaks about, picked out of a list of elements and
|
|
@@ -86,14 +64,6 @@ export function c4BoardFrom(elements) {
|
|
|
86
64
|
}
|
|
87
65
|
return { boards, nodes, boundaries, connectors, texts, groups };
|
|
88
66
|
}
|
|
89
|
-
/**
|
|
90
|
-
* A name a file system will accept, minus the extension: the shared
|
|
91
|
-
* `safeFilename` with C4's fallback, `diagram`. Held to it by
|
|
92
|
-
* `safe-filename-parity.unit.spec.ts`.
|
|
93
|
-
*/
|
|
94
|
-
export function c4SafeFilename(raw) {
|
|
95
|
-
return safeFilename(raw, 'diagram');
|
|
96
|
-
}
|
|
97
67
|
/* ── The capability ───────────────────────────────────────────────────── */
|
|
98
68
|
/**
|
|
99
69
|
* The board as a mermaid C4 document.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formicoidea/labre-framework-c4",
|
|
3
3
|
"description": "Labre c4 framework for @formicoidea/labre-core.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.51.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "lajola",
|
|
@@ -25,14 +25,18 @@
|
|
|
25
25
|
"./commands-manifest": {
|
|
26
26
|
"types": "./dist/commands-manifest.d.ts",
|
|
27
27
|
"import": "./dist/commands-manifest.js"
|
|
28
|
+
},
|
|
29
|
+
"./interchange": {
|
|
30
|
+
"types": "./dist/interchange-headless.d.ts",
|
|
31
|
+
"import": "./dist/interchange-headless.js"
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
"files": [
|
|
31
35
|
"dist"
|
|
32
36
|
],
|
|
33
37
|
"dependencies": {
|
|
34
|
-
"@formicoidea/labre-core": "0.
|
|
35
|
-
"@formicoidea/labre-ddd-shared": "0.
|
|
38
|
+
"@formicoidea/labre-core": "0.51.0",
|
|
39
|
+
"@formicoidea/labre-ddd-shared": "0.51.0",
|
|
36
40
|
"lit": "^3.2.0"
|
|
37
41
|
}
|
|
38
42
|
}
|