diff --git a/package.json b/package.json index 81ab32abc..2b8b3c750 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "@babel/plugin-transform-flow-strip-types": "^7.2.3", "@babel/preset-flow": "^7.0.0", "@babel/preset-react": "^7.0.0", + "@babel/register": "^7.0.0", "@hot-loader/react-dom": "16.8", "@lbry/color": "^1.0.2", "@lbry/components": "^2.2.4", @@ -113,6 +114,7 @@ "babel-eslint": "^10.0.1", "babel-loader": "^8.0.5", "babel-plugin-add-module-exports": "^1.0.0", + "babel-plugin-transform-imports": "^1.5.1", "chalk": "^2.4.2", "copy-webpack-plugin": "^4.6.0", "cross-env": "^5.2.0", diff --git a/src/platforms/electron/.babelrc b/src/platforms/electron/.babelrc new file mode 100644 index 000000000..db414b48b --- /dev/null +++ b/src/platforms/electron/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + ["@babel/preset-env", { "useBuiltIns": "entry" }], + "@babel/react", + "@babel/flow" + ], + "plugins": [ + "babel-plugin-transform-imports", + ["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }], + "@babel/plugin-transform-flow-strip-types", + "@babel/plugin-proposal-class-properties", + "babel-plugin-add-module-exports" + ] +} diff --git a/src/platforms/electron/devServer.js b/src/platforms/electron/devServer.js index c6318529c..2a9e40c1e 100644 --- a/src/platforms/electron/devServer.js +++ b/src/platforms/electron/devServer.js @@ -65,4 +65,8 @@ mainInstance.waitUntilValid(() => { const proc = require('child_process'); const child = proc.spawn(electron, ['./dist/electron/main.js']); + + child.stdout.on('data', (data) => { + console.log(data.toString()); + }); }); diff --git a/src/platforms/electron/index.js b/src/platforms/electron/index.js index 4bfc2db64..da2d13596 100644 --- a/src/platforms/electron/index.js +++ b/src/platforms/electron/index.js @@ -13,7 +13,7 @@ import Daemon from './Daemon'; import createTray from './createTray'; import createWindow from './createWindow'; import pjson from '../../../package.json'; -// import startSandbox from './startSandbox'; +import startSandbox from './startSandbox'; autoUpdater.autoDownload = true; @@ -36,13 +36,9 @@ let daemon; const appState = {}; const installExtensions = async () => { - // // eslint-disable-next-line import/no-extraneous-dependencies,global-require - // const installer = require('electron-devtools-installer'); - // // eslint-disable-next-line import/no-extraneous-dependencies,global-require - // const devtronExtension = require('devtron'); - // const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS']; - // await devtronExtension.install(); - // return Promise.all(extensions.map(name => installer.default(installer[name]))).catch(console.log); + // eslint-disable-next-line import/no-extraneous-dependencies,global-require + const devtronExtension = require('devtron'); + return await devtronExtension.install(); }; app.setAsDefaultProtocolClient('lbry'); @@ -89,7 +85,7 @@ app.on('ready', async () => { daemon.launch(); } - // startSandbox(); + startSandbox(); if (isDev) { await installExtensions(); diff --git a/src/platforms/electron/sandboxTest.js b/src/platforms/electron/sandboxTest.js new file mode 100644 index 000000000..32dc9edbc --- /dev/null +++ b/src/platforms/electron/sandboxTest.js @@ -0,0 +1,4 @@ +require('@babel/register'); +require("@babel/polyfill"); + +require('./startSandbox.js')(); diff --git a/src/platforms/electron/startSandbox.js b/src/platforms/electron/startSandbox.js index 3b0de06ae..6912911de 100644 --- a/src/platforms/electron/startSandbox.js +++ b/src/platforms/electron/startSandbox.js @@ -1,28 +1,32 @@ -// import express from 'express'; -// import unpackByOutpoint from './unpackByOutpoint'; +import express from 'express'; +import unpackByOutpoint from './unpackByOutpoint'; -// // Polyfills and `lbry-redux` -// global.fetch = require('node-fetch'); +// Polyfills and `lbry-redux` +global.fetch = require('node-fetch'); +global.window = global; +if (typeof(global.fetch) === 'object') { + global.fetch = global.fetch.default; +} -// global.window = global; -// // eslint-disable-next-line import/no-commonjs,global-require -// const { Lbry } = require('lbry-redux'); +// eslint-disable-next-line import/no-commonjs,global-require +const { Lbry } = require('lbry-redux'); -// delete global.window; +delete global.window; -// export default async function startSandbox() { -// const sandbox = express(); -// const port = 5278; +export default async function startSandbox() { + const sandbox = express(); + const port = 5278; -// sandbox.get('/set/:outpoint', async (req, res) => { -// const { outpoint } = req.params; -// const resolvedPath = await unpackByOutpoint(Lbry, outpoint); + sandbox.get('/set/:outpoint', async (req, res) => { + const { outpoint } = req.params; -// sandbox.use(`/sandbox/${outpoint}/`, express.static(resolvedPath)); + const resolvedPath = await unpackByOutpoint(Lbry, outpoint); -// res.send(`/sandbox/${outpoint}/`); -// }); + sandbox.use(`/sandbox/${outpoint}/`, express.static(resolvedPath)); -// // eslint-disable-next-line no-console -// sandbox.listen(port, 'localhost', () => console.log(`Sandbox listening on port ${port}.`)); -// } + res.send(`/sandbox/${outpoint}/`); + }); + + // eslint-disable-next-line no-console + sandbox.listen(port, 'localhost', () => console.log(`Sandbox listening on port ${port}.`)); +} diff --git a/src/ui/component/fileViewer/internal/player.jsx b/src/ui/component/fileViewer/internal/player.jsx index ed78026d1..08c1a4fe5 100644 --- a/src/ui/component/fileViewer/internal/player.jsx +++ b/src/ui/component/fileViewer/internal/player.jsx @@ -202,7 +202,9 @@ class MediaPlayer extends React.PureComponent { } const playerElement = this.mediaContainer.current; if (playerElement) { - playerElement.children[0].play(); + if(playerElement.children && playerElement.children[0]) { + playerElement.children[0].play(); + } } } // @endif @@ -254,13 +256,19 @@ class MediaPlayer extends React.PureComponent { // This is what render-media does with unplayable files const { claim, fileName, downloadPath, contentType } = this.props; + console.log('render', contentType, MediaPlayer.SANDBOX_TYPES) + if (MediaPlayer.SANDBOX_TYPES.indexOf(contentType) > -1) { + console.log('claim', claim) const outpoint = `${claim.txid}:${claim.nout}`; + console.log('fetch', `${MediaPlayer.SANDBOX_SET_BASE_URL}${outpoint}`) + return fetch(`${MediaPlayer.SANDBOX_SET_BASE_URL}${outpoint}`) .then(res => res.text()) .then(url => { const fileSource = { url: `${MediaPlayer.SANDBOX_CONTENT_BASE_URL}${url}` }; + console.log('set source', fileSource) return this.setState({ fileSource }); }); } @@ -324,6 +332,9 @@ class MediaPlayer extends React.PureComponent { const { fileSource } = this.state; const isFileType = this.isSupportedFile(); + + console.log('isFileType', isFileType); + const isFileReady = fileSource && isFileType; const isPlayableType = this.playableType(); const { isLoading, loadingStatus } = this.showLoadingScreen(isFileType, isPlayableType); diff --git a/yarn.lock b/yarn.lock index dd40e4eba..bbcf4e69e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -714,6 +714,19 @@ "@babel/plugin-transform-react-jsx-self" "^7.0.0" "@babel/plugin-transform-react-jsx-source" "^7.0.0" +"@babel/register@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.0.0.tgz#fa634bae1bfa429f60615b754fc1f1d745edd827" + integrity sha512-f/+CRmaCe7rVEvcvPvxeA8j5aJhHC3aJie7YuqcMDhUOuyWLA7J/aNrTaHIzoWPEhpHA54mec4Mm8fv8KBlv3g== + dependencies: + core-js "^2.5.7" + find-cache-dir "^1.0.0" + home-or-tmp "^3.0.0" + lodash "^4.17.10" + mkdirp "^0.5.1" + pirates "^4.0.0" + source-map-support "^0.5.9" + "@babel/runtime@^7.1.2", "@babel/runtime@^7.2.0": version "7.3.4" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.4.tgz#73d12ba819e365fcf7fd152aed56d6df97d21c83" @@ -1491,6 +1504,18 @@ babel-plugin-component@^1.1.1: dependencies: "@babel/helper-module-imports" "7.0.0-beta.35" +babel-plugin-transform-imports@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-imports/-/babel-plugin-transform-imports-1.5.1.tgz#b3756696aea907719d0d63b0e67c88fba963adb0" + integrity sha512-Jkb0tjqye8kjOD7GdcKJTGB3dC9fruQhwRFZCeYS0sZO2otyjG6SohKR8nZiSm/OvhY+Ny2ktzVE59XKgIqskA== + dependencies: + babel-types "^6.6.0" + is-valid-path "^0.1.1" + lodash.camelcase "^4.3.0" + lodash.findkey "^4.6.0" + lodash.kebabcase "^4.1.1" + lodash.snakecase "^4.1.1" + babel-polyfill@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" @@ -1508,6 +1533,16 @@ babel-runtime@6.x, babel-runtime@^6.26.0: core-js "^2.4.0" regenerator-runtime "^0.11.0" +babel-types@^6.6.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" + integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc= + dependencies: + babel-runtime "^6.26.0" + esutils "^2.0.2" + lodash "^4.17.4" + to-fast-properties "^1.0.3" + bail@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/bail/-/bail-1.0.3.tgz#63cfb9ddbac829b02a3128cd53224be78e6c21a3" @@ -4955,6 +4990,11 @@ hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: dependencies: react-is "^16.7.0" +home-or-tmp@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-3.0.0.tgz#57a8fe24cf33cdd524860a15821ddc25c86671fb" + integrity sha1-V6j+JM8zzdUkhgoVgh3cJchmcfs= + homedir-polyfill@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" @@ -5477,6 +5517,11 @@ is-extendable@^1.0.1: dependencies: is-plain-object "^2.0.4" +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + integrity sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA= + is-extglob@^2.1.0, is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" @@ -5506,6 +5551,13 @@ is-function@^1.0.1: resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5" integrity sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU= +is-glob@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + integrity sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM= + dependencies: + is-extglob "^1.0.0" + is-glob@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" @@ -5533,6 +5585,13 @@ is-installed-globally@^0.1.0: global-dirs "^0.1.0" is-path-inside "^1.0.0" +is-invalid-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-invalid-path/-/is-invalid-path-0.1.0.tgz#307a855b3cf1a938b44ea70d2c61106053714f34" + integrity sha1-MHqFWzzxqTi0TqcNLGEQYFNxTzQ= + dependencies: + is-glob "^2.0.0" + is-nan@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.2.1.tgz#9faf65b6fb6db24b7f5c0628475ea71f988401e2" @@ -5666,6 +5725,13 @@ is-utf8@^0.2.0: resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= +is-valid-path@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-valid-path/-/is-valid-path-0.1.1.tgz#110f9ff74c37f663e1ec7915eb451f2db93ac9df" + integrity sha1-EQ+f90w39mPh7HkV60UfLbk6yd8= + dependencies: + is-invalid-path "^0.1.0" + is-whitespace-character@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-whitespace-character/-/is-whitespace-character-1.0.2.tgz#ede53b4c6f6fb3874533751ec9280d01928d03ed" @@ -6176,11 +6242,21 @@ lodash.assign@^4.0.3, lodash.assign@^4.0.6, lodash.assign@^4.2.0: resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" integrity sha1-DZnzzNem0mHRm9rrkkUAXShYCOc= +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY= + lodash.clonedeep@^4.3.2: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= +lodash.findkey@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.findkey/-/lodash.findkey-4.6.0.tgz#83058e903b51cbb759d09ccf546dea3ea39c4718" + integrity sha1-gwWOkDtRy7dZ0JzPVG3qPqOcRxg= + lodash.forin@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.forin/-/lodash.forin-4.4.0.tgz#5d3f20ae564011fbe88381f7d98949c9c9519731" @@ -6201,6 +6277,11 @@ lodash.isequal@4.5.0, lodash.isequal@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA= +lodash.kebabcase@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" + integrity sha1-hImxyw0p/4gZXM7KRI/21swpXDY= + lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" @@ -6221,6 +6302,11 @@ lodash.set@^4.3.2: resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM= +lodash.snakecase@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz#39d714a35357147837aefd64b5dcbb16becd8f8d" + integrity sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40= + lodash.tail@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664" @@ -6954,6 +7040,11 @@ node-loader@^0.6.0: resolved "https://registry.yarnpkg.com/node-loader/-/node-loader-0.6.0.tgz#c797ef51095ed5859902b157f6384f6361e05ae8" integrity sha1-x5fvUQle1YWZArFX9jhPY2HgWug= +node-modules-regexp@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40" + integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA= + node-pre-gyp@^0.10.0: version "0.10.3" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc" @@ -7613,6 +7704,13 @@ pinkie@^2.0.0: resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= +pirates@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.1.tgz#643a92caf894566f91b2b986d2c66950a8e2fb87" + integrity sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA== + dependencies: + node-modules-regexp "^1.0.0" + pkcs7@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pkcs7/-/pkcs7-1.0.2.tgz#b6dba527528c2942bfc122ce2dafcdb5e59074e7" @@ -10062,6 +10160,11 @@ to-buffer@^1.1.1: resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80" integrity sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg== +to-fast-properties@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" + integrity sha1-uDVx+k2MJbguIxsG46MFXeTKGkc= + to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"