@ham2k/extension-tools 0.4.0 → 0.5.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/h2kext-pack.mjs CHANGED
@@ -64,6 +64,9 @@ try {
64
64
  // person installing it will be asked to approve.
65
65
  console.log(` may reach: ${result.manifest.domains.join(", ")}`)
66
66
  }
67
+ if (result.manifest.webSockets?.length) {
68
+ console.log(` may hold connections to: ${result.manifest.webSockets.join(", ")}`)
69
+ }
67
70
  } catch (e) {
68
71
  if (e instanceof PackError) {
69
72
  console.error(`h2kext-pack: ${dir} is not ready to package:\n${e.message}`)
package/h2kext.mjs CHANGED
@@ -25,7 +25,16 @@ import yazl from "yazl"
25
25
  /// The extension API this format describes. A bundle declares the version it
26
26
  /// was built against and the host refuses one it does not speak, so an old app
27
27
  /// meeting a newer bundle says so instead of failing at a call site.
28
- export const H2KEXT_API_VERSION = 1
28
+ ///
29
+ /// Raised when a bundle using something new could not work at all on an app
30
+ /// without it — not for every addition. 2 adds `host.webSocket` and the
31
+ /// manifest's `webSockets` grant.
32
+ export const H2KEXT_API_VERSION = 2
33
+
34
+ /// The first API with `host.webSocket`. A manifest declaring `webSockets`
35
+ /// under an older one is refused: an older app would install it and fail only
36
+ /// when it tried to connect.
37
+ export const WEB_SOCKETS_API_VERSION = 2
29
38
 
30
39
  /// `<prefix>-<name>`, all lowercase. The shape is what the kernel's
31
40
  /// `bundleMayDefine` prefix rule can reason about; the PREFIX is what keeps two
@@ -117,6 +126,7 @@ export const SHARED_MODULES_BY_API = {
117
126
  "liquidjs",
118
127
  ],
119
128
  }
129
+ SHARED_MODULES_BY_API[2] = SHARED_MODULES_BY_API[1]
120
130
 
121
131
  /// What a scaffolded extension declares on day one: the eight modules the SDK
122
132
  /// barrel itself reaches, so a project that has written no code yet still
@@ -273,6 +283,14 @@ export function validateManifest(manifest, { source = MANIFEST_ENTRY, forceName
273
283
  say(`'api' is ${manifest.api}, but this packer only knows ${H2KEXT_API_VERSION}`)
274
284
  }
275
285
 
286
+ if (manifest.webSockets !== undefined) {
287
+ if (!Array.isArray(manifest.webSockets) || manifest.webSockets.some((host) => typeof host !== "string")) {
288
+ say("'webSockets' must be a list of hosts")
289
+ } else if (manifest.webSockets.length && Number.isInteger(manifest.api) && manifest.api < WEB_SOCKETS_API_VERSION) {
290
+ say(`'webSockets' needs 'api' ${WEB_SOCKETS_API_VERSION} or later — an app older than that would install this and fail only when it connects`)
291
+ }
292
+ }
293
+
276
294
  // An extension with no category is CORE to the host: always enabled, and
277
295
  // never listed in the Extensions panel. That is a status the app grants its
278
296
  // own extensions, not one a distributed bundle may claim for itself — a user
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ham2k/extension-tools",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Build and package extensions for the Ham2K Logger",
5
5
  "keywords": [
6
6
  "ham2k",