@powerlines/plugin-image-compression 0.2.69 → 0.2.71

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.
Files changed (40) hide show
  1. package/dist/index-BgAdqTbb.d.mts +1 -0
  2. package/dist/index-CEgs-Dz2.d.cts +1 -0
  3. package/dist/index.cjs +65 -5
  4. package/dist/index.d.cts +2 -2
  5. package/dist/index.d.mts +2 -3
  6. package/dist/index.mjs +35 -1
  7. package/dist/plugin-C20deWYm.d.cts +1819 -0
  8. package/dist/plugin-C3MaN5jp.mjs +1 -0
  9. package/dist/plugin-DHXHjv16.cjs +0 -0
  10. package/dist/plugin-DxOmyOU0.d.mts +1819 -0
  11. package/dist/types/index.cjs +2 -0
  12. package/dist/types/index.d.cts +2 -1
  13. package/dist/types/index.d.mts +2 -1
  14. package/dist/types/index.mjs +3 -0
  15. package/dist/types/plugin.cjs +1 -0
  16. package/dist/types/plugin.d.cts +1 -74
  17. package/dist/types/plugin.d.mts +1 -74
  18. package/dist/types/plugin.mjs +2 -0
  19. package/dist/types-CTUnla4x.mjs +1 -0
  20. package/dist/types-DHkg7xmX.cjs +0 -0
  21. package/package.json +5 -5
  22. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  23. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  24. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  25. package/dist/powerlines/src/types/build.d.cts +0 -145
  26. package/dist/powerlines/src/types/build.d.mts +0 -145
  27. package/dist/powerlines/src/types/commands.d.cts +0 -8
  28. package/dist/powerlines/src/types/commands.d.mts +0 -8
  29. package/dist/powerlines/src/types/config.d.cts +0 -369
  30. package/dist/powerlines/src/types/config.d.mts +0 -369
  31. package/dist/powerlines/src/types/context.d.cts +0 -403
  32. package/dist/powerlines/src/types/context.d.mts +0 -403
  33. package/dist/powerlines/src/types/fs.d.cts +0 -486
  34. package/dist/powerlines/src/types/fs.d.mts +0 -486
  35. package/dist/powerlines/src/types/plugin.d.cts +0 -231
  36. package/dist/powerlines/src/types/plugin.d.mts +0 -231
  37. package/dist/powerlines/src/types/resolved.d.cts +0 -81
  38. package/dist/powerlines/src/types/resolved.d.mts +0 -81
  39. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  40. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.cjs CHANGED
@@ -1,6 +1,33 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
- const require_paths = require('./powerlines/src/plugin-utils/paths.cjs');
2
+ //#region rolldown:runtime
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+
28
+ //#endregion
29
+ require('./plugin-DHXHjv16.cjs');
30
+ require('./types-DHkg7xmX.cjs');
4
31
  let __stryke_convert_to_array = require("@stryke/convert/to-array");
5
32
  let __stryke_fs_list_files = require("@stryke/fs/list-files");
6
33
  let __stryke_fs_read_file = require("@stryke/fs/read-file");
@@ -8,11 +35,44 @@ let __stryke_fs_write_file = require("@stryke/fs/write-file");
8
35
  let __stryke_path_find = require("@stryke/path/find");
9
36
  let __stryke_string_format_pretty_bytes = require("@stryke/string-format/pretty-bytes");
10
37
  let chalk = require("chalk");
11
- chalk = require_rolldown_runtime.__toESM(chalk);
38
+ chalk = __toESM(chalk);
12
39
  let node_buffer = require("node:buffer");
13
40
  let node_fs_promises = require("node:fs/promises");
41
+ let __stryke_path_replace = require("@stryke/path/replace");
14
42
  let svgo = require("svgo");
15
43
 
44
+ //#region ../powerlines/src/plugin-utils/paths.ts
45
+ /**
46
+ * Replaces tokens in the given path string with their corresponding values from the context.
47
+ *
48
+ * @remarks
49
+ * The following tokens are supported:
50
+ * - `{workspaceRoot}` - The root directory of the workspace.
51
+ * - `{root}` - The root directory of the project (same as `{projectRoot}`).
52
+ * - `{projectRoot}` - The root directory of the project (same as `{root}`).
53
+ * - `{sourceRoot}` - The source root directory of the project (usually `./src`).
54
+ * - `{powerlinesPath}` - The directory where Powerlines is installed.
55
+ * - `{cachePath}` - The environment's directory for cached files.
56
+ * - `{dataPath}` - The environment's directory for data files.
57
+ * - `{logPath}` - The environment's directory for log files.
58
+ * - `{tempPath}` - The environment's directory for temporary files.
59
+ * - `{configPath}` - The environment's directory for configuration files.
60
+ * - `{outputPath}` - The configured output directory for the project.
61
+ * - `{buildPath}` - The configured distribution directory for the project.
62
+ * - `{artifactsPath}` - The configured directory for build artifacts.
63
+ * - `{builtinPath}` - The configured directory for generated built-in plugins.
64
+ * - `{entryPath}` - The configured directory for generated entry files.
65
+ *
66
+ * @param context - The context containing the values for the path tokens.
67
+ * @param path - The path string with tokens to replace.
68
+ * @returns The path string with tokens replaced by their corresponding values from the context.
69
+ */
70
+ function replacePathTokens(context, path) {
71
+ if (!path) return path;
72
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", (0, __stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, __stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
73
+ }
74
+
75
+ //#endregion
16
76
  //#region src/index.ts
17
77
  /**
18
78
  * A Powerlines plugin to optimize image assets used by the project.
@@ -42,12 +102,12 @@ const plugin = (options = {}) => {
42
102
  },
43
103
  async configResolved() {
44
104
  if (!this.config.imageCompression.filter) throw new Error("ImageCompression plugin requires a filter or glob pattern to be specified in the configuration.");
45
- this.config.imageCompression.filter = (0, __stryke_convert_to_array.toArray)(this.config.imageCompression.filter).map((path) => require_paths.replacePathTokens(this, path)).filter(Boolean);
105
+ this.config.imageCompression.filter = (0, __stryke_convert_to_array.toArray)(this.config.imageCompression.filter).map((path) => replacePathTokens(this, path)).filter(Boolean);
46
106
  },
47
107
  async prepare() {
48
108
  await Promise.all((0, __stryke_convert_to_array.toArray)(this.config.imageCompression.filter).map(async (path) => {
49
109
  await Promise.all((await (0, __stryke_fs_list_files.listFiles)(path)).map(async (file) => {
50
- const outputPath = this.config.imageCompression.outputPath ? require_paths.replacePathTokens(this, this.config.imageCompression.outputPath).replace(/\{fileName\}/g, file.split("/").pop() || "output") : file;
110
+ const outputPath = this.config.imageCompression.outputPath ? replacePathTokens(this, this.config.imageCompression.outputPath).replace(/\{fileName\}/g, file.split("/").pop() || "output") : file;
51
111
  const start = performance.now();
52
112
  const originalSize = (await (0, node_fs_promises.stat)(file)).size;
53
113
  let compressedSize = 0;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { Plugin } from "./powerlines/src/types/plugin.cjs";
2
- import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./types/plugin.cjs";
1
+ import { a as __ΩImageCompressionPluginContext, c as __ΩImageCompressionPluginUserConfig, i as ImageCompressionPluginUserConfig, l as Plugin, n as ImageCompressionPluginOptions, o as __ΩImageCompressionPluginOptions, r as ImageCompressionPluginResolvedConfig, s as __ΩImageCompressionPluginResolvedConfig, t as ImageCompressionPluginContext } from "./plugin-C20deWYm.cjs";
2
+ import "./index-CEgs-Dz2.cjs";
3
3
 
4
4
  //#region src/index.d.ts
5
5
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { Plugin } from "./powerlines/src/types/plugin.mjs";
2
- import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./types/plugin.mjs";
3
- import "./types/index.mjs";
1
+ import { a as __ΩImageCompressionPluginContext, c as __ΩImageCompressionPluginUserConfig, i as ImageCompressionPluginUserConfig, l as Plugin, n as ImageCompressionPluginOptions, o as __ΩImageCompressionPluginOptions, r as ImageCompressionPluginResolvedConfig, s as __ΩImageCompressionPluginResolvedConfig, t as ImageCompressionPluginContext } from "./plugin-DxOmyOU0.mjs";
2
+ import "./index-BgAdqTbb.mjs";
4
3
 
5
4
  //#region src/index.d.ts
6
5
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { replacePathTokens } from "./powerlines/src/plugin-utils/paths.mjs";
1
+ import "./plugin-C3MaN5jp.mjs";
2
+ import "./types-CTUnla4x.mjs";
2
3
  import { toArray } from "@stryke/convert/to-array";
3
4
  import { listFiles } from "@stryke/fs/list-files";
4
5
  import { readFile } from "@stryke/fs/read-file";
@@ -8,8 +9,41 @@ import { prettyBytes } from "@stryke/string-format/pretty-bytes";
8
9
  import chalk from "chalk";
9
10
  import { Buffer } from "node:buffer";
10
11
  import { stat } from "node:fs/promises";
12
+ import { replacePath } from "@stryke/path/replace";
11
13
  import { optimize } from "svgo";
12
14
 
15
+ //#region ../powerlines/src/plugin-utils/paths.ts
16
+ /**
17
+ * Replaces tokens in the given path string with their corresponding values from the context.
18
+ *
19
+ * @remarks
20
+ * The following tokens are supported:
21
+ * - `{workspaceRoot}` - The root directory of the workspace.
22
+ * - `{root}` - The root directory of the project (same as `{projectRoot}`).
23
+ * - `{projectRoot}` - The root directory of the project (same as `{root}`).
24
+ * - `{sourceRoot}` - The source root directory of the project (usually `./src`).
25
+ * - `{powerlinesPath}` - The directory where Powerlines is installed.
26
+ * - `{cachePath}` - The environment's directory for cached files.
27
+ * - `{dataPath}` - The environment's directory for data files.
28
+ * - `{logPath}` - The environment's directory for log files.
29
+ * - `{tempPath}` - The environment's directory for temporary files.
30
+ * - `{configPath}` - The environment's directory for configuration files.
31
+ * - `{outputPath}` - The configured output directory for the project.
32
+ * - `{buildPath}` - The configured distribution directory for the project.
33
+ * - `{artifactsPath}` - The configured directory for build artifacts.
34
+ * - `{builtinPath}` - The configured directory for generated built-in plugins.
35
+ * - `{entryPath}` - The configured directory for generated entry files.
36
+ *
37
+ * @param context - The context containing the values for the path tokens.
38
+ * @param path - The path string with tokens to replace.
39
+ * @returns The path string with tokens replaced by their corresponding values from the context.
40
+ */
41
+ function replacePathTokens(context, path) {
42
+ if (!path) return path;
43
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
44
+ }
45
+
46
+ //#endregion
13
47
  //#region src/index.ts
14
48
  /**
15
49
  * A Powerlines plugin to optimize image assets used by the project.