@howaboua/pi-pet 0.1.4 → 0.1.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @howaboua/pi-pet
2
2
 
3
+ ## 0.1.6
4
+
5
+ - Desktop attachment now uses Electron 44 and requires macOS 13 or newer, or a supported 64-bit Windows or Linux desktop. Linux ARMv7, 32-bit Windows and Linux Unity are no longer supported. The browser miniapp is unchanged.
6
+
7
+ ## 0.1.5
8
+
9
+ - Pi Pet desktop now requires Node 22.12 or newer.
10
+
3
11
  ## 0.1.4
4
12
 
5
13
  - Remove obsolete test-only helper exports without changing tool behavior.
package/README.md CHANGED
@@ -29,6 +29,8 @@ Electron is optional. With no attached device, Pi Pet still publishes its versio
29
29
 
30
30
  The Electron shell loads the same GipPity-hosted app in a transparent, frameless, always-on-top window. It adds local cursor tracking, size, quiet mode, and snooze without another agent runtime or remote protocol.
31
31
 
32
+ The desktop shell uses Electron 44. It requires macOS 13 or newer, or a supported 64-bit Windows or Linux desktop. Linux ARMv7, 32-bit Windows and Linux Unity are no longer supported. The browser miniapp does not require Electron.
33
+
32
34
  Attach the device running Pi directly:
33
35
 
34
36
  ```text
@@ -41,7 +43,7 @@ For another device, give it an SSH alias and confirm key-based access once outsi
41
43
  ssh desktop true
42
44
  ```
43
45
 
44
- The remote device needs npm and Node 22 or newer; runtime extraction uses PowerShell on Windows and standard `unzip` on macOS/Linux. Attach it from Pi:
46
+ The remote device needs npm and Node 22.12 or newer; runtime extraction uses PowerShell on Windows and standard `unzip` on macOS/Linux. Attach it from Pi:
45
47
 
46
48
  ```text
47
49
  /pet attach desktop
package/desktop/build.mjs CHANGED
@@ -9,7 +9,6 @@ import { dirname, join } from "node:path";
9
9
  import { Transform } from "node:stream";
10
10
  import { pipeline } from "node:stream/promises";
11
11
  import { fileURLToPath } from "node:url";
12
- import ts from "typescript";
13
12
 
14
13
  const desktop = dirname(fileURLToPath(import.meta.url));
15
14
  const source = join(desktop, "..", "src", "desktop");
@@ -17,6 +16,7 @@ const output = join(desktop, "dist", "app");
17
16
  const esmFiles = ["attention", "bridge", "config", "cursor-provider", "main"];
18
17
  const cjsFiles = ["bridge", "preload"];
19
18
  const require = createRequire(join(desktop, "package.json"));
19
+ const compiler = join(dirname(require.resolve("typescript/package.json")), require("typescript/package.json").bin.tsc);
20
20
  const MAX_ARCHIVE_BYTES = 1024 * 1024 * 1024;
21
21
  const LEADING_V_PATTERN = /^v/;
22
22
 
@@ -152,42 +152,49 @@ async function downloadArchive(artifact, path, expectedChecksum, version) {
152
152
  }
153
153
  }
154
154
 
155
- function transpile(code, file, module) {
156
- const result = ts.transpileModule(code, {
157
- fileName: file,
158
- compilerOptions: {
159
- target: ts.ScriptTarget.ES2024,
160
- module,
161
- rewriteRelativeImportExtensions: true,
162
- verbatimModuleSyntax: true,
163
- },
164
- reportDiagnostics: true,
165
- });
166
- const errors = (result.diagnostics || []).filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);
167
- if (errors.length > 0) {
168
- throw new Error(
169
- errors.map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")).join("\n"),
155
+ function compile(files, module, destination) {
156
+ return new Promise((resolvePromise, reject) => {
157
+ const child = spawn(
158
+ process.execPath,
159
+ [
160
+ compiler,
161
+ "--ignoreConfig",
162
+ "--noCheck",
163
+ "--noResolve",
164
+ "--target",
165
+ "es2024",
166
+ "--module",
167
+ module,
168
+ "--rewriteRelativeImportExtensions",
169
+ "--outDir",
170
+ destination,
171
+ ...files.map((name) => join(source, `${name}.ts`)),
172
+ ],
173
+ { stdio: "inherit", windowsHide: true },
170
174
  );
171
- }
172
- return result.outputText;
175
+ child.once("error", reject);
176
+ child.once("exit", (code) => {
177
+ if (code === 0) resolvePromise();
178
+ else reject(new Error(`Desktop compilation exited ${code ?? "without status"}.`));
179
+ });
180
+ });
173
181
  }
174
182
 
175
183
  await ensureElectronRuntime();
176
184
  await rm(join(desktop, "dist"), { recursive: true, force: true });
177
185
  await mkdir(output, { recursive: true });
178
186
 
179
- for (const name of esmFiles) {
180
- const path = join(source, `${name}.ts`);
181
- await writeFile(join(output, `${name}.js`), transpile(await readFile(path, "utf8"), path, ts.ModuleKind.ESNext));
182
- }
187
+ await compile(esmFiles, "esnext", output);
188
+ const cjsOutput = join(desktop, "dist", "preload");
189
+ await compile(cjsFiles, "commonjs", cjsOutput);
183
190
  for (const name of cjsFiles) {
184
- const path = join(source, `${name}.ts`);
185
- const compiled = transpile(await readFile(path, "utf8"), path, ts.ModuleKind.CommonJS).replaceAll(
191
+ const compiled = (await readFile(join(cjsOutput, `${name}.js`), "utf8")).replaceAll(
186
192
  /require\("(\.\/.+)\.js"\)/g,
187
193
  'require("$1.cjs")',
188
194
  );
189
195
  await writeFile(join(output, `${name}.cjs`), compiled);
190
196
  }
197
+ await rm(cjsOutput, { recursive: true });
191
198
  await writeFile(
192
199
  join(output, "package.json"),
193
200
  `${JSON.stringify({ name: "pi-pet-remote-desktop", private: true, type: "module", main: "main.js" }, null, 2)}\n`,