Skip to content

Commit 79c94d3

Browse files
initial commit
1 parent f006d15 commit 79c94d3

File tree

348 files changed

+32947
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

348 files changed

+32947
-6
lines changed

.config/externals.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Utility methods for use when generating build configuration objects.
3+
*/
4+
const { join } = require( 'path' );
5+
6+
/**
7+
* Given a string, returns a new string with dash separators converted to
8+
* camel-case equivalent. This is not as aggressive as `_.camelCase`, which
9+
* which would also upper-case letters following numbers.
10+
*
11+
* @param {string} string Input dash-delimited string.
12+
*
13+
* @return {string} Camel-cased string.
14+
*/
15+
const camelCaseDash = string => string.replace(
16+
/-([a-z])/g,
17+
( match, letter ) => letter.toUpperCase()
18+
);
19+
20+
/**
21+
* Define externals to load components through the wp global.
22+
*/
23+
const wpExternals = [
24+
'api',
25+
'api-fetch',
26+
'block-editor',
27+
'blocks',
28+
'components',
29+
'compose',
30+
'data',
31+
'date',
32+
'html-entities',
33+
'hooks',
34+
'element',
35+
'i18n',
36+
'plugins',
37+
'viewport',
38+
'ajax',
39+
'codeEditor',
40+
'rich-text',
41+
'url',
42+
'keyboard-shortcuts',
43+
'token-list',
44+
'keycodes',
45+
'escape-html',
46+
].reduce( ( externals, name ) => ( {
47+
...externals,
48+
[ `@wordpress/${ name }` ]: `wp.${ camelCaseDash( name ) }`,
49+
} ), {} );
50+
51+
const externals = {
52+
interactions: 'interactions',
53+
wp: 'wp',
54+
lodash: 'lodash', // WP loads lodash already.
55+
fetch: 'fetch', // Used in our debugger sidebar.
56+
// react: 'wp.element', // Use the bundled React in Gutenberg. (not working see https://github.com/WordPress/gutenberg/issues/33674)
57+
'react-dom': 'wp.element', // Use the bundled ReactDom in Gutenberg.
58+
...wpExternals,
59+
}
60+
61+
module.exports = {
62+
externals,
63+
};

.config/rules.js

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Determine if we're building premium version
2+
const isPremiumBuild = process.env.BUILD_TYPE === 'premium'
3+
4+
module.exports = [
5+
{
6+
test: /\.js$/,
7+
exclude: isPremiumBuild
8+
? /(node_modules|bower_components)/
9+
: /(node_modules|bower_components|pro__premium_only)/,
10+
use: {
11+
loader: 'babel-loader',
12+
options: {
13+
presets: [ '@wordpress/babel-preset-default' ],
14+
cacheDirectory: true,
15+
}
16+
},
17+
resolve: { fullySpecified: false },
18+
},
19+
{
20+
// Fixes Module not found error when origin is *.mjs or ESM js
21+
test: /\.m?jsx?$/,
22+
resolve: { fullySpecified: false },
23+
exclude: isPremiumBuild
24+
? /(node_modules|bower_components)/
25+
: /(node_modules|bower_components|pro__premium_only)/,
26+
},
27+
{
28+
test: /\.svg$/,
29+
exclude: isPremiumBuild
30+
? /(node_modules|bower_components)/
31+
: /(node_modules|bower_components|pro__premium_only)/,
32+
use: [
33+
{
34+
loader: 'babel-loader',
35+
options: { presets: [ '@wordpress/babel-preset-default' ], cacheDirectory: true },
36+
},
37+
{ loader: '@svgr/webpack', options: { babel: false } },
38+
],
39+
},
40+
{
41+
test: /\.(png|jpg|gif)$/,
42+
exclude: isPremiumBuild
43+
? /(node_modules|bower_components)/
44+
: /(node_modules|bower_components|pro__premium_only)/,
45+
use: [
46+
{
47+
loader: 'file-loader',
48+
options: {
49+
outputPath: 'images',
50+
publicPath: 'dist/images',
51+
regExp: /\/([^\/]+)\/([^\/]+)\/images\/(.+)\.(.*)?$/,
52+
name: '[1]-[2]-[3].[hash:hex:7].[ext]',
53+
},
54+
},
55+
],
56+
},
57+
{
58+
test: /\.(mp4)$/,
59+
exclude: isPremiumBuild
60+
? /(node_modules|bower_components)/
61+
: /(node_modules|bower_components|pro__premium_only)/,
62+
use: [
63+
{
64+
loader: 'file-loader',
65+
options: {
66+
outputPath: 'videos',
67+
publicPath: 'dist/videos',
68+
regExp: /\/([^\/]+)\/([^\/]+)\/videos\/(.+)\.(.*)?$/,
69+
name: '[name].[hash:hex:7].[ext]',
70+
},
71+
},
72+
],
73+
},
74+
{
75+
test: /\.scss$/,
76+
use: [
77+
'style-loader',
78+
'css-loader',
79+
'sass-loader',
80+
],
81+
exclude: isPremiumBuild
82+
? /(\.css\.scss$)/
83+
: /(\.css\.scss$|pro__premium_only)/, // Exclude CSS entry files and premium folder (unless premium build)
84+
},
85+
{
86+
test: /\.css\.scss$/,
87+
exclude: isPremiumBuild
88+
? /(node_modules|bower_components)/
89+
: /(node_modules|bower_components|pro__premium_only)/,
90+
use: [
91+
require( 'mini-css-extract-plugin' ).loader,
92+
'css-loader',
93+
'sass-loader',
94+
],
95+
},
96+
]
97+
98+

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
indent_size = 4
6+
charset = utf-8
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.yml]
12+
indent_style = space
13+
indent_size = 2
14+
15+
16+
17+

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
vendor/
3+
build/
4+
dist/
5+
*.min.js
6+
src/editor/animejs/index.js

.eslintrc.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'plugin:@wordpress/eslint-plugin/recommended-with-formatting',
5+
'plugin:jest/recommended',
6+
'plugin:compat/recommended',
7+
],
8+
env: {
9+
browser: true,
10+
},
11+
rules: {
12+
semi: [ 'error', 'never' ],
13+
'arrow-parens': [ 'error', 'as-needed' ],
14+
camelcase: [ 'error', { allow: [ '\\w+(_\\d+)+' ] } ],
15+
'object-curly-newline': [ 'error', {
16+
ObjectExpression: {
17+
multiline: true, minProperties: 3, consistent: true,
18+
},
19+
ObjectPattern: {
20+
multiline: true, minProperties: 3, consistent: true,
21+
},
22+
ImportDeclaration: {
23+
multiline: true, minProperties: 3, consistent: false,
24+
},
25+
ExportDeclaration: {
26+
multiline: true, minProperties: 3, consistent: false,
27+
},
28+
} ],
29+
'no-shadow': 'off',
30+
'no-nested-ternary': 'off',
31+
'no-mixed-spaces-and-tabs': [ 'error', 'smart-tabs' ],
32+
'sort-vars': [ 'error', { ignoreCase: true } ],
33+
'array-element-newline': [ 'error', 'consistent' ],
34+
'@wordpress/valid-sprintf': 'off',
35+
'@wordpress/no-unused-vars-before-return': 'off',
36+
'jsdoc/no-undefined-types': 'off',
37+
'@wordpress/no-unguarded-get-range-at': 'off',
38+
'linebreak-style': [ 'error', 'unix' ],
39+
'no-unused-expressions': 'off',
40+
'import/no-extraneous-dependencies': 'off',
41+
'import/no-unresolved': 'off',
42+
'@wordpress/i18n-text-domain': 'off',
43+
'@wordpress/i18n-translator-comments': 'off',
44+
'@wordpress/no-base-control-with-label-without-id': 'off',
45+
'no-unused-vars': [ 'error', { varsIgnorePattern: '^_' } ],
46+
'react/jsx-indent': [ 2, 'tab', { indentLogicalExpressions: true } ],
47+
'react/jsx-curly-brace-presence': [ 'error', { props: 'never', children: 'never' } ],
48+
},
49+
globals: {
50+
localStorage: true,
51+
fetch: true,
52+
Waypoint: true,
53+
shallow: true,
54+
btoa: true,
55+
alert: true,
56+
Element: true,
57+
FileReader: true,
58+
MutationObserver: true,
59+
IntersectionObserver: true,
60+
InteractRunner: true,
61+
interactions: true,
62+
BUILD_TYPE: true,
63+
PREMIUM_ACTIONS_NUM: true,
64+
PREMIUM_INTERACTIONS_NUM: true,
65+
},
66+
}
67+

.github/workflows/plugin-build.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Plugin Build
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out
15+
uses: actions/checkout@v2
16+
17+
- name: Set the version suffix for the output
18+
run: echo VERSION_SUFFIX=${GITHUB_REF_NAME//\//-} >> $GITHUB_ENV
19+
20+
- name: Install ffmpeg
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y ffmpeg
24+
25+
- name: Install dependencies and build
26+
run: |
27+
npm ci --legacy-peer-deps
28+
npm run build --suffix=${{ env.VERSION_SUFFIX }}
29+
30+
- name: Rename build zip for PR
31+
run: |
32+
# Find the zip file in build directory
33+
ZIP_FILE=$(find build -name "interactions-*.zip" -type f | head -1)
34+
if [ -n "$ZIP_FILE" ]; then
35+
mv "$ZIP_FILE" wpnteractions-${{ env.VERSION_SUFFIX }}.zip
36+
echo "Renamed $ZIP_FILE to interactions-${{ env.VERSION_SUFFIX }}.zip"
37+
else
38+
echo "Build zip file not found in build directory"
39+
echo "Contents of build directory:"
40+
ls -la build/
41+
exit 1
42+
fi
43+
44+
- name: Upload PR build zip artifact
45+
if: ${{ github.event_name == 'pull_request' }}
46+
uses: gavv/[email protected]
47+
with:
48+
commit: ${{ github.event.pull_request.head.sha }}
49+
repo-token: ${{ secrets.GITHUB_TOKEN }}
50+
artifacts: interactions-${{ env.VERSION_SUFFIX }}.zip
51+
artifacts-branch: artifacts

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules/
2+
build/
3+
dist/
4+
build-plugin/
5+
.DS_Store
6+
*.log
7+
*.map
8+
package-lock.json
9+
pro__premium_only/

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"@wordpress/prettier-config"

.prettierrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require( '@wordpress/prettier-config' )

.stylelintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
vendor/
3+
build/
4+
dist/
5+
*.min.css

0 commit comments

Comments
 (0)