first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
/**
* Grunt bumpup task config
* @package Elementor
*/
module.exports = {
options: {
updateProps: {
pkg: 'package.json'
}
},
file: 'package.json'
};

View File

@@ -0,0 +1,41 @@
const checkTextDomain = {
standard: {
options:{
text_domain: 'elementor',
correct_domain: true,
keywords: [
// WordPress keywords
'__:1,2d',
'_e:1,2d',
'_x:1,2c,3d',
'esc_html__:1,2d',
'esc_html_e:1,2d',
'esc_html_x:1,2c,3d',
'esc_attr__:1,2d',
'esc_attr_e:1,2d',
'esc_attr_x:1,2c,3d',
'_ex:1,2c,3d',
'_n:1,2,4d',
'_nx:1,2,4c,5d',
'_n_noop:1,2,3d',
'_nx_noop:1,2,3c,4d'
]
},
files: [ {
src: [
'**/*.php',
'!docs/**',
'!bin/**',
'!node_modules/**',
'!build/**',
'!tests/**',
'!.github/**',
'!vendor/**',
'!*~'
],
expand: true
} ]
}
};
module.exports = checkTextDomain;

View File

@@ -0,0 +1,10 @@
/**
* Grunt clean task config
* @package Elementor
*/
module.exports = {
//Clean up build folder
main: [
'build'
],
};

View File

@@ -0,0 +1,65 @@
/**
* Grunt copy task config
* @package Elementor
*/
const getBuildFiles = [
'**',
'!.git/**',
'!.github/**',
'!.gitignore',
'!.gitmodules',
'!.jscsrc',
'!karma.conf.js',
'!.jshintignore',
'!.jshintrc',
'!.travis.yml',
'!assets/**/*.map',
'!assets/dev/**',
'!assets/js/qunit-tests*',
'!bin/**',
'!build/**',
'!composer.json',
'!composer.lock',
'!core/**/assets/**',
'!cypress.json',
'!docker-compose.yml',
'!docs/**',
'!Gruntfile.js',
'!local-site/**',
'!logo.png',
'!modules/**/assets/**',
'!nightwatch.conf.js',
'!node_modules/**',
'!npm-debug.log',
'!package-lock.json',
'!package.json',
'!phpunit.xml',
'!CHANGELOG.md',
'!README.md',
'!ruleset.xml',
'!tests/**',
'!vendor/**',
'!yarn.lock',
'!*~',
'!commitlint.config.js',
// Conflict with above rule.
'core/files/assets/**',
];
/**
* @type {{main: {src: string[], expand: boolean, dest: string}, secondary: {src: string[], expand: boolean, dest: string}}}
*/
const copy = {
main: {
src: getBuildFiles,
expand: true,
dest: 'build/'
},
secondary: {
src: getBuildFiles,
expand: true,
dest: '/tmp/elementor-builds/<%= pkg.version %>/'
}
};
module.exports = copy;

View File

@@ -0,0 +1,29 @@
/**
* Grunt karma task config
* @package Elementor
*/
module.exports = {
unit: {
configFile: 'karma.conf.js',
reporters: [ 'dots', 'fail-fast']
},
coverage: {
configFile: 'karma.conf.js',
reporters: [ 'progress', 'coverage', 'coverage-istanbul' ],
},
coverageHtml: {
configFile: 'karma.conf.js',
reporters: [ 'progress', 'coverage', 'coverage-istanbul' ],
reports: [ 'text', 'html' ],
},
debug: {
configFile: 'karma.conf.js',
browsers: [ 'Chrome' ],
singleRun: false,
client: {
qunit: {
showUI: true,
},
},
},
};

View File

@@ -0,0 +1,21 @@
const path = require( 'path' ),
fs = require('fs'),
dir = path.resolve( __dirname, '../../' ),
importsFile = dir + '/core/app/assets/styles/app-imports.scss';
module.exports = function() {
const resourceRelativePath = path.relative( path.dirname(importsFile), this.resourcePath ).replace( /\\/g, '/' ),
importStatement = `@import "${ resourceRelativePath }";`,
importContent = fs.readFileSync( importsFile ).toString().split( "\n" ),
importExists = -1 !== importContent.indexOf( importStatement );
if ( ! importExists ) {
fs.open( importsFile, 'a', 666, ( e, id ) => {
fs.write( id, importStatement + "\n", null, 'utf8', () => {
fs.close( id );
} );
} );
}
return ``;
}

View File

@@ -0,0 +1,47 @@
/**
* Grunt postcss task config
* @package Elementor
*/
module.exports = {
dev: {
options: {
map: true,
processors: [
require( 'autoprefixer' )( {
browsers: 'last 10 versions'
} )
]
},
files: [ {
src: [
'assets/css/*.css',
'!assets/css/*.min.css'
]
} ]
},
minify: {
options: {
processors: [
require( 'autoprefixer' )( {
browsers: 'last 10 versions'
} ),
require( 'cssnano' )( {
preset: [ 'default', {
reduceIdents: false,
zindex: false,
calc: false
} ]
} )
]
},
files: [ {
expand: true,
src: [
'assets/css/*.css',
'!assets/css/*.min.css'
],
ext: '.min.css'
} ]
}
};

View File

@@ -0,0 +1,14 @@
/**
* Grunt release task config
* @package Elementor
*/
module.exports = {
options: {
bump: false,
npm: false,
commit: false,
tagName: 'v<%= version %>',
commitMessage: 'released v<%= version %>',
tagMessage: 'Tagged as v<%= version %>'
}
};

View File

@@ -0,0 +1,38 @@
const path = require( 'path' );
const fs = require( 'fs' );
class RemoveChunksPlugin {
constructor( chunkSuffix ) {
this.chunkSuffix = chunkSuffix;
}
apply( compiler ) {
compiler.hooks.afterPlugins.tap( 'RemoveChunksPlugin', () => this.removeChunks() );
}
removeChunks() {
if ( ! this.chunkSuffix ) {
return;
}
const chunksFolder = path.resolve( __dirname, '../assets/js' );
if ( fs.existsSync( chunksFolder ) ) {
fs.readdir( chunksFolder, ( err, files ) => {
if ( err ) throw err;
for ( const fileName of files ) {
const filePath = path.join( chunksFolder, fileName );
if ( -1 !== fileName.indexOf( this.chunkSuffix ) && fs.existsSync( filePath ) ) {
fs.unlink( filePath, err => {
if ( err ) throw err;
} );
}
}
} );
}
}
}
module.exports = RemoveChunksPlugin;

View File

@@ -0,0 +1,42 @@
module.exports = {
plugin_main: {
src: [ 'elementor.php' ],
overwrite: true,
replacements: [
{
from: /Version: \d{1,1}\.\d{1,2}\.\d{1,2}/g,
to: 'Version: <%= pkg.version %>'
},
{
from: /ELEMENTOR_VERSION', '.*?'/g,
to: 'ELEMENTOR_VERSION\', \'<%= pkg.version %>\''
},
{
from: /ELEMENTOR_PREVIOUS_STABLE_VERSION', '.*?'/g,
to: 'ELEMENTOR_PREVIOUS_STABLE_VERSION\', \'<%= grunt.config.get( \'prev_stable_version\' ) %>\''
}
]
},
readme: {
src: [ 'readme.txt' ],
overwrite: true,
replacements: [
{
from: /Stable tag: \d{1,1}\.\d{1,2}\.\d{1,2}/g,
to: 'Stable tag: <%= pkg.version %>'
}
]
},
packageFile: {
src: [ 'package.json' ],
overwrite: true,
replacements: [
{
from: /prev_stable_version": ".*?"/g,
to: 'prev_stable_version": "<%= grunt.config.get( \'prev_stable_version\' ) %>"'
}
]
}
};

View File

@@ -0,0 +1,17 @@
const sass = {
dist: {
options: {
sourcemap: true,
sourceMap: true
},
files: [ {
expand: true,
cwd: 'assets/dev/scss/direction',
src: '*.scss',
dest: 'assets/css',
ext: '.css'
} ]
}
};
module.exports = sass;

View File

@@ -0,0 +1,11 @@
const shell = {
git_add_all: {
command: [
'git add --all',
'git commit -m "Bump to <%= pkg.version %>"'
].join( '&&' )
}
};
module.exports = shell;

View File

@@ -0,0 +1,17 @@
/**
* Grunt usebanner task config
* @package Elementor
*/
module.exports = {
dist: {
options: {
banner: '<%= banner %>'
},
files: {
src: [
'assets/js/*.js',
'assets/css/*.css'
]
}
}
};

View File

@@ -0,0 +1,19 @@
/**
* Grunt watch task config
* @package Elementor
*/
const watch = {
styles: {
files: [
'**/*.scss',
'!assets/dev/scss/frontend/breakpoints/proxy.scss'
],
tasks: [ 'styles:true' ],
options: {
spawn: false,
livereload: true
}
},
};
module.exports = watch;

View File

@@ -0,0 +1,31 @@
const path = require( 'path' );
module.exports = {
resolve: {
alias: {
'elementor': path.resolve( __dirname, '../' ),
'elementor-app': path.resolve( __dirname, '../core/app/assets/js' ),
'elementor-admin': path.resolve( __dirname, '../assets/dev/js/admin' ),
'elementor-api': path.resolve( __dirname, '../core/common/assets/js/api' ),
'elementor-assets-js': path.resolve( __dirname, '../assets/dev/js' ),
'elementor-behaviors': path.resolve( __dirname, '../assets/dev/js/editor/elements/views/behaviors' ),
'elementor-common': path.resolve( __dirname, '../core/common/assets/js' ),
'elementor-common-modules': path.resolve( __dirname, '../core/common/modules' ),
'elementor-controls': path.resolve( __dirname, '../assets/dev/js/editor/controls' ),
'elementor-document': path.resolve( __dirname, '../assets/dev/js/editor/document' ),
'elementor-dynamic-tags': path.resolve( __dirname, '../assets/dev/js/editor/components/dynamic-tags' ),
'elementor-editor': path.resolve( __dirname, '../assets/dev/js/editor' ),
'elementor-editor-utils': path.resolve( __dirname, '../assets/dev/js/editor/utils' ),
'elementor-elements': path.resolve( __dirname, '../assets/dev/js/editor/elements' ),
'elementor-frontend': path.resolve( __dirname, '../assets/dev/js/frontend' ),
'elementor-panel': path.resolve( __dirname, '../assets/dev/js/editor/regions/panel' ),
'elementor-regions': path.resolve( __dirname, '../assets/dev/js/editor/regions' ),
'elementor-revisions': path.resolve( __dirname, '../assets/dev/js/editor/components/revisions' ),
'elementor-scss': path.resolve( __dirname, '../assets/dev/scss' ),
'elementor-templates': path.resolve( __dirname, '../assets/dev/js/editor/components/template-library' ),
'elementor-utils': path.resolve( __dirname, '../assets/dev/js/utils' ),
'elementor-validator': path.resolve( __dirname, '../assets/dev/js/editor/components/validator' ),
'elementor-views': path.resolve( __dirname, '../assets/dev/js/editor/views' ),
},
},
};

View File

@@ -0,0 +1,257 @@
/**
* Grunt webpack task config
* @package Elementor
*/
const path = require( 'path' );
// Handling minification for production assets.
const TerserPlugin = require( 'terser-webpack-plugin' );
const aliasList = require('./webpack.alias.js').resolve;
const webpack = require('webpack');
// Cleaning up existing chunks before creating new ones.
const RemoveChunksPlugin = require('./remove-chunks');
// Preventing auto-generated long names of shared sub chunks (optimization.splitChunks.minChunks) by using only the hash.
const getChunkName = ( chunkData, environment ) => {
const minSuffix = 'production' === environment ? '.min' : '',
name = chunkData.chunk.name ? '[name].' : '';
return `${ name }[contenthash].bundle${ minSuffix }.js`;
};
const moduleRules = {
rules: [
// {
// enforce: 'pre',
// test: /\.js$/,
// exclude: /node_modules/,
// loader: 'eslint-loader',
// options: {
// failOnError: true,
// }
// },
{
test: /core[/\\]app.*\.(s)?css$/i,
use: [
{
loader: './loaders/app-imports.js',
},
],
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: [ '@wordpress/default' ],
plugins: [
[ '@wordpress/babel-plugin-import-jsx-pragma' ],
[ '@babel/plugin-transform-react-jsx', {
'pragmaFrag': 'React.Fragment',
} ],
[ '@babel/plugin-proposal-class-properties' ],
[ '@babel/plugin-transform-runtime' ],
[ '@babel/plugin-transform-modules-commonjs' ],
[ '@babel/plugin-proposal-optional-chaining' ],
],
},
},
],
},
],
};
const entry = {
'editor': [
path.resolve( __dirname, '../assets/dev/js/editor/utils/jquery-serialize-object.js' ),
path.resolve( __dirname, '../assets/dev/js/editor/utils/jquery-html5-dnd.js' ),
path.resolve( __dirname, '../assets/dev/js/editor/editor.js' ),
],
'admin': path.resolve( __dirname, '../assets/dev/js/admin/admin.js' ),
'elementor-admin-bar': path.resolve( __dirname, '../modules/admin-bar/assets/js/frontend/module.js' ),
'admin-feedback': path.resolve( __dirname, '../assets/dev/js/admin/admin-feedback.js' ),
'common': path.resolve( __dirname, '../core/common/assets/js/common.js' ),
'gutenberg': path.resolve( __dirname, '../assets/dev/js/admin/gutenberg.js' ),
'new-template': path.resolve( __dirname, '../assets/dev/js/admin/new-template/new-template.js' ),
'app': path.resolve( __dirname, '../core/app/assets/js/index.js' ),
'app-loader': path.resolve( __dirname, '../core/app/assets/js/app-loader' ),
'app-packages': path.resolve( __dirname, '../core/app/assets/js/app-packages' ),
'beta-tester': path.resolve( __dirname, '../assets/dev/js/admin/beta-tester/beta-tester.js' ),
'common-modules': path.resolve( __dirname, '../core/common/assets/js/modules' ),
'editor-modules': path.resolve( __dirname, '../assets/dev/js/editor/modules.js' ),
'editor-document': path.resolve( __dirname, '../assets/dev/js/editor/editor-document.js' ),
'qunit-tests': path.resolve( __dirname, '../tests/qunit/main.js' ),
};
const frontendEntries = {
'frontend-modules': path.resolve( __dirname, '../assets/dev/js/frontend/modules.js' ),
'frontend': { import: path.resolve( __dirname, '../assets/dev/js/frontend/frontend.js' ), dependOn: 'frontend-modules' },
'preloaded-modules': { import: path.resolve( __dirname, '../assets/dev/js/frontend/preloaded-modules.js' ), dependOn: 'frontend' },
};
const externals = {
'@wordpress/i18n': 'wp.i18n',
react: 'React',
'react-dom': 'ReactDOM',
'@elementor/app-ui': 'elementorAppPackages.appUi',
'@elementor/site-editor': 'elementorAppPackages.siteEditor',
'@elementor/router': 'elementorAppPackages.router',
};
const plugins = [
new webpack.ProvidePlugin( {
React: 'react',
ReactDOM: 'react-dom',
PropTypes: 'prop-types',
__: ['@wordpress/i18n', '__'],
sprintf: ['@wordpress/i18n', 'sprintf'],
} )
];
const baseConfig = {
target: 'web',
context: __dirname,
externals,
module: moduleRules,
resolve: aliasList,
};
const devSharedConfig = {
...baseConfig,
devtool: 'source-map',
mode: 'development',
output: {
path: path.resolve( __dirname, '../assets/js' ),
chunkFilename: ( chunkData ) => getChunkName( chunkData, 'development' ),
filename: '[name].js',
devtoolModuleFilenameTemplate: '../[resource]',
// Prevents the collision of chunk names between different bundles.
uniqueName: 'elementor',
},
watch: true,
};
const webpackConfig = [
{
...devSharedConfig,
plugins: [
...plugins,
],
name: 'base',
entry: entry,
},
{
...devSharedConfig,
plugins: [
new RemoveChunksPlugin( '.bundle.js' ),
...plugins,
],
name: 'frontend',
optimization: {
runtimeChunk: {
name: 'webpack.runtime',
},
splitChunks: {
minChunks: 2,
},
},
entry: frontendEntries,
},
];
const prodSharedOptimization = {
minimize: true,
minimizer: [
new TerserPlugin( {
terserOptions: {
keep_fnames: true,
},
include: /\.min\.js$/
} ),
],
};
const prodSharedConfig = {
...baseConfig,
mode: 'production',
output: {
path: path.resolve( __dirname, '../assets/js' ),
chunkFilename: ( chunkData ) => getChunkName( chunkData, 'production' ),
filename: '[name].js',
// Prevents the collision of chunk names between different bundles.
uniqueName: 'elementor',
},
performance: { hints: false },
};
const webpackProductionConfig = [
{
...prodSharedConfig,
plugins: [
...plugins,
],
name: 'base',
entry: {
// Clone.
...entry,
},
optimization: {
...prodSharedOptimization,
},
},
{
...prodSharedConfig,
plugins: [
new RemoveChunksPlugin( '.bundle.min.js' ),
...plugins,
],
name: 'frontend',
entry: {
// Clone.
...frontendEntries,
},
optimization: {
...prodSharedOptimization,
runtimeChunk: {
name: 'webpack.runtime.min',
},
splitChunks: {
minChunks: 2,
},
},
},
];
// Adding .min suffix to production entries.
webpackProductionConfig.forEach( ( config, index ) => {
for ( const entryPoint in config.entry ) {
let entryValue = config.entry[ entryPoint ];
if ( entryValue.dependOn ) {
// We duplicate the 'entryValue' obj for not affecting the 'entry' obj used by the dev process.
entryValue = { ...entryValue };
entryValue.dependOn += '.min';
}
delete config.entry[ entryPoint ];
config.entry[ entryPoint + '.min' ] = entryValue;
}
} );
const developmentNoWatchConfig = webpackConfig.map( ( config ) => {
return { ...config, watch: false };
} );
const gruntWebpackConfig = {
development: webpackConfig,
developmentNoWatch: developmentNoWatchConfig,
production: webpackProductionConfig
};
module.exports = gruntWebpackConfig;