@wickermoney/plugin-sdk 0.5.0 → 0.6.0-rc.1

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.
Files changed (83) hide show
  1. package/README.md +166 -29
  2. package/dist/{recurrence → date}/calendar.d.ts +1 -1
  3. package/dist/date/calendar.d.ts.map +1 -0
  4. package/dist/{recurrence → date}/calendar.js +1 -1
  5. package/dist/date/calendar.js.map +1 -0
  6. package/dist/date/index.d.ts +17 -0
  7. package/dist/date/index.d.ts.map +1 -0
  8. package/dist/date/index.js +17 -0
  9. package/dist/date/index.js.map +1 -0
  10. package/dist/index.d.ts +7 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +7 -3
  13. package/dist/index.js.map +1 -1
  14. package/dist/isolated/PluginApiError.d.ts +20 -0
  15. package/dist/isolated/PluginApiError.d.ts.map +1 -0
  16. package/dist/isolated/PluginApiError.js +25 -0
  17. package/dist/isolated/PluginApiError.js.map +1 -0
  18. package/dist/isolated/client.d.ts +118 -0
  19. package/dist/isolated/client.d.ts.map +1 -0
  20. package/dist/isolated/client.js +275 -0
  21. package/dist/isolated/client.js.map +1 -0
  22. package/dist/isolated/format.d.ts +25 -0
  23. package/dist/isolated/format.d.ts.map +1 -0
  24. package/dist/isolated/format.js +59 -0
  25. package/dist/isolated/format.js.map +1 -0
  26. package/dist/isolated/index.d.ts +48 -0
  27. package/dist/isolated/index.d.ts.map +1 -0
  28. package/dist/isolated/index.js +45 -0
  29. package/dist/isolated/index.js.map +1 -0
  30. package/dist/isolated/protocol.d.ts +217 -0
  31. package/dist/isolated/protocol.d.ts.map +1 -0
  32. package/dist/isolated/protocol.js +31 -0
  33. package/dist/isolated/protocol.js.map +1 -0
  34. package/dist/isolated/theme.d.ts +24 -0
  35. package/dist/isolated/theme.d.ts.map +1 -0
  36. package/dist/isolated/theme.js +32 -0
  37. package/dist/isolated/theme.js.map +1 -0
  38. package/dist/isolated/validate.d.ts +47 -0
  39. package/dist/isolated/validate.d.ts.map +1 -0
  40. package/dist/isolated/validate.js +260 -0
  41. package/dist/isolated/validate.js.map +1 -0
  42. package/dist/manifest/PERMISSIONS.d.ts +4 -2
  43. package/dist/manifest/PERMISSIONS.d.ts.map +1 -1
  44. package/dist/manifest/PERMISSIONS.js +4 -2
  45. package/dist/manifest/PERMISSIONS.js.map +1 -1
  46. package/dist/manifest/checkRemoteEntryIntegrity.d.ts +27 -0
  47. package/dist/manifest/checkRemoteEntryIntegrity.d.ts.map +1 -0
  48. package/dist/manifest/checkRemoteEntryIntegrity.js +47 -0
  49. package/dist/manifest/checkRemoteEntryIntegrity.js.map +1 -0
  50. package/dist/manifest/index.d.ts +2 -5
  51. package/dist/manifest/index.d.ts.map +1 -1
  52. package/dist/manifest/index.js +2 -5
  53. package/dist/manifest/index.js.map +1 -1
  54. package/dist/manifest/integritySchema.d.ts +28 -0
  55. package/dist/manifest/integritySchema.d.ts.map +1 -0
  56. package/dist/manifest/integritySchema.js +30 -0
  57. package/dist/manifest/integritySchema.js.map +1 -0
  58. package/dist/manifest/parseIntegrity.d.ts +14 -0
  59. package/dist/manifest/parseIntegrity.d.ts.map +1 -0
  60. package/dist/manifest/parseIntegrity.js +16 -0
  61. package/dist/manifest/parseIntegrity.js.map +1 -0
  62. package/dist/manifest/pluginManifestSchema.d.ts +2 -0
  63. package/dist/manifest/pluginManifestSchema.d.ts.map +1 -1
  64. package/dist/manifest/pluginManifestSchema.js +36 -0
  65. package/dist/manifest/pluginManifestSchema.js.map +1 -1
  66. package/dist/recurrence/index.d.ts +1 -1
  67. package/dist/recurrence/index.d.ts.map +1 -1
  68. package/dist/recurrence/index.js +3 -1
  69. package/dist/recurrence/index.js.map +1 -1
  70. package/dist/recurrence/projection.js +1 -1
  71. package/dist/recurrence/projection.js.map +1 -1
  72. package/dist/recurrence/schedule.js +1 -1
  73. package/dist/recurrence/schedule.js.map +1 -1
  74. package/dist/recurrence/scheduled.js +1 -1
  75. package/dist/recurrence/scheduled.js.map +1 -1
  76. package/dist/runtime.d.ts +4 -0
  77. package/dist/runtime.d.ts.map +1 -1
  78. package/dist/runtime.js.map +1 -1
  79. package/dist/server/RegisterRoute.d.ts +5 -0
  80. package/dist/server/RegisterRoute.d.ts.map +1 -1
  81. package/package.json +9 -1
  82. package/dist/recurrence/calendar.d.ts.map +0 -1
  83. package/dist/recurrence/calendar.js.map +0 -1
package/README.md CHANGED
@@ -28,15 +28,18 @@ plugin as a Module Federation singleton.
28
28
  | Import | Use it for | Contents |
29
29
  |---|---|---|
30
30
  | `@wickermoney/plugin-sdk/runtime` | Plugin UI code (browser) | Types for the React components a plugin exports (`PluginWidgetProps`, `PluginPageProps`, `PluginContext`, ...), and `adoptPluginStyles` |
31
+ | `@wickermoney/plugin-sdk/isolated` | Plugin UI code that runs in a sandboxed frame (browser), and the host's broker | The message protocol between a plugin frame and the host, validators for it, and the in-frame client: `connectToHost`, `PluginApiError`, `applyHostTheme`. Experimental |
32
+ | `@wickermoney/plugin-sdk/date` | Anything (browser or Node) | Calendar-date arithmetic on `YYYY-MM-DD` strings: `addDays` and `addMonths` |
31
33
  | `@wickermoney/plugin-sdk/recurrence` | Anything (browser or Node) | Recurring-item date maths and projections: `occurrences`, `nextOccurrence`, `scheduledOccurrences`, `nextScheduledOccurrence`, `nextPayday`, `monthlyEquivalent`, `dailyBalances`, `flowTotals`, the calendar helpers `addDays` and `addMonths`, with per-occurrence overrides (skip, move, change the legs) |
32
34
  | `@wickermoney/plugin-sdk/money` | Anything (browser or Node) | Exact money arithmetic on decimal strings: `addMoney`, `sumMoney`, `compareMoney`, `equalMoney`, `moneyToUnits`, `divideUnits`, ... |
33
35
  | `@wickermoney/plugin-sdk/server` | Bundled plugins' server code, and the host (Node) | The server-side contract: `RouteContext`, `RegisterRoute`, `Query`, `RunAsPlugin`, `PluginRouteError`, `isUuid`, and the category-rule types `RuleForMatching` and `RuleSubject` |
34
- | `@wickermoney/plugin-sdk` | Hosts, tooling, tests (Node) | Everything above, plus the Zod manifest schemas, `parseManifest`, dashboard-range helpers and constants |
36
+ | `@wickermoney/plugin-sdk` | Hosts, tooling, tests (Node) | Everything above, plus `parseManifest` and the manifest types, dashboard-range helpers and constants |
35
37
 
36
38
  Import from `/runtime` (and `/money` or `/recurrence` if you need them) in plugin UI code,
37
39
  and from `/server` in a bundled plugin's server code.
38
- The package root re-exports the Zod manifest schemas, which add about 85 kB to
39
- a plugin bundle that never uses them.
40
+ The package root includes `parseManifest`, which is built on Zod, so importing the
41
+ root adds about 85 kB to a plugin bundle that never uses it. The Zod schemas
42
+ themselves are not exported; validate a manifest with `parseManifest`.
40
43
 
41
44
  ## Stability
42
45
 
@@ -45,13 +48,16 @@ module documentation (`@stable` or `@experimental`).
45
48
 
46
49
  | Import | Tier | What it is for | Who uses it today |
47
50
  |---|---|---|---|
48
- | `@wickermoney/plugin-sdk` (root: manifest, dashboard range) | stable | Manifest schema and `parseManifest`, `SDK_MAJOR_VERSION`, remote-entry checks, and the dashboard range helpers | The API and the web app (manifest, range); the Insights and Spending Trends plugins (`monthsInRange`); several plugins import the `PluginContext` and props types from here |
49
- | `@wickermoney/plugin-sdk/runtime` | stable | The props and context the host hands a plugin's React components, plus `adoptPluginStyles` | The web app and all six bundled UI plugins |
51
+ | `@wickermoney/plugin-sdk` (root: manifest, dashboard range) | stable | `parseManifest` and the manifest types, `SDK_MAJOR_VERSION`, remote-entry checks, and the dashboard range helpers | The API and the web app (manifest, range); the Insights and Spending Trends plugins (`monthsInRange`); several plugins import the `PluginContext` and props types from here |
52
+ | `@wickermoney/plugin-sdk/runtime` | stable | The props and context the host hands a plugin's React components, plus `adoptPluginStyles` | The web app and all seven bundled UI plugins |
50
53
  | `@wickermoney/plugin-sdk/money` | stable | Exact money arithmetic on decimal strings | The web app, the Budgets, Insights and Spending Trends plugins, and the API's tests |
51
54
  | `@wickermoney/plugin-sdk/server` | stable | The server-side contract between the host and a bundled plugin's `register` function | The API, Budgets and Import CSV |
52
- | `@wickermoney/plugin-sdk/recurrence` | experimental | Recurring-item date maths and projections, and the `addDays` and `addMonths` calendar helpers | The API and the web app; Budgets uses `addDays`. No plugin uses the projections yet |
55
+ | `@wickermoney/plugin-sdk/date` | stable | The `addDays` and `addMonths` calendar helpers | The API, the web app and Budgets |
56
+ | `@wickermoney/plugin-sdk/isolated` | experimental | The runtime contract for UI plugins that run in a sandboxed frame: protocol, validators, in-frame client. Stays experimental until the isolation work has shipped and settled | The web app's frame host and broker. The Insights and Spending Trends plugins run in a frame but are written against `/runtime`, unchanged |
57
+ | `@wickermoney/plugin-sdk/recurrence` | experimental | Recurring-item date maths and projections. It still re-exports `addDays` and `addMonths` so older imports work; import them from `/date` | The API and the web app. No plugin uses the projections yet |
53
58
 
54
- The root also re-exports the `/recurrence`, `/money` and `/server` exports. An
59
+ The root also re-exports the `/date`, `/recurrence`, `/money` and `/server` exports. It does
60
+ not re-export `/isolated`: a frame has no use for the Zod manifest code the root carries. An
55
61
  export keeps the tier of the entry point it comes from, however it is
56
62
  imported, so `occurrences` is experimental even when imported from the root.
57
63
 
@@ -116,7 +122,7 @@ involved. `addMonths` clamps to the end of a short month, and each call clamps
116
122
  on its own, so add the total to the original date rather than stepping.
117
123
 
118
124
  ```ts
119
- import { addDays, addMonths } from '@wickermoney/plugin-sdk/recurrence'
125
+ import { addDays, addMonths } from '@wickermoney/plugin-sdk/date'
120
126
 
121
127
  addDays('2026-12-31', 1) // '2027-01-01'
122
128
  addMonths('2026-08-31', 6) // '2027-02-28' ('2028-02-29' in a leap year)
@@ -202,8 +208,9 @@ Each bundled plugin's server code runs under its own database role, which is
202
208
  granted exactly the tables its manifest lists. A query against any other table
203
209
  is refused.
204
210
 
205
- It is **not** enforced against your plugin's UI code. See
206
- [Trust model](#trust-model) below.
211
+ For your plugin's UI code, the broker and the server hold a plugin that runs in a
212
+ frame to these grants; a plugin that still runs in the app's own page is not held
213
+ to them. See [Trust model](#trust-model).
207
214
 
208
215
  ### Widget
209
216
 
@@ -223,6 +230,65 @@ export default function RunwayWidget({ ctx, size, range }: PluginWidgetProps) {
223
230
  Money crosses the contract as a **decimal string**, never a JavaScript
224
231
  `number`. Use `ctx.formatMoney` to display it.
225
232
 
233
+ ## Isolated runtime (experimental)
234
+
235
+ `/runtime` hands a plugin a `PluginContext`, an object of functions. A function cannot
236
+ cross the boundary of a sandboxed frame, so a plugin that runs in one uses
237
+ `/isolated` instead: a small message protocol over a `MessagePort`, and a client that
238
+ rebuilds the same `PluginContext` inside the frame. A component written against
239
+ `PluginWidgetProps` or `PluginPageProps` runs in either place.
240
+
241
+ ```ts
242
+ import { connectToHost } from '@wickermoney/plugin-sdk/isolated'
243
+
244
+ const host = await connectToHost() // hello, port, init; applies the host's theme
245
+ host.observeSize(document.body) // the host sets the frame height from this
246
+ render(<Widget ctx={host.ctx} size={host.getState().size!} />)
247
+
248
+ host.subscribe((change) => { /* theme, locale, props, route, focus-in */ })
249
+ ```
250
+
251
+ A manifest marks a plugin as built for this runtime with `isolated: true`. That is a
252
+ declaration of what the plugin was built for, not a grant: it can only move a plugin
253
+ towards isolation, and the host decides which runtime a plugin gets. A plugin the
254
+ image did not ship always gets the frame, whatever the flag says. The flag is
255
+ optional, and an existing manifest without it loads exactly as before.
256
+
257
+ Protocol version 1. After a one-time window handshake (the frame says `wm.hello`; the
258
+ host answers `wm.connect` with a transferred port, or `wm.refuse`), everything travels
259
+ on the port:
260
+
261
+ | Direction | Message | Purpose |
262
+ |---|---|---|
263
+ | frame to host | `ready` | The port is live; the host answers `init` |
264
+ | frame to host | `request` / `cancel` | `GET`, `POST`, `PUT` or `DELETE` of a path relative to the API root, with an optional `cache` mode; `cancel` for an aborted call |
265
+ | frame to host | `navigate` | Go to an in-app path |
266
+ | frame to host | `resize` | The content height in CSS pixels; the host owns the width |
267
+ | frame to host | `focus-out` | Focus left past the last (`next`) or before the first (`previous`) element |
268
+ | frame to host | `notify` | Reserved; a host answers `not_supported` until the `notify` permission exists |
269
+ | host to frame | `init` | Plugin id, widget or page, session, locale, theme, size and range, first path |
270
+ | host to frame | `response` | The JSON value, or an error: `code`, `message`, optional `status` and `issues` |
271
+ | host to frame | `theme`, `locale`, `props`, `route` | Updates after `init` |
272
+ | host to frame | `focus-in` | Move focus to the frame's first or last focusable element |
273
+
274
+ What differs from the in-realm `ctx.api`:
275
+
276
+ - `RequestInit` is narrowed to `signal` and `cache`. Headers and credentials are the
277
+ host's to set; any other option is refused with `invalid_request` rather than
278
+ silently dropped.
279
+ - A failed call rejects with `PluginApiError`, which has the same `status`, `code` and
280
+ `issues` as the host's own `ApiError` (`status` is `0` when there was no HTTP response),
281
+ so `formErrorsFrom` and existing `catch` blocks work unchanged. An aborted call has
282
+ `name === 'AbortError'`.
283
+ - There is no `localStorage`, cookie or network of its own in the frame. A widget frame
284
+ clips overlays, so a widget that needs a dialog should `navigate` to its page, whose
285
+ frame is full height. Protocol 1 has no host-rendered dialog.
286
+
287
+ The host must run `parsePluginMessage` on every message a frame sends and identify the
288
+ frame by the `MessagePort` and `event.source`, never by `event.origin` (which is
289
+ `"null"` for a sandboxed frame). Unknown message types are ignored by both sides, so
290
+ adding one is not a version bump.
291
+
226
292
  ## Two rules that fail at runtime, not build time
227
293
 
228
294
  1. **The remote entry must be an ES module.** The host loads remotes with a
@@ -244,25 +310,96 @@ Money crosses the contract as a **decimal string**, never a JavaScript
244
310
 
245
311
  ## Trust model
246
312
 
247
- UI plugins (widgets and pages loaded over Module Federation) run **fully
248
- trusted, in the host application's origin**. They share the page, its memory and
249
- the signed-in user's session with the host. The host's scoped client, the
250
- `x-wickermoney-plugin` header and the manifest check in `ctx.api` are
251
- developer feedback, not a security boundary: UI code that wants to can call any
252
- `/api/v1/*` route as the user, including routes outside its `requiredTables`.
253
-
254
- What is enforced against plugin code is the per-plugin PostgreSQL role, and only
255
- for server-side code (`contributes.endpoints`, bundled plugins only).
256
-
257
- So today:
258
-
259
- - Third-party plugin install is not supported. Treat every UI plugin as code
260
- with full access to the user's data, and only run plugins you wrote or have
261
- reviewed.
262
- - Operators should keep `PLUGIN_REMOTE_ORIGINS` empty unless they fully trust
263
- every origin listed.
264
- - Declare `requiredTables` honestly anyway. It is what the database enforces
265
- for your server code, and the contract a future isolation model will rely on.
313
+ Where a plugin's UI runs decides what it can do.
314
+
315
+ | Plugin | UI runs in | What contains it |
316
+ | --- | --- | --- |
317
+ | Bundled, ported (Insights, Spending Trends) | A sandboxed frame | The sandbox and the host's broker (below) |
318
+ | Bundled, not ported yet (Budgets, Import CSV, Upcoming, Forecast, Debt payoff) | **The app's own page** | Nothing: fully trusted, in the host's origin, with the signed-in user's session. `requiredTables`, the `x-wickermoney-plugin` header and the checks in `ctx.api` are developer feedback there, not a boundary |
319
+ | Third-party (a manifest the operator added) | A sandboxed frame, **always** | The sandbox and the broker |
320
+
321
+ Which row a plugin is in is decided by the host, never by the manifest. In-page
322
+ mode is a host-internal list of bundled plugin ids. `isolated: true` can only
323
+ move a plugin towards the frame. A manifest cannot ask for the page, and a
324
+ plugin whose `remoteEntry` is not served by the host has no path into it.
325
+
326
+ ### What the frame gives you, and what it takes away
327
+
328
+ In a frame your code has no cookies, `localStorage`, IndexedDB, host DOM, or
329
+ network of its own. It talks to the host over the
330
+ [isolated runtime](#isolated-runtime-experimental), and the host answers a
331
+ request only if it is a `GET` of a core route for a table your manifest lists in
332
+ `requiredTables`, or a call to your own `/p/<id>/` routes (a third-party plugin has none). The server then holds
333
+ the request to a token that carries only those grants. Nothing else is
334
+ reachable, including sign-in, the data export and other plugins.
335
+
336
+ ### What a third-party plugin can do
337
+
338
+ - **Read the core aggregates it is granted.** Eight read-only `GET /api/v1/core/*`
339
+ routes, each needing the tables listed in the manifest.
340
+ - **Nothing server-side.** No endpoints, no exporters, no scheduled work and no
341
+ storage of its own (a server half is first-party only, because the per-plugin
342
+ database role is a guardrail and not a sandbox). A manifest that asks for
343
+ `contributes.endpoints` or `contributes.exporters` is refused, with a reason.
344
+ - **No write.** A `write` grant on a core table has no route it can use.
345
+ - **No permissions.** `network:outbound`, `schedule:daily` and `notify` are
346
+ reserved, not implemented, and a manifest that declares one is refused.
347
+
348
+ ### Integrity pin
349
+
350
+ A plugin the image did not ship, and any plugin served from another origin,
351
+ must pin its build with the manifest's `integrity` field: Subresource Integrity
352
+ values keyed by path relative to the directory of `remoteEntry`.
353
+
354
+ ```json
355
+ "remoteEntry": "https://plugins.example.com/cash-runway/remoteEntry.js",
356
+ "integrity": {
357
+ "remoteEntry.js": "sha384-...",
358
+ "assets/RunwayWidget-1a2b3c.js": "sha384-..."
359
+ }
360
+ ```
361
+
362
+ The host has the browser check each listed file before the plugin runs
363
+ (`<link rel=modulepreload integrity=...>`), and a file whose bytes differ is not
364
+ loaded; the widget shows the reason. Limits, because a pin is easy to
365
+ over-trust:
366
+
367
+ - **List every file of the build.** Only listed files are verified. A file the
368
+ entry loads that you did not list loads unchecked. A pin that does not list the
369
+ entry file is refused.
370
+ - **Stylesheets are not covered.**
371
+ - **The hash is only as good as its source.** Take it from the build you
372
+ reviewed, not from the server that will serve it. A manifest fetched from the
373
+ same place as the code proves nothing.
374
+ - **It does not say the code is safe**, only that it is the code you pinned.
375
+ - **The remote origin must send CORS headers**
376
+ (`Access-Control-Allow-Origin`), because the frame fetches in CORS mode.
377
+ - Tested in Chromium 141 only.
378
+
379
+ Generate the values from the built files:
380
+
381
+ ```bash
382
+ openssl dgst -sha384 -binary assets/RunwayWidget-1a2b3c.js | openssl base64 -A | sed 's/^/sha384-/'
383
+ ```
384
+
385
+ ```powershell
386
+ $hex = (Get-FileHash -Algorithm SHA384 'assets\RunwayWidget-1a2b3c.js').Hash
387
+ 'sha384-' + [Convert]::ToBase64String([byte[]]($hex -split '(?<=\G..)(?=.)' | ForEach-Object { [Convert]::ToByte($_, 16) }))
388
+ ```
389
+
390
+ ### What this does not give you
391
+
392
+ - There is **no install flow, no catalog and no signing**. An operator copies the
393
+ manifest into the directory named by `PLUGIN_MANIFEST_DIR`, lists the origin in
394
+ `PLUGIN_REMOTE_ORIGINS`, restarts the API and switches the plugin on.
395
+ - The sandbox has **known gaps** in Chromium 141: `<link rel=prerender>` and
396
+ WebRTC reach an address the plugin chooses and can carry what it holds (the
397
+ user's email and id, and what its grants allow it to read). Other browsers
398
+ were not tested. Admission control (the operator choosing what to pin) is the
399
+ backstop, so only add a plugin you have read.
400
+ - The broker and token path have not had an independent security review.
401
+ - `requiredTables` is a **declaration** for your UI code, and what the grant
402
+ holds the broker and server to. Declare it honestly.
266
403
 
267
404
  ## Server-side code
268
405
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module
3
3
  * Calendar-date arithmetic on `YYYY-MM-DD` strings. `addDays` and `addMonths` are
4
- * public (re-exported from the `./recurrence` entry point); the rest is internal to the SDK.
4
+ * public (exported from the `./date` entry point); the rest is internal to the SDK.
5
5
  *
6
6
  * Dates here are calendar days, not instants: there is no time of day and no
7
7
  * time zone, so nothing can shift a day across midnight or a DST change. The
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/date/calendar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAUrG;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAS,GAAG,MAAM,CAGjE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKjG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAI9D;AAMD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1G"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module
3
3
  * Calendar-date arithmetic on `YYYY-MM-DD` strings. `addDays` and `addMonths` are
4
- * public (re-exported from the `./recurrence` entry point); the rest is internal to the SDK.
4
+ * public (exported from the `./date` entry point); the rest is internal to the SDK.
5
5
  *
6
6
  * Dates here are calendar days, not instants: there is no time of day and no
7
7
  * time zone, so nothing can shift a day across midnight or a DST change. The
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../src/date/calendar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,QAAQ,GAAG,2BAA2B,CAAA;AAC5C,MAAM,UAAU,GAAG,UAAU,CAAA;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,KAAK,GAAG,MAAM;IACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,UAAU,CAAC,WAAW,K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AA;AAChD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,MAAc;IACpD,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAChC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAC5C,OAAO,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;AACnD,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,KAAa;IAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,WAAW,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAA;AACpH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,SAAiB,EAAE,MAAc,EAAE,OAAe;IAChG,OAAO,CAAC,MAAM,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,GAAG,SAAS,CAAC,CAAA;AAC9D,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module
3
+ * Calendar-date arithmetic on `YYYY-MM-DD` strings: `addDays` and `addMonths`.
4
+ *
5
+ * Dates here are calendar days, not instants: there is no time of day and no
6
+ * time zone, so nothing can shift a day across midnight or a DST change. Pure
7
+ * and dependency-free, so it is safe in the browser and in Node, and importing
8
+ * it pulls in nothing else from the SDK.
9
+ *
10
+ * Stability: `@stable`. The two helpers are small and their behaviour is
11
+ * settled (month-end clamping, `RangeError` for anything that is not a real
12
+ * calendar date or a whole number).
13
+ *
14
+ * @stable
15
+ */
16
+ export { addDays, addMonths } from './calendar.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/date/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module
3
+ * Calendar-date arithmetic on `YYYY-MM-DD` strings: `addDays` and `addMonths`.
4
+ *
5
+ * Dates here are calendar days, not instants: there is no time of day and no
6
+ * time zone, so nothing can shift a day across midnight or a DST change. Pure
7
+ * and dependency-free, so it is safe in the browser and in Node, and importing
8
+ * it pulls in nothing else from the SDK.
9
+ *
10
+ * Stability: `@stable`. The two helpers are small and their behaviour is
11
+ * settled (month-end clamping, `RangeError` for anything that is not a real
12
+ * calendar date or a whole number).
13
+ *
14
+ * @stable
15
+ */
16
+ export { addDays, addMonths } from './calendar.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/date/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA"}
package/dist/index.d.ts CHANGED
@@ -8,20 +8,24 @@
8
8
  * The two groups are kept apart so a Node process can import the manifest
9
9
  * exports without pulling in React.
10
10
  *
11
- * Stability: the manifest, runtime, range, money and server exports are
11
+ * Stability: the manifest, runtime, range, date, money and server exports are
12
12
  * `@stable`. The recurrence exports re-exported here are `@experimental`,
13
13
  * exactly as they are from `@wickermoney/plugin-sdk/recurrence`: an export
14
14
  * keeps the tier of the entry point it comes from, however it is imported.
15
15
  *
16
+ * `@wickermoney/plugin-sdk/isolated` (`@experimental`) is deliberately not
17
+ * re-exported here; import it from its own entry point.
18
+ *
16
19
  * @stable
17
20
  */
18
- export { CORE_TABLES, checkRemoteEntry, remoteEntrySchema, PERMISSIONS, REMOTE_ENTRY_TYPE, SDK_MAJOR_VERSION, WIDGET_SIZES, WIDGET_SLOTS, federationName, isCompatible, pagePath, parseManifest, pageContributionSchema, pluginManifestSchema, tableGrantSchema, widgetContributionSchema, } from './manifest/index.js';
21
+ export { CORE_TABLES, checkRemoteEntry, checkRemoteEntryIntegrity, PERMISSIONS, REMOTE_ENTRY_TYPE, SDK_MAJOR_VERSION, WIDGET_SIZES, WIDGET_SLOTS, federationName, isCompatible, pagePath, parseIntegrity, parseManifest, } from './manifest/index.js';
19
22
  export type { CoreTableName, ManifestParseResult, PageContribution, Permission, PluginManifest, TableGrant, WidgetContribution, WidgetSize, WidgetSlot, } from './manifest/index.js';
20
23
  export { adoptPluginStyles } from './runtime.js';
21
24
  export type { PluginApi, PluginContext, PluginModule, PluginPage, PluginPageProps, PluginSession, PluginWidget, PluginWidgetProps, } from './runtime.js';
22
25
  export { RANGE_KEYS, DEFAULT_RANGE_KEY, isRangeKey, rangeLabel, resolveRange, monthsInRange, } from './range.js';
23
26
  export type { DashboardRange, RangeKey } from './range.js';
24
- export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES, addDays, addMonths, dailyBalances, flowTotals, monthlyEquivalent, nextOccurrence, nextPayday, nextScheduledOccurrence, occurrences, scheduledOccurrences, } from './recurrence/index.js';
27
+ export { addDays, addMonths } from './date/index.js';
28
+ export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES, dailyBalances, flowTotals, monthlyEquivalent, nextOccurrence, nextPayday, nextScheduledOccurrence, occurrences, scheduledOccurrences, } from './recurrence/index.js';
25
29
  export type { DailyBalance, FlowTotals, OccurrenceOverride, RecurrenceFrequency, RecurrenceSchedule, RecurringItem, RecurringLeg, ScheduledOccurrence, } from './recurrence/index.js';
26
30
  export { MONEY_SCALE, MONEY_UNIT, ZERO_MONEY, absMoney, addMoney, compareMoney, divideUnits, editableMoney, equalMoney, isNegativeMoney, isZeroMoney, moneyToUnits, negateMoney, normalizeMoney, subtractMoney, sumMoney, unitsToMoney, } from './money/index.js';
27
31
  export type { Money } from './money/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","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E1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EACL,wBAAwB,EAAE,sBAAsB,EAChD,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,uBAAuB,EACjG,WAAW,EAAE,oBAAoB,GAClC,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EACV,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EACpG,YAAY,EAAE,mBAAmB,GAClC,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,WAAW,EAAE,UAAU,EAAE,UAAU,EACnC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EACzF,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,GAC9F,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC5D,YAAY,EACV,oBAAoB,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EACxG,WAAW,EAAE,WAAW,GACzB,MAAM,mBAAmB,CAAA"}
package/dist/index.js CHANGED
@@ -8,17 +8,21 @@
8
8
  * The two groups are kept apart so a Node process can import the manifest
9
9
  * exports without pulling in React.
10
10
  *
11
- * Stability: the manifest, runtime, range, money and server exports are
11
+ * Stability: the manifest, runtime, range, date, money and server exports are
12
12
  * `@stable`. The recurrence exports re-exported here are `@experimental`,
13
13
  * exactly as they are from `@wickermoney/plugin-sdk/recurrence`: an export
14
14
  * keeps the tier of the entry point it comes from, however it is imported.
15
15
  *
16
+ * `@wickermoney/plugin-sdk/isolated` (`@experimental`) is deliberately not
17
+ * re-exported here; import it from its own entry point.
18
+ *
16
19
  * @stable
17
20
  */
18
- export { CORE_TABLES, checkRemoteEntry, remoteEntrySchema, PERMISSIONS, REMOTE_ENTRY_TYPE, SDK_MAJOR_VERSION, WIDGET_SIZES, WIDGET_SLOTS, federationName, isCompatible, pagePath, parseManifest, pageContributionSchema, pluginManifestSchema, tableGrantSchema, widgetContributionSchema, } from './manifest/index.js';
21
+ export { CORE_TABLES, checkRemoteEntry, checkRemoteEntryIntegrity, PERMISSIONS, REMOTE_ENTRY_TYPE, SDK_MAJOR_VERSION, WIDGET_SIZES, WIDGET_SLOTS, federationName, isCompatible, pagePath, parseIntegrity, parseManifest, } from './manifest/index.js';
19
22
  export { adoptPluginStyles } from './runtime.js';
20
23
  export { RANGE_KEYS, DEFAULT_RANGE_KEY, isRangeKey, rangeLabel, resolveRange, monthsInRange, } from './range.js';
21
- export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES, addDays, addMonths, dailyBalances, flowTotals, monthlyEquivalent, nextOccurrence, nextPayday, nextScheduledOccurrence, occurrences, scheduledOccurrences, } from './recurrence/index.js';
24
+ export { addDays, addMonths } from './date/index.js';
25
+ export { DEFAULT_SEMIMONTHLY_DAYS, RECURRENCE_FREQUENCIES, dailyBalances, flowTotals, monthlyEquivalent, nextOccurrence, nextPayday, nextScheduledOccurrence, occurrences, scheduledOccurrences, } from './recurrence/index.js';
22
26
  export { MONEY_SCALE, MONEY_UNIT, ZERO_MONEY, absMoney, addMoney, compareMoney, divideUnits, editableMoney, equalMoney, isNegativeMoney, isZeroMoney, moneyToUnits, negateMoney, normalizeMoney, subtractMoney, sumMoney, unitsToMoney, } from './money/index.js';
23
27
  export { PluginRouteError, isUuid } from './server/index.js';
24
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GA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,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAYhD,OAAO,EACL,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,GACnF,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EACL,wBAAwB,EAAE,sBAAsB,EAChD,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,uBAAuB,EACjG,WAAW,EAAE,oBAAoB,GAClC,MAAM,uBAAuB,CAAA;AAM9B,OAAO,EACL,WAAW,EAAE,UAAU,EAAE,UAAU,EACnC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EACzF,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,GAC9F,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,20 @@
1
+ import type { PluginApiIssue, PluginErrorPayload } from './protocol.js';
2
+ /**
3
+ * The error a failed `ctx.api` call rejects with inside an isolated frame.
4
+ *
5
+ * The fields match the host's own `ApiError` (`status`, `code`, `issues`), so a
6
+ * plugin's `catch` blocks and ui-kit's `formErrorsFrom` read it the same way in
7
+ * either runtime. `status` is `0` when the failure did not come from an HTTP
8
+ * response (a grant refusal, an abort, a lost connection). An aborted request
9
+ * has `name === 'AbortError'`, like a rejected `fetch`.
10
+ */
11
+ export declare class PluginApiError extends Error {
12
+ /** The HTTP status of the API response, or `0` when there was none. */
13
+ readonly status: number;
14
+ /** A code to branch on; see `PLUGIN_ERROR_CODES` for the ones the host promises. */
15
+ readonly code: string;
16
+ /** Field-by-field problems; empty when there are none. */
17
+ readonly issues: readonly PluginApiIssue[];
18
+ constructor(payload: PluginErrorPayload);
19
+ }
20
+ //# sourceMappingURL=PluginApiError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginApiError.d.ts","sourceRoot":"","sources":["../../src/isolated/PluginApiError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEvE;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAA;gBAE9B,OAAO,EAAE,kBAAkB;CAOxC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The error a failed `ctx.api` call rejects with inside an isolated frame.
3
+ *
4
+ * The fields match the host's own `ApiError` (`status`, `code`, `issues`), so a
5
+ * plugin's `catch` blocks and ui-kit's `formErrorsFrom` read it the same way in
6
+ * either runtime. `status` is `0` when the failure did not come from an HTTP
7
+ * response (a grant refusal, an abort, a lost connection). An aborted request
8
+ * has `name === 'AbortError'`, like a rejected `fetch`.
9
+ */
10
+ export class PluginApiError extends Error {
11
+ /** The HTTP status of the API response, or `0` when there was none. */
12
+ status;
13
+ /** A code to branch on; see `PLUGIN_ERROR_CODES` for the ones the host promises. */
14
+ code;
15
+ /** Field-by-field problems; empty when there are none. */
16
+ issues;
17
+ constructor(payload) {
18
+ super(payload.message);
19
+ this.name = payload.code === 'aborted' ? 'AbortError' : 'PluginApiError';
20
+ this.status = payload.status ?? 0;
21
+ this.code = payload.code;
22
+ this.issues = payload.issues ?? [];
23
+ }
24
+ }
25
+ //# sourceMappingURL=PluginApiError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginApiError.js","sourceRoot":"","sources":["../../src/isolated/PluginApiError.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,uEAAuE;IAC9D,MAAM,CAAQ;IACvB,oFAAoF;IAC3E,IAAI,CAAQ;IACrB,0DAA0D;IACjD,MAAM,CAA2B;IAE1C,YAAY,OAA2B;QACrC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB,CAAA;QACxE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAA;IACpC,CAAC;CACF"}
@@ -0,0 +1,118 @@
1
+ import type { PluginContext, PluginSession } from '../runtime.js';
2
+ import type { DashboardRange } from '../range.js';
3
+ import type { WidgetSize } from '../manifest/WidgetSize.js';
4
+ import type { ThemeTarget } from './theme.js';
5
+ import type { FocusDirection, FocusInMessage, FrameKind, HostLocale, HostTheme, LocaleMessage, NotifyMessage, PropsMessage, RouteMessage, ThemeMessage } from './protocol.js';
6
+ /** What the host currently says about this frame. A new object on every change, so it suits `useSyncExternalStore`. */
7
+ export interface IsolatedState {
8
+ readonly pluginId: string;
9
+ readonly kind: FrameKind;
10
+ readonly session: PluginSession;
11
+ readonly locale: HostLocale;
12
+ readonly theme: HostTheme;
13
+ /** Widgets only. */
14
+ readonly size?: WidgetSize;
15
+ /** Widgets only, and only when the dashboard has a range. */
16
+ readonly range?: DashboardRange;
17
+ /** Pages only: the current path under the page's route. */
18
+ readonly path?: string;
19
+ }
20
+ /** A change the host pushed after `init`. `state` already reflects it by the time listeners run. */
21
+ export type HostChange = ThemeMessage | LocaleMessage | PropsMessage | RouteMessage | FocusInMessage;
22
+ /** The live link between a plugin frame and the host. */
23
+ export interface HostConnection {
24
+ /** The context to hand a plugin component: the same shape the in-realm host provides. */
25
+ readonly ctx: PluginContext;
26
+ /** The latest state. */
27
+ getState(): IsolatedState;
28
+ /**
29
+ * Listens for changes the host pushes (theme, locale, props, route, focus-in).
30
+ *
31
+ * @returns A function that removes the listener.
32
+ */
33
+ subscribe(listener: (change: HostChange) => void): () => void;
34
+ /** Reports the content height in CSS pixels. Rounded up; repeats of the same height are not sent. */
35
+ reportSize(height: number): void;
36
+ /**
37
+ * Reports the height of `element` now and whenever it changes.
38
+ *
39
+ * Also re-reads the height every {@link SIZE_POLL_MS} ms. Chromium does not run a cross-origin frame's
40
+ * rendering updates while it is off screen, so a `ResizeObserver` alone never fires there and the frame
41
+ * would keep the host's minimum height until scrolled into view. Repeats of a height are not sent, so
42
+ * the poll costs one layout read per tick and no messages.
43
+ *
44
+ * @param element - The element whose height is the frame's content height, usually the app root.
45
+ * @param observer - A `ResizeObserver` constructor; defaults to the global one.
46
+ * @returns A function that stops observing.
47
+ */
48
+ observeSize(element: ObservedElement, observer?: ResizeObserverCtor): () => void;
49
+ /** Tells the host that focus left the frame, past its last (`next`) or before its first (`previous`) focusable element. */
50
+ focusOut(direction: FocusDirection): void;
51
+ /**
52
+ * Sends a notification request. No host implements `notify` yet, so this
53
+ * rejects with code `not_supported` today.
54
+ */
55
+ notify(level: NotifyMessage['level'], message: string): Promise<void>;
56
+ /** Closes the port and rejects every call still waiting with code `disconnected`. */
57
+ dispose(): void;
58
+ }
59
+ /** How often `observeSize` re-reads the height, in milliseconds. */
60
+ export declare const SIZE_POLL_MS = 250;
61
+ /** The part of an element `observeSize` reads. */
62
+ export interface ObservedElement {
63
+ getBoundingClientRect(): {
64
+ readonly height: number;
65
+ };
66
+ }
67
+ /** A `ResizeObserver` constructor, as far as `observeSize` uses it. */
68
+ export type ResizeObserverCtor = new (callback: () => void) => {
69
+ observe(target: ObservedElement): void;
70
+ disconnect(): void;
71
+ };
72
+ /** Options for {@link connectOverPort} and {@link connectToHost}. */
73
+ export interface ConnectOptions {
74
+ /** Where to write the theme. `null` turns automatic theming off. Defaults to `document.documentElement` when there is a `document`. */
75
+ readonly themeRoot?: ThemeTarget | null;
76
+ /** How long to wait for the host, in milliseconds, before rejecting. Defaults to 10 000. */
77
+ readonly timeoutMs?: number;
78
+ }
79
+ /** The slice of `window` the handshake uses. Narrow so a test can supply a stand-in. */
80
+ export interface HandshakeWindow {
81
+ readonly parent: {
82
+ postMessage(message: unknown, targetOrigin: string): void;
83
+ };
84
+ addEventListener(type: 'message', listener: (event: HandshakeEvent) => void): void;
85
+ removeEventListener(type: 'message', listener: (event: HandshakeEvent) => void): void;
86
+ }
87
+ /** The slice of a window `MessageEvent` the handshake reads. */
88
+ export interface HandshakeEvent {
89
+ readonly source: unknown;
90
+ readonly data: unknown;
91
+ readonly ports: readonly MessagePort[];
92
+ }
93
+ /**
94
+ * Connects a plugin frame to its host. Call it once, at the start of the frame.
95
+ *
96
+ * The frame says hello to `window.parent`; the host replies with the protocol
97
+ * version to use and a `MessagePort`; everything after that travels on the
98
+ * port. The reply is accepted only from `window.parent` and only with a port,
99
+ * so another window cannot answer in the host's place.
100
+ *
101
+ * @param options - Theme and timeout options.
102
+ * @param win - The window to use. Defaults to the global `window`.
103
+ * @returns The connection, once the host has sent `init`.
104
+ * @throws {PluginApiError} With code `disconnected` on timeout, or `invalid_request` when the host speaks no protocol version this SDK does.
105
+ */
106
+ export declare function connectToHost(options?: ConnectOptions, win?: HandshakeWindow): Promise<HostConnection>;
107
+ /**
108
+ * The second half of {@link connectToHost}: says `ready` on a port the host
109
+ * gave, waits for `init`, and builds the connection. Public so a test harness
110
+ * can connect over a `MessageChannel` without a window.
111
+ *
112
+ * @param port - The port from the host.
113
+ * @param protocol - The protocol version the host chose.
114
+ * @param options - Theme and timeout options.
115
+ * @returns The connection, once the host has sent `init`.
116
+ */
117
+ export declare function connectOverPort(port: MessagePort, protocol: number, options?: ConnectOptions): Promise<HostConnection>;
118
+ //# sourceMapping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