@first-ch/tools-mcp 0.4.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 +119 -0
- package/lib.mjs +160 -0
- package/package.json +56 -0
- package/server.mjs +175 -0
- package/vendor/jsquash-webp/LICENSE +201 -0
- package/vendor/jsquash-webp/README.md +25 -0
- package/vendor/jsquash-webp/codec/LICENSE.codec.md +29 -0
- package/vendor/jsquash-webp/codec/enc/webp_enc_simd.js +16 -0
- package/vendor/jsquash-webp/codec/enc/webp_enc_simd.wasm +0 -0
- package/vendor/jsquash-webp/meta.js +33 -0
- package/vendor/jsquash-webp/utils.js +31 -0
- package/webp.mjs +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 First CH LLC
|
|
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,119 @@
|
|
|
1
|
+
# @first-ch/tools-mcp
|
|
2
|
+
|
|
3
|
+
MCP server exposing First CH Tools' free web-tool logic (WCAG contrast, JP character/X-weight counting, WebP conversion, JSON-LD, and llms.txt generation) to AI agents such as Claude Code.
|
|
4
|
+
|
|
5
|
+
日本語版は [後半セクション](#日本語) を参照してください。
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | What it does | Main input |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `contrast_check` | Computes the WCAG 2.1 contrast ratio between a foreground and background color and returns AA/AAA pass/fail (normal text, large text, UI components) | `fg`, `bg` (hex, e.g. `#333333` / `333` / `fff`) |
|
|
12
|
+
| `count_chars` | Counts Japanese text by grapheme, breaks it down into zenkaku/hankaku, counts lines, and computes the X (Twitter) post weight (zenkaku=2, hankaku=1, URL=23 flat, limit 280) | `text` |
|
|
13
|
+
| `webp_convert` | Converts PNG/JPEG files to WebP using the same libwebp WASM encoder (default quality 80) as the browser tool at tools.first-ch.com/webp/ | `paths[]` (absolute paths), `quality?` (1-100), `outputDir?` |
|
|
14
|
+
| `jsonld_generate` | Generates schema.org JSON-LD for `organization` / `faqpage` / `service` / `breadcrumb`. Empty fields are omitted automatically | `type`, plus the matching `organization` / `faq` / `service` / `breadcrumb` object |
|
|
15
|
+
| `llmstxt_generate` | Generates an `llms.txt` file (per the llmstxt.org proposed format) summarizing a site for AI crawlers/agents | `siteName`, `summary?`, `notes?`, `sections?` |
|
|
16
|
+
|
|
17
|
+
See [`server.mjs`](./server.mjs) for the exact Zod input schemas.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
With Claude Code:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
With any other MCP client, add to its server config (e.g. `mcp.json` / `claude_desktop_config.json`):
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcpServers": {
|
|
32
|
+
"firstch-tools": {
|
|
33
|
+
"command": "npx",
|
|
34
|
+
"args": ["-y", "@first-ch/tools-mcp"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Requires Node.js `>=18.14.1`.
|
|
41
|
+
|
|
42
|
+
## Telemetry
|
|
43
|
+
|
|
44
|
+
Nothing is logged by default. Usage is recorded **only** when you set the `FIRSTCH_TOOLS_USAGE_LOG` environment variable to a file path — each tool call then appends one JSON line (`{ ts, tool, source }`) to that local file. There is no network transmission of any kind; if the variable is unset, no file is written and no data leaves your machine.
|
|
45
|
+
|
|
46
|
+
## Web version
|
|
47
|
+
|
|
48
|
+
The same algorithms are also available as a free, no-install browser tool at **[tools.first-ch.com](https://tools.first-ch.com)** — useful when you want a UI instead of an MCP call, or want to hand a link to someone without an MCP client.
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
The package itself is licensed under [MIT](./LICENSE).
|
|
53
|
+
|
|
54
|
+
It bundles a subset of [jSquash](https://github.com/jamsinclair/jSquash)'s WebP codec under `vendor/jsquash-webp/` to power `webp_convert`, which carries its own licenses:
|
|
55
|
+
|
|
56
|
+
- The jSquash wrapper code is licensed under **Apache-2.0** — see [`vendor/jsquash-webp/LICENSE`](./vendor/jsquash-webp/LICENSE).
|
|
57
|
+
- The underlying libwebp codec (WASM binary and its JS glue) is licensed under **BSD-3-Clause, Copyright (c) 2010 Google Inc.** — see [`vendor/jsquash-webp/codec/LICENSE.codec.md`](./vendor/jsquash-webp/codec/LICENSE.codec.md).
|
|
58
|
+
|
|
59
|
+
Both license files are included verbatim in the published npm package, as required by their respective terms (BSD-3-Clause in particular requires the copyright notice, condition list, and disclaimer to be reproduced in binary redistributions).
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 日本語
|
|
64
|
+
|
|
65
|
+
`@first-ch/tools-mcp` は、First CH Tools(無料Webツール集)の計算ロジック — WCAGコントラスト比・日本語文字数/Xウェイト計測・WebP変換・JSON-LD生成・llms.txt生成 — をAIエージェント(Claude Code等)向けMCPツールとして提供するサーバーです。
|
|
66
|
+
|
|
67
|
+
### ツール一覧
|
|
68
|
+
|
|
69
|
+
| ツール | 何をするか | 主な入力 |
|
|
70
|
+
| --- | --- | --- |
|
|
71
|
+
| `contrast_check` | 文字色と背景色のWCAG 2.1コントラスト比を計算し、AA/AAA基準(通常テキスト・大テキスト・UI部品)の合否を返す | `fg`・`bg`(hex。例: `#333333` / `333` / `fff`) |
|
|
72
|
+
| `count_chars` | 日本語テキストを書記素単位で数え、全角/半角内訳・行数・X(Twitter)投稿ウェイト(全角=2・半角=1・URL=一律23・上限280)を返す | `text` |
|
|
73
|
+
| `webp_convert` | PNG/JPEG画像をWebPへ変換する。tools.first-ch.com/webp/ と同一のlibwebp WASMエンコーダ(品質既定80) | `paths[]`(絶対パス)・`quality?`(1-100)・`outputDir?` |
|
|
74
|
+
| `jsonld_generate` | schema.org準拠のJSON-LDを生成する(`organization` / `faqpage` / `service` / `breadcrumb`)。空項目は自動で省略 | `type` と対応する `organization` / `faq` / `service` / `breadcrumb` オブジェクト |
|
|
75
|
+
| `llmstxt_generate` | AI検索・生成AI向けにサイト概要を伝える `llms.txt`(llmstxt.org提案フォーマット準拠)を生成する | `siteName`・`summary?`・`notes?`・`sections?` |
|
|
76
|
+
|
|
77
|
+
正確な入力スキーマ(Zod定義)は [`server.mjs`](./server.mjs) を参照してください。
|
|
78
|
+
|
|
79
|
+
### インストール
|
|
80
|
+
|
|
81
|
+
Claude Codeの場合:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
他のMCPクライアントの場合は設定ファイル(`mcp.json` / `claude_desktop_config.json` 等)に以下を追加します。
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"mcpServers": {
|
|
92
|
+
"firstch-tools": {
|
|
93
|
+
"command": "npx",
|
|
94
|
+
"args": ["-y", "@first-ch/tools-mcp"]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Node.js `>=18.14.1` が必要です。
|
|
101
|
+
|
|
102
|
+
### 計測(Telemetry)について
|
|
103
|
+
|
|
104
|
+
既定では何も記録しません。環境変数 `FIRSTCH_TOOLS_USAGE_LOG` にファイルパスを設定したときのみ、各ツール呼び出しごとに1行のJSON(`{ ts, tool, source }`)をそのローカルファイルへ追記します。ネットワーク送信は一切ありません(未設定であればファイルへの書き込み自体が発生せず、データが端末外に出ることはありません)。
|
|
105
|
+
|
|
106
|
+
### Web版
|
|
107
|
+
|
|
108
|
+
同一アルゴリズムを、インストール不要の無料ブラウザツールとしても公開しています: **[tools.first-ch.com](https://tools.first-ch.com)**。UIで使いたいとき・MCPクライアントを持たない相手にリンクを共有したいときはこちらをどうぞ。
|
|
109
|
+
|
|
110
|
+
### ライセンス
|
|
111
|
+
|
|
112
|
+
本パッケージ自体は [MIT](./LICENSE) です。
|
|
113
|
+
|
|
114
|
+
`webp_convert` のために [jSquash](https://github.com/jamsinclair/jSquash) のWebPコーデックの一部を `vendor/jsquash-webp/` 配下に同梱しており、それぞれ別のライセンスが適用されます。
|
|
115
|
+
|
|
116
|
+
- jSquashのラッパーコード部分は **Apache-2.0** — [`vendor/jsquash-webp/LICENSE`](./vendor/jsquash-webp/LICENSE) を参照
|
|
117
|
+
- 内部で使われるlibwebpコーデック本体(WASMバイナリとそのJSグルーコード)は **BSD-3-Clause, Copyright (c) 2010 Google Inc.** — [`vendor/jsquash-webp/codec/LICENSE.codec.md`](./vendor/jsquash-webp/codec/LICENSE.codec.md) を参照
|
|
118
|
+
|
|
119
|
+
いずれのライセンスファイルも公開npmパッケージに原文のまま同梱しています(BSD-3-Clauseはバイナリ再配布時にも著作権表示・条件・免責事項の再掲を求めるため)。
|
package/lib.mjs
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// First CH Tools — 計算ロジック(site/ 各ツールのJSと同一アルゴリズム)
|
|
2
|
+
// site側を変更したらこちらも同期すること(正本はこのファイルとsite側の2重管理を避けるため、
|
|
3
|
+
// アルゴリズム変更時は必ず両方を1コミットで更新する)。
|
|
4
|
+
|
|
5
|
+
export function parseHex(s) {
|
|
6
|
+
s = String(s).trim().replace(/^#/, '');
|
|
7
|
+
if (/^[0-9a-f]{3}$/i.test(s)) s = s.split('').map((c) => c + c).join('');
|
|
8
|
+
if (!/^[0-9a-f]{6}$/i.test(s)) return null;
|
|
9
|
+
return [parseInt(s.slice(0, 2), 16), parseInt(s.slice(2, 4), 16), parseInt(s.slice(4, 6), 16)];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function luminance([r, g, b]) {
|
|
13
|
+
const f = (v) => {
|
|
14
|
+
v /= 255;
|
|
15
|
+
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
|
16
|
+
};
|
|
17
|
+
return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** WCAG 2.1 コントラスト比とAA/AAA判定 */
|
|
21
|
+
export function contrastCheck(fg, bg) {
|
|
22
|
+
const c1 = parseHex(fg);
|
|
23
|
+
const c2 = parseHex(bg);
|
|
24
|
+
if (!c1 || !c2) throw new Error('色は hex 6桁または3桁で指定してください(例: #333333, fff)');
|
|
25
|
+
const l1 = luminance(c1);
|
|
26
|
+
const l2 = luminance(c2);
|
|
27
|
+
const ratio = (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
28
|
+
return {
|
|
29
|
+
fg: '#' + c1.map((v) => v.toString(16).padStart(2, '0')).join(''),
|
|
30
|
+
bg: '#' + c2.map((v) => v.toString(16).padStart(2, '0')).join(''),
|
|
31
|
+
ratio: Math.round(ratio * 100) / 100,
|
|
32
|
+
aa_normal_text: ratio >= 4.5,
|
|
33
|
+
aa_large_text: ratio >= 3,
|
|
34
|
+
aaa_normal_text: ratio >= 7,
|
|
35
|
+
aaa_large_text: ratio >= 4.5,
|
|
36
|
+
ui_components: ratio >= 3,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// X のウェイト1扱い範囲(Latin-1 系・一般句読点の一部)。それ以外(CJK・絵文字等)は2
|
|
41
|
+
function charWeight(cp) {
|
|
42
|
+
if ((cp >= 0x0000 && cp <= 0x10ff) ||
|
|
43
|
+
(cp >= 0x2000 && cp <= 0x200d) ||
|
|
44
|
+
(cp >= 0x2010 && cp <= 0x201f) ||
|
|
45
|
+
(cp >= 0x2032 && cp <= 0x2037)) return 1;
|
|
46
|
+
return 2;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const URL_RE = /https?:\/\/[^\s]+/g;
|
|
50
|
+
|
|
51
|
+
function graphemes(s) {
|
|
52
|
+
const seg = new Intl.Segmenter('ja', { granularity: 'grapheme' });
|
|
53
|
+
return [...seg.segment(s)].map((x) => x.segment);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 文字数・全角/半角・行数・X(Twitter)ウェイト */
|
|
57
|
+
export function countChars(text) {
|
|
58
|
+
const v = String(text);
|
|
59
|
+
const gs = graphemes(v);
|
|
60
|
+
let zen = 0;
|
|
61
|
+
let han = 0;
|
|
62
|
+
for (const g of gs) {
|
|
63
|
+
if (/\s/.test(g)) continue;
|
|
64
|
+
charWeight(g.codePointAt(0)) === 1 ? han++ : zen++;
|
|
65
|
+
}
|
|
66
|
+
let weight = (v.match(URL_RE) || []).length * 23;
|
|
67
|
+
for (const g of graphemes(v.replace(URL_RE, ''))) {
|
|
68
|
+
weight += g.length > 1 ? 2 : charWeight(g.codePointAt(0));
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
total: gs.length,
|
|
72
|
+
total_without_whitespace: graphemes(v.replace(/\s/g, '')).length,
|
|
73
|
+
zenkaku: zen,
|
|
74
|
+
hankaku: han,
|
|
75
|
+
lines: v === '' ? 0 : v.split('\n').length,
|
|
76
|
+
x_weight: weight,
|
|
77
|
+
x_weight_limit: 280,
|
|
78
|
+
x_weight_remaining: 280 - weight,
|
|
79
|
+
x_postable: weight <= 280,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ---- llms.txt 生成(site/llms-txt/app.js と同一アルゴリズム・2箇所ルール対象) ----
|
|
84
|
+
// spec: { siteName, summary?, notes?, sections?: [{ title, links: [{ title, url, note? }] }] }
|
|
85
|
+
export function buildLlmsTxt(spec) {
|
|
86
|
+
const name = String(spec.siteName || '').trim();
|
|
87
|
+
if (!name) throw new Error('siteName は必須です');
|
|
88
|
+
const parts = [`# ${name}`];
|
|
89
|
+
const summary = String(spec.summary || '').trim();
|
|
90
|
+
if (summary) parts.push(summary.split(/\n+/).map((l) => `> ${l.trim()}`).join('\n'));
|
|
91
|
+
const notes = String(spec.notes || '').trim();
|
|
92
|
+
if (notes) parts.push(notes);
|
|
93
|
+
for (const sec of spec.sections || []) {
|
|
94
|
+
const title = String(sec.title || '').trim();
|
|
95
|
+
const links = (sec.links || [])
|
|
96
|
+
.map((l) => ({ title: String(l.title || '').trim(), url: String(l.url || '').trim(), note: String(l.note || '').trim() }))
|
|
97
|
+
.filter((l) => l.title && l.url)
|
|
98
|
+
.map((l) => `- [${l.title}](${l.url})${l.note ? ': ' + l.note : ''}`);
|
|
99
|
+
if (title && links.length) parts.push(`## ${title}\n\n${links.join('\n')}`);
|
|
100
|
+
}
|
|
101
|
+
return parts.join('\n\n') + '\n';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ---- JSON-LD 生成(site/jsonld/app.js と同一アルゴリズム・2箇所ルール対象) ----
|
|
105
|
+
// 空の項目はキーごと省略する。fields はタイプ別(下記 builders 参照)。
|
|
106
|
+
const trimmed = (v) => String(v ?? '').trim();
|
|
107
|
+
|
|
108
|
+
const jsonLdBuilders = {
|
|
109
|
+
organization(f) {
|
|
110
|
+
const o = { '@context': 'https://schema.org', '@type': 'Organization' };
|
|
111
|
+
if (trimmed(f.name)) o.name = trimmed(f.name);
|
|
112
|
+
if (trimmed(f.alternateName)) o.alternateName = trimmed(f.alternateName);
|
|
113
|
+
if (trimmed(f.url)) o.url = trimmed(f.url);
|
|
114
|
+
if (trimmed(f.logo)) o.logo = trimmed(f.logo);
|
|
115
|
+
if (trimmed(f.description)) o.description = trimmed(f.description);
|
|
116
|
+
const same = (f.sameAs || []).map(trimmed).filter(Boolean);
|
|
117
|
+
if (same.length) o.sameAs = same;
|
|
118
|
+
return o;
|
|
119
|
+
},
|
|
120
|
+
faqpage(f) {
|
|
121
|
+
const items = (f.faq || [])
|
|
122
|
+
.map((x) => ({ q: trimmed(x.q), a: trimmed(x.a) }))
|
|
123
|
+
.filter((x) => x.q && x.a)
|
|
124
|
+
.map((x) => ({ '@type': 'Question', name: x.q, acceptedAnswer: { '@type': 'Answer', text: x.a } }));
|
|
125
|
+
return { '@context': 'https://schema.org', '@type': 'FAQPage', mainEntity: items };
|
|
126
|
+
},
|
|
127
|
+
service(f) {
|
|
128
|
+
const o = { '@context': 'https://schema.org', '@type': 'Service' };
|
|
129
|
+
if (trimmed(f.name)) o.name = trimmed(f.name);
|
|
130
|
+
if (trimmed(f.serviceType)) o.serviceType = trimmed(f.serviceType);
|
|
131
|
+
if (trimmed(f.description)) o.description = trimmed(f.description);
|
|
132
|
+
if (trimmed(f.url)) o.url = trimmed(f.url);
|
|
133
|
+
if (trimmed(f.areaServed)) o.areaServed = trimmed(f.areaServed);
|
|
134
|
+
if (trimmed(f.providerName) || trimmed(f.providerUrl)) {
|
|
135
|
+
o.provider = { '@type': 'Organization' };
|
|
136
|
+
if (trimmed(f.providerName)) o.provider.name = trimmed(f.providerName);
|
|
137
|
+
if (trimmed(f.providerUrl)) o.provider.url = trimmed(f.providerUrl);
|
|
138
|
+
}
|
|
139
|
+
return o;
|
|
140
|
+
},
|
|
141
|
+
breadcrumb(f) {
|
|
142
|
+
const items = (f.items || [])
|
|
143
|
+
.map((x) => ({ name: trimmed(x.name), url: trimmed(x.url) }))
|
|
144
|
+
.filter((x) => x.name)
|
|
145
|
+
.map((x, i) => {
|
|
146
|
+
const li = { '@type': 'ListItem', position: i + 1, name: x.name };
|
|
147
|
+
if (x.url) li.item = x.url;
|
|
148
|
+
return li;
|
|
149
|
+
});
|
|
150
|
+
return { '@context': 'https://schema.org', '@type': 'BreadcrumbList', itemListElement: items };
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export function buildJsonLd(type, fields = {}) {
|
|
155
|
+
const builder = jsonLdBuilders[type];
|
|
156
|
+
if (!builder) throw new Error(`未対応タイプ: ${type}(organization / faqpage / service / breadcrumb のいずれか)`);
|
|
157
|
+
const json = builder(fields);
|
|
158
|
+
const snippet = `<script type="application/ld+json">\n${JSON.stringify(json, null, 2)}\n</script>`;
|
|
159
|
+
return { json, snippet };
|
|
160
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@first-ch/tools-mcp",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "First CH Tools の計算ロジック(WCAGコントラスト比・文字数/Xウェイト・WebP変換・JSON-LD生成・llms.txt生成)をMCPツールとして提供するサーバー",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"firstch-tools-mcp": "server.mjs"
|
|
8
|
+
},
|
|
9
|
+
"main": "lib.mjs",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node server.mjs",
|
|
12
|
+
"test": "node test.mjs"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
16
|
+
"jpeg-js": "^0.4.4",
|
|
17
|
+
"pngjs": "^7.0.0",
|
|
18
|
+
"zod": "^3.23.0"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"mcpName": "io.github.First-CH/tools-mcp",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"mcp",
|
|
24
|
+
"model-context-protocol",
|
|
25
|
+
"webp",
|
|
26
|
+
"wcag",
|
|
27
|
+
"contrast",
|
|
28
|
+
"json-ld",
|
|
29
|
+
"llms-txt",
|
|
30
|
+
"character-count"
|
|
31
|
+
],
|
|
32
|
+
"author": "First CH LLC (https://first-ch.com)",
|
|
33
|
+
"homepage": "https://tools.first-ch.com",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/First-CH/FirstCHTools.git",
|
|
37
|
+
"directory": "packages/mcp"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/First-CH/FirstCHTools/issues"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18.14.1"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"server.mjs",
|
|
50
|
+
"lib.mjs",
|
|
51
|
+
"webp.mjs",
|
|
52
|
+
"vendor/",
|
|
53
|
+
"README.md",
|
|
54
|
+
"LICENSE"
|
|
55
|
+
]
|
|
56
|
+
}
|
package/server.mjs
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// First CH Tools MCP サーバー(stdio)
|
|
3
|
+
// 導入例: npx -y @first-ch/tools-mcp
|
|
4
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { appendFile } from 'node:fs/promises';
|
|
8
|
+
import { createRequire } from 'node:module';
|
|
9
|
+
import { contrastCheck, countChars, buildLlmsTxt, buildJsonLd } from './lib.mjs';
|
|
10
|
+
import { convertToWebp } from './webp.mjs';
|
|
11
|
+
|
|
12
|
+
const { version } = createRequire(import.meta.url)('./package.json');
|
|
13
|
+
const server = new McpServer({ name: 'firstch-tools', version });
|
|
14
|
+
|
|
15
|
+
const asText = (obj) => ({ content: [{ type: 'text', text: JSON.stringify(obj, null, 2) }] });
|
|
16
|
+
|
|
17
|
+
// 社内利用の計測(tools-strategy.md KPI 5)。環境変数を設定したときだけローカルJSONLに追記する
|
|
18
|
+
// (opt-in・未設定なら一切記録しない)。ネットワーク送信は一切しない。
|
|
19
|
+
// 集計は FirstCHOps 側 scripts/tools/tools-usage-report.py。計測失敗でツール本体は止めない。
|
|
20
|
+
const USAGE_LOG = process.env.FIRSTCH_TOOLS_USAGE_LOG; // 未設定なら記録しない(opt-in)
|
|
21
|
+
const logUsage = (tool) =>
|
|
22
|
+
USAGE_LOG
|
|
23
|
+
? appendFile(USAGE_LOG, JSON.stringify({ ts: new Date().toISOString(), tool, source: 'mcp' }) + '\n').catch(() => {})
|
|
24
|
+
: Promise.resolve();
|
|
25
|
+
|
|
26
|
+
server.registerTool(
|
|
27
|
+
'contrast_check',
|
|
28
|
+
{
|
|
29
|
+
title: 'WCAGコントラスト比チェック',
|
|
30
|
+
description:
|
|
31
|
+
'文字色と背景色のWCAG 2.1コントラスト比を計算し、AA/AAA基準(通常/大テキスト・UI部品)の合否を返す。' +
|
|
32
|
+
'Webデザインの配色検証・アクセシビリティチェックに使う。',
|
|
33
|
+
inputSchema: {
|
|
34
|
+
fg: z.string().describe('文字色(hex。例: #333333 / 333 / fff)'),
|
|
35
|
+
bg: z.string().describe('背景色(hex。例: #ffffff)'),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
async ({ fg, bg }) => {
|
|
39
|
+
await logUsage('contrast_check');
|
|
40
|
+
return asText(contrastCheck(fg, bg));
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
server.registerTool(
|
|
45
|
+
'count_chars',
|
|
46
|
+
{
|
|
47
|
+
title: '文字数カウント(Xウェイト対応)',
|
|
48
|
+
description:
|
|
49
|
+
'日本語テキストの文字数(書記素単位)・全角/半角内訳・行数と、X(Twitter)の投稿ウェイト' +
|
|
50
|
+
'(全角=2・半角=1・URL=一律23、上限280)を返す。SNS投稿や文字数制限のあるフォーム入力の検証に使う。',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
text: z.string().describe('カウント対象のテキスト'),
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
async ({ text }) => {
|
|
56
|
+
await logUsage('count_chars');
|
|
57
|
+
return asText(countChars(text));
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
server.registerTool(
|
|
62
|
+
'webp_convert',
|
|
63
|
+
{
|
|
64
|
+
title: '画像→WebP変換',
|
|
65
|
+
description:
|
|
66
|
+
'PNG/JPEG画像ファイルをWebPへ変換して保存する。エンコーダは tools.first-ch.com/webp/ と同一の' +
|
|
67
|
+
'libwebp WASM(品質既定80)。Web制作の画像最適化・納品前の軽量化に使う。' +
|
|
68
|
+
'入力は絶対パス。出力先を省略すると入力と同じ場所に拡張子.webpで保存する。',
|
|
69
|
+
inputSchema: {
|
|
70
|
+
paths: z.array(z.string()).min(1).describe('変換するPNG/JPEGファイルの絶対パスの配列'),
|
|
71
|
+
quality: z.number().int().min(1).max(100).optional().describe('品質1-100(既定80)'),
|
|
72
|
+
outputDir: z.string().optional().describe('出力先ディレクトリ(省略時は各入力と同じ場所)'),
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
async ({ paths, quality, outputDir }) => {
|
|
76
|
+
await logUsage('webp_convert');
|
|
77
|
+
const { join, basename } = await import('node:path');
|
|
78
|
+
const results = [];
|
|
79
|
+
for (const p of paths) {
|
|
80
|
+
try {
|
|
81
|
+
const output = outputDir ? join(outputDir, basename(p).replace(/\.[^.]+$/, '') + '.webp') : undefined;
|
|
82
|
+
results.push(await convertToWebp(p, { quality, output }));
|
|
83
|
+
} catch (e) {
|
|
84
|
+
results.push({ input: p, error: String(e.message || e) });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return asText({ converted: results.filter((r) => !r.error).length, results });
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
server.registerTool(
|
|
92
|
+
'jsonld_generate',
|
|
93
|
+
{
|
|
94
|
+
title: 'JSON-LD構造化データ生成',
|
|
95
|
+
description:
|
|
96
|
+
'schema.org準拠のJSON-LD構造化データを生成する(tools.first-ch.com/jsonld/ と同一ロジック)。' +
|
|
97
|
+
'対応タイプ: organization(会社情報)/ faqpage(よくある質問)/ service(提供サービス)/ breadcrumb(パンくず)。' +
|
|
98
|
+
'空の項目は出力から自動で省略される。返り値は json オブジェクトと <script> スニペット。',
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: z.enum(['organization', 'faqpage', 'service', 'breadcrumb']).describe('スキーマタイプ'),
|
|
101
|
+
organization: z
|
|
102
|
+
.object({
|
|
103
|
+
name: z.string().optional(),
|
|
104
|
+
alternateName: z.string().optional(),
|
|
105
|
+
url: z.string().optional(),
|
|
106
|
+
logo: z.string().optional(),
|
|
107
|
+
description: z.string().optional(),
|
|
108
|
+
sameAs: z.array(z.string()).optional().describe('SNS・外部プロフィールURL'),
|
|
109
|
+
})
|
|
110
|
+
.optional()
|
|
111
|
+
.describe('type=organization のときの項目'),
|
|
112
|
+
faq: z
|
|
113
|
+
.array(z.object({ q: z.string().describe('質問'), a: z.string().describe('回答') }))
|
|
114
|
+
.optional()
|
|
115
|
+
.describe('type=faqpage のときのQ&Aリスト'),
|
|
116
|
+
service: z
|
|
117
|
+
.object({
|
|
118
|
+
name: z.string().optional(),
|
|
119
|
+
serviceType: z.string().optional(),
|
|
120
|
+
description: z.string().optional(),
|
|
121
|
+
url: z.string().optional(),
|
|
122
|
+
areaServed: z.string().optional(),
|
|
123
|
+
providerName: z.string().optional(),
|
|
124
|
+
providerUrl: z.string().optional(),
|
|
125
|
+
})
|
|
126
|
+
.optional()
|
|
127
|
+
.describe('type=service のときの項目'),
|
|
128
|
+
breadcrumb: z
|
|
129
|
+
.array(z.object({ name: z.string(), url: z.string().optional().describe('最下層(現在ページ)は省略可') }))
|
|
130
|
+
.optional()
|
|
131
|
+
.describe('type=breadcrumb のときの階層リスト(上から position 1,2,3…)'),
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
async ({ type, organization, faq, service, breadcrumb }) => {
|
|
135
|
+
await logUsage('jsonld_generate');
|
|
136
|
+
const fields = { organization, faqpage: { faq }, service, breadcrumb: { items: breadcrumb } }[type];
|
|
137
|
+
return asText(buildJsonLd(type, fields || {}));
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
server.registerTool(
|
|
142
|
+
'llmstxt_generate',
|
|
143
|
+
{
|
|
144
|
+
title: 'llms.txt 生成',
|
|
145
|
+
description:
|
|
146
|
+
'生成AI・AI検索にサイト概要を伝える llms.txt(llmstxt.org 提案フォーマット準拠)を生成する' +
|
|
147
|
+
'(tools.first-ch.com/llms-txt/ と同一ロジック)。生成テキストをサイトのルート(/llms.txt)に設置して使う。',
|
|
148
|
+
inputSchema: {
|
|
149
|
+
siteName: z.string().describe('サイト名(H1になる)'),
|
|
150
|
+
summary: z.string().optional().describe('サイト概要(引用ブロックになる・改行可)'),
|
|
151
|
+
notes: z.string().optional().describe('補足説明(自由記述の段落)'),
|
|
152
|
+
sections: z
|
|
153
|
+
.array(
|
|
154
|
+
z.object({
|
|
155
|
+
title: z.string().describe('セクション見出し(例: Main Pages / Optional)'),
|
|
156
|
+
links: z.array(
|
|
157
|
+
z.object({
|
|
158
|
+
title: z.string().describe('ページタイトル'),
|
|
159
|
+
url: z.string().describe('ページURL'),
|
|
160
|
+
note: z.string().optional().describe('1行説明'),
|
|
161
|
+
}),
|
|
162
|
+
),
|
|
163
|
+
}),
|
|
164
|
+
)
|
|
165
|
+
.optional()
|
|
166
|
+
.describe('リンクセクション(順に出力される)'),
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
async (spec) => {
|
|
170
|
+
await logUsage('llmstxt_generate');
|
|
171
|
+
return asText({ text: buildLlmsTxt(spec) });
|
|
172
|
+
},
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
await server.connect(new StdioServerTransport());
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2023] jamsinclair
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# vendor/jsquash-webp(サブセットコピー)
|
|
2
|
+
|
|
3
|
+
出所: `site/vendor/jsquash-webp`(`@jsquash/webp` v1.5.0)のサブセットコピー。
|
|
4
|
+
|
|
5
|
+
npm パッケージ `@first-ch/tools-mcp` は tarball としてパッケージルート外を参照できないため、
|
|
6
|
+
`packages/mcp/webp.mjs` が必要とする以下6ファイルのみを、相対ディレクトリ構造を保ったままここへ複製している。
|
|
7
|
+
|
|
8
|
+
- `utils.js`
|
|
9
|
+
- `meta.js`
|
|
10
|
+
- `codec/enc/webp_enc_simd.js`
|
|
11
|
+
- `codec/enc/webp_enc_simd.wasm`
|
|
12
|
+
- `LICENSE`
|
|
13
|
+
- `codec/LICENSE.codec.md`
|
|
14
|
+
|
|
15
|
+
非SIMD版(`webp_enc.js` / `webp_enc.wasm`)はパッケージサイズを不必要に増やさないため含めていない。
|
|
16
|
+
|
|
17
|
+
## ライセンス
|
|
18
|
+
|
|
19
|
+
- jSquash 部分(`utils.js` / `meta.js` 等): Apache-2.0(`LICENSE`)
|
|
20
|
+
- libwebp codec 部分(`codec/enc/webp_enc_simd.*`): BSD-3-Clause(`codec/LICENSE.codec.md`)。同梱WASMの実体は libwebp v1.0.2(Copyright (c) 2010 Google Inc.)
|
|
21
|
+
|
|
22
|
+
## 同期ルール
|
|
23
|
+
|
|
24
|
+
**site側 vendor(`site/vendor/jsquash-webp`)を更新したら、`packages/mcp` 側も同一コミットで更新すること。**
|
|
25
|
+
CIが `cmp` でバイト一致を検査するため、片方だけ更新するとCIが落ちる。
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Copyright (c) 2010, Google Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are
|
|
5
|
+
met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
notice, this list of conditions and the following disclaimer in
|
|
12
|
+
the documentation and/or other materials provided with the
|
|
13
|
+
distribution.
|
|
14
|
+
|
|
15
|
+
* Neither the name of Google nor the names of its contributors may
|
|
16
|
+
be used to endorse or promote products derived from this software
|
|
17
|
+
without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
var Module = (() => {
|
|
3
|
+
var _scriptDir = import.meta.url;
|
|
4
|
+
|
|
5
|
+
return (
|
|
6
|
+
function(Module = {}) {
|
|
7
|
+
|
|
8
|
+
var Module=typeof Module!="undefined"?Module:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});const isServiceWorker=globalThis.ServiceWorkerGlobalScope!==undefined;const isRunningInCloudFlareWorkers=isServiceWorker&&typeof self!=="undefined"&&caches.default!==undefined;if(isRunningInCloudFlareWorkers){if(!globalThis.ImageData){globalThis.ImageData=class ImageData{constructor(data,width,height){this.data=data;this.width=width;this.height=height}}}if(import.meta.url===undefined){import.meta.url="https://localhost"}if(self.location===undefined){self.location={href:""}}}var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var str="";while(!(idx>=endIdx)){var u0=heapOrArray[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len}var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b)}var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}var wasmBinaryFile;if(Module["locateFile"]){wasmBinaryFile="webp_enc_simd.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}}else{wasmBinaryFile=new URL("webp_enc_simd.wasm",import.meta.url).href}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}catch(err){abort(err)}}function getBinaryPromise(binaryFile){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+binaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(binaryFile)})}}return Promise.resolve().then(function(){return getBinary(binaryFile)})}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(function(binary){return WebAssembly.instantiate(binary,imports)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}else{return instantiateArrayBuffer(binaryFile,imports,callback)}}function createWasm(){var info={"a":wasmImports};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;wasmMemory=Module["asm"]["x"];updateMemoryViews();wasmTable=Module["asm"]["D"];addOnInit(Module["asm"]["y"]);removeRunDependency("wasm-instantiate");return exports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err("Module.instantiateWasm callback failed with error: "+e);readyPromiseReject(e)}}instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){callbacks.shift()(Module)}}function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24;this.set_type=function(type){HEAPU32[this.ptr+4>>2]=type};this.get_type=function(){return HEAPU32[this.ptr+4>>2]};this.set_destructor=function(destructor){HEAPU32[this.ptr+8>>2]=destructor};this.get_destructor=function(){return HEAPU32[this.ptr+8>>2]};this.set_refcount=function(refcount){HEAP32[this.ptr>>2]=refcount};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+12>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+12>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+13>>0]!=0};this.init=function(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor);this.set_refcount(0);this.set_caught(false);this.set_rethrown(false)};this.add_ref=function(){var value=HEAP32[this.ptr>>2];HEAP32[this.ptr>>2]=value+1};this.release_ref=function(){var prev=HEAP32[this.ptr>>2];HEAP32[this.ptr>>2]=prev-1;return prev===1};this.set_adjusted_ptr=function(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr};this.get_adjusted_ptr=function(){return HEAPU32[this.ptr+16>>2]};this.get_exception_ptr=function(){var isPointer=___cxa_is_pointer_type(this.get_type());if(isPointer){return HEAPU32[this.excPtr>>2]}var adjusted=this.get_adjusted_ptr();if(adjusted!==0)return adjusted;return this.excPtr}}var exceptionLast=0;var uncaughtExceptionCount=0;function ___cxa_throw(ptr,type,destructor){var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw ptr}var structRegistrations={};function runDestructors(destructors){while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}}function simpleReadValueFromPointer(pointer){return this["fromWireType"](HEAP32[pointer>>2])}var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var char_0=48;var char_9=57;function makeLegalFunctionName(name){if(undefined===name){return"_unknown"}name=name.replace(/[^a-zA-Z0-9_]/g,"$");var f=name.charCodeAt(0);if(f>=char_0&&f<=char_9){return"_"+name}return name}function createNamedFunction(name,body){name=makeLegalFunctionName(name);return{[name]:function(){return body.apply(this,arguments)}}[name]}function extendError(baseErrorType,errorName){var errorClass=createNamedFunction(errorName,function(message){this.name=errorName;this.message=message;var stack=new Error(message).stack;if(stack!==undefined){this.stack=this.toString()+"\n"+stack.replace(/^Error(:[^\n]*)?\n/,"")}});errorClass.prototype=Object.create(baseErrorType.prototype);errorClass.prototype.constructor=errorClass;errorClass.prototype.toString=function(){if(this.message===undefined){return this.name}else{return this.name+": "+this.message}};return errorClass}var InternalError=undefined;function throwInternalError(message){throw new InternalError(message)}function whenDependentTypesAreResolved(myTypes,dependentTypes,getTypeConverters){myTypes.forEach(function(type){typeDependencies[type]=dependentTypes});function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i<myTypes.length;++i){registerType(myTypes[i],myTypeConverters[i])}}var typeConverters=new Array(dependentTypes.length);var unregisteredTypes=[];var registered=0;dependentTypes.forEach((dt,i)=>{if(registeredTypes.hasOwnProperty(dt)){typeConverters[i]=registeredTypes[dt]}else{unregisteredTypes.push(dt);if(!awaitingDependencies.hasOwnProperty(dt)){awaitingDependencies[dt]=[]}awaitingDependencies[dt].push(()=>{typeConverters[i]=registeredTypes[dt];++registered;if(registered===unregisteredTypes.length){onComplete(typeConverters)}})}});if(0===unregisteredTypes.length){onComplete(typeConverters)}}function __embind_finalize_value_object(structType){var reg=structRegistrations[structType];delete structRegistrations[structType];var rawConstructor=reg.rawConstructor;var rawDestructor=reg.rawDestructor;var fieldRecords=reg.fields;var fieldTypes=fieldRecords.map(field=>field.getterReturnType).concat(fieldRecords.map(field=>field.setterArgumentType));whenDependentTypesAreResolved([structType],fieldTypes,fieldTypes=>{var fields={};fieldRecords.forEach((field,i)=>{var fieldName=field.fieldName;var getterReturnType=fieldTypes[i];var getter=field.getter;var getterContext=field.getterContext;var setterArgumentType=fieldTypes[i+fieldRecords.length];var setter=field.setter;var setterContext=field.setterContext;fields[fieldName]={read:ptr=>{return getterReturnType["fromWireType"](getter(getterContext,ptr))},write:(ptr,o)=>{var destructors=[];setter(setterContext,ptr,setterArgumentType["toWireType"](destructors,o));runDestructors(destructors)}}});return[{name:reg.name,"fromWireType":function(ptr){var rv={};for(var i in fields){rv[i]=fields[i].read(ptr)}rawDestructor(ptr);return rv},"toWireType":function(destructors,o){for(var fieldName in fields){if(!(fieldName in o)){throw new TypeError('Missing field: "'+fieldName+'"')}}var ptr=rawConstructor();for(fieldName in fields){fields[fieldName].write(ptr,o[fieldName])}if(destructors!==null){destructors.push(rawDestructor,ptr)}return ptr},"argPackAdvance":8,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:rawDestructor}]})}function __embind_register_bigint(primitiveType,name,size,minRange,maxRange){}function getShiftFromSize(size){switch(size){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+size)}}function embind_init_charCodes(){var codes=new Array(256);for(var i=0;i<256;++i){codes[i]=String.fromCharCode(i)}embind_charCodes=codes}var embind_charCodes=undefined;function readLatin1String(ptr){var ret="";var c=ptr;while(HEAPU8[c]){ret+=embind_charCodes[HEAPU8[c++]]}return ret}var BindingError=undefined;function throwBindingError(message){throw new BindingError(message)}function registerType(rawType,registeredInstance,options={}){if(!("argPackAdvance"in registeredInstance)){throw new TypeError("registerType registeredInstance requires argPackAdvance")}var name=registeredInstance.name;if(!rawType){throwBindingError('type "'+name+'" must have a positive integer typeid pointer')}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError("Cannot register type '"+name+"' twice")}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach(cb=>cb())}}function __embind_register_bool(rawType,name,size,trueValue,falseValue){var shift=getShiftFromSize(size);name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":function(wt){return!!wt},"toWireType":function(destructors,o){return o?trueValue:falseValue},"argPackAdvance":8,"readValueFromPointer":function(pointer){var heap;if(size===1){heap=HEAP8}else if(size===2){heap=HEAP16}else if(size===4){heap=HEAP32}else{throw new TypeError("Unknown boolean type size: "+name)}return this["fromWireType"](heap[pointer>>shift])},destructorFunction:null})}var emval_free_list=[];var emval_handle_array=[{},{value:undefined},{value:null},{value:true},{value:false}];function __emval_decref(handle){if(handle>4&&0===--emval_handle_array[handle].refcount){emval_handle_array[handle]=undefined;emval_free_list.push(handle)}}function count_emval_handles(){var count=0;for(var i=5;i<emval_handle_array.length;++i){if(emval_handle_array[i]!==undefined){++count}}return count}function get_first_emval(){for(var i=5;i<emval_handle_array.length;++i){if(emval_handle_array[i]!==undefined){return emval_handle_array[i]}}return null}function init_emval(){Module["count_emval_handles"]=count_emval_handles;Module["get_first_emval"]=get_first_emval}var Emval={toValue:handle=>{if(!handle){throwBindingError("Cannot use deleted val. handle = "+handle)}return emval_handle_array[handle].value},toHandle:value=>{switch(value){case undefined:return 1;case null:return 2;case true:return 3;case false:return 4;default:{var handle=emval_free_list.length?emval_free_list.pop():emval_handle_array.length;emval_handle_array[handle]={refcount:1,value:value};return handle}}}};function __embind_register_emval(rawType,name){name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":function(handle){var rv=Emval.toValue(handle);__emval_decref(handle);return rv},"toWireType":function(destructors,value){return Emval.toHandle(value)},"argPackAdvance":8,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:null})}function ensureOverloadTable(proto,methodName,humanName){if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=function(){if(!proto[methodName].overloadTable.hasOwnProperty(arguments.length)){throwBindingError("Function '"+humanName+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+proto[methodName].overloadTable+")!")}return proto[methodName].overloadTable[arguments.length].apply(this,arguments)};proto[methodName].overloadTable=[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}}function exposePublicSymbol(name,value,numArguments){if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments]){throwBindingError("Cannot register public name '"+name+"' twice")}ensureOverloadTable(Module,name,name);if(Module.hasOwnProperty(numArguments)){throwBindingError("Cannot register multiple overloads of a function with the same number of arguments ("+numArguments+")!")}Module[name].overloadTable[numArguments]=value}else{Module[name]=value;if(undefined!==numArguments){Module[name].numArguments=numArguments}}}function enumReadValueFromPointer(name,shift,signed){switch(shift){case 0:return function(pointer){var heap=signed?HEAP8:HEAPU8;return this["fromWireType"](heap[pointer])};case 1:return function(pointer){var heap=signed?HEAP16:HEAPU16;return this["fromWireType"](heap[pointer>>1])};case 2:return function(pointer){var heap=signed?HEAP32:HEAPU32;return this["fromWireType"](heap[pointer>>2])};default:throw new TypeError("Unknown integer type: "+name)}}function __embind_register_enum(rawType,name,size,isSigned){var shift=getShiftFromSize(size);name=readLatin1String(name);function ctor(){}ctor.values={};registerType(rawType,{name:name,constructor:ctor,"fromWireType":function(c){return this.constructor.values[c]},"toWireType":function(destructors,c){return c.value},"argPackAdvance":8,"readValueFromPointer":enumReadValueFromPointer(name,shift,isSigned),destructorFunction:null});exposePublicSymbol(name,ctor)}function getTypeName(type){var ptr=___getTypeName(type);var rv=readLatin1String(ptr);_free(ptr);return rv}function requireRegisteredType(rawType,humanName){var impl=registeredTypes[rawType];if(undefined===impl){throwBindingError(humanName+" has unknown type "+getTypeName(rawType))}return impl}function __embind_register_enum_value(rawEnumType,name,enumValue){var enumType=requireRegisteredType(rawEnumType,"enum");name=readLatin1String(name);var Enum=enumType.constructor;var Value=Object.create(enumType.constructor.prototype,{value:{value:enumValue},constructor:{value:createNamedFunction(enumType.name+"_"+name,function(){})}});Enum.values[enumValue]=Value;Enum[name]=Value}function floatReadValueFromPointer(name,shift){switch(shift){case 2:return function(pointer){return this["fromWireType"](HEAPF32[pointer>>2])};case 3:return function(pointer){return this["fromWireType"](HEAPF64[pointer>>3])};default:throw new TypeError("Unknown float type: "+name)}}function __embind_register_float(rawType,name,size){var shift=getShiftFromSize(size);name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":function(value){return value},"toWireType":function(destructors,value){return value},"argPackAdvance":8,"readValueFromPointer":floatReadValueFromPointer(name,shift),destructorFunction:null})}function craftInvokerFunction(humanName,argTypes,classType,cppInvokerFunc,cppTargetFunc,isAsync){var argCount=argTypes.length;if(argCount<2){throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!")}var isClassMethodFunc=argTypes[1]!==null&&classType!==null;var needsDestructorStack=false;for(var i=1;i<argTypes.length;++i){if(argTypes[i]!==null&&argTypes[i].destructorFunction===undefined){needsDestructorStack=true;break}}var returns=argTypes[0].name!=="void";var expectedArgCount=argCount-2;var argsWired=new Array(expectedArgCount);var invokerFuncArgs=[];var destructors=[];return function(){if(arguments.length!==expectedArgCount){throwBindingError("function "+humanName+" called with "+arguments.length+" arguments, expected "+expectedArgCount+" args!")}destructors.length=0;var thisWired;invokerFuncArgs.length=isClassMethodFunc?2:1;invokerFuncArgs[0]=cppTargetFunc;if(isClassMethodFunc){thisWired=argTypes[1]["toWireType"](destructors,this);invokerFuncArgs[1]=thisWired}for(var i=0;i<expectedArgCount;++i){argsWired[i]=argTypes[i+2]["toWireType"](destructors,arguments[i]);invokerFuncArgs.push(argsWired[i])}var rv=cppInvokerFunc.apply(null,invokerFuncArgs);function onDone(rv){if(needsDestructorStack){runDestructors(destructors)}else{for(var i=isClassMethodFunc?1:2;i<argTypes.length;i++){var param=i===1?thisWired:argsWired[i-2];if(argTypes[i].destructorFunction!==null){argTypes[i].destructorFunction(param)}}}if(returns){return argTypes[0]["fromWireType"](rv)}}return onDone(rv)}}function heap32VectorToArray(count,firstElement){var array=[];for(var i=0;i<count;i++){array.push(HEAPU32[firstElement+i*4>>2])}return array}function replacePublicSymbol(name,value,numArguments){if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistant public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}}function dynCallLegacy(sig,ptr,args){var f=Module["dynCall_"+sig];return args&&args.length?f.apply(null,[ptr].concat(args)):f.call(null,ptr)}var wasmTableMirror=[];function getWasmTableEntry(funcPtr){var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func}function dynCall(sig,ptr,args){if(sig.includes("j")){return dynCallLegacy(sig,ptr,args)}var rtn=getWasmTableEntry(ptr).apply(null,args);return rtn}function getDynCaller(sig,ptr){var argCache=[];return function(){argCache.length=0;Object.assign(argCache,arguments);return dynCall(sig,ptr,argCache)}}function embind__requireFunction(signature,rawFunction){signature=readLatin1String(signature);function makeDynCaller(){if(signature.includes("j")){return getDynCaller(signature,rawFunction)}return getWasmTableEntry(rawFunction)}var fp=makeDynCaller();if(typeof fp!="function"){throwBindingError("unknown function pointer with signature "+signature+": "+rawFunction)}return fp}var UnboundTypeError=undefined;function throwUnboundTypeError(message,types){var unboundTypes=[];var seen={};function visit(type){if(seen[type]){return}if(registeredTypes[type]){return}if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(message+": "+unboundTypes.map(getTypeName).join([", "]))}function __embind_register_function(name,argCount,rawArgTypesAddr,signature,rawInvoker,fn,isAsync){var argTypes=heap32VectorToArray(argCount,rawArgTypesAddr);name=readLatin1String(name);rawInvoker=embind__requireFunction(signature,rawInvoker);exposePublicSymbol(name,function(){throwUnboundTypeError("Cannot call "+name+" due to unbound types",argTypes)},argCount-1);whenDependentTypesAreResolved([],argTypes,function(argTypes){var invokerArgsArray=[argTypes[0],null].concat(argTypes.slice(1));replacePublicSymbol(name,craftInvokerFunction(name,invokerArgsArray,null,rawInvoker,fn,isAsync),argCount-1);return[]})}function integerReadValueFromPointer(name,shift,signed){switch(shift){case 0:return signed?function readS8FromPointer(pointer){return HEAP8[pointer]}:function readU8FromPointer(pointer){return HEAPU8[pointer]};case 1:return signed?function readS16FromPointer(pointer){return HEAP16[pointer>>1]}:function readU16FromPointer(pointer){return HEAPU16[pointer>>1]};case 2:return signed?function readS32FromPointer(pointer){return HEAP32[pointer>>2]}:function readU32FromPointer(pointer){return HEAPU32[pointer>>2]};default:throw new TypeError("Unknown integer type: "+name)}}function __embind_register_integer(primitiveType,name,size,minRange,maxRange){name=readLatin1String(name);if(maxRange===-1){maxRange=4294967295}var shift=getShiftFromSize(size);var fromWireType=value=>value;if(minRange===0){var bitshift=32-8*size;fromWireType=value=>value<<bitshift>>>bitshift}var isUnsignedType=name.includes("unsigned");var checkAssertions=(value,toTypeName)=>{};var toWireType;if(isUnsignedType){toWireType=function(destructors,value){checkAssertions(value,this.name);return value>>>0}}else{toWireType=function(destructors,value){checkAssertions(value,this.name);return value}}registerType(primitiveType,{name:name,"fromWireType":fromWireType,"toWireType":toWireType,"argPackAdvance":8,"readValueFromPointer":integerReadValueFromPointer(name,shift,minRange!==0),destructorFunction:null})}function __embind_register_memory_view(rawType,dataTypeIndex,name){var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){handle=handle>>2;var heap=HEAPU32;var size=heap[handle];var data=heap[handle+1];return new TA(heap.buffer,data,size)}name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":decodeMemoryView,"argPackAdvance":8,"readValueFromPointer":decodeMemoryView},{ignoreDuplicateRegistrations:true})}function __embind_register_std_string(rawType,name){name=readLatin1String(name);var stdStringIsUTF8=name==="std::string";registerType(rawType,{name:name,"fromWireType":function(value){var length=HEAPU32[value>>2];var payload=value+4;var str;if(stdStringIsUTF8){var decodeStartPtr=payload;for(var i=0;i<=length;++i){var currentBytePtr=payload+i;if(i==length||HEAPU8[currentBytePtr]==0){var maxRead=currentBytePtr-decodeStartPtr;var stringSegment=UTF8ToString(decodeStartPtr,maxRead);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+1}}}else{var a=new Array(length);for(var i=0;i<length;++i){a[i]=String.fromCharCode(HEAPU8[payload+i])}str=a.join("")}_free(value);return str},"toWireType":function(destructors,value){if(value instanceof ArrayBuffer){value=new Uint8Array(value)}var length;var valueIsOfTypeString=typeof value=="string";if(!(valueIsOfTypeString||value instanceof Uint8Array||value instanceof Uint8ClampedArray||value instanceof Int8Array)){throwBindingError("Cannot pass non-string to std::string")}if(stdStringIsUTF8&&valueIsOfTypeString){length=lengthBytesUTF8(value)}else{length=value.length}var base=_malloc(4+length+1);var ptr=base+4;HEAPU32[base>>2]=length;if(stdStringIsUTF8&&valueIsOfTypeString){stringToUTF8(value,ptr,length+1)}else{if(valueIsOfTypeString){for(var i=0;i<length;++i){var charCode=value.charCodeAt(i);if(charCode>255){_free(ptr);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+i]=charCode}}else{for(var i=0;i<length;++i){HEAPU8[ptr+i]=value[i]}}}if(destructors!==null){destructors.push(_free,base)}return base},"argPackAdvance":8,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:function(ptr){_free(ptr)}})}function UTF16ToString(ptr,maxBytesToRead){var str="";for(var i=0;!(i>=maxBytesToRead/2);++i){var codeUnit=HEAP16[ptr+i*2>>1];if(codeUnit==0)break;str+=String.fromCharCode(codeUnit)}return str}function stringToUTF16(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite<str.length*2?maxBytesToWrite/2:str.length;for(var i=0;i<numCharsToWrite;++i){var codeUnit=str.charCodeAt(i);HEAP16[outPtr>>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr}function lengthBytesUTF16(str){return str.length*2}function UTF32ToString(ptr,maxBytesToRead){var i=0;var str="";while(!(i>=maxBytesToRead/4)){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)break;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else{str+=String.fromCharCode(utf32)}}return str}function stringToUTF32(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i<str.length;++i){var codeUnit=str.charCodeAt(i);if(codeUnit>=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr}function lengthBytesUTF32(str){var len=0;for(var i=0;i<str.length;++i){var codeUnit=str.charCodeAt(i);if(codeUnit>=55296&&codeUnit<=57343)++i;len+=4}return len}function __embind_register_std_wstring(rawType,charSize,name){name=readLatin1String(name);var decodeString,encodeString,getHeap,lengthBytesUTF,shift;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16;getHeap=()=>HEAPU16;shift=1}else if(charSize===4){decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32;getHeap=()=>HEAPU32;shift=2}registerType(rawType,{name:name,"fromWireType":function(value){var length=HEAPU32[value>>2];var HEAP=getHeap();var str;var decodeStartPtr=value+4;for(var i=0;i<=length;++i){var currentBytePtr=value+4+i*charSize;if(i==length||HEAP[currentBytePtr>>shift]==0){var maxReadBytes=currentBytePtr-decodeStartPtr;var stringSegment=decodeString(decodeStartPtr,maxReadBytes);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+charSize}}_free(value);return str},"toWireType":function(destructors,value){if(!(typeof value=="string")){throwBindingError("Cannot pass non-string to C++ string type "+name)}var length=lengthBytesUTF(value);var ptr=_malloc(4+length+charSize);HEAPU32[ptr>>2]=length>>shift;encodeString(value,ptr+4,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},"argPackAdvance":8,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:function(ptr){_free(ptr)}})}function __embind_register_value_object(rawType,name,constructorSignature,rawConstructor,destructorSignature,rawDestructor){structRegistrations[rawType]={name:readLatin1String(name),rawConstructor:embind__requireFunction(constructorSignature,rawConstructor),rawDestructor:embind__requireFunction(destructorSignature,rawDestructor),fields:[]}}function __embind_register_value_object_field(structType,fieldName,getterReturnType,getterSignature,getter,getterContext,setterArgumentType,setterSignature,setter,setterContext){structRegistrations[structType].fields.push({fieldName:readLatin1String(fieldName),getterReturnType:getterReturnType,getter:embind__requireFunction(getterSignature,getter),getterContext:getterContext,setterArgumentType:setterArgumentType,setter:embind__requireFunction(setterSignature,setter),setterContext:setterContext})}function __embind_register_void(rawType,name){name=readLatin1String(name);registerType(rawType,{isVoid:true,name:name,"argPackAdvance":0,"fromWireType":function(){return undefined},"toWireType":function(destructors,o){return undefined}})}var emval_symbols={};function getStringOrSymbol(address){var symbol=emval_symbols[address];if(symbol===undefined){return readLatin1String(address)}return symbol}function emval_get_global(){if(typeof globalThis=="object"){return globalThis}function testGlobal(obj){obj["$$$embind_global$$$"]=obj;var success=typeof $$$embind_global$$$=="object"&&obj["$$$embind_global$$$"]==obj;if(!success){delete obj["$$$embind_global$$$"]}return success}if(typeof $$$embind_global$$$=="object"){return $$$embind_global$$$}if(typeof global=="object"&&testGlobal(global)){$$$embind_global$$$=global}else if(typeof self=="object"&&testGlobal(self)){$$$embind_global$$$=self}if(typeof $$$embind_global$$$=="object"){return $$$embind_global$$$}throw Error("unable to get global object.")}function __emval_get_global(name){if(name===0){return Emval.toHandle(emval_get_global())}else{name=getStringOrSymbol(name);return Emval.toHandle(emval_get_global()[name])}}function __emval_incref(handle){if(handle>4){emval_handle_array[handle].refcount+=1}}function craftEmvalAllocator(argCount){var argsList=new Array(argCount+1);return function(constructor,argTypes,args){argsList[0]=constructor;for(var i=0;i<argCount;++i){var argType=requireRegisteredType(HEAPU32[argTypes+i*4>>2],"parameter "+i);argsList[i+1]=argType["readValueFromPointer"](args);args+=argType["argPackAdvance"]}var obj=new(constructor.bind.apply(constructor,argsList));return Emval.toHandle(obj)}}var emval_newers={};function __emval_new(handle,argCount,argTypes,args){handle=Emval.toValue(handle);var newer=emval_newers[argCount];if(!newer){newer=craftEmvalAllocator(argCount);emval_newers[argCount]=newer}return newer(handle,argTypes,args)}function _abort(){abort("")}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function getHeapMax(){return 2147483648}function emscripten_realloc_buffer(size){var b=wasmMemory.buffer;try{wasmMemory.grow(size-b.byteLength+65535>>>16);updateMemoryViews();return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}let alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}InternalError=Module["InternalError"]=extendError(Error,"InternalError");embind_init_charCodes();BindingError=Module["BindingError"]=extendError(Error,"BindingError");init_emval();UnboundTypeError=Module["UnboundTypeError"]=extendError(Error,"UnboundTypeError");var wasmImports={"k":___cxa_throw,"m":__embind_finalize_value_object,"o":__embind_register_bigint,"t":__embind_register_bool,"s":__embind_register_emval,"q":__embind_register_enum,"d":__embind_register_enum_value,"h":__embind_register_float,"f":__embind_register_function,"c":__embind_register_integer,"b":__embind_register_memory_view,"i":__embind_register_std_string,"e":__embind_register_std_wstring,"n":__embind_register_value_object,"a":__embind_register_value_object_field,"u":__embind_register_void,"j":__emval_decref,"w":__emval_get_global,"l":__emval_incref,"v":__emval_new,"g":_abort,"r":_emscripten_memcpy_big,"p":_emscripten_resize_heap};var asm=createWasm();var ___wasm_call_ctors=function(){return(___wasm_call_ctors=Module["asm"]["y"]).apply(null,arguments)};var _malloc=function(){return(_malloc=Module["asm"]["z"]).apply(null,arguments)};var _free=function(){return(_free=Module["asm"]["A"]).apply(null,arguments)};var ___getTypeName=Module["___getTypeName"]=function(){return(___getTypeName=Module["___getTypeName"]=Module["asm"]["B"]).apply(null,arguments)};var __embind_initialize_bindings=Module["__embind_initialize_bindings"]=function(){return(__embind_initialize_bindings=Module["__embind_initialize_bindings"]=Module["asm"]["C"]).apply(null,arguments)};var ___errno_location=function(){return(___errno_location=Module["asm"]["__errno_location"]).apply(null,arguments)};var ___cxa_is_pointer_type=function(){return(___cxa_is_pointer_type=Module["asm"]["E"]).apply(null,arguments)};var dynCall_jiiii=Module["dynCall_jiiii"]=function(){return(dynCall_jiiii=Module["dynCall_jiiii"]=Module["asm"]["F"]).apply(null,arguments)};var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
return Module.ready
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
);
|
|
15
|
+
})();
|
|
16
|
+
export default Module;
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const label = 'WebP';
|
|
2
|
+
export const mimeType = 'image/webp';
|
|
3
|
+
export const extension = 'webp';
|
|
4
|
+
// These come from struct WebPConfig in encode.h.
|
|
5
|
+
export const defaultOptions = {
|
|
6
|
+
quality: 75,
|
|
7
|
+
target_size: 0,
|
|
8
|
+
target_PSNR: 0,
|
|
9
|
+
method: 4,
|
|
10
|
+
sns_strength: 50,
|
|
11
|
+
filter_strength: 60,
|
|
12
|
+
filter_sharpness: 0,
|
|
13
|
+
filter_type: 1,
|
|
14
|
+
partitions: 0,
|
|
15
|
+
segments: 4,
|
|
16
|
+
pass: 1,
|
|
17
|
+
show_compressed: 0,
|
|
18
|
+
preprocessing: 0,
|
|
19
|
+
autofilter: 0,
|
|
20
|
+
partition_limit: 0,
|
|
21
|
+
alpha_compression: 1,
|
|
22
|
+
alpha_filtering: 1,
|
|
23
|
+
alpha_quality: 100,
|
|
24
|
+
lossless: 0,
|
|
25
|
+
exact: 0,
|
|
26
|
+
image_hint: 0,
|
|
27
|
+
emulate_jpeg_size: 0,
|
|
28
|
+
thread_level: 0,
|
|
29
|
+
low_memory: 0,
|
|
30
|
+
near_lossless: 100,
|
|
31
|
+
use_delta_palette: 0,
|
|
32
|
+
use_sharp_yuv: 0,
|
|
33
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
* See the License for the specific language governing permissions and
|
|
11
|
+
* limitations under the License.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Notice: I (Jamie Sinclair) have modified this file to allow manual instantiation of the Wasm Module.
|
|
15
|
+
*/
|
|
16
|
+
export function initEmscriptenModule(moduleFactory, wasmModule, moduleOptionOverrides = {}) {
|
|
17
|
+
let instantiateWasm;
|
|
18
|
+
if (wasmModule) {
|
|
19
|
+
instantiateWasm = (imports, callback) => {
|
|
20
|
+
const instance = new WebAssembly.Instance(wasmModule, imports);
|
|
21
|
+
callback(instance);
|
|
22
|
+
return instance.exports;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return moduleFactory({
|
|
26
|
+
// Just to be safe, don't automatically invoke any wasm functions
|
|
27
|
+
noInitialRun: true,
|
|
28
|
+
instantiateWasm,
|
|
29
|
+
...moduleOptionOverrides,
|
|
30
|
+
});
|
|
31
|
+
}
|
package/webp.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// WebP変換(MCPツール用・Node実行)
|
|
2
|
+
// エンコーダはパッケージ内 packages/mcp/vendor/jsquash-webp の libwebp WASM を読み込む。
|
|
3
|
+
// これは site/vendor/jsquash-webp とバイト単位で同期させたコピー(CLAUDE.md「vendorコピーの同期ルール」対象・CIで検査)
|
|
4
|
+
// =ブラウザ版と同一品質・同一アルゴリズム。
|
|
5
|
+
// PNG/JPEG のデコードのみ Node に Canvas がないため pure-JS の pngjs / jpeg-js で行う。
|
|
6
|
+
|
|
7
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { PNG } from 'pngjs';
|
|
10
|
+
import jpeg from 'jpeg-js';
|
|
11
|
+
// encode.js は 'wasm-feature-detect' を bare import しており Node から解決できないため、
|
|
12
|
+
// emscripten グルーを直接読み込む(encode.js がSIMD対応環境で行うのと同じ組み合わせ)
|
|
13
|
+
import webpEncoder from './vendor/jsquash-webp/codec/enc/webp_enc_simd.js';
|
|
14
|
+
import { initEmscriptenModule } from './vendor/jsquash-webp/utils.js';
|
|
15
|
+
import { defaultOptions } from './vendor/jsquash-webp/meta.js';
|
|
16
|
+
|
|
17
|
+
let encoderReady;
|
|
18
|
+
|
|
19
|
+
function ensureEncoder() {
|
|
20
|
+
if (!encoderReady) {
|
|
21
|
+
encoderReady = (async () => {
|
|
22
|
+
const wasmUrl = new URL('./vendor/jsquash-webp/codec/enc/webp_enc_simd.wasm', import.meta.url);
|
|
23
|
+
const wasmModule = await WebAssembly.compile(await readFile(wasmUrl));
|
|
24
|
+
return initEmscriptenModule(webpEncoder, wasmModule);
|
|
25
|
+
})();
|
|
26
|
+
}
|
|
27
|
+
return encoderReady;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function decodeImage(buf, file) {
|
|
31
|
+
if (buf[0] === 0x89 && buf[1] === 0x50) {
|
|
32
|
+
const png = PNG.sync.read(buf);
|
|
33
|
+
return { data: new Uint8ClampedArray(png.data), width: png.width, height: png.height };
|
|
34
|
+
}
|
|
35
|
+
if (buf[0] === 0xff && buf[1] === 0xd8) {
|
|
36
|
+
const img = jpeg.decode(buf, { useTArray: true, maxMemoryUsageInMB: 2048, maxResolutionInMP: 200 });
|
|
37
|
+
return { data: new Uint8ClampedArray(img.data), width: img.width, height: img.height };
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`${file}: PNG / JPEG のみ対応です(SVG・WebP入力は未対応)`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 1ファイルをWebPへ変換する。
|
|
44
|
+
* @param {string} input 入力ファイルの絶対パス(PNG/JPEG)
|
|
45
|
+
* @param {object} opts { output?: 出力パス(既定=入力の拡張子を.webpに), quality?: 1-100(既定80・サイト版と同じ) }
|
|
46
|
+
* @returns {Promise<object>} { input, output, width, height, bytesIn, bytesOut, saving }
|
|
47
|
+
*/
|
|
48
|
+
export async function convertToWebp(input, opts = {}) {
|
|
49
|
+
const encoder = await ensureEncoder();
|
|
50
|
+
const quality = opts.quality ?? 80;
|
|
51
|
+
const output = opts.output || input.replace(/\.[^.]+$/, '') + '.webp';
|
|
52
|
+
const buf = await readFile(input);
|
|
53
|
+
const image = decodeImage(buf, path.basename(input));
|
|
54
|
+
const result = encoder.encode(image.data, image.width, image.height, { ...defaultOptions, quality });
|
|
55
|
+
if (!result) throw new Error(`${path.basename(input)}: エンコードに失敗しました`);
|
|
56
|
+
const webp = result.buffer;
|
|
57
|
+
await writeFile(output, Buffer.from(webp));
|
|
58
|
+
const bytesOut = webp.byteLength;
|
|
59
|
+
return {
|
|
60
|
+
input,
|
|
61
|
+
output,
|
|
62
|
+
width: image.width,
|
|
63
|
+
height: image.height,
|
|
64
|
+
bytesIn: buf.length,
|
|
65
|
+
bytesOut,
|
|
66
|
+
saving: `${(100 - (bytesOut / buf.length) * 100).toFixed(1)}%`,
|
|
67
|
+
};
|
|
68
|
+
}
|