@dooc-dev/dooc 0.0.0-stage → 0.0.1

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 (213) hide show
  1. package/README.md +26 -2
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +244 -0
  4. package/dist/code.global.js +285 -0
  5. package/dist/compiler/bundle-urls.d.ts +3 -0
  6. package/dist/compiler/bundle-urls.js +294 -0
  7. package/dist/compiler/bundle.d.ts +2 -0
  8. package/dist/compiler/bundle.js +100 -0
  9. package/dist/compiler/check-prose.d.ts +11 -0
  10. package/dist/compiler/check-prose.js +138 -0
  11. package/dist/compiler/check-types.d.ts +44 -0
  12. package/dist/compiler/check-types.js +1 -0
  13. package/dist/compiler/check.d.ts +5 -0
  14. package/dist/compiler/check.js +450 -0
  15. package/dist/compiler/code-blocks.d.ts +17 -0
  16. package/dist/compiler/code-blocks.js +198 -0
  17. package/dist/compiler/code-languages.d.ts +10 -0
  18. package/dist/compiler/code-languages.js +109 -0
  19. package/dist/compiler/compile.d.ts +95 -0
  20. package/dist/compiler/compile.js +410 -0
  21. package/dist/compiler/config.d.ts +7 -0
  22. package/dist/compiler/config.js +52 -0
  23. package/dist/compiler/dialect.d.ts +24 -0
  24. package/dist/compiler/dialect.js +198 -0
  25. package/dist/compiler/drawio.d.ts +26 -0
  26. package/dist/compiler/drawio.js +176 -0
  27. package/dist/compiler/figures.d.ts +14 -0
  28. package/dist/compiler/figures.js +221 -0
  29. package/dist/compiler/file-cache.d.ts +14 -0
  30. package/dist/compiler/file-cache.js +61 -0
  31. package/dist/compiler/files.d.ts +29 -0
  32. package/dist/compiler/files.js +431 -0
  33. package/dist/compiler/fonts.d.ts +10 -0
  34. package/dist/compiler/fonts.js +54 -0
  35. package/dist/compiler/format.d.ts +1 -0
  36. package/dist/compiler/format.js +42 -0
  37. package/dist/compiler/from-mdast.d.ts +16 -0
  38. package/dist/compiler/from-mdast.js +142 -0
  39. package/dist/compiler/icons.d.ts +14 -0
  40. package/dist/compiler/icons.js +85 -0
  41. package/dist/compiler/language-codes.d.ts +7 -0
  42. package/dist/compiler/language-codes.js +17 -0
  43. package/dist/compiler/locales.d.ts +7 -0
  44. package/dist/compiler/locales.js +67 -0
  45. package/dist/compiler/manifest.d.ts +6 -0
  46. package/dist/compiler/manifest.js +30 -0
  47. package/dist/compiler/ops.d.ts +44 -0
  48. package/dist/compiler/ops.js +362 -0
  49. package/dist/compiler/public-file.d.ts +2 -0
  50. package/dist/compiler/public-file.js +93 -0
  51. package/dist/compiler/serialize.d.ts +3 -0
  52. package/dist/compiler/serialize.js +16 -0
  53. package/dist/compiler/terms.d.ts +9 -0
  54. package/dist/compiler/terms.js +44 -0
  55. package/dist/compiler/textfile-remote.d.ts +12 -0
  56. package/dist/compiler/textfile-remote.js +124 -0
  57. package/dist/compiler/textfile.d.ts +9 -0
  58. package/dist/compiler/textfile.js +113 -0
  59. package/dist/compiler/theme-variants.d.ts +4 -0
  60. package/dist/compiler/theme-variants.js +22 -0
  61. package/dist/compiler/zip.d.ts +6 -0
  62. package/dist/compiler/zip.js +48 -0
  63. package/dist/core/blocks.d.ts +99 -0
  64. package/dist/core/blocks.js +29 -0
  65. package/dist/core/code-file.d.ts +12 -0
  66. package/dist/core/code-file.js +68 -0
  67. package/dist/core/content-metadata.d.ts +48 -0
  68. package/dist/core/content-metadata.js +264 -0
  69. package/dist/core/content-types.d.ts +45 -0
  70. package/dist/core/content-types.js +1 -0
  71. package/dist/core/figure-frame.d.ts +12 -0
  72. package/dist/core/figure-frame.js +108 -0
  73. package/dist/core/file-embed.d.ts +13 -0
  74. package/dist/core/file-embed.js +43 -0
  75. package/dist/core/files.d.ts +15 -0
  76. package/dist/core/files.js +59 -0
  77. package/dist/core/flow-base-css.generated.d.ts +1 -0
  78. package/dist/core/flow-base-css.generated.js +4 -0
  79. package/dist/core/flow-css.d.ts +9 -0
  80. package/dist/core/flow-css.js +54 -0
  81. package/dist/core/graph-common.d.ts +32 -0
  82. package/dist/core/graph-common.js +113 -0
  83. package/dist/core/graph.d.ts +117 -0
  84. package/dist/core/graph.js +480 -0
  85. package/dist/core/html.d.ts +29 -0
  86. package/dist/core/html.js +444 -0
  87. package/dist/core/icons.d.ts +1 -0
  88. package/dist/core/icons.js +1 -0
  89. package/dist/core/inline.d.ts +27 -0
  90. package/dist/core/inline.js +42 -0
  91. package/dist/core/language.d.ts +41 -0
  92. package/dist/core/language.js +44 -0
  93. package/dist/core/languages/ja.d.ts +2 -0
  94. package/dist/core/languages/ja.js +5 -0
  95. package/dist/core/markdown.d.ts +27 -0
  96. package/dist/core/markdown.js +154 -0
  97. package/dist/core/previewers.d.ts +37 -0
  98. package/dist/core/previewers.js +103 -0
  99. package/dist/core/routing.d.ts +20 -0
  100. package/dist/core/routing.js +64 -0
  101. package/dist/core/schema-comments.d.ts +14 -0
  102. package/dist/core/schema-comments.js +52 -0
  103. package/dist/core/schema-graph-flow.d.ts +9 -0
  104. package/dist/core/schema-graph-flow.js +379 -0
  105. package/dist/core/schema-graph-mount.d.ts +9 -0
  106. package/dist/core/schema-graph-mount.js +105 -0
  107. package/dist/core/schema-graph.d.ts +254 -0
  108. package/dist/core/schema-graph.js +981 -0
  109. package/dist/core/table-ui.d.ts +2 -0
  110. package/dist/core/table-ui.js +180 -0
  111. package/dist/core/taxonomy.d.ts +12 -0
  112. package/dist/core/taxonomy.js +49 -0
  113. package/dist/core/term-reference.d.ts +5 -0
  114. package/dist/core/term-reference.js +19 -0
  115. package/dist/core/terms-ui.d.ts +6 -0
  116. package/dist/core/terms-ui.js +22 -0
  117. package/dist/core/textfile.d.ts +10 -0
  118. package/dist/core/textfile.js +39 -0
  119. package/dist/core/theme-variants.d.ts +3 -0
  120. package/dist/core/theme-variants.js +37 -0
  121. package/dist/core/toc-ui.d.ts +2 -0
  122. package/dist/core/toc-ui.js +161 -0
  123. package/dist/core/video-ui.d.ts +2 -0
  124. package/dist/core/video-ui.js +253 -0
  125. package/dist/core/workspace.d.ts +15 -0
  126. package/dist/core/workspace.js +28 -0
  127. package/dist/edit.global.js +305 -0
  128. package/dist/flow.global.js +4959 -0
  129. package/dist/index.d.ts +17 -0
  130. package/dist/index.js +31 -0
  131. package/dist/mcp.d.ts +24 -0
  132. package/dist/mcp.js +467 -0
  133. package/dist/plugins/actions.d.ts +45 -0
  134. package/dist/plugins/actions.js +125 -0
  135. package/dist/plugins/blocks.d.ts +92 -0
  136. package/dist/plugins/blocks.js +99 -0
  137. package/dist/plugins/index.d.ts +4 -0
  138. package/dist/plugins/index.js +1 -0
  139. package/dist/plugins/oauth.d.ts +14 -0
  140. package/dist/plugins/oauth.js +164 -0
  141. package/dist/plugins/runtime.d.ts +24 -0
  142. package/dist/plugins/runtime.js +339 -0
  143. package/dist/plugins/types.d.ts +56 -0
  144. package/dist/plugins/types.js +1 -0
  145. package/dist/plugins/view.d.ts +29 -0
  146. package/dist/plugins/view.js +60 -0
  147. package/dist/ui.global.js +77 -0
  148. package/dist/viewer/assets.d.ts +2 -0
  149. package/dist/viewer/assets.js +3 -0
  150. package/dist/viewer/build.d.ts +12 -0
  151. package/dist/viewer/build.js +55 -0
  152. package/dist/viewer/bundle-network.d.ts +2 -0
  153. package/dist/viewer/bundle-network.js +88 -0
  154. package/dist/viewer/code-file.d.ts +20 -0
  155. package/dist/viewer/code-file.js +42 -0
  156. package/dist/viewer/editor-tools.d.ts +38 -0
  157. package/dist/viewer/editor-tools.js +211 -0
  158. package/dist/viewer/file-references.d.ts +14 -0
  159. package/dist/viewer/file-references.js +38 -0
  160. package/dist/viewer/font-picker.d.ts +4 -0
  161. package/dist/viewer/font-picker.js +145 -0
  162. package/dist/viewer/font-settings.d.ts +11 -0
  163. package/dist/viewer/font-settings.js +50 -0
  164. package/dist/viewer/fonts/LICENSE.txt +119 -0
  165. package/dist/viewer/fonts/udev-gothic-regular.woff2 +0 -0
  166. package/dist/viewer/fonts.d.ts +2 -0
  167. package/dist/viewer/fonts.js +13 -0
  168. package/dist/viewer/git-diff.d.ts +3 -0
  169. package/dist/viewer/git-diff.js +33 -0
  170. package/dist/viewer/git-types.d.ts +73 -0
  171. package/dist/viewer/git-types.js +1 -0
  172. package/dist/viewer/git.d.ts +5 -0
  173. package/dist/viewer/git.js +337 -0
  174. package/dist/viewer/hmr.d.ts +53 -0
  175. package/dist/viewer/hmr.js +335 -0
  176. package/dist/viewer/i18n.d.ts +6 -0
  177. package/dist/viewer/i18n.js +65 -0
  178. package/dist/viewer/ja-lint.d.ts +3 -0
  179. package/dist/viewer/ja-lint.js +44 -0
  180. package/dist/viewer/language-picker.d.ts +2 -0
  181. package/dist/viewer/language-picker.js +233 -0
  182. package/dist/viewer/languages.d.ts +11 -0
  183. package/dist/viewer/languages.js +20 -0
  184. package/dist/viewer/locales/eng.json +294 -0
  185. package/dist/viewer/locales/jpn.json +294 -0
  186. package/dist/viewer/locales/zho.json +294 -0
  187. package/dist/viewer/nav-focus.d.ts +2 -0
  188. package/dist/viewer/nav-focus.js +64 -0
  189. package/dist/viewer/plugin-blocks.d.ts +3 -0
  190. package/dist/viewer/plugin-blocks.js +115 -0
  191. package/dist/viewer/plugin-config.d.ts +35 -0
  192. package/dist/viewer/plugin-config.js +57 -0
  193. package/dist/viewer/plugin-view.d.ts +3 -0
  194. package/dist/viewer/plugin-view.js +28 -0
  195. package/dist/viewer/plugins.d.ts +8 -0
  196. package/dist/viewer/plugins.js +214 -0
  197. package/dist/viewer/resize.d.ts +4 -0
  198. package/dist/viewer/resize.js +238 -0
  199. package/dist/viewer/resource-library.d.ts +29 -0
  200. package/dist/viewer/resource-library.js +104 -0
  201. package/dist/viewer/search.d.ts +16 -0
  202. package/dist/viewer/search.js +358 -0
  203. package/dist/viewer/serve.d.ts +206 -0
  204. package/dist/viewer/serve.js +3233 -0
  205. package/dist/viewer/site-icon.d.ts +8 -0
  206. package/dist/viewer/site-icon.js +56 -0
  207. package/dist/viewer/textfile.d.ts +9 -0
  208. package/dist/viewer/textfile.js +50 -0
  209. package/dist/viewer/theme-picker.d.ts +2 -0
  210. package/dist/viewer/theme-picker.js +135 -0
  211. package/dist/viewer/workspace.d.ts +4 -0
  212. package/dist/viewer/workspace.js +47 -0
  213. package/package.json +127 -5
@@ -0,0 +1,254 @@
1
+ /** Closed set of scalar types (anything else is a validation error). */
2
+ export declare const SCHEMA_SCALAR_TYPES: readonly ["string", "number", "bool", "json", "timestamp"];
3
+ export type SchemaScalarType = (typeof SCHEMA_SCALAR_TYPES)[number];
4
+ /** A single field. kind = pk / fk / fkList (fk[]) / scalar. */
5
+ export interface SchemaField {
6
+ name: string;
7
+ kind: "pk" | "fk" | "fkList" | "scalar";
8
+ /**
9
+ * Scalar only. `kind: "scalar"` has two origins: a plain scalar = one of the closed set
10
+ * `SCHEMA_SCALAR_TYPES`; from `enum("a"|"b")` = the display label itself, the written values
11
+ * joined with `|` (e.g. `"a"|"b"`).
12
+ */
13
+ type?: string;
14
+ /** fk / fkList only. A union (`fk(a|b)`) yields several. */
15
+ targets?: string[];
16
+ }
17
+ export interface SchemaTable {
18
+ name: string;
19
+ fields: SchemaField[];
20
+ /** Lines without a value (= descriptions). */
21
+ notes: string[];
22
+ /**
23
+ * Field names in the composite primary key (`pk(<field>, <field>, ...)`), in declaration
24
+ * order. A single pk stays as `kind: "pk"` on the field (it can't coexist with this array =
25
+ * validation error). Absent = no composite pk. The fields' own `kind` is unchanged (an fk
26
+ * stays an fk = edges are unaffected).
27
+ */
28
+ pk?: string[];
29
+ /**
30
+ * Field names of each unique constraint (`unique(<field>, ...)`), in declaration order. One
31
+ * element per constraint; a table may declare several uniques (= array of arrays;
32
+ * `unique(a)` alongside `unique(b, c)` is valid). A unique over the same column set as the pk
33
+ * is rejected as a validation error (the pk is already unique), so only column sets that
34
+ * differ from the pk end up here. The fields' own `kind` is unchanged (= no extra edges).
35
+ */
36
+ unique?: string[][];
37
+ }
38
+ /** A group delimited by `###`. A frame + heading is drawn on the graph only when it has a label. */
39
+ export interface SchemaGroup {
40
+ label?: string;
41
+ /** Member table names (declaration order). groups partition all tables (none is ungrouped). */
42
+ tables: string[];
43
+ }
44
+ /** One fk reference = one edge (a union yields one per target). */
45
+ export interface SchemaEdge {
46
+ from: string;
47
+ /** Field index within the from table (key for hover linkage). */
48
+ fieldIndex: number;
49
+ field: string;
50
+ to: string;
51
+ /** Whether it's fk[] (1:N). */
52
+ list: boolean;
53
+ }
54
+ export interface SchemaModel {
55
+ groups: SchemaGroup[];
56
+ tables: SchemaTable[];
57
+ edges: SchemaEdge[];
58
+ }
59
+ /** Error with a DSL line number (0-indexed, relative to the DSL). */
60
+ export interface SchemaParseError {
61
+ line: number;
62
+ message: string;
63
+ }
64
+ export interface SchemaParseResult {
65
+ model: SchemaModel;
66
+ errors: SchemaParseError[];
67
+ }
68
+ /**
69
+ * table DSL → graph model + errors. Even with errors, a partial model is returned
70
+ * (so preview can show "validation errors + as much as can be drawn" at the same time).
71
+ */
72
+ export declare const parseSchemaSource: (source: string) => SchemaParseResult;
73
+ /**
74
+ * Short id derived deterministically from the model contents. Used as the namespace for SVG
75
+ * markers / classes (no id collisions when one page has several graphs; no randomness / time =
76
+ * reproducible builds).
77
+ */
78
+ export declare const schemaGraphUid: (model: SchemaModel) => string;
79
+ /**
80
+ * One row in a table box (field or note). All coordinates are absolute px (= the renderer holds
81
+ * no geometry). y = row center, baseline = text baseline, x = left edge of the name,
82
+ * typeX = right edge of the type label.
83
+ */
84
+ export interface SchemaLayoutRow {
85
+ kind: SchemaField["kind"] | "note";
86
+ name: string;
87
+ /** Type label (`pk` / `fk` / `fk[]` / scalar type name; empty for notes). */
88
+ type: string;
89
+ y: number;
90
+ baseline: number;
91
+ x: number;
92
+ typeX: number;
93
+ /** Field rows only (undefined for notes). Key for hover linkage. */
94
+ fieldIndex?: number;
95
+ }
96
+ export interface SchemaLayoutTable {
97
+ name: string;
98
+ index: number;
99
+ x: number;
100
+ y: number;
101
+ w: number;
102
+ h: number;
103
+ headerH: number;
104
+ /** Text baseline y of the header (table name). */
105
+ headerBaseline: number;
106
+ /** Corner radius of the box. */
107
+ radius: number;
108
+ rows: SchemaLayoutRow[];
109
+ }
110
+ export interface SchemaLayoutGroup {
111
+ label: string;
112
+ x: number;
113
+ y: number;
114
+ w: number;
115
+ h: number;
116
+ /**
117
+ * Member table names (declaration order). Column reordering (independent groups pushed left)
118
+ * makes the order of `layout.groups` diverge from the declaration order of `model.groups`, so
119
+ * this lets the mapping be looked up without relying on index matching (used by
120
+ * `schemaGraphClientData`).
121
+ */
122
+ members: string[];
123
+ }
124
+ /**
125
+ * Minimal box shape read by edge routing (`SchemaLayoutTable` satisfies it structurally). The
126
+ * client passes data of this shape, embedded in the SVG, to the same `routeSchemaEdges` (= the
127
+ * routing rules aren't implemented twice).
128
+ */
129
+ export interface SchemaRouteBox {
130
+ name: string;
131
+ index: number;
132
+ x: number;
133
+ y: number;
134
+ w: number;
135
+ h: number;
136
+ headerH: number;
137
+ /** Used to look up fk rows' y (no fieldIndex = note row). */
138
+ rows: readonly {
139
+ y: number;
140
+ fieldIndex?: number;
141
+ }[];
142
+ }
143
+ /** One interactive-UI (React Flow) node = a table box, with the static SVG's position / content. */
144
+ export interface SchemaFlowNode {
145
+ name: string;
146
+ index: number;
147
+ x: number;
148
+ y: number;
149
+ w: number;
150
+ h: number;
151
+ headerH: number;
152
+ /** Rows (field / note). dy = center y from the box top (vertical position of the handle). */
153
+ rows: {
154
+ kind: SchemaField["kind"] | "note";
155
+ label: string;
156
+ type: string;
157
+ dy: number;
158
+ fieldIndex?: number;
159
+ }[];
160
+ }
161
+ /**
162
+ * Client data embedded in the SVG (`data-sg-layout`). The interactive UI (React Flow) reads only
163
+ * this and starts from the same picture as the static SVG (= no parse or layout on the client).
164
+ */
165
+ export interface SchemaGraphClientData {
166
+ uid: string;
167
+ width: number;
168
+ height: number;
169
+ nodes: SchemaFlowNode[];
170
+ edges: SchemaEdge[];
171
+ /** Group frames (labeled only). members = member table names (to refit frames after drag). */
172
+ groups: {
173
+ label: string;
174
+ x: number;
175
+ y: number;
176
+ w: number;
177
+ h: number;
178
+ members: string[];
179
+ }[];
180
+ /**
181
+ * Source text of the table DSL as written (the `schemath` body itself). The interactive UI's
182
+ * source viewer shows it as-is. Not derived from the model, since rebuilding it from the model
183
+ * would lose notes / blank lines / ordering. When absent, the viewer button isn't shown.
184
+ */
185
+ source?: string;
186
+ }
187
+ /** One interactive-UI edge, with its exit and entry sides decided (independent of the UI lib). */
188
+ export interface SchemaFlowEdge {
189
+ id: string;
190
+ from: string;
191
+ to: string;
192
+ fieldIndex: number;
193
+ list: boolean;
194
+ /** Exit side / entry side (l = left, r = right). Recomputed when a box moves. */
195
+ sourceSide: "l" | "r";
196
+ targetSide: "l" | "r";
197
+ }
198
+ /**
199
+ * Decides each edge's connecting sides from the current box positions (a pure function meant to
200
+ * be re-called on every drag). Target to the right: exit right, enter left; to the left: the
201
+ * reverse; overlapping: rightward.
202
+ */
203
+ export declare const schemaFlowEdges: (nodes: readonly {
204
+ name: string;
205
+ x: number;
206
+ w: number;
207
+ }[], edges: readonly SchemaEdge[]) => SchemaFlowEdge[];
208
+ export interface SchemaLayoutEdge {
209
+ /** Table index (index into SchemaLayout.tables). */
210
+ from: number;
211
+ to: number;
212
+ fieldIndex: number;
213
+ list: boolean;
214
+ /** SVG path d: orthogonal, 3 segments up close, 5 below the tables between distant columns. */
215
+ d: string;
216
+ }
217
+ export interface SchemaLayout {
218
+ width: number;
219
+ height: number;
220
+ groups: SchemaLayoutGroup[];
221
+ tables: SchemaLayoutTable[];
222
+ edges: SchemaLayoutEdge[];
223
+ /** Baseline y of the legend (only when fk[] exists). */
224
+ legendY?: number;
225
+ }
226
+ /** Left edge of the legend / group labels (used by the renderer). */
227
+ export declare const SCHEMA_LAYOUT_MARGIN: 16;
228
+ /** Minimum gap between groups stacked in one band (tests use it to verify non-overlap). */
229
+ export declare const SCHEMA_GAP_GROUP_Y: 40;
230
+ /** Group frame label-area height / padding (tests use them to derive the "label top"). */
231
+ export declare const SCHEMA_FRAME_LABEL_H: 22;
232
+ export declare const SCHEMA_FRAME_PAD: 14;
233
+ /**
234
+ * graph model → deterministic layout. Column bands are decided by the depth (level) of
235
+ * inter-group references: groups that reference no other group (including groups that are only
236
+ * referenced) are level 0; a referencing group is one level deeper than the group it references
237
+ * (= referenced groups land in bands to the left, referencing groups to the right). Reference
238
+ * cycles are cut deterministically by excluding back-edges to an ancestor on the search path
239
+ * from the level computation (see depthLevels).
240
+ * Bands run left → right in ascending level; groups in the same band stack top → bottom in
241
+ * declaration order (a band may hold several groups; independent groups land in the level-0
242
+ * band).
243
+ * Within a group (one group in a band), splitColumns may split the tables, in declaration order,
244
+ * into several internal columns.
245
+ * Edges leave from the fk field's row and enter the target box's header. Routes are bundled:
246
+ * edges that "enter the same target from the same column" share a trunk (vertical line) in the
247
+ * gutter next to that column and an entry point, so they merge into short exit stubs + one trunk
248
+ * + one crossing (the number of lines depends on target × column, not on the reference count).
249
+ * The same input always yields the same coordinates.
250
+ */
251
+ export declare const layoutSchemaGraph: (model: SchemaModel) => SchemaLayout;
252
+ export declare const routeSchemaEdges: (boxes: readonly SchemaRouteBox[], edges: readonly SchemaEdge[]) => SchemaLayoutEdge[];
253
+ /** layout → interactive-UI data (payload embedded in the static SVG; same positions / content). */
254
+ export declare const schemaGraphClientData: (uid: string, model: SchemaModel, layout: SchemaLayout, source?: string) => SchemaGraphClientData;