Skip to content

Commit

Permalink
Merge branch 'MarmadileManteater:development' into dockerize
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenTruong authored Jun 28, 2023
2 parents f279288 + d9656c0 commit fc9cf85
Show file tree
Hide file tree
Showing 166 changed files with 7,141 additions and 13,845 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ module.exports = {
{
files: ['*.json'],
parser: 'jsonc-eslint-parser',
extends: ['plugin:jsonc/base'],
rules: {
'no-tabs': 'off',
'comma-spacing': 'off'
}
},
{
files: ['*.yaml', '*.yml'],
parser: 'yaml-eslint-parser',
extends: ['plugin:yml/recommended'],
rules: {
'yml/no-irregular-whitespace': 'off'
}
}
],

Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ updates:
labels:
- "PR: waiting for review"
- "PR: dependencies"
open-pull-requests-limit: 10
open-pull-requests-limit: 15
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/autoLabelIssue.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
"labels": ["B: visual"]
},
{
"keywords": ["AUR", "Chocolatey", "PortableApps", "winget", "Scoop", "MPR"],
"keywords": ["AUR", "Chocolatey", "FreeTubeCordova", "PortableApps", "winget", "Scoop", "Snapcraft", "MPR"],
"labels": ["B: Unofficial Download"]
},
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/calibreapp-image-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
compressOnly: true
- name: Create New Pull Request If Needed
if: steps.calibre.outputs.markdown != ''
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v5
with:
title: Compressed Images Nightly
branch-suffix: timestamp
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v7
- uses: actions/stale@v8
with:
stale-issue-message: 'This issue is stale because it has been open 28 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
stale-pr-message: 'This PR is stale because it has been open 28 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
Expand Down
19 changes: 18 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,22 @@
"less",
"postcss",
"scss"
]
],
"eslint.packageManager": "yarn",
"eslint.probe": [
"javascript",
"vue",
"json",
"jsonc",
"yml",
"yaml"
],
"eslint.validate": [
"javascript",
"vue",
"json",
"jsonc",
"yml",
"yaml"
],
}
21 changes: 21 additions & 0 deletions _scripts/ProcessLocalesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class ProcessLocalesPlugin {
delete data['Locale Name']
}

this.removeEmptyValues(data)

let filename = `${this.outputDir}/${locale}.json`
let output = JSON.stringify(data)

Expand Down Expand Up @@ -92,6 +94,25 @@ class ProcessLocalesPlugin {
}
})
}

/**
* vue-i18n doesn't fallback if the translation is an empty string
* so we want to get rid of them and also remove the empty objects that can get left behind
* if we've removed all the keys and values in them
* @param {object|string} data
*/
removeEmptyValues(data) {
for (const key of Object.keys(data)) {
const value = data[key]
if (typeof value === 'object') {
this.removeEmptyValues(value)
}

if (!value || (typeof value === 'object' && Object.keys(value).length === 0)) {
delete data[key]
}
}
}
}

module.exports = ProcessLocalesPlugin
5 changes: 5 additions & 0 deletions _scripts/_domParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const DOMParser = window.DOMParser

export {
DOMParser
}
Empty file added _scripts/_empty.js
Empty file.
16 changes: 16 additions & 0 deletions _scripts/getInstances.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const fs = require('fs/promises')
const invidiousApiUrl = 'https://api.invidious.io/instances.json'

fetch(invidiousApiUrl).then(e => e.json()).then(res => {
const data = res.filter((instance) => {
return !(instance[0].includes('.onion') ||
instance[0].includes('.i2p') ||
!instance[1].api)
}).map((instance) => {
return {
url: instance[1].uri.replace(/\/$/, ''),
cors: instance[1].cors
}
})
fs.writeFile('././static/invidious-instances.json', JSON.stringify(data, null, 2))
})
49 changes: 29 additions & 20 deletions _scripts/webpack.cordova.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const config = {
{
electron: '{}',
cordova: 'cordova',
'music-controls': 'MusicControls'
'music-controls': 'MusicControls',
'universal-links': 'universalLinks'
}
],
module: {
Expand All @@ -39,7 +40,12 @@ const config = {
},
{
test: /\.vue$/,
loader: 'vue-loader'
loader: 'vue-loader',
options: {
compilerOptions: {
whitespace: 'condense',
}
}
},
{
test: /\.scss$/,
Expand Down Expand Up @@ -75,10 +81,6 @@ const config = {
}
],
},
{
test: /\.html$/,
use: 'vue-html-loader',
},
{
test: /\.(png|jpe?g|gif|tif?f|bmp|webp|svg)(\?.*)?$/,
type: 'asset/resource',
Expand Down Expand Up @@ -113,7 +115,19 @@ const config = {
new webpack.DefinePlugin({
'process.env.IS_ELECTRON': false,
'process.env.IS_ELECTRON_MAIN': false,
'process.env.IS_CORDOVA': true
'process.env.IS_CORDOVA': true,

// video.js' vhs-utils supports both atob() in web browsers and Buffer in node
// As the FreeTube web build only runs in web browsers, we can override their check for atob() here: https://github.com/videojs/vhs-utils/blob/main/src/decode-b64-to-uint8-array.js#L3
// overriding that check means we don't need to include a Buffer polyfill
// https://caniuse.com/atob-btoa

// NOTE FOR THE FUTURE: this override won't work with vite as their define does a find and replace in the code for production builds,
// but uses globals in development builds to save build time, so this would replace the actual atob() function with true if used with vite
// this works in webpack as webpack does a find and replace in the source code for both development and production builds
// https://vitejs.dev/config/shared-options.html#define
// https://webpack.js.org/plugins/define-plugin/
'window.atob': true
}),
new webpack.ProvidePlugin({
process: 'process/browser',
Expand All @@ -134,22 +148,17 @@ const config = {
],
resolve: {
alias: {
vue$: 'vue/dist/vue.esm.js'
vue$: 'vue/dist/vue.esm.js',
'jintr': 'jintr-patch',
'youtubei.js$': 'youtubei.js/web',
// video.js's mpd-parser uses @xmldom/xmldom so that it can support both node and web browsers
// As FreeTube only runs in electron and web browsers, we can use the native DOMParser class, instead of the "polyfill"
// https://caniuse.com/mdn-api_domparser
'@xmldom/xmldom$': path.resolve(__dirname, '_domParser.js')
},
fallback: {
buffer: require.resolve('buffer/'),
dns: require.resolve('browserify/lib/_empty.js'),
'fs/promises': require.resolve('browserify/lib/_empty.js'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
net: require.resolve('browserify/lib/_empty.js'),
os: require.resolve('os-browserify/browser.js'),
'fs/promises': path.resolve(__dirname, '_empty.js'),
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
timers: require.resolve('timers-browserify'),
tls: require.resolve('browserify/lib/_empty.js'),
vm: require.resolve('vm-browserify'),
zlib: require.resolve('browserify-zlib')
},
extensions: ['.js', '.vue']
},
Expand Down
10 changes: 8 additions & 2 deletions _scripts/webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const config = {
},
externals: {
cordova: 'browserify/lib/_empty.js',
'music-controls': 'browserify/lib/_empty.js'
'music-controls': 'browserify/lib/_empty.js',
'universal-links': 'browserify/lib/_empty.js'
},
module: {
rules: [
Expand Down Expand Up @@ -137,9 +138,14 @@ const config = {
],
resolve: {
alias: {
vue$: 'vue/dist/vue.common.js',
vue$: 'vue/dist/vue.runtime.esm.js',

'youtubei.js$': 'youtubei.js/web',

// video.js's mpd-parser uses @xmldom/xmldom so that it can support both node and web browsers
// as FreeTube only runs in electron and web browsers we can use the native DOMParser class, instead of the "polyfill"
// https://caniuse.com/mdn-api_domparser
'@xmldom/xmldom$': path.resolve(__dirname, '_domParser.js')
},
extensions: ['.js', '.vue']
},
Expand Down
42 changes: 24 additions & 18 deletions _scripts/webpack.web.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const config = {
electron: '{}',
cordova: '{}',
'music-controls': '{}',
'youtubei.js': '{}'
'youtubei.js': '{}',
'universal-links': '{}'
},
module: {
rules: [
Expand Down Expand Up @@ -115,11 +116,23 @@ const config = {
plugins: [
new webpack.DefinePlugin({
'process.env.IS_ELECTRON': false,
'process.env.IS_CORDOVA': false
'process.env.IS_CORDOVA': false,
'process.env.IS_ELECTRON_MAIN': false,

// video.js' vhs-utils supports both atob() in web browsers and Buffer in node
// As the FreeTube web build only runs in web browsers, we can override their check for atob() here: https://github.com/videojs/vhs-utils/blob/main/src/decode-b64-to-uint8-array.js#L3
// overriding that check means we don't need to include a Buffer polyfill
// https://caniuse.com/atob-btoa

// NOTE FOR THE FUTURE: this override won't work with vite as their define does a find and replace in the code for production builds,
// but uses globals in development builds to save build time, so this would replace the actual atob() function with true if used with vite
// this works in webpack as webpack does a find and replace in the source code for both development and production builds
// https://vitejs.dev/config/shared-options.html#define
// https://webpack.js.org/plugins/define-plugin/
'window.atob': true
}),
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
process: 'process/browser'
}),
new HtmlWebpackPlugin({
excludeChunks: ['processTaskWorker'],
Expand All @@ -135,23 +148,16 @@ const config = {
],
resolve: {
alias: {
vue$: 'vue/dist/vue.esm.js'
vue$: 'vue/dist/vue.runtime.esm.js',

// video.js's mpd-parser uses @xmldom/xmldom so that it can support both node and web browsers
// As FreeTube only runs in electron and web browsers, we can use the native DOMParser class, instead of the "polyfill"
// https://caniuse.com/mdn-api_domparser
'@xmldom/xmldom$': path.resolve(__dirname, '_domParser.js')
},
fallback: {
buffer: require.resolve('buffer/'),
dns: require.resolve('browserify/lib/_empty.js'),
'fs/promises': require.resolve('browserify/lib/_empty.js'),
'fs': require.resolve('browserify/lib/_empty.js'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
net: require.resolve('browserify/lib/_empty.js'),
os: require.resolve('os-browserify/browser.js'),
'fs/promises': path.resolve(__dirname, '_empty.js'),
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
timers: require.resolve('timers-browserify'),
tls: require.resolve('browserify/lib/_empty.js'),
vm: require.resolve('vm-browserify'),
zlib: require.resolve('browserify-zlib')
},
extensions: ['.js', '.vue']
},
Expand Down
Loading

0 comments on commit fc9cf85

Please sign in to comment.