@eightshift/frontend-libs-tailwind 3.2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,6 @@ const DEFAULT_STATE = {
10
10
  components: {},
11
11
  config: {
12
12
  useWrapper: true,
13
- useLegacyComponents: true,
14
13
  },
15
14
  wrapper: {},
16
15
  variations: {},
@@ -45,9 +44,6 @@ const selectors = {
45
44
  getConfigUseWrapper(state) {
46
45
  return state.config.useWrapper;
47
46
  },
48
- getConfigUseLegacyComponents(state) {
49
- return state.config.useLegacyComponents;
50
- },
51
47
  getWrapper(state) {
52
48
  return state.wrapper;
53
49
  },
@@ -94,12 +90,6 @@ const actions = {
94
90
  config,
95
91
  };
96
92
  },
97
- setConfigUseLegacyComponents(config) {
98
- return {
99
- type: 'SET_CONFIG_USE_LEGACY_COMPONENTS',
100
- config,
101
- };
102
- },
103
93
  setWrapper(wrapper) {
104
94
  return {
105
95
  type: 'SET_WRAPPER',
@@ -150,15 +140,6 @@ const reducer = (state = DEFAULT_STATE, action) => {
150
140
  },
151
141
  };
152
142
  }
153
- case 'SET_CONFIG_USE_LEGACY_COMPONENTS': {
154
- return {
155
- ...state,
156
- config: {
157
- ...state.config,
158
- useLegacyComponents: action.config,
159
- },
160
- };
161
- }
162
143
  case 'SET_WRAPPER': {
163
144
  return {
164
145
  ...state,
@@ -1,222 +1,6 @@
1
1
  import { checkAttr } from '../editor/attributes';
2
2
  import { clsx } from '@eightshift/ui-components/utilities';
3
3
 
4
- /**
5
- * Gets Tailwind classes for the provided part.
6
- *
7
- * The part needs to be defined within the manifest, in the `tailwind` object.
8
- *
9
- * @param {string} part - Part name.
10
- * @param {Object<string, mixed>} manifest - Component/block manifest.
11
- * @param {...string?} custom - Custom classes to include in the output.
12
- *
13
- * @returns {string} Output classes.
14
- *
15
- * @deprecated Since 1.4.0. Use `tailwindClasses` instead.
16
- *
17
- * @example
18
- * const classes = getTwPart('intro', manifest);
19
- *
20
- * @example
21
- * const classes = getTwPart('intro', manifest, 'p-4 bg-gray-100');
22
- *
23
- */
24
- export const getTwPart = (part, manifest, ...custom) => {
25
- if (!part || !manifest || !manifest?.tailwind || Object.keys(manifest?.tailwind ?? {}).length === 0) {
26
- return clsx(...custom);
27
- }
28
-
29
- let partClasses =
30
- manifest?.tailwind?.parts?.[part]?.twClassesEditor ?? manifest?.tailwind?.parts?.[part]?.twClasses ?? '';
31
-
32
- if (Array.isArray(partClasses)) {
33
- partClasses = partClasses.join(' ');
34
- }
35
-
36
- return clsx(partClasses, ...custom);
37
- };
38
-
39
- /**
40
- * Gets Tailwind classes for the provided dynamic part.
41
- *
42
- * The part needs to be defined within the manifest, in the `tailwind` object.
43
- *
44
- * @param {string} part - Part name.
45
- * @param {Object<string, mixed>} attributes - Current attribute value.
46
- * @param {Object<string, mixed>} manifest - Component/block manifest.
47
- * @param {...string?} custom - Custom classes to include in the output.
48
- *
49
- * @returns {string} Output classes.
50
- *
51
- * @deprecated Since 1.4.0. Use `tailwindClasses` instead.
52
- *
53
- * @example
54
- * const classes = getTwPart('intro', manifest);
55
- *
56
- * @example
57
- * const classes = getTwPart('intro', manifest, 'p-4 bg-gray-100');
58
- *
59
- */
60
- export const getTwDynamicPart = (part, attributes, manifest, ...custom) => {
61
- if (!part || !manifest || !manifest?.tailwind || Object.keys(manifest?.tailwind ?? {}).length === 0) {
62
- return clsx(...custom);
63
- }
64
-
65
- const baseClasses =
66
- manifest?.tailwind?.parts?.[part]?.twClassesEditor ?? manifest?.tailwind?.parts?.[part]?.twClasses ?? '';
67
-
68
- const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce(
69
- (current, [attributeName, { responsive, twClasses, twClassesEditor, part: partName }]) => {
70
- if (partName !== part) {
71
- return current;
72
- }
73
-
74
- const value = checkAttr(attributeName, attributes, manifest, true);
75
-
76
- if (!value) {
77
- return current;
78
- }
79
-
80
- if (!responsive) {
81
- const currentClasses = twClassesEditor?.[value] ?? twClasses?.[value];
82
-
83
- if (Array.isArray(currentClasses)) {
84
- return [...current, ...currentClasses];
85
- }
86
-
87
- return [...current, currentClasses];
88
- }
89
-
90
- const responsiveClasses = Object.keys(value).reduce((curr, breakpoint) => {
91
- if (breakpoint === '_desktopFirst') {
92
- return curr;
93
- }
94
-
95
- let currentClasses = twClassesEditor?.[value[breakpoint]] ?? twClasses?.[value[breakpoint]];
96
-
97
- if (!Array.isArray(currentClasses)) {
98
- currentClasses = [currentClasses];
99
- }
100
-
101
- if (breakpoint === '_default') {
102
- return [...curr, ...currentClasses];
103
- }
104
-
105
- return [...curr, ...currentClasses.split(' ').map((currentClass) => `${breakpoint}:${currentClass}`)];
106
- }, []);
107
-
108
- return [...current, ...responsiveClasses];
109
- },
110
- [],
111
- );
112
-
113
- return clsx(baseClasses, ...mainClasses, ...custom);
114
- };
115
-
116
- /**
117
- * Get Tailwind classes from attributes and manifest.
118
- *
119
- * @param {Object<string, mixed>} attributes - Current attribute value.
120
- * @param {Object<string, mixed>} manifest - Component/block manifest.
121
- * @param {...string?} custom - Custom classes to include in the output.
122
- *
123
- * @returns {string} Output classes
124
- *
125
- * @deprecated Since 1.4.0. Use `tailwindClasses` instead.
126
- *
127
- * @example
128
- * const classes = getTwClasses(attributes, manifest);
129
- *
130
- * @example
131
- * const classes = getTwClasses(attributes, manifest, 'p-4 bg-gray-100');
132
- *
133
- */
134
- export const getTwClasses = (attributes, manifest, ...custom) => {
135
- if (!attributes || !manifest || !manifest?.tailwind || Object.keys(manifest?.tailwind ?? {}).length === 0) {
136
- return clsx(...custom);
137
- }
138
-
139
- let baseClasses = manifest?.tailwind?.base?.twClassesEditor ?? manifest?.tailwind?.base?.twClasses ?? '';
140
-
141
- if (Array.isArray(baseClasses)) {
142
- baseClasses = baseClasses.join(' ');
143
- }
144
-
145
- const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce(
146
- (current, [attributeName, { responsive, twClasses, twClassesEditor, part: partName }]) => {
147
- if (partName) {
148
- return current;
149
- }
150
-
151
- const value = checkAttr(attributeName, attributes, manifest, true);
152
-
153
- if (!value) {
154
- return current;
155
- }
156
-
157
- if (!responsive) {
158
- let currentClasses = twClassesEditor?.[value] ?? twClasses?.[value];
159
-
160
- if (Array.isArray(currentClasses)) {
161
- currentClasses = currentClasses.join(' ');
162
- }
163
-
164
- return [...current, currentClasses];
165
- }
166
-
167
- const responsiveClasses = Object.keys(value).reduce((curr, breakpoint) => {
168
- if (breakpoint === '_desktopFirst') {
169
- return curr;
170
- }
171
-
172
- let currentClasses = twClassesEditor?.[value[breakpoint]] ?? twClasses?.[value[breakpoint]];
173
-
174
- if (!Array.isArray(currentClasses)) {
175
- currentClasses = [currentClasses];
176
- }
177
-
178
- if (breakpoint === '_default') {
179
- return [...curr, ...currentClasses];
180
- }
181
-
182
- return [...curr, ...currentClasses.map((currentClass) => `${breakpoint}:${currentClass}`)];
183
- }, []);
184
-
185
- return [...current, ...responsiveClasses];
186
- },
187
- [],
188
- );
189
-
190
- const combinationClasses =
191
- manifest?.tailwind?.combinations?.reduce((current, { attributes: conditions, twClasses, twClassesEditor }) => {
192
- const conditionKeys = Object.keys(conditions);
193
-
194
- for (const key of conditionKeys) {
195
- const value = checkAttr(key, attributes, manifest, true);
196
-
197
- const isArrayCondition = Array.isArray(conditions[key]);
198
-
199
- if (!value) {
200
- return current;
201
- } else if (isArrayCondition && !conditions[key].includes(value)) {
202
- return current;
203
- } else if (!isArrayCondition && value !== conditions[key]) {
204
- return current;
205
- }
206
- }
207
-
208
- let currentClasses = twClassesEditor ?? twClasses;
209
-
210
- if (!Array.isArray(currentClasses)) {
211
- currentClasses = [currentClasses];
212
- }
213
-
214
- return [...current, ...currentClasses];
215
- }, []) ?? [];
216
-
217
- return clsx(baseClasses, ...mainClasses, ...combinationClasses, ...custom);
218
- };
219
-
220
4
  /**
221
5
  * Custom transformer for JSON files. Required for processing responsive classes.
222
6
  *
@@ -316,14 +100,14 @@ export const generateOptionsFromValue = (value, getLabel = (v) => v) => {
316
100
 
317
101
  // Utilities
318
102
  function* extractKeys(obj, parentKey = '', isResponsive = false) {
319
- isResponsive = obj['responsive'] === true ? true : isResponsive;
320
- let resultKey = isResponsive ? 'responsive' : 'regular';
103
+ const responsive = obj['responsive'] === true ? true : isResponsive;
104
+ let resultKey = responsive ? 'responsive' : 'regular';
321
105
 
322
106
  for (let key in obj) {
323
107
  let newKey = parentKey ? `${parentKey}.${key}` : key;
324
108
 
325
109
  if (typeof obj[key] === 'object' && obj[key] !== null) {
326
- yield* extractKeys(obj[key], newKey, isResponsive);
110
+ yield* extractKeys(obj[key], newKey, responsive);
327
111
  } else if (newKey.includes('twClasses')) {
328
112
  if (typeof obj[key] === 'object') {
329
113
  for (let subKey in obj[key]) {
@@ -356,7 +140,9 @@ const unifyClasses = (classes) => {
356
140
  return classes.trim();
357
141
  };
358
142
 
359
- const processOption = (partName, optionValue, defs) => {
143
+ const processOption = (partName, optionValue, defs, options) => {
144
+ const { ignoreEditorClasses } = options;
145
+
360
146
  let optionClasses = [];
361
147
 
362
148
  const isResponsive = defs?.responsive === true;
@@ -373,20 +159,20 @@ const processOption = (partName, optionValue, defs) => {
373
159
  }
374
160
 
375
161
  // Non-responsive options.
376
- if (!isResponsive) {
377
- const rawValueBase =
378
- defs?.twClassesEditorOnly?.[optionValue] ??
379
- defs?.twClasses?.[optionValue] ??
380
- defs?.[partName]?.twClassesEditorOnly?.[optionValue] ??
381
- defs?.[partName]?.twClasses?.[optionValue] ??
382
- '';
162
+ if (!isResponsive && !ignoreEditorClasses) {
163
+ const rawValueBase = defs?.twClassesEditorOnly?.[optionValue] ?? defs?.twClasses?.[optionValue] ?? defs?.[partName]?.twClassesEditorOnly?.[optionValue] ?? defs?.[partName]?.twClasses?.[optionValue] ?? '';
383
164
 
384
- const rawValueEditor =
385
- defs?.twClassesEditor?.[optionValue] ?? defs?.[partName]?.twClassesEditor?.[optionValue] ?? '';
165
+ const rawValueEditor = defs?.twClassesEditor?.[optionValue] ?? defs?.[partName]?.twClassesEditor?.[optionValue] ?? '';
386
166
 
387
167
  return clsx(unifyClasses(rawValueBase), unifyClasses(rawValueEditor));
388
168
  }
389
169
 
170
+ if (!isResponsive && ignoreEditorClasses) {
171
+ const rawValueBase = defs?.twClasses?.[optionValue] ?? defs?.[partName]?.twClasses?.[optionValue] ?? '';
172
+
173
+ return unifyClasses(rawValueBase);
174
+ }
175
+
390
176
  // Responsive options.
391
177
  const breakpoints = Object.keys(optionValue).filter((key) => key !== '_desktopFirst');
392
178
 
@@ -397,15 +183,15 @@ const processOption = (partName, optionValue, defs) => {
397
183
  continue;
398
184
  }
399
185
 
400
- const rawValueBase =
401
- defs?.twClassesEditorOnly?.[breakpointValue] ??
402
- defs?.twClasses?.[breakpointValue] ??
403
- defs?.[partName]?.twClassesEditorOnly?.[breakpointValue] ??
404
- defs?.[partName]?.twClasses?.[breakpointValue] ??
405
- '';
186
+ let rawValueBase = '';
187
+ let rawValueEditor = '';
406
188
 
407
- const rawValueEditor =
408
- defs?.twClassesEditor?.[breakpointValue] ?? defs?.[partName]?.twClassesEditor?.[breakpointValue] ?? '';
189
+ if (ignoreEditorClasses) {
190
+ rawValueBase = defs?.twClasses?.[breakpointValue] ?? defs?.[partName]?.twClasses?.[breakpointValue] ?? '';
191
+ } else {
192
+ rawValueBase = defs?.twClassesEditorOnly?.[breakpointValue] ?? defs?.twClasses?.[breakpointValue] ?? defs?.[partName]?.twClassesEditorOnly?.[breakpointValue] ?? defs?.[partName]?.twClasses?.[breakpointValue] ?? '';
193
+ rawValueEditor = defs?.twClassesEditor?.[breakpointValue] ?? defs?.[partName]?.twClassesEditor?.[breakpointValue] ?? '';
194
+ }
409
195
 
410
196
  if (breakpoint === '_default') {
411
197
  optionClasses = [...optionClasses, unifyClasses(rawValueBase), unifyClasses(rawValueEditor)];
@@ -429,7 +215,9 @@ const processOption = (partName, optionValue, defs) => {
429
215
  return unifyClasses(optionClasses);
430
216
  };
431
217
 
432
- const processCombination = (partName, combo, attributes, manifest) => {
218
+ const processCombination = (partName, combo, attributes, manifest, options) => {
219
+ const { ignoreEditorClasses } = options;
220
+
433
221
  let matches = true;
434
222
 
435
223
  for (const [attributeName, allowedValue] of Object.entries(combo?.attributes ?? {})) {
@@ -457,25 +245,22 @@ const processCombination = (partName, combo, attributes, manifest) => {
457
245
  return '';
458
246
  }
459
247
 
460
- const rawValueBase =
461
- combo?.output?.[partName]?.twClassesEditorOnly ??
462
- combo?.output?.[partName]?.twClasses ??
463
- combo?.twClassesEditorOnly ??
464
- combo?.twClasses ??
465
- '';
248
+ let rawValueBase = '';
249
+ let rawValueEditor = '';
466
250
 
467
- const rawValueEditor = combo?.output?.[partName]?.twClassesEditor ?? combo?.twClassesEditor ?? '';
251
+ if (ignoreEditorClasses) {
252
+ rawValueBase = combo?.output?.[partName]?.twClasses ?? combo?.twClasses ?? '';
253
+ } else {
254
+ rawValueBase = combo?.output?.[partName]?.twClassesEditorOnly ?? combo?.output?.[partName]?.twClasses ?? combo?.twClassesEditorOnly ?? combo?.twClasses ?? '';
255
+ rawValueEditor = combo?.output?.[partName]?.twClassesEditor ?? combo?.twClassesEditor ?? '';
256
+ }
468
257
 
469
258
  if (!Array.isArray(rawValueBase) && typeof rawValueBase !== 'string') {
470
- throw new Error(
471
- 'Combination classes/editor-only classes were not defined correctly. Please check the combination definition in the manifest.',
472
- );
259
+ throw new Error('Combination classes/editor-only classes were not defined correctly. Please check the combination definition in the manifest.');
473
260
  }
474
261
 
475
262
  if (!Array.isArray(rawValueEditor) && typeof rawValueEditor !== 'string') {
476
- throw new Error(
477
- 'Combination editor classes were not defined correctly. Please check the combination definition in the manifest.',
478
- );
263
+ throw new Error('Combination editor classes were not defined correctly. Please check the combination definition in the manifest.');
479
264
  }
480
265
 
481
266
  return clsx(unifyClasses(rawValueBase), unifyClasses(rawValueEditor));
@@ -491,6 +276,14 @@ const processCombination = (partName, combo, attributes, manifest) => {
491
276
  *
492
277
  * @returns {string} Output classes
493
278
  *
279
+ * ### Note
280
+ * `_twcOptions` can be passed in the `attributes` object to customize the behavior of this function.
281
+ *
282
+ * Options include:
283
+ * - `ignoreEditorClasses` (boolean): If true, editor/editor-only classes will be ignored. Default: `false`.
284
+ * - `noPartDebug` (boolean): If true, debug classes for parts will not be added. Default: `false`.
285
+ * - `ssr` (boolean): If true, indicates server-side rendering. Default: determined by checking if `window` is `undefined`.
286
+ *
494
287
  * @example
495
288
  * const classes = tailwindClasses(attributes, manifest);
496
289
  *
@@ -499,6 +292,11 @@ const processCombination = (partName, combo, attributes, manifest) => {
499
292
  *
500
293
  */
501
294
  export const tailwindClasses = (part, attributes, manifest, ...custom) => {
295
+ // eslint-disable-next-line no-underscore-dangle
296
+ const twcOptions = attributes?._twcOptions ?? {};
297
+
298
+ const { ignoreEditorClasses = false, noPartDebug = false, ssr = typeof window === 'undefined' } = twcOptions;
299
+
502
300
  // If nothing is set, return custom classes as a fallback.
503
301
  if (!attributes || !manifest || !manifest?.tailwind || Object.keys(manifest?.tailwind ?? {}).length === 0) {
504
302
  return clsx(...custom);
@@ -508,24 +306,22 @@ export const tailwindClasses = (part, attributes, manifest, ...custom) => {
508
306
 
509
307
  let partName = 'base';
510
308
 
511
- if (
512
- part !== 'base' &&
513
- part?.length > 0 &&
514
- typeof manifest?.tailwind?.parts?.[part] !== 'undefined' &&
515
- allParts.includes(part)
516
- ) {
309
+ if (part !== 'base' && part?.length > 0 && typeof manifest?.tailwind?.parts?.[part] !== 'undefined' && allParts.includes(part)) {
517
310
  partName = part;
518
311
  } else if (part !== 'base') {
519
312
  throw new Error(`Part '${part}' is not defined in the manifest.`);
520
313
  }
521
314
 
522
315
  // Base classes.
523
- const baseBaseClasses = manifest?.tailwind?.parts?.[partName]?.twClassesEditorOnly ??
524
- manifest?.tailwind?.parts?.[partName]?.twClasses ??
525
- manifest?.tailwind?.base?.twClassesEditorOnly ??
526
- manifest?.tailwind?.base?.twClasses ?? [''];
527
- const baseEditorClasses = manifest?.tailwind?.parts?.[partName]?.twClassesEditor ??
528
- manifest?.tailwind?.base?.twClassesEditor ?? [''];
316
+ let baseBaseClasses = '';
317
+ let baseEditorClasses = '';
318
+
319
+ if (ignoreEditorClasses) {
320
+ baseBaseClasses = manifest?.tailwind?.parts?.[partName]?.twClasses ?? manifest?.tailwind?.base?.twClasses ?? [''];
321
+ } else {
322
+ baseBaseClasses = manifest?.tailwind?.parts?.[partName]?.twClassesEditorOnly ?? manifest?.tailwind?.parts?.[partName]?.twClasses ?? manifest?.tailwind?.base?.twClassesEditorOnly ?? manifest?.tailwind?.base?.twClasses ?? [''];
323
+ baseEditorClasses = manifest?.tailwind?.parts?.[partName]?.twClassesEditor ?? manifest?.tailwind?.base?.twClassesEditor ?? [''];
324
+ }
529
325
 
530
326
  // Option classes.
531
327
  const options = manifest?.tailwind?.options ?? {};
@@ -535,7 +331,7 @@ export const tailwindClasses = (part, attributes, manifest, ...custom) => {
535
331
  for (const [attributeName, defs] of Object.entries(options)) {
536
332
  const optionValue = checkAttr(attributeName, attributes, manifest, true);
537
333
 
538
- optionClasses = [...optionClasses, processOption(partName, optionValue, defs)];
334
+ optionClasses = [...optionClasses, processOption(partName, optionValue, defs, twcOptions)];
539
335
  }
540
336
 
541
337
  // Combinations.
@@ -544,17 +340,16 @@ export const tailwindClasses = (part, attributes, manifest, ...custom) => {
544
340
  let combinationClasses = [];
545
341
 
546
342
  for (const combo of combinations) {
547
- combinationClasses = [...combinationClasses, processCombination(partName, combo, attributes, manifest)];
343
+ combinationClasses = [...combinationClasses, processCombination(partName, combo, attributes, manifest, twcOptions)];
548
344
  }
549
345
 
550
346
  const partPrefix = manifest.title.replace(/[^a-zA-Z]+/g, '-').toLowerCase();
551
347
 
552
- return clsx(
553
- document.body.classList.contains('es-wp-debug') && `_es__${partPrefix}/${part}`,
554
- unifyClasses(baseBaseClasses),
555
- unifyClasses(baseEditorClasses),
556
- ...optionClasses,
557
- ...combinationClasses,
558
- ...custom,
559
- );
348
+ let extras = [];
349
+
350
+ if (!ssr && !noPartDebug) {
351
+ extras = [...extras, document?.body?.classList?.contains('es-wp-debug') && `_es__${partPrefix}/${part}`];
352
+ }
353
+
354
+ return clsx(...extras, unifyClasses(baseBaseClasses), unifyClasses(baseEditorClasses), ...optionClasses, ...combinationClasses, ...custom);
560
355
  };
@@ -1,11 +1,5 @@
1
1
  // All exports are sorted in alphabetical order.
2
2
 
3
- export {
4
- getBreakpointData,
5
- getBreakpointNames,
6
- getGlobalManifest,
7
- getBreakpointUiData,
8
- getResponsiveData,
9
- } from './breakpoints';
3
+ export { getBreakpointData, getBreakpointNames, getGlobalManifest, getBreakpointUiData, getResponsiveData } from './breakpoints';
10
4
  export { cookies } from './cookies';
11
5
  export { dynamicImport } from './dynamic-import';
package/scripts/index.js CHANGED
@@ -15,23 +15,10 @@ export * from './editor/fetch';
15
15
  export * from './editor/options';
16
16
  export * from './editor/utility';
17
17
  export * from './editor/tailwindcss';
18
- export {
19
- getAttributes,
20
- getExample,
21
- getFullBlockName,
22
- getFullBlockNameVariation,
23
- registerBlocks,
24
- registerVariations,
25
- } from './editor/registration';
18
+ export { getAttributes, getExample, getFullBlockName, getFullBlockNameVariation, registerBlocks, registerVariations } from './editor/registration';
26
19
  export { STORE_NAME, BUILD_VERSION, setStore, setStoreGlobalWindow, setConfigFlags } from './editor/store';
27
20
 
28
21
  // Helpers.
29
- export {
30
- getBreakpointData,
31
- getBreakpointNames,
32
- getGlobalManifest,
33
- getBreakpointUiData,
34
- getResponsiveData,
35
- } from './helpers/breakpoints';
22
+ export { getBreakpointData, getBreakpointNames, getGlobalManifest, getBreakpointUiData, getResponsiveData } from './helpers/breakpoints';
36
23
  export { cookies } from './helpers/cookies';
37
24
  export { dynamicImport } from './helpers/dynamic-import';
@@ -15,11 +15,7 @@ export const yoastSeo = (options) => {
15
15
 
16
16
  domReady(() => {
17
17
  // Ensure YoastSEO.js is present and can access the necessary features.
18
- if (
19
- typeof YoastSEO === 'undefined' ||
20
- typeof YoastSEO.analysis === 'undefined' ||
21
- typeof YoastSEO.analysis.worker === 'undefined'
22
- ) {
18
+ if (typeof YoastSEO === 'undefined' || typeof YoastSEO.analysis === 'undefined' || typeof YoastSEO.analysis.worker === 'undefined') {
23
19
  return;
24
20
  }
25
21
 
package/webpack/base.mjs CHANGED
@@ -17,9 +17,7 @@ export default (options) => {
17
17
  if (!options.overrides.includes('definePlugin')) {
18
18
  plugins.push(
19
19
  new webpack.DefinePlugin({
20
- 'process.env.VERSION': JSON.stringify(
21
- Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
22
- ),
20
+ 'process.env.VERSION': JSON.stringify(Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)),
23
21
  'process.browser': true,
24
22
  }),
25
23
  );
@@ -15,23 +15,13 @@ import path from 'path';
15
15
  * @param {string} blocksManifestSettingsPath Main global settings manifest.json path after projectPath location.
16
16
  *
17
17
  */
18
- function getConfig(
19
- projectDir,
20
- projectPathConfig,
21
- blocksAssetsPathConfig = 'src/Blocks/assets',
22
- outputPathConfig = 'public',
23
- blocksManifestSettingsPath = 'src/Blocks/manifest.json',
24
- ) {
18
+ function getConfig(projectDir, projectPathConfig, blocksAssetsPathConfig = 'src/Blocks/assets', outputPathConfig = 'public', blocksManifestSettingsPath = 'src/Blocks/manifest.json') {
25
19
  if (typeof projectDir === 'undefined') {
26
- throw Error(
27
- 'projectDir parameter is empty, please provide. This key represents: Current project directory absolute path. For example: __dirname',
28
- );
20
+ throw Error('projectDir parameter is empty, please provide. This key represents: Current project directory absolute path. For example: __dirname');
29
21
  }
30
22
 
31
23
  if (typeof projectPathConfig === 'undefined') {
32
- throw Error(
33
- 'projectPath parameter is empty, please provide. This key represents: Project path relative to project root. For example: wp-content/themes/eightshift-boilerplate',
34
- );
24
+ throw Error('projectPath parameter is empty, please provide. This key represents: Project path relative to project root. For example: wp-content/themes/eightshift-boilerplate');
35
25
  }
36
26
 
37
27
  // Clear all slashes from user config.
@@ -55,16 +45,8 @@ function getConfig(
55
45
  // Source files entries absolute locations.
56
46
  applicationAdminEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-admin.js'),
57
47
  applicationBlocksEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks.js'),
58
- applicationBlocksEditorEntry: path.resolve(
59
- absolutePath,
60
- blocksAssetsPathConfigClean,
61
- 'application-blocks-editor.js',
62
- ),
63
- applicationBlocksFrontendEntry: path.resolve(
64
- absolutePath,
65
- blocksAssetsPathConfigClean,
66
- 'application-blocks-frontend.js',
67
- ),
48
+ applicationBlocksEditorEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks-editor.js'),
49
+ applicationBlocksFrontendEntry: path.resolve(absolutePath, blocksAssetsPathConfigClean, 'application-blocks-frontend.js'),
68
50
 
69
51
  blocksManifestSettingsPath: path.resolve(absolutePath, blocksManifestSettingsPathClean),
70
52
  };
package/webpack/index.mjs CHANGED
@@ -19,13 +19,7 @@ const eightshiftConfig = (mode, optionsData = {}) => {
19
19
  };
20
20
 
21
21
  // Append project config using getConfig helper.
22
- options.config = getConfig(
23
- optionsData.config.projectDir,
24
- optionsData.config.projectPath,
25
- optionsData.config.blocksAssetsPath,
26
- optionsData.config.outputPath,
27
- optionsData.config.blocksManifestSettingsPath,
28
- );
22
+ options.config = getConfig(optionsData.config.projectDir, optionsData.config.projectPath, optionsData.config.blocksAssetsPath, optionsData.config.outputPath, optionsData.config.blocksManifestSettingsPath);
29
23
 
30
24
  options.config.mode = mode;
31
25
  options.config.filesOutput = mode === 'production' ? '[name]-[contenthash]' : '[name]';
@@ -29,18 +29,12 @@ export default (options) => {
29
29
  }
30
30
 
31
31
  // Load ApplicationBlocksEditor Entrypoint.
32
- if (
33
- !options.overrides.includes('applicationBlocksEditor') &&
34
- fs.existsSync(options.config.applicationBlocksEditorEntry)
35
- ) {
32
+ if (!options.overrides.includes('applicationBlocksEditor') && fs.existsSync(options.config.applicationBlocksEditorEntry)) {
36
33
  entry.applicationBlocksEditor = options.config.applicationBlocksEditorEntry;
37
34
  }
38
35
 
39
36
  // Load applicationBlocksFrontend Entrypoint.
40
- if (
41
- !options.overrides.includes('applicationBlocksFrontend') &&
42
- fs.existsSync(options.config.applicationBlocksFrontendEntry)
43
- ) {
37
+ if (!options.overrides.includes('applicationBlocksFrontend') && fs.existsSync(options.config.applicationBlocksFrontendEntry)) {
44
38
  entry.applicationBlocksFrontend = options.config.applicationBlocksFrontendEntry;
45
39
  }
46
40
 
@@ -18,8 +18,7 @@ const DEFAULT_MANIFEST_GLOB = 'src/**/manifest.json';
18
18
  const FRONTEND_CLASS_KEYS = new Set(['twClasses']);
19
19
  const EDITOR_CLASS_KEYS = new Set(['twClasses', 'twClassesEditor', 'twClassesEditorOnly']);
20
20
 
21
- const isResponsiveToken = (token, breakpoints) =>
22
- breakpoints.some((bp) => token.startsWith(`${bp}:`) || token.startsWith(`max-${bp}:`));
21
+ const isResponsiveToken = (token, breakpoints) => breakpoints.some((bp) => token.startsWith(`${bp}:`) || token.startsWith(`max-${bp}:`));
23
22
 
24
23
  const addClasses = (value, breakpoints, output, isResponsive = false) => {
25
24
  if (!value) {
@@ -123,12 +122,7 @@ const runPreprocess = ({ projectDir, breakpoints, manifestGlob, outputFrontend,
123
122
  * @param {string} [options.manifestGlob] Glob (relative to `projectDir`) used to find manifests. Defaults to `src/**\/manifest.json`.
124
123
  * @param {{ frontend?: string, editor?: string }} [options.output] Override absolute output paths.
125
124
  */
126
- export const esTwResponsiveCompiler = ({
127
- projectDir,
128
- breakpoints = DEFAULT_BREAKPOINTS,
129
- manifestGlob = DEFAULT_MANIFEST_GLOB,
130
- output = {},
131
- } = {}) => {
125
+ export const esTwResponsiveCompiler = ({ projectDir, breakpoints = DEFAULT_BREAKPOINTS, manifestGlob = DEFAULT_MANIFEST_GLOB, output = {} } = {}) => {
132
126
  if (!projectDir) {
133
127
  throw new Error('esTwResponsiveCompiler: `projectDir` is required.');
134
128
  }
@@ -1,7 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npm --version)"
5
- ]
6
- }
7
- }