Integration strategy

6 min read · Edit this page on GitHub(opens in new tab)
Principle: the core depends on nothing. Every third-party engine or SDK sits behind a Tomato provider or plugin interface. It is installed by the user as a peer dependency and loaded with dynamic import() only when needed.

1. Decisions per library

LibraryDecisionRationalePackagingLazy-load trigger
hls.js (Apache-2.0)Reuse: optional adapter @tomato/provider-hlsDe facto HLS engine. Supports ManagedMediaSource and CMCD v1/v2 (API.md). Zero deps.peerDependencies: { "hls.js": "^1.6" } (range TBD), marked peerDependenciesMeta.optional. Offer hls.js/light as an option.Source is .m3u8 or application/vnd.apple.mpegurl, and native HLS is not preferred or not available
Shaka Player (Apache-2.0)Reuse: optional adapter @tomato/provider-shakaBest DRM, offline storage, and DASH+HLS in one engineOptional peer. Use the compiled build without Shaka UI.DRM config present, or the user picks Shaka for DASH
dash.js (BSD-3-Clause)Reuse: optional adapter @tomato/provider-dashDASH-IF reference with strong LL-DASH and CMCD/CMSDOptional peer.mpd source, when the user picks dash.js over Shaka
mpegts.js (Apache-2.0)Reuse: optional adapter (P2)Low-latency TS/FLV liveOptional peer.flv or .ts live source
SVTA @svta/cml-cmcd, cml-cmsd (Apache-2.0)Reuse inside @tomato/plugin-cmcd for native playbackA standard implementation already used by dash.jsRegular dependency of the plugin onlyPlugin import
JASSUB (MIT wrapper with LGPL-2.1+ components)Reuse: opt-in plugin @tomato/plugin-assOnly viable ASS/SSA renderer. Active.Optional peer. Never bundled into a CDN "all" build..ass or .ssa track selected
Google IMA SDK (proprietary)Reuse: adapter, loaded at runtimeMarket default for VAST/VMAP/DAIInject the script from Google's URL //imasdk.googleapis.com/js/sdkloader/ima3.js as the setup guide shows. Types come from @types/google_interactive_media_ads_types. Never vendor the SDK; no self-host permission was found.Ads plugin requestAds()
Google Cast Web Sender (proprietary)Reuse: adapter, loaded at runtimeOnly path to ChromecastLoad from Google's CDN per docsCast button visible and Cast available
Video.js v10Learn from, and stay interoperableSame architecture thesis. Do not fork. Study its feature-slice store, presets and shadcn eject (beta post).n/an/a
Media Chrome / Mux ElementsLearn from the "custom element implements HTMLMediaElement" pattern. Consider supporting any element that implements this contract, e.g. <hls-video> and <mux-video>.Lets Tomato skins wrap third-party media elements for freen/a. Optional compatibility: accept any HTMLMediaElement-like element.n/a
Vidstack, PlyrLearn from, then target for migrationDeprecated. Their users need a home. Write codemods and API maps.n/an/a
media-captionsLearn from or fork under MIT with attributionStale since 2024Vendor only with its MIT notice keptn/a
ReactPlayerLearn from its lazy per-provider loadingGood pattern for YouTube, Vimeo and other embed providersn/an/a
Clappr, OvenPlayer, xgplayer, Artplayer, Fluid Player, MediaElement.jsAvoid as deps. Mine for features: danmaku and thumbnails from Artplayer, VAST without IMA from Fluid.Monolithic or heavy, or tied to one vendor or servern/an/a
flv.js, libass-wasm, @eyevinn/cmcd, @silvermine/videojs-chromecast, castable-videoAvoidStale or archived (see landscape.md)n/an/a

2. Peer dependency vs bundled

OptionUse whenTomato default
Optional peer depLarge engines users may already have, or need to pin for security or DRM fixeshls.js, Shaka, dash.js, mpegts.js, JASSUB
Regular dependencySmall, internal-only, version-locked utilities@svta/cml-* inside the CMCD plugin
Runtime script injectionProprietary SDKs that are not on npm, or must come from the vendorIMA, Cast
Bundled in CDN buildCDN users want one URLCDN "core+skin" only. Engines stay separate CDN files (tomato.hls.js) loaded on demand by URL.
Rules:
  • Never pin an exact engine version in a peer range.
  • Publish a tested compatibility matrix per release.
  • Adapters type-import the engine (import type Hls from 'hls.js') and load the runtime through import('hls.js'). Bundlers then code-split it automatically.
  • The CDN build lets the user override the engine URL so they can pin or self-host it.

3. Lazy-loading flow

  1. player.src = { src, type? }. Sniff the type from the extension or MIME, or call a canPlay probe on each registered provider.
  2. Pick a provider from the priority list:
    • native (video.canPlayType),
    • then the registered adapters in user order.
    • Safari rule: prefer native HLS unless the requested features need MSE.
  3. Dynamically import the provider package, then the engine, with <link rel="modulepreload"> hints available via player.preconnect() / preload().
  4. Prefetch on intent: hover or viewport intersection triggers import() with fetchpriority=low.
  5. Plugins such as ads, cast, ASS and thumbnails register lazily and load on first use.

4. Licenses and attribution obligations

Not legal advice. Have counsel review before the 1.0 release.
LicenseLibrariesWhat Tomato must doSource
Apache-2.0hls.js, Shaka, mpegts.js, SVTA CML, Video.js (if code is borrowed), videojs-imaWhen redistributing (CDN bundles that include the engine, or vendored code): include a copy of the license; keep copyright, patent and attribution notices; mark modified files; and if the upstream ships a NOTICE file, reproduce its attribution notices (§4(d)). On 2026-11-21 there was no root NOTICE file in hls.js (master), Shaka (main), Video.js (main) or mpegts.js (master): these URLs return 404. hls.js's LICENSE includes copyrights from Dailymotion and Brightcove (derived from videojs-contrib-hls), so keep it verbatim.Apache-2.0 §4, hls.js LICENSE
BSD-3-Clausedash.js, ClapprBinary redistribution must reproduce the copyright notice, conditions and disclaimer in the docs or other materials. No-endorsement clause: do not use "Dash Industry Forum" to promote Tomato without permission. dash.js itself has 13 deps; audit their licenses (e.g. localforage, imsc, codem-isoboxer) before CDN bundling.dash.js LICENSE.md
MITMedia Chrome, Vidstack, Plyr, media-captions, mux elements, JASSUB wrapperKeep the copyright and permission notice in all copies or substantial portions, including vendored or forked code.Each repo's LICENSE
LGPL-2.1+ (plus FTL/GPL-2.0+, ISC, Zlib, BSL-1.0 ...)JASSUB and libass WASM components (npm license field)Keep the plugin a separate, user-replaceable module. Do not statically merge the WASM into Tomato bundles. Ship the license texts and point to the corresponding source. Prefer opt-in installs only. Get a legal review before any CDN distribution of the WASM.npm jassub metadata
ProprietaryGoogle IMA, Cast SDKDo not redistribute. Load from Google. The user accepts Google's terms. Document this in the plugin README.IMA setup
Operational:
  • Generate THIRD_PARTY_NOTICES.md per CDN artifact at build time, for example with rollup-plugin-license or a similar tool.
  • Preserve /*! ... */ license comments in minified output.
  • npm packages that only list peers need no notice, because Tomato does not redistribute the code.
  • Add a CI license allowlist with license-checker or a similar tool. It fails on GPL or AGPL in core packages. LGPL is allowed only in plugin-ass.
PreviousOpportunities