macOS ネイティブ技術だけで実装した EPUB 3 ツールキット。 日本語組版(縦組み・ルビ・縦中横・圏点・右綴じ)を第一級でサポートする。
An EPUB 3 toolkit built entirely with macOS-native technologies, with first-class support for Japanese typography: vertical writing, ruby, tate-chu-yoko, emphasis marks, and right binding.
macOS 14 以降・Swift 6。Xcode の File → Add Package Dependencies… に
https://github.com/shunnag/Washi.git を入力し、Up to Next Major Version に
最新の GitHub Release の版を指定して
追加する。アプリのターゲットには、表示するなら Washi、解析・表紙・検索だけなら
WashiCore を選ぶ。通常の SwiftPM 利用で WashiDynamic を選ぶ必要はない。
Requires macOS 14+ and Swift 6. In Xcode, choose File → Add Package Dependencies…,
enter https://github.com/shunnag/Washi.git, and use Up to Next Major Version with
the latest GitHub Release.
Add Washi to your app target for rendering, or WashiCore for parsing, covers,
and search. Ordinary SwiftPM clients do not need WashiDynamic.
まず動作を見たい場合は、独立したサンプルを起動する。両方とも小さな EPUB を同梱し、 ファイル選択、ページ送り、検索とハイライト、読書位置の保存・復元を試せる。
To try a working app first, run either standalone sample. Both include a small EPUB and demonstrate file selection, paging, search and highlights, and position restoration.
git clone https://github.com/shunnag/Washi.git
cd Washi
Scripts/run-sample.sh AppKitReader
# SwiftUI 版 / SwiftUI version
Scripts/run-sample.sh SwiftUIReader- 導入と最初の表示 / Installation and first display
- サンプルの構成・実行方法 / Sample apps
- 公開ドキュメント / Online documentation
公開ガイドとサンプルは main ブランチに追従し、最新の GitHub Release の公開 API で動作する。 MIT ライセンスで、第三者パッケージには依存しない。
The online guides and samples follow the main branch and use the public API of the latest GitHub Release. MIT-licensed, with no third-party package dependencies.
| パス / Path | 内容 / Contents |
|---|---|
Package.swift |
SwiftPM manifest。プロダクト WashiCore / Washi / WashiDynamic(cooViewer 向け dylib、契約はコメント参照) / Manifest; products and the WashiDynamic contract |
Sources/WashiCore/ |
解析層(AppKit / WebKit なし)。話題ごとのフォルダ / Parsing layer, one folder per topic |
Sources/WashiCore/EPUBError.swift |
両層で共有する EPUBError と EPUBReadStrategy(フォルダに属さない唯一のファイル) / Shared error and read-strategy types, the only root-level file |
Sources/WashiCore/Container/ |
ZIP・OCF コンテナの読み出しと CRC / ZIP, OCF container, CRC |
Sources/WashiCore/Package/ |
パッケージ文書(OPF)とメタデータ・アクセシビリティ / Package document and metadata |
Sources/WashiCore/Navigation/ |
nav 文書と NCX / Navigation document and NCX |
Sources/WashiCore/Publication/ |
EPUBPublication、locator、本文抽出・検索、表紙、固定レイアウト、脚注 / Publication, locators, text, search, covers |
Sources/WashiCore/Encryption/ |
encryption.xml、フォント難読化、DRM 検出 / Encryption, font deobfuscation, DRM detection |
Sources/WashiCore/MediaOverlay/ |
SMIL の解析 / SMIL parsing |
Sources/WashiCore/Util/ |
XML 走査、文字コード判定、メディアタイプ、HTML 実体表(自動生成) / XML, charset, media types, generated HTML entities |
Sources/WashiCore/WashiCore.docc/ |
WashiCore の DocC カタログ / DocC catalog |
Sources/Washi/ |
表示層(AppKit / WebKit)。WashiExports.swift が WashiCore を再輸出 / Rendering layer; re-exports WashiCore |
Sources/Washi/Reader/ |
EPUBReaderView、delegate、設定、テーマ CSS、キー処理 / Reader view, delegate, settings |
Sources/Washi/WebContent/ |
注入 JavaScript / CSS、scheme handler、スクリプト強化 / Injected scripts, scheme handler |
Sources/Washi/Pagination/ |
表示メトリクス、census 記録、フロー判定 / Screen metrics, census records |
Sources/Washi/Offscreen/ |
不可視 WebKit による census・サムネイル・ラスタライズ / Offscreen census, thumbnails, rasterizer |
Sources/Washi/MediaOverlay/ |
メディアオーバーレイ再生 / Media overlay playback |
Sources/Washi/Util/ |
CSS 色の解析、タイムアウト付き待機 / CSS colors, timeout helpers |
Sources/Washi/Washi.docc/ |
Washi の DocC カタログとガイド / DocC catalog and guides |
Tests/WashiTests/ |
両層の単体テスト(@testable)。WebKit を使うものは GUI セッションで実行 / Unit tests for both layers |
Tests/WashiPublicAPITests/ |
公開 API だけを使うテスト / Public-API-only tests |
Tests/Scripts/ |
Scripts/ の Python テスト(unittest) / Python tests for the scripts |
Tests/Corpus/ |
公開 EPUB コーパスの manifest と手順(英語) / Public corpus manifest and instructions |
Samples/ |
独立した AppKit / SwiftUI サンプルアプリ / Standalone sample apps |
Scripts/run-sample.sh |
サンプルのビルドと起動 / Build and launch a sample |
Scripts/build-documentation.py |
DocC のビルド、ガイドと README の Swift 例の型検査、静的サイト生成 / DocC build, example typecheck, site |
Scripts/fetch-epub-corpus.py |
公開コーパスの取得と照合 / Fetch and verify the corpus |
Scripts/generate-html-entities.py |
WHATWG entities.json から HTMLEntities.swift を生成 / Generate the entity table |
Scripts/release.sh |
リリース前検証の入口(release.py を呼ぶだけ、タグ作成は行わない) / Release preflight entry point |
Scripts/release.py |
リリース前検証の本体 / Release preflight checks |
Scripts/release_support.py |
版番号と CHANGELOG 検証の共通部 / Shared version and changelog checks |
Scripts/publish-github-release.py |
CI がタグから GitHub Release を作る / CI release publisher |
Documentation/ |
監査記録などの開発文書 / Development documents such as audit records |
CHANGELOG.md |
変更履歴(Keep a Changelog) / Change log |
.beads/ |
課題管理(beads)。.beads/README.md 参照 / Issue tracking |
-
依存ゼロ: ZIP 読み取り(zip64・CRC 検証)から自前実装。解析層は Foundation の
XMLDocument・CoreFoundation・zlib(libz、OS 標準)・CryptoKit・CoreGraphics・ImageIO のみ (ヘッドレス利用可)、表示層(EPUBReaderView等)は AppKit・WebKit を使用Zero dependencies: implemented in-house, starting with ZIP reading (zip64, CRC validation). The parsing layer uses only Foundation's
XMLDocument, CoreFoundation, zlib (libz, part of the OS), CryptoKit, CoreGraphics, and ImageIO (headless); the rendering layer (EPUBReaderViewand related types) uses AppKit and WebKit. -
攻撃的 EPUB への耐性: zip 爆弾(比率+絶対上限)、XML 実体爆弾(billion laughs。 互換シムは許容)、異常な深さの XML、パス走査・シンボリックリンク脱出を入口で遮断(テスト付き)
Resilience against malicious EPUBs: blocks zip bombs (ratio and absolute limits), XML entity bombs (billion laughs, allowing compatibility shims), excessively deep XML, path traversal, and symlink escapes at the point of entry, with tests.
-
EPUB 3.3 の RS(閲覧システム)要件に準拠する設計(EPUB 2.0.1 後方互換込み): OCF コンテナ(複数 rootfile・
mimetype検証・encryption.xml、.epubと展開済み フォルダの両方)。パッケージ文書は DCMES +refines、display-seq、シリーズ (belongs-to-collection)、prefix正規化、rendition プロパティ、page-progression-direction、循環ガード付き manifest フォールバック、EPUB 2 のopf:*属性とmeta name="cover"。ナビゲーションは EPUB 3 nav(toc / page-list / landmarks)+ NCX フォールバックDesigned to conform to EPUB 3.3 reading-system requirements, with EPUB 2.0.1 compatibility: OCF containers (multiple rootfiles,
mimetypevalidation,encryption.xml; both.epubfiles and unpacked directories); package documents with DCMES +refines,display-seq, series (belongs-to-collection),prefixnormalization, rendition properties,page-progression-direction, manifest fallback chains with cycle guards, and EPUB 2opf:*attributes andmeta name="cover"; EPUB 3 nav (toc / page-list / landmarks) with an NCX fallback. -
本文抽出・全文検索(WebKit 不要): 大小文字・ダイアクリティカルマーク・全半角の 区別を
EPUBSearchOptionsで個別指定。EPUBSearchHit.utf16Rangeは DOM Range と同じ UTF-16 コード単位。XML 宣言と HTML の meta charset を解析・表示で共通判定し、 Shift_JIS 系は NEC / IBM 拡張を含む CP932、EUC-JP は日本語 EUC として復号Text extraction and full-text search without WebKit. Configure case, diacritic, and character-width sensitivity with
EPUBSearchOptions;EPUBSearchHit.utf16Rangeuses UTF-16 code units like DOM Range. Parsing and rendering share encoding detection; Shift_JIS variants decode as CP932 (NEC / IBM extensions), EUC-JP as Japanese EUC. -
フォント難読化の透過解除(IDPF / Adobe)。DRM(ADEPT / LCP / FairPlay)は指紋検出して 明示的に報告(復号はしない)
Transparent font deobfuscation (IDPF / Adobe). DRM (ADEPT / LCP / FairPlay) is detected by its signatures and reported explicitly; it is not decrypted.
-
メディアオーバーレイ(SMIL)の再生:
playMediaOverlay()/pauseMediaOverlay()/stopMediaOverlay()。読み上げ箇所にmedia:active-classを付け、必要なページへ自動追従Media overlay (SMIL) playback with
playMediaOverlay()/pauseMediaOverlay()/stopMediaOverlay(); the narrated passage getsmedia:active-classand the reader follows it to the right page. -
リフローレンダラー
EPUBReaderView(AppKit / WKWebView): 標準 CSS multicol によるページ分割。縦組みは「縦積みカラム + 無アニメーションジャンプ」 方式(Bibi / Readium CSS と同じモデル。行が途中で割れない)。ウインドウ幅で単ページ⇔ 見開きを自動切替(columnModeで固定も可)、縦書きの見開きは半幅ページボックスで右綴じの 正順、中央にノドと下部中央のノンブル(showsPageFurniture)、画像単独ページは中央フィット。 ライト/ダークテーマ(EPUBReaderTheme、color-scheme注入、invertsGlyphImagesInDarkによる外字画像の反転)。電書連(DPFJ)EPUB 3 制作ガイド ver.1.1.4 の抽象フォント名 (serif-ja等)をヒラギノへ結ぶ@font-faceポリフィル。WKURLSchemeHandlerによるコンテナ内配信(MIME / CSP / Range)。外部通信は 全応答の CSP・washi-epub以外の遷移拒否・初回ナビゲーション前のWKContentRuleListで抑止する。コンパイル失敗は error ログへ記録する。 システムメニューやホストの動作はこれらの層の対象外で、ホストにも境界の設計が必要。 画面上の媒体再生にも利用者の操作を要求するため、悪意ある EPUB の<audio autoplay>/<video autoplay>は本を開いただけでは再生されず、<audio controls>を利用者が 押す再生は引き続き利用できる。朗読(media overlay)は AVAudioPlayer を使うため変わらない。 信頼できる本ではEPUBReaderSettings.allowsMediaAutoplay = trueを設定して、<video autoplay muted loop>などの自動再生をホストが opt-in できる。Reflowable renderer
EPUBReaderView(AppKit / WKWebView): pagination with standard CSS multicol; vertical writing uses stacked columns and non-animated jumps (the Bibi / Readium CSS model, no split lines). Single page or two-page spread switches with window width (columnModefixes it); vertical spreads use half-width page boxes in right-bound order with a center gutter and a folio at the bottom (showsPageFurniture); single-image pages stay centered. Light and dark themes (EPUBReaderTheme, injectedcolor-scheme,invertsGlyphImagesInDarkfor glyph images). An@font-facepolyfill maps the DPFJ EPUB 3 guide (ver. 1.1.4) abstract font names such asserif-jato Hiragino. Container resources are served throughWKURLSchemeHandler(MIME / CSP / Range). External communication is limited by CSP on every response, refusal of navigations outsidewashi-epub, and aWKContentRuleListinstalled before the first navigation. Compilation failures are logged as errors. System menus and host actions fall outside these layers, so hosts must design their own trust boundaries. Book JavaScript is off by default and, when enabled, WebRTC constructors are disabled. Onscreen media playback also requires user interaction, so malicious EPUBs cannot play<audio autoplay>/<video autoplay>merely by being opened; playback initiated by pressing<audio controls>remains available. Media overlay narration uses AVAudioPlayer and is unchanged. For trusted books, hosts can setEPUBReaderSettings.allowsMediaAutoplay = trueto opt into decorative playback such as<video autoplay muted loop>. -
設定・位置・履歴:
EPUBReaderSettingsでフォント倍率・行間・横組み字間・段落間隔・ 著者フォント上書き・ルビ表示・配色・余白・ユーザー CSS。EPUBLocator(spine index + 進行率)で位置を保存/復元。effectiveReadingDirectionはpage-progression-direction、primary-writing-mode、冒頭の XHTML / CSS、RTL 言語の順で決定。canGoBack/goBack()はジャンプ元を最大 50 件保持し、履歴の変化を delegate へ通知Settings, positions, history:
EPUBReaderSettingscovers font scale, line height, horizontal letter spacing, paragraph spacing, font overrides, ruby visibility, colors, insets, and user CSS.EPUBLocator(spine index + progression) saves and restores positions.effectiveReadingDirectionis derived frompage-progression-direction,primary-writing-mode, initial XHTML / CSS, then RTL language.canGoBack/goBack()keep up to 50 jump origins and notify the delegate when history availability changes. -
リンク・脚注・選択・page-list:
EPUBInternalLinkとshouldFollowInternalLinkで遷移前に 判定し、脚注はnoteContent(for:)で抽出、hidesFootnoteAsidesでページ割りから除外、follow(_:)で delegate を通さず遷移。選択 API(currentSelection/clearSelection()/rects(forTextRange:inSpineIndex:))は正規化 UTF-16 範囲と reader-view 座標を結ぶ。 EPUB page-list(printPageLabels/go(toPrintPage:)/currentPrintPage)は本文の pagebreak marker とノンブルにも連動Links, footnotes, selection, page-list: inspect links before navigation with
EPUBInternalLinkandshouldFollowInternalLink; extract notes withnoteContent(for:), exclude asides withhidesFootnoteAsides, and navigate without the delegate viafollow(_:). Selection APIs (currentSelection/clearSelection()/rects(forTextRange:inSpineIndex:)) map normalized UTF-16 ranges to view coordinates. EPUB page-list support (printPageLabels/go(toPrintPage:)/currentPrintPage) integrates with pagebreak markers and the folio. -
アクセシビリティと census: VoiceOver への確定ページ通知と accessibility label/value、 システムのコントラスト増加・色以外での区別へ追従。全文ページ数の census は、欠落や決定的に 読めない spine 項目を 1 ページとして計測を続け、部分的な結果も利用可能。自動実測の 対象は spine 8,192 項目までで、それを超える本は実測せず未完として扱う
Accessibility and census: announces settled pages to VoiceOver, provides labels and values, and follows Increase Contrast and Differentiate Without Color. The whole-book census counts a missing or deterministically unloadable spine item as one page and keeps measuring, so partial results stay usable. Automatic measurement covers books of up to 8,192 spine items; larger books are not measured and remain incomplete.
-
ピンチでフォント倍率(0.5〜3.0 倍): ジェスチャ中は
WKWebView.magnificationで追従し、 指を離すと進行率を保って再ページ割り。adjustFontScale(by:)で段階調整、変更は delegate へ通知Pinch to adjust font scale (0.5–3.0×):
WKWebView.magnificationfollows the gesture; on release the content repaginates preserving progression.adjustFontScale(by:)steps the scale; changes are reported to the delegate. -
ホスト統合: キー/クリック/ファイルドロップの delegate 転送、
EPUBContextMenuPolicyと 表示直前 delegate によるコンテキストメニュー制御、既定では左右端タップでページ送り。forwardsKeyEventsNativelyでネイティブNSEventを横取り転送でき、WKWebView にキーを 食われない(ホスト独自バインドの推奨経路)Host integration: forwards key, click, and file-drop events to delegates; controls context menus with
EPUBContextMenuPolicyand a pre-presentation delegate; tapping the left or right edge turns pages by default.forwardsKeyEventsNativelyintercepts nativeNSEventkeys so WKWebView cannot consume them (the recommended path for host bindings). -
固定レイアウト: viewport 解析、
page-spread-left/right/center、「画像 1 枚だけのページ」の 検出(WebKit を介さず画像を直接取り出せる。日本の漫画 EPUB の大多数がこの形)、複雑ページの オフスクリーンラスタライズ(EPUBPageRasterizer)。device-width/device-heightの viewport はライブ表示に追従し、ラスタライズ時はdeviceViewportSizeで寸法を渡す (FixedLayoutPageInfo.viewportIsDeviceSizedで判別)。文書全体と itemref ごとのrendition:spread-*を文書順に解決し、表示と census の見開き計画へ反映Fixed-layout: viewport parsing,
page-spread-left/right/center, single-image page detection (extract the image without WebKit; most Japanese manga EPUBs use this form), and offscreen rasterization of complex pages (EPUBPageRasterizer). Adevice-width/device-heightviewport follows the live display area; passdeviceViewportSizewhen rasterizing (FixedLayoutPageInfo.viewportIsDeviceSizedidentifies such pages). Per-itemrefrendition:spread-*is resolved in document order and applied to display and to the census spread plan.
通常利用するプロダクトは 2 つ。WashiCore は解析層のみで、AppKit / WebKit を引かないので
GUI セッションのないヘッドレス利用(CLI・索引・サーバ・変換ツール)に向く。Washi は
表示層込みで WashiCore を再輸出するため、import Washi だけで両層の公開 API が見える。
WashiDynamic は両ターゲットを 1 本の動的ライブラリにまとめたいホスト(フレームワーク同梱)
向けで、通常の SwiftPM 導入では使わない。Xcode と Package.swift それぞれの手順は
導入と最初の表示 を参照。
Two products cover typical use. WashiCore is the parsing layer only; it does not
link AppKit / WebKit, so it suits headless use without a GUI session (CLI tools,
indexing, servers, converters). Washi adds the rendering layer and re-exports
WashiCore, so import Washi exposes both layers. WashiDynamic bundles both targets
into one dynamic library for hosts assembling a framework; ordinary SwiftPM integration
does not use it. See Installation for the
Xcode and Package.swift steps.
解析は main actor の外で行い、表示は EPUBReaderView に読み込む。at: に EPUBLocator を
渡せば位置を復元できる。
Parse off the main actor, then load the publication into an EPUBReaderView. Pass an
EPUBLocator to at: to restore a position.
import AppKit
import Washi
@MainActor
func open(_ url: URL, in reader: EPUBReaderView, restoring locator: EPUBLocator? = nil) async throws {
// 解析(重い処理は detached task で走る) / Parse; heavy work runs in a detached task.
let publication = try await EPUBPublication.open(url: url)
// 常に .ltr または .rtl と、その出典 / Always .ltr or .rtl, plus its source.
print(publication.metadata.mainTitle ?? "",
publication.effectiveReadingDirection, publication.effectiveReadingDirectionSource)
for item in publication.navigation.toc { print(item.title) }
// 表示(AppKit) / Display (AppKit).
reader.load(publication: publication, at: locator)
// 読書順で次ページ。turnPageLeft() / turnPageRight() は物理方向
// Next page in reading order; turnPageLeft() / turnPageRight() are physical directions.
reader.goForward()
}そのほかの API はガイドを参照する。コード例はすべて CI で型検査される。
See the guides for the remaining APIs. Every code example is typechecked in CI.
- Washi 入門 / Getting started: AppKit のコントローラー、位置と census の保存・復元 / AppKit controller, saving positions and census
- 脚注 / Footnotes: 内部リンクの捕捉と
noteContent(for:)/ Intercepting links and note extraction - ページ割り / Pagination: メトリクス、
exportCensus()/importCensus(_:)、オフスクリーン API の優先度と解放 / Metrics, census records, offscreen rules - 読み込みと終了 / Loading and lifetime: タスクの所有、
unload()、キーボード転送、実行環境 / Task ownership, unload, key routing, environment - 検索・表紙・サムネイル / Search, covers, thumbnails:
search、coverImage(maxPixelSize:)、EPUBScreenAtlas/ Search, covers, atlas - スクロール表示 / Scrolling、SwiftUI、ファイルアクセス / File access
- WashiCore: ヘッドレスの解析・検索の例 / Headless parsing and search
| 領域 / Area | 状態 / Status(✅ = 対応済み / supported) |
|---|---|
| OCF(ZIP / zip64 / mimetype / container.xml / encryption.xml) | ✅ |
| パッケージ文書(metadata refines / spine / rendition / fallback) | ✅ |
| ナビゲーション(nav の toc / landmarks、NCX フォールバック) | ✅ |
| EPUB page-list(一覧・移動・現在位置・本文 marker) | ✅ |
パッケージ metadata の dir / xml:lang |
✅(package / metadata から title・creator・contributor へ継承) |
実効読書方向(page-progression-direction / primary-writing-mode / CSS / 言語) |
✅ |
内部リンクと noteref(遷移前 delegate・脚注抽出) |
✅ |
| フォント難読化(IDPF / Adobe) | ✅ |
| リフロー描画(縦組み・ルビ・縦中横・圏点・右綴じ) | ✅ |
| 固定レイアウト(viewport / spread 指定 / SVG ラッパー) | ✅ |
| 本文テキスト抽出・全文検索(ルビ除去・大小/全半角無視) | ✅(解析層のみ) |
| メタデータ(著者/シリーズ/アクセシビリティの型付きサーフェス) | ✅ |
| scripted コンテンツ | 任意(既定オフ。CSP / 外部通信ルール / WebRTC 無効化込みで有効化可) |
| メディアオーバーレイ(SMIL) | パース+項目取得(mediaOverlay)。1.8.0 から再生・active-class ハイライト・自動ページ追従 |
| DRM(ADEPT / LCP / FairPlay) | 非対応(検出して報告) |
| リフロー見開き(横組み / 縦組み) | ✅ |
| FXL 見開き合成 | 未実装(ホスト側で合成可)/ Not implemented; compose in the host |
-
text-spacing-trimとhanging-punctuation: force-endは WebKit に未実装のため反映されない。text-spacing-trimandhanging-punctuation: force-endhave no effect because WebKit does not implement them. -
EPUB 3.4 で outdated とされた機能のうち、
rendition:spread/rendition:flow/rendition:orientationは legacy hint として保持し、フォント難読化・NCX・OPF 2 のmetaは互換性のため引き続き対応する。collection要素には未対応。Among the features marked outdated in EPUB 3.4,
rendition:spread,rendition:flow, andrendition:orientationare retained as legacy hints. Font obfuscation, NCX, and OPF 2metaremain supported. Thecollectionelement is not supported. -
scrolled-docは章単位、scrolled-continuousは連続する章をつないで表示する。rollと旧pre-paginated+scrolled-continuousは幅を合わせて隙間なく並べる。スクロール中のページ番号は 画面サイズに基づく区切りで、印刷ページ番号とは異なる。詳細は スクロール表示 を参照。 連続表示の区間が 4,096 spine 項目を超えると、連続スクロール文書の構成は 章単位スクロールへ縮退するが、renderingFlow(at:)は.scrolledContinuousを返し続ける。Tests/Corpusの 251 冊のうち、rendition:layout=rollまたはrendition:flow=scrolled-continuousを宣言するのは 7 冊で、最大 spine は 9 項目のため、 この制限でコーパス内の実在する本の表示は変わらない。scrolled-docscrolls each chapter;scrolled-continuousjoins consecutive chapters. Roll and legacy fixed continuous content fit the viewport width without gaps. Screen numbers in these modes describe viewport-sized steps, not printed pages. When a continuous group exceeds 4,096 spine items, continuous-scroll document construction falls back to chapter-by-chapter scrolling;renderingFlow(at:)still returns.scrolledContinuous. Of the 251 books inTests/Corpus, only seven declarerendition:layout=rollorrendition:flow=scrolled-continuous, and their largest spine has nine items, so this limit leaves those real-world books' presentation unchanged. -
text/html宣言の非準拠 spine は、ヘッドレスの本文抽出・検索では可能な範囲で読むが、表示には XHTML 等の対応形式への fallback が必要。表示できない項目の正確な検索位置・選択矩形・ テキストアンカーは返さない。Nonconforming text/html spine items remain available for best-effort headless extraction/search, but rendering requires a supported fallback such as XHTML. Unrenderable items do not return exact text positions, range rectangles, or text anchors.
-
defersTapsForDoubleClick = trueは、ダブルクリックの単語選択より先にページ送りが起きるのを 防ぐ代わりに、primary click の通知をシステムのダブルクリック間隔だけ遅らせる(既定はfalse)。invertsGlyphImagesInDarkの外字判定はクラス名と表示寸法に基づくため、小さな挿絵を誤判定する ことがある(原色が必要な本ではfalse)。WebRTC の無効化はallowsScriptedContent = trueの EPUB コンテンツだけが対象で、ホストアプリや別の WebView への一般的な制御ではない。defersTapsForDoubleClick = trueprevents a page turn before double-click word selection but delays primary-click notifications by the system double-click interval (defaultfalse).invertsGlyphImagesInDarkidentifies glyph images by class names and rendered dimensions and may misclassify small illustrations (set it tofalsefor books that need original colors). WebRTC is disabled only in EPUB content withallowsScriptedContent = true, not for the host app or other WebViews.
-
公開 EPUB コーパス(IDPF サンプルと W3C テスト、251 冊)に対するヘッドレスのスモークテスト。 出典・ライセンス・照合規則は Tests/Corpus/README.md(英語)を参照。
WASHI_CORPUS_DIRが未設定かディレクトリが無ければスキップされる。Headless smoke tests over the public EPUB corpus (IDPF samples and W3C tests, 251 books). Provenance, licensing, and verification rules are in Tests/Corpus/README.md. The tests are skipped when
WASHI_CORPUS_DIRis unset or missing.python3 Scripts/fetch-epub-corpus.py WASHI_CORPUS_DIR="$PWD/.build/epub-corpus" swift test --filter CorpusSmokeTests
-
Scripts/の Python スクリプトはどのカレントディレクトリからでも動き、python3 -m unittest discover -s Tests/Scripts -p 'test_*.py'で検証する。HTMLEntities.swiftはScripts/generate-html-entities.pyで生成し、--checkで最新か確かめる。The Python scripts work from any current directory; verify them with the
unittestcommand above.HTMLEntities.swiftis generated byScripts/generate-html-entities.py;--checkverifies the table is current. -
日本語 EPUB の合成フィクスチャは cooViewer の
Scripts/make-jp-epub-fixtures.py <outdir> [--big]で生成できる(Washi には含まれない)。 / Synthetic Japanese EPUB fixtures come from cooViewer'sScripts/make-jp-epub-fixtures.py(not included in Washi). -
2026 年 9 月の堅牢化監査の記録は Documentation/EPUB-Audit-2026-09.md にある(修正は 1.18.0 で公開済み)。 The September 2026 hardening audit is recorded in Documentation/EPUB-Audit-2026-09.md; its repairs shipped in 1.18.0.
-
2026 年 10 月の監査の記録は Documentation/EPUB-Audit-2026-10.md にある(残った課題は beads で追う)。 The October 2026 audit is recorded in Documentation/EPUB-Audit-2026-10.md; its open items are tracked in beads.
公開 DocC / Online DocC から Washi と WashiCore の両方を 参照できる。main 更新時にガイドのコード例とサンプルを検証して公開する。
Browse both modules in the online DocC documentation. Guides and samples are checked before documentation is published from main.
公開 API の doc コメントと DocC カタログ記事は、日本語を正(ベース)として英語を併記する。 内部コメントは日本語で書く。
Public API doc comments and DocC catalog articles use Japanese as the authoritative base, with English alongside it. Internal comments are written in Japanese.
Swift Package Index 用の設定(.spi.yml)は Washi / WashiCore の両ターゲットを生成対象にする。
/ .spi.yml enables Swift Package Index documentation for both targets.
ローカルでは xcodebuild docbuild -scheme Washi -destination 'platform=macOS' で DocC を
ビルドできる。ガイドと README の全 Swift コード例の型検査と静的サイトの生成は次のコマンドで
行う(出力先には空のディレクトリを指定)。サンプルの検証は swift test --package-path Samples。
Build DocC locally with xcodebuild docbuild -scheme Washi -destination 'platform=macOS'.
The command below typechecks every Swift example in the guides and README and generates
the static site (use an empty output directory). Verify the samples with
swift test --package-path Samples.
python3 Scripts/build-documentation.py --output-dir .build/docs-site --derived-data .build/docs-derivedこのリポジトリが Washi の正リポジトリであり、開発もここで行う。Issue / PR はこのリポジトリで
受け付ける。開発課題は beads で管理する(初回は bd bootstrap --yes、作業の確認は bd ready。
cooViewer から移した課題は旧 ID を維持。詳細は .beads/README.md)。
AI エージェント向けの作業規則は AGENTS.md にある。
This is Washi's canonical repository, where development takes place and issues and pull
requests are accepted. Tasks are tracked in Beads (bd bootstrap --yes on a new checkout,
bd ready to find work; issues migrated from cooViewer keep their original IDs; see
.beads/README.md). Working rules for AI agents are in AGENTS.md.
PR は Test と Release artifact の macos-26 / xcode-27、
Documentation and guide examples、Public EPUB corpus を検査する。
main の push・毎週木曜 04:43 UTC・手動実行・タグでは、Test の
macos-26-intel / macos-15 / macos-15-intel / macos-15-swift-6.0(Xcode 16.2 で
Swift 6.0 の下限を検査。macos-14 イメージは 2026-11 に廃止)と Release artifact の
macos-15 も検査する。古い実行の取り消しは PR だけに適用する。
Documentation/**・Sources/**/*.docc/**・Markdown・.beads/**・LICENSE* のみの差分では
ビルド・テストを省き、matrix の check 名は Ubuntu で成功を報告する。.github/** と
appcast.xml は省略対象にしない。文書とコード例の検査は常に行い、main で Pages を公開する。
PR の全対象が成功した merge checkout の HEAD^{tree} を 7 日間記録し、main の push は
同じ tree の場合だけ PR 対象の Test・Release artifact・corpus を省く。この場合も旧 OS を検査し、
照会失敗・定期・手動・タグは全検査する。
PRs check Test and Release artifact on macos-26 / xcode-27, documentation and guide examples,
and the public EPUB corpus. Main pushes, weekly Thursday runs at 04:43 UTC, manual runs, and tags
also cover the older OS / Intel test matrix (including macos-15-swift-6.0, which checks
the Swift 6.0 lower bound with Xcode 16.2 after GitHub retired the macos-14 image in
2026-11) and the macos-15 release artifact. Only PR runs cancel
older runs. Documentation-only diffs skip builds and tests while preserving matrix check names
on Ubuntu; documentation validation and main's Pages publication still run. Changes under
.github/ or to appcast.xml require full CI. A successful PR records its merge checkout's
HEAD^{tree} for seven days: an identical main tree skips only the PR-covered tests, release
builds, and corpus. Older OS checks still run; lookup failures, scheduled runs, manual runs, and
tags run the full matrix.
ソースは macOS 14+ / Swift 6(strict concurrency)で Apple Silicon・Intel の両方に対応する。
cooViewer はこのパッケージの利用者のひとつで、
WashiDynamic から Washi.framework を手組みして同梱する(arm64 のみ)。その前提は
Package.swift の WashiDynamic のコメントに記す。
The source supports macOS 14+, Swift 6 with strict concurrency, and both Apple Silicon and
Intel. cooViewer is one consumer; it assembles
Washi.framework from WashiDynamic and bundles it (arm64 only). The assumptions it relies
on are documented in the WashiDynamic comment in Package.swift.
公開予定の版を CHANGELOG に ## [X.Y.Z] - YYYY-MM-DD と空でない本文で記録し、
EPUBReadingSystem.version と導入ガイド(Installation.md)の from: の例も同じ版に
更新する。変更をコミットしてから次を実行する。
作業ツリー(未追跡ファイルを含む)がクリーンで、公開先の最新確定版タグより新しい版で
あることも検証する。
Record the planned version in CHANGELOG as ## [X.Y.Z] - YYYY-MM-DD with nonempty
release notes, and set EPUBReadingSystem.version and the from: example in the
installation guide (Installation.md) to that version. Commit the changes
and run the command below. It also requires a clean working tree, including untracked
files, and a version newer than the latest stable tag on the public remote.
Scripts/release.sh X.Y.Z
# 公開先を切り替える場合 / Use another remote
Scripts/release.sh X.Y.Z --remote originこのスクリプトは検証のみを行う(Python 3.9 以降と Git が必要)。対象コミットの CI が成功したことを
確認してから、タグの作成・push を別途行う。タグは CI 完了前にも SwiftPM から利用できるため、
タグ作成前の確認が必要になる。タグを push すると、テスト・配布構成ビルド・公開 EPUB コーパス検証が
すべて成功した後、CI(Scripts/publish-github-release.py)がそのタグの CHANGELOG から
GitHub Release を自動作成する。確定版タグ(X.Y.Z または vX.Y.Z)と日付付きの変更履歴が必要。
The script performs validation only (Python 3.9+ and Git required). Create and push the
tag separately, after the target commit's CI has passed; SwiftPM can resolve the tag before
CI finishes, so the pre-tag check matters. After the push, CI
(Scripts/publish-github-release.py) creates the GitHub Release from the tagged CHANGELOG
once all tests, release artifact builds, and public corpus checks pass. This requires a
stable tag (X.Y.Z or vX.Y.Z) and a dated changelog entry.
公開処理だけが失敗した場合は、そのタグの CI で失敗したジョブを再実行する。公開済みの Release は
上書きせず、同じタグの下書きがあると自動公開は止まる(確認して手動公開するか、整理して再実行)。
旧タグを手動で補う場合は、ノートを確認した上で
gh release create X.Y.Z --verify-tag --notes-file notes.md --latest=false を使う。自動公開は
公開先の最新確定版タグだけを Latest にし、旧版の再実行による巻き戻りを防ぐ。
If only publication fails, rerun the failed jobs in that tag's CI run. Published Releases
are preserved, and an existing draft stops automatic publication (review and publish it
manually, or resolve it and retry). For historical tags, review the notes and use
gh release create X.Y.Z --verify-tag --notes-file notes.md --latest=false. Only the
newest stable remote tag becomes Latest, so retries for older versions cannot move it back.
MIT License(LICENSE を参照)。依存パッケージはない。設計にあたり Readium CSS・Bibi (いずれも実装は独立)の公開知見を参考にした。
MIT License (see LICENSE). There are no package dependencies. The design draws on publicly shared findings from Readium CSS and Bibi; Washi's implementation is independent of both.