@cloudnest/redxplyr 1.0.0
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.
- package/.editorconfig +10 -0
- package/.gitpod.yml +6 -0
- package/.node-version +1 -0
- package/.prettierrc +7 -0
- package/.stickler.yml +5 -0
- package/.stylelintrc.json +26 -0
- package/CHANGELOG.md +16 -0
- package/CONTRIBUTING.md +34 -0
- package/CONTROLS.md +49 -0
- package/Dockerfile +32 -0
- package/LICENSE.md +22 -0
- package/README.md +194 -0
- package/cspell.json +48 -0
- package/dist/redxplyr.css +1 -0
- package/dist/redxplyr.js +8801 -0
- package/dist/redxplyr.min.js +2 -0
- package/dist/redxplyr.min.js.map +1 -0
- package/dist/redxplyr.min.mjs +1 -0
- package/dist/redxplyr.min.mjs.map +1 -0
- package/dist/redxplyr.mjs +8793 -0
- package/dist/redxplyr.polyfilled.js +9294 -0
- package/dist/redxplyr.polyfilled.min.js +2 -0
- package/dist/redxplyr.polyfilled.min.js.map +1 -0
- package/dist/redxplyr.polyfilled.min.mjs +1 -0
- package/dist/redxplyr.polyfilled.min.mjs.map +1 -0
- package/dist/redxplyr.polyfilled.mjs +9286 -0
- package/dist/redxplyr.svg +1 -0
- package/eslint.config.mjs +39 -0
- package/gulpfile.js +8 -0
- package/package.json +114 -0
- package/pnpm-workspace.yaml +8 -0
- package/src/js/captions.js +411 -0
- package/src/js/config/defaults.js +459 -0
- package/src/js/config/states.js +10 -0
- package/src/js/config/types.js +34 -0
- package/src/js/console.js +28 -0
- package/src/js/controls.js +1870 -0
- package/src/js/fullscreen.js +305 -0
- package/src/js/html5.js +148 -0
- package/src/js/listeners.js +854 -0
- package/src/js/media.js +61 -0
- package/src/js/plugins/ads.js +647 -0
- package/src/js/plugins/preview-thumbnails.js +706 -0
- package/src/js/plugins/vimeo.js +443 -0
- package/src/js/plugins/youtube.js +451 -0
- package/src/js/plyr.d.ts +729 -0
- package/src/js/plyr.js +1291 -0
- package/src/js/plyr.polyfilled.js +13 -0
- package/src/js/source.js +155 -0
- package/src/js/storage.js +70 -0
- package/src/js/support.js +100 -0
- package/src/js/ui.js +297 -0
- package/src/js/utils/animation.js +33 -0
- package/src/js/utils/arrays.js +23 -0
- package/src/js/utils/browser.js +21 -0
- package/src/js/utils/elements.js +263 -0
- package/src/js/utils/events.js +116 -0
- package/src/js/utils/fetch.js +45 -0
- package/src/js/utils/i18n.js +47 -0
- package/src/js/utils/is.js +81 -0
- package/src/js/utils/load-image.js +19 -0
- package/src/js/utils/load-script.js +14 -0
- package/src/js/utils/load-sprite.js +77 -0
- package/src/js/utils/numbers.js +17 -0
- package/src/js/utils/objects.js +43 -0
- package/src/js/utils/promise.js +14 -0
- package/src/js/utils/strings.js +80 -0
- package/src/js/utils/style.js +148 -0
- package/src/js/utils/time.js +36 -0
- package/src/js/utils/urls.js +40 -0
- package/src/sass/base.scss +69 -0
- package/src/sass/components/badges.scss +12 -0
- package/src/sass/components/captions.scss +58 -0
- package/src/sass/components/control.scss +52 -0
- package/src/sass/components/controls.scss +65 -0
- package/src/sass/components/menus.scss +205 -0
- package/src/sass/components/poster.scss +27 -0
- package/src/sass/components/progress.scss +107 -0
- package/src/sass/components/sliders.scss +99 -0
- package/src/sass/components/times.scss +20 -0
- package/src/sass/components/tooltips.scss +91 -0
- package/src/sass/components/volume.scss +18 -0
- package/src/sass/lib/animation.scss +31 -0
- package/src/sass/lib/css-vars.scss +103 -0
- package/src/sass/lib/functions.scss +3 -0
- package/src/sass/lib/mixins.scss +82 -0
- package/src/sass/plugins/ads.scss +53 -0
- package/src/sass/plugins/preview-thumbnails/index.scss +121 -0
- package/src/sass/plugins/preview-thumbnails/settings.scss +17 -0
- package/src/sass/plyr.scss +46 -0
- package/src/sass/settings/badges.scss +7 -0
- package/src/sass/settings/breakpoints.scss +9 -0
- package/src/sass/settings/captions.scss +10 -0
- package/src/sass/settings/colors.scss +18 -0
- package/src/sass/settings/controls.scss +30 -0
- package/src/sass/settings/cosmetics.scss +5 -0
- package/src/sass/settings/helpers.scss +7 -0
- package/src/sass/settings/menus.scss +13 -0
- package/src/sass/settings/progress.scss +18 -0
- package/src/sass/settings/sliders.scss +39 -0
- package/src/sass/settings/tooltips.scss +11 -0
- package/src/sass/settings/type.scss +16 -0
- package/src/sass/states/fullscreen.scss +15 -0
- package/src/sass/types/audio.scss +61 -0
- package/src/sass/types/video.scss +170 -0
- package/src/sass/utils/animation.scss +7 -0
- package/src/sass/utils/hidden.scss +28 -0
- package/src/sprite/plyr-airplay.svg +8 -0
- package/src/sprite/plyr-captions-off.svg +7 -0
- package/src/sprite/plyr-captions-on.svg +7 -0
- package/src/sprite/plyr-download.svg +8 -0
- package/src/sprite/plyr-enter-fullscreen.svg +4 -0
- package/src/sprite/plyr-exit-fullscreen.svg +4 -0
- package/src/sprite/plyr-fast-forward.svg +3 -0
- package/src/sprite/plyr-logo-vimeo.svg +6 -0
- package/src/sprite/plyr-logo-youtube.svg +6 -0
- package/src/sprite/plyr-muted.svg +8 -0
- package/src/sprite/plyr-pause.svg +8 -0
- package/src/sprite/plyr-pip.svg +6 -0
- package/src/sprite/plyr-play.svg +5 -0
- package/src/sprite/plyr-restart.svg +5 -0
- package/src/sprite/plyr-rewind.svg +3 -0
- package/src/sprite/plyr-settings.svg +5 -0
- package/src/sprite/plyr-volume.svg +11 -0
- package/tasks/build.js +226 -0
- package/tasks/deploy.js +216 -0
- package/tasks/utils/publish.js +34 -0
package/tasks/deploy.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import path, { join } from 'node:path';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { S3Client } from '@aws-sdk/client-s3';
|
|
6
|
+
import aws from 'aws-sdk';
|
|
7
|
+
import { bold, cyan, green } from 'colorette';
|
|
8
|
+
import log from 'fancy-log';
|
|
9
|
+
import gitbranch from 'git-branch';
|
|
10
|
+
import gulp from 'gulp';
|
|
11
|
+
import open from 'gulp-open';
|
|
12
|
+
import rename from 'gulp-rename';
|
|
13
|
+
import replace from 'gulp-replace';
|
|
14
|
+
import size from 'gulp-size';
|
|
15
|
+
|
|
16
|
+
import { publish } from './utils/publish.js';
|
|
17
|
+
import 'dotenv/config';
|
|
18
|
+
|
|
19
|
+
// Convert `import.meta.url` to `__filename` and `__dirname`
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = path.dirname(__filename);
|
|
22
|
+
|
|
23
|
+
const pkg = JSON.parse(readFileSync(join(path.resolve(), 'package.json'), 'utf-8'));
|
|
24
|
+
const config = JSON.parse(readFileSync(join(path.resolve(), 'deploy.json'), 'utf-8'));
|
|
25
|
+
|
|
26
|
+
// Info from package
|
|
27
|
+
const { version } = pkg;
|
|
28
|
+
const minSuffix = '.min';
|
|
29
|
+
|
|
30
|
+
// Get AWS config
|
|
31
|
+
const jobs = Object.fromEntries(Object.entries(config).map(([name, options]) => [name, {
|
|
32
|
+
...options,
|
|
33
|
+
client: options.type === 'r2'
|
|
34
|
+
? new S3Client({
|
|
35
|
+
region: 'auto',
|
|
36
|
+
credentials: {
|
|
37
|
+
accessKeyId: process.env.R2_ACCESS_KEY_ID,
|
|
38
|
+
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
|
|
39
|
+
},
|
|
40
|
+
endpoint: `https://${process.env.CF_ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
|
41
|
+
})
|
|
42
|
+
: new S3Client({
|
|
43
|
+
region: options.region,
|
|
44
|
+
credentials: new aws.SharedIniFileCredentials({ profile: 'redxplyr' }),
|
|
45
|
+
}),
|
|
46
|
+
}]));
|
|
47
|
+
|
|
48
|
+
// Paths
|
|
49
|
+
const root = path.join(__dirname, '..');
|
|
50
|
+
const paths = {
|
|
51
|
+
demo: path.join(root, 'demo/'),
|
|
52
|
+
upload: [
|
|
53
|
+
path.join(root, `dist/*${minSuffix}.*`),
|
|
54
|
+
path.join(root, 'dist/*.css'),
|
|
55
|
+
path.join(root, 'dist/*.svg'),
|
|
56
|
+
path.join(root, `demo/dist/*${minSuffix}.*`),
|
|
57
|
+
path.join(root, 'demo/dist/*.css'),
|
|
58
|
+
path.join(root, 'demo/dist/*.svg'),
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Get git branch info
|
|
63
|
+
const currentBranch = (() => {
|
|
64
|
+
try {
|
|
65
|
+
return gitbranch.sync();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
})();
|
|
71
|
+
|
|
72
|
+
const branch = {
|
|
73
|
+
current: currentBranch,
|
|
74
|
+
isMaster: currentBranch === 'master',
|
|
75
|
+
isBeta: currentBranch === 'beta',
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const maxAge = 31536000; // 1 year
|
|
79
|
+
const options = {
|
|
80
|
+
cdn: {
|
|
81
|
+
headers: {
|
|
82
|
+
'Cache-Control': `max-age=${maxAge}, immutable`,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
demo: {
|
|
86
|
+
uploadPath: branch.isBeta ? '/beta' : null,
|
|
87
|
+
headers: {
|
|
88
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Size plugin
|
|
94
|
+
const sizeOptions = { showFiles: true, gzip: true };
|
|
95
|
+
|
|
96
|
+
const regex = '(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\da-z\\-]+(?:\\.[\\da-z\\-]+)*)?(?:\\+[\\da-z\\-]+(?:\\.[\\da-z\\-]+)*)?';
|
|
97
|
+
const semver = new RegExp(`v${regex}`, 'gi');
|
|
98
|
+
const localPath = /(..\/)?dist\//gi;
|
|
99
|
+
const cdnChannel = jobs.cdn.path ?? `v${version.split('.')[0]}`;
|
|
100
|
+
const versionPath = `https://${jobs.cdn.domain}/${cdnChannel}/`;
|
|
101
|
+
const cdnPath = new RegExp(`${jobs.cdn.domain}/(?:${regex}|v\\d+)/`, 'gi');
|
|
102
|
+
|
|
103
|
+
const renameFile = rename((p) => {
|
|
104
|
+
p.basename = p.basename.replace(minSuffix, '');
|
|
105
|
+
p.dirname = p.dirname.replace('.', cdnChannel);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Check we're on the correct branch to deploy
|
|
109
|
+
function canDeploy() {
|
|
110
|
+
if (![branch.isMaster, branch.isBeta].some(Boolean)) {
|
|
111
|
+
console.error(`Must be on an allowed branch to publish! (current: ${branch.current})`);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function prepare(done) {
|
|
119
|
+
if (!canDeploy()) {
|
|
120
|
+
done();
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const { domain } = jobs.cdn;
|
|
125
|
+
|
|
126
|
+
log(`Updating version in files to ${green(bold(version))} and CDN channel ${green(bold(cdnChannel))}...`);
|
|
127
|
+
|
|
128
|
+
// Replace versioned URLs in source
|
|
129
|
+
const files = ['plyr.js', 'plyr.polyfilled.js', 'config/defaults.js'];
|
|
130
|
+
|
|
131
|
+
return gulp
|
|
132
|
+
.src(
|
|
133
|
+
files.map(file => path.join(root, `src/js/${file}`)),
|
|
134
|
+
{ base: '.' },
|
|
135
|
+
)
|
|
136
|
+
.pipe(replace(semver, `v${version}`))
|
|
137
|
+
.pipe(replace(cdnPath, `${domain}/${cdnChannel}/`))
|
|
138
|
+
.pipe(gulp.dest('./'));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function cdn(done) {
|
|
142
|
+
if (!canDeploy()) {
|
|
143
|
+
done();
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const { domain, client, bucket } = jobs.cdn;
|
|
148
|
+
|
|
149
|
+
log(`Uploading ${green(bold(pkg.version))} as ${green(bold(cdnChannel))} to ${cyan(domain)}...`);
|
|
150
|
+
|
|
151
|
+
// Upload to CDN
|
|
152
|
+
return gulp
|
|
153
|
+
.src(paths.upload)
|
|
154
|
+
.pipe(renameFile)
|
|
155
|
+
.pipe(
|
|
156
|
+
replace(
|
|
157
|
+
/sourceMappingURL=([\w\-?.]+)/,
|
|
158
|
+
(_, filename) => `sourceMappingURL=${filename.replace(minSuffix, '')}`,
|
|
159
|
+
),
|
|
160
|
+
)
|
|
161
|
+
.pipe(size(sizeOptions))
|
|
162
|
+
.pipe(replace(localPath, versionPath))
|
|
163
|
+
.pipe(publish(client, bucket, options.cdn.headers));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function demo(done) {
|
|
167
|
+
if (!canDeploy()) {
|
|
168
|
+
done();
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const { client, bucket, domain } = jobs.demo;
|
|
173
|
+
log(`Uploading ${green(bold(pkg.version))} to ${cyan(domain)}...`);
|
|
174
|
+
|
|
175
|
+
// Replace versioned files in README.md
|
|
176
|
+
gulp
|
|
177
|
+
.src([`${root}/README.md`])
|
|
178
|
+
.pipe(replace(cdnPath, `${jobs.cdn.domain}/${cdnChannel}/`))
|
|
179
|
+
.pipe(gulp.dest(root));
|
|
180
|
+
|
|
181
|
+
// Replace local file paths with remote paths in demo HTML
|
|
182
|
+
const ai = `${paths.demo}ai.html`;
|
|
183
|
+
const index = `${paths.demo}index.html`;
|
|
184
|
+
const llms = `${paths.demo}llms.txt`;
|
|
185
|
+
const versionPage = `${paths.demo}${cdnChannel}/index.html`;
|
|
186
|
+
const error = `${paths.demo}error.html`;
|
|
187
|
+
const pages = [index, ai, llms, versionPage];
|
|
188
|
+
|
|
189
|
+
if (branch.isMaster) {
|
|
190
|
+
pages.push(error);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return gulp
|
|
194
|
+
.src(pages)
|
|
195
|
+
.pipe(replace(localPath, versionPath))
|
|
196
|
+
.pipe(
|
|
197
|
+
rename((p) => {
|
|
198
|
+
if (options.demo.uploadPath) {
|
|
199
|
+
p.dirname += options.demo.uploadPath;
|
|
200
|
+
}
|
|
201
|
+
}),
|
|
202
|
+
)
|
|
203
|
+
.pipe(publish(client, bucket, options.demo.headers));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function preview() {
|
|
207
|
+
const { domain } = jobs.demo;
|
|
208
|
+
|
|
209
|
+
return gulp.src(__filename).pipe(
|
|
210
|
+
open({
|
|
211
|
+
uri: `https://${domain}/${branch.isBeta ? 'beta' : ''}`,
|
|
212
|
+
}),
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export const deploy = gulp.series(cdn, demo, preview);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PutObjectCommand } from '@aws-sdk/client-s3';
|
|
2
|
+
import mime from 'mime';
|
|
3
|
+
import through from 'through2';
|
|
4
|
+
|
|
5
|
+
export function publish(client, bucket, headers = {}) {
|
|
6
|
+
return through.obj(async function (file, _, callback) {
|
|
7
|
+
if (!file.isBuffer()) return callback(null, file);
|
|
8
|
+
|
|
9
|
+
// Use the relative path as the key
|
|
10
|
+
const key = file.relative.replace(/\\/g, '/'); // Ensure forward slashes for S3 keys
|
|
11
|
+
|
|
12
|
+
// Determine the MIME type of the file
|
|
13
|
+
const contentType = mime.getType(file.path) || 'application/octet-stream';
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
await client.send(
|
|
17
|
+
new PutObjectCommand({
|
|
18
|
+
Bucket: bucket,
|
|
19
|
+
Key: key,
|
|
20
|
+
Body: file.contents,
|
|
21
|
+
ContentType: contentType, // Set the MIME type
|
|
22
|
+
CacheControl: headers['Cache-Control'], // Use provided Cache-Control header
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
console.warn(`Uploaded: ${key} (Content-Type: ${contentType})`);
|
|
27
|
+
this.push(file);
|
|
28
|
+
callback();
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
callback(err);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|