mirror of
https://github.com/LamGC/wp-asciiplayer.git
synced 2026-11-26 20:55:48 +00:00
Refresh wp-asciiplayer with native block editor playback (#36)
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
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
* 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. * Fix emitted frontend boot and verify bundled runtime initialization * Record verified WordPress 7.1.3 compatibility * Use WordPress readme major-version compatibility format * Add responsive player layout, captions and native terminal sizing * Keep editor caption geometry stable during block selection * Respect WordPress editor gutters with border-box sizing * Improve automatic previews and toolbar terminal sizing (1.2.1) * Show native cast dimensions and add Media Library recordings (1.2.2) * Fix Media Library test storage and scope sidebar selectors * Document bounded temporary-upload stream exceptions * Move block explanations into collapsed sidebar help (1.2.3) * Add bundled English and Simplified Chinese UI translations (1.1.0-dev) * Use native RichText labels and supported Chinese HTML language tags in locale tests
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { runInNewContext } from 'node:vm';
|
||||
import assert from 'node:assert/strict';
|
||||
const hash = (data) => createHash('sha256').update(data).digest('hex');
|
||||
const asset = await readFile('build/index.asset.php', 'utf8');
|
||||
if (asset.includes('react-jsx-runtime')) throw new Error('Automatic JSX runtime would break the WordPress 6.3 baseline.');
|
||||
for (const dependency of ['wp-blocks', 'wp-block-editor', 'wp-element', 'wp-compose']) {
|
||||
if (!asset.includes(`'${dependency}'`)) throw new Error(`Missing editor dependency: ${dependency}`);
|
||||
}
|
||||
for (const [destination, original] of [
|
||||
['build/player.js', 'node_modules/asciinema-player/dist/bundle/asciinema-player.min.js'],
|
||||
['build/player.css', 'node_modules/asciinema-player/dist/bundle/asciinema-player.css'],
|
||||
]) {
|
||||
if (hash(await readFile(destination)) !== hash(await readFile(original))) throw new Error(`Vendor file mismatch: ${destination}`);
|
||||
}
|
||||
const metadata = JSON.parse(await readFile('build/block.json', 'utf8'));
|
||||
if (metadata.apiVersion !== 3 || metadata.name !== 'lamgc/asciiplayer') throw new Error('Unexpected block metadata.');
|
||||
// Execute the emitted bundle too: source-only tests miss minifier scope errors.
|
||||
// In particular, never shadow the global document used by mountPlayers' default.
|
||||
const view = await readFile('build/view.js', 'utf8');
|
||||
for (const readyState of ['loading', 'complete']) {
|
||||
let mounts = 0;
|
||||
let onReady;
|
||||
const container = {
|
||||
dataset: { apSrc: '/recording.cast', apOptions: '{"preload":false}' },
|
||||
};
|
||||
const document = {
|
||||
readyState,
|
||||
body: { classList: { contains: () => false } },
|
||||
querySelector: () => null,
|
||||
querySelectorAll: () => [container],
|
||||
addEventListener(event, callback) {
|
||||
assert.equal(event, 'DOMContentLoaded');
|
||||
onReady = callback;
|
||||
},
|
||||
defaultView: { AsciinemaPlayer: { create(source, target) {
|
||||
assert.equal(source, '/recording.cast');
|
||||
assert.equal(target, container);
|
||||
mounts++;
|
||||
return { addEventListener() {} };
|
||||
} } },
|
||||
};
|
||||
runInNewContext(view, { document, window: { wp: { i18n: { __: (text) => text } } }, URL });
|
||||
if (readyState === 'loading') {
|
||||
assert.equal(mounts, 0);
|
||||
onReady();
|
||||
onReady(); // A repeated boot must not mount the same container twice.
|
||||
}
|
||||
assert.equal(mounts, 1, `Frontend boot failed at readyState=${readyState}`);
|
||||
assert.equal(container.dataset.apStatus, 'idle');
|
||||
}
|
||||
console.log('Verified WordPress 6.3 dependencies, block metadata, exact vendor files, and emitted frontend boot.');
|
||||
|
||||
// Physical placement and terminal direction must not be mirrored by RTLCSS.
|
||||
for (const suffix of ['', '-rtl']) {
|
||||
const css = await readFile(`build/style-index${suffix}.css`, 'utf8');
|
||||
assert.match(css, /asciiplayer-align-left\{[^}]*margin-left:0!important[^}]*margin-right:auto!important/);
|
||||
assert.match(css, /asciiplayer-align-right\{[^}]*margin-left:auto!important[^}]*margin-right:0!important/);
|
||||
assert.match(css, /asciiplayer-container \.ap-wrapper\{text-align:left/);
|
||||
}
|
||||
Reference in New Issue
Block a user