@cardenelabs/dragon 0.39.0 → 0.41.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.
Files changed (44) hide show
  1. package/README.md +39 -1
  2. package/dist/cli.cjs +1921 -429
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +1926 -434
  5. package/dist/cli.js.map +1 -1
  6. package/dist/export.cjs +1718 -353
  7. package/dist/export.cjs.map +1 -1
  8. package/dist/export.d.cts +1 -1
  9. package/dist/export.d.ts +1 -1
  10. package/dist/export.js +1723 -358
  11. package/dist/export.js.map +1 -1
  12. package/dist/index.cjs +1835 -342
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +5 -15
  15. package/dist/index.d.ts +5 -15
  16. package/dist/index.js +1836 -342
  17. package/dist/index.js.map +1 -1
  18. package/dist/{ink-Cg-v6XSG.d.cts → ink-B_7OXxtb.d.cts} +27 -2
  19. package/dist/{ink-Cg-v6XSG.d.ts → ink-B_7OXxtb.d.ts} +27 -2
  20. package/dist/node.cjs +2946 -0
  21. package/dist/node.cjs.map +1 -0
  22. package/dist/node.d.cts +9 -0
  23. package/dist/node.d.ts +9 -0
  24. package/dist/node.js +2944 -0
  25. package/dist/node.js.map +1 -0
  26. package/dist/player.global.js +2 -2
  27. package/package.json +11 -1
  28. package/src/field-messages.ts +8 -0
  29. package/src/index.ts +5 -2
  30. package/src/layout/git.ts +728 -0
  31. package/src/look/values.ts +40 -1
  32. package/src/messages.ts +47 -4
  33. package/src/node.ts +23 -0
  34. package/src/parser.ts +142 -7
  35. package/src/printer.ts +16 -4
  36. package/src/render/git.ts +161 -0
  37. package/src/render/parts.ts +1 -1
  38. package/src/render/svg.ts +26 -1
  39. package/src/schema.ts +47 -13
  40. package/src/schemas/diagram.schema.json +75 -8
  41. package/src/schemas/validate-diagram.js +1 -1
  42. package/src/timeline.ts +18 -3
  43. package/src/version.ts +1 -20
  44. package/src/words.ts +19 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardenelabs/dragon",
3
- "version": "0.39.0",
3
+ "version": "0.41.0",
4
4
  "description": "Dragon — 動く図を、人は行ごとの記法で、AI は JSON で書く。時系列図と構成図を段ごとに動かし、mp4・GIF・HTML・PNG に書き出す。",
5
5
  "license": "MIT",
6
6
  "author": "cardene777",
@@ -52,6 +52,16 @@
52
52
  "types": "./dist/export.d.cts",
53
53
  "default": "./dist/export.cjs"
54
54
  }
55
+ },
56
+ "./node": {
57
+ "import": {
58
+ "types": "./dist/node.d.ts",
59
+ "default": "./dist/node.js"
60
+ },
61
+ "require": {
62
+ "types": "./dist/node.d.cts",
63
+ "default": "./dist/node.cjs"
64
+ }
55
65
  }
56
66
  },
57
67
  "files": [
@@ -34,6 +34,10 @@ export interface FieldMessages {
34
34
  not: (allowed: Allowed | undefined) => string;
35
35
  /** 状態遷移図の箱の名札に、始まりと終わりの印の名前 (`names`) を書いた */
36
36
  reserved: (names: readonly string[]) => string;
37
+ /** `kind` の図だけが書ける出来事の種類 (`types`) を、別の種類の図に書いた (#3164) */
38
+ kindOnly: (types: readonly string[], kind: string) => string;
39
+ /** 16 進の字を `min` から `max` 字で書く決まり (commit の hash、#3164) */
40
+ hex: (min: number, max: number) => string;
37
41
  /** 選べる決まりがどれも欄が足りない時の、足りない欄。それ以外の時は空 */
38
42
  anyOf: (fields: readonly string[]) => string;
39
43
  oneOf: string;
@@ -77,6 +81,8 @@ const ja: FieldMessages = {
77
81
  const: (value) => `${value} にする`,
78
82
  not: (allowed) => (allowed ? `${allowed.field} の欄は kind が ${allowed.kind} の時だけ書ける` : "この欄の組み合わせは書けない"),
79
83
  reserved: (names) => `${names.join(" と ")} は状態遷移図の始まりと終わりの印の名前で、箱の名札に使えない`,
84
+ kindOnly: (types, kind) => `${types.join(" と ")} の出来事は kind が ${kind} の時だけ書ける`,
85
+ hex: (min, max) => `0 から 9 と a から f の字で ${min} から ${max} 字にする`,
80
86
  anyOf: (fields) =>
81
87
  fields.length > 0 ? `${fields.join(" か ")} の${fields.length === 2 ? "どちらか" : "どれか"}の欄が要る` : "書ける形のどれにも合わない",
82
88
  oneOf: "書ける形のどれか 1 つだけに合わせる",
@@ -99,6 +105,8 @@ const en: FieldMessages = {
99
105
  const: (value) => `Use ${value}`,
100
106
  not: (allowed) => (allowed ? `The ${allowed.field} field is allowed only when kind is ${allowed.kind}` : "This combination of fields is not allowed"),
101
107
  reserved: (names) => `${names.join(" and ")} name the start and end marks of a state diagram and cannot be box ids`,
108
+ kindOnly: (types, kind) => `${types.join(" and ")} events are allowed only when kind is ${kind}`,
109
+ hex: (min, max) => `Use ${min} to ${max} characters of 0-9 and a-f`,
102
110
  anyOf: (fields) => (fields.length > 0 ? `Write one of the ${fields.join(" or ")} fields` : "Does not match any of the allowed shapes"),
103
111
  oneOf: "Match exactly one of the allowed shapes",
104
112
  discriminator: (tag, values) => `${tag} is one of ${values.join(" / ")}`,
package/src/index.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * 図の原本は JSON で、人は行の頭の英語の語で行の種類を決める dragon記法で書く。記法と JSON は行き来でき、
5
5
  * JSON は JSON Schema 1 本で検査する。原本から図を描き、頁に置いて段ごとに動かす。
6
- * 頁に字を読み込むのは別の入口 `@cardenelabs/dragon/fonts`。
6
+ * 頁に字を読み込むのは別の入口 `@cardenelabs/dragon/fonts`、原本の file を移すのは Node でだけ動く入口 `@cardenelabs/dragon/node`。
7
+ * この入口は頁を束ねる道具が読むため、Node の組み込みの module を読む部品を置かない (#3206)。
7
8
  */
8
9
  export { extractDiagrams, type Fence } from "./markdown";
9
10
  export { type LineError, type ParseOptions, type Parsed, parseNotation } from "./parser";
@@ -18,6 +19,8 @@ export {
18
19
  type Diagram,
19
20
  type DiagramEvent,
20
21
  type FieldError,
22
+ type GitBranch,
23
+ type GitCommit,
21
24
  type LabelSide,
22
25
  type Region,
23
26
  type StatePath,
@@ -25,7 +28,7 @@ export {
25
28
  validateDiagram,
26
29
  type ViewMode,
27
30
  } from "./schema";
28
- export { FORMAT_VERSION, type Migrated, migrateFile, type Read, readDiagram } from "./version";
31
+ export { FORMAT_VERSION, type Read, readDiagram } from "./version";
29
32
  export type {
30
33
  Layout,
31
34
  Point,