@gullabs/flipbook-core

中文文档
3.2.2发布于 2026/10/01MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 1万

Framework-agnostic page-curl engine. Maintained fork of StPageFlip.

原始使用文档
文档目录3 节
  1. Essentials
  2. Error codes
  3. License

@gullabs/flipbook-core

Framework-agnostic HTML page-curl engine. Maintained fork of StPageFlip. Zero runtime dependencies. License: MPL-2.0.

Full monorepo docs (install recipes, styling, events, accessibility, SSR/CSP):

npm i @gullabs/flipbook-core
import { PageFlip } from '@gullabs/flipbook-core';
// Optional under a strict CSP — default is runtime style injection:
// import '@gullabs/flipbook-core/style.css';

const pageFlip = new PageFlip(root, { width: 400, height: 600 });
pageFlip.loadFromHTML(pages);
// HTML only — loadFromImages / canvas mode were removed in 3.0.0.
// Pictures: put <img alt="…"> inside the HTML page elements.

Essentials

TopicRule
Paper colorpageBackground (default #fff) → --stf-paper. Opacity is structural.
Leaf stylingStyle an inner wrapper; the engine owns layout + paper on the leaf root.
StylesheetDefault injects CSS. CSP: injectStyles: false + ship style.css / FLIPBOOK_CSS.
NavigationflipToPage / flipNext / flipPrev animate; turnTo* are instant. Relative turns return boolean and may emit turnRejected.
ProgressturnProgress while a fold moves. Silent on flippingTime: 0, reduced motion, and hover peel. No terminal 1.0. Settle with flip / changeState.
React-onlylazyRadius, controls, liveRegion, useKeyboard, controlled page / pageTransition are not FlipOptions. Unknown keys are ignored. Window the DOM yourself.
CancelcancelTurn() aborts an in-flight turn without committing. read fires after the portrait clone is removed, on a completed turn and on cancel.
MediaA portrait clone replaces each <video> with a canvas of the current frame and strips <audio>. No second request, decoder, or audio. A cloned <canvas> is unsupported. Landscape folds the live element.
ControlsWith respectInteractiveContent (default on), a pointer that starts on video[controls], audio[controls], iframe, embed, or object does not start a fold. A <video> without controls still swipes.
PlaybackCore does not play, pause, or load media the host created. Play from getVisiblePages().
QueriesgetVisiblePages(), canTurn(dir), getPageCount(), getCurrentPageIndex(), isReady(), isAnimating().

Error codes

Public failures throw PageFlipError with a stable code and kind (usage | lifecycle | internal). Setting failures also set err.setting.

CodeKindWhen
INVALID_SETTINGusageA setting failed validation (err.setting names which)
INVALID_PAGEusagePage index out of range
PAGE_NOT_IN_SPREADusagePage exists but is in no spread
INVALID_INDEXusageInternal array access out of range
WRONG_MODEusageReserved after canvas removal; not thrown by HTML today
DESTROYEDlifecycleCalled after destroy()
NOT_LOADEDlifecycleAPI used before load finished
DETACHED_PAGElifecycleA page element left the document mid-turn
NO_ANIMATION_FRAMElifecycleAnimation frame list was empty
COLLINEAR_SEGMENTSinternalGeometry: segments are collinear
DEGENERATE_SEGMENTinternalGeometry: a segment has zero length
FLIP_SETUPinternalCould not prepare flipping/bottom pages
INVALID_SPREADinternalSpread index invalid during a turn
RENDER_SETUPinternalShadow/DOM render setup failed
PAGE_FLIPinternalGeneric / unspecified

flipNext / flipPrev return boolean (false = did not start) and emit turnRejected when refused — that is not an exception path.

License

MPL-2.0 — file-level copyleft. Your application is not Covered Software when you only import and call the public API. Distribution of the engine (including bundled browser JS) requires source availability + notice; for the unmodified npm package, point at https://github.com/gul-labs/flipbook.

Copyright (c) 2026 Gul Labs, with upstream Nodlik MIT notices in LICENSE.

版本与发布记录

@gullabs/flipbook-core 共发布 5 个版本,首次发布于 2026/08/31;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.2.2latest2026/10/011 个月前
3.2.12026/09/092 个月前
3.2.02026/09/092 个月前
3.1.02026/09/012 个月前
3.0.02026/08/312 个月前

关于 @gullabs/flipbook-core 的常见问题

@gullabs/flipbook-core 是什么?

Framework-agnostic page-curl engine. Maintained fork of StPageFlip.

如何安装 @gullabs/flipbook-core?

在项目目录运行 npm install @gullabs/flipbook-core,或使用 pnpm add / yarn add / bun add。

@gullabs/flipbook-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gullabs/flipbook-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gullabs/flipbook-core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.18.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@gullabs/flipbook-core 可以商用吗?

@gullabs/flipbook-core 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@gullabs/flipbook-core 的下载量有多少?

根据 npm 官方下载统计,@gullabs/flipbook-core 在 2026/10/17 – 2026/11/15 这 30 天内被下载 10,010 次,日均约 334 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gullabs/flipbook-core 还在维护吗?

最新版本 3.2.2 发布于 2026/10/01(1 个月前);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/08/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。