@zh-xx/antu 0.10.0 → 0.12.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/README.md +8 -0
- package/assets/viewer.html +55 -55
- package/bin/antu-mcp.mjs +53 -53
- package/bin/antu.mjs +55 -55
- package/embed/antu-embed.d.ts +95 -0
- package/embed/antu-embed.js +81139 -0
- package/examples/agent/fact/1-minimal.en.json +8 -11
- package/examples/agent/fact/1-minimal.zh-CN.json +34 -9
- package/examples/agent/fact/2-single-actor.en.json +4 -30
- package/examples/agent/fact/2-single-actor.zh-CN.json +22 -10
- package/examples/agent/fact/{3-groups.en.json → 3-sides.en.json} +9 -9
- package/examples/agent/fact/{3-groups.zh-CN.json → 3-sides.zh-CN.json} +9 -9
- package/examples/agent/fact/4-one-side-several.en.json +44 -0
- package/examples/agent/fact/4-one-side-several.zh-CN.json +44 -0
- package/examples/agent/fact/5-duration.en.json +31 -8
- package/examples/agent/fact/5-duration.zh-CN.json +31 -8
- package/examples/agent/fact/6-sources.en.json +51 -12
- package/examples/agent/fact/6-sources.zh-CN.json +51 -12
- package/examples/agent/fact/7-undated.en.json +26 -9
- package/examples/agent/fact/7-undated.zh-CN.json +26 -9
- package/examples/fact/fang-yuan-loan-and-conflict.en.json +7 -66
- package/examples/fact/fang-yuan-loan-and-conflict.zh-CN.json +6 -29
- package/examples/fact/gym-membership-face-scan.en.json +15 -20
- package/examples/fact/gym-membership-face-scan.zh-CN.json +15 -20
- package/examples/fact/lin-fang-v-zhao-lei-private-lending.en.json +6 -19
- package/examples/fact/lin-fang-v-zhao-lei-private-lending.zh-CN.json +6 -19
- package/examples/fact/marketplace-platform-liability.en.json +5 -24
- package/examples/fact/marketplace-platform-liability.zh-CN.json +5 -24
- package/examples/fact/neighbour-corridor-charging.en.json +3 -25
- package/examples/fact/neighbour-corridor-charging.zh-CN.json +3 -25
- package/examples/fact/sample-construction-payment.en.json +8 -82
- package/examples/fact/sample-construction-payment.zh-CN.json +7 -25
- package/examples/fact/sample-four-parties-four-slots.en.json +8 -81
- package/examples/fact/sample-four-parties-four-slots.zh-CN.json +5 -22
- package/examples/fact/sample-no-groups.en.json +1 -1
- package/examples/fact/sample-no-groups.zh-CN.json +1 -1
- package/examples/fact/sample-three-slots.en.json +3 -15
- package/examples/fact/sample-three-slots.zh-CN.json +3 -15
- package/examples/fact/sample-two-actors-one-side.en.json +4 -23
- package/examples/fact/sample-two-actors-one-side.zh-CN.json +4 -23
- package/examples/fact/sample-two-parties-each-side.en.json +7 -34
- package/examples/fact/sample-two-parties-each-side.zh-CN.json +7 -34
- package/examples/raw//357/274/2102031/357/274/211/347/244/272/346/260/221/345/210/2352/345/217/267-/345/201/245/350/272/253/346/210/277/345/210/267/350/204/270/345/205/245/345/234/272/346/241/210-/344/270/200/345/256/241.md +1 -1
- package/lib/chunks/report-BbG7HCJA.mjs +1462 -0
- package/lib/html.d.ts +9 -0
- package/lib/html.mjs +1425 -0
- package/lib/validate.d.ts +38 -0
- package/lib/validate.mjs +1425 -0
- package/package.json +17 -2
- package/server.json +2 -2
- package/spec/agent/fact/guide.md +38 -38
- package/examples/agent/fact/4-views.en.json +0 -44
- package/examples/agent/fact/4-views.zh-CN.json +0 -44
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Declarations of `@zh-xx/antu/embed` (src/embed/index.js). The contract is in spec/embed.md;
|
|
2
|
+
// test/embed.test.mjs checks that every function the module exports is declared here and nothing else.
|
|
3
|
+
|
|
4
|
+
/** An Antu JSON: the envelope (`type`, `specVersion`, `title`) and the content of its type */
|
|
5
|
+
export interface AntuSpec {
|
|
6
|
+
type: string
|
|
7
|
+
specVersion?: number
|
|
8
|
+
title?: string
|
|
9
|
+
[field: string]: unknown
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type AntuTheme = 'document' | 'modern' | 'legal'
|
|
13
|
+
export type AntuLang = 'zh' | 'en'
|
|
14
|
+
|
|
15
|
+
/** A source as written in the spec's `sources` (`loc` is shaped by the source's `type`, e.g. a contract's { file, clause, page }) */
|
|
16
|
+
export interface AntuSource {
|
|
17
|
+
id: string
|
|
18
|
+
type?: string
|
|
19
|
+
name?: string
|
|
20
|
+
loc?: Record<string, unknown>
|
|
21
|
+
[field: string]: unknown
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type AntuEvent =
|
|
25
|
+
| {
|
|
26
|
+
/** The reader pinned an item's card open, or closed it (`id` null) */
|
|
27
|
+
type: 'select'
|
|
28
|
+
/** The item's id in the spec; a canvas node's own id when it is not one item (a run of events on the scale) */
|
|
29
|
+
id: string | null
|
|
30
|
+
/** The top-level array the item is in (`nodes`, `rules`, `events`, `entities`, …); null when none */
|
|
31
|
+
collection: string | null
|
|
32
|
+
sourceIds: string[]
|
|
33
|
+
/** The item's sources as written in `sources` */
|
|
34
|
+
sources: AntuSource[]
|
|
35
|
+
}
|
|
36
|
+
| { type: 'kindchange'; kind: string }
|
|
37
|
+
| { type: 'invalid'; errors: string[] }
|
|
38
|
+
|
|
39
|
+
export interface AntuPrefsStore {
|
|
40
|
+
read(): Record<string, unknown>
|
|
41
|
+
/** Merge the patch into what is kept */
|
|
42
|
+
write(patch: Record<string, unknown>): void
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface MountOptions {
|
|
46
|
+
/** The kind it opens in, until the reader picks another. Not a kind of the spec's type: `mount` throws. */
|
|
47
|
+
kind?: string
|
|
48
|
+
/** The kinds the reader may pick from; one fixes the kind. A name that is not a kind of the type: `mount` throws. */
|
|
49
|
+
kinds?: string[]
|
|
50
|
+
/** The theme it opens in (the reader can still switch, unless the label card is left out) */
|
|
51
|
+
theme?: AntuTheme
|
|
52
|
+
/** The language of the page's own words; the case is never translated. Default: the browser's. */
|
|
53
|
+
lang?: AntuLang
|
|
54
|
+
/** Pieces of the page's chrome to leave out; all shown by default */
|
|
55
|
+
ui?: { header?: boolean; capsule?: boolean; minimap?: boolean; zoom?: boolean }
|
|
56
|
+
/** Where the reader's choices are kept: 'none' (default) while mounted only, 'local' in the viewer page's localStorage key, or the host's store */
|
|
57
|
+
prefs?: 'none' | 'local' | AntuPrefsStore
|
|
58
|
+
/** How it opens, ahead of the reader's stored choices (the reader can still change it). An unknown key or a wrong value: `mount` throws. */
|
|
59
|
+
initial?: { headerFolded?: boolean }
|
|
60
|
+
onEvent?: (event: AntuEvent) => void
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface AntuHandle {
|
|
64
|
+
/** Resolves once the diagram is drawn and fitted; rejects (with `errors`) when the spec is not valid */
|
|
65
|
+
readonly ready: Promise<void>
|
|
66
|
+
/** Draw another spec in the same place */
|
|
67
|
+
update(spec: AntuSpec): void
|
|
68
|
+
/** False when `kind` is not a kind of the type (or not in `kinds`) */
|
|
69
|
+
setKind(kind: string): boolean
|
|
70
|
+
setTheme(theme: AntuTheme): boolean
|
|
71
|
+
setLang(lang: AntuLang): boolean
|
|
72
|
+
/** Pin the card of the item `id`, as a reader's click would (a `select` event follows); `null` unpins. False when no card of it is drawn in this kind. */
|
|
73
|
+
select(id: string | null): boolean
|
|
74
|
+
/** Move the view to the item `id`, keeping the zoom unless it would not show it. False when it is not drawn in this kind. */
|
|
75
|
+
focus(id: string): boolean
|
|
76
|
+
/** Ring these items in the theme's colour until called again; `[]` clears. Ids that name no item are passed over. */
|
|
77
|
+
highlight(ids: string[]): void
|
|
78
|
+
fitView(): void
|
|
79
|
+
/** The PNG the page's own export makes (no label card, a white margin), not saved anywhere. Waits until the spec now mounted is drawn; rejects (with `errors`) while it is not valid. */
|
|
80
|
+
exportPng(options?: { pixelRatio?: number }): Promise<Blob>
|
|
81
|
+
/** Take the diagram off the element */
|
|
82
|
+
destroy(): void
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Draw `spec` inside `element` (in a shadow root; the element needs a height). Throws if one is already mounted there, or if `kind`/`kinds` name a way of drawing the spec's type does not have. */
|
|
86
|
+
export function mount(element: HTMLElement, spec: AntuSpec, options?: MountOptions): AntuHandle
|
|
87
|
+
|
|
88
|
+
/** Check a spec the way the diagram checks it before drawing; each error names its field */
|
|
89
|
+
export function validate(spec: unknown): { ok: boolean; errors: string[] }
|
|
90
|
+
|
|
91
|
+
/** Repair what is inconsistent in the marks of a spec but not in its content (a procedure's main line); the input is not modified, `changes` says what was done */
|
|
92
|
+
export function normalize(spec: unknown): { spec: unknown; changes: string[] }
|
|
93
|
+
|
|
94
|
+
/** The kinds a type can be drawn in, the first being the one it opens in */
|
|
95
|
+
export function kindsOf(type: string): string[]
|