@vidispine/vdt-videojs 21.3.0 → 22.1.0-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +4 -4
  2. package/deprecated-app/README.md +21 -0
  3. package/{demo.html → deprecated-app/index.html} +1 -1
  4. package/{demo.js → deprecated-app/index.js} +69 -41
  5. package/{samples → deprecated-app/samples}/birds-es.vvt +0 -0
  6. package/{samples → deprecated-app/samples}/birds.vvt +0 -0
  7. package/{tests.js → deprecated-app/tests.js} +87 -54
  8. package/{lib/style.css → dist/index.css} +755 -55
  9. package/dist/index.es.js +2099 -0
  10. package/dist/index.js +2112 -0
  11. package/dist/index.umd.js +2115 -0
  12. package/package.json +29 -85
  13. package/rollup.config.js +54 -0
  14. package/src/constants.js +1 -1
  15. package/src/externalControls.js +14 -18
  16. package/src/helpOverlay.js +12 -16
  17. package/src/helpers.js +3 -3
  18. package/src/index.js +3 -9
  19. package/src/index.stories.mdx +59 -0
  20. package/src/menu.api.stories.mdx +59 -0
  21. package/src/menu.js +23 -19
  22. package/src/{menu.example.md → menu.usage.stories.mdx} +31 -21
  23. package/src/osd.js +24 -18
  24. package/src/player.api.stories.mdx +120 -0
  25. package/src/player.js +157 -108
  26. package/src/player.scss +2 -0
  27. package/src/{player.example.md → player.usage.stories.mdx} +18 -8
  28. package/src/seekBar.js +85 -48
  29. package/src/timeCodeDisplay.js +39 -31
  30. package/src/videoTime.js +4 -4
  31. package/build.js +0 -233
  32. package/lib/index.cjs.js +0 -3240
  33. package/lib/index.esm.js +0 -3227
  34. package/lib/index.umd.js +0 -3243
  35. package/lib/package.json +0 -13
  36. package/lib/src/constants.js +0 -51
  37. package/lib/src/externalControls.js +0 -307
  38. package/lib/src/helpOverlay.js +0 -106
  39. package/lib/src/helpers.js +0 -34
  40. package/lib/src/index.js +0 -13
  41. package/lib/src/menu.js +0 -365
  42. package/lib/src/osd.js +0 -91
  43. package/lib/src/player.js +0 -943
  44. package/lib/src/seekBar.js +0 -833
  45. package/lib/src/timeCodeDisplay.js +0 -253
  46. package/lib/src/videoTime.js +0 -66
  47. package/log.js +0 -24
  48. package/src/_index.stories.js +0 -24
  49. package/src/externalControls.stories.js +0 -6
  50. package/src/helpOverlay.stories.js +0 -6
  51. package/src/menu.classMethods.md +0 -47
  52. package/src/player.classMethods.md +0 -108
  53. package/src/player.stories.js +0 -14
  54. package/src/seekBar.stories.js +0 -8
  55. package/tmp/player.css +0 -1
package/build.js DELETED
@@ -1,233 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- /* eslint-disable import/no-dynamic-require */
3
- /* eslint-disable no-console */
4
- const Bundler = require("parcel-bundler");
5
- const chokidar = require("chokidar");
6
- const strip = require("strip-comments");
7
- const path = require("path");
8
- const fs = require("fs");
9
-
10
- const rollup = require("rollup");
11
- const jsonPlugin = require("rollup-plugin-json");
12
-
13
- const log = require("./log.js");
14
-
15
- const scssFile = path.resolve("src/player.scss");
16
- const packageJSON = require(path.resolve(__dirname, "./package.json"));
17
-
18
- // relates to module output
19
- const moduleFileNames = {
20
- // can isolate for testing by commenting keys to exclude from build
21
- cjs: "index.cjs.js",
22
- umd: "index.umd.js",
23
- esm: "index.esm.js",
24
- };
25
-
26
- async function clean() {
27
- try {
28
- const buildPath = path.resolve(__dirname, "lib/");
29
- fs.statSync(buildPath);
30
- fs.rmdirSync(buildPath, { recursive: true });
31
- } catch (e) {
32
- fs.mkdirSync(path.resolve(__dirname, "lib/"));
33
- }
34
- }
35
-
36
- async function bundleModules() {
37
- return new Promise((resolve, reject) => {
38
- const inputOptions = {
39
- input: path.resolve(__dirname, "./src/index.js"),
40
- plugins: [
41
- jsonPlugin(),
42
- ],
43
- external: ["mousetrap", "video.js", "video.js/dist/alt/video.core.min"],
44
- };
45
-
46
- try {
47
- const keys = Object.keys(moduleFileNames);
48
-
49
- keys.forEach(async (key, index) => {
50
- const outputOptions = {
51
- file: path.resolve(__dirname, `./lib/${moduleFileNames[key]}`),
52
- format: key,
53
- };
54
-
55
- if (key !== "cjs") {
56
- outputOptions.name = "vdtVideojs";
57
- outputOptions.globals = {
58
- mousetrap: "mousetrap",
59
- "video.js/dist/alt/video.core.min": "videojs",
60
- };
61
- }
62
-
63
- const bundle = await rollup.rollup(inputOptions);
64
- await bundle.generate(outputOptions);
65
- await bundle.write(outputOptions);
66
- log.progress(`Bundled ${key} module.`);
67
-
68
- if (index === keys.length - 1) {
69
- resolve();
70
- }
71
- });
72
- } catch (error) {
73
- console.log(error);
74
- reject();
75
- }
76
- });
77
- }
78
-
79
- // main build method
80
- async function build() {
81
- try {
82
- log.clear();
83
- // establish lib folder
84
- try {
85
- fs.statSync(path.resolve(__dirname, "lib/"));
86
- } catch (e) {
87
- fs.mkdirSync(path.resolve(__dirname, "lib/"));
88
- }
89
-
90
- // Add a package json
91
- log.progress("Writing package.json...");
92
- const propsToKeep = [
93
- "name",
94
- "version",
95
- "license",
96
- "author",
97
- "dependencies",
98
- "private",
99
- ];
100
-
101
- const libPkgJson = {};
102
- propsToKeep.forEach((prop) => {
103
- libPkgJson[prop] = packageJSON[prop];
104
- });
105
-
106
- libPkgJson.main = moduleFileNames.cjs;
107
- libPkgJson.module = moduleFileNames.esm;
108
- fs.writeFileSync(
109
- path.resolve(__dirname, "./lib/package.json"),
110
- JSON.stringify(libPkgJson, null, 2)
111
- );
112
-
113
- log.progress(
114
- `Building ${packageJSON.name} for distribution (/lib/) with css combined...`
115
- );
116
- // from scss to css
117
- const parcelOptions = {
118
- outDir: "./tmp/", // for easy css output viewing
119
- sourceMaps: false, // dead weight
120
- watch: false,
121
- cache: false,
122
- outFile: "player.css", // Specify single file output
123
- minify: true, // nice and compact css string needed
124
- logLevel: 0, // silence parcel output, custom logging follows
125
- port: 5555, // avoid colliding with dev servers
126
- };
127
-
128
- const bundler = new Bundler(scssFile, parcelOptions);
129
- const bundle = await bundler.bundle(); // outputs player.css to /tmp/ for easy viewing
130
- log.progress("SCSS to CSS transformation for player.scss done, see ./tmp/");
131
-
132
- log.progress("Getting video.js CSS...");
133
- // get video.js css
134
- let videojsCss;
135
- try {
136
- // depends if lerna bootstrap has been run or not
137
- videojsCss = fs.readFileSync(
138
- path.resolve("./node_modules/video.js/dist/video-js.css"),
139
- "utf8"
140
- ); // look in the node_modules here
141
- } catch (err) {
142
- videojsCss = fs.readFileSync(
143
- path.resolve("./../../node_modules/video.js/dist/video-js.css"),
144
- "utf8"
145
- ); // look in the node_modules in peerdependencies
146
- }
147
-
148
- // the css
149
- log.progress("Concatinating CSS...");
150
- const playerCss = bundle.entryAsset.generated.css;
151
- const theCSS = videojsCss + playerCss;
152
- fs.writeFileSync(path.resolve(__dirname, "./lib/style.css"), theCSS);
153
-
154
- // copy rest of src *.js imports
155
- const excludes = [
156
- "player.scss",
157
- "stories.js",
158
- ".md",
159
- "stories.js",
160
- "DS_Store",
161
- ];
162
- let jsFiles = fs.readdirSync(path.resolve(__dirname, "./src/"));
163
- jsFiles = jsFiles.filter((fileName) => {
164
- const excluded = new RegExp(excludes.join("|")).test(fileName);
165
- return !excluded;
166
- });
167
-
168
- log.progress("Copying local *.js import files...");
169
- const cleanSrcDir = path.resolve(__dirname, "./lib/src/");
170
- // make a src dir if one does not exist
171
- try {
172
- fs.statSync(cleanSrcDir);
173
- } catch (e) {
174
- fs.mkdirSync(cleanSrcDir);
175
- }
176
-
177
- const wroteFilesPromise = new Promise((resolve, reject) => {
178
- let iteration = 0;
179
- const { length } = jsFiles;
180
- jsFiles.forEach(async (file) => {
181
- try {
182
- iteration += 1;
183
- log.progress(`Stripping comments from ${file} and saving...`);
184
- const jsCode = fs.readFileSync(
185
- path.resolve(__dirname, `src/${file}`),
186
- "binary"
187
- );
188
- const jsCodeCommentFree = strip(jsCode);
189
- fs.writeFileSync(
190
- path.resolve(cleanSrcDir, `${file}`),
191
- jsCodeCommentFree
192
- );
193
- if (iteration === length) {
194
- resolve();
195
- }
196
- } catch (error) {
197
- console.log(error);
198
- reject();
199
- }
200
- });
201
- });
202
-
203
- await wroteFilesPromise; // wait before logging success
204
-
205
- // bundles
206
- const bundledModulesPromise = bundleModules();
207
- await bundledModulesPromise;
208
-
209
- // celebrate
210
- log.success(`${packageJSON.name} built, output saved to ./lib/`);
211
- } catch (err) {
212
- console.log(err);
213
- log.fail(`${packageJSON.name} build failed, check the previous step`);
214
- }
215
- }
216
-
217
- (async function () {
218
- await clean();
219
- await build();
220
- // when watch argument is passed, watch files
221
- const args = process.argv.slice(2);
222
- if (args.indexOf("--watch") > -1) {
223
- log.change(`${packageJSON.name} - watching for changes...`);
224
- const watcher = chokidar.watch(path.resolve("./src/"), {
225
- ignored: /^\./,
226
- persistent: true,
227
- });
228
- watcher.on("change", () => {
229
- log.change("Detected a change...");
230
- build();
231
- });
232
- }
233
- })();