@plaudit/webpack-extensions 2.67.0 → 2.68.1

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.
@@ -28,12 +28,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
28
28
  const emitDir = node_path_1.default.join(this.buildRoot, this.outputDir);
29
29
  const handleLists = {
30
30
  register: [],
31
- clientView: [],
32
- clientEditor: [],
33
- admin: [],
34
- login: [],
35
- customizer: [],
36
- analytics: []
31
+ ...Object.fromEntries((0, shared_1.constantKeys)(shared_1.standardLocationNamesMeta).map(sln => [sln, []]))
37
32
  };
38
33
  const allNamedHandles = assets
39
34
  .flatMap(({ handles }) => handles)
@@ -112,7 +107,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
112
107
  if (data.locations.register !== false) {
113
108
  handleLists.register.push({ handle, type, data, priority: typeof data.locations.register === 'number' ? data.locations.register : 10 });
114
109
  }
115
- for (const location of shared_1.standardLocationNames) {
110
+ for (const location of (0, shared_1.constantKeys)(shared_1.standardLocationNamesMeta)) {
116
111
  if (location === 'clientEditor' && type === 'style') {
117
112
  // We don't include editor styles in the handle list because editor styles are enqueued via a completely separate mechanism at runtime and, therefore,
118
113
  // cannot be handled by the same code as every other enqueueable item
@@ -128,10 +123,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
128
123
  }
129
124
  }
130
125
  static appendEnqueuingHandleLists(writer, handleLists) {
131
- const enqueuingHandleActions = [
132
- ["wp_enqueue_scripts", handleLists.clientView], ["enqueue_block_editor_assets", handleLists.clientEditor], ["admin_enqueue_scripts", handleLists.admin],
133
- ["login_enqueue_scripts", handleLists.login], ["customize_controls_enqueue_scripts", handleLists.customizer], ["plaudit_enqueue_analytics", handleLists.analytics]
134
- ];
126
+ const enqueuingHandleActions = (0, shared_1.constantEntries)(shared_1.standardLocationNamesMeta).map(([sln, { action }]) => [action, handleLists[sln]]);
135
127
  for (const [action, handleList] of enqueuingHandleActions) {
136
128
  if (handleList.length > 0) {
137
129
  for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(handleList)) {
package/build/shared.d.ts CHANGED
@@ -14,8 +14,30 @@ export type HandleData = {
14
14
  in_footer?: boolean;
15
15
  } | boolean];
16
16
  };
17
- export declare const standardLocationNames: readonly ["clientView", "clientEditor", "admin", "login", "customizer", "analytics"];
18
- export type StandardLocationNames = typeof standardLocationNames[number];
17
+ export declare const standardLocationNamesMeta: {
18
+ readonly clientView: {
19
+ readonly action: "wp_enqueue_scripts";
20
+ };
21
+ readonly clientEditor: {
22
+ readonly action: "enqueue_block_editor_assets";
23
+ };
24
+ readonly blockAssets: {
25
+ readonly action: "enqueue_block_assets";
26
+ };
27
+ readonly admin: {
28
+ readonly action: "admin_enqueue_scripts";
29
+ };
30
+ readonly login: {
31
+ readonly action: "login_enqueue_scripts";
32
+ };
33
+ readonly customizer: {
34
+ readonly action: "customize_controls_enqueue_scripts";
35
+ };
36
+ readonly analytics: {
37
+ readonly action: "plaudit_enqueue_analytics";
38
+ };
39
+ };
40
+ export type StandardLocationNames = keyof typeof standardLocationNamesMeta;
19
41
  export type UsageLocations = {
20
42
  [K in StandardLocationNames]?: boolean | number;
21
43
  } & {
@@ -26,6 +48,12 @@ export type UsageLocations = {
26
48
  in_footer?: boolean;
27
49
  } | boolean;
28
50
  };
51
+ export declare function constantKeys<K extends string, V>(object: {
52
+ [k in K]: V;
53
+ }): K[];
54
+ export declare function constantEntries<K extends string, V>(object: {
55
+ [k in K]: V;
56
+ }): [K, V][];
29
57
  export declare const enum SourceType {
30
58
  blocks = "blocks",
31
59
  extensions = "extensions",
package/build/shared.js CHANGED
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.styleExtension = exports.scriptWithModuleExtension = exports.scriptWithoutModuleExtension = exports.scriptExtension = exports.entrypointFields = exports.standardLocationNames = void 0;
6
+ exports.styleExtension = exports.scriptWithModuleExtension = exports.scriptWithoutModuleExtension = exports.scriptExtension = exports.entrypointFields = exports.standardLocationNamesMeta = void 0;
7
7
  exports.isParsedAssetsJson = isParsedAssetsJson;
8
+ exports.constantKeys = constantKeys;
9
+ exports.constantEntries = constantEntries;
8
10
  exports.determineCurrentSourceType = determineCurrentSourceType;
9
11
  exports.convertUsageLocationsHandleToEmittableHandle = convertUsageLocationsHandleToEmittableHandle;
10
12
  exports.makeEmittableConfigPHP = makeEmittableConfigPHP;
@@ -39,7 +41,17 @@ function isParsedAssetsJson(thing) {
39
41
  }
40
42
  return true;
41
43
  }
42
- exports.standardLocationNames = ['clientView', 'clientEditor', 'admin', 'login', 'customizer', 'analytics'];
44
+ exports.standardLocationNamesMeta = {
45
+ clientView: { action: "wp_enqueue_scripts" }, clientEditor: { action: "enqueue_block_editor_assets" }, blockAssets: { action: "enqueue_block_assets" },
46
+ admin: { action: "admin_enqueue_scripts" }, login: { action: "login_enqueue_scripts" }, customizer: { action: "customize_controls_enqueue_scripts" },
47
+ analytics: { action: "plaudit_enqueue_analytics" }
48
+ };
49
+ function constantKeys(object) {
50
+ return Object.keys(object);
51
+ }
52
+ function constantEntries(object) {
53
+ return Object.entries(object);
54
+ }
43
55
  function determineCurrentSourceType(dest, srcIsDirectory) {
44
56
  if (typeof dest === 'string') {
45
57
  return srcIsDirectory ? "blocks" /* SourceType.blocks */ : "plain" /* SourceType.plain */;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.67.0",
3
+ "version": "2.68.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/build"