Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
85d533a
build(deps): add pinned @videojs/* 10.0.1 and vitest
b-l-i-n-d Oct 11, 2026
f05b096
build(player): emit the player engine as an ES module entry
b-l-i-n-d Oct 11, 2026
761f990
docs(player): add migration plan, ADRs, and glossary
b-l-i-n-d Oct 11, 2026
9f93efa
chore(player): add migration map and tickets
b-l-i-n-d Oct 11, 2026
8dcc81a
feat(player): enqueue the player engine as type=module
b-l-i-n-d Oct 11, 2026
6ca120a
docs(player): record ticket 02 fullscreen spike outcome
b-l-i-n-d Oct 11, 2026
5de54c8
docs(player): note YouTube branding crop for the new player
b-l-i-n-d Oct 11, 2026
90bbb23
feat(player): add shared player types and free TutorCore.player
b-l-i-n-d Oct 11, 2026
befda77
docs(player): record ticket 03 resolution
b-l-i-n-d Oct 11, 2026
7672568
refactor(player): type event payloads by event name
b-l-i-n-d Oct 11, 2026
9bd5dd1
refactor(player): align shared player contract with the migration plan
b-l-i-n-d Oct 11, 2026
13b102d
feat(player): implement the video.js engine behind TutorCore.player
b-l-i-n-d Oct 11, 2026
051ea1a
test(player): add vitest and unit tests for the engine
b-l-i-n-d Oct 11, 2026
2060a80
style(player): size and crop embed media in the video.js player
b-l-i-n-d Oct 11, 2026
5d04e1d
docs(player): record ticket 04 engine outcome
b-l-i-n-d Oct 11, 2026
69a6144
feat(player): rewrite lesson playback over TutorCore.player
b-l-i-n-d Oct 11, 2026
59d92f1
test(player): cover lesson playback controller with a fake handle
b-l-i-n-d Oct 11, 2026
81a0836
docs(player): record ticket 05 outcome
b-l-i-n-d Oct 11, 2026
08adada
feat(player): wire lesson playback to the engine on learning-area pages
b-l-i-n-d Oct 11, 2026
415e664
feat(player): route legacy lesson and course-intro playback through t…
b-l-i-n-d Oct 11, 2026
f32dca2
feat(player): rebuild the Alpine player component on the engine
b-l-i-n-d Oct 11, 2026
adcdefa
feat(player): add deprecated TutorLessonPlayer compat adapter
b-l-i-n-d Oct 11, 2026
db6db5b
test(player): add e2e coverage for the lesson video engine
b-l-i-n-d Oct 11, 2026
a582354
chore(player): delete Plyr assets, types and styles
b-l-i-n-d Oct 11, 2026
8f35fe9
chore(player): stop enqueuing Plyr on lesson pages
b-l-i-n-d Oct 11, 2026
658a227
refactor(player): simplify engine surface and drop unused APIs
b-l-i-n-d Oct 11, 2026
d346c72
style(player): match border radius with container and hide unsupporte…
b-l-i-n-d Oct 12, 2026
17f5bec
fix(player): match container border radius, support fullscreen events…
b-l-i-n-d Oct 12, 2026
aa6efde
style: force no border-radius and add aspect ratio for video player i…
b-l-i-n-d Oct 12, 2026
1b4682a
style: move Take Note button to top in fullscreen mode
b-l-i-n-d Oct 12, 2026
38a4303
style: move Take Note button to top in fullscreen for legacy view
b-l-i-n-d Oct 12, 2026
8e039f7
fix(player): hide media title, size engine hosts in legacy bundle, to…
b-l-i-n-d Oct 12, 2026
cc1e2da
fix(player): show lesson title via skin media-title in fullscreen only
b-l-i-n-d Oct 12, 2026
648ac9a
fix(player): re-sync stuck fullscreen store on vimeo echo
b-l-i-n-d Oct 12, 2026
ce818fc
fix(player): reset stale provider flag and re-sync store on fullscree…
b-l-i-n-d Oct 12, 2026
b6aca1c
docs(player): migration report with stats, trade-offs, and walkthrough
b-l-i-n-d Oct 12, 2026
8606a7f
perf(player): lazy-load YouTube/Vimeo adapters and update build/docs
b-l-i-n-d Oct 13, 2026
937cb99
Merge branch '4.2.0' into feat/videojs-migration
b-l-i-n-d Oct 14, 2026
d92ff01
feat(player): self-boot declarative engine, classic IIFE delivery
b-l-i-n-d Oct 16, 2026
fde5db5
docs(player): record stage-1 gate results and the stage-2 caller reta…
b-l-i-n-d Oct 16, 2026
3286680
docs(player): record the second stage-1 gate pass
b-l-i-n-d Oct 17, 2026
6e8634d
feat(player): declarative player markup in the video templates (stage 2)
b-l-i-n-d Oct 17, 2026
4f2e63c
fix(player): define the host element before the skin registers
b-l-i-n-d Oct 17, 2026
50c4245
Merge branch '4.2.0' into feat/videojs-migration
b-l-i-n-d Oct 17, 2026
69d16ee
fix(player): stop cropping non-16:9 YouTube embeds
b-l-i-n-d Oct 17, 2026
9de9ccc
fix(player): ignore fullscreen events from other elements
b-l-i-n-d Oct 17, 2026
b4c2c3d
test(player): lock the engine define order
b-l-i-n-d Oct 17, 2026
f349b53
docs(player): record the review fixes
b-l-i-n-d Oct 17, 2026
c5091c8
refactor(player): publish the registry on window and cut the engine f…
b-l-i-n-d Oct 17, 2026
5376515
fix(player): throttled strict mode and the legacy tooltip on the cont…
b-l-i-n-d Oct 17, 2026
db900d3
fix(player): keep an unplayable legacy element from breaking page scr…
b-l-i-n-d Oct 17, 2026
9aad94e
fix(player): enqueue the engine only on singles that have a video
b-l-i-n-d Oct 17, 2026
316cce9
fix(player): read path-form hashes from player.vimeo.com URLs
b-l-i-n-d Oct 17, 2026
d33d9c5
fix(player): emit the raw provider URLs from the video templates
b-l-i-n-d Oct 17, 2026
4ce8483
docs(player): record the review round 2 fixes
b-l-i-n-d Oct 17, 2026
21c4cb7
fix: normalize non-object tracking payload in readPlayerData
b-l-i-n-d Oct 18, 2026
9800481
docs(player): record the Video.js 10 bundle-size research
b-l-i-n-d Oct 18, 2026
914e556
perf(player): minify only the player assets in the production build
b-l-i-n-d Oct 18, 2026
6b2615f
docs: research how Elementor builds and ships its production bundles
b-l-i-n-d Oct 19, 2026
2994e74
Merge branch 'dev' into feat/videojs-migration
b-l-i-n-d Nov 10, 2026
64d8ff5
chore(player): bump videojs packages to 10.3.0
b-l-i-n-d Nov 11, 2026
35bc3b3
feat(player): detect portrait YouTube videos to preserve full aspect …
b-l-i-n-d Nov 11, 2026
cc17cd1
feat(player): add TypeScript dynamic watermark controller and templat…
b-l-i-n-d Nov 11, 2026
601d61c
refactor(player): decouple watermark from core and emit player lifecy…
b-l-i-n-d Nov 11, 2026
926f58d
chore: remove dynamic video watermark planning spec from core
b-l-i-n-d Nov 11, 2026
41562e2
fix(player): patch lifecycle leaks, service unsubscribe, error isolat…
b-l-i-n-d Nov 11, 2026
0adaba8
fix(player): resolve skin patch timing, service subscription ownershi…
b-l-i-n-d Nov 11, 2026
4344897
fix(player): serialize vimeo seek calls and suppress non-fatal seek a…
b-l-i-n-d Nov 11, 2026
9d0a7c4
fix(player): patch vimeo adapter before the element module upgrades it
b-l-i-n-d Nov 12, 2026
c860a03
refactor(player): remove legacy shim & plyr remnants, prune cypress, …
b-l-i-n-d Nov 13, 2026
10cd8d7
fix(player): smooth initial load, match border radius, and fix mobile…
b-l-i-n-d Nov 13, 2026
77277dd
fix(player): unblock vimeo seeks and finish migration review fixes
b-l-i-n-d Nov 14, 2026
ae7c1bf
style(phpcs): clear coding-standard errors in migration-touched PHP
b-l-i-n-d Nov 14, 2026
67f39ee
fix(player): keep vimeo resume seek through embed load
b-l-i-n-d Nov 14, 2026
d7f990c
fix(player): harden vimeo seek errors, filter live streams, and prese…
b-l-i-n-d Nov 14, 2026
75259a8
Merge branch 'master' of https://github.com/themeum/tutor into feat/v…
b-l-i-n-d Nov 16, 2026
7e169ba
fix(player): verify vimeo seeks and finish on seek-to-end
b-l-i-n-d Nov 18, 2026
b202b0c
Merge remote-tracking branch 'origin/4.3.0' into feat/videojs-migration
b-l-i-n-d Dec 3, 2026
2fa97e5
chore(tests): move JS unit tests and vitest config into tests/js and …
b-l-i-n-d Dec 3, 2026
9b20580
chore(build): update rspack targets and upgrade @videojs/* to 10.7.1
b-l-i-n-d Dec 3, 2026
136f8fc
chore(tests): split CI unit test jobs, add vitest reporters, and move…
b-l-i-n-d Dec 3, 2026
6f2b949
fix(ci): remove duplicate pnpm version in js-unit-tests workflow
b-l-i-n-d Dec 3, 2026
64df7a3
chore(tests): disable happy-dom child frame navigation and clean up D…
b-l-i-n-d Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,29 @@ jobs:

- name: Run Unit tests
working-directory: ${{ env.PLUGIN_DIR }}
run: pnpm test:unit
run: pnpm test:unit:php

js-unit-tests:
name: Vitest Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run Vitest unit tests
run: pnpm test:unit:js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Type: task
Status: done
Blocked by: —

## Question

Register the player service through `ComponentRegistry` instead of the hand-rolled
`Object.assign` in `assets/core/ts/services/player/index.ts` (ADR-0010, grilling Q8):

- Move `window.TutorComponentRegistry = TutorComponentRegistry` from inside
`initializePlugin()` to module scope in `assets/core/ts/index.ts`. The deferred engine
module executes before `initializePlugin` runs, so the window bridge must exist by
then. Confirm no consumer depends on the registry appearing later — existing
registrants run on `alpine:init` or later and only guard with `if`.
- Add `playerServiceMeta: ServiceMeta<PlayerService>` next to the service
(`{ name: 'player', instance }`).
- Engine `index.ts`: register via
`window.TutorComponentRegistry?.register({ type: 'service', meta: playerServiceMeta })`,
falling back to the imported registry instance when the bridge is absent; delete the
`Object.assign` exposure. `window.TutorCore.player` must be set by
`exposeToWindow` like every other service.
- Add `window.TutorComponentRegistry` typing if missing.

Verify: `tsc` / `eslint` / `rspack --mode=production` green;
`window.TutorComponentRegistry.has({ name: 'player', type: 'service' })` is true after
the engine boots; `TutorCore.player` is set on a lesson page; dashboard +
learning-area smoke (the earlier exposure must be inert).

## Outcome

Done. `window.TutorComponentRegistry = TutorComponentRegistry` moved to module scope in
`assets/core/ts/index.ts`; `playerServiceMeta` added in `PlayerService.ts`; the engine
registers via `window.TutorComponentRegistry ?? imported instance` and the `Object.assign`
exposure is deleted. Typing already existed (`declaration.d.ts:58`).

Verified: player vitest suite, `tsc`, eslint, production build green. Built
`tutor-player.js` carries the `name:"player"` meta; `tutor-core.js` sets the bridge at
module scope. Since the delivery change (ADR-0011) the engine is a classic script too:
registration uses the bridge when `tutor-core` is already loaded (learning-area pages)
and the imported instance when the engine runs first (course pages); either path exposes
`window.TutorCore.player`. Browser smoke in 04.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Type: task
Status: done
Blocked by: 01

## Question

Self-boot the declared element and move ownership to the element (ADR-0010, grilling
Q6/Q9). Templates are untouched in this ticket — today's markup must run through the
new path via the shim.

- The element creates its handle on connect (`createTutorPlayer` over its store),
exposes it as `element.player`, and registers with the service.
- Service tracks instances: `getActive()` = most recent live instance; dispose clears
the active slot; `on()` late-binds when a player appears (research F1). Public shape
frozen (`create`/`getActive`/`on`/proxies).
- `create()` becomes an idempotent "ensure a handle for legacy markup": detect →
replace with the declarative tree → element self-boots → return `element.player`
(used by the shim and the Alpine component).
- Adapter loading: subtree tag scan for `youtube-video`/`vimeo-video` → lazy import.
Keep the define-player-before-adapters order (ADR-0010 hard contract).
- The element removes a `controls` attribute if present (no-op today; the stage-2
templates keep `controls` as the no-JS fallback).
- Keep wiring injectable (fake store) so happy-dom tests stay meaningful; extend
`PlayerService.test.ts`; add element-boot tests. Decide the element ↔ service
plumbing (wired callback vs DOM event) — avoid the `elements.ts` ↔ `PlayerService.ts`
import cycle.

Verify: unit tests + `tsc` + build green; smoke learning-area lesson, legacy lesson,
course intro, Alpine path — behavior identical to pre-change.

## Outcome

Done. Plumbing decision: **wired callback** — `elements.ts` exposes
`setPlayerElementHooks({ onMount, onDispose })`, wired by the engine entry to
`playerServiceMeta.instance.track/untrack`; no `elements ↔ PlayerService` import cycle.

- `TutorVideoPlayerElement` (subclass of the vendor `PlayerElement`) boots in
`connectedCallback`: sets the default `content-title`, drops the no-JS `controls`
fallback, resolves the provider from its subtree (`resolveProvider`: embed tag scan,
then `providerFromUrl` on the native source), lazy-loads the adapter for yt/vimeo, and
creates the handle as `element.player`. `destroyCallback` releases it too, so the
vendor's two-frame auto-destroy after removal cannot leave a dead handle active.
- Service: `track`/`untrack` (dispose clears the active slot), `on()` late-binds to the
first player that appears, `create()` = detect → build tree → replace → return
`element.player` (idempotent ensure). Dependencies reduced to injectable
`createElement`.
- Adapter loading moved out of `createPlayerElement`; it now always appends the media
immediately (the deferred-append dance is gone) and the element owns the import.
Define-player-before-adapters order preserved (hard contract).
- `legacy.ts` subscribes through `service.on` and retries on `PLAYER_ENGINE_READY` when
the engine is absent (F1).

Tests: 46 in the player suite (boot/dispose/reconnect/destroy, provider resolution,
late-bind, untrack, `onDispose`); full suite 66 green. `tsc`, eslint, production build
green. Browser smoke owed in 04.
28 changes: 28 additions & 0 deletions .scratch/declarative-player/issues/03-space-reservation-css.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Type: task
Status: done
Blocked by: —

## Question

Reserve the player's space before upgrade (ADR-0010, grilling Q10) in
`assets/src/scss/frontend/components/_videojs-player.scss`:

- `tutor-video-player { display: block; width: 100%; }` + wrapper aspect-ratio so an
unupgraded element occupies the same box as the skinned player (no CLS).
- Keep the spinner visible pre-upgrade (it is removed on ready).
- Size the pre-upgrade slotted media (light-DOM `<video>` with `controls`) to fill the
reserved box.
- No `:not(:defined)` hiding.

Inert until ticket 05 ships; harmless to land early with stage 1.

Verify: throttle JS / block the player script — the reserved box renders with the spinner, no
layout shift when the engine upgrades; fullscreen + embed sizing unchanged.

## Outcome

Done. Added a standalone `tutor-video-player { display: block; width: 100%;
aspect-ratio: 16/9; overflow: hidden; }` rule plus pre-upgrade `video` sizing in
`assets/src/scss/frontend/components/_videojs-player.scss`. The `.tutor-video-player`
wrapper already reserved the box and keeps the spinner visible pre-upgrade; no
`:not(:defined)` hiding. Inert until 05 ships. Browser smoke owed in 04.
121 changes: 121 additions & 0 deletions .scratch/declarative-player/issues/04-stage1-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Type: task
Status: claimed
Blocked by: 01, 02, 03

## Question

Stage-1 gate: prove the invisible refactor changed nothing before templates move.

- `pnpm test:unit`, `tsc --noEmit`, `rspack --mode=production` green.
- Manual smoke against today's markup: learning-area lesson, legacy lesson, course
intro, Alpine component path, Pro lesson notes + Take Note fullscreen.
- Provider matrix subset: html5, external, youtube opt-in, vimeo opt-in (playback,
fullscreen, resume, strict mode, auto-next, mobile Vimeo mute).
- Record any behavioral delta. Stage 2 does not start until this passes.

## Progress

Automated half done: full vitest suite 66 green (46 in the player folder), `tsc --noEmit`
clean, eslint clean, production build green.

Delivery changed mid-gate (ADR-0002 superseded by ADR-0011): the engine is a standard
`jsEntries` IIFE entry enqueued as a classic script. The separate module config, the
`type="module"` `script_loader_tag` filter, and the namespaced `js/lazy-chunks/player/`
chunk path are deleted. The collision below was real for the two-config era and its fix
worked, but it is moot now — one config emits the adapter chunks at the standard
`js/lazy-chunks/[name].js?ver=…` path.

History, condensed:

- Both configs emitted same-named lazy chunks into `js/lazy-chunks/` — the IIFE config as
classic JSONP (its dead copy of `elements.ts` keeps the adapter dynamic imports alive)
and the player ES-module config as ES-module chunks. The JSONP copy clobbered the ESM
copy, so the engine's `import()` of `tutor-player-youtube.js` resolved to a namespace
without `__webpack_ids__` and the runtime threw.
- The earlier `jsEntries` rejection stands as an observation: folding into the IIFE config
_while still enqueuing as `type="module"`_ breaks adapter loading
(`document.currentScript` is null under `type="module"`, so the runtime's chunk base
falls back to the last http(s) script on the page — Query Monitor / MathJax — and the
chunk 404s). Fold + classic enqueue is the working pair.
- The IIFE bundles still ship a dead copy of `elements.ts` — stage-2 cleanup candidate,
unrelated to the delivery.

Verified live after the delivery change (course page + a real html5 lesson):

- Classic `<script>` tag (no `type="module"`); engine boots; `TutorCore.player` present.
- yt probe: adapter chunk 200 from the correct plugin URL; `<youtube-video>` defines;
player created. No `StoreError: NO_TARGET`, no console errors.
- Real lesson: legacy markup replaced by `<tutor-video-player>`, `video-skin` mounted,
media `readyState 4`, muted playback works and resumes from the saved position. Script
order: `tutor-core` → `tutor-learning-area` → `tutor-player`.

Manual half pending on this delivery — walk the checklist and close this ticket: four
pages (learning-area lesson, legacy lesson, course intro, Alpine path) + Pro
fullscreen/notes + provider matrix (html5, external, yt, vimeo: playback, fullscreen,
resume, strict mode, auto-next, mobile Vimeo mute).

### Verified on the new delivery (2026-10-16)

- Lesson pages `html5-4`, `vimeo-4`, `dadas-2` (course
`1-introduction-to-mindfulness-3-6-19`): classic `tutor-player.js` tag; element booted;
`TutorCore.player` present; legacy markup replaced; `video-skin` mounted;
`window.TutorLessonPlayer` set through the controller's `notifyReady`; no console errors.
- Adapter matrix: vimeo opt-in → `vimeo-video` mounts, src resolves to
`player.vimeo.com/video/336812686?…`, duration 41s; youtube opt-in → `youtube-video`
mounts, src `youtube.com/embed/YwKRJMzvQnU?…`, duration 61s; html5 → `video`
(`sample-course-video.mp4`, 10.006s). HTML5 playback + resume were proven earlier on
the saved-position lesson.

### Second pass (2026-10-17) — flips + visible window

Temporary site settings were flipped and reverted; final values verified:
`learning_mode=modern`, `course_completion_process=flexible`,
`control_video_lesson_completion=false`; user preferences untouched (`auto_play_next` was
already on). No enrollment was created — `do_enroll()` refuses the trashed course and
user 1 was already enrolled in published `#30666`.

Passed:

- Auto-next: lesson 72099 (html5, `#30666`) seeked to `duration-2` and played to the end;
the tab navigated to `…/quizzes/q1/` = that lesson's `next_id` (72431). `ended` →
`#autoloadContent()` → `autoload_next_course_content` → `openUrl` end-to-end.
- Strict mode: lesson 72795 (`course-v3`: enrolled, not completed) with
`course_completion_process=strict` + `control_video_lesson_completion=true`:
`PlayerData` carried `strict:true, control:true, enrolled:true, completed:false`;
`seek(120)` was clamped back and the toast “Forward seeking is disabled” appeared. The
handle's `on()` delivered `play`/`timeupdate` events throughout.
- Legacy lesson (`learning_mode=legacy`, same lesson): `.tutor-course-topic-single-body`
and `.tutor-video-player-wrapper` render, modern `.tutor-lesson-video-wrapper` does not;
element boots, player is created, media loads (8.1 s), console clean; the video played
to the end and the page advanced to the next content (assignment 72797). In legacy mode
the learning-area controller's `.tutor-lesson-video-wrapper .tutorPlayer` selector
matches nothing, so the player is created by the legacy path through the shim — the shim
working as designed.
- `content-title` stays empty outside fullscreen (element default), as specified. The
fullscreen wiring (`is-fullscreen` class, title set/clear, empty-title case, Vimeo exit
resync) has unit coverage in `lesson/player.test.ts`.

Notes:

- `window.TutorLessonPlayer.on()` (legacy shim) only carries `enterfullscreen` /
`exitfullscreen` by design; `play`/`pause`/`ended`/`timeupdate` come from the handle
(`TutorCore.player.create(…)`) the controller uses. Do not test event flow via the shim.

Remaining — manual pass only (cannot be driven from the harness browser):

- Fullscreen at all: `document.documentElement.requestFullscreen()` never settles (stays
pending) even after a trusted keypress grants transient activation. The skin's
fullscreen button, the real `fullscreenchange` path, the Vimeo exit resync and Pro Take
Note fullscreen need a human run in a real browser.
- YouTube playback: adapter mounts and resolves (`embed/YwKRJMzvQnU`, 61 s) but
programmatic play against the cross-origin iframe does not start — env limitation.
- Mobile Vimeo mute: no device/UA emulation available.

No test data (unchanged): external provider, course intro, Alpine path.

Test side effects (acceptable on this QA site): watch-time syncs from the playback runs on
lessons 72099/72795 and the vimeo lesson; no completion states changed.

Stage 2 landed in [05](05-declarative-templates.md) and re-ran this ladder against the
declarative markup (html5/vimeo/youtube mounts, playback + auto-next, strict clamp, legacy
lesson, shim back-compat). The manual items above stay open for both stages.
Loading
Loading