shiveshnavin commited on
Commit
f431cd4
·
1 Parent(s): bf6291d
.gitignore CHANGED
@@ -9,4 +9,5 @@ ffmpeg/
9
  public/
10
  **.zip
11
  yarn.lock
12
- package-lock.json
 
 
9
  public/
10
  **.zip
11
  yarn.lock
12
+ package-lock.json
13
+ functions/*.log
server.ts → app.js RENAMED
@@ -1,21 +1,19 @@
1
-
2
- import express from 'express'
3
- import stream from 'stream'
4
- import bodyParser from 'body-parser';
5
- import { spawn } from 'child_process';
6
- import fs from 'fs'
7
- import path from 'path'
8
- import { Utils } from './common-utils';
9
- import { UnzipFiles } from './common-utils/utils/FileZipper';
10
- import { OriginalManuscript } from './src/OriginalManuscriptModel';
11
- import OracheStorage from './common-creds/oracle/storage.json'
12
- import axios from 'axios';
13
 
14
  let pl = {
15
  onLog: console.log
16
  }
17
 
18
- let jobs: any = {}
19
  function render() {
20
  let outputFile = '';
21
  let thumbnailFile = '';
@@ -80,7 +78,7 @@ function render() {
80
  }
81
 
82
 
83
- function modifyFiles(originalManuscript: OriginalManuscript) {
84
 
85
  let fname = path.join(__dirname, "./src/textWithBgImage/SequentialScene.orig.tsx")
86
  let fnameTarget = path.join(__dirname, "./src/textWithBgImage/SequentialScene.tsx")
@@ -96,7 +94,7 @@ function modifyFiles(originalManuscript: OriginalManuscript) {
96
  fs.writeFileSync(fnameTarget, SequentialSceneText.replace("{getScene(contents[0])}", seqScene));
97
 
98
  }
99
- async function extract(filePath: string) {
100
  await UnzipFiles(filePath, './public')
101
  }
102
 
@@ -146,7 +144,7 @@ app.all('/render', async (req, res) => {
146
  message: 'The asset bundle dosent contain a original_manuscript.json at root'
147
  })
148
  }
149
- let manuObj: OriginalManuscript = JSON.parse(fs.readFileSync(manuFile).toString())
150
  modifyFiles(manuObj)
151
 
152
  res.send({
@@ -165,7 +163,7 @@ app.use('/out', express.static(path.join(__dirname, 'out')));
165
 
166
 
167
  const uploadDir = path.join(__dirname, 'uploads');
168
- const oracleAPI = OracheStorage.semibit_media.url
169
 
170
  if (!fs.existsSync(uploadDir)) {
171
  fs.mkdirSync(uploadDir);
@@ -204,12 +202,9 @@ app.get('/', (req, res) => {
204
 
205
  fs.writeFileSync('index.html', fs.readFileSync('index.html').toString().replace("___ORACLE_API_BASE___", oracleAPI))
206
 
207
- let port = process.env.PORT || 8083
208
- app.listen(port, () => {
209
- console.log("Remote renderer listenting at port", port)
210
- })
211
 
212
 
 
213
 
214
  // let manuFile = path.join(__dirname, 'public/original_manuscript.json')
215
  // let manuObj: OriginalManuscript = JSON.parse(fs.readFileSync(manuFile).toString())
 
1
+ const express = require('express');
2
+ const stream = require('stream');
3
+ const bodyParser = require('body-parser');
4
+ const { spawn } = require('child_process');
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const { Utils } = require('common-utils');
8
+ const { ZipFiles, UnzipFiles } = require('common-utils');
9
+ const OracleStorage = require('./common-creds/oracle/storage.json');
10
+ const axios = require('axios');
 
 
11
 
12
  let pl = {
13
  onLog: console.log
14
  }
15
 
16
+ let jobs = {}
17
  function render() {
18
  let outputFile = '';
19
  let thumbnailFile = '';
 
78
  }
79
 
80
 
81
+ function modifyFiles(originalManuscript) {
82
 
83
  let fname = path.join(__dirname, "./src/textWithBgImage/SequentialScene.orig.tsx")
84
  let fnameTarget = path.join(__dirname, "./src/textWithBgImage/SequentialScene.tsx")
 
94
  fs.writeFileSync(fnameTarget, SequentialSceneText.replace("{getScene(contents[0])}", seqScene));
95
 
96
  }
97
+ async function extract(filePath) {
98
  await UnzipFiles(filePath, './public')
99
  }
100
 
 
144
  message: 'The asset bundle dosent contain a original_manuscript.json at root'
145
  })
146
  }
147
+ let manuObj = JSON.parse(fs.readFileSync(manuFile).toString())
148
  modifyFiles(manuObj)
149
 
150
  res.send({
 
163
 
164
 
165
  const uploadDir = path.join(__dirname, 'uploads');
166
+ const oracleAPI = OracleStorage.semibit_media.url
167
 
168
  if (!fs.existsSync(uploadDir)) {
169
  fs.mkdirSync(uploadDir);
 
202
 
203
  fs.writeFileSync('index.html', fs.readFileSync('index.html').toString().replace("___ORACLE_API_BASE___", oracleAPI))
204
 
 
 
 
 
205
 
206
 
207
+ module.exports = app
208
 
209
  // let manuFile = path.join(__dirname, 'public/original_manuscript.json')
210
  // let manuObj: OriginalManuscript = JSON.parse(fs.readFileSync(manuFile).toString())
ffmpeg-fix.js CHANGED
@@ -22,7 +22,7 @@ async function createSymlink(targetPath, symlinkPath) {
22
  await fs.symlink(targetPath, symlinkPath);
23
  console.log('Symlink created successfully:', symlinkPath);
24
  } catch (error) {
25
- console.error('An error occurred:', error);
26
  }
27
  }
28
 
@@ -33,7 +33,7 @@ async function findAndCreateSymlink(targetExecutable, ffmpegPath) {
33
  const symlinkPath = path.join(__dirname, 'node_modules', '@remotion', 'compositor-win32-x64-msvc', 'ffmpeg', 'remotion', 'bin', targetExecutable);
34
  await createSymlink(ffmpegPath, symlinkPath);
35
  } catch (error) {
36
- console.error('An error occurred while locating ffmpeg:', error);
37
  }
38
  }
39
  const ffmpegtargetExecutable = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
 
22
  await fs.symlink(targetPath, symlinkPath);
23
  console.log('Symlink created successfully:', symlinkPath);
24
  } catch (error) {
25
+ console.error('An error occurred:', error.message);
26
  }
27
  }
28
 
 
33
  const symlinkPath = path.join(__dirname, 'node_modules', '@remotion', 'compositor-win32-x64-msvc', 'ffmpeg', 'remotion', 'bin', targetExecutable);
34
  await createSymlink(ffmpegPath, symlinkPath);
35
  } catch (error) {
36
+ console.error('An error occurred while creating symlink ffmpeg:', error);
37
  }
38
  }
39
  const ffmpegtargetExecutable = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
firebase.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "functions": {
3
+ "codebase": "semibitmedia",
4
+ "predeploy": [
5
+ "echo Hey"
6
+ ]
7
+ },
8
+ "emulators": {
9
+ "functions": {
10
+ "port": 5001
11
+ },
12
+ "firestore": {
13
+ "port": 8080
14
+ },
15
+ "ui": {
16
+ "enabled": true
17
+ }
18
+ }
19
+ }
functions/index.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { logger } = require("firebase-functions");
2
+ const { onRequest } = require("firebase-functions/v2/https");
3
+ const { setGlobalOptions } = require("firebase-functions/v2");
4
+
5
+ const { initializeApp } = require("firebase-admin/app");
6
+ const { default: app } = require("../app");
7
+ setGlobalOptions({
8
+ region: "us-central1",
9
+ // memory: "2GiB",
10
+ maxInstances: 1,
11
+ minInstances: 0
12
+ });
13
+
14
+ initializeApp();
15
+
16
+ exports.ping = onRequest(async (req, res) => {
17
+ const original = req.query.text;
18
+
19
+ res.json({ result: `Working` });
20
+ });
21
+
22
+
23
+ exports.ping = onRequest(app);
24
+
functions/package.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "functions",
3
+ "description": "Cloud Functions for Firebase",
4
+ "dependencies": {
5
+ "firebase-admin": "^11.9.0",
6
+ "firebase-functions": "^4.4.1"
7
+ },
8
+ "devDependencies": {
9
+ "chai": "^4.3.6",
10
+ "chai-as-promised": "^7.1.1",
11
+ "eslint": "^8.40.0",
12
+ "mocha": "^7.2.0",
13
+ "sinon": "^9.2.4"
14
+ },
15
+ "scripts": {
16
+ "serve": "firebase emulators:start --only functions --project semibitmedia",
17
+ "shell": "firebase functions:shell --project semibitmedia",
18
+ "start": "npm run shell",
19
+ "deploy": "firebase deploy --only functions --project semibitmedia",
20
+ "logs": "firebase functions:log --project semibitmedia",
21
+ "compile": "cp ../tsconfig.json ./tsconfig-compile.json && tsc --project tsconfig-compile.json && cd .. && npm run build"
22
+ },
23
+ "engines": {
24
+ "node": "16"
25
+ },
26
+ "private": true
27
+ }
package-lock.json CHANGED
The diff for this file is too large to render. See raw diff
 
package.json CHANGED
@@ -8,12 +8,12 @@
8
  "scripts": {
9
  "start": "ts-node-dev --respawn --transpile-only server.ts",
10
  "preview": "remotion studio",
11
- "render-build": "remotion render SemibitComposition ",
12
  "render-still": "remotion still --image-format=jpeg SemibitCompositionPoster ",
13
- "build": "remotion render --image-format=jpeg --quality=70 --gl=angle SemibitComposition ",
14
  "upgrade": "remotion upgrade",
15
  "test": "eslint src --ext ts,tsx,js,jsx && tsc",
16
- "postinstall": "node ffmpeg-fix.js"
17
  },
18
  "repository": {},
19
  "license": "UNLICENSED",
@@ -33,6 +33,7 @@
33
  "@remotion/zod-types": "4.0.19",
34
  "axios": "^1.4.0",
35
  "body-parser": "^1.20.2",
 
36
  "express": "^4.18.2",
37
  "ffbinaries": "^1.1.5",
38
  "fs-extra": "^11.1.1",
 
8
  "scripts": {
9
  "start": "ts-node-dev --respawn --transpile-only server.ts",
10
  "preview": "remotion studio",
11
+ "render-build": "remotion render --image-format=jpeg --quality=70 --gl=angle SemibitComposition ",
12
  "render-still": "remotion still --image-format=jpeg SemibitCompositionPoster ",
13
+ "build": "tsc --noEmitOnError --noUnusedLocals --noUnusedParameters --allowUnusedLabels",
14
  "upgrade": "remotion upgrade",
15
  "test": "eslint src --ext ts,tsx,js,jsx && tsc",
16
+ "postinstall": "cd node_modules/common-utils && npm run build && cd ../../ && node ffmpeg-fix.js"
17
  },
18
  "repository": {},
19
  "license": "UNLICENSED",
 
33
  "@remotion/zod-types": "4.0.19",
34
  "axios": "^1.4.0",
35
  "body-parser": "^1.20.2",
36
+ "common-utils": "file:common-utils",
37
  "express": "^4.18.2",
38
  "ffbinaries": "^1.1.5",
39
  "fs-extra": "^11.1.1",
server.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ const app = require('./app')
2
+ let port = process.env.PORT || 8083
3
+ app.listen(port, () => {
4
+ console.log("Remote renderer listenting at port", port)
5
+ })
tsconfig.json CHANGED
@@ -1,5 +1,6 @@
1
  {
2
  "compilerOptions": {
 
3
  "target": "ES2018",
4
  "resolveJsonModule": true,
5
  "module": "commonjs",
 
1
  {
2
  "compilerOptions": {
3
+ "allowSyntheticDefaultImports": true,
4
  "target": "ES2018",
5
  "resolveJsonModule": true,
6
  "module": "commonjs",