@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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kimura Atsushi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# @sigma-studio/viewer
|
|
2
|
+
|
|
3
|
+
SigmaDoc教材をReactアプリ内で安全に表示する、閲覧専用の軽量Viewerです。
|
|
4
|
+
|
|
5
|
+
## パッケージの選び方
|
|
6
|
+
|
|
7
|
+
| 用途 | パッケージ |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| 教材を表示する | `@sigma-studio/viewer` |
|
|
10
|
+
| 教材をWeb上で編集する | `@sigma-studio/editor` |
|
|
11
|
+
|
|
12
|
+
Viewerには編集UI、保存、認証、AI、Electron API、外部assetの取得は含まれません。ホストアプリがSigmaDocの取得と状態管理を担当します。
|
|
13
|
+
|
|
14
|
+
## インストール
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @sigma-studio/viewer
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 基本的な使い方
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { SigmaDocViewer, type SigmaDocument } from "@sigma-studio/viewer";
|
|
24
|
+
import "@sigma-studio/viewer/styles.css";
|
|
25
|
+
|
|
26
|
+
export function MaterialPage({ document }: { document: SigmaDocument }) {
|
|
27
|
+
return (
|
|
28
|
+
<SigmaDocViewer
|
|
29
|
+
document={document}
|
|
30
|
+
onError={(error) => console.error(error)}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
ホストが新しい`document`オブジェクトを渡すと、ViewerはSigmaDocを再検証して表示を更新します。Viewer自身はfetch、polling、保存を行いません。
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
### `SigmaDocViewer`
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
interface SigmaDocViewerProps {
|
|
44
|
+
document: SigmaDocument;
|
|
45
|
+
visibleParts?: readonly ("problem" | "solution" | "comments")[];
|
|
46
|
+
hideProblemNumbers?: boolean;
|
|
47
|
+
maxHeightPx?: number;
|
|
48
|
+
className?: string;
|
|
49
|
+
style?: React.CSSProperties;
|
|
50
|
+
onError?: (error: SigmaDocViewerError) => void;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
本文は選択・コピーできます。URL形式の本文も自動リンク化せず、通常の文字列として表示します。オーバーレイは表示専用で、編集ハンドルやツールバーは描画されません。問題の問題文、解答、ヒント、解説はすべて表示し、制作コメントは表示しません。
|
|
55
|
+
|
|
56
|
+
`visibleParts`を指定すると、problem外の本文を除外して、次の問題領域だけを組み合わせて表示できます。未指定時は従来どおり全内容を表示します。
|
|
57
|
+
|
|
58
|
+
- `problem`: 導入文と問題文 (`lead` / `prompt`)
|
|
59
|
+
- `solution`: 解答 (`solution`)。短い正答の`answer`は含みません
|
|
60
|
+
- `comments`: 編集画面上の問題内コメント (`hints`)
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
<SigmaDocViewer document={document} visibleParts={["problem"]} />
|
|
64
|
+
<SigmaDocViewer document={document} visibleParts={["solution"]} />
|
|
65
|
+
<SigmaDocViewer document={document} visibleParts={["problem", "solution"]} />
|
|
66
|
+
<SigmaDocViewer document={document} visibleParts={["comments"]} />
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`hideProblemNumbers`はSigmaDocの採番設定より優先して問題番号を非表示にします。`maxHeightPx`に正のpx値を指定すると、その高さを超えた場合だけ下端をフェードし、「すべて表示」ボタンを表示します。このボタンは表示範囲を広げるだけで、SigmaDocを変更しません。
|
|
70
|
+
|
|
71
|
+
### Validation
|
|
72
|
+
|
|
73
|
+
`parseSigmaDocument`は外部から取得したunknown値をSigmaDoc v2として検証・正規化します。
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const document = parseSigmaDocument(await response.json());
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 画像の扱い
|
|
80
|
+
|
|
81
|
+
画像assetの`props.src`には次のdata URLだけを使用できます。
|
|
82
|
+
|
|
83
|
+
- `data:image/png`
|
|
84
|
+
- `data:image/jpeg`
|
|
85
|
+
- `data:image/webp`
|
|
86
|
+
- `data:image/svg+xml`
|
|
87
|
+
|
|
88
|
+
PNG、JPEG、WebPはbase64形式と実ファイル署名を検証します。SVGはbase64またはpercent-encoded UTF-8を受け付け、script、event属性、外部resource参照を含まない自己完結した内容だけを表示します。SVG文字列はDOMへ展開せず、SVGの`<image>`として描画します。位置、寸法、crop、回転、透明度、前景・背景、anchorをSigmaDocの指定どおり再現します。
|
|
89
|
+
|
|
90
|
+
外部URL、`blob:`、`sigma-doc-storage://`、空のsource、存在しないassetは取得しません。同じ画像枠にplaceholderを表示し、`onError`へ`unsupported-asset`を通知します。
|
|
91
|
+
|
|
92
|
+
## 互換性
|
|
93
|
+
|
|
94
|
+
- React / React DOM: `>=18.2.0 <20`
|
|
95
|
+
- SigmaDoc: `version: "2.0"`
|
|
96
|
+
- CSS: `@sigma-studio/viewer/styles.css`
|
|
97
|
+
|
|
98
|
+
パッケージのバージョンはSigma Studio本体と揃えて公開します。
|
|
99
|
+
|
|
100
|
+
## 開発
|
|
101
|
+
|
|
102
|
+
以下はこのリポジトリの開発者向けコマンドです。リポジトリルートで実行します。
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
npm run viewer:typecheck
|
|
107
|
+
npm run viewer:test
|
|
108
|
+
npm run viewer:build
|
|
109
|
+
npm run viewer:pack
|
|
110
|
+
npm run viewer:example
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`npm run viewer:pack`は公開せず、npm packageの内容だけを確認します。
|
|
114
|
+
|
|
115
|
+
## ライセンス
|
|
116
|
+
|
|
117
|
+
MIT
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
`@sigma-studio/viewer` bundles display CSS and font assets from the following MIT-licensed projects.
|
|
4
|
+
|
|
5
|
+
## KaTeX
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2013-2020 Khan Academy and other contributors
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
14
|
+
|
|
15
|
+
## MathLive
|
|
16
|
+
|
|
17
|
+
Copyright (c) 2017-present Arno Gourdol. All rights reserved.
|
|
18
|
+
|
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
2
|
+
import type { SigmaDocument } from "./types";
|
|
3
|
+
declare const VIEWER_PARTS: readonly ["problem", "solution", "comments"];
|
|
4
|
+
export type SigmaDocViewerPart = (typeof VIEWER_PARTS)[number];
|
|
5
|
+
export interface SigmaDocViewerProps {
|
|
6
|
+
document: SigmaDocument;
|
|
7
|
+
visibleParts?: readonly SigmaDocViewerPart[];
|
|
8
|
+
hideProblemNumbers?: boolean;
|
|
9
|
+
maxHeightPx?: number;
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
onError?: (error: SigmaDocViewerError) => void;
|
|
13
|
+
}
|
|
14
|
+
export type SigmaDocViewerError = {
|
|
15
|
+
code: "invalid-document";
|
|
16
|
+
message: string;
|
|
17
|
+
issues: readonly string[];
|
|
18
|
+
} | {
|
|
19
|
+
code: "unsupported-asset";
|
|
20
|
+
message: string;
|
|
21
|
+
assetId: string;
|
|
22
|
+
} | {
|
|
23
|
+
code: "render-failed";
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
export declare class SigmaDocParseError extends Error {
|
|
27
|
+
readonly issues: readonly string[];
|
|
28
|
+
constructor(issues: readonly string[], options?: {
|
|
29
|
+
cause?: unknown;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Validate and normalize an unknown value as the canonical SigmaDoc v2 model.
|
|
34
|
+
* The implementation is shared with Sigma Studio so migrations and defaults do
|
|
35
|
+
* not drift between the authoring app and the viewer.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseSigmaDocument(input: unknown): SigmaDocument;
|
|
38
|
+
export declare function SigmaDocViewer({ document, visibleParts, hideProblemNumbers, maxHeightPx, className, style, onError, }: SigmaDocViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export {};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
ADDED