@sigma-studio/viewer 0.188.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 +117 -0
- package/THIRD_PARTY_NOTICES.md +23 -0
- package/dist/SigmaDocViewer.d.ts +39 -0
- package/dist/assets/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
- package/dist/assets/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
- package/dist/assets/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
- package/dist/assets/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
- package/dist/assets/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
- package/dist/assets/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
- package/dist/assets/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
- package/dist/assets/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
- package/dist/assets/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
- package/dist/assets/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
- package/dist/assets/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
- package/dist/assets/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +14 -0
- package/dist/overlay-types.d.ts +371 -0
- package/dist/styles.css +1 -0
- package/dist/types.d.ts +461 -0
- package/dist/viewer-safety.d.ts +19 -0
- package/package.json +66 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import type { OverlaySnapshot } from "./overlay-types";
|
|
2
|
+
export type SigmaDocVersion = "2.0";
|
|
3
|
+
export type OutputProfileName = "student" | "teacher" | "answerBook";
|
|
4
|
+
export type PageSizePreset = "A4" | "A3" | "B5" | "B4" | "custom";
|
|
5
|
+
export type PageOrientation = "portrait" | "landscape";
|
|
6
|
+
export interface SigmaDocument {
|
|
7
|
+
version: SigmaDocVersion;
|
|
8
|
+
docId: string;
|
|
9
|
+
metadata: SigmaMetadata;
|
|
10
|
+
content: SigmaBlock[];
|
|
11
|
+
outputProfiles: Record<OutputProfileName, OutputProfile>;
|
|
12
|
+
comments?: SigmaCommentThread[];
|
|
13
|
+
pageLayout?: PageLayout;
|
|
14
|
+
updatedAt?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PageLayout {
|
|
17
|
+
preset: PageSizePreset;
|
|
18
|
+
orientation: PageOrientation;
|
|
19
|
+
pageSize: {
|
|
20
|
+
widthMm: number;
|
|
21
|
+
heightMm: number;
|
|
22
|
+
};
|
|
23
|
+
marginsMm: {
|
|
24
|
+
top: number;
|
|
25
|
+
right: number;
|
|
26
|
+
bottom: number;
|
|
27
|
+
left: number;
|
|
28
|
+
};
|
|
29
|
+
flow: {
|
|
30
|
+
type: "columns";
|
|
31
|
+
columnCount: number;
|
|
32
|
+
columnGapMm: number;
|
|
33
|
+
};
|
|
34
|
+
header?: PageRunningRegion;
|
|
35
|
+
footer?: PageRunningRegion;
|
|
36
|
+
/** Single continuous overlay for the whole document (figures resolve their page from block anchors). */
|
|
37
|
+
overlay?: PageOverlay;
|
|
38
|
+
}
|
|
39
|
+
export interface PageRunningRegion {
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
heightMm: number;
|
|
42
|
+
offsetMm: number;
|
|
43
|
+
showOnFirstPage: boolean;
|
|
44
|
+
/** Free-form header/footer body. This is the canonical repeated text content. */
|
|
45
|
+
blocks: RichBlock[];
|
|
46
|
+
/** Repeated overlay for figures, images, graphs, and free-positioned text inside this region. */
|
|
47
|
+
overlay?: PageOverlay;
|
|
48
|
+
}
|
|
49
|
+
export interface PageOverlay {
|
|
50
|
+
overlaySnapshot?: OverlaySnapshot;
|
|
51
|
+
previewSvg?: string;
|
|
52
|
+
updatedAt?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface SigmaMetadata {
|
|
55
|
+
title: string;
|
|
56
|
+
source?: SigmaDocumentSourceMetadata;
|
|
57
|
+
styleUnits?: SigmaDocumentStyleUnits;
|
|
58
|
+
mathFractionSizing?: MathFractionSizing;
|
|
59
|
+
}
|
|
60
|
+
export type MathFractionSizing = "uniform" | "texDefault";
|
|
61
|
+
export interface SigmaDocumentSourceMetadata {
|
|
62
|
+
format?: "studyaid-prt";
|
|
63
|
+
layoutMode?: "fixedOverlay";
|
|
64
|
+
printFlowContent?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface SigmaDocumentStyleUnits {
|
|
67
|
+
fontSize?: "pt";
|
|
68
|
+
}
|
|
69
|
+
export interface OutputProfile {
|
|
70
|
+
showSolutions?: boolean;
|
|
71
|
+
showHints?: boolean;
|
|
72
|
+
includeAnswers?: boolean;
|
|
73
|
+
onlySolutions?: boolean;
|
|
74
|
+
includeComments?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface SigmaCommentThread {
|
|
77
|
+
id: string;
|
|
78
|
+
anchor: SigmaCommentAnchor;
|
|
79
|
+
messages: SigmaCommentMessage[];
|
|
80
|
+
/** Thread-level reactions are displayed on the first message. */
|
|
81
|
+
reactions?: SigmaCommentReaction[];
|
|
82
|
+
resolved?: boolean;
|
|
83
|
+
color?: string;
|
|
84
|
+
createdAt: string;
|
|
85
|
+
updatedAt?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface SigmaCommentMessage {
|
|
88
|
+
id: string;
|
|
89
|
+
authorName?: string;
|
|
90
|
+
body: InlineNode[];
|
|
91
|
+
reactions?: SigmaCommentReaction[];
|
|
92
|
+
createdAt: string;
|
|
93
|
+
updatedAt?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface SigmaCommentReaction {
|
|
96
|
+
id: string;
|
|
97
|
+
emoji: string;
|
|
98
|
+
authorName?: string;
|
|
99
|
+
createdAt: string;
|
|
100
|
+
}
|
|
101
|
+
export type SigmaCommentAnchor = SigmaTextRangeCommentAnchor | SigmaInlineMathCommentAnchor | SigmaBlockCommentAnchor | SigmaOverlayShapeCommentAnchor | SigmaOverlayMathCommentAnchor;
|
|
102
|
+
export interface SigmaTextRangeCommentAnchor {
|
|
103
|
+
type: "textRange";
|
|
104
|
+
start: SigmaCommentTextPosition;
|
|
105
|
+
end: SigmaCommentTextPosition;
|
|
106
|
+
quote: string;
|
|
107
|
+
mathInlineIds?: string[];
|
|
108
|
+
mathTex?: string[];
|
|
109
|
+
}
|
|
110
|
+
export interface SigmaCommentTextPosition {
|
|
111
|
+
blockId: string;
|
|
112
|
+
offset: number;
|
|
113
|
+
}
|
|
114
|
+
export interface SigmaInlineMathCommentAnchor {
|
|
115
|
+
type: "inlineMath";
|
|
116
|
+
blockId: string;
|
|
117
|
+
mathInlineId: string;
|
|
118
|
+
quote?: string;
|
|
119
|
+
tex?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface SigmaBlockCommentAnchor {
|
|
122
|
+
type: "block";
|
|
123
|
+
blockId: string;
|
|
124
|
+
quote?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface SigmaOverlayShapeCommentAnchor {
|
|
127
|
+
type: "overlayShape";
|
|
128
|
+
shapeIds: string[];
|
|
129
|
+
quote?: string;
|
|
130
|
+
}
|
|
131
|
+
export interface SigmaOverlayMathCommentAnchor {
|
|
132
|
+
type: "overlayMath";
|
|
133
|
+
shapeId?: string;
|
|
134
|
+
mathInlineId?: string;
|
|
135
|
+
quote?: string;
|
|
136
|
+
tex?: string;
|
|
137
|
+
}
|
|
138
|
+
export type SigmaBlock = SectionNode | HeadingNode | ParagraphNode | ListNode | ProblemNode | LayoutSectionNode | BoxBlockNode;
|
|
139
|
+
export type RichBlock = HeadingNode | ParagraphNode | ListNode;
|
|
140
|
+
export type ProblemAreaBlock = RichBlock | LayoutSectionNode;
|
|
141
|
+
export type LayoutSectionChildBlock = SectionNode | HeadingNode | ParagraphNode | ListNode | BoxBlockNode;
|
|
142
|
+
export type BoxBlockChildBlock = LayoutSectionChildBlock | LayoutSectionNode;
|
|
143
|
+
export interface BaseNode {
|
|
144
|
+
type: string;
|
|
145
|
+
id: string;
|
|
146
|
+
pageBreak?: PageBreakHints;
|
|
147
|
+
}
|
|
148
|
+
export interface PageBreakHints {
|
|
149
|
+
avoidInside?: boolean;
|
|
150
|
+
keepWithNext?: boolean;
|
|
151
|
+
breakBefore?: "auto" | "always";
|
|
152
|
+
breakAfter?: "auto" | "always";
|
|
153
|
+
}
|
|
154
|
+
export interface SectionNode extends BaseNode {
|
|
155
|
+
type: "section";
|
|
156
|
+
title: string;
|
|
157
|
+
align?: TextAlign;
|
|
158
|
+
lineHeight?: LineHeight;
|
|
159
|
+
}
|
|
160
|
+
export interface HeadingNode extends BaseNode {
|
|
161
|
+
type: "heading";
|
|
162
|
+
level: 1 | 2 | 3;
|
|
163
|
+
children: InlineNode[];
|
|
164
|
+
align?: TextAlign;
|
|
165
|
+
lineHeight?: LineHeight;
|
|
166
|
+
}
|
|
167
|
+
export interface ParagraphNode extends BaseNode {
|
|
168
|
+
type: "paragraph";
|
|
169
|
+
children: InlineNode[];
|
|
170
|
+
align?: TextAlign;
|
|
171
|
+
lineHeight?: LineHeight;
|
|
172
|
+
}
|
|
173
|
+
export interface ListNode extends BaseNode {
|
|
174
|
+
type: "list";
|
|
175
|
+
listType: "bullet" | "ordered";
|
|
176
|
+
start?: number;
|
|
177
|
+
items: ListItemNode[];
|
|
178
|
+
}
|
|
179
|
+
export interface ListItemNode {
|
|
180
|
+
type: "listItem";
|
|
181
|
+
id: string;
|
|
182
|
+
children: InlineNode[];
|
|
183
|
+
nested?: ListNode[];
|
|
184
|
+
}
|
|
185
|
+
export type TextAlign = "left" | "center" | "right" | "justify";
|
|
186
|
+
/** Unitless CSS line-height multiplier, normalized by `normalizeLineHeight`. */
|
|
187
|
+
export type LineHeight = string;
|
|
188
|
+
export interface ProblemNode extends BaseNode {
|
|
189
|
+
type: "problem";
|
|
190
|
+
tags: string[];
|
|
191
|
+
lead: ProblemAreaBlock[];
|
|
192
|
+
prompt: ProblemAreaBlock[];
|
|
193
|
+
answer?: AnswerDefinition;
|
|
194
|
+
solution: ProblemAreaBlock[];
|
|
195
|
+
hints: ProblemAreaBlock[];
|
|
196
|
+
areaLayout?: Partial<Record<ProblemAreaKind, ProblemAreaLayout>>;
|
|
197
|
+
numbering?: ProblemNumbering;
|
|
198
|
+
frame?: ProblemFrame;
|
|
199
|
+
}
|
|
200
|
+
export type ProblemAreaKind = "lead" | "prompt" | "solution" | "hints";
|
|
201
|
+
export type ProblemAreaColumnSpan = "column" | "full";
|
|
202
|
+
export interface ProblemAreaLayout {
|
|
203
|
+
minHeightMm?: number;
|
|
204
|
+
columnSpan?: ProblemAreaColumnSpan;
|
|
205
|
+
}
|
|
206
|
+
export interface ProblemNumbering {
|
|
207
|
+
enabled?: boolean;
|
|
208
|
+
fontSize?: number;
|
|
209
|
+
value?: number;
|
|
210
|
+
}
|
|
211
|
+
export interface ProblemFrame {
|
|
212
|
+
enabled?: boolean;
|
|
213
|
+
styleId?: string;
|
|
214
|
+
}
|
|
215
|
+
export interface LayoutSectionNode extends BaseNode {
|
|
216
|
+
type: "layoutSection";
|
|
217
|
+
layout: LayoutSectionLayout;
|
|
218
|
+
children: LayoutSectionChildBlock[];
|
|
219
|
+
}
|
|
220
|
+
export interface LayoutSectionLayout {
|
|
221
|
+
columnCount: number;
|
|
222
|
+
columnGapMm?: number;
|
|
223
|
+
}
|
|
224
|
+
export interface BoxBlockNode extends BaseNode {
|
|
225
|
+
type: "boxBlock";
|
|
226
|
+
/** Built-in or user-defined style identifier such as `fancybox` or `doublebox`. */
|
|
227
|
+
styleId: string;
|
|
228
|
+
title?: InlineNode[];
|
|
229
|
+
blocks: BoxBlockChildBlock[];
|
|
230
|
+
frame?: BoxFrameSpec;
|
|
231
|
+
}
|
|
232
|
+
export interface BoxFrameSpec {
|
|
233
|
+
borderWidthPx?: number;
|
|
234
|
+
borderColor?: string;
|
|
235
|
+
borderStyle?: "solid" | "dashed" | "dotted" | "double" | "none";
|
|
236
|
+
backgroundColor?: string;
|
|
237
|
+
titleBackgroundColor?: string;
|
|
238
|
+
titleColor?: string;
|
|
239
|
+
titleAlign?: TextAlign;
|
|
240
|
+
titleFontWeight?: "normal" | "bold";
|
|
241
|
+
titleFontFamily?: string;
|
|
242
|
+
titleFontSizePx?: number;
|
|
243
|
+
titleLineHeight?: string;
|
|
244
|
+
bodyColor?: string;
|
|
245
|
+
bodyAlign?: TextAlign;
|
|
246
|
+
bodyFontFamily?: string;
|
|
247
|
+
bodyFontSizePx?: number;
|
|
248
|
+
bodyLineHeight?: string;
|
|
249
|
+
cornerStyle?: "sharp" | "round";
|
|
250
|
+
radiusPx?: number;
|
|
251
|
+
paddingPx?: BoxSpacingPx;
|
|
252
|
+
decorations?: BoxDecorationSpec[];
|
|
253
|
+
}
|
|
254
|
+
export interface BoxSpacingPx {
|
|
255
|
+
top: number;
|
|
256
|
+
right: number;
|
|
257
|
+
bottom: number;
|
|
258
|
+
left: number;
|
|
259
|
+
}
|
|
260
|
+
export type BoxDecorationSpec = {
|
|
261
|
+
type: "cornerSquares";
|
|
262
|
+
sizePx: number;
|
|
263
|
+
color: string;
|
|
264
|
+
} | {
|
|
265
|
+
type: "doubleRule";
|
|
266
|
+
offsetPx: number;
|
|
267
|
+
widthPx?: number;
|
|
268
|
+
color?: string;
|
|
269
|
+
} | {
|
|
270
|
+
type: "titleDoubleRule";
|
|
271
|
+
ruleWidthPx?: number;
|
|
272
|
+
ruleColor?: string;
|
|
273
|
+
guideColor?: string;
|
|
274
|
+
} | {
|
|
275
|
+
type: "titleBand";
|
|
276
|
+
heightPx?: number;
|
|
277
|
+
backgroundColor?: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: "titlePlate";
|
|
280
|
+
borderColor?: string;
|
|
281
|
+
radiusPx?: number;
|
|
282
|
+
paddingPx?: BoxSpacingPx;
|
|
283
|
+
} | {
|
|
284
|
+
type: "leftBar";
|
|
285
|
+
widthPx: number;
|
|
286
|
+
color: string;
|
|
287
|
+
} | {
|
|
288
|
+
type: "shadow";
|
|
289
|
+
offsetXPx: number;
|
|
290
|
+
offsetYPx: number;
|
|
291
|
+
blurPx?: number;
|
|
292
|
+
spreadPx?: number;
|
|
293
|
+
color: string;
|
|
294
|
+
} | {
|
|
295
|
+
type: "horizontalRules";
|
|
296
|
+
widthPx?: number;
|
|
297
|
+
color?: string;
|
|
298
|
+
} | {
|
|
299
|
+
type: "notebookRules";
|
|
300
|
+
baseBodyWidthPx?: number;
|
|
301
|
+
frameLeftPx?: number;
|
|
302
|
+
frameHeightPx?: number;
|
|
303
|
+
frameStrokeOpacity?: number;
|
|
304
|
+
lineColor?: string;
|
|
305
|
+
lineGapPx?: number;
|
|
306
|
+
lineWidthPx?: number;
|
|
307
|
+
lineOffsetPx?: number;
|
|
308
|
+
bindingColor?: string;
|
|
309
|
+
bindingWidthPx?: number;
|
|
310
|
+
bindingXPx?: number;
|
|
311
|
+
bindingStrokeOpacity?: number;
|
|
312
|
+
ringColor?: string;
|
|
313
|
+
ringWidthPx?: number;
|
|
314
|
+
ringHeightPx?: number;
|
|
315
|
+
ringStrokePx?: number;
|
|
316
|
+
ringGapPx?: number;
|
|
317
|
+
ringTopPx?: number;
|
|
318
|
+
ringCount?: number;
|
|
319
|
+
ringLeftOverhangPx?: number;
|
|
320
|
+
minHeightPx?: number;
|
|
321
|
+
};
|
|
322
|
+
export type Graph2DKind = "cartesian" | "numberLine";
|
|
323
|
+
export type GraphTickMode = "number" | "pi";
|
|
324
|
+
export type GraphCurveMode = "yOfX" | "xOfY" | "parametric" | "implicit";
|
|
325
|
+
export type GraphCurveDash = "solid" | "dashed" | "dotted";
|
|
326
|
+
export type GraphRenderStyle = "default" | "studyaid";
|
|
327
|
+
export type GraphFillPattern = "solid" | "diagonal" | "diagonalBack" | "cross" | "horizontal" | "vertical" | "dots";
|
|
328
|
+
export interface Graph2DSpec {
|
|
329
|
+
kind: Graph2DKind;
|
|
330
|
+
title: string;
|
|
331
|
+
width: number;
|
|
332
|
+
height: number;
|
|
333
|
+
viewBox: GraphViewBox;
|
|
334
|
+
graphViewBox?: GraphViewBox;
|
|
335
|
+
axes: GraphAxes;
|
|
336
|
+
curves: GraphCurve[];
|
|
337
|
+
points?: GraphPoint[];
|
|
338
|
+
annotations?: GraphAnnotation[];
|
|
339
|
+
fills?: GraphFillRegion[];
|
|
340
|
+
showFormulaLabels?: boolean;
|
|
341
|
+
}
|
|
342
|
+
export interface GraphViewBox {
|
|
343
|
+
xMin: string;
|
|
344
|
+
xMax: string;
|
|
345
|
+
yMin: string;
|
|
346
|
+
yMax: string;
|
|
347
|
+
}
|
|
348
|
+
export interface GraphAxes {
|
|
349
|
+
grid: boolean;
|
|
350
|
+
showX?: boolean;
|
|
351
|
+
showY?: boolean;
|
|
352
|
+
showTicks?: boolean;
|
|
353
|
+
renderStyle?: GraphRenderStyle;
|
|
354
|
+
axisDash?: GraphCurveDash;
|
|
355
|
+
axisColor?: string;
|
|
356
|
+
axisStrokeWidth?: number;
|
|
357
|
+
xLabel?: string;
|
|
358
|
+
yLabel?: string;
|
|
359
|
+
originLabel?: string;
|
|
360
|
+
/** Tick label font size in points. */
|
|
361
|
+
tickFontSize?: number;
|
|
362
|
+
xTickStep?: string;
|
|
363
|
+
yTickStep?: string;
|
|
364
|
+
xTickMode?: GraphTickMode;
|
|
365
|
+
yTickMode?: GraphTickMode;
|
|
366
|
+
}
|
|
367
|
+
export interface GraphCurve {
|
|
368
|
+
id: string;
|
|
369
|
+
/** `yOfX`: y=f(x), `xOfY`: x=f(y), `parametric`: x=f(t), `implicit`: F(x,y)=0. 評価用の正規化済み式 (正本)。 */
|
|
370
|
+
expr: string;
|
|
371
|
+
/** Used only when `mode` is `"parametric"`: y=g(t). */
|
|
372
|
+
yExpr?: string;
|
|
373
|
+
/** ユーザーが入力した TeX (表示・再編集用の投影)。無ければ `expr` から導出する。 */
|
|
374
|
+
exprTex?: string;
|
|
375
|
+
/** `yExpr` に対応する入力 TeX。 */
|
|
376
|
+
yExprTex?: string;
|
|
377
|
+
label?: string;
|
|
378
|
+
color: string;
|
|
379
|
+
mode?: GraphCurveMode;
|
|
380
|
+
dash?: GraphCurveDash;
|
|
381
|
+
strokeWidth?: number;
|
|
382
|
+
domain?: {
|
|
383
|
+
min?: string;
|
|
384
|
+
max?: string;
|
|
385
|
+
};
|
|
386
|
+
samples?: number;
|
|
387
|
+
}
|
|
388
|
+
/** 点ラベルを置く方位 (8方位)。未指定なら曲線・軸・他の点/ラベルを避けて自動配置する。 */
|
|
389
|
+
export type GraphPointLabelPlacement = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
|
|
390
|
+
export interface GraphPoint {
|
|
391
|
+
id: string;
|
|
392
|
+
x: string;
|
|
393
|
+
y: string;
|
|
394
|
+
/** ユーザーが入力した座標 TeX (表示・再編集用の投影)。無ければ `x`/`y` から導出する。 */
|
|
395
|
+
xTex?: string;
|
|
396
|
+
yTex?: string;
|
|
397
|
+
label?: string;
|
|
398
|
+
/** ラベルを置く方位。省略時は曲線・軸・他要素と重ならない位置を自動選択する。 */
|
|
399
|
+
labelPlacement?: GraphPointLabelPlacement;
|
|
400
|
+
color?: string;
|
|
401
|
+
fill?: "solid" | "none";
|
|
402
|
+
radius?: number;
|
|
403
|
+
showXProjection?: boolean;
|
|
404
|
+
showYProjection?: boolean;
|
|
405
|
+
}
|
|
406
|
+
export interface GraphAnnotation {
|
|
407
|
+
id: string;
|
|
408
|
+
x: string;
|
|
409
|
+
y: string;
|
|
410
|
+
text: string;
|
|
411
|
+
}
|
|
412
|
+
export interface GraphFillRegion {
|
|
413
|
+
id: string;
|
|
414
|
+
x: string;
|
|
415
|
+
y: string;
|
|
416
|
+
color?: string;
|
|
417
|
+
opacity?: number;
|
|
418
|
+
pattern?: GraphFillPattern;
|
|
419
|
+
}
|
|
420
|
+
export interface AnswerDefinition {
|
|
421
|
+
type: "math" | "text";
|
|
422
|
+
expected: string;
|
|
423
|
+
}
|
|
424
|
+
export type InlineNode = TextInlineNode | MathInlineNode;
|
|
425
|
+
export interface TextInlineNode {
|
|
426
|
+
type: "text";
|
|
427
|
+
text: string;
|
|
428
|
+
marks?: TextMark[];
|
|
429
|
+
color?: string;
|
|
430
|
+
backgroundColor?: string;
|
|
431
|
+
fontFamily?: string;
|
|
432
|
+
fontSize?: number;
|
|
433
|
+
boxedPaddingY?: number;
|
|
434
|
+
boxedVariant?: BoxedVariant;
|
|
435
|
+
boxedTone?: BoxedTone;
|
|
436
|
+
}
|
|
437
|
+
export type TextMark = "bold" | "italic" | "underline" | "boxed";
|
|
438
|
+
/**
|
|
439
|
+
* Visual style of a boxed run, modeled after common TeX box commands:
|
|
440
|
+
* `frame` (\fbox), `thick`, `double`, `oval` (\ovalbox), and `shade` (\tcolorbox / \itembox).
|
|
441
|
+
* Absent means `frame`, so existing boxed runs keep their thin-border look.
|
|
442
|
+
*/
|
|
443
|
+
export type BoxedVariant = "frame" | "thick" | "double" | "oval" | "shade";
|
|
444
|
+
/** Fill colour preset for `shade` boxes. Absent means `gray`. */
|
|
445
|
+
export type BoxedTone = "gray" | "blue" | "green" | "red" | "yellow";
|
|
446
|
+
export interface MathInlineNode {
|
|
447
|
+
type: "mathInline";
|
|
448
|
+
id: string;
|
|
449
|
+
tex: string;
|
|
450
|
+
display: "inline";
|
|
451
|
+
marks?: Array<Extract<TextMark, "underline" | "boxed">>;
|
|
452
|
+
color?: string;
|
|
453
|
+
backgroundColor?: string;
|
|
454
|
+
fontFamily?: string;
|
|
455
|
+
fontSize?: number;
|
|
456
|
+
boxedPaddingY?: number;
|
|
457
|
+
boxedVariant?: BoxedVariant;
|
|
458
|
+
boxedTone?: BoxedTone;
|
|
459
|
+
semanticRole?: "expression" | "equation" | "variable";
|
|
460
|
+
altText?: string;
|
|
461
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SigmaDocument } from "./types";
|
|
2
|
+
export declare class ViewerSafetyValidationError extends Error {
|
|
3
|
+
readonly issues: readonly string[];
|
|
4
|
+
constructor(issues: readonly string[]);
|
|
5
|
+
}
|
|
6
|
+
export interface ValidatedImageDataUrl {
|
|
7
|
+
src: string;
|
|
8
|
+
mimeType: "image/png" | "image/jpeg" | "image/webp" | "image/svg+xml";
|
|
9
|
+
}
|
|
10
|
+
export type ImageDataUrlValidation = {
|
|
11
|
+
ok: true;
|
|
12
|
+
value: ValidatedImageDataUrl;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
reason: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function assertViewerSafeDocument(document: SigmaDocument): void;
|
|
18
|
+
export declare function getViewerSafetyIssues(document: SigmaDocument): string[];
|
|
19
|
+
export declare function validateImageDataUrl(source: string): ImageDataUrlValidation;
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sigma-studio/viewer",
|
|
3
|
+
"version": "0.188.0",
|
|
4
|
+
"description": "Read-only React renderer for SigmaDoc teaching materials.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/Atsu-Taiyo/ai-math-editor.git",
|
|
9
|
+
"directory": "packages/viewer"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/Atsu-Taiyo/ai-math-editor/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./styles.css": "./dist/styles.css",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"README.md",
|
|
31
|
+
"THIRD_PARTY_NOTICES.md"
|
|
32
|
+
],
|
|
33
|
+
"sideEffects": [
|
|
34
|
+
"**/*.css"
|
|
35
|
+
],
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"clean": "node ./scripts/clean.mjs",
|
|
41
|
+
"build": "npm run clean && node ./scripts/build.mjs && tsc -p tsconfig.build.json",
|
|
42
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"prepack": "npm run build"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": ">=18.2.0 <20",
|
|
48
|
+
"react-dom": ">=18.2.0 <20"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"katex": "^0.16.45",
|
|
52
|
+
"mathlive": "^0.109.2",
|
|
53
|
+
"zod": "^4.4.3"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/react": "^19.2.14",
|
|
57
|
+
"@types/react-dom": "^19.2.3",
|
|
58
|
+
"esbuild": "^0.24.0",
|
|
59
|
+
"happy-dom": "^20.11.0",
|
|
60
|
+
"postcss": "^8.5.14",
|
|
61
|
+
"react": "^19.2.6",
|
|
62
|
+
"react-dom": "^19.2.6",
|
|
63
|
+
"typescript": "^5.9.3",
|
|
64
|
+
"vitest": "^3.2.4"
|
|
65
|
+
}
|
|
66
|
+
}
|