@peachy/plugin-resources 0.0.11 → 0.0.13

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 (2) hide show
  1. package/dist/index.mjs +21 -31
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -6,12 +6,10 @@ import { access, mkdir, mkdtempDisposable, readFile, readdir, stat, writeFile }
6
6
  import { exec } from "node:child_process";
7
7
  import { tmpdir } from "node:os";
8
8
  import { promisify } from "node:util";
9
-
10
9
  //#region src/constants.ts
11
10
  const GRESOURCE_PREFIX = "\0gresource";
12
11
  const GRESOURCE_LOADER = `${GRESOURCE_PREFIX}:loader`;
13
12
  const GRESOURCE_ICONS_PATH = "icons/scalable/actions";
14
-
15
13
  //#endregion
16
14
  //#region src/utilities/index.ts
17
15
  function parseImportType(assertions) {
@@ -56,12 +54,12 @@ function generateImportCode(type, resourcePath, addImportCode = false) {
56
54
  if (addImportCode) return `import ${JSON.stringify(GRESOURCE_LOADER)};${code}`;
57
55
  return code;
58
56
  }
59
- async function loadIcons(prefix, path$1) {
60
- if (!access(path$1).catch(() => false)) throw new Error(`Icon assets directory not found: ${path$1}`);
61
- const files = await readdir(path$1, { recursive: true });
57
+ async function loadIcons(prefix, path) {
58
+ if (!access(path).catch(() => false)) throw new Error(`Icon assets directory not found: ${path}`);
59
+ const files = await readdir(path, { recursive: true });
62
60
  const collectedAssets = /* @__PURE__ */ new Map();
63
61
  for (const file of files) {
64
- const fullName = resolve(path$1, file);
62
+ const fullName = resolve(path, file);
65
63
  const stats = await stat(fullName);
66
64
  if (!fullName.endsWith(".svg") || !stats.isFile()) continue;
67
65
  const id = relative(process.cwd(), fullName);
@@ -72,13 +70,13 @@ async function loadIcons(prefix, path$1) {
72
70
  }
73
71
  return collectedAssets;
74
72
  }
75
- function getFilePath(path$1, alias) {
73
+ function getFilePath(path, alias) {
76
74
  let attrs = "";
77
- if (/\.(svg|xml)$/.test(path$1)) attrs = " compressed=\"true\" preprocess=\"xml-stripblanks\"";
78
- else if (/\.(png|jpg|jpeg)$/.test(path$1)) attrs = " compressed=\"true\"";
79
- else if (/\.(json)$/.test(path$1)) attrs = " preprocess=\"json-stripblanks\"";
75
+ if (/\.(svg|xml)$/.test(path)) attrs = " compressed=\"true\" preprocess=\"xml-stripblanks\"";
76
+ else if (/\.(png|jpg|jpeg)$/.test(path)) attrs = " compressed=\"true\"";
77
+ else if (/\.(json)$/.test(path)) attrs = " preprocess=\"json-stripblanks\"";
80
78
  if (alias) attrs += ` alias="${alias}"`;
81
- return ` <file${attrs}>${path$1}</file>`;
79
+ return ` <file${attrs}>${path}</file>`;
82
80
  }
83
81
  function generateGResourceXML(prefix, assets, icons) {
84
82
  const files = Array.from(assets).map(([id, { internalResourceId }]) => getFilePath(id, internalResourceId)).join("\n");
@@ -93,7 +91,6 @@ ${iconFiles}
93
91
  </gresource>` : ""}
94
92
  </gresources>`;
95
93
  }
96
-
97
94
  //#endregion
98
95
  //#region src/utilities/bundle.ts
99
96
  function addBundledResources(collectedResources, prefix, bundle = []) {
@@ -108,7 +105,6 @@ function addBundledResources(collectedResources, prefix, bundle = []) {
108
105
  });
109
106
  }
110
107
  }
111
-
112
108
  //#endregion
113
109
  //#region src/utilities/icons.ts
114
110
  async function getIconsPath(iconsPath) {
@@ -122,7 +118,6 @@ async function collectIcons(baseIconsPath, prefix) {
122
118
  if (iconsPath) collectedIcons = await loadIcons(prefix, iconsPath);
123
119
  return collectedIcons;
124
120
  }
125
-
126
121
  //#endregion
127
122
  //#region src/plugins/dev/index.ts
128
123
  /**
@@ -139,12 +134,12 @@ function resourcesPluginOverlay({ prefix, prod, outdir, setRunnerEnv, iconsPath:
139
134
  load: {
140
135
  filter: { id: prefixRegex(`${GRESOURCE_PREFIX}:`) },
141
136
  handler(id) {
142
- const [, importType, path$1] = id.split(":", 3);
143
- if (!path$1) return;
144
- const resourceId = getResourceId(prefix, path$1);
145
- collectedResources.set(path$1, {
137
+ const [, importType, path] = id.split(":", 3);
138
+ if (!path) return;
139
+ const resourceId = getResourceId(prefix, path);
140
+ collectedResources.set(path, {
146
141
  resourceId,
147
- internalResourceId: getInternalResourceId(path$1)
142
+ internalResourceId: getInternalResourceId(path)
148
143
  });
149
144
  return generateImportCode(importType, resourceId, false);
150
145
  }
@@ -171,7 +166,7 @@ function resourcesPluginOverlay({ prefix, prod, outdir, setRunnerEnv, iconsPath:
171
166
  if (!entry.isSymbolicLink()) continue;
172
167
  const fullPath = path.resolve(entry.parentPath, entry.name);
173
168
  const relativePath = path.relative(devResourcesOverlay, fullPath);
174
- if (currentPaths.has(relativePath) || relativePath === GRESOURCE_ICONS_PATH) continue;
169
+ if (currentPaths.has(relativePath) || relativePath === "icons/scalable/actions") continue;
175
170
  await fs.unlink(fullPath);
176
171
  }
177
172
  for (const [filePath, { internalResourceId }] of collectedResources) {
@@ -187,7 +182,6 @@ function resourcesPluginOverlay({ prefix, prod, outdir, setRunnerEnv, iconsPath:
187
182
  }
188
183
  };
189
184
  }
190
-
191
185
  //#endregion
192
186
  //#region src/plugins/loader.ts
193
187
  /**
@@ -215,7 +209,6 @@ function resourcesPluginLoader({ gresourcePath }) {
215
209
  }
216
210
  };
217
211
  }
218
-
219
212
  //#endregion
220
213
  //#region src/plugins/prod/index.ts
221
214
  const exec$1 = promisify(exec);
@@ -227,13 +220,13 @@ function resourcesPluginGenerateXML({ prefix, gresourceName, gresourcePath, prod
227
220
  load: {
228
221
  filter: { id: prefixRegex(`${GRESOURCE_PREFIX}:`) },
229
222
  handler(id) {
230
- const [, _importType, path$1] = id.split(":", 3);
231
- if (!path$1) return;
223
+ const [, _importType, path] = id.split(":", 3);
224
+ if (!path) return;
232
225
  const importType = _importType;
233
- const resourceId = getResourceId(prefix, path$1);
234
- collectedResources.set(path$1, {
226
+ const resourceId = getResourceId(prefix, path);
227
+ collectedResources.set(path, {
235
228
  resourceId,
236
- internalResourceId: getInternalResourceId(path$1)
229
+ internalResourceId: getInternalResourceId(path)
237
230
  });
238
231
  return generateImportCode(importType, resourceId, true);
239
232
  }
@@ -256,7 +249,6 @@ function resourcesPluginGenerateXML({ prefix, gresourceName, gresourcePath, prod
256
249
  }
257
250
  };
258
251
  }
259
-
260
252
  //#endregion
261
253
  //#region src/plugins/resolve.ts
262
254
  /**
@@ -277,7 +269,6 @@ function resourcesPluginResolve() {
277
269
  }
278
270
  };
279
271
  }
280
-
281
272
  //#endregion
282
273
  //#region src/plugins/index.ts
283
274
  function resourcesPlugin(config) {
@@ -298,6 +289,5 @@ function resourcesPlugin(config) {
298
289
  resourcesPluginGenerateXML(resourcesOptions)
299
290
  ].filter(Boolean);
300
291
  }
301
-
302
292
  //#endregion
303
- export { resourcesPlugin };
293
+ export { resourcesPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peachy/plugin-resources",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Import resources in your app",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -18,10 +18,10 @@
18
18
  }
19
19
  },
20
20
  "devDependencies": {
21
- "@types/node": "^25.0.9",
22
- "rolldown": "1.0.0-beta.60",
23
- "tsdown": "0.20.0-beta.4",
24
- "typescript": "^5.9.3",
21
+ "@types/node": "^25.5.2",
22
+ "rolldown": "1.0.0-rc.14",
23
+ "tsdown": "0.21.7",
24
+ "typescript": "^6.0.2",
25
25
  "@peachy/internal-utilities": "0.0.0"
26
26
  },
27
27
  "peerDependencies": {