fix: update build dependencies and improve documentation
Build and WordPress integration / PHP 7.4 syntax and regression tests (push) Canceled after 0s
Build and WordPress integration / PHP 8.3 syntax and regression tests (push) Canceled after 0s
Build and WordPress integration / WordPress 6.3 / PHP 7.4 (push) Canceled after 0s
Build and WordPress integration / WordPress latest / PHP 8.2 (push) Canceled after 0s

- Fix gettext-parser 9 compatibility and update Babel parser
- Apply targeted dependency security fixes and align Node.js requirements
- Add regression tests and document remaining dependency risks
- Review bundled player dependencies and advisory reachability
- Reformat English and Chinese READMEs and simplify wording
- Remove plugin version descriptions from README files

PR #39
This commit is contained in:
2026-10-14 17:43:24 +08:00
committed by GitHub
parent 85e5ffa0ec
commit 16d8400d76
13 changed files with 613 additions and 255 deletions
+111 -94
View File
@@ -1,119 +1,136 @@
# wp-asciiplayer
An Asciicast Player block for WordPress, with real playback in the editor and
backwards-compatible `[asciiplayer]` shortcodes. [中文说明](README-zh.md)
Play terminal recordings in WordPress posts and pages. Add an **Asciicast Player**
block to preview the recording while you edit, or keep using the `[asciiplayer]`
shortcode in existing posts.
## Development preview: 1.1.0-dev
This PR is an unreleased development preview. Earlier draft ZIP labels 1.1.0 and
1.2.0–1.2.3 were iteration labels, not published releases. Review packages use
`wp-asciiplayer-1.1.0-dev-<commit>.zip`; no release tag or deployment is implied.
## Languages
Plugin-owned UI includes English and Simplified Chinese (`zh_CN`). The editor
follows **Users → Profile → Language** (or the site default); public pages follow
**Settings → General → Site Language**. Catalogs ship inside the ZIP and need no
translation server at runtime. English is the source/fallback language, so a
separate `en_US` catalog is unnecessary. `zh_TW` and other locales are not silently
mapped to Simplified Chinese. Recorded terminal output and author captions stay
unchanged. The bundled upstream player's own playback controls and help remain
English; its vendor files are not modified.
[中文说明](README-zh.md)
## Install
Install the built `wp-asciiplayer.zip` through **Plugins → Add New → Upload
Plugin**, then activate **Asciicast Player**. A GitHub source ZIP must be built
first; it does not contain generated assets. See [SOURCE.md](SOURCE.md).
Requires **WordPress 6.3+** and **PHP 7.4+**.
Requires WordPress 6.3+ and PHP 7.4+. Compatibility must be checked against your
site and theme; CI tests the versions listed in `.github/workflows/ci.yml`.
1. Upload the built `wp-asciiplayer.zip` through **Plugins → Add New → Upload Plugin**.
2. Activate **Asciicast Player**.
## Block editor
A GitHub source ZIP needs to be built before you can install it. See the
[build instructions](SOURCE.md). The [CI workflow](.github/workflows/ci.yml)
lists the combinations we test; check the plugin with your own theme too.
1. Insert **Asciicast Player**.
2. Paste an HTTP(S) recording-file URL (for example a `.cast` file), or use **Choose recording** to select/upload a `.cast` file in the WordPress Media Library. The preview loads after a short pause; **Apply URL** loads it immediately.
3. Play, pause and seek in the editor. **Display** offers width presets or a custom
CSS length (for example `480px` or `65%`), plus left/center/right alignment.
The width stays within the available space. Add a caption below the player.
4. Use **Terminal size** in the floating block toolbar for quick Columns/Rows
edits, or expand the **Terminal size** sidebar panel. Both edit the same values.
Empty fields show the recording’s original columns/rows as placeholders after
loading. Changing the URL refreshes these hints without clearing your explicit
overrides; reset clears overrides, so recorded resize events remain active.
Terminal size is separate from display width: leave Columns and Rows blank to use the cast
file's dimensions and recorded resize events. Override either axis only when
intentional; use **Use recording size** to clear both. Display width and
`fit: width` scale the existing grid without changing terminal columns.
5. Change theme, speed, looping, controls, fit, start time and idle-time limit
from the remaining block settings.
6. Save the post or page; the same locally bundled player is used on the front end.
## Add a recording
Existing saved blocks load their valid recording URL automatically on reopening
the editor. Typed URL changes are debounced for 500ms; empty or invalid URLs do
not start a recording request.
Preview does not autoplay even when front-end autoplay is enabled.
Recording/privacy and playback explanations are available in the collapsed
**Help** sidebar panel, keeping the block canvas focused on editing.
The inserter preview is a local static example and never loads a recording.
1. Insert an **Asciicast Player** block.
2. Paste a recording-file URL, or click **Choose recording** to select or upload a
`.cast` file from the Media Library.
3. The preview loads about half a second after you stop typing. Click **Apply URL**
to load it immediately, then play, pause or seek through the recording.
4. Use **Display** to set the width and alignment. You can choose a preset or enter
a CSS length such as `480px` or `65%`. Add a caption below the player.
5. Adjust the theme, speed, looping, controls, fit, start time and idle-time limit
in the block settings, then save your post or page.
Terminal typography is scoped against common theme `pre`/`span` styles so
character scaling stays aligned with the player grid. A theme with additional
custom rules may still require compatibility testing; keyboard focus indicators
remain visible.
Saved recordings load again when you reopen the editor. Previews do not autoplay,
even if you enable autoplay for the published page. Empty or invalid URLs do not
start a request. The block inserter uses a static example, so it does not fetch a
recording either.
The source must be a recording-file URL, not an asciinema share-page URL.
A recording on another origin must allow CORS requests from your WordPress site.
HTTP recordings on an HTTPS site may be blocked as mixed content. Use a same-site
HTTPS URL when possible. The plugin does not proxy or copy remote files, grant
new upload capabilities, or add a recording-management post type.
### Display width and terminal size
The display width controls how much space the player takes on the page. It stays
within the available width. Changing it, or using `fit: width`, scales the picture
without changing the terminal's columns and rows.
Leave **Columns** and **Rows** empty to use the recording's dimensions and resize
events. To override them, use **Terminal size** in the block toolbar or sidebar;
both controls update the same settings. **Use recording size** clears the overrides.
After loading, the empty fields show the recording's original dimensions as hints.
Changing the URL updates those hints but keeps any values you entered. The hints
come from the first 64 KiB of the preview response; if they cannot be read, the
fields keep a generic placeholder. Later resize events do not change the hints.
The player includes styles to keep terminal text aligned and keyboard focus
visible. Some themes may still need CSS adjustments. Playback tips and recording
privacy information are in the sidebar's **Help** panel.
### Recording URLs
Use an HTTP(S) URL that points to the recording file, not an asciinema share page.
A file hosted on another domain must allow CORS requests from your site. Browsers
may block HTTP recordings on HTTPS pages; a same-site HTTPS URL is the simplest
option. The plugin does not proxy or copy remote files.
## Existing shortcodes
Old articles remain supported; no content migration is required:
Existing posts keep working without a content migration:
[asciiplayer]https://example.org/demo.cast[/asciiplayer]
[asciiplayer theme="monokai" speed="1.5" controls="false"]https://example.org/demo.cast[/asciiplayer]
[asciiplayer startAt="2" idleTimeLimit="3" style="width: 80%;"]https://example.org/demo.cast[/asciiplayer]
```text
[asciiplayer]https://example.org/demo.cast[/asciiplayer]
[asciiplayer theme="monokai" speed="1.5" controls="false"]https://example.org/demo.cast[/asciiplayer]
[asciiplayer startAt="2" idleTimeLimit="3" style="width: 80%;"]https://example.org/demo.cast[/asciiplayer]
```
Boolean and numeric options are typed, and historical camelCase options are
normalized after WordPress lowercases shortcode attribute names. Inline styles
are filtered through WordPress safe-CSS handling; unsafe protocols and markup
are rejected/escaped. Unsupported executable/object options are not accepted.
The Classic Editor continues to support shortcodes; it has no custom visual UI.
The block supports a shortcode-to-block transform for supported options. Review
converted settings before saving; articles are never rewritten automatically.
Boolean, numeric and older camelCase options are handled automatically. Inline
styles go through WordPress's safe-CSS filter; unsafe URLs, markup and executable
or object-valued options are not accepted.
## Local resources and privacy
You can convert supported shortcodes into blocks. Check the settings before
saving; the plugin never rewrites old posts automatically. The Classic Editor
supports shortcodes, but has no custom player-editing interface.
All player JavaScript, CSS, and WebAssembly are included in the plugin. The old
`ap_use_local_resources` switch is no longer used, and jsDelivr is not contacted.
No analytics or background remote API calls are added.
## Media Library uploads
A recording URL you choose is fetched directly by the visitor's browser. Its host
can receive the visitor's IP address, browser request metadata and possibly a
referrer, according to browser/site policy. Editor previews have the same effect
automatically when a valid URL is present, including when reopening saved blocks. Choose a trusted host and review
recordings for sensitive terminal output before publishing them. The host's own
privacy policy applies; the plugin cannot make an external recording private.
You can upload `.cast` files if your account already has WordPress's `upload_files`
permission. Multisite networks must also allow the `cast` extension. The plugin
does not grant extra upload permissions or add a separate recording-management
post type.
## Development
Uploads are checked against these limits:
See [SOURCE.md](SOURCE.md) for locked build and ZIP packaging commands. Source
code is GPL-3.0-only. The player and its dependencies retain their own compatible
licenses; see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
- **32 MiB** per file.
- **100,000** events or stream lines.
- **256 KiB** per JSONL line.
- **1,000** columns or rows in either direction.
### Media Library upload limits
The older asciicast v1 format is limited to **2 MiB**. Its JSON must be
pretty-printed, with the opening `{` on a line of its own; the bundled player
cannot read compact, single-line v1 files. Asciicast v2 and v3 use standard JSONL.
Lower site or server upload limits still apply. Invalid recordings are rejected;
this does not enable general JSON, HTML or SVG uploads.
The plugin adds only `.cast` uploads for users who already have WordPress
`upload_files` permission. On multisite, the network must also allow the `cast`
extension. Existing site/server upload limits still apply. Each upload is fully
validated: at most 32 MiB, 100,000 events/stream lines, 256 KiB per JSONL line, and dimensions
up to 1,000 columns/rows. Legacy v1 is limited to 2 MiB and must be pretty-printed
with its opening JSON object on a separate line because the bundled player cannot
read compact single-line v1. v2/v3 use their standard JSONL format. Invalid files
are rejected; generic JSON, HTML and SVG uploads are not enabled.
## Languages
Original-size hints inspect at most the first 64 KiB of the same preview response.
If metadata is unavailable, the fields keep a generic placeholder rather than
guessing dimensions. Recorded resize events do not replace the initial-size hint.
The plugin's interface includes English and Simplified Chinese (`zh_CN`).
- In the editor, choose **Users → Profile → Language**, or use the site default.
- On public pages, the language follows **Settings → General → Site Language**.
Translations are included in the ZIP and work offline. English is the fallback;
there is no separate `en_US` catalog. Other Chinese locales, including `zh_TW`, are
not automatically mapped to Simplified Chinese.
Recorded terminal output and your captions are unchanged. The bundled player's
own playback controls and help remain in English; its files are kept as supplied
by the upstream project.
## Resources and privacy
The player’s JavaScript, CSS and WebAssembly are bundled locally. The plugin does
not contact jsDelivr, add analytics or make background remote API calls. The old
`ap_use_local_resources` option is no longer used.
Recordings are different: visitors' browsers fetch the URL you choose directly.
An external host may receive their IP address, browser request details and a
referrer, depending on browser and site settings. Editor previews make the same
request whenever a valid URL loads, including when you reopen a saved block.
Use a trusted host and check recordings for sensitive terminal output before
publishing. The host's privacy policy applies; the plugin cannot make an external
recording private.
## Build and license
See [SOURCE.md](SOURCE.md) for build, test and ZIP packaging commands.
The plugin is GPL-3.0-only. The player and its dependencies keep their own
compatible licenses; see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).