Compare commits

..
Author SHA1 Message Date
LamGC 85474494b1 Document bounded temporary-upload stream exceptions
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
2026-10-13 18:06:18 +08:00
LamGC 04f19543d3 Fix Media Library test storage and scope sidebar selectors 2026-10-13 17:57:41 +08:00
LamGC af866bc20e Show native cast dimensions and add Media Library recordings (1.2.2) 2026-10-13 17:50:18 +08:00
LamGC 27fe6e0d19 Improve automatic previews and toolbar terminal sizing (1.2.1) 2026-10-13 17:19:54 +08:00
LamGC 26742f3699 Respect WordPress editor gutters with border-box sizing 2026-10-13 16:48:28 +08:00
LamGC 90ef836730 Keep editor caption geometry stable during block selection 2026-10-13 16:41:36 +08:00
LamGC 2041124178 Add responsive player layout, captions and native terminal sizing 2026-10-13 16:31:55 +08:00
LamGC 4f85e3f420 Use WordPress readme major-version compatibility format 2026-10-12 18:15:34 +08:00
LamGC bb8295a29a Record verified WordPress 7.1.3 compatibility 2026-10-12 18:11:03 +08:00
LamGC 6735999e63 Fix emitted frontend boot and verify bundled runtime initialization 2026-10-12 18:07:01 +08:00
LamGC f04600c37b Refresh player with native block editor preview and local assets
Preserve shortcode rendering, normalize options, bundle the player locally,
and add reproducible packaging and WordPress integration tests.
2026-10-12 17:56:08 +08:00
29 changed files with 254 additions and 2371 deletions
+20 -101
View File
@@ -23,7 +23,7 @@ jobs:
matrix:
php: ['7.4', '8.3']
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Check syntax and execute PHP regression tests
run: |
docker run --rm -v "$PWD:/app" -w /app "php:${{ matrix.php }}-cli" sh -ec '
@@ -31,37 +31,7 @@ jobs:
php tests/php/run.php
'
# Only this job publishes the installable package. No WordPress containers or
# downloaded plugins run here, and the artifact is immutable once uploaded.
build:
name: Build and publish pristine package
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
package-artifact-id: ${{ steps.package.outputs.artifact-id }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: '24.18.0'
cache: npm
- name: Use the documented npm toolchain
run: npm install --global [email protected]
- run: npm ci
- run: npm run build
- run: npm test
- run: npm run package
- name: Upload pristine installable ZIP
id: package
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: wp-asciiplayer-package-${{ github.run_id }}-${{ github.run_attempt }}
path: dist/wp-asciiplayer.zip
if-no-files-found: error
retention-days: 14
wordpress:
needs: build
name: WordPress ${{ matrix.wordpress }} / PHP ${{ matrix.php }}
runs-on: ubuntu-latest
timeout-minutes: 30
@@ -74,20 +44,15 @@ jobs:
- wordpress: '6.3'
php: '7.4'
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '24.18.0'
node-version: '24'
cache: npm
- name: Use the documented npm toolchain
run: npm install --global [email protected]
- run: npm ci
- name: Download the pristine package from this run
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
artifact-ids: ${{ needs.build.outputs.package-artifact-id }}
path: dist
merge-multiple: true
- run: npm run build
- run: npm test
- run: npm run package
- name: Configure clean WordPress version
env:
WP_TEST_VERSION: ${{ matrix.wordpress }}
@@ -108,27 +73,25 @@ jobs:
npx --no-install wp-env run cli wp plugin is-active wp-asciiplayer
npx --no-install wp-env run cli wp core version | tee wordpress-version.txt
npx --no-install wp-env run cli wp plugin list
npx --no-install wp-env run cli wp language core install zh_CN
npx --no-install wp-env run cli wp site switch-language en_US
npx --no-install wp-env run cli wp user meta update admin locale en_US
- name: Install Chromium
run: npx --no-install playwright install --with-deps chromium
- name: Exercise editor iframe, saved blocks, Pages, posts and legacy shortcodes
env:
PLAYWRIGHT_HTML_OUTPUT_DIR: playwright-report/en-US
run: npm run test:e2e -- --grep-invert @i18n --output=test-results/en-US
- name: Exercise real en_US and zh_CN site and user locale combinations
env:
PLAYWRIGHT_HTML_OUTPUT_DIR: playwright-report/i18n
run: npm run test:e2e -- --grep @i18n --output=test-results/i18n
run: npm run test:e2e
- name: Run Plugin Check (advisory until directory review)
if: always() && matrix.wordpress == 'latest'
continue-on-error: true
run: |
npx --no-install wp-env run cli wp plugin install plugin-check --activate
npx --no-install wp-env run cli wp plugin get plugin-check --field=version | tee plugin-check-version.txt
npx --no-install wp-env run cli wp plugin check wp-asciiplayer --require=/var/www/html/wp-content/plugins/plugin-check/cli.php --format=json | tee plugin-check-report.txt
- name: Record WordPress and PHP logs
if: always()
run: |
npx --no-install wp-env logs --watch=false > wordpress-logs.txt 2>&1 || true
npx --no-install wp-env run cli sh -c 'test ! -f wp-content/debug.log || cat wp-content/debug.log' > wordpress-debug.txt 2>&1 || true
- name: Upload integration evidence
- name: Upload integration evidence and installable ZIP
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: wordpress-${{ matrix.wordpress }}-php-${{ matrix.php }}
if-no-files-found: warn
@@ -136,56 +99,12 @@ jobs:
path: |
playwright-report/
test-results/
plugin-check-version.txt
plugin-check-report.txt
wordpress-version.txt
wordpress-logs.txt
wordpress-debug.txt
- name: Stop WordPress
if: always()
run: npx --no-install wp-env stop
# Plugin Check receives its own disposable copy. It cannot replace the package
# uploaded by build, and this job never republishes files from dist.
plugin-check:
name: Plugin Check (advisory)
needs: build
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: '24.18.0'
cache: npm
- name: Use the documented npm toolchain
run: npm install --global [email protected]
- run: npm ci
- name: Download the pristine package from this run
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
artifact-ids: ${{ needs.build.outputs.package-artifact-id }}
path: dist
merge-multiple: true
- name: Start WordPress and install the packaged plugin
run: |
mkdir -p .wp-env-uploads
npx --no-install wp-env start
npx --no-install wp-env run cli wp plugin install /var/www/html/wp-content/asciiplayer-packages/wp-asciiplayer.zip --activate --force
- name: Run Plugin Check (advisory until directory review)
continue-on-error: true
run: |
npx --no-install wp-env run cli wp plugin install plugin-check --activate
npx --no-install wp-env run cli wp plugin get plugin-check --field=version | tee plugin-check-version.txt
npx --no-install wp-env run cli wp plugin check wp-asciiplayer --require=/var/www/html/wp-content/plugins/plugin-check/cli.php --format=json | tee plugin-check-report.txt
- name: Upload Plugin Check evidence only
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: plugin-check-${{ github.run_id }}-${{ github.run_attempt }}
if-no-files-found: warn
retention-days: 14
path: |
plugin-check-version.txt
plugin-check-report.txt
dist/wp-asciiplayer.zip
- name: Stop WordPress
if: always()
run: npx --no-install wp-env stop
+40 -90
View File
@@ -1,112 +1,62 @@
# wp-asciiplayer
把终端录屏放进 WordPress 文章和页面。添加 **Asciicast Player** 区块,就能一边编辑一边预览录屏;
旧文章里的 `[asciiplayer]` shortcode 也可以继续使用。
为 WordPress 提供原生 Asciicast Player 区块,可在编辑器内真实播放终端录屏,
同时兼容原有 `[asciiplayer]` shortcode。
[English documentation](README.md)
## 安装与使用
## 安装
将构建得到的 `wp-asciiplayer.zip` 上传到「插件 → 安装插件 → 上传插件」并启用。
GitHub 源码 ZIP 需要先构建,不能直接当发行包安装。构建方法见 [SOURCE.md](SOURCE.md)。
要求 WordPress 6.3+、PHP 7.4+;具体测试版本见仓库 CI。
需要 **WordPress 6.3+** 和 **PHP 7.4+**。
插入「Asciicast Player」区块,粘贴录制文件的 HTTP(S) URL,停止输入约半秒后会自动加载预览;也可以点击「Apply URL」立即加载。之后即可在编辑器内播放、
暂停和拖动。「Display」面板提供展示宽度预设、自定义宽度(例如 `480px`、`65%`)以及左、中、右对齐;
展示宽度会限制在当前页面可用空间内。点击播放器下方即可添加描述文字。
1. 在 **插件 → 安装插件 → 上传插件** 中上传构建好的 `wp-asciiplayer.zip`。
2. 启用 **Asciicast Player**。
在区块上方浮动工具栏点击「Terminal size」可快速调整终端行列数;侧边栏的同名折叠面板也保留,两处设置实时同步。
终端尺寸与展示大小分别控制:Columns / Rows 留空时,使用 cast 文件记录的终端尺寸,
并跟随录制中的 resize 事件。只有需要改变终端网格时才覆盖行列数,点击「Use recording size」可恢复。
展示宽度与 `fit: width` 只缩放画面,不会修改终端行列数;覆盖网格可能影响录屏排版或裁切内容。
主题、速度、循环、控制栏、起始时间和空闲压缩等选项仍在区块设置中调整。
保存文章或页面后,前台使用同一播放器。重新打开已有区块时,只要已有有效 URL 就自动加载预览;
编辑预览不会自动播放,前台自动播放设置仍会保留。区块插入器使用本地静态示例,不请求录制文件。
播放器增加了局部样式隔离,避免常见主题的代码块边框、阴影和字体设置干扰终端;键盘焦点提示仍保留。
GitHub 下载的源码 ZIP 需要先构建,不能直接安装,步骤见[构建说明](SOURCE.md)。
[仓库 CI](.github/workflows/ci.yml) 列出了测试的环境组合;使用前也请检查与你的主题是否兼容。
URL 必须指向录制文件(例如 `.cast`),不能直接使用分享页面地址。跨域文件需要允许
来自你站点的 CORS 请求;HTTPS 页面上的 HTTP 文件可能被浏览器阻止。优先使用同源 HTTPS。
本插件不提供远程文件代理、不扩大用户的上传权限,也不创建额外的录屏管理文章类型。
## 添加录屏
## 旧文章兼容
1. 插入 **Asciicast Player** 区块。
2. 粘贴录制文件的 URL,或点击 **选择录制文件(Choose recording)**,从媒体库选择或上传 `.cast` 文件。
3. 停止输入约半秒后会自动加载预览。点击 **Apply URL** 可以立即加载,然后就能播放、暂停和拖动进度。
4. 在 **Display** 中设置宽度和对齐方式。可以选择预设,也可以填写 `480px`、`65%` 等 CSS 长度。
播放器下方可以添加说明文字。
5. 在区块设置中调整主题、速度、循环、控制栏、适应方式、起始时间和空闲压缩,然后保存文章或页面。
原有 shortcode 继续有效,无须批量修改文章:
重新打开文章时,已有有效 URL 的区块会自动加载录屏。编辑预览不会自动播放,即使你给前台启用了自动播放。
空白或无效 URL 不会发起请求。区块插入器里的示例是静态的,也不会请求录制文件。
### 展示宽度与终端尺寸
展示宽度决定播放器在页面里占多大空间,并且不会超出可用宽度。
调整宽度或使用 `fit: width` 只是缩放画面,不会改变终端的行列数。
**Columns** 和 **Rows** 留空时,会使用录屏本身的尺寸,并跟随录制中的尺寸变化。
需要手动设置时,可以使用区块工具栏或侧栏里的 **Terminal size**,两处设置会同步。
点击 **Use recording size** 可以清空手动设置,恢复录屏原有尺寸。
加载后,空白字段会显示录屏的原始行列数作为提示。换一个 URL 会刷新提示,但保留你手动填写的值。
提示只读取同一次预览响应的前 **64 KiB**;读取不到时保留通用占位提示,不猜测尺寸。
录制过程中后续的尺寸变化不会改变这组提示。
播放器自带样式,用来保持终端文字对齐和键盘焦点可见。部分主题可能仍需要调整 CSS。
播放操作和录屏隐私说明可以在侧栏的 **帮助(Help)** 面板中找到。
### 录制文件地址
URL 要直接指向录制文件,例如 `.cast` 文件,而不是 asciinema 分享页面。
其他域名上的文件需要允许来自你站点的 CORS 请求。HTTPS 页面可能无法加载 HTTP 文件,优先使用同站点的 HTTPS 地址。
插件不会代理请求或复制远程文件。
## 旧文章与 shortcode
旧文章可以继续使用原有 shortcode,不需要批量修改:
```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]
```
布尔值、数值和旧的 camelCase 参数会自动处理。自定义 `style` 会经过 WordPress 的安全 CSS 过滤;
不安全的 URL、标记,以及可执行或对象形式的选项不会被接受。
支持的 shortcode 可以转换成区块,保存前请检查设置。插件不会自动重写旧文章。
经典编辑器仍可使用 shortcode,但没有专门的播放器编辑界面。
## 媒体库上传
已有 WordPress `upload_files` 权限的用户可以上传 `.cast` 文件。
多站点还需要网络管理员允许 `cast` 扩展名。插件不会增加用户的上传权限,也不会另建录屏管理文章类型。
上传文件会完整校验,限制如下:
- 每个文件最多 **32 MiB**。
- 最多 **100,000** 个事件或流内行。
- 每条 JSONL 行最多 **256 KiB**。
- 终端任一方向不超过 **1,000** 列或行。
旧的 asciicast v1 格式最多 **2 MiB**,需要格式化 JSON,并让起始 `{` 单独占一行;
内置播放器无法读取压成一行的 v1 文件。Asciicast v2、v3 使用标准 JSONL。
站点或服务器更低的上传限制仍然生效。无效录屏会被拒绝,也不会因此开放普通 JSON、HTML 或 SVG 上传。
## 界面语言
插件界面包含英文和简体中文(`zh_CN`):
- 编辑器跟随 **用户 → 个人资料 → 语言**;未单独设置时使用站点语言。
- 前台跟随 **设置 → 常规 → 站点语言**。
翻译文件随 ZIP 附带,可离线使用。英文是默认回退语言,不需要单独的 `en_US` 翻译文件。
`zh_TW` 等其他中文地区设置不会自动映射成简体中文。
录屏中的终端内容和你填写的说明文字不会被翻译。
内置播放器自身的播放控件和帮助仍为英文,其文件保持上游原样。
布尔值、数值和历史 camelCase 参数会归一化处理;自定义 style 经过 WordPress 安全 CSS 过滤。
区块提供 shortcode 转换能力,转换后请检查设置再保存,不会自动重写旧文章。
经典编辑器继续使用 shortcode,暂不增加 TinyMCE 自定义界面。
## 资源与隐私
播放器的 JavaScript、CSS 和 WebAssembly 都在插件内,不会从 jsDelivr 加载。
插件没有统计追踪,也不会在后台调用远程 API。旧的 `ap_use_local_resources` 选项不再使用。
播放器 JavaScript、CSS、WebAssembly 全部本地附带,不再请求 jsDelivr,
旧 `ap_use_local_resources` 开关不再使用。没有统计追踪或后台远程 API 请求。
录屏文件会由浏览器直接请求你填写的 URL。外部主机可能收到读者的 IP 地址、浏览器请求信息,
以及浏览器和站点设置允许发送的来源信息。编辑预览也会发起同样的请求,包括重新打开已有录屏的文章时。
你选择的录制文件会由读者浏览器直接请求;外部文件主机可能收到 IP、浏览器请求信息和
依浏览器/站点策略发送的来源信息。编辑器存在有效 URL 时也会自动发起这类请求,包括重新打开已保存的区块。
请使用可信主机,发布前检查录屏是否包含终端里的敏感信息。外部主机适用其自身隐私政策。
请使用可信主机,发布前检查终端录屏是否含有敏感信息。
外部主机适用自己的隐私政策,插件无法让外部录屏变成私有文件。
## 开发与许可
## 构建与许可
[构建与测试说明](SOURCE.md) · [第三方许可证](THIRD-PARTY-NOTICES.md)
构建、测试和 ZIP 打包步骤见 [SOURCE.md](SOURCE.md)。
本插件保持 GPL-3.0-only,播放器及依赖保留各自的兼容许可证。
插件使用 GPL-3.0-only。播放器和依赖保留各自的兼容许可证,详见[第三方许可证](THIRD-PARTY-NOTICES.md)。
### 素材库与原始终端尺寸(1.2.2)
点击区块中的 **Choose recording** 可通过 WordPress 素材库选择或上传 `.cast` 录制文件。上传权限沿用 WordPress 的 `upload_files` 能力,不会为低权限用户开放上传。插件仅为经过格式校验的 `.cast` 文件添加支持,不放开任意 JSON、HTML 或 SVG。
浮动工具栏和折叠侧栏中的 Columns / Rows 留空时,会在录制加载后显示原始终端尺寸作为占位提示。更换 URL 会刷新提示,但保留你明确填写的覆盖值;恢复录制尺寸会清空覆盖值,继续尊重录制中的尺寸变化。未知或加载失败时不猜测尺寸。
上传文件会完整校验:最多 32 MiB、100,000 个事件或流内行、每条 JSONL 行 256 KiB、终端任一方向不超过 1,000。旧版 v1 最多 2 MiB,需使用起始 `{` 单独一行的格式化 JSON;内置播放器不支持压成一行的 v1。v2/v3 使用标准 JSONL。站点和服务器更低的上传限制仍生效,多站点还需网络允许 `cast` 扩展名。原始尺寸提示只检查同一次预览响应的前 64 KiB,无法读取时保留通用提示。
+73 -109
View File
@@ -1,136 +1,100 @@
# wp-asciiplayer
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.
[中文说明](README-zh.md)
An Asciicast Player block for WordPress, with real playback in the editor and
backwards-compatible `[asciiplayer]` shortcodes. [中文说明](README-zh.md)
## Install
Requires **WordPress 6.3+** and **PHP 7.4+**.
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).
1. Upload the built `wp-asciiplayer.zip` through **Plugins → Add New → Upload Plugin**.
2. Activate **Asciicast Player**.
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`.
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.
## Block editor
## Add a recording
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.
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.
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.
The inserter preview is a local static example and never loads a recording.
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.
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.
### 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.
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.
## Existing shortcodes
Existing posts keep working without a content migration:
Old articles remain supported; no content migration is required:
```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, 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.
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.
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.
## Local resources and privacy
## Media Library uploads
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.
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.
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.
Uploads are checked against these limits:
## Development
- **32 MiB** per file.
- **100,000** events or stream lines.
- **256 KiB** per JSONL line.
- **1,000** columns or rows in either direction.
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).
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.
### Media Library upload limits
## Languages
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.
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).
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.
+1 -30
View File
@@ -4,16 +4,12 @@ This distribution contains the plugin's PHP and JavaScript source, block metadat
build configuration, scripts, and npm lockfile. The development repository is
https://github.com/LamGC/wp-asciiplayer .
Use Node.js 24.18+ (24.x) or 26+, npm 11.16+, and the standard `zip` command:
Use Node.js 24 (24.15 or later), npm, and the standard `zip` command:
npm ci
npm run build
npm run package
Node.js 22 and 25 are not supported by the complete development toolchain.
The Node requirement is for building/testing only; the plugin still supports
WordPress 6.3 and PHP 7.4.
The installable output is `dist/wp-asciiplayer.zip`. Generated assets are never
loaded from a CDN. `scripts/vendor.mjs` copies the pinned official npm
`[email protected]` distribution, verified by package-lock integrity, into
@@ -37,28 +33,3 @@ Chromium; the repository CI records the exact WordPress version under test and
installs the release ZIP into the test site before checking it. Refer to the
workflow for setup details. Running a unit test is not a substitute for the
WordPress browser integration suite.
## Translation maintenance
The English gettext strings are the fallback. Edit `languages/wp-asciiplayer-zh_CN.po`
to maintain Simplified Chinese; `npm run i18n` extracts the current static PHP/JS
and block-metadata strings into the POT and compiles the MO and WordPress Jed JSON.
`npm run i18n:check` fails for missing/fuzzy translations, stale generated files,
unsupported plural extraction, and mismatched printf placeholders. Build runs
compilation and tests check it reproducibly, without a network service or timestamps.
For new strings, run `node scripts/i18n.mjs --pot-only`, merge into the maintained
PO with a gettext editor, translate, and run `npm run i18n` again.
JSON files use WordPress's supported domain-locale-script-handle names for the
actual `lamgc-asciiplayer-editor` and `lamgc-asciiplayer-view` handles. The editor
bundle has no lazy translated chunks. `wp_set_script_translations` registers both
paths after scripts; PHP registers `load_plugin_textdomain` during `init`, before
block metadata is translated. The generated assets and all catalogs are packaged.
The upstream vendor bundle is byte-for-byte unchanged and its own controls remain
English. Runtime JS/CSS versions use build content hashes even though the preview
package version stays `1.1.0-dev`.
References:
- https://developer.wordpress.org/reference/functions/wp_set_script_translations/
- https://developer.wordpress.org/reference/functions/load_script_textdomain/
- https://developer.wordpress.org/reference/functions/load_plugin_textdomain/
+2 -3
View File
@@ -3,14 +3,13 @@
* Plugin Name: Asciicast Player
* Plugin URI: https://github.com/LamGC/wp-asciiplayer
* Description: Add interactive terminal recordings to posts and pages with a block or shortcode.
* Version: 1.1.0-dev
* Version: 1.2.2
* Requires at least: 6.3
* Requires PHP: 7.4
* Author: LamGC
* Author URI: https://blog.lamgc.moe
* License: GPL-3.0-only
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Domain Path: /languages
* Text Domain: wp-asciiplayer
*
* @package LamGC\Asciiplayer
@@ -22,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
const VERSION = '1.1.0-dev';
const VERSION = '1.2.2';
const PLUGIN_FILE = __FILE__;
const SHORTCODE = 'asciiplayer';
+1 -1
View File
@@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "lamgc/asciiplayer",
"version": "1.1.0-dev",
"version": "1.2.2",
"title": "Asciicast Player",
"category": "media",
"icon": "editor-code",
-96
View File
@@ -1,96 +0,0 @@
# Dependency security review
Reviewed 2026-10-14 against the main-branch lockfile and fresh npm audit. Baseline: **44 affected package records (2 critical, 19 high, 20 moderate, 3 low), representing 15 distinct advisories**. The package-record count includes vulnerable packages and their affected parents; it is not 44 distinct security defects. All mapped paths originate in development dependencies. The final production-only root-lock audit reports zero findings; the separately vendored browser player is assessed in [player-bundle-review.md](player-bundle-review.md).
## Implemented narrow changes
Retain the current WordPress parent packages: npm registry reports `@wordpress/[email protected]` and `@wordpress/[email protected]` as current latest. This change uses scoped overrides:
```json
{
"copy-webpack-plugin": { "serialize-javascript": "7.0.5" },
"markdownlint-cli": { "js-yaml": "5.4.3", "smol-toml": "1.9.1" },
"simple-git": { "@simple-git/argv-parser": "2.0.1" }
}
```
- `serialize-javascript`: the current `[email protected]` calls the CommonJS serializer for cache keys. Version 7 retains that callable CommonJS API. Its major-version requirement is Node >=20, already satisfied by this project. Isolated serialization smoke tests passed. Upgrading the entire plugin to 14 would be a larger, unnecessary compatibility change. [v7 release](https://github.com/yahoo/serialize-javascript/releases/tag/v7.0.0)
- `js-yaml`: 5.4.1 is the minimum patched version; 5.4.3 is the latest verified patch. Scope it to `markdownlint-cli`; that package pins `~5.2.1`. Do not override js-yaml globally: wp-env still calls `yaml.safeLoad`, which is unavailable in modern majors. The separate wp-env -> js-yaml 3 -> argparse 1 -> sprintf-js path remains.
- `smol-toml`: 1.9.0 is the minimum patched version; 1.9.1 is the latest verified patch. Scope it to markdownlint-cli, which pins `~1.7.0`. The CommonJS parse API works and the null-prototype result matches the installed older version.
- `qs`: 6.16.0 fixes both findings. **Prefer the in-range Express 4.22.2 -> 4.22.3 update**, because official metadata confirms 4.22.3 pins qs `~6.16.0`. If lockfile regeneration cannot resolve that parent update, a scoped `express -> qs: 6.16.0` override is a fallback. Avoid a disruptive Express 5 migration. The existing body-parser path already has 6.16.0.
- `@simple-git/argv-parser`: the scoped 2.0.1 override is a partial mitigation only, with targeted no-execution tests. Preserve and document remaining simple-git alerts; details below.
These recommendations were based on official npm metadata, published tarballs, source inspection, and small isolated API smoke tests. Local build, 41 JS tests and packaging pass on Node 24.18.0. CI covers PHP 7.4/8.3 and real WordPress 6.3/PHP 7.4 and latest/PHP 8.2 integration.
## Critical simple-git findings: migration blocker
Path: `@wordpress/[email protected] -> [email protected] -> @simple-git/[email protected]`.
**Do not directly override simple-git to v4.** v4 removes the callable CommonJS default export and requires `const { simpleGit } = require('simple-git')`. wp-env currently uses `const SimpleGit = require('simple-git')` and then calls it in both `lib/download-sources.js` and `lib/runtime/docker/download-wp-phpunit.js`. A direct v4 override would fail during Git source/PHPUnit downloads. [Official v4 breaking changes](https://github.com/steveukx/git-js/releases/tag/[email protected])
The fully patched latest combination is simple-git **4.0.2**, which pins argv-parser **2.0.1**. Note that simple-git 4.0.1 pins parser 2.0.0, so it does not by itself clear the VISUAL finding.
A scoped parser-only override to 2.0.1 is included as a **partial mitigation**, with regression tests of the CommonJS API and rejected unsafe inputs. The `vulnerabilityCheck(tokens, env)` signature is unchanged, and isolated simple-git 3.36.0 with parser 2.0.1 passed read-only `checkIsRepo('root')`, `raw('rev-parse', '--show-toplevel')`, and `status()` checks. Parser checks rejected VISUAL, trailer command configuration, and include.path. However, `--receive-p` still produced no finding in that parser-only combination, and version-based simple-git advisories remain. This is not a complete fix and has not been validated through all wp-env Docker/download flows. It is reasonable to include the scoped parser override with the focused regressions while explicitly retaining the residual alerts; a full fix still needs a reviewed wp-env migration.
The examined wp-env call sites use clone/fetch/checkout/reset and fixed sparse-checkout commands; no commit, rebase, interpret-trailers, push, or explicit `.env()` calls were observed in these files. This reduces reachability of the reported flows for ordinary trusted wp-env use, but does not establish that the vulnerable dependency is harmless. Keep development configuration, Git arguments, environment values and source URLs trusted; do not run these tools on attacker-controlled configuration with privileged credentials.
## Advisory matrix
Ranges below are the audit's affected ranges and GitHub Advisory Database's patched versions. Registry availability was checked on the review date.
| Package / baseline | Advisory | Affected range | First patched version | Decision |
|---|---|---|---|---|
| @simple-git/argv-parser 1.1.1 | [VISUAL editor bypass](https://github.com/advisories/GHSA-v5rq-49vh-5v5c) | <2.0.1 | 2.0.1 | Parser 2.0.1 removes this finding; simple-git mitigation remains incomplete overall |
| simple-git 3.36.0 | [Trailer command configuration](https://github.com/advisories/GHSA-x6jw-m9v5-85vh) | >=3.15.0 <4.0.1 | 4.0.1 | v4 is not drop-in for wp-env |
| simple-git 3.36.0 | [Git configuration includes](https://github.com/advisories/GHSA-g4wm-2vf7-vfgr) | <=3.36.0 | 4.0.0 | Same migration blocker |
| simple-git 3.36.0 | [Long-option abbreviation bypass](https://github.com/advisories/GHSA-858h-whjf-mvg5) | <=3.36.0 | 4.0.0 | Parser-only override does not fix this path |
| serialize-javascript 6.0.2 | [RegExp/Date code injection](https://github.com/advisories/GHSA-5c6j-r48x-rmvq) | <=7.0.2 | 7.0.3 | Scoped 7.0.5 clears both findings |
| serialize-javascript 6.0.2 | [Array-like object CPU exhaustion](https://github.com/advisories/GHSA-qj8w-gfj5-8c6v) | >=5.0.0 <7.0.5 | 7.0.5 | Scoped 7.0.5 |
| braces 3.0.3 | [Deep nesting stack exhaustion](https://github.com/advisories/GHSA-vfj7-8cjw-p6xm) | <=3.0.3 | None | Latest published version still affected; trusted build globs only |
| js-yaml 5.2.3 | [Empty merge source CPU exhaustion](https://github.com/advisories/GHSA-r3ph-w7gj-g6xm) | >=5.0.0 <=5.4.0 | 5.4.1 | Scoped 5.4.3 under markdownlint-cli |
| smol-toml 1.7.2 | [Quadratic key parsing](https://github.com/advisories/GHSA-r4xh-jqrq-34v2) | <=1.8.0 | 1.9.0 | Scoped 1.9.1 |
| sprintf-js 1.0.3 | [Unbounded precision DoS](https://github.com/advisories/GHSA-hp3w-g68c-fv3c) | <=1.1.3 | None | Latest published version still affected; wp-env parent migration needed |
| qs 6.15.3 | [Array-limit bypass](https://github.com/advisories/GHSA-x5fp-wj9c-mxmx) | >=6.14.2 <=6.15.3 | 6.16.0 | Express 4.22.3 / qs 6.16.0 |
| qs 6.15.3 | [Attacker-controlled isBuffer](https://github.com/advisories/GHSA-4mjr-xmp4-gh2g) | >=2.2.5 <6.16.0 | 6.16.0 | Scoped 6.16.0 |
| postcss-selector-parser 6.1.4 | [Flat selector CPU exhaustion](https://github.com/advisories/GHSA-rj75-hqrm-r3gf) | <7.1.6 | 7.1.6 | Requires v6 -> v7 range override or parent migration; defer pending CSS-specific regression tests |
| uuid 8.3.2 | [Missing output buffer checks](https://github.com/advisories/GHSA-w5hq-g745-h8pq) | <11.1.1 (installed line) | 11.1.1 | Cross-major candidate; sockjs only calls v4(), not the affected v3/v5/v6 APIs |
| katex 0.16.47 | [Prototype pollution trust bypass](https://github.com/advisories/GHSA-238p-pmpm-9mq7) | >=0.11.0 <0.18.2 | 0.18.2 | 0.x minor-range migration; defer pending markdown math regression validation |
The KaTeX advisory range is from the fresh npm audit. Its GitHub advisory page could not be retrieved during this pass; registry 0.18.2 was downloaded and its rendering API smoke-tested. The fix boundary is inferred from the audit range rather than independently confirmed from that advisory page.
## Paths behind remaining package records
- braces: scripts -> fast-glob -> micromatch -> braces; also transitively affects copy-webpack-plugin, stylelint-family tooling, webpack-dev-server's chokidar and http-proxy-middleware paths. No patched braces release is available, despite some propagated `fixAvailable: true` flags in npm audit.
- postcss-selector-parser: scripts -> cssnano 6.1.2 -> cssnano-preset-default 6.1.2 -> postcss-calc 9.0.1, postcss-merge-rules 6.1.1, postcss-minify-selectors 6.0.4, postcss-unique-selectors 6.0.4, or postcss-merge-longhand 6.0.5 -> stylehacks 6.1.1. Each currently resolves a nested parser 6.1.4. The hoisted parser 7.1.6 is already patched. v7's notable breaking behavior is safe insertion during iteration; avoid a blind global replacement. The advisory explicitly excludes ordinary build-time parsing of trusted source CSS from exposed request-path scenarios. [v7 release](https://github.com/postcss/postcss-selector-parser/releases/tag/v7.0.0)
- sprintf-js: env -> js-yaml 3.15.2 -> argparse 1.0.10 -> sprintf-js 1.0.3. Updating sprintf-js to its latest 1.1.3 does not fix the advisory. Updating js-yaml globally breaks wp-env's safeLoad call.
- uuid: scripts -> webpack-dev-server 5.2.6 -> sockjs 0.3.24 -> uuid 8.3.2. Source inspection finds `require('uuid').v4` and `uuidv4()` only. A scoped uuid11.1.1 override retains CommonJS and passed v4()/validate() smoke testing, but it remains outside sockjs's supported ^8 range. Do not choose uuid12+ blindly because of later module-format changes.
- KaTeX: scripts -> markdownlint-cli 0.49.1 -> markdownlint 0.41.1 -> micromark-extension-math 3.1.0 -> katex 0.16.47. Minimum nonaffected release 0.18.2 exposes renderToString and passed a basic rendering smoke test, but is outside micromark's ^0.16 range.
- qs (recommended fix): env -> @wp-playground/cli 3.1.57 -> express 4.22.2 -> qs 6.15.3; shared Express is also used by webpack-dev-server.
- serialize-javascript (recommended fix): scripts -> copy-webpack-plugin 10.2.4 -> serialize-javascript 6.0.2.
## Engine consistency
The existing Playground/PHP-WASM 3.1.57 tree requires Node >=24.18.0 and npm >=11.16.0. `@wordpress/[email protected]` accepts Node `^22.22.2 || ^24.15.0 || >=26.0.0`, so the intersection is **`^24.18.0 || >=26.0.0`**, not plain >=24.18.0 (which would misleadingly include Node 25). Use npm >=11.16.0 and test the supported minimum in CI. The build and tests were rerun on Node 24.18.0 with npm 11.19.0. CI pins these versions. Node 26 is admitted by dependency engine declarations but has not been separately exercised here.
## Verification checklist
1. Regenerate the lockfile without force and inspect that only intended subtree changes occur.
2. Run `npm ci`, build, JS tests, PHP tests where supported, and release packaging.
3. Validate markdownlint YAML and TOML configuration loading after its minor-range overrides.
4. Run final `npm audit --json` and `npm audit --omit=dev --json`; describe residuals honestly, including the critical simple-git findings.
5. Track wp-env's simple-git v4 migration and braces/sprintf-js upstream releases. Do not suppress remaining advisories merely to make the report green.
## Final audit snapshot
After these changes, npm 11.19.0 reports **39 affected package records**
(1 critical, 20 high, 14 moderate, 4 low), representing **8 distinct advisories**,
versus 15 distinct advisories in the initial snapshot. Counts can change as the
registry advisory database changes; do not equate affected parents with unique flaws.
The remaining advisory packages are braces, KaTeX, postcss-selector-parser,
simple-git (three advisories), sprintf-js and uuid. No advisory is suppressed.
`npm audit --omit=dev --json` reports zero findings for the root production lock.
This does not certify arbitrary bundled code or establish a complete security audit.
Do not run development servers or wp-env against untrusted configurations or
source URLs, or expose development services publicly. A full simple-git fix
needs a compatible wp-env migration; the parser override is not a complete fix.
-62
View File
@@ -1,62 +0,0 @@
# Prebuilt player dependency reachability review
Reviewed 2026-10-14 for `[email protected]`. This is a static review of
specific published bytes, not an independent rebuild or a full security audit.
`scripts/vendor.mjs` copies the npm package's prebuilt browser bundle unchanged.
The root lockfile therefore does not describe all components used to build it.
The upstream dependency inventory is deliberately conservative: it includes
Seroval 1.5.0 through Solid 1.9.6, including server-only dependency paths.
## Verified artifact
The official npm package integrity is recorded in package-lock.json.
- Minified bundle SHA-256: `a13c37632e1b5c49fe9128417b9319a9b5bc64cb457dd5ae52cbba8a3aceb880`
- Readable bundle SHA-256: `4d63cfb88859f158d1eef5d8a5550861abcb7ec195fb5d684f35f6446a29fe11`
The minified hash also matches THIRD-PARTY-NOTICES.md and the installed package.
## Import and artifact evidence
1. [Player view.js](https://github.com/asciinema/asciinema-player/blob/v3.17.0/src/view.js)
imports `render` from `solid-js/web`.
2. Solid 1.9.6's package exports select `web/dist/web.js` for the browser/default
import. Its only external import is `solid-js`; the client `dist/solid.js`
has no imports. Neither imports Seroval.
3. Seroval is imported by the separate `web/dist/server.js` SSR renderer,
not the browser renderer.
4. The [Rollup configuration](https://github.com/asciinema/asciinema-player/blob/v3.17.0/rollup.config.mjs)
creates both readable and minified IIFEs from the same intermediate ESM bundle.
The inspected readable IIFE contains the client renderer and does not contain
Seroval deserialization implementations.
5. Both bundles lack `Seroval`, `fromJSON`, `fromCrossJSON`, `deserialize`,
`__SEROVAL_STREAM__`, and distinctive Seroval error/typed-array registry
signatures. Name searches alone are not proof; they corroborate the import trace.
6. Recording/live input paths use native `JSON.parse`/`response.json`, not
Seroval decoding.
## Advisory-specific conclusion
No reachable affected Seroval decoder was found in these browser bundle bytes:
- [GHSA-mv8w-475r-vwqw](https://github.com/advisories/GHSA-mv8w-475r-vwqw):
affected <=1.5.2, fixed 1.5.3; requires `fromJSON` Promise-control deserialization.
- [GHSA-p6vx-979v-rg4c](https://github.com/advisories/GHSA-p6vx-979v-rg4c):
affected >=0.12.0, <=1.6.0, fixed 1.6.2; requires `fromJSON` with plugin-produced
callables and Promise assimilation.
- [GHSA-jp82-f5mq-hwhp](https://github.com/advisories/GHSA-jp82-f5mq-hwhp):
affected <=1.6.2, fixed 1.6.3; requires Seroval typed-array JSON deserialization.
Seroval 1.5.0 is inside these version ranges, but the necessary decoder is absent
from this browser dependency path. Do not label the player vulnerable solely from
that inventory, or claim the entire plugin safe from this limited review.
Re-review after any player artifact or build-path change.
## Reproduction
Fetch official npm tarballs into separate directories using `npm pack --ignore-scripts`
for `[email protected]`, `[email protected]`, and `[email protected]`.
Verify both player hashes with `sha256sum`, inspect Solid's package exports and
client/server imports, and compare the readable bundle implementation against
those modules. Search both bundles for the decoder names/signatures above.
+6 -9
View File
@@ -17,7 +17,6 @@ if ( ! defined( 'ABSPATH' ) ) {
* @return void
*/
function register_plugin() {
load_plugin_textdomain( 'wp-asciiplayer', false, dirname( plugin_basename( PLUGIN_FILE ) ) . '/languages' );
$base = plugin_dir_url( PLUGIN_FILE ) . 'build/';
$asset = array(
'dependencies' => array( 'wp-blocks', 'wp-element', 'wp-block-editor', 'wp-components', 'wp-i18n' ),
@@ -32,9 +31,7 @@ function register_plugin() {
$view_asset = require dirname( PLUGIN_FILE ) . '/build/view.asset.php';
}
$versions = file_exists( dirname( PLUGIN_FILE ) . '/build/runtime.asset.php' ) ? require dirname( PLUGIN_FILE ) . '/build/runtime.asset.php' : array();
$player_version = $versions['player.js'] ?? VERSION;
wp_register_script( 'lamgc-asciiplayer-player', $base . 'player.js', array(), $player_version, true );
wp_register_script( 'lamgc-asciiplayer-player', $base . 'player.js', array(), VERSION, true );
wp_register_script(
'lamgc-asciiplayer-view',
$base . 'view.js',
@@ -49,16 +46,16 @@ function register_plugin() {
$asset['version'],
true
);
wp_register_style( 'lamgc-asciiplayer-player-style', $base . 'player.css', array(), $versions['player.css'] ?? VERSION );
wp_register_style( 'lamgc-asciiplayer-style', $base . 'style-index.css', array( 'lamgc-asciiplayer-player-style' ), $versions['style-index.css'] ?? VERSION );
wp_register_style( 'lamgc-asciiplayer-editor-style', $base . 'index.css', array( 'lamgc-asciiplayer-player-style' ), $versions['index.css'] ?? VERSION );
wp_register_style( 'lamgc-asciiplayer-player-style', $base . 'player.css', array(), VERSION );
wp_register_style( 'lamgc-asciiplayer-style', $base . 'style-index.css', array( 'lamgc-asciiplayer-player-style' ), VERSION );
wp_register_style( 'lamgc-asciiplayer-editor-style', $base . 'index.css', array( 'lamgc-asciiplayer-player-style' ), VERSION );
wp_add_inline_script(
'lamgc-asciiplayer-editor',
'window.wpAsciiplayerSettings = ' . wp_json_encode(
array(
'playerScriptUrl' => add_query_arg( 'ver', $player_version, $base . 'player.js' ),
'playerStyleUrl' => add_query_arg( 'ver', $versions['player.css'] ?? VERSION, $base . 'player.css' ),
'playerScriptUrl' => add_query_arg( 'ver', VERSION, $base . 'player.js' ),
'playerStyleUrl' => add_query_arg( 'ver', VERSION, $base . 'player.css' ),
),
JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
) . ';',
@@ -1,237 +0,0 @@
{
"domain": "wp-asciiplayer",
"locale_data": {
"messages": {
"": {
"domain": "wp-asciiplayer",
"lang": "zh_CN",
"plural-forms": "nplurals=1; plural=0;"
},
"Columns": [
"列数"
],
"From recording": [
"使用录制尺寸"
],
"Rows": [
"行数"
],
"Placeholders show the recording’s original columns and rows once loaded. Leave blank to follow its terminal size and recorded resize events. These overrides change the character grid, not the display width, and may alter or crop the layout.": [
"加载后,占位提示会显示录制文件的原始行列数。留空可使用录制尺寸,并跟随录制中的尺寸变化。手动设置会改变字符网格,而非显示宽度,可能影响排版或裁切内容。"
],
"Use recording size": [
"使用录制尺寸"
],
"Asciinema": [
"Asciinema"
],
"Recording theme (automatic)": [
"录制文件主题(自动)"
],
"Custom": [
"自定义"
],
"Width": [
"按宽度缩放"
],
"Original size": [
"原始大小"
],
"Height (legacy)": [
"按高度缩放(旧版)"
],
"Width and height (legacy)": [
"按宽高缩放(旧版)"
],
"Example terminal recording": [
"终端录屏示例"
],
"A terminal recording, right in your post.": [
"在文章中直接播放终端录屏。"
],
"Terminal size": [
"终端尺寸"
],
"Terminal size (columns × rows)": [
"终端尺寸(列数 × 行数)"
],
"Close": [
"关闭"
],
"Display": [
"显示"
],
"Player width": [
"播放器宽度"
],
"Custom width": [
"自定义宽度"
],
"Use a CSS length, such as 480px or 65%. The player stays within its available space.": [
"使用 CSS 长度,例如 480px 或 65%。播放器不会超出可用空间。"
],
"Enter a positive width with a unit, such as 480px or 65%. The last valid width is kept.": [
"请输入带单位的正数宽度,例如 480px 或 65%。将保留上一次有效的宽度。"
],
"Display alignment": [
"对齐方式"
],
"Left": [
"左对齐"
],
"Center": [
"居中"
],
"Right": [
"右对齐"
],
"Display width scales the recording without changing its terminal columns or rows. Add a caption directly below the player.": [
"显示宽度只缩放画面,不改变终端行列数。可在播放器下方直接添加说明文字。"
],
"Playback": [
"播放"
],
"Playback speed": [
"播放速度"
],
"Loop playback": [
"循环播放"
],
"Autoplay on published page": [
"在发布后的页面自动播放"
],
"The editor preview always waits for you to press play.": [
"编辑器预览始终需要点击播放后才会开始。"
],
"Preload on published page": [
"在发布后的页面预加载"
],
"Loads the recording before the visitor presses play. The editor preview always preloads a valid recording URL.": [
"在访客点击播放前加载录制文件。编辑器预览始终会预加载有效的录制文件 URL。"
],
"Start at (seconds)": [
"起始时间(秒)"
],
"Idle time limit (seconds)": [
"最长空闲时间(秒)"
],
"Shorten long pauses. Use 0 to keep the recording’s default.": [
"缩短过长的停顿。设为 0 可保留录制文件的默认设置。"
],
"Appearance": [
"外观"
],
"Theme": [
"主题"
],
"Player controls": [
"播放控制栏"
],
"Show on interaction": [
"交互时显示"
],
"Always show": [
"始终显示"
],
"Hide": [
"隐藏"
],
"Fit": [
"缩放方式"
],
"Height-based fitting requires a fixed container height in your site CSS.": [
"按高度缩放需要在站点 CSS 中设置固定的容器高度。"
],
"The custom container style from your shortcode is preserved on the published page.": [
"发布后的页面会保留简码中的自定义容器样式。"
],
"Help": [
"帮助"
],
"A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.": [
"有效的录制文件 URL 会自动加载预览,重新打开编辑器时也一样。文件所在服务器会收到浏览器请求,发布后的播放器也会访问该服务器。请使用 .cast 文件直链;外部服务器需允许跨域请求(CORS)。"
],
"Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.": [
"使用播放器控件播放、暂停和跳转。仅编辑器预览禁用自动播放。"
],
"Recording URL": [
"录制文件 URL"
],
"Apply URL": [
"应用 URL"
],
"Choose an Asciicast recording": [
"选择 Asciicast 录制文件"
],
"Choose recording": [
"选择录制文件"
],
"Choose an Asciicast (.cast) file from the Media Library.": [
"请从媒体库选择 Asciicast(.cast)文件。"
],
"Enter an HTTP(S) recording URL or a path starting with a single /.": [
"请输入 HTTP(S) 录制文件 URL,或以单个 / 开头的路径。"
],
"Asciicast Player": [
"Asciicast 播放器"
],
"Enter a recording URL to load its preview automatically. Playback starts only when you press play.": [
"输入录制文件 URL 后会自动加载预览,点击播放才会开始播放。"
],
"Add a caption…": [
"添加说明文字…"
],
"Recording caption": [
"录屏说明文字"
],
"Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.": [
"按高度缩放的预览会使用简码中的固定高度;未设置时使用 320px 的编辑器预览高度。发布后的高度仍由容器样式决定。"
],
"block title\u0004Asciicast Player": [
"Asciicast 播放器"
],
"block description\u0004Embed and preview a terminal recording with the locally bundled asciinema player.": [
"使用本地附带的 asciinema 播放器嵌入和预览终端录屏。"
],
"block keyword\u0004asciinema": [
"asciinema"
],
"block keyword\u0004terminal": [
"终端"
],
"block keyword\u0004recording": [
"录屏"
],
"Unable to load the recording. Check the URL, file format, and the source server’s CORS permissions.": [
"无法加载录制文件。请检查 URL、文件格式及来源服务器的跨域请求(CORS)权限。"
],
"The recording is taking too long to load. Check your connection and try again.": [
"录制文件加载超时。请检查网络连接后重试。"
],
"The local player could not start. Try again, or check that the plugin’s built assets are installed.": [
"本地播放器无法启动。请重试,或检查插件的构建资源是否已安装。"
],
"Loading recording…": [
"正在加载录制文件…"
],
"Retry preview": [
"重试预览"
],
"Interactive terminal recording preview": [
"可交互的终端录屏预览"
],
"Unable to load this terminal recording. The file may be unavailable, invalid, or blocked by the source server’s CORS policy.": [
"无法加载此终端录屏。文件可能无法访问、格式无效,或被来源服务器的跨域请求(CORS)策略阻止。"
],
"You are not allowed to upload Asciicast files.": [
"你没有上传 Asciicast 文件的权限。"
],
"Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording (up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and 1,000 columns or rows).": [
"请上传有效的 Asciicast v2/v3 JSONL 或格式化的 v1 .cast 录制文件(最大 32 MiB;v1 最大 2 MiB;最多 100,000 个事件;每行 JSONL最大 256 KiB;列数和行数均不超过 1,000)。"
],
"Add interactive terminal recordings to posts and pages with a block or shortcode.": [
"通过区块或简码在文章和页面中添加可交互的终端录屏。"
]
}
}
}
@@ -1,237 +0,0 @@
{
"domain": "wp-asciiplayer",
"locale_data": {
"messages": {
"": {
"domain": "wp-asciiplayer",
"lang": "zh_CN",
"plural-forms": "nplurals=1; plural=0;"
},
"Columns": [
"列数"
],
"From recording": [
"使用录制尺寸"
],
"Rows": [
"行数"
],
"Placeholders show the recording’s original columns and rows once loaded. Leave blank to follow its terminal size and recorded resize events. These overrides change the character grid, not the display width, and may alter or crop the layout.": [
"加载后,占位提示会显示录制文件的原始行列数。留空可使用录制尺寸,并跟随录制中的尺寸变化。手动设置会改变字符网格,而非显示宽度,可能影响排版或裁切内容。"
],
"Use recording size": [
"使用录制尺寸"
],
"Asciinema": [
"Asciinema"
],
"Recording theme (automatic)": [
"录制文件主题(自动)"
],
"Custom": [
"自定义"
],
"Width": [
"按宽度缩放"
],
"Original size": [
"原始大小"
],
"Height (legacy)": [
"按高度缩放(旧版)"
],
"Width and height (legacy)": [
"按宽高缩放(旧版)"
],
"Example terminal recording": [
"终端录屏示例"
],
"A terminal recording, right in your post.": [
"在文章中直接播放终端录屏。"
],
"Terminal size": [
"终端尺寸"
],
"Terminal size (columns × rows)": [
"终端尺寸(列数 × 行数)"
],
"Close": [
"关闭"
],
"Display": [
"显示"
],
"Player width": [
"播放器宽度"
],
"Custom width": [
"自定义宽度"
],
"Use a CSS length, such as 480px or 65%. The player stays within its available space.": [
"使用 CSS 长度,例如 480px 或 65%。播放器不会超出可用空间。"
],
"Enter a positive width with a unit, such as 480px or 65%. The last valid width is kept.": [
"请输入带单位的正数宽度,例如 480px 或 65%。将保留上一次有效的宽度。"
],
"Display alignment": [
"对齐方式"
],
"Left": [
"左对齐"
],
"Center": [
"居中"
],
"Right": [
"右对齐"
],
"Display width scales the recording without changing its terminal columns or rows. Add a caption directly below the player.": [
"显示宽度只缩放画面,不改变终端行列数。可在播放器下方直接添加说明文字。"
],
"Playback": [
"播放"
],
"Playback speed": [
"播放速度"
],
"Loop playback": [
"循环播放"
],
"Autoplay on published page": [
"在发布后的页面自动播放"
],
"The editor preview always waits for you to press play.": [
"编辑器预览始终需要点击播放后才会开始。"
],
"Preload on published page": [
"在发布后的页面预加载"
],
"Loads the recording before the visitor presses play. The editor preview always preloads a valid recording URL.": [
"在访客点击播放前加载录制文件。编辑器预览始终会预加载有效的录制文件 URL。"
],
"Start at (seconds)": [
"起始时间(秒)"
],
"Idle time limit (seconds)": [
"最长空闲时间(秒)"
],
"Shorten long pauses. Use 0 to keep the recording’s default.": [
"缩短过长的停顿。设为 0 可保留录制文件的默认设置。"
],
"Appearance": [
"外观"
],
"Theme": [
"主题"
],
"Player controls": [
"播放控制栏"
],
"Show on interaction": [
"交互时显示"
],
"Always show": [
"始终显示"
],
"Hide": [
"隐藏"
],
"Fit": [
"缩放方式"
],
"Height-based fitting requires a fixed container height in your site CSS.": [
"按高度缩放需要在站点 CSS 中设置固定的容器高度。"
],
"The custom container style from your shortcode is preserved on the published page.": [
"发布后的页面会保留简码中的自定义容器样式。"
],
"Help": [
"帮助"
],
"A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.": [
"有效的录制文件 URL 会自动加载预览,重新打开编辑器时也一样。文件所在服务器会收到浏览器请求,发布后的播放器也会访问该服务器。请使用 .cast 文件直链;外部服务器需允许跨域请求(CORS)。"
],
"Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.": [
"使用播放器控件播放、暂停和跳转。仅编辑器预览禁用自动播放。"
],
"Recording URL": [
"录制文件 URL"
],
"Apply URL": [
"应用 URL"
],
"Choose an Asciicast recording": [
"选择 Asciicast 录制文件"
],
"Choose recording": [
"选择录制文件"
],
"Choose an Asciicast (.cast) file from the Media Library.": [
"请从媒体库选择 Asciicast(.cast)文件。"
],
"Enter an HTTP(S) recording URL or a path starting with a single /.": [
"请输入 HTTP(S) 录制文件 URL,或以单个 / 开头的路径。"
],
"Asciicast Player": [
"Asciicast 播放器"
],
"Enter a recording URL to load its preview automatically. Playback starts only when you press play.": [
"输入录制文件 URL 后会自动加载预览,点击播放才会开始播放。"
],
"Add a caption…": [
"添加说明文字…"
],
"Recording caption": [
"录屏说明文字"
],
"Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.": [
"按高度缩放的预览会使用简码中的固定高度;未设置时使用 320px 的编辑器预览高度。发布后的高度仍由容器样式决定。"
],
"block title\u0004Asciicast Player": [
"Asciicast 播放器"
],
"block description\u0004Embed and preview a terminal recording with the locally bundled asciinema player.": [
"使用本地附带的 asciinema 播放器嵌入和预览终端录屏。"
],
"block keyword\u0004asciinema": [
"asciinema"
],
"block keyword\u0004terminal": [
"终端"
],
"block keyword\u0004recording": [
"录屏"
],
"Unable to load the recording. Check the URL, file format, and the source server’s CORS permissions.": [
"无法加载录制文件。请检查 URL、文件格式及来源服务器的跨域请求(CORS)权限。"
],
"The recording is taking too long to load. Check your connection and try again.": [
"录制文件加载超时。请检查网络连接后重试。"
],
"The local player could not start. Try again, or check that the plugin’s built assets are installed.": [
"本地播放器无法启动。请重试,或检查插件的构建资源是否已安装。"
],
"Loading recording…": [
"正在加载录制文件…"
],
"Retry preview": [
"重试预览"
],
"Interactive terminal recording preview": [
"可交互的终端录屏预览"
],
"Unable to load this terminal recording. The file may be unavailable, invalid, or blocked by the source server’s CORS policy.": [
"无法加载此终端录屏。文件可能无法访问、格式无效,或被来源服务器的跨域请求(CORS)策略阻止。"
],
"You are not allowed to upload Asciicast files.": [
"你没有上传 Asciicast 文件的权限。"
],
"Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording (up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and 1,000 columns or rows).": [
"请上传有效的 Asciicast v2/v3 JSONL 或格式化的 v1 .cast 录制文件(最大 32 MiB;v1 最大 2 MiB;最多 100,000 个事件;每行 JSONL最大 256 KiB;列数和行数均不超过 1,000)。"
],
"Add interactive terminal recordings to posts and pages with a block or shortcode.": [
"通过区块或简码在文章和页面中添加可交互的终端录屏。"
]
}
}
}
Binary file not shown.
-367
View File
@@ -1,367 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: wp-asciiplayer 1.1.0-dev\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Domain: wp-asciiplayer\n"
"Language: zh_CN\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"Language-Team: Simplified Chinese\n"
#: src/edit.js:91
msgid "A terminal recording, right in your post."
msgstr "在文章中直接播放终端录屏。"
#: src/edit.js:139
msgid ""
"A valid recording URL loads its preview automatically, including when "
"reopening this editor. That server receives your browser’s request. "
"Published players contact the same server. Use a direct .cast URL; external "
"servers must allow CORS."
msgstr ""
"有效的录制文件 URL 会自动加载预览,重新打开编辑器时也一样。文件所在服务器会收到浏览器请求,发布后的播放器也会访问该服务器。请使用 .cast "
"文件直链;外部服务器需允许跨域请求(CORS)。"
#: src/edit.js:165
msgid "Add a caption…"
msgstr "添加说明文字…"
#: asciicast-player.php:1
msgid ""
"Add interactive terminal recordings to posts and pages with a block or "
"shortcode."
msgstr "通过区块或简码在文章和页面中添加可交互的终端录屏。"
#: src/edit.js:132
msgid "Always show"
msgstr "始终显示"
#: src/edit.js:128
msgid "Appearance"
msgstr "外观"
#: src/edit.js:147
msgid "Apply URL"
msgstr "应用 URL"
#: src/edit.js:163
#: asciicast-player.php:1
msgid "Asciicast Player"
msgstr "Asciicast 播放器"
#: src/edit.js:73
msgid "Asciinema"
msgstr "Asciinema"
#: src/edit.js:123
msgid "Autoplay on published page"
msgstr "在发布后的页面自动播放"
#: src/edit.js:116
msgid "Center"
msgstr "居中"
#: src/edit.js:154
msgid "Choose an Asciicast (.cast) file from the Media Library."
msgstr "请从媒体库选择 Asciicast(.cast)文件。"
#: src/edit.js:150
msgid "Choose an Asciicast recording"
msgstr "选择 Asciicast 录制文件"
#: src/edit.js:151
msgid "Choose recording"
msgstr "选择录制文件"
#: src/edit.js:104
msgid "Close"
msgstr "关闭"
#: src/edit.js:12
msgid "Columns"
msgstr "列数"
#: src/edit.js:81
msgid "Custom"
msgstr "自定义"
#: src/edit.js:115
msgid "Custom width"
msgstr "自定义宽度"
#: src/edit.js:113
msgid "Display"
msgstr "显示"
#: src/edit.js:116
msgid "Display alignment"
msgstr "对齐方式"
#: src/edit.js:117
msgid ""
"Display width scales the recording without changing its terminal columns or "
"rows. Add a caption directly below the player."
msgstr "显示宽度只缩放画面,不改变终端行列数。可在播放器下方直接添加说明文字。"
#: src/edit.js:115
msgid ""
"Enter a positive width with a unit, such as 480px or 65%. The last valid "
"width is kept."
msgstr "请输入带单位的正数宽度,例如 480px 或 65%。将保留上一次有效的宽度。"
#: src/edit.js:163
msgid ""
"Enter a recording URL to load its preview automatically. Playback starts "
"only when you press play."
msgstr "输入录制文件 URL 后会自动加载预览,点击播放才会开始播放。"
#: src/edit.js:155
msgid "Enter an HTTP(S) recording URL or a path starting with a single /."
msgstr "请输入 HTTP(S) 录制文件 URL,或以单个 / 开头的路径。"
#: src/edit.js:91
msgid "Example terminal recording"
msgstr "终端录屏示例"
#: src/edit.js:135
msgid "Fit"
msgstr "缩放方式"
#: src/edit.js:12
#: src/edit.js:13
msgid "From recording"
msgstr "使用录制尺寸"
#: src/edit.js:89
msgid "Height (legacy)"
msgstr "按高度缩放(旧版)"
#: src/edit.js:135
msgid "Height-based fitting requires a fixed container height in your site CSS."
msgstr "按高度缩放需要在站点 CSS 中设置固定的容器高度。"
#: src/edit.js:167
msgid ""
"Height-based previews use the shortcode’s fixed height when available, or a "
"320px editor frame. Published height still comes from your container style."
msgstr "按高度缩放的预览会使用简码中的固定高度;未设置时使用 320px 的编辑器预览高度。发布后的高度仍由容器样式决定。"
#: src/edit.js:138
msgid "Help"
msgstr "帮助"
#: src/edit.js:133
msgid "Hide"
msgstr "隐藏"
#: src/edit.js:126
msgid "Idle time limit (seconds)"
msgstr "最长空闲时间(秒)"
#: src/preview.js:85
msgid "Interactive terminal recording preview"
msgstr "可交互的终端录屏预览"
#: src/edit.js:116
msgid "Left"
msgstr "左对齐"
#: src/preview.js:83
msgid "Loading recording…"
msgstr "正在加载录制文件…"
#: src/edit.js:124
msgid ""
"Loads the recording before the visitor presses play. The editor preview "
"always preloads a valid recording URL."
msgstr "在访客点击播放前加载录制文件。编辑器预览始终会预加载有效的录制文件 URL。"
#: src/edit.js:122
msgid "Loop playback"
msgstr "循环播放"
#: src/edit.js:87
msgid "Original size"
msgstr "原始大小"
#: src/edit.js:15
msgid ""
"Placeholders show the recording’s original columns and rows once loaded. "
"Leave blank to follow its terminal size and recorded resize events. These "
"overrides change the character grid, not the display width, and may alter "
"or crop the layout."
msgstr "加载后,占位提示会显示录制文件的原始行列数。留空可使用录制尺寸,并跟随录制中的尺寸变化。手动设置会改变字符网格,而非显示宽度,可能影响排版或裁切内容。"
#: src/edit.js:120
msgid "Playback"
msgstr "播放"
#: src/edit.js:121
msgid "Playback speed"
msgstr "播放速度"
#: src/edit.js:130
msgid "Player controls"
msgstr "播放控制栏"
#: src/edit.js:114
msgid "Player width"
msgstr "播放器宽度"
#: src/edit.js:124
msgid "Preload on published page"
msgstr "在发布后的页面预加载"
#: src/edit.js:165
msgid "Recording caption"
msgstr "录屏说明文字"
#: src/edit.js:74
msgid "Recording theme (automatic)"
msgstr "录制文件主题(自动)"
#: src/edit.js:146
msgid "Recording URL"
msgstr "录制文件 URL"
#: src/preview.js:84
msgid "Retry preview"
msgstr "重试预览"
#: src/edit.js:116
msgid "Right"
msgstr "右对齐"
#: src/edit.js:13
msgid "Rows"
msgstr "行数"
#: src/edit.js:126
msgid "Shorten long pauses. Use 0 to keep the recording’s default."
msgstr "缩短过长的停顿。设为 0 可保留录制文件的默认设置。"
#: src/edit.js:131
msgid "Show on interaction"
msgstr "交互时显示"
#: src/edit.js:125
msgid "Start at (seconds)"
msgstr "起始时间(秒)"
#: src/edit.js:99
#: src/edit.js:101
#: src/edit.js:110
msgid "Terminal size"
msgstr "终端尺寸"
#: src/edit.js:102
msgid "Terminal size (columns × rows)"
msgstr "终端尺寸(列数 × 行数)"
#: src/edit.js:136
msgid ""
"The custom container style from your shortcode is preserved on the "
"published page."
msgstr "发布后的页面会保留简码中的自定义容器样式。"
#: src/edit.js:123
msgid "The editor preview always waits for you to press play."
msgstr "编辑器预览始终需要点击播放后才会开始。"
#: src/preview.js:70
msgid ""
"The local player could not start. Try again, or check that the plugin’s "
"built assets are installed."
msgstr "本地播放器无法启动。请重试,或检查插件的构建资源是否已安装。"
#: src/preview.js:68
msgid ""
"The recording is taking too long to load. Check your connection and try "
"again."
msgstr "录制文件加载超时。请检查网络连接后重试。"
#: src/edit.js:129
msgid "Theme"
msgstr "主题"
#: src/preview.js:59
msgid ""
"Unable to load the recording. Check the URL, file format, and the source "
"server’s CORS permissions."
msgstr "无法加载录制文件。请检查 URL、文件格式及来源服务器的跨域请求(CORS)权限。"
#: src/view.js:12
msgid ""
"Unable to load this terminal recording. The file may be unavailable, "
"invalid, or blocked by the source server’s CORS policy."
msgstr "无法加载此终端录屏。文件可能无法访问、格式无效,或被来源服务器的跨域请求(CORS)策略阻止。"
#: includes/uploads.php:197
msgid ""
"Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording "
"(up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and "
"1,000 columns or rows)."
msgstr ""
"请上传有效的 Asciicast v2/v3 JSONL 或格式化的 v1 .cast 录制文件(最大 32 MiB;v1 最大 2 MiB;最多 "
"100,000 个事件;每行 JSONL最大 256 KiB;列数和行数均不超过 1,000)。"
#: src/edit.js:115
msgid ""
"Use a CSS length, such as 480px or 65%. The player stays within its "
"available space."
msgstr "使用 CSS 长度,例如 480px 或 65%。播放器不会超出可用空间。"
#: src/edit.js:16
msgid "Use recording size"
msgstr "使用录制尺寸"
#: src/edit.js:140
msgid ""
"Use the player controls to play, pause, and seek. Autoplay is disabled only "
"in the editor."
msgstr "使用播放器控件播放、暂停和跳转。仅编辑器预览禁用自动播放。"
#: src/edit.js:86
msgid "Width"
msgstr "按宽度缩放"
#: src/edit.js:89
msgid "Width and height (legacy)"
msgstr "按宽高缩放(旧版)"
#: includes/uploads.php:195
msgid "You are not allowed to upload Asciicast files."
msgstr "你没有上传 Asciicast 文件的权限。"
#: src/index.js:19
#: block.json:1
msgctxt "block description"
msgid ""
"Embed and preview a terminal recording with the locally bundled asciinema "
"player."
msgstr "使用本地附带的 asciinema 播放器嵌入和预览终端录屏。"
#: src/index.js:20
#: block.json:1
msgctxt "block keyword"
msgid "asciinema"
msgstr "asciinema"
#: src/index.js:20
#: block.json:1
msgctxt "block keyword"
msgid "recording"
msgstr "录屏"
#: src/index.js:20
#: block.json:1
msgctxt "block keyword"
msgid "terminal"
msgstr "终端"
#: src/index.js:18
#: block.json:1
msgctxt "block title"
msgid "Asciicast Player"
msgstr "Asciicast 播放器"
-360
View File
@@ -1,360 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: wp-asciiplayer 1.1.0-dev\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Domain: wp-asciiplayer\n"
#: src/edit.js:91
msgid "A terminal recording, right in your post."
msgstr ""
#: src/edit.js:139
msgid ""
"A valid recording URL loads its preview automatically, including when "
"reopening this editor. That server receives your browser’s request. "
"Published players contact the same server. Use a direct .cast URL; external "
"servers must allow CORS."
msgstr ""
#: src/edit.js:165
msgid "Add a caption…"
msgstr ""
#: asciicast-player.php:1
msgid ""
"Add interactive terminal recordings to posts and pages with a block or "
"shortcode."
msgstr ""
#: src/edit.js:132
msgid "Always show"
msgstr ""
#: src/edit.js:128
msgid "Appearance"
msgstr ""
#: src/edit.js:147
msgid "Apply URL"
msgstr ""
#: src/edit.js:163
#: asciicast-player.php:1
msgid "Asciicast Player"
msgstr ""
#: src/edit.js:73
msgid "Asciinema"
msgstr ""
#: src/edit.js:123
msgid "Autoplay on published page"
msgstr ""
#: src/edit.js:116
msgid "Center"
msgstr ""
#: src/edit.js:154
msgid "Choose an Asciicast (.cast) file from the Media Library."
msgstr ""
#: src/edit.js:150
msgid "Choose an Asciicast recording"
msgstr ""
#: src/edit.js:151
msgid "Choose recording"
msgstr ""
#: src/edit.js:104
msgid "Close"
msgstr ""
#: src/edit.js:12
msgid "Columns"
msgstr ""
#: src/edit.js:81
msgid "Custom"
msgstr ""
#: src/edit.js:115
msgid "Custom width"
msgstr ""
#: src/edit.js:113
msgid "Display"
msgstr ""
#: src/edit.js:116
msgid "Display alignment"
msgstr ""
#: src/edit.js:117
msgid ""
"Display width scales the recording without changing its terminal columns or "
"rows. Add a caption directly below the player."
msgstr ""
#: src/edit.js:115
msgid ""
"Enter a positive width with a unit, such as 480px or 65%. The last valid "
"width is kept."
msgstr ""
#: src/edit.js:163
msgid ""
"Enter a recording URL to load its preview automatically. Playback starts "
"only when you press play."
msgstr ""
#: src/edit.js:155
msgid "Enter an HTTP(S) recording URL or a path starting with a single /."
msgstr ""
#: src/edit.js:91
msgid "Example terminal recording"
msgstr ""
#: src/edit.js:135
msgid "Fit"
msgstr ""
#: src/edit.js:12
#: src/edit.js:13
msgid "From recording"
msgstr ""
#: src/edit.js:89
msgid "Height (legacy)"
msgstr ""
#: src/edit.js:135
msgid "Height-based fitting requires a fixed container height in your site CSS."
msgstr ""
#: src/edit.js:167
msgid ""
"Height-based previews use the shortcode’s fixed height when available, or a "
"320px editor frame. Published height still comes from your container style."
msgstr ""
#: src/edit.js:138
msgid "Help"
msgstr ""
#: src/edit.js:133
msgid "Hide"
msgstr ""
#: src/edit.js:126
msgid "Idle time limit (seconds)"
msgstr ""
#: src/preview.js:85
msgid "Interactive terminal recording preview"
msgstr ""
#: src/edit.js:116
msgid "Left"
msgstr ""
#: src/preview.js:83
msgid "Loading recording…"
msgstr ""
#: src/edit.js:124
msgid ""
"Loads the recording before the visitor presses play. The editor preview "
"always preloads a valid recording URL."
msgstr ""
#: src/edit.js:122
msgid "Loop playback"
msgstr ""
#: src/edit.js:87
msgid "Original size"
msgstr ""
#: src/edit.js:15
msgid ""
"Placeholders show the recording’s original columns and rows once loaded. "
"Leave blank to follow its terminal size and recorded resize events. These "
"overrides change the character grid, not the display width, and may alter "
"or crop the layout."
msgstr ""
#: src/edit.js:120
msgid "Playback"
msgstr ""
#: src/edit.js:121
msgid "Playback speed"
msgstr ""
#: src/edit.js:130
msgid "Player controls"
msgstr ""
#: src/edit.js:114
msgid "Player width"
msgstr ""
#: src/edit.js:124
msgid "Preload on published page"
msgstr ""
#: src/edit.js:165
msgid "Recording caption"
msgstr ""
#: src/edit.js:74
msgid "Recording theme (automatic)"
msgstr ""
#: src/edit.js:146
msgid "Recording URL"
msgstr ""
#: src/preview.js:84
msgid "Retry preview"
msgstr ""
#: src/edit.js:116
msgid "Right"
msgstr ""
#: src/edit.js:13
msgid "Rows"
msgstr ""
#: src/edit.js:126
msgid "Shorten long pauses. Use 0 to keep the recording’s default."
msgstr ""
#: src/edit.js:131
msgid "Show on interaction"
msgstr ""
#: src/edit.js:125
msgid "Start at (seconds)"
msgstr ""
#: src/edit.js:99
#: src/edit.js:101
#: src/edit.js:110
msgid "Terminal size"
msgstr ""
#: src/edit.js:102
msgid "Terminal size (columns × rows)"
msgstr ""
#: src/edit.js:136
msgid ""
"The custom container style from your shortcode is preserved on the "
"published page."
msgstr ""
#: src/edit.js:123
msgid "The editor preview always waits for you to press play."
msgstr ""
#: src/preview.js:70
msgid ""
"The local player could not start. Try again, or check that the plugin’s "
"built assets are installed."
msgstr ""
#: src/preview.js:68
msgid ""
"The recording is taking too long to load. Check your connection and try "
"again."
msgstr ""
#: src/edit.js:129
msgid "Theme"
msgstr ""
#: src/preview.js:59
msgid ""
"Unable to load the recording. Check the URL, file format, and the source "
"server’s CORS permissions."
msgstr ""
#: src/view.js:12
msgid ""
"Unable to load this terminal recording. The file may be unavailable, "
"invalid, or blocked by the source server’s CORS policy."
msgstr ""
#: includes/uploads.php:197
msgid ""
"Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording "
"(up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and "
"1,000 columns or rows)."
msgstr ""
#: src/edit.js:115
msgid ""
"Use a CSS length, such as 480px or 65%. The player stays within its "
"available space."
msgstr ""
#: src/edit.js:16
msgid "Use recording size"
msgstr ""
#: src/edit.js:140
msgid ""
"Use the player controls to play, pause, and seek. Autoplay is disabled only "
"in the editor."
msgstr ""
#: src/edit.js:86
msgid "Width"
msgstr ""
#: src/edit.js:89
msgid "Width and height (legacy)"
msgstr ""
#: includes/uploads.php:195
msgid "You are not allowed to upload Asciicast files."
msgstr ""
#: src/index.js:19
#: block.json:1
msgctxt "block description"
msgid ""
"Embed and preview a terminal recording with the locally bundled asciinema "
"player."
msgstr ""
#: src/index.js:20
#: block.json:1
msgctxt "block keyword"
msgid "asciinema"
msgstr ""
#: src/index.js:20
#: block.json:1
msgctxt "block keyword"
msgid "recording"
msgstr ""
#: src/index.js:20
#: block.json:1
msgctxt "block keyword"
msgid "terminal"
msgstr ""
#: src/index.js:18
#: block.json:1
msgctxt "block title"
msgid "Asciicast Player"
msgstr ""
+59 -179
View File
@@ -1,26 +1,23 @@
{
"name": "wp-asciiplayer",
"version": "1.1.0-dev",
"version": "1.2.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "wp-asciiplayer",
"version": "1.1.0-dev",
"version": "1.2.2",
"license": "GPL-3.0-only",
"dependencies": {
"asciinema-player": "3.17.0"
},
"devDependencies": {
"@babel/parser": "8.0.7",
"@playwright/test": "1.64.0",
"@wordpress/env": "11.17.0",
"@wordpress/scripts": "36.1.0",
"gettext-parser": "9.1.1"
"@wordpress/scripts": "36.1.0"
},
"engines": {
"node": "^24.18.0 || >=26.0.0",
"npm": ">=11.16.0"
"node": ">=22.22.2"
}
},
"node_modules/@babel/code-frame": {
@@ -79,22 +76,6 @@
"url": "https://opencollective.com/babel"
}
},
"node_modules/@babel/core/node_modules/@babel/parser": {
"version": "7.29.9",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@babel/generator": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz",
@@ -112,22 +93,6 @@
"node": ">=6.9.0"
}
},
"node_modules/@babel/generator/node_modules/@babel/parser": {
"version": "7.29.9",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@babel/helper-annotate-as-pure": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.29.7.tgz",
@@ -404,53 +369,19 @@
}
},
"node_modules/@babel/parser": {
"version": "8.0.7",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-8.0.7.tgz",
"integrity": "sha512-UkDwEbPO1px2JQSrdh4qIgaH1JgG7GO/pFeJkpxhDxIETkT/QvGpnigXIw75ViHYPtIgKITmVUJqLjiO+JuWjA==",
"version": "7.29.9",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^8.0.6"
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": "^22.18.0 || >=24.11.0"
}
},
"node_modules/@babel/parser/node_modules/@babel/helper-string-parser": {
"version": "8.0.6",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-8.0.6.tgz",
"integrity": "sha512-+6HYEBnsDRZHJtUTAEfMQd0zMDqdFHS7C+5vAsEZqBUr3vEMWOWlHJ0Jz1gS8jJIlCvLsuA6ivmeoqzH936YcA==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^22.18.0 || >=24.11.0"
}
},
"node_modules/@babel/parser/node_modules/@babel/helper-validator-identifier": {
"version": "8.0.6",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-8.0.6.tgz",
"integrity": "sha512-HYx0YmuchRxRSpnjvcNffnPS8DCauKNmnumIuHG3jnQAVewRA7kfJGwF13ayEpSZs7s4R/oBH4eppuXcAQd5JQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^22.18.0 || >=24.11.0"
}
},
"node_modules/@babel/parser/node_modules/@babel/types": {
"version": "8.0.6",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-8.0.6.tgz",
"integrity": "sha512-c+xgSWboV2pdwXP67BUWDVRHi2BO5Q3KwxyFVs7taVTY+fsK47/L51ZXQoV9rozHJDNHvJ4v4WEsI/IlxV2l2A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/helper-string-parser": "^8.0.6",
"@babel/helper-validator-identifier": "^8.0.6"
},
"engines": {
"node": "^22.18.0 || >=24.11.0"
"node": ">=6.0.0"
}
},
"node_modules/@babel/plugin-bugfix-firefox-class-in-computed-class-key": {
@@ -1810,22 +1741,6 @@
"node": ">=6.9.0"
}
},
"node_modules/@babel/template/node_modules/@babel/parser": {
"version": "7.29.9",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@babel/traverse": {
"version": "7.29.10",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.10.tgz",
@@ -1845,22 +1760,6 @@
"node": ">=6.9.0"
}
},
"node_modules/@babel/traverse/node_modules/@babel/parser": {
"version": "7.29.9",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@babel/types": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
@@ -5626,13 +5525,13 @@
"license": "MIT"
},
"node_modules/@simple-git/argv-parser": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@simple-git/argv-parser/-/argv-parser-2.0.1.tgz",
"integrity": "sha512-M++IaVWrN+vYalilOHfwvT2IL3wYZtVEBQpmX6DLSOJLtxbZ+SUeIDE3IiPogzhPACLajwtxfa5rp+ZX1FczzQ==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@simple-git/argv-parser/-/argv-parser-1.1.1.tgz",
"integrity": "sha512-Q9lBcfQ+VQCpQqGJFHe5yooOS5hGdLFFbJ5R+R5aDsnkPCahtn1hSkMcORX65J2Z5lxSkD0lQorMsncuBQxYUw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@simple-git/args-pathspec": "^1.0.4"
"@simple-git/args-pathspec": "^1.0.3"
}
},
"node_modules/@sindresorhus/base62": {
@@ -7501,17 +7400,6 @@
"node": ">=18.12.0"
}
},
"node_modules/@wordpress/i18n/node_modules/gettext-parser": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz",
"integrity": "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA==",
"dev": true,
"license": "MIT",
"dependencies": {
"encoding": "^0.1.12",
"safe-buffer": "^5.1.1"
}
},
"node_modules/@wordpress/is-shallow-equal": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@wordpress/is-shallow-equal/-/is-shallow-equal-5.57.0.tgz",
@@ -8007,22 +7895,6 @@
}
}
},
"node_modules/@wordpress/theme/node_modules/@babel/parser": {
"version": "7.29.9",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@wordpress/undo-manager": {
"version": "1.57.0",
"resolved": "https://registry.npmjs.org/@wordpress/undo-manager/-/undo-manager-1.57.0.tgz",
@@ -9035,6 +8907,23 @@
"dev": true,
"license": "MIT"
},
"node_modules/body-parser/node_modules/qs": {
"version": "6.16.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz",
"integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
"es-define-property": "^1.0.1",
"side-channel": "^1.1.1"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/bonjour-service": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.4.4.tgz",
@@ -11961,22 +11850,6 @@
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 || ^10.0.0"
}
},
"node_modules/eslint-plugin-react-hooks/node_modules/@babel/parser": {
"version": "7.29.9",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/eslint-plugin-react/node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@@ -12967,17 +12840,14 @@
}
},
"node_modules/gettext-parser": {
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-9.1.1.tgz",
"integrity": "sha512-ZLeqWPz9OMNrTgMuww0C22kkcNqis+e4059R94t7L7ERlZ2rUNpiDbaAUus+esBC6uBAQWbS9N+R5vJIJg//lw==",
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz",
"integrity": "sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA==",
"dev": true,
"license": "MIT",
"dependencies": {
"content-type": "^1.0.5",
"encoding": "^0.1.13"
},
"engines": {
"node": ">=20"
"encoding": "^0.1.12",
"safe-buffer": "^5.1.1"
}
},
"node_modules/glob": {
@@ -15570,9 +15440,9 @@
"license": "Python-2.0"
},
"node_modules/markdownlint-cli/node_modules/js-yaml": {
"version": "5.4.3",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.3.tgz",
"integrity": "sha512-yzzNtgczwgoVHNigCyKTXcQJU4Y8t/ikU4UxXW0BvrLfHTGWZhsNcOT2s/a7vn81/4KqVnNmHjaUEPlvWnNwVw==",
"version": "5.2.3",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.2.3.tgz",
"integrity": "sha512-n+mUVyUX5bVv7G/G2zyIHOhdxfuU1dY2NOFzTQUWiMUbFss8b57NFlgCCaggU78wSw5KVS9cllzeLyzyR+n5nw==",
"dev": true,
"funding": [
{
@@ -18847,9 +18717,9 @@
"license": "MIT"
},
"node_modules/qs": {
"version": "6.16.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz",
"integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==",
"version": "6.15.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz",
"integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
@@ -18897,6 +18767,16 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"safe-buffer": "^5.1.0"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@@ -19961,13 +19841,13 @@
}
},
"node_modules/serialize-javascript": {
"version": "7.0.5",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.0.5.tgz",
"integrity": "sha512-F4LcB0UqUl1zErq+1nYEEzSHJnIwb3AF2XWB94b+afhrekOUijwooAYqFyRbjYkm2PAKBabx6oYv/xDxNi8IBw==",
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz",
"integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=20.0.0"
"dependencies": {
"randombytes": "^2.1.0"
}
},
"node_modules/seroval": {
@@ -20411,9 +20291,9 @@
}
},
"node_modules/smol-toml": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.9.1.tgz",
"integrity": "sha512-j7WyPdf0CJoutMzMoPLF/bVXHtKZIT9Rb4eGeEbWw8X2t5oirjPgpL+OpaENZrILYaXqYwnVH+qgUwVbl+pUJQ==",
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.7.2.tgz",
"integrity": "sha512-pXFZ9B2WinEPzxWkMmlYE/oYx2BP+qLrE95wP8tCuK901uLSMGdCb6QSr82z+wnhXkG4+cO+OMLbZB2Cn+97zw==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
+6 -26
View File
@@ -1,24 +1,21 @@
{
"name": "wp-asciiplayer",
"version": "1.1.0-dev",
"version": "1.2.2",
"private": true,
"description": "Native WordPress asciicast block with real playback previews and compatible shortcodes",
"type": "module",
"license": "GPL-3.0-only",
"engines": {
"node": "^24.18.0 || >=26.0.0",
"npm": ">=11.16.0"
"node": ">=22.22.2"
},
"scripts": {
"build": "wp-scripts build --config webpack.config.cjs && node scripts/vendor.mjs && npm run i18n && node scripts/verify-build.mjs",
"build": "wp-scripts build --config webpack.config.cjs && node scripts/vendor.mjs && node scripts/verify-build.mjs",
"start": "wp-scripts start --config webpack.config.cjs",
"test": "npm run i18n:check && node --test tests/js/*.test.js",
"test": "node --test tests/js/*.test.js",
"test:php": "php tests/php/run.php",
"test:e2e": "playwright test",
"wp-env": "wp-env",
"package": "node scripts/package.mjs",
"i18n": "node scripts/i18n.mjs",
"i18n:check": "node scripts/i18n.mjs --check"
"package": "node scripts/package.mjs"
},
"dependencies": {
"asciinema-player": "3.17.0"
@@ -26,9 +23,7 @@
"devDependencies": {
"@playwright/test": "1.64.0",
"@wordpress/env": "11.17.0",
"@wordpress/scripts": "36.1.0",
"@babel/parser": "8.0.7",
"gettext-parser": "9.1.1"
"@wordpress/scripts": "36.1.0"
},
"cssnano": {
"preset": [
@@ -39,20 +34,5 @@
}
}
]
},
"overrides": {
"copy-webpack-plugin": {
"serialize-javascript": "7.0.5"
},
"markdownlint-cli": {
"js-yaml": "5.4.3",
"smol-toml": "1.9.1"
},
"express": {
"qs": "6.16.0"
},
"simple-git": {
"@simple-git/argv-parser": "2.0.1"
}
}
}
+31 -3
View File
@@ -4,7 +4,7 @@ Tags: asciicast, asciiplayer, asciinema, terminal, block
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.0-dev
Stable tag: 1.2.2
License: GPL-3.0-only
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -53,6 +53,34 @@ No. The JavaScript, CSS and WebAssembly ship with the plugin. The previous ap_us
Existing shortcodes work in the Classic Editor. The new visual controls and inline playback preview are for the block editor.
= Which languages are included? =
== Changelog ==
English (en_US fallback) and Simplified Chinese (zh_CN) are bundled and work offline. Plugin-owned editor controls follow the WordPress user language; public pages follow the site language. Set these in Users > Profile and Settings > General. Other Chinese locales, including zh_TW, are not mapped to zh_CN. Recording output and author captions are never translated. The upstream player's own controls and help remain English.
= 1.2.2 =
* Show original cast dimensions as toolbar/sidebar placeholders without forcing overrides.
* Refresh recording metadata when the URL changes, reusing the preview request.
* Select and upload validated .cast recordings through the native Media Library.
= 1.2.1 =
* Automatically load saved recording previews without enabling playback autoplay.
* Debounce recording URL edits; retain immediate apply, retry and request cleanup.
* Add terminal Columns/Rows and reset controls to the floating block toolbar, synchronized with the collapsed sidebar panel.
= 1.2.0 =
* Add responsive display-width presets/custom lengths, left/center/right placement and captions.
* Preserve recorded terminal dimensions and resize events by default; expose optional row/column overrides.
* Isolate terminal typography and frames from common host-theme code-block styles.
* Add a local static block-inserter preview without recording requests.
= 1.1.0 =
* Add a native block with typed controls and interactive, iframe-aware preview.
* Preserve shortcode support and normalize historical parameter names and types.
* Escape output, constrain recording URLs, and filter custom styles.
* Bundle player 3.17.0 locally and add reproducible build/install ZIP tooling.
* Improve asset loading for posts, pages and render-time shortcode use.
* Add unit and real WordPress browser integration tests.
= 1.0.0 =
* Set the version attribute for resource files and add documentation.
= 0.1.0 =
* First available version; asciinema-player 3.4.0.
-84
View File
@@ -1,84 +0,0 @@
/** Deterministic gettext catalogs. English msgids are the en_US fallback. */
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { parse } from '@babel/parser';
import gettext from 'gettext-parser';
const domain = 'wp-asciiplayer';
const version = JSON.parse(fs.readFileSync('package.json')).version;
const entries = new Map();
function add(msgid, context, file, line) {
assert.equal(typeof msgid, 'string', `Static gettext string required: ${file}:${line}`);
const key = `${context || ''}\u0004${msgid}`;
if (!entries.has(key)) entries.set(key, { msgid, msgctxt: context || undefined, msgstr: [''], comments: { reference: '' } });
const entry = entries.get(key);
entry.comments.reference += `${entry.comments.reference ? '\n' : ''}${file}:${line}`;
}
function walk(node, file) {
if (!node || typeof node !== 'object') return;
if (node.type === 'CallExpression' && ['__', '_x', '_n', '_nx'].includes(node.callee?.name)) {
const name = node.callee.name;
assert.ok(['__', '_x'].includes(name), `Add plural extraction before using ${name}: ${file}`);
const args = node.arguments;
assert.equal(args[name === '__' ? 1 : 2]?.value, domain, `Explicit textdomain required: ${file}`);
assert.equal(args[0]?.type, 'StringLiteral', `Literal gettext message required: ${file}`);
if (name === '_x') assert.equal(args[1]?.type, 'StringLiteral');
add(args[0].value, name === '_x' ? args[1].value : '', file, node.loc.start.line);
}
for (const value of Object.values(node)) {
if (Array.isArray(value)) for (const child of value) walk(child, file);
else if (value && typeof value === 'object') walk(value, file);
}
}
for (const file of fs.readdirSync('src').filter((name) => name.endsWith('.js')).map((name) => `src/${name}`)) {
walk(parse(fs.readFileSync(file, 'utf8'), { sourceType: 'module', plugins: ['jsx'] }), file);
}
for (const file of ['asciicast-player.php', ...fs.readdirSync('includes').filter((name) => name.endsWith('.php')).map((name) => `includes/${name}`)]) {
const source = fs.readFileSync(file, 'utf8');
const calls = [...source.matchAll(/\b__\s*\(/g)];
const matches = [...source.matchAll(/\b__\(\s*'((?:\\.|[^'\\])*)'\s*,\s*'wp-asciiplayer'\s*\)/g)];
assert.equal(matches.length, calls.length, `Unsupported PHP gettext syntax in ${file}; extend extractor first.`);
assert.ok(!/\b(?:_x|_n|_nx|_e|esc_html__|esc_attr__)\s*\(/.test(source), `Extend PHP extractor for new gettext functions: ${file}`);
for (const match of matches) add(match[1].replace(/\\(['\\])/g, '$1'), '', file, source.slice(0, match.index).split('\n').length);
}
const pluginHeader = fs.readFileSync('asciicast-player.php', 'utf8');
for (const label of ['Plugin Name', 'Description']) {
const value = pluginHeader.match(new RegExp(` \* ${label}: (.+)`))?.[1];
if (value) add(value, '', 'asciicast-player.php', 1);
}
const metadata = JSON.parse(fs.readFileSync('block.json'));
for (const [field, context] of [['title', 'block title'], ['description', 'block description'], ['keywords', 'block keyword']]) {
for (const value of [].concat(metadata[field])) add(value, context, 'block.json', 1);
}
const headers = { 'Project-Id-Version': `${domain} ${version}`, 'MIME-Version': '1.0', 'Content-Type': 'text/plain; charset=UTF-8', 'Content-Transfer-Encoding': '8bit', 'X-Domain': domain };
const pot = { charset: 'utf-8', headers, translations: { '': {} } };
for (const entry of [...entries.values()].sort((a, b) => `${a.msgctxt || ''}\u0004${a.msgid}`.localeCompare(`${b.msgctxt || ''}\u0004${b.msgid}`, 'en'))) {
const context = entry.msgctxt || '';
(pot.translations[context] ||= {})[entry.msgid] = entry;
}
fs.mkdirSync('languages', { recursive: true });
const output = new Map([['languages/wp-asciiplayer.pot', gettext.po.compile(pot)]]);
if (!process.argv.includes('--pot-only')) {
const po = gettext.po.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN.po'));
assert.equal(po.headers.Language, 'zh_CN');
assert.match(po.headers['Plural-Forms'], /^nplurals=1;\s*plural=0;$/);
const messages = { '': { domain, lang: 'zh_CN', 'plural-forms': 'nplurals=1; plural=0;' } };
for (const entry of entries.values()) {
const translation = po.translations[entry.msgctxt || '']?.[entry.msgid];
assert.ok(translation?.msgstr?.[0], `Missing zh_CN translation: ${entry.msgid}`);
assert.ok(!translation.comments?.flag?.includes('fuzzy'), `Fuzzy translation: ${entry.msgid}`);
assert.ok(!translation.msgid_plural && translation.msgstr.length === 1, `Unexpected plural: ${entry.msgid}`);
const placeholders = (text) => [...text.matchAll(/%(?:\d+\$)?[sdif]/g)].map((match) => match[0]).sort();
assert.deepEqual(placeholders(translation.msgstr[0]), placeholders(entry.msgid), `Placeholder mismatch: ${entry.msgid}`);
messages[entry.msgctxt ? `${entry.msgctxt}\u0004${entry.msgid}` : entry.msgid] = translation.msgstr;
}
output.set('languages/wp-asciiplayer-zh_CN.mo', gettext.mo.compile(po));
const json = `${JSON.stringify({ domain, locale_data: { messages } }, null, 2)}\n`;
for (const handle of ['lamgc-asciiplayer-editor', 'lamgc-asciiplayer-view']) output.set(`languages/wp-asciiplayer-zh_CN-${handle}.json`, json);
}
for (const [file, content] of output) {
if (process.argv.includes('--check')) assert.deepEqual(fs.readFileSync(file), Buffer.from(content), `Stale catalog: ${file}; run npm run i18n.`);
else fs.writeFileSync(file, content);
}
console.log(`Verified ${entries.size} gettext entries; ${output.size} reproducible artifacts${process.argv.includes('--check') ? ' checked' : ' written'}.`);
+2 -3
View File
@@ -4,8 +4,7 @@ import path from 'node:path';
import os from 'node:os';
const root = path.resolve(import.meta.dirname, '..');
execFileSync(process.execPath, ['scripts/i18n.mjs', '--check'], { cwd: root, stdio: 'inherit' });
const required = ['build/block.json', 'build/index.js', 'build/index.asset.php', 'build/view.js', 'build/view.asset.php', 'build/player.js', 'build/player.css', 'build/runtime.asset.php', 'languages/wp-asciiplayer-zh_CN.mo', 'languages/wp-asciiplayer-zh_CN-lamgc-asciiplayer-editor.json', 'languages/wp-asciiplayer-zh_CN-lamgc-asciiplayer-view.json'];
const required = ['build/block.json', 'build/index.js', 'build/index.asset.php', 'build/view.js', 'build/view.asset.php', 'build/player.js', 'build/player.css'];
for (const file of required) await stat(path.join(root, file));
const pkg = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8'));
const php = await readFile(path.join(root, 'asciicast-player.php'), 'utf8');
@@ -13,7 +12,7 @@ const readme = await readFile(path.join(root, 'readme.txt'), 'utf8');
if (!php.includes(`Version: ${pkg.version}`) || !readme.includes(`Stable tag: ${pkg.version}`)) throw new Error('Version headers disagree.');
const temp = await mkdtemp(path.join(os.tmpdir(), 'wp-asciiplayer-package-'));
const target = path.join(temp, 'wp-asciiplayer');
const inputs = ['asciicast-player.php', 'includes', 'build', 'languages', 'LICENSE', 'licenses', 'THIRD-PARTY-NOTICES.md', 'README.md', 'README-zh.md', 'readme.txt', 'SOURCE.md', 'src', 'block.json', 'package.json', 'package-lock.json', 'webpack.config.cjs', 'babel.config.json', 'scripts'];
const inputs = ['asciicast-player.php', 'includes', 'build', 'LICENSE', 'licenses', 'THIRD-PARTY-NOTICES.md', 'README.md', 'README-zh.md', 'readme.txt', 'SOURCE.md', 'src', 'block.json', 'package.json', 'package-lock.json', 'webpack.config.cjs', 'babel.config.json', 'scripts'];
try {
await mkdir(target);
for (const file of inputs) await cp(path.join(root, file), path.join(target, file), { recursive: true });
+1 -10
View File
@@ -1,6 +1,5 @@
import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises';
import { copyFile, mkdir, readFile } from 'node:fs/promises';
import path from 'node:path';
import { createHash } from 'node:crypto';
const root = path.resolve(import.meta.dirname, '..');
const pkg = JSON.parse(await readFile(path.join(root, 'node_modules/asciinema-player/package.json'), 'utf8'));
@@ -14,11 +13,3 @@ for (const [source, destination] of [
}
await copyFile(path.join(root, 'block.json'), path.join(root, 'build/block.json'));
console.log(`Bundled local asciinema-player ${pkg.version}; no CDN is used.`);
// Content hashes avoid stale assets across successive builds of 1.1.0-dev.
const versions = [];
for (const file of ['player.js', 'player.css', 'style-index.css', 'index.css']) {
const hash = createHash('sha256').update(await readFile(path.join(root, 'build', file))).digest('hex').slice(0, 16);
versions.push(`'${file}' => '${hash}'`);
}
await writeFile(path.join(root, 'build/runtime.asset.php'), `<?php return array(${versions.join(', ')});\n`);
+2 -4
View File
@@ -135,10 +135,6 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
<SelectControl label={ __( 'Fit', 'wp-asciiplayer' ) } value={ fit } options={ fitOptions } help={ [ 'height', 'both' ].includes( fit ) ? __( 'Height-based fitting requires a fixed container height in your site CSS.', 'wp-asciiplayer' ) : undefined } onChange={ ( value ) => setAttributes( { fit: value } ) } />
{ attributes.legacyStyle && <p>{ __( 'The custom container style from your shortcode is preserved on the published page.', 'wp-asciiplayer' ) }</p> }
</PanelBody>
<PanelBody title={ __( 'Help', 'wp-asciiplayer' ) } initialOpen={ false }>
<p className="asciiplayer-editor__privacy">{ __( 'A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.', 'wp-asciiplayer' ) }</p>
<p className="asciiplayer-editor__hint">{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }</p>
</PanelBody>
</InspectorControls>
<div { ...blockProps }>
<div className="asciiplayer-editor__source">
@@ -152,6 +148,7 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
) } />
</MediaUploadCheck>
{ mediaError && <Notice status="error" isDismissible={ false }>{ __( 'Choose an Asciicast (.cast) file from the Media Library.', 'wp-asciiplayer' ) }</Notice> }
<p className="asciiplayer-editor__privacy">{ __( 'A valid recording URL loads its preview automatically, including when reopening this editor. That server receives your browser’s request. Published players contact the same server. Use a direct .cast URL; external servers must allow CORS.', 'wp-asciiplayer' ) }</p>
{ urlError && <Notice status="error" isDismissible={ false }>{ __( 'Enter an HTTP(S) recording URL or a path starting with a single /.', 'wp-asciiplayer' ) }</Notice> }
</div>
<figure className={ `asciiplayer-figure asciiplayer-align-${ placement }` } style={ { width: normalizeWidth( width ) } }>
@@ -164,6 +161,7 @@ export default function Edit( { attributes, setAttributes, isSelected } ) {
) }
<RichText tagName="figcaption" className={ `wp-element-caption${ ! isSelected && ! caption ? ' asciiplayer-caption-empty' : '' }` } value={ caption } allowedFormats={ [] } onChange={ ( value ) => setAttributes( { caption: value } ) } placeholder={ __( 'Add a caption…', 'wp-asciiplayer' ) } aria-label={ __( 'Recording caption', 'wp-asciiplayer' ) } />
</figure>
{ showPreview && <p className="asciiplayer-editor__hint">{ __( 'Use the player controls to play, pause, and seek. Autoplay is disabled only in the editor.', 'wp-asciiplayer' ) }</p> }
{ [ 'height', 'both' ].includes( fit ) && <p className="asciiplayer-editor__hint">{ __( 'Height-based previews use the shortcode’s fixed height when available, or a 320px editor frame. Published height still comes from your container style.', 'wp-asciiplayer' ) }</p> }
</div>
</>
-4
View File
@@ -2,7 +2,6 @@ import { createBlock, registerBlockType } from '@wordpress/blocks';
import { next } from '@wordpress/shortcode';
import { decodeEntities } from '@wordpress/html-entities';
import metadata from '../block.json';
import { _x } from '@wordpress/i18n';
import Edit from './edit.js';
import { attributesFromShortcode, canTransformShortcode, normalizeSource } from './options.js';
import './style.css';
@@ -15,9 +14,6 @@ function matchShortcodeBlock( text = '' ) {
registerBlockType( metadata.name, {
...metadata,
title: _x( 'Asciicast Player', 'block title', 'wp-asciiplayer' ),
description: _x( 'Embed and preview a terminal recording with the locally bundled asciinema player.', 'block description', 'wp-asciiplayer' ),
keywords: [ _x( 'asciinema', 'block keyword', 'wp-asciiplayer' ), _x( 'terminal', 'block keyword', 'wp-asciiplayer' ), _x( 'recording', 'block keyword', 'wp-asciiplayer' ) ],
edit: Edit,
save: () => null,
transforms: {
-15
View File
@@ -16,9 +16,6 @@ npm run package
mkdir -p .wp-env-uploads
npm run wp-env -- start
npm run wp-env -- run cli wp plugin install /var/www/html/wp-content/asciiplayer-packages/wp-asciiplayer.zip --activate --force
npm run wp-env -- run cli wp language core install zh_CN
npm run wp-env -- run cli wp site switch-language en_US
npm run wp-env -- run cli wp user meta update admin locale en_US
npx --no-install playwright install chromium
npm run test:e2e
npm run wp-env -- stop
@@ -91,15 +88,3 @@ overrides, URL replacement, error/empty states and recorded resize events.
The Media Library tests use actual isolated WordPress upload dialogs to upload
validated fixtures, reject malformed casts, cancel/reopen and select an existing
recording. No production-site media is accessed.
## Plugin localization
Five `@i18n` cases set real site and user languages via the authenticated WordPress
REST API, covering all en_US/zh_CN combinations and site-default inheritance.
They verify bundled PHP upload errors, editor metadata and controls, recoverable
preview errors, and logged-in/anonymous frontend messages. Author captions and
actual recording content remain unchanged, and upstream player controls stay
English. Original site/user locale values are restored after each test.
Run these only against the isolated test site, with zh_CN installed first.
CI runs the existing English suite before the locale suite and retains separate
reports/screenshots. No catalog data is injected into the browser by the tests.
+2 -15
View File
@@ -267,21 +267,8 @@ test('a saved Recording URL loads once without a click and never autoplays in th
await readyPreview(block);
await expect(block.getByRole('button', { name: 'Load preview', exact: true })).toHaveCount(0);
await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible();
await expect(block.locator('.asciiplayer-editor__privacy')).toHaveCount(0);
await expect(block.locator(':scope > .asciiplayer-editor__hint')).toHaveCount(0);
await expect(block.getByRole('textbox', { name: 'Recording URL', exact: true })).toBeVisible();
await expect(block.getByRole('button', { name: 'Choose recording', exact: true })).toBeVisible();
await expect(block.locator('figcaption[contenteditable="true"]')).toBeVisible();
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
const helpToggle = page.locator('.components-panel__body-toggle').filter({ hasText: /^Help$/ });
await expect(helpToggle).toHaveAttribute('aria-expanded', 'false');
await helpToggle.click();
const help = page.locator('.components-panel__body').filter({ has: helpToggle });
await expect(help.locator('.asciiplayer-editor__privacy')).toContainText(/automatic/i);
await expect(help.locator('.asciiplayer-editor__privacy')).toContainText(/server/i);
await expect(help).toContainText('Use the player controls to play, pause, and seek.');
await helpToggle.click();
await expect(helpToggle).toHaveAttribute('aria-expanded', 'false');
await expect(block.locator('.asciiplayer-editor__privacy')).toContainText(/automatic/i);
await expect(block.locator('.asciiplayer-editor__privacy')).toContainText(/server/i);
await page.waitForTimeout(750); // Catch a second fetch from a pending debounce.
expect(requests).toEqual([source]);
await expect(block.locator('.ap-overlay-start .ap-play-button')).toBeVisible();
-218
View File
@@ -1,218 +0,0 @@
import { test as base, expect } from '@playwright/test';
import { readFile } from 'node:fs/promises';
const blockName = 'lamgc/asciiplayer';
const fixturePath = '/wp-content/uploads/asciiplayer-fixtures';
const copy = {
en_US: {
title: 'Asciicast Player', source: 'Recording URL', apply: 'Apply URL',
choose: 'Choose recording', dimensions: 'Terminal size', columns: 'Columns', rows: 'Rows',
help: 'Help', retry: 'Retry preview', captionLabel: 'Recording caption',
previewError: 'Unable to load the recording. Check the URL, file format, and the source server’s CORS permissions.',
frontendError: 'Unable to load this terminal recording. The file may be unavailable, invalid, or blocked by the source server’s CORS policy.',
uploadError: 'Upload a valid Asciicast v2/v3 JSONL or pretty-printed v1 .cast recording (up to 32 MiB; v1 up to 2 MiB, 100,000 events, 256 KiB per JSONL line, and 1,000 columns or rows).',
},
zh_CN: {
title: 'Asciicast 播放器', source: '录制文件 URL', apply: '应用 URL',
choose: '选择录制文件', dimensions: '终端尺寸', columns: '列数', rows: '行数',
help: '帮助', retry: '重试预览', captionLabel: '录屏说明文字',
previewError: '无法加载录制文件。请检查 URL、文件格式及来源服务器的跨域请求(CORS)权限。',
frontendError: '无法加载此终端录屏。文件可能无法访问、格式无效,或被来源服务器的跨域请求(CORS)策略阻止。',
uploadError: '请上传有效的 Asciicast v2/v3 JSONL 或格式化的 v1 .cast 录制文件(最大 32 MiB;v1 最大 2 MiB;最多 100,000 个事件;每行 JSONL最大 256 KiB;列数和行数均不超过 1,000)。',
},
};
async function login(page) {
await page.goto('/wp-login.php');
await page.locator('#user_login').fill(process.env.WP_USERNAME || 'admin');
await page.locator('#user_pass').fill(process.env.WP_PASSWORD || 'password');
await page.locator('#wp-submit').click();
await expect(page).toHaveURL(/\/wp-admin\//);
}
async function openEditor(page) {
await page.goto('/wp-admin/post-new.php');
await page.waitForFunction((name) => Boolean(
window.wp?.apiFetch && window.wp?.blocks?.getBlockType(name) &&
window.wp?.data?.select('core/editor')?.getCurrentPostId()
), blockName);
await page.evaluate(() => {
for (const scope of ['core/edit-post', 'core/editor']) {
window.wp.data.dispatch('core/preferences').set(scope, 'welcomeGuide', false);
}
});
await expect(page.locator('iframe[name="editor-canvas"]')).toBeVisible();
}
// Change actual WordPress settings, never navigator.language or wp.i18n mocks.
// Keep an authenticated control page alive so cleanup also works if a test
// finishes on the public site or fails during a player/media interaction.
const test = base.extend({
localeSession: async ({ context }, use) => {
const control = await context.newPage();
await login(control);
await control.goto('/wp-admin/profile.php');
const language = control.locator('#locale');
await expect(language, 'Install the zh_CN core language pack before this suite.').toBeVisible();
await expect(language.locator('option[value="zh_CN"]')).toHaveCount(1);
const selectedUserLocale = await language.inputValue();
const originalUserLocale = selectedUserLocale === 'site-default' ? '' : selectedUserLocale;
await openEditor(control);
const originalSiteLocale = await control.evaluate(async () =>
(await window.wp.apiFetch({ path: '/wp/v2/settings' })).language
);
const setLocales = async (siteLocale, userLocale) => control.evaluate(async ({ site, user }) => {
const settings = await window.wp.apiFetch({ path: '/wp/v2/settings', method: 'POST', data: { language: site } });
const currentUser = await window.wp.apiFetch({ path: '/wp/v2/users/me', method: 'POST', data: { locale: user } });
return { site: settings.language || 'en_US', user: currentUser.locale };
}, { site: siteLocale, user: userLocale });
try {
await use({ setLocales, control });
} finally {
await setLocales(originalSiteLocale, originalUserLocale);
await control.close();
}
},
});
async function insertPlayer(page) {
const id = await page.evaluate((name) => {
const block = window.wp.blocks.createBlock(name, { controls: 'always' });
window.wp.data.dispatch('core/block-editor').insertBlocks(block);
window.wp.data.dispatch('core/block-editor').selectBlock(block.clientId);
return block.clientId;
}, blockName);
return page.frameLocator('iframe[name="editor-canvas"]').locator(`[data-block="${id}"]`);
}
async function assertTranslatedError(locator, locale, kind) {
// Expected strings are independent literals, never read from the loaded
// catalog: a missing translation must fail instead of defining expectations.
await expect(locator).toHaveText(copy[locale][kind]);
}
async function rejectInvalidUpload(page, block, locale, testInfo) {
await block.getByRole('button', { name: copy[locale].choose, exact: true }).click();
const dialog = page.locator('.media-modal[role="dialog"]');
await expect(dialog).toBeVisible();
await dialog.locator('#menu-item-upload').click();
const input = page.locator('.moxie-shim input[type="file"]').last();
await expect(input).toBeAttached();
const response = page.waitForResponse((result) =>
/\/wp-admin\/async-upload\.php(?:\?|$)/.test(result.url()) && result.request().method() === 'POST'
);
await input.setInputFiles({
name: `asciiplayer-locale-invalid-${Date.now()}-${testInfo.retry}.cast`,
mimeType: 'application/x-asciicast',
buffer: await readFile(new URL('../fixtures/malformed.cast', import.meta.url)),
});
const result = await (await response).json();
expect(result.success, JSON.stringify(result)).toBe(false);
expect(result.data.message).toBe(copy[locale].uploadError);
await expect(dialog).toContainText(result.data.message);
await expect(dialog.locator('.media-button-select')).toBeDisabled();
await dialog.locator('.media-modal-close').click();
}
async function verifyFrontend(page, url, locale) {
await page.goto(url);
await expect(page.locator('html')).toHaveAttribute('lang', locale === 'zh_CN' ? /^zh-(CN|Hans)$/ : 'en-US');
const players = page.locator('.asciiplayer-container');
await expect(players).toHaveCount(3);
await assertTranslatedError(players.nth(1).locator('.asciiplayer-error'), locale, 'frontendError');
for (const index of [0, 2]) {
const player = players.nth(index);
await expect(player.locator('.ap-wrapper')).toBeVisible();
await player.locator('.ap-overlay-start .ap-play-button').click();
await expect(player.locator('.ap-term-text')).toContainText('Hello from wp-asciiplayer');
}
await expect(page.locator('.asciiplayer-figure figcaption')).toHaveText('Author caption / 作者说明');
}
test.describe('@i18n real WordPress site and user locales', () => {
// Locale is site-global. The repository config has one worker; do not run
// these cases concurrently against a shared WordPress database.
test.describe.configure({ mode: 'default' });
for (const [siteLocale, userLocale] of [
['en_US', 'en_US'], ['zh_CN', 'zh_CN'],
['zh_CN', 'en_US'], ['en_US', 'zh_CN'],
]) {
test(`site ${siteLocale}, user ${userLocale}: editor, PHP upload and public player`, async ({ page, browser, localeSession }, testInfo) => {
test.setTimeout(150_000);
const locales = await localeSession.setLocales(siteLocale, userLocale);
expect(locales).toEqual({ site: siteLocale, user: userLocale });
const ui = copy[userLocale];
const pageErrors = [];
page.on('pageerror', (error) => pageErrors.push(error.message));
await openEditor(page);
await expect(page.locator('html')).toHaveAttribute('lang', userLocale === 'zh_CN' ? /^zh-(CN|Hans)$/ : 'en-US');
expect(await page.evaluate((name) => window.wp.blocks.getBlockType(name).title, blockName)).toBe(ui.title);
const block = await insertPlayer(page);
const source = block.getByRole('textbox', { name: ui.source, exact: true });
await expect(source).toBeVisible();
await expect(block.getByRole('button', { name: ui.apply, exact: true })).toBeVisible();
await expect(block.getByRole('button', { name: ui.choose, exact: true })).toBeVisible();
await expect(block.locator('figcaption[contenteditable="true"]')).toHaveAttribute('aria-label', ui.captionLabel);
await page.evaluate(() => window.wp.data.dispatch('core/edit-post').openGeneralSidebar('edit-post/block'));
await page.locator('.components-panel__body-toggle').filter({ hasText: new RegExp(`^${ui.dimensions}$`) }).click();
await expect(page.getByRole('spinbutton', { name: ui.columns, exact: true })).toBeVisible();
await expect(page.getByRole('spinbutton', { name: ui.rows, exact: true })).toBeVisible();
await expect(page.locator('.components-panel__body-toggle').filter({ hasText: new RegExp(`^${ui.help}$`) })).toBeVisible();
const valid = new URL(`${fixturePath}/hello.cast`, page.url()).href;
const missing = new URL(`${fixturePath}/missing-i18n.cast`, page.url()).href;
await source.fill(missing);
await block.getByRole('button', { name: ui.apply, exact: true }).click();
await expect(block.locator('.asciiplayer-editor__preview')).toHaveAttribute('data-preview-status', 'error');
await assertTranslatedError(block.locator('.components-notice__content > p'), userLocale, 'previewError');
await expect(block.getByRole('button', { name: ui.retry, exact: true })).toBeVisible();
await source.fill(valid);
await block.getByRole('button', { name: ui.apply, exact: true }).click();
await expect(block.locator('.asciiplayer-editor__preview')).toHaveAttribute('data-preview-status', 'ready');
await block.locator('.ap-overlay-start .ap-play-button').click();
await expect(block.locator('.ap-term-text')).toContainText('Hello from wp-asciiplayer');
// Upstream 3.17.0 has no localization API. Its unmodified controls
// deliberately retain their English accessibility labels in both locales.
await expect(block.locator('.ap-playback-button')).toHaveAttribute('aria-label', 'Pause');
await block.locator('.ap-playback-button').click();
await expect(block.locator('.ap-playback-button')).toHaveAttribute('aria-label', 'Play');
await rejectInvalidUpload(page, block, userLocale, testInfo);
const editorShot = testInfo.outputPath(`editor-${siteLocale}-${userLocale}.png`);
await page.screenshot({ path: editorShot, fullPage: true });
await testInfo.attach('editor-locale', { path: editorShot, contentType: 'image/png' });
const saved = await page.evaluate(async ({ name, good, bad }) => {
const blockContent = window.wp.blocks.serialize(window.wp.blocks.createBlock(name, {
source: good, controls: 'always', preload: true, caption: 'Author caption / 作者说明',
}));
return window.wp.apiFetch({ path: '/wp/v2/posts', method: 'POST', data: {
title: `Asciiplayer locale integration ${Date.now()}`, status: 'publish',
content: `${blockContent}\n[asciiplayer preload="true"]${bad}[/asciiplayer]\n[asciiplayer preload="true"]${good}[/asciiplayer]`,
} });
}, { name: blockName, good: valid, bad: missing });
// A logged-in user's language must not leak into public frontend JS.
await verifyFrontend(page, saved.link, siteLocale);
const anonymous = await browser.newContext();
try {
const visitor = await anonymous.newPage();
visitor.on('pageerror', (error) => pageErrors.push(error.message));
await verifyFrontend(visitor, saved.link, siteLocale);
const frontendShot = testInfo.outputPath(`frontend-${siteLocale}-${userLocale}.png`);
await visitor.screenshot({ path: frontendShot, fullPage: true });
await testInfo.attach('frontend-locale', { path: frontendShot, contentType: 'image/png' });
} finally {
await anonymous.close();
}
expect(pageErrors).toEqual([]);
});
}
test('a user with the site default language inherits zh_CN in the editor', async ({ page, localeSession }) => {
expect(await localeSession.setLocales('zh_CN', '')).toEqual({ site: 'zh_CN', user: 'zh_CN' });
await openEditor(page);
expect(await page.evaluate((name) => window.wp.blocks.getBlockType(name).title, blockName)).toBe(copy.zh_CN.title);
const block = await insertPlayer(page);
await expect(block.getByRole('textbox', { name: copy.zh_CN.source, exact: true })).toBeVisible();
});
});
-49
View File
@@ -1,49 +0,0 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import gettext from 'gettext-parser';
const po = gettext.po.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN.po'));
const mo = gettext.mo.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN.mo'));
const pot = gettext.po.parse(fs.readFileSync('languages/wp-asciiplayer.pot'));
const editor = JSON.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN-lamgc-asciiplayer-editor.json')).locale_data.messages;
const view = JSON.parse(fs.readFileSync('languages/wp-asciiplayer-zh_CN-lamgc-asciiplayer-view.json')).locale_data.messages;
test('all extracted strings and gettext contexts round-trip through MO and both script catalogs', () => {
let count = 0;
for (const [context, entries] of Object.entries(pot.translations)) {
for (const entry of Object.values(entries)) {
if (!entry.msgid) continue;
count++;
const translated = po.translations[context][entry.msgid].msgstr;
assert.ok(translated[0]);
assert.deepEqual(mo.translations[context][entry.msgid].msgstr, translated);
const key = context ? `${context}\u0004${entry.msgid}` : entry.msgid;
assert.deepEqual(editor[key], translated);
assert.deepEqual(view[key], translated);
}
}
assert.ok(count >= 75);
});
test('catalogs use Chinese plural rules, exact locale, and standard WordPress textdomain', () => {
assert.equal(po.headers.Language, 'zh_CN');
assert.equal(mo.headers.Language, 'zh_CN');
assert.equal(po.headers['Plural-Forms'], 'nplurals=1; plural=0;');
assert.equal(mo.headers['Plural-Forms'], 'nplurals=1; plural=0;');
assert.equal(pot.headers['Project-Id-Version'], `wp-asciiplayer ${JSON.parse(fs.readFileSync('package.json')).version}`);
assert.equal(pot.headers['Content-Type'], 'text/plain; charset=utf-8');
assert.equal(editor[''].lang, 'zh_CN');
assert.equal(editor[''].domain, 'wp-asciiplayer');
assert.equal(editor['']['plural-forms'], 'nplurals=1; plural=0;');
assert.equal(editor['block title\u0004Asciicast Player'][0], 'Asciicast 播放器');
assert.equal(editor['Recording URL'][0], '录制文件 URL');
});
test('Unicode, punctuation, percentages and literal author content are preserved', () => {
assert.equal(editor['Add a caption…'][0], '添加说明文字…');
assert.match(editor['Use a CSS length, such as 480px or 65%. The player stays within its available space.'][0], /480px.*65%/);
assert.equal(editor['Author caption / 作者说明'], undefined);
const serialized = JSON.stringify(editor);
assert.deepEqual(JSON.parse(serialized), editor);
});
-37
View File
@@ -1,37 +0,0 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const SimpleGit = require('simple-git');
const requireFromGit = createRequire(require.resolve('simple-git'));
const { vulnerabilityCheck } = requireFromGit('@simple-git/argv-parser');
test('wp-env CommonJS simple-git API remains callable with the scoped parser update', async () => {
assert.equal(typeof SimpleGit, 'function');
const git = SimpleGit({ baseDir: process.cwd() });
assert.equal(await git.checkIsRepo(), true);
assert.equal((await git.raw(['rev-parse', '--is-inside-work-tree'])).trim(), 'true');
});
test('git argument parser rejects unsafe editor and configuration inputs without executing them', () => {
assert.deepEqual(vulnerabilityCheck(['status'], {}), []);
for (const [args, env, category] of [
[['commit'], { VISUAL: 'untrusted-editor' }, 'allowUnsafeEditor'],
[['-c', 'trailer.test.cmd=untrusted-command', 'log'], {}, 'allowUnsafeCommandBinaries'],
[['-c', 'include.path=/untrusted/config', 'status'], {}, 'allowUnsafeInclude'],
]) {
assert.ok(vulnerabilityCheck(args, env).some((finding) => finding.category === category));
}
});
test('git argument parser accepts wp-env download command shapes', () => {
// Validate parser inputs only; these commands are never executed by this test.
for (const args of [
['clone', 'https://github.com/WordPress/wordpress-develop.git', '/tmp/wp-example', '--depth', '1', '--filter', 'blob:none', '--no-checkout'],
['fetch', 'origin', 'trunk', '--depth', '1'],
['checkout', 'trunk'],
['reset', '--hard', 'FETCH_HEAD'],
['sparse-checkout', 'set', '--cone', 'tests/phpunit'],
]) assert.deepEqual(vulnerabilityCheck(args, {}), []);
});
-6
View File
@@ -20,12 +20,6 @@ function add_action( $hook, $callback, $priority = 10 ) {
function add_filter( $hook, $callback, $priority = 10, $accepted_args = 1 ) {
ap_record( 'filters', array( $hook, $callback, $priority, $accepted_args ) );
}
function load_plugin_textdomain( $domain, $deprecated, $path ) {
ap_record( 'textdomains', array( $domain, $path ) );
}
function plugin_basename( $file ) {
return 'wp-asciiplayer/asciicast-player.php';
}
function __( $text, $domain = 'default' ) {
return $text;
}
+2 -10
View File
@@ -48,14 +48,6 @@ try {
same( true, is_callable( $action[1] ), 'Every registered callback is callable.' );
}
register_plugin();
same( array( 'wp-asciiplayer', 'wp-asciiplayer/languages' ), $GLOBALS['ap_test']['textdomains'][0], 'Bundled PHP catalogs register during init.' );
if ( file_exists( dirname( __DIR__, 2 ) . '/build/runtime.asset.php' ) ) {
$versions = require dirname( __DIR__, 2 ) . '/build/runtime.asset.php';
same( $versions['player.js'], $GLOBALS['ap_test']['scripts']['lamgc-asciiplayer-player']['version'], 'Player script uses its content hash.' );
foreach ( array( 'lamgc-asciiplayer-player-style' => 'player.css', 'lamgc-asciiplayer-style' => 'style-index.css', 'lamgc-asciiplayer-editor-style' => 'index.css' ) as $handle => $file ) {
same( $versions[ $file ], $GLOBALS['ap_test']['styles'][ $handle ]['version'], 'Each stylesheet uses its own content hash.' );
}
}
same( 'asciiplayer', $GLOBALS['ap_test']['shortcodes'][0][0], 'Legacy shortcode stays registered.' );
contains( '/build', $GLOBALS['ap_test']['blocks'][0]['path'], 'Block uses local metadata.' );
same( 'LamGC\\Asciiplayer\\render_block', $GLOBALS['ap_test']['blocks'][0]['args']['render_callback'], 'Block is server rendered.' );
@@ -68,8 +60,8 @@ try {
same( array( 'lamgc-asciiplayer-player-style' ), $GLOBALS['ap_test']['styles']['lamgc-asciiplayer-style']['deps'], 'Frontend style depends on player stylesheet.' );
contains( 'window.wpAsciiplayerSettings = ', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Editor iframe receives trusted runtime URLs.' );
same( 'before', $GLOBALS['ap_test']['inline_scripts'][0]['position'], 'Settings are available before editor boot.' );
contains( 'player.js?ver=' . $GLOBALS['ap_test']['scripts']['lamgc-asciiplayer-player']['version'], $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge JavaScript cache-buster matches registered asset version.' );
contains( 'player.css?ver=' . $GLOBALS['ap_test']['styles']['lamgc-asciiplayer-player-style']['version'], $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge CSS cache-buster matches registered asset version.' );
contains( 'player.js?ver=1.2.2', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge JavaScript cache-buster matches registered asset version.' );
contains( 'player.css?ver=1.2.2', $GLOBALS['ap_test']['inline_scripts'][0]['source'], 'Bridge CSS cache-buster matches registered asset version.' );
// Source validation covers script, HTML, credential and relative-URL attacks.
foreach ( array( '', 'javascript:alert(1)', 'data:text/html,test', 'file:///tmp/a.cast', '//evil.test/a.cast', '/\\evil.test/a.cast', "https://example.test/a\n.cast", 'https://x.test/" onmouseover="alert(1)', 'https://user:[email protected]/a.cast', 'https:///a.cast', 'a.cast', array( 'bad' ) ) as $source ) {