diff options
author | Mario <mario@mariovavti.com> | 2021-06-07 12:56:27 +0200 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-06-07 12:56:27 +0200 |
commit | f3b4308cb59bf4b21ff186f8479c82239446d139 (patch) | |
tree | 0dcbdcffcfe0dd678958cbcc34f41cb1c470c69b /vendor/twbs/bootstrap/build | |
parent | 67322c12643ced03bec0be70667f8b1c45de752f (diff) | |
download | volse-hubzilla-f3b4308cb59bf4b21ff186f8479c82239446d139.tar.gz volse-hubzilla-f3b4308cb59bf4b21ff186f8479c82239446d139.tar.bz2 volse-hubzilla-f3b4308cb59bf4b21ff186f8479c82239446d139.zip |
upgrade to bootstrap 5.0.1 and first batch of fixes
Diffstat (limited to 'vendor/twbs/bootstrap/build')
-rw-r--r-- | vendor/twbs/bootstrap/build/build-plugins.js | 137 | ||||
-rw-r--r--[-rwxr-xr-x] | vendor/twbs/bootstrap/build/change-version.js | 117 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/build/generate-sri.js | 12 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/build/postcss.config.js | 3 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/build/rollup.config.js | 38 | ||||
-rwxr-xr-x | vendor/twbs/bootstrap/build/ship.sh | 55 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/build/svgo.yml | 7 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/build/vnu-jar.js | 13 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/build/zip-examples.js | 10 |
9 files changed, 210 insertions, 182 deletions
diff --git a/vendor/twbs/bootstrap/build/build-plugins.js b/vendor/twbs/bootstrap/build/build-plugins.js index ffdf0d1e9..53093dc41 100644 --- a/vendor/twbs/bootstrap/build/build-plugins.js +++ b/vendor/twbs/bootstrap/build/build-plugins.js @@ -14,7 +14,7 @@ const rollup = require('rollup') const { babel } = require('@rollup/plugin-babel') const banner = require('./banner.js') -const TEST = process.env.NODE_ENV === 'test' +const rootPath = path.resolve(__dirname, '../js/dist/') const plugins = [ babel({ // Only transpile our source code @@ -24,43 +24,142 @@ const plugins = [ }) ] const bsPlugins = { + Data: path.resolve(__dirname, '../js/src/dom/data.js'), + EventHandler: path.resolve(__dirname, '../js/src/dom/event-handler.js'), + Manipulator: path.resolve(__dirname, '../js/src/dom/manipulator.js'), + SelectorEngine: path.resolve(__dirname, '../js/src/dom/selector-engine.js'), Alert: path.resolve(__dirname, '../js/src/alert.js'), + Base: path.resolve(__dirname, '../js/src/base-component.js'), Button: path.resolve(__dirname, '../js/src/button.js'), Carousel: path.resolve(__dirname, '../js/src/carousel.js'), Collapse: path.resolve(__dirname, '../js/src/collapse.js'), Dropdown: path.resolve(__dirname, '../js/src/dropdown.js'), Modal: path.resolve(__dirname, '../js/src/modal.js'), + Offcanvas: path.resolve(__dirname, '../js/src/offcanvas.js'), Popover: path.resolve(__dirname, '../js/src/popover.js'), ScrollSpy: path.resolve(__dirname, '../js/src/scrollspy.js'), Tab: path.resolve(__dirname, '../js/src/tab.js'), Toast: path.resolve(__dirname, '../js/src/toast.js'), - Tooltip: path.resolve(__dirname, '../js/src/tooltip.js'), - Util: path.resolve(__dirname, '../js/src/util.js') + Tooltip: path.resolve(__dirname, '../js/src/tooltip.js') } -const rootPath = TEST ? '../js/coverage/dist/' : '../js/dist/' + +const defaultPluginConfig = { + external: [ + bsPlugins.Data, + bsPlugins.Base, + bsPlugins.EventHandler, + bsPlugins.SelectorEngine + ], + globals: { + [bsPlugins.Data]: 'Data', + [bsPlugins.Base]: 'Base', + [bsPlugins.EventHandler]: 'EventHandler', + [bsPlugins.SelectorEngine]: 'SelectorEngine' + } +} + +const getConfigByPluginKey = pluginKey => { + if ( + pluginKey === 'Data' || + pluginKey === 'Manipulator' || + pluginKey === 'EventHandler' || + pluginKey === 'SelectorEngine' || + pluginKey === 'Util' || + pluginKey === 'Sanitizer' || + pluginKey === 'Backdrop' + ) { + return { + external: [] + } + } + + if (pluginKey === 'Alert' || pluginKey === 'Tab' || pluginKey === 'Offcanvas') { + return defaultPluginConfig + } + + if ( + pluginKey === 'Base' || + pluginKey === 'Button' || + pluginKey === 'Carousel' || + pluginKey === 'Collapse' || + pluginKey === 'Modal' || + pluginKey === 'ScrollSpy' + ) { + const config = Object.assign(defaultPluginConfig) + config.external.push(bsPlugins.Manipulator) + config.globals[bsPlugins.Manipulator] = 'Manipulator' + return config + } + + if (pluginKey === 'Dropdown' || pluginKey === 'Tooltip') { + const config = Object.assign(defaultPluginConfig) + config.external.push(bsPlugins.Manipulator, '@popperjs/core') + config.globals[bsPlugins.Manipulator] = 'Manipulator' + config.globals['@popperjs/core'] = 'Popper' + return config + } + + if (pluginKey === 'Popover') { + return { + external: [ + bsPlugins.Data, + bsPlugins.SelectorEngine, + bsPlugins.Tooltip + ], + globals: { + [bsPlugins.Data]: 'Data', + [bsPlugins.SelectorEngine]: 'SelectorEngine', + [bsPlugins.Tooltip]: 'Tooltip' + } + } + } + + if (pluginKey === 'Toast') { + return { + external: [ + bsPlugins.Data, + bsPlugins.Base, + bsPlugins.EventHandler, + bsPlugins.Manipulator + ], + globals: { + [bsPlugins.Data]: 'Data', + [bsPlugins.Base]: 'Base', + [bsPlugins.EventHandler]: 'EventHandler', + [bsPlugins.Manipulator]: 'Manipulator' + } + } + } +} + +const utilObjects = new Set([ + 'Util', + 'Sanitizer', + 'Backdrop' +]) + +const domObjects = new Set([ + 'Data', + 'EventHandler', + 'Manipulator', + 'SelectorEngine' +]) const build = async plugin => { console.log(`Building ${plugin} plugin...`) - const external = ['jquery', 'popper.js'] - const globals = { - jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode - 'popper.js': 'Popper' - } + const { external, globals } = getConfigByPluginKey(plugin) + const pluginFilename = path.basename(bsPlugins[plugin]) + let pluginPath = rootPath - // Do not bundle Util in plugins - if (plugin !== 'Util') { - external.push(bsPlugins.Util) - globals[bsPlugins.Util] = 'Util' + if (utilObjects.has(plugin)) { + pluginPath = `${rootPath}/util/` } - // Do not bundle Tooltip in Popover - if (plugin === 'Popover') { - external.push(bsPlugins.Tooltip) - globals[bsPlugins.Tooltip] = 'Tooltip' + if (domObjects.has(plugin)) { + pluginPath = `${rootPath}/dom/` } - const pluginFilename = `${plugin.toLowerCase()}.js` const bundle = await rollup.rollup({ input: bsPlugins[plugin], plugins, @@ -73,7 +172,7 @@ const build = async plugin => { name: plugin, sourcemap: true, globals, - file: path.resolve(__dirname, `${rootPath}${pluginFilename}`) + file: path.resolve(__dirname, `${pluginPath}/${pluginFilename}`) }) console.log(`Building ${plugin} plugin... Done!`) diff --git a/vendor/twbs/bootstrap/build/change-version.js b/vendor/twbs/bootstrap/build/change-version.js index 78bc8464b..63f231ea2 100755..100644 --- a/vendor/twbs/bootstrap/build/change-version.js +++ b/vendor/twbs/bootstrap/build/change-version.js @@ -9,102 +9,73 @@ 'use strict' -const fs = require('fs') +const fs = require('fs').promises const path = require('path') -const sh = require('shelljs') - -sh.config.fatal = true +const globby = require('globby') + +const VERBOSE = process.argv.includes('--verbose') +const DRY_RUN = process.argv.includes('--dry') || process.argv.includes('--dry-run') + +// These are the filetypes we only care about replacing the version +const GLOB = [ + '**/*.{css,html,js,json,md,scss,txt,yml}' +] +const GLOBBY_OPTIONS = { + cwd: path.join(__dirname, '..'), + gitignore: true +} // Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37 function regExpQuote(string) { - return string.replace(/[$()*+.?[\\\]^{|}-]/g, '\\$&') + return string.replace(/[$()*+-.?[\\\]^{|}]/g, '\\$&') } function regExpQuoteReplacement(string) { return string.replace(/\$/g, '$$') } -const DRY_RUN = false +async function replaceRecursively(file, oldVersion, newVersion) { + const originalString = await fs.readFile(file, 'utf8') + const newString = originalString.replace( + new RegExp(regExpQuote(oldVersion), 'g'), regExpQuoteReplacement(newVersion) + ) -function walkAsync(directory, excludedDirectories, fileCallback, errback) { - if (excludedDirectories.has(path.parse(directory).base)) { + // No need to move any further if the strings are identical + if (originalString === newString) { return } - fs.readdir(directory, (err, names) => { - if (err) { - errback(err) - return - } - - names.forEach(name => { - const filepath = path.join(directory, name) - fs.lstat(filepath, (err, stats) => { - if (err) { - process.nextTick(errback, err) - return - } - - if (stats.isDirectory()) { - process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback) - } else if (stats.isFile()) { - process.nextTick(fileCallback, filepath) - } - }) - }) - }) -} + if (VERBOSE) { + console.log(`FILE: ${file}`) + } -function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) { - original = new RegExp(regExpQuote(original), 'g') - replacement = regExpQuoteReplacement(replacement) - const updateFile = DRY_RUN ? filepath => { - if (allowedExtensions.has(path.parse(filepath).ext)) { - console.log(`FILE: ${filepath}`) - } else { - console.log(`EXCLUDED:${filepath}`) - } - } : filepath => { - if (allowedExtensions.has(path.parse(filepath).ext)) { - sh.sed('-i', original, replacement, filepath) - } + if (DRY_RUN) { + return } - walkAsync(directory, excludedDirectories, updateFile, err => { - console.error('ERROR while traversing directory!:') - console.error(err) - process.exit(1) - }) + await fs.writeFile(file, newString, 'utf8') } -function main(args) { - if (args.length !== 2) { - console.error('USAGE: change-version old_version new_version') +async function main(args) { + const [oldVersion, newVersion] = args + + if (!oldVersion || !newVersion) { + console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]') console.error('Got arguments:', args) process.exit(1) } - const oldVersion = args[0] - const newVersion = args[1] - const EXCLUDED_DIRS = new Set([ - '.git', - '_gh_pages', - 'node_modules', - 'vendor' - ]) - const INCLUDED_EXTENSIONS = new Set([ - // This extension whitelist is how we avoid modifying binary files - '', - '.css', - '.html', - '.js', - '.json', - '.md', - '.scss', - '.txt', - '.yml' - ]) - replaceRecursively('.', EXCLUDED_DIRS, INCLUDED_EXTENSIONS, oldVersion, newVersion) + // Strip any leading `v` from arguments because otherwise we will end up with duplicate `v`s + [oldVersion, newVersion].map(arg => arg.startsWith('v') ? arg.slice(1) : arg) + + try { + const files = await globby(GLOB, GLOBBY_OPTIONS) + + await Promise.all(files.map(file => replaceRecursively(file, oldVersion, newVersion))) + } catch (error) { + console.error(error) + process.exit(1) + } } main(process.argv.slice(2)) diff --git a/vendor/twbs/bootstrap/build/generate-sri.js b/vendor/twbs/bootstrap/build/generate-sri.js index f0aa7340b..221873b8f 100644 --- a/vendor/twbs/bootstrap/build/generate-sri.js +++ b/vendor/twbs/bootstrap/build/generate-sri.js @@ -17,8 +17,6 @@ const fs = require('fs') const path = require('path') const sh = require('shelljs') -const pkg = require('../package.json') - sh.config.fatal = true const configFile = path.join(__dirname, '../config.yml') @@ -32,6 +30,10 @@ const files = [ configPropertyName: 'css_hash' }, { + file: 'dist/css/bootstrap.rtl.min.css', + configPropertyName: 'css_rtl_hash' + }, + { file: 'dist/js/bootstrap.min.js', configPropertyName: 'js_hash' }, @@ -40,11 +42,7 @@ const files = [ configPropertyName: 'js_bundle_hash' }, { - file: `site/static/docs/${pkg.config.version_short}/assets/js/vendor/jquery.slim.min.js`, - configPropertyName: 'jquery_hash' - }, - { - file: 'node_modules/popper.js/dist/umd/popper.min.js', + file: 'node_modules/@popperjs/core/dist/umd/popper.min.js', configPropertyName: 'popper_hash' } ] diff --git a/vendor/twbs/bootstrap/build/postcss.config.js b/vendor/twbs/bootstrap/build/postcss.config.js index ef416258f..b179a0e77 100644 --- a/vendor/twbs/bootstrap/build/postcss.config.js +++ b/vendor/twbs/bootstrap/build/postcss.config.js @@ -12,7 +12,8 @@ module.exports = ctx => { plugins: { autoprefixer: { cascade: false - } + }, + rtlcss: ctx.env === 'RTL' ? {} : false } } } diff --git a/vendor/twbs/bootstrap/build/rollup.config.js b/vendor/twbs/bootstrap/build/rollup.config.js index e2d2b125e..8cecec9aa 100644 --- a/vendor/twbs/bootstrap/build/rollup.config.js +++ b/vendor/twbs/bootstrap/build/rollup.config.js @@ -3,12 +3,14 @@ const path = require('path') const { babel } = require('@rollup/plugin-babel') const { nodeResolve } = require('@rollup/plugin-node-resolve') +const replace = require('@rollup/plugin-replace') const banner = require('./banner.js') const BUNDLE = process.env.BUNDLE === 'true' +const ESM = process.env.ESM === 'true' -let fileDest = 'bootstrap.js' -const external = ['jquery', 'popper.js'] +let fileDest = `bootstrap${ESM ? '.esm' : ''}` +const external = ['@popperjs/core'] const plugins = [ babel({ // Only transpile our source code @@ -18,27 +20,37 @@ const plugins = [ }) ] const globals = { - jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode - 'popper.js': 'Popper' + '@popperjs/core': 'Popper' } if (BUNDLE) { - fileDest = 'bootstrap.bundle.js' + fileDest += '.bundle' // Remove last entry in external array to bundle Popper external.pop() - delete globals['popper.js'] - plugins.push(nodeResolve()) + delete globals['@popperjs/core'] + plugins.push( + replace({ + 'process.env.NODE_ENV': '"production"', + preventAssignment: true + }), + nodeResolve() + ) } -module.exports = { - input: path.resolve(__dirname, '../js/index.js'), +const rollupConfig = { + input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`), output: { banner, - file: path.resolve(__dirname, `../dist/js/${fileDest}`), - format: 'umd', - globals, - name: 'bootstrap' + file: path.resolve(__dirname, `../dist/js/${fileDest}.js`), + format: ESM ? 'esm' : 'umd', + globals }, external, plugins } + +if (!ESM) { + rollupConfig.output.name = 'bootstrap' +} + +module.exports = rollupConfig diff --git a/vendor/twbs/bootstrap/build/ship.sh b/vendor/twbs/bootstrap/build/ship.sh deleted file mode 100755 index f1c5e38e3..000000000 --- a/vendor/twbs/bootstrap/build/ship.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# -# Usage -# --------------- -# 1. Clone second version of Bootstrap in sibling directory named `bs-docs`. -# 2. Within `bs-docs` copy, switch to `gh-pages` branch. -# 3. Pull latest, re-bundle, re-npm. -# 4. Run script. - -red=$'\e[1;31m' -green=$'\e[1;32m' -#blue=$'\e[1;34m' -magenta=$'\e[1;35m' -#cyan=$'\e[1;36m' -end=$'\e[0m' - -# Get current version from package.json -current_version=$(node -p "require('./package.json').version") - -if [[ $# -lt 1 ]]; then - printf "\n%s⚠️ Shipping aborted. You must specify a version.\n%s" "$red" "$end" - exit 1 -fi - -# Pulling latest changes, just to be sure -printf "\n%s=======================================================%s" "$magenta" "$end" -printf "\n%sPulling latest changes...%s" "$magenta" "$end" -printf "\n%s=======================================================\n\n%s" "$magenta" "$end" -git pull origin v4-dev - -# Update version number -printf "\n%s=======================================================%s" "$magenta" "$end" -printf "\n%sUpdating version number...%s" "$magenta" "$end" -printf "\n%s=======================================================\n%s" "$magenta" "$end" -npm run release-version "$current_version" "$1" - -# Build release -printf "\n%s=======================================================%s" "$magenta" "$end" -printf "\n%sBuilding release...%s" "$magenta" "$end" -printf "\n%s=======================================================\n%s" "$magenta" "$end" -npm run release - -# Copy the contents of the built docs site over to `bs-docs` repo -printf "\n%s=======================================================%s" "$magenta" "$end" -printf "\n%sCopy it over...%s" "$magenta" "$end" -printf "\n%s=======================================================\n%s" "$magenta" "$end" -cp -rf _gh_pages/. ../bs-docs/ -printf "\nDone!\n" - -printf "\n%s=======================================================%s" "$green" "$end" -printf "\n%sSuccess, $1 is ready to review and publish.%s" "$green" "$end" -printf "\n%s=======================================================\n\n%s" "$green" "$end" diff --git a/vendor/twbs/bootstrap/build/svgo.yml b/vendor/twbs/bootstrap/build/svgo.yml index 1b592f00f..67940d393 100644 --- a/vendor/twbs/bootstrap/build/svgo.yml +++ b/vendor/twbs/bootstrap/build/svgo.yml @@ -15,10 +15,9 @@ js2svg: indent: 2 plugins: - # remove this with IE 11 is no longer supported - - addAttributesToSVGElement: - attributes: - - focusable: false +# - addAttributesToSVGElement: +# attributes: +# - focusable: false - cleanupAttrs: true - cleanupEnableBackground: true - cleanupIDs: true diff --git a/vendor/twbs/bootstrap/build/vnu-jar.js b/vendor/twbs/bootstrap/build/vnu-jar.js index d211ce577..7a912675e 100644 --- a/vendor/twbs/bootstrap/build/vnu-jar.js +++ b/vendor/twbs/bootstrap/build/vnu-jar.js @@ -33,22 +33,23 @@ childProcess.exec('java -version', (error, stdout, stderr) => { // Content → Reboot uses various date/time inputs as a visual example. // Documentation does not rely on them being usable. 'The “date” input type is not supported in all browsers.*', - 'The “time” input type is not supported in all browsers.*', - // IE11 doesn't recognise <main> / give the element an implicit "main" landmark. - // Explicit role="main" is redundant for other modern browsers, but still valid. - 'The “main” role is unnecessary for element “main”.' + 'The “week” input type is not supported in all browsers.*', + 'The “month” input type is not supported in all browsers.*', + 'The “color” input type is not supported in all browsers.*', + 'The “datetime-local” input type is not supported in all browsers.*', + 'The “time” input type is not supported in all browsers.*' ].join('|') const args = [ '-jar', - vnu, + `"${vnu}"`, '--asciiquotes', '--skip-non-html', // Ignore the language code warnings '--no-langdetect', '--Werror', `--filterpattern "${ignores}"`, - '_gh_pages/', + '_site/', 'js/tests/' ] diff --git a/vendor/twbs/bootstrap/build/zip-examples.js b/vendor/twbs/bootstrap/build/zip-examples.js index f976c3bc5..312548e8a 100644 --- a/vendor/twbs/bootstrap/build/zip-examples.js +++ b/vendor/twbs/bootstrap/build/zip-examples.js @@ -16,21 +16,23 @@ const pkg = require('../package.json') const versionShort = pkg.config.version_short const distFolder = `bootstrap-${pkg.version}-examples` -const rootDocsDir = '_gh_pages' +const rootDocsDir = '_site' const docsDir = `${rootDocsDir}/docs/${versionShort}/` // these are the files we need in the examples const cssFiles = [ 'bootstrap.min.css', - 'bootstrap.min.css.map' + 'bootstrap.min.css.map', + 'bootstrap.rtl.min.css', + 'bootstrap.rtl.min.css.map' ] const jsFiles = [ 'bootstrap.bundle.min.js', 'bootstrap.bundle.min.js.map' ] const imgFiles = [ - 'bootstrap-outline.svg', - 'bootstrap-solid.svg' + 'bootstrap-logo.svg', + 'bootstrap-logo-white.svg' ] sh.config.fatal = true |