@kaoruisaac/pedelec 0.3.1 → 0.3.3

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 CHANGED
@@ -225,7 +225,17 @@ console.log(status.installed, status.approved, status.origin);
225
225
 
226
226
  `getApprovalStatus()` includes `appConnected`, a non-sensitive Core `ping` result. It does not require approval or open the approval popup, but it may use the Native Host's existing Desktop auto-launch fallback. `appConnected` does not mean the origin is approved or a provider is ready.
227
227
 
228
- `getSettings()` and `listProviders()` require origin approval and may open the approval popup. Settings expose only defaults (never provider credentials); providers expose only `name`, `code`, `available`, and `error`. Use `getApprovalStatus().appConnected` rather than `listProviders()` as a connection probe.
228
+ `getSettings()` and `listProviders()` require origin approval and may open the approval popup. Settings expose only defaults (never provider credentials); providers expose only `name`, `code`, `available`, `isDefault`, and `error`. `isDefault` identifies the provider selected by the current Desktop settings and is independent of `available`; it remains true when that provider is unavailable. Use `getApprovalStatus().appConnected` rather than `listProviders()` as a connection probe.
229
+
230
+ ```ts
231
+ type ProviderInfo = {
232
+ name: string;
233
+ code: ProviderCode;
234
+ available: boolean;
235
+ isDefault: boolean;
236
+ error: string | null;
237
+ };
238
+ ```
229
239
 
230
240
  For a complete Extension, approval, and Desktop readiness probe, use `checkAvailability()`. It never creates/resumes a session or opens approval. Its status ping may attempt Desktop launch even for an unapproved origin.
231
241
 
package/dist/index.d.ts CHANGED
@@ -110,6 +110,7 @@ export type ProviderInfo = {
110
110
  name: string;
111
111
  code: ProviderCode;
112
112
  available: boolean;
113
+ isDefault: boolean;
113
114
  error: string | null;
114
115
  };
115
116
  export type PedelecSettings = {
package/dist/index.js CHANGED
@@ -160,7 +160,14 @@ export class Pedelec {
160
160
  return normalizeWorkspaceFolderPickerResponse(result);
161
161
  }
162
162
  async listProviders() {
163
- return normalizeProviderInfoList(await this.request("list_providers"));
163
+ const providers = normalizeProviderInfoList(await this.request("list_providers"));
164
+ if (hasProviderDefaultFlags(providers))
165
+ return providers;
166
+ const settings = await this.getSettings();
167
+ return providers.map((provider) => ({
168
+ ...provider,
169
+ isDefault: provider.code === settings.defaultProvider,
170
+ }));
164
171
  }
165
172
  async getSettings() {
166
173
  return normalizePedelecSettings(await this.request("get_settings"));
@@ -1396,8 +1403,7 @@ function isPlainObject(value) {
1396
1403
  return !!value && typeof value === "object" && !Array.isArray(value);
1397
1404
  }
1398
1405
  function normalizePedelecSettings(value) {
1399
- if (!isPlainObject(value) || (value.defaultProvider !== null && !isProviderCode(value.defaultProvider)) ||
1400
- "defaultModels" in value || "providerSettings" in value) {
1406
+ if (!isPlainObject(value) || (value.defaultProvider !== null && !isProviderCode(value.defaultProvider))) {
1401
1407
  throw makeError("SDK_PROTOCOL_ERROR", "get_settings response had invalid shape");
1402
1408
  }
1403
1409
  return { defaultProvider: value.defaultProvider };
@@ -1425,12 +1431,22 @@ function normalizeProviderInfoList(value) {
1425
1431
  return value.map((item) => {
1426
1432
  if (!isPlainObject(item) || typeof item.name !== "string" || item.name.length === 0 ||
1427
1433
  !isProviderCode(item.code) || typeof item.available !== "boolean" ||
1428
- (item.error !== null && typeof item.error !== "string")) {
1434
+ (item.error !== null && typeof item.error !== "string") ||
1435
+ ("isDefault" in item && typeof item.isDefault !== "boolean")) {
1429
1436
  throw makeError("SDK_PROTOCOL_ERROR", "list_providers response had invalid provider data");
1430
1437
  }
1431
- return { name: item.name, code: item.code, available: item.available, error: item.error };
1438
+ return {
1439
+ name: item.name,
1440
+ code: item.code,
1441
+ available: item.available,
1442
+ ...(typeof item.isDefault === "boolean" ? { isDefault: item.isDefault } : {}),
1443
+ error: item.error,
1444
+ };
1432
1445
  });
1433
1446
  }
1447
+ function hasProviderDefaultFlags(value) {
1448
+ return value.every((provider) => typeof provider.isDefault === "boolean");
1449
+ }
1434
1450
  function makeError(code, message, details) {
1435
1451
  return details === undefined ? { code, message } : { code, message, details };
1436
1452
  }
@@ -169,6 +169,8 @@ function publicSecurityTypesAreRestricted() {
169
169
  appConnected: true,
170
170
  };
171
171
  const provider = {};
172
+ const isDefault = provider.isDefault;
173
+ void isDefault;
172
174
  // @ts-expect-error SDK provider metadata must not expose executable paths
173
175
  provider.path;
174
176
  return status;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.3.1";
1
+ export declare const SDK_VERSION = "0.3.3";
@@ -1,2 +1,2 @@
1
1
  // Generated from sdk/package.json. Do not edit manually.
2
- export const SDK_VERSION = "0.3.1";
2
+ export const SDK_VERSION = "0.3.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaoruisaac/pedelec",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",