automify 0.1.3 → 0.1.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automify",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "AI computer use for browser, CLI, and desktop in Node.js.",
5
5
  "homepage": "https://aldovincenti.github.io/automify",
6
6
  "bugs": {
@@ -66,10 +66,13 @@ patchPlatformLibnutDependency();
66
66
 
67
67
  runPnpm(["install"], { cwd: nutSource });
68
68
  runPnpm(["--filter", "@nut-tree/shared", "run", "compile"], { cwd: nutSource });
69
+ patchNutJimpCompatibility();
69
70
  runPnpm(["--filter", "@nut-tree/provider-interfaces", "run", "compile"], { cwd: nutSource });
70
71
  runPnpm(["--filter", "@nut-tree/default-clipboard-provider", "run", "compile"], { cwd: nutSource });
71
72
  runPnpm(["--filter", "@nut-tree/libnut", "run", "compile"], { cwd: nutSource });
73
+ writeLibnutImportBridge();
72
74
  runPnpm(["--filter", "@nut-tree/nut-js", "run", "compile"], { cwd: nutSource });
75
+ patchNutJimpCompatibility();
73
76
 
74
77
  run("npm", ["install", "--no-save", ...runtimeDependencies], { cwd: root });
75
78
 
@@ -225,6 +228,101 @@ function patchNutWorkspace() {
225
228
  }
226
229
  }
227
230
 
231
+ function writeLibnutImportBridge() {
232
+ const distDir = join(nutSource, "providers", "libnut", "dist");
233
+ mkdirSync(distDir, { recursive: true });
234
+ writeText(
235
+ join(distDir, "import_libnut.js"),
236
+ `"use strict";
237
+ Object.defineProperty(exports, "__esModule", { value: true });
238
+ exports.libnut = void 0;
239
+ exports.libnut = process.platform === "win32"
240
+ ? require("@nut-tree/libnut-win32")
241
+ : process.platform === "linux"
242
+ ? require("@nut-tree/libnut-linux")
243
+ : require("@nut-tree/libnut-darwin");
244
+ `
245
+ );
246
+ writeText(
247
+ join(distDir, "import_libnut.d.ts"),
248
+ `import ln from "./libnut";
249
+ declare const libnut: typeof ln;
250
+ export { libnut };
251
+ `
252
+ );
253
+ }
254
+
255
+ function patchNutJimpCompatibility() {
256
+ const sharedImageToJimpPath = join(
257
+ nutSource,
258
+ "core",
259
+ "shared",
260
+ "dist",
261
+ "lib",
262
+ "functions",
263
+ "imageToJimp.function.js"
264
+ );
265
+ if (existsSync(sharedImageToJimpPath)) {
266
+ writeText(
267
+ sharedImageToJimpPath,
268
+ `"use strict";
269
+ Object.defineProperty(exports, "__esModule", { value: true });
270
+ exports.imageToJimp = void 0;
271
+ const jimp_1 = require("jimp");
272
+ const colormode_enum_1 = require("../enums/colormode.enum");
273
+ function imageToJimp(image) {
274
+ const jimpImage = new jimp_1.Jimp({
275
+ data: image.data,
276
+ width: image.width,
277
+ height: image.height
278
+ });
279
+ if (image.colorMode === colormode_enum_1.ColorMode.BGR) {
280
+ jimpImage.scan(0, 0, jimpImage.bitmap.width, jimpImage.bitmap.height, function (_, __, idx) {
281
+ const red = this.bitmap.data[idx];
282
+ this.bitmap.data[idx] = this.bitmap.data[idx + 2];
283
+ this.bitmap.data[idx + 2] = red;
284
+ });
285
+ }
286
+ return jimpImage;
287
+ }
288
+ exports.imageToJimp = imageToJimp;
289
+ `
290
+ );
291
+ }
292
+
293
+ const jimpImageWriterPath = join(
294
+ nutSource,
295
+ "core",
296
+ "nut.js",
297
+ "dist",
298
+ "lib",
299
+ "provider",
300
+ "io",
301
+ "jimp-image-writer.class.js"
302
+ );
303
+ if (existsSync(jimpImageWriterPath)) {
304
+ writeText(
305
+ jimpImageWriterPath,
306
+ `"use strict";
307
+ Object.defineProperty(exports, "__esModule", { value: true });
308
+ const shared_1 = require("@nut-tree/shared");
309
+ class default_1 {
310
+ store(parameters) {
311
+ return new Promise((resolve, reject) => {
312
+ const jimpImage = (0, shared_1.imageToJimp)(parameters.image);
313
+ jimpImage
314
+ .write(parameters.path)
315
+ .then((_) => resolve())
316
+ .catch((err) => reject(err));
317
+ });
318
+ }
319
+ }
320
+ exports.default = default_1;
321
+ `
322
+ );
323
+ }
324
+ }
325
+
228
326
  function installWorkspacePackage(source, target) {
229
327
  rmSync(target, { recursive: true, force: true });
230
328
  mkdirSync(dirname(target), { recursive: true });