aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-17 16:17:22 +0100
committerChocobozzz <me@florianbigard.com>2019-12-18 10:14:25 +0100
commit03d641a0d7f996de44ec898ad739bc4050514ba1 (patch)
treedc8d36a945133fdc91fa279b9c97a22f1ec11465
parentc026a2e67357bd4bd4fcc4c10f8c5cd4749435c9 (diff)
downloadPeerTube-03d641a0d7f996de44ec898ad739bc4050514ba1.tar.gz
PeerTube-03d641a0d7f996de44ec898ad739bc4050514ba1.tar.zst
PeerTube-03d641a0d7f996de44ec898ad739bc4050514ba1.zip
Add embed api build
-rw-r--r--client/src/standalone/player/.npmignore3
-rw-r--r--client/src/standalone/player/package.json11
-rw-r--r--client/src/standalone/player/player.ts2
-rw-r--r--client/src/standalone/player/tsconfig.json19
-rw-r--r--client/src/standalone/player/webpack.config.js12
-rw-r--r--package.json2
-rwxr-xr-xscripts/build/client.sh2
-rwxr-xr-xscripts/build/embed.sh2
-rwxr-xr-x[-rw-r--r--]scripts/dev/embed.sh0
-rwxr-xr-xscripts/release-embed-api.sh11
-rw-r--r--support/doc/api/embeds.md21
11 files changed, 78 insertions, 7 deletions
diff --git a/client/src/standalone/player/.npmignore b/client/src/standalone/player/.npmignore
new file mode 100644
index 000000000..870b6315b
--- /dev/null
+++ b/client/src/standalone/player/.npmignore
@@ -0,0 +1,3 @@
1tsconfig.json
2*.ts
3webpack.config.ts
diff --git a/client/src/standalone/player/package.json b/client/src/standalone/player/package.json
index b056de718..591c3ee3d 100644
--- a/client/src/standalone/player/package.json
+++ b/client/src/standalone/player/package.json
@@ -1,6 +1,7 @@
1{ 1{
2 "name": "@peertube/embed-api", 2 "name": "@peertube/embed-api",
3 "version": "1.0.0", 3 "private": false,
4 "version": "0.0.1",
4 "description": "API to communicate with the PeerTube player embed", 5 "description": "API to communicate with the PeerTube player embed",
5 "scripts": { 6 "scripts": {
6 "test": "echo \"Error: no test specified\" && exit 1" 7 "test": "echo \"Error: no test specified\" && exit 1"
@@ -13,11 +14,15 @@
13 "peertube", 14 "peertube",
14 "embed" 15 "embed"
15 ], 16 ],
16 "main": "./player.ts", 17 "main": "./dist/player.js",
18 "types": "./dist/player.d.ts",
17 "author": "Chocobozzz", 19 "author": "Chocobozzz",
18 "license": "AGPL-3.0", 20 "license": "AGPL-3.0",
19 "bugs": { 21 "bugs": {
20 "url": "https://github.com/Chocobozzz/PeerTube/issues" 22 "url": "https://github.com/Chocobozzz/PeerTube/issues"
21 }, 23 },
22 "homepage": "https://github.com/Chocobozzz/PeerTube#readme" 24 "homepage": "https://github.com/Chocobozzz/PeerTube#readme",
25 "dependencies": {
26 "jschannel": "^1.0.2"
27 }
23} 28}
diff --git a/client/src/standalone/player/player.ts b/client/src/standalone/player/player.ts
index f33539134..71c412950 100644
--- a/client/src/standalone/player/player.ts
+++ b/client/src/standalone/player/player.ts
@@ -192,4 +192,4 @@ export class PeerTubePlayer {
192} 192}
193 193
194// put it on the window as well as the export 194// put it on the window as well as the export
195window[ 'PeerTubePlayer' ] = PeerTubePlayer 195(window[ 'PeerTubePlayer' ] as any) = PeerTubePlayer
diff --git a/client/src/standalone/player/tsconfig.json b/client/src/standalone/player/tsconfig.json
new file mode 100644
index 000000000..eecc63dfb
--- /dev/null
+++ b/client/src/standalone/player/tsconfig.json
@@ -0,0 +1,19 @@
1{
2 "compilerOptions": {
3 "module": "commonjs",
4 "removeComments": true,
5 "sourceMap": false,
6 "typeRoots": [
7 "../../../node_modules/@types"
8 ],
9 "outDir": "./dist",
10 "declaration": true,
11 "target": "es5",
12 "types": [],
13 "lib": [
14 "es2018",
15 "dom"
16 ]
17 },
18 "files": [ "./player.ts" ]
19}
diff --git a/client/src/standalone/player/webpack.config.js b/client/src/standalone/player/webpack.config.js
new file mode 100644
index 000000000..48d350edf
--- /dev/null
+++ b/client/src/standalone/player/webpack.config.js
@@ -0,0 +1,12 @@
1const path = require('path')
2
3module.exports = [
4 {
5 mode: 'production',
6 entry: './dist/player.js',
7 output: {
8 filename: 'player.min.js',
9 path: path.resolve(__dirname, 'build')
10 }
11 }
12]
diff --git a/package.json b/package.json
index acc4b7e1f..d48841517 100644
--- a/package.json
+++ b/package.json
@@ -46,7 +46,6 @@
46 "dev:embed": "scripty", 46 "dev:embed": "scripty",
47 "dev:client": "scripty", 47 "dev:client": "scripty",
48 "dev:cli": "scripty", 48 "dev:cli": "scripty",
49 "dev:embed": "scripty",
50 "start": "node dist/server", 49 "start": "node dist/server",
51 "start:server": "node dist/server --no-client", 50 "start:server": "node dist/server --no-client",
52 "update-host": "node ./dist/scripts/update-host.js", 51 "update-host": "node ./dist/scripts/update-host.js",
@@ -73,6 +72,7 @@
73 "mocha": "mocha", 72 "mocha": "mocha",
74 "ci": "scripty", 73 "ci": "scripty",
75 "release": "scripty", 74 "release": "scripty",
75 "release-embed-api": "scripty",
76 "nightly": "scripty", 76 "nightly": "scripty",
77 "client-report": "scripty" 77 "client-report": "scripty"
78 }, 78 },
diff --git a/scripts/build/client.sh b/scripts/build/client.sh
index fd9190660..d95bb9574 100755
--- a/scripts/build/client.sh
+++ b/scripts/build/client.sh
@@ -62,7 +62,7 @@ if [ -z ${1+x} ] || [ "$1" != "--light" ]; then
62 done 62 done
63fi 63fi
64 64
65npm run build:embed 65cd ../ && npm run build:embed && cd client/
66 66
67# Copy runtime locales 67# Copy runtime locales
68cp -r "./src/locale" "./dist/locale" 68cp -r "./src/locale" "./dist/locale"
diff --git a/scripts/build/embed.sh b/scripts/build/embed.sh
index ea5e7d57d..47e195d96 100755
--- a/scripts/build/embed.sh
+++ b/scripts/build/embed.sh
@@ -2,4 +2,6 @@
2 2
3set -eu 3set -eu
4 4
5cd client
6
5NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js --mode production --json > "./dist/embed-stats.json" 7NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js --mode production --json > "./dist/embed-stats.json"
diff --git a/scripts/dev/embed.sh b/scripts/dev/embed.sh
index 9b0ef27cf..9b0ef27cf 100644..100755
--- a/scripts/dev/embed.sh
+++ b/scripts/dev/embed.sh
diff --git a/scripts/release-embed-api.sh b/scripts/release-embed-api.sh
new file mode 100755
index 000000000..ae76a65f5
--- /dev/null
+++ b/scripts/release-embed-api.sh
@@ -0,0 +1,11 @@
1#!/bin/sh
2
3set -eu
4
5cd client/src/standalone/player
6
7rm -rf dist build && tsc -p . && ../../../node_modules/.bin/webpack --config ./webpack.config.js
8
9npm publish --access public
10
11rm -rf dist build node_modules
diff --git a/support/doc/api/embeds.md b/support/doc/api/embeds.md
index c2317a030..ca480006d 100644
--- a/support/doc/api/embeds.md
+++ b/support/doc/api/embeds.md
@@ -21,6 +21,24 @@ Now just use the `PeerTubePlayer` class exported by the module:
21```typescript 21```typescript
22import { PeerTubePlayer } from '@peertube/embed-api' 22import { PeerTubePlayer } from '@peertube/embed-api'
23 23
24...
25```
26
27Or use the minified build from NPM CDN in your HTML file:
28
29```
30<script src="https://unpkg.com/@peertube/embed-api@0.0.1/build/player.min.js"></script>
31
32<script>
33 const PeerTubePlayer = window['PeerTubePlayer']
34
35 ...
36</script>
37```
38
39Then you can instantiate the player:
40
41```typescript
24let player = new PeerTubePlayer(document.querySelector('iframe')) 42let player = new PeerTubePlayer(document.querySelector('iframe'))
25await player.ready // wait for the player to be ready 43await player.ready // wait for the player to be ready
26 44
@@ -56,7 +74,7 @@ Get the available resolutions. A `PeerTubeResolution` looks like:
56{ 74{
57 "id": 3, 75 "id": 3,
58 "label": "720p", 76 "label": "720p",
59 "src": "//src-url-here", 77 "height": "720",
60 "active": true 78 "active": true
61} 79}
62``` 80```
@@ -87,6 +105,7 @@ Set the playback volume. Value should be between `0` and `1`.
87## `getVolume(): Promise<number>` 105## `getVolume(): Promise<number>`
88 106
89Get the playback volume. Returns a value between `0` and `1`. 107Get the playback volume. Returns a value between `0` and `1`.
108
90# Events 109# Events
91 110
92You can subscribe to events by using `addEventListener()`. See above for details. 111You can subscribe to events by using `addEventListener()`. See above for details.