Compare commits
1 Commits
video-play
...
video-play
| Author | SHA1 | Date | |
|---|---|---|---|
| 028ce21c4c |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hublib-web/video-player",
|
"name": "@hublib-web/video-player",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"description": "Cross-framework video player package for React and Angular",
|
"description": "Cross-framework video player package for React and Angular",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
"sideEffects": true,
|
"sideEffects": true,
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
"README.md"
|
"README.md",
|
||||||
|
"scripts"
|
||||||
],
|
],
|
||||||
"typesVersions": {
|
"typesVersions": {
|
||||||
"*": {
|
"*": {
|
||||||
@@ -48,6 +49,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"postinstall": "node ./scripts/apply-videojs-patch.mjs",
|
||||||
"build": "yarn clean && node ./scripts/build.mjs",
|
"build": "yarn clean && node ./scripts/build.mjs",
|
||||||
"clean": "rm -rf dist storybook-static",
|
"clean": "rm -rf dist storybook-static",
|
||||||
"typecheck": "tsc -p ./tsconfig.json --noEmit",
|
"typecheck": "tsc -p ./tsconfig.json --noEmit",
|
||||||
|
|||||||
45
packages/video-player/scripts/apply-videojs-patch.mjs
Normal file
45
packages/video-player/scripts/apply-videojs-patch.mjs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { readFileSync, writeFileSync } from "node:fs";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
|
import { createRequire } from "node:module";
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
|
||||||
|
const originalSnippet = ` const originalAbort = request.abort;
|
||||||
|
request.abort = function () {
|
||||||
|
request.aborted = true;
|
||||||
|
return originalAbort.apply(request, arguments);
|
||||||
|
};`;
|
||||||
|
|
||||||
|
const patchedSnippet = ` // const originalAbort = request.abort;
|
||||||
|
// request.abort = function () {
|
||||||
|
// request.aborted = true;
|
||||||
|
// return originalAbort.apply(request, arguments);
|
||||||
|
// };`;
|
||||||
|
|
||||||
|
function run() {
|
||||||
|
const packageJsonPath = require.resolve("video.js/package.json");
|
||||||
|
const videoEsPath = join(dirname(packageJsonPath), "dist", "video.es.js");
|
||||||
|
const source = readFileSync(videoEsPath, "utf8");
|
||||||
|
|
||||||
|
if (source.includes(patchedSnippet)) {
|
||||||
|
console.log("[video-player] video.js patch already applied");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!source.includes(originalSnippet)) {
|
||||||
|
throw new Error(
|
||||||
|
"[video-player] Cannot apply video.js patch: target snippet not found. Expected video.js 8.23.4 source."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const patched = source.replace(originalSnippet, patchedSnippet);
|
||||||
|
writeFileSync(videoEsPath, patched, "utf8");
|
||||||
|
console.log("[video-player] Applied video.js patch");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
run();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error instanceof Error ? error.message : String(error));
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user