@caplets/pi 0.3.0 → 0.4.0
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/README.md +16 -8
- package/dist/index.js +33 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -40,9 +40,10 @@ By default the extension uses the local Caplets native service. To connect Pi to
|
|
|
40
40
|
especially the password:
|
|
41
41
|
|
|
42
42
|
```sh
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
43
|
+
export CAPLETS_MODE="remote"
|
|
44
|
+
export CAPLETS_SERVER_URL="https://caplets.example.com/caplets"
|
|
45
|
+
export CAPLETS_SERVER_USER="caplets"
|
|
46
|
+
export CAPLETS_SERVER_PASSWORD="..." # or load from your shell/secret manager
|
|
46
47
|
```
|
|
47
48
|
|
|
48
49
|
Pi currently calls extension factories with the Pi API only, so this extension reads its remote
|
|
@@ -54,10 +55,13 @@ options are supplied:
|
|
|
54
55
|
"packages": ["npm:@caplets/pi"],
|
|
55
56
|
"caplets": {
|
|
56
57
|
"mode": "remote",
|
|
57
|
-
"
|
|
58
|
-
"url": "https://caplets.example.com/
|
|
58
|
+
"server": {
|
|
59
|
+
"url": "https://caplets.example.com/caplets",
|
|
59
60
|
"user": "caplets"
|
|
60
61
|
},
|
|
62
|
+
"remote": {
|
|
63
|
+
"pollIntervalMs": 5000
|
|
64
|
+
},
|
|
61
65
|
"statusWidget": true,
|
|
62
66
|
"nerdFontIcons": true
|
|
63
67
|
}
|
|
@@ -79,13 +83,17 @@ import { createCapletsPiExtension } from "@caplets/pi";
|
|
|
79
83
|
export default createCapletsPiExtension({
|
|
80
84
|
args: {
|
|
81
85
|
mode: "remote",
|
|
82
|
-
|
|
83
|
-
url: "https://caplets.example.com/
|
|
86
|
+
server: {
|
|
87
|
+
url: "https://caplets.example.com/caplets",
|
|
84
88
|
user: "caplets",
|
|
85
89
|
},
|
|
90
|
+
remote: {
|
|
91
|
+
pollIntervalMs: 5_000,
|
|
92
|
+
},
|
|
86
93
|
},
|
|
87
94
|
});
|
|
88
95
|
```
|
|
89
96
|
|
|
90
|
-
|
|
97
|
+
The explicit config shape is `{ mode, server: { url, user }, remote: { pollIntervalMs } }`.
|
|
98
|
+
Prefer environment variables for `CAPLETS_SERVER_PASSWORD` rather than storing passwords in
|
|
91
99
|
settings files or source code.
|
package/dist/index.js
CHANGED
|
@@ -3453,7 +3453,7 @@ function topLevelCapletsOptions(settings, writeWarning, path) {
|
|
|
3453
3453
|
]) {
|
|
3454
3454
|
const value = objectProperty(settings, key);
|
|
3455
3455
|
if (!value) continue;
|
|
3456
|
-
const parsed = parsePiNativeOptions(objectProperty(value, "native") ?? objectProperty(value, "args") ?? value);
|
|
3456
|
+
const parsed = parsePiNativeOptions(objectProperty(value, "native") ?? objectProperty(value, "args") ?? value, writeWarning, `${path}.${key}`);
|
|
3457
3457
|
if (!parsed) {
|
|
3458
3458
|
writeWarning(`[caplets/pi] Ignoring Pi settings args: invalid ${path}.${key} shape`);
|
|
3459
3459
|
return {};
|
|
@@ -3461,7 +3461,7 @@ function topLevelCapletsOptions(settings, writeWarning, path) {
|
|
|
3461
3461
|
return parsed;
|
|
3462
3462
|
}
|
|
3463
3463
|
}
|
|
3464
|
-
function parsePiNativeOptions(value) {
|
|
3464
|
+
function parsePiNativeOptions(value, writeWarning, path = "settings.caplets") {
|
|
3465
3465
|
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
3466
3466
|
const result = {};
|
|
3467
3467
|
const mode = value.mode;
|
|
@@ -3482,17 +3482,6 @@ function parsePiNativeOptions(value) {
|
|
|
3482
3482
|
const remote = objectProperty(value, "remote");
|
|
3483
3483
|
if (remote) {
|
|
3484
3484
|
const parsedRemote = {};
|
|
3485
|
-
for (const key of [
|
|
3486
|
-
"url",
|
|
3487
|
-
"user",
|
|
3488
|
-
"password"
|
|
3489
|
-
]) {
|
|
3490
|
-
const field = remote[key];
|
|
3491
|
-
if (field !== void 0) {
|
|
3492
|
-
if (typeof field !== "string") return void 0;
|
|
3493
|
-
parsedRemote[key] = field;
|
|
3494
|
-
}
|
|
3495
|
-
}
|
|
3496
3485
|
const pollIntervalMs = remote.pollIntervalMs;
|
|
3497
3486
|
if (pollIntervalMs !== void 0) {
|
|
3498
3487
|
if (typeof pollIntervalMs !== "number" || !Number.isFinite(pollIntervalMs)) return void 0;
|
|
@@ -3500,8 +3489,37 @@ function parsePiNativeOptions(value) {
|
|
|
3500
3489
|
}
|
|
3501
3490
|
result.remote = parsedRemote;
|
|
3502
3491
|
}
|
|
3492
|
+
const server = objectProperty(value, "server");
|
|
3493
|
+
const parsedServer = parsePiServerOptions(server);
|
|
3494
|
+
if (parsedServer === void 0 && server) return;
|
|
3495
|
+
const legacyServer = parsePiServerOptions(remote);
|
|
3496
|
+
if (legacyServer === void 0 && remote && hasLegacyRemoteServerFields(remote)) return;
|
|
3497
|
+
if (legacyServer && !parsedServer) writeWarning?.(`[caplets/pi] ${path}.remote.url is deprecated; move remote.url/user/password to server.url/user/password.`);
|
|
3498
|
+
if (legacyServer || parsedServer) result.server = {
|
|
3499
|
+
...legacyServer,
|
|
3500
|
+
...parsedServer
|
|
3501
|
+
};
|
|
3503
3502
|
return result;
|
|
3504
3503
|
}
|
|
3504
|
+
function parsePiServerOptions(value) {
|
|
3505
|
+
if (!value) return;
|
|
3506
|
+
const parsedServer = {};
|
|
3507
|
+
for (const key of [
|
|
3508
|
+
"url",
|
|
3509
|
+
"user",
|
|
3510
|
+
"password"
|
|
3511
|
+
]) {
|
|
3512
|
+
const field = value[key];
|
|
3513
|
+
if (field !== void 0) {
|
|
3514
|
+
if (typeof field !== "string") return void 0;
|
|
3515
|
+
parsedServer[key] = field;
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
return Object.keys(parsedServer).length > 0 ? parsedServer : void 0;
|
|
3519
|
+
}
|
|
3520
|
+
function hasLegacyRemoteServerFields(remote) {
|
|
3521
|
+
return remote.url !== void 0 || remote.user !== void 0 || remote.password !== void 0;
|
|
3522
|
+
}
|
|
3505
3523
|
function capletsRemoteStatusText(status, nerdFontIcons) {
|
|
3506
3524
|
if (nerdFontIcons) return status === "connected" ? " caplets ✓" : " caplets ×";
|
|
3507
3525
|
return status === "connected" ? "caplets ✓" : "caplets ×";
|
|
@@ -3509,12 +3527,13 @@ function capletsRemoteStatusText(status, nerdFontIcons) {
|
|
|
3509
3527
|
function nativeServiceOptions(options) {
|
|
3510
3528
|
return {
|
|
3511
3529
|
...options.mode ? { mode: options.mode } : {},
|
|
3530
|
+
...options.server ? { server: options.server } : {},
|
|
3512
3531
|
...options.remote ? { remote: options.remote } : {}
|
|
3513
3532
|
};
|
|
3514
3533
|
}
|
|
3515
3534
|
function shouldShowStatusWidget(options, statusWidget) {
|
|
3516
3535
|
if (statusWidget === false) return false;
|
|
3517
|
-
return options.mode === "remote" || !!options.
|
|
3536
|
+
return options.mode === "remote" || !!options.server?.url || process.env.CAPLETS_SERVER_URL !== void 0;
|
|
3518
3537
|
}
|
|
3519
3538
|
async function readFileUtf8(path) {
|
|
3520
3539
|
return readFile(path, "utf8");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caplets/pi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Native Pi extension for Caplets.",
|
|
5
5
|
"homepage": "https://github.com/spiritledsoftware/caplets#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@caplets/core": "0.
|
|
29
|
+
"@caplets/core": "0.17.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^25.9.0",
|