-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/reject-invalid-paths
# Conflicts: # apps/http-server/packages/generic/src/storage/fileStorage.ts # shared/packages/api/src/lib.ts # shared/packages/worker/src/worker/accessorHandlers/http.ts # shared/packages/worker/src/worker/accessorHandlers/lib/FileHandler.ts
- Loading branch information
Showing
73 changed files
with
5,337 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ffmpeg.exe | ||
ffprobe.exe | ||
log.log | ||
deploy/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# HTML Renderer | ||
|
||
## How to run | ||
|
||
### Default CasparCG template | ||
|
||
_This is used for a HTML file that follows the typical CasparCG lifespan (`update(data); play(); stop()`)_ | ||
|
||
```bash | ||
html-renderer.exe -- --url=file://C:/templates/mytemplate.html outputPath="C:\\rendered" --screenshots=true --recording=true --recording-cropped=true --casparData='{"name":"John Doe"}' --casparDelay=1000 | ||
``` | ||
|
||
### Generic HTML template | ||
|
||
_This is used for a HTML file that doesn't require any additional input during its run._ | ||
|
||
```bash | ||
html-renderer.exe -- --url=https://bouncingdvdlogo.com outputPath="C:\\rendered" --screenshots=true --recording=true --recording-cropped=false --genericWaitIdle=1000 --genericWaitPlay=1000 --genericWaitStop=1000 --width=480 --height=320 --zoom=0.25 | ||
``` | ||
|
||
### Interactive mode | ||
|
||
_This is used for HTML templates that require manual handling (like, external API calls need to be made)_ | ||
|
||
```bash | ||
html-renderer.exe -- --url=https://bouncingdvdlogo.com outputPath=C:\\rendered --interactive=1 | ||
``` | ||
|
||
In interactive mode, commands are sent to the renderer via the console. The following commands are available: | ||
|
||
```json | ||
|
||
// Wait for this message before sending interactive messages. | ||
{ "status": "ready" } | ||
|
||
|
||
// Wait for the load event to be fired | ||
{ "do": "waitForLoad" } | ||
// Reply: | ||
{ "reply": "waitForLoad" } | ||
|
||
// Take a screenshot and save it as PNG | ||
{ "do": "takeScreenshot", "fileName": "screenshot.png" } | ||
// Reply: | ||
{ "reply": "takeScreenshot" } | ||
{ "reply": "takeScreenshot", "error": "Unable to write file \"screenshot.png\"" } | ||
|
||
// Start recording | ||
{ "do": "startRecording", "fileName": "recording.webm" } | ||
// Reply: | ||
{ "reply": "startRecording" } | ||
{ "reply": "startRecording", "error": "Recording already started" } | ||
|
||
|
||
// Stop recording | ||
{ "do": "stopRecording" } | ||
// Reply: | ||
{ "reply": "stopRecording"} | ||
{ "reply": "stopRecording", "error": "Unable to write file \"recording.webm\"" } | ||
|
||
// Analyze the recording and crop it to only include the region with content | ||
{ "do": "cropRecording", "fileName": "recording-cropped.webm" } | ||
// Reply: | ||
{ "reply": "cropRecording" } | ||
{ "reply": "cropRecording", "error": "No recording found" } | ||
|
||
// Execute javascript in the renderer | ||
{ "do": "executeJs", "js": "update(\"myData\")" } | ||
// Reply: | ||
{ "reply": "executeJs" } | ||
{ "reply": "executeJs", "error": "Some error" } | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const base = require('../../../jest.config.base') | ||
const packageJson = require('./package') | ||
|
||
module.exports = { | ||
...base, | ||
displayName: packageJson.name, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"name": "@html-renderer/app", | ||
"version": "1.50.5", | ||
"description": "HTML-renderer", | ||
"private": true, | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "yarn rimraf dist && yarn build:main", | ||
"build:main": "tsc -p tsconfig.json", | ||
"build-win32": "yarn prepare-build-win32 && electron-builder && yarn post-build-win32", | ||
"prepare-build-win32": "node scripts/prepare_build.js", | ||
"post-build-win32": "node scripts/post_build.js", | ||
"__test": "jest", | ||
"start": "electron dist/index.js" | ||
}, | ||
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json", | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"lint-staged": { | ||
"*.{js,css,json,md,scss}": [ | ||
"prettier" | ||
], | ||
"*.{ts,tsx}": [ | ||
"eslint" | ||
] | ||
}, | ||
"peerDependencies": { | ||
"ws": "*" | ||
}, | ||
"dependencies": { | ||
"@html-renderer/generic": "1.50.5", | ||
"@sofie-automation/shared-lib": "1.51.0-nightly-fix-pm-types-html-template-20240823-061828-d90c220.0", | ||
"@sofie-package-manager/api": "1.50.6", | ||
"portfinder": "^1.0.32", | ||
"tslib": "^2.1.0", | ||
"yargs": "^17.7.2" | ||
}, | ||
"devDependencies": { | ||
"@types/ws": "^8.5.4", | ||
"archiver": "^7.0.1", | ||
"electron": "30.0.6", | ||
"electron-builder": "^24.13.3", | ||
"lerna": "^6.6.1", | ||
"rimraf": "^5.0.5" | ||
}, | ||
"build": { | ||
"productName": "html-renderer", | ||
"appId": "no.nrk.sofie.html-renderer", | ||
"win": { | ||
"extraFiles": [], | ||
"target": [ | ||
{ | ||
"target": "portable", | ||
"arch": [ | ||
"x64" | ||
] | ||
} | ||
] | ||
}, | ||
"linux": { | ||
"target": "dir", | ||
"executableName": "html-renderer", | ||
"extraFiles": [] | ||
}, | ||
"files": [ | ||
"dist/**/*" | ||
], | ||
"portable": { | ||
"artifactName": "html-renderer.exe" | ||
}, | ||
"directories": { | ||
"output": "deploy" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* eslint-disable no-console, node/no-unpublished-require */ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const archiver = require('archiver') | ||
|
||
/* | ||
* This script gathers the built files from electron-builder and zips them into a zip file | ||
*/ | ||
|
||
async function main() { | ||
const myDir = path.resolve('.') | ||
const deployDir = path.join(myDir, 'deploy') | ||
const archiveDir = path.join(deployDir, 'win-unpacked') | ||
|
||
const zipFile = path.join(deployDir, 'html-renderer.zip') | ||
|
||
await new Promise((resolve, reject) => { | ||
const output = fs.createWriteStream(zipFile) | ||
const archive = archiver('zip', { | ||
zlib: { level: 5 }, // Sets the compression level. | ||
}) | ||
output.on('close', function () { | ||
console.log(archive.pointer() + ' total bytes') | ||
resolve() | ||
}) | ||
archive.on('warning', function (err) { | ||
if (err.code === 'ENOENT') console.log(`WARNING: ${err}`) | ||
else reject(err) | ||
}) | ||
archive.on('error', reject) | ||
archive.pipe(output) | ||
|
||
console.log(`Archiving ${archiveDir}`) | ||
archive.directory(archiveDir, false) | ||
|
||
archive.finalize() | ||
}) | ||
console.log('Zipping done, removing temporary artifacts...') | ||
|
||
// Remove the archived directory | ||
await fs.promises.rm(archiveDir, { recursive: true }) | ||
await fs.promises.rm(path.join(deployDir, 'html-renderer.exe'), { recursive: true }) | ||
await fs.promises.rm(path.join(myDir, 'node_modules'), { recursive: true }) | ||
} | ||
|
||
main().catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
/* eslint-disable no-console */ | ||
|
||
/* | ||
* This script copies some dependencies from the main node_modules folder to the node_modules folder of this project. | ||
* So that electron-builder includes them when building the executable. | ||
*/ | ||
|
||
async function main() { | ||
// Things to copy: | ||
|
||
const baseDir = path.resolve('../../..') | ||
const myDir = path.resolve('.') | ||
|
||
const libsToCopy = ['tslib', '@sofie-automation'] | ||
|
||
// Create node_modules folder | ||
await fs.promises.mkdir(path.join(myDir, 'node_modules'), { recursive: true }) | ||
|
||
for (const lib of libsToCopy) { | ||
const src = path.join(baseDir, `node_modules/${lib}`) | ||
const target = path.join(myDir, `node_modules/${lib}`) | ||
console.log(`Copying ${src} to ${target}`) | ||
await fs.promises.cp(src, target, { | ||
recursive: true, | ||
}) | ||
} | ||
} | ||
|
||
main().catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe('tmp', () => { | ||
test('tmp', () => { | ||
// Note: To enable tests in this package, ensure that the "test" script is present in package.json | ||
expect(1).toEqual(1) | ||
}) | ||
}) | ||
export {} |
Oops, something went wrong.