@botiverse/porthole 0.3.2 → 0.3.4

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.
@@ -301,7 +301,11 @@ export function createHost(config, options = {}) {
301
301
  }
302
302
  const bridge = createBridge({
303
303
  config,
304
- display: { id: mount.displayId, title: mount.title },
304
+ display: {
305
+ id: mount.displayId,
306
+ title: mount.title,
307
+ ...(mount.instance === undefined ? {} : { instance: mount.instance }),
308
+ },
305
309
  handlers,
306
310
  ...(options.confirm === undefined ? {} : { confirm: options.confirm }),
307
311
  userActivation: () => created.userActivation(),
@@ -51,7 +51,11 @@ export interface MountOptions {
51
51
  readonly scheme: ColorScheme;
52
52
  /** Handlers for this display only, over the host's. */
53
53
  readonly handlers?: CapabilityHandlers;
54
- /** Domain and external isolation: the instance to locate. */
54
+ /**
55
+ * Domain and external isolation: the instance to locate. Opaque: the host's own name for what
56
+ * the display shows, given back to the host in its confirmations (`ConfirmRequest.display`) and
57
+ * never sent to the frame (P077).
58
+ */
55
59
  readonly instance?: InstanceRef;
56
60
  /** A whole document the frame starts with (an MCP Apps view), hardened by the shell. */
57
61
  readonly document?: string;
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ export type { PlatformHost, Surface, SurfaceSpec } from "./platform/types.ts";
22
22
  export type { Transport } from "./transport/types.ts";
23
23
  export type { AdapterConnection, AdapterEvent, AdapterSession, ProtocolAdapter, ShellConnection, } from "./protocol/adapter.ts";
24
24
  export { COPY_TEXT_METHOD, MCP_APPS_METHODS, MCP_APPS_PROTOCOL_VERSION, MCP_APPS_STYLE_VARIABLES, PORTHOLE_STYLES, type HostContext, } from "./protocol/mcp-apps.ts";
25
- export type { CallContext, CallOutcome, CapabilityHandler, CapabilityHandlers, Confirm, ConfirmAnswer, ConfirmRequest, Proceed, HostFunctionBridge, Refusal, } from "./bridge/types.ts";
25
+ export type { CallContext, CallOutcome, CapabilityHandler, CapabilityHandlers, Confirm, ConfirmAnswer, ConfirmDisplay, ConfirmRequest, Proceed, HostFunctionBridge, Refusal, } from "./bridge/types.ts";
26
26
  export { createHost } from "./host/create-host.ts";
27
27
  export { entryTarget, frameFallback, portholeClient, type ContentClientMeta, type FrameFallback, type PortholeClient, type PortholeClientOptions, } from "./host/client.ts";
28
28
  export { defineDisplays, type DisplayKind, type Displays } from "./displays/displays.ts";
@@ -50,7 +50,10 @@ export interface NodeServerOptions {
50
50
  /**
51
51
  * The content host, or a function giving it when it exists: a host made after the server listens
52
52
  * (its content domain names the port `listen(0)` chose, P074). Until it gives one, every request
53
- * is the app's; the health gate starts when it first does.
53
+ * is the app's. `nodeServer` starts the host's health gate when it listens, asking the function
54
+ * once the server's `listen` callbacks have run (a host made in one starts then), and again at
55
+ * each request until it gives one; `start` is idempotent, so an app may start the host itself
56
+ * as soon as it makes it (P076).
54
57
  */
55
58
  readonly content: ContentHost<unknown> | (() => ContentHost<unknown> | null);
56
59
  /**
@@ -300,9 +300,11 @@ export function nodeServer(options) {
300
300
  });
301
301
  server.on("listening", () => {
302
302
  listening = true;
303
- current();
303
+ // After the listen callbacks: a host made in one (with the port it got) starts now.
304
+ setImmediate(current);
304
305
  });
305
306
  server.on("close", () => {
307
+ listening = false;
306
308
  const host = typeof given === "function" ? given() : given;
307
309
  host?.close();
308
310
  });
@@ -126,7 +126,10 @@ export interface PortholeFrameProps {
126
126
  readonly partial?: boolean;
127
127
  /** A whole document to start with (an MCP Apps view). */
128
128
  readonly document?: string;
129
- /** Domain and external isolation: the instance to show. */
129
+ /**
130
+ * Domain and external isolation: the instance to show. Opaque: the host's own name for what it
131
+ * shows, for its confirmations only, never sent to the frame (P077).
132
+ */
130
133
  readonly instance?: InstanceRef;
131
134
  /** The color scheme it shows in. Default: the provider's `scheme`, else light. */
132
135
  readonly scheme?: ColorScheme;
@@ -357,7 +357,14 @@ function Mount({ frame, page, initialHeightPx, placeholder, run }) {
357
357
  handlers,
358
358
  ...(asks
359
359
  ? {
360
- confirm: (request, proceed) => (latest().confirm ?? pageConfirm ?? (() => Promise.resolve(false)))({ ...request, display: { id: latest().displayId, title: latest().title } }, proceed),
360
+ confirm: (request, proceed) => (latest().confirm ?? pageConfirm ?? (() => Promise.resolve(false)))({
361
+ ...request,
362
+ display: {
363
+ ...request.display,
364
+ id: latest().displayId,
365
+ title: latest().title,
366
+ },
367
+ }, proceed),
361
368
  }
362
369
  : {}),
363
370
  theme: (each) => (latest().theme ?? latestPage().theme)?.(each) ?? {},
@@ -22,7 +22,10 @@ export interface PortholeFallbackProps extends FrameFallback {
22
22
  export interface PortholeViewProps extends Omit<PortholeFrameProps, "config" | "instance" | "content" | "fill"> {
23
23
  /** The display kind (`defineDisplays`). */
24
24
  readonly display: string;
25
- /** The instance to show while frames are served. */
25
+ /**
26
+ * The instance: what a served frame shows; for an opaque one, the host's own name for it, given
27
+ * back in its confirmations only, never sent to the frame (P077).
28
+ */
26
29
  readonly instance?: InstanceRef;
27
30
  /**
28
31
  * The content: a served shell's to draw, and what an opaque frame shows while frames aren't
@@ -73,7 +73,7 @@ export function PortholeView(props) {
73
73
  if (failed !== null) {
74
74
  return _jsx(_Fragment, { children: (fallback ?? DefaultFallback)({ ...failed, link, retry }) });
75
75
  }
76
- return (_jsx(PortholeFrame, { ...frame, config: config, generation: (frame.generation ?? 0) + generation, ...(served && instance !== undefined ? { instance } : {}), ...(content === undefined ? {} : { content }), onOutcome: (outcome) => {
76
+ return (_jsx(PortholeFrame, { ...frame, config: config, generation: (frame.generation ?? 0) + generation, ...(instance === undefined ? {} : { instance }), ...(content === undefined ? {} : { content }), onOutcome: (outcome) => {
77
77
  onOutcome?.(outcome);
78
78
  const said = frameFallback(outcome, { url });
79
79
  if (said !== null) {
@@ -251,7 +251,10 @@ export interface ContentHost<V> {
251
251
  authorize(viewerOf: (request: Request) => Awaitable<V | null>): (request: Request) => Promise<Response>;
252
252
  /** A url-mode app's access for a WebSocket upgrade (`server.access`), or null. */
253
253
  access(request: Request): Promise<Access | null>;
254
- /** Starts the health gate (after the app listens). */
254
+ /**
255
+ * Starts the health gate (after the app listens). Once: starting a started host does nothing,
256
+ * so the app and `nodeServer` may both start it (P076). After `close`, it starts again.
257
+ */
255
258
  start(): void;
256
259
  /** Runs one health check now. */
257
260
  check(): Promise<ContentHealthView>;
@@ -203,6 +203,7 @@ export function createContentHost(options) {
203
203
  let timer = null;
204
204
  let running = null;
205
205
  let closed = false;
206
+ let started = false;
206
207
  const schedule = () => {
207
208
  if (closed || gate === undefined || view.misconfigured === true || domain === null) {
208
209
  return;
@@ -687,12 +688,17 @@ export function createContentHost(options) {
687
688
  },
688
689
  access: async (request) => (server === null ? null : server.access(request)),
689
690
  start() {
691
+ if (started) {
692
+ return;
693
+ }
694
+ started = true;
690
695
  closed = false;
691
696
  void check();
692
697
  },
693
698
  check,
694
699
  close() {
695
700
  closed = true;
701
+ started = false;
696
702
  if (timer !== null) {
697
703
  clearTimeout(timer);
698
704
  timer = null;
package/docs/ADOPTING.md CHANGED
@@ -65,7 +65,9 @@ reads the page's), `handlers`, `openLink` (default: a new tab), `notify` (your o
65
65
  a copy button copied), and `renderConfirm` (your own dialog, given `accept`, `decline` and
66
66
  `redirect`: Porthole keeps the queue, runs `accept` inside its click, and counts declines toward
67
67
  muting the display; `redirect`, for "edit it first", answers the call `"redirected"` and neither
68
- counts nor resets the count). `useRunAgain()` gives a "run again" button.
68
+ counts nor resets the count). The request names the display (`request.display`: its `id`,
69
+ `title`, and the `instance` you gave the frame, served or opaque), so the dialog can say what it
70
+ is from your own records. It stays on your side: an opaque frame never gets the instance. `useRunAgain()` gives a "run again" button.
69
71
 
70
72
  ## 4. Served pages: the host kit
71
73
 
@@ -132,7 +134,10 @@ nodeServer({ content, app: async (request) => (await routes(request)) ?? app(req
132
134
  every other request to `app` (fetch-style: Hono's `app.fetch`) or `request` (a Node listener:
133
135
  Express), the health gate started on listen and stopped on close. Behind a TLS edge, add
134
136
  `scheme: "https"`. A host that needs the port first (`listen(0)`) can come later: `content:
135
- () => host` (null until made); requests go to the app until it gives one.
137
+ () => host` (null until made); requests go to the app until it gives one. `nodeServer` starts
138
+ the host it is given: a host made in a `listen` callback starts right after it, and one made
139
+ later at the next request. `start()` runs once (a started host ignores it), so starting it
140
+ yourself as soon as you make it is fine too.
136
141
  - **`nodeHost(content, { request })`** is for an app that keeps its own `node:http` server (or a
137
142
  framework that owns one): put its `request` and `upgrade` listeners on your server, call
138
143
  `content.start()` once it listens and `content.close()` when it stops.
package/docs/DECISIONS.md CHANGED
@@ -2122,3 +2122,41 @@ on `/check`; a Worker's bundle would fail where the path runs. 0.3.2:
2122
2122
  and the failure shows only where the path runs.
2123
2123
  **Revisit when** a bundler needs code split into chunks of its own (none does yet).
2124
2124
 
2125
+ ## P076 · 2026-10-12 · A confirmation names the instance; a content host starts once · Accepted
2126
+
2127
+ **Decision.** From Ferry, #10. 0.3.3, additive:
2128
+ 1. **`ConfirmRequest.display` carries the frame's `instance`** where the display is served
2129
+ (`ConfirmDisplay`: `id`, `title`, `instance?`), in the core's `confirm` and React's
2130
+ `renderConfirm`. A host words its dialog from its own records (Ferry: the transcript the
2131
+ instance belongs to) without keeping an index from display ids to them (28 lines in Ferry). The
2132
+ instance is the host's own, as it gave it to `mount`: nothing the content chose.
2133
+ 2. **`ContentHost.start()` runs once**: a started host ignores it until `close`, so the app and
2134
+ `nodeServer` may both start it (before, each start ran a check, and the second came at the first
2135
+ request). **`nodeServer` asks a lazily given host right after the server's `listen` callbacks**
2136
+ (a host made in one, with the port it got, starts then), and again at each request until it
2137
+ gives one. ADOPTING says who starts it.
2138
+
2139
+ **Why.** Each was a workaround in Ferry: the side index, and starting the host itself while
2140
+ `nodeServer` started it again.
2141
+ **Measured.** `leak/react.spec.ts` (`renderConfirm` names the served frame's instance, and none
2142
+ for an opaque one); `test/kit03.test.ts` (a host made in the `listen` callback is checked without a
2143
+ request, once, however often it is started).
2144
+
2145
+ ## P077 · 2026-10-12 · A confirmation names the host's instance in opaque frames too · Accepted
2146
+
2147
+ **Decision.** P076 gave `ConfirmRequest.display` the instance only where the frame is served,
2148
+ because `PortholeView` handed the instance to its frame only then. The instance is the host's own
2149
+ value in both modes: Ferry passes `instance={widgetInstance(sessionId)}` to `PortholeView`
2150
+ whether its frame ends up served or opaque (the content domain down, absent on a self-hosted
2151
+ server, the first seconds before the probe). 0.3.4: `PortholeView` gives its frame the instance
2152
+ in both modes, and an opaque mount's `instance` (`MountOptions`, `PortholeFrame`) is documented
2153
+ as the host's own name for what it shows, given back in its confirmations only.
2154
+
2155
+ **Never sent to the frame.** An opaque frame's document is the shell built from the config, with
2156
+ no instance in it; the instance is used to locate only a served frame, and the bridge's display
2157
+ (where confirmations get it) stays on the host's side. A served frame already knows its scope:
2158
+ its origin is named from it.
2159
+ **Measured.** `leak/react.spec.ts`: `renderConfirm` names the instance the host gave, served and
2160
+ opaque (failing on 0.3.3 for opaque); for an opaque frame, the instance is in none of the frame's
2161
+ attributes, its document, its address or name, nor any message its page heard.
2162
+
package/docs/DESIGN.md CHANGED
@@ -530,7 +530,8 @@ What both adopters still wrote after 0.2 moves into Porthole (ADOPTING.md is the
530
530
  served, content source, frame sources, health) and `POST`/`DELETE handoff`.
531
531
  `contentHostFor(build)` gives one host per Workers `env`, failing closed with a plain 503;
532
532
  `nodeServer({ content, app })` is the whole Node server (`content` may be a function giving the
533
- host once made, P074). A missing or short secret throws, naming `PORTHOLE_SECRET`.
533
+ host once made, P074; asked right after the `listen` callbacks and at each request until it
534
+ gives one, and `start` is idempotent, P076). A missing or short secret throws, naming `PORTHOLE_SECRET`.
534
535
  - **The client:** `portholeClient({ displays, base, headers, credentials, handoff })` is the
535
536
  locator and knows each kind's config from the meta (null until known), links, `openInTab`
536
537
  (a tab opened in the click, then sent to the address), the handoff, and `entryTarget` (the
@@ -539,7 +540,9 @@ What both adopters still wrote after 0.2 moves into Porthole (ADOPTING.md is the
539
540
  `denied`, `expired`, `failed`, `timeout`). React: `PortholeView` (a display by kind, served or
540
541
  opaque, with its fallback), `usePortholeLink`, and the provider's shared `scheme`, `theme`
541
542
  (`cssVariableTheme`), `nonce: "auto"`, `handlers`, `openLink`, `notify` and `renderConfirm`
542
- (`accept`, `decline`, and `redirect`: `"redirected"`, which doesn't count toward muting, P074).
543
+ (`accept`, `decline`, and `redirect`: `"redirected"`, which doesn't count toward muting, P074;
544
+ the request's `display` carries the instance the host gave the frame, served or opaque, and an
545
+ opaque frame never gets it, P076, P077).
543
546
  A flip of the provider's scheme or a new themeKey re-themes running frames in place: no effect
544
547
  that makes a display depends on the context value those renew (#9, P074).
545
548
  - **The viewer handoff** for a page that holds a token: `POST /porthole/handoff` with the app's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botiverse/porthole",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "A host-side sandbox for agent-made HTML: isolation, egress hardening, a themed shell, gated host functions, and the agent manual, from one config.",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
@@ -15,6 +15,7 @@ import type {
15
15
  CapabilityHandlers,
16
16
  Confirm,
17
17
  ConfirmAnswer,
18
+ ConfirmDisplay,
18
19
  ConfirmRequest,
19
20
  HostFunctionBridge,
20
21
  Refusal,
@@ -35,7 +36,7 @@ export type BridgeEvent =
35
36
 
36
37
  export interface BridgeOptions {
37
38
  readonly config: PortholeConfig;
38
- readonly display: { readonly id: string; readonly title: string };
39
+ readonly display: ConfirmDisplay;
39
40
  readonly handlers: CapabilityHandlers;
40
41
  readonly confirm?: Confirm;
41
42
  /** Whether the embedding page has user activation now; undefined where it can't tell. */
@@ -4,6 +4,7 @@ import type {
4
4
  CapabilityResults,
5
5
  HandledCapability,
6
6
  } from "../config/capabilities.ts";
7
+ import type { InstanceRef } from "../isolation/types.ts";
7
8
 
8
9
  /**
9
10
  * The host-function bridge (ARCHITECTURE § Framework layer): carries a capability call from the
@@ -28,12 +29,23 @@ export type CapabilityHandler<N extends CapabilityName> = (
28
29
  /** The host's handlers: one for each declared capability served by a handler. */
29
30
  export type CapabilityHandlers = { readonly [N in HandledCapability]?: CapabilityHandler<N> };
30
31
 
32
+ /**
33
+ * The display a confirmation is for, as the host named it: its id and title, and the instance the
34
+ * host gave it, served or opaque (P076, P077), so a host can word its dialog from its own records.
35
+ * Host-side only: none of it is the content's word, and an opaque frame never gets the instance.
36
+ */
37
+ export interface ConfirmDisplay {
38
+ readonly id: string;
39
+ readonly title: string;
40
+ readonly instance?: InstanceRef;
41
+ }
42
+
31
43
  /** What a person is asked to confirm: the call's whole effect, not a summary the content chose. */
32
44
  export type ConfirmRequest = {
33
45
  [N in CapabilityName]: {
34
46
  readonly capability: N;
35
47
  readonly args: CapabilityArgs[N];
36
- readonly display: { readonly id: string; readonly title: string };
48
+ readonly display: ConfirmDisplay;
37
49
  };
38
50
  }[CapabilityName];
39
51
 
@@ -353,7 +353,11 @@ export function createHost<C extends AdapterConnection = ShellConnection>(
353
353
  }
354
354
  const bridge = createBridge({
355
355
  config,
356
- display: { id: mount.displayId, title: mount.title },
356
+ display: {
357
+ id: mount.displayId,
358
+ title: mount.title,
359
+ ...(mount.instance === undefined ? {} : { instance: mount.instance }),
360
+ },
357
361
  handlers,
358
362
  ...(options.confirm === undefined ? {} : { confirm: options.confirm }),
359
363
  userActivation: () => created.userActivation(),
package/src/host/types.ts CHANGED
@@ -51,7 +51,11 @@ export interface MountOptions {
51
51
  readonly scheme: ColorScheme;
52
52
  /** Handlers for this display only, over the host's. */
53
53
  readonly handlers?: CapabilityHandlers;
54
- /** Domain and external isolation: the instance to locate. */
54
+ /**
55
+ * Domain and external isolation: the instance to locate. Opaque: the host's own name for what
56
+ * the display shows, given back to the host in its confirmations (`ConfirmRequest.display`) and
57
+ * never sent to the frame (P077).
58
+ */
55
59
  readonly instance?: InstanceRef;
56
60
  /** A whole document the frame starts with (an MCP Apps view), hardened by the shell. */
57
61
  readonly document?: string;
package/src/index.ts CHANGED
@@ -124,6 +124,7 @@ export type {
124
124
  CapabilityHandlers,
125
125
  Confirm,
126
126
  ConfirmAnswer,
127
+ ConfirmDisplay,
127
128
  ConfirmRequest,
128
129
  Proceed,
129
130
  HostFunctionBridge,
package/src/node/index.ts CHANGED
@@ -295,7 +295,10 @@ export interface NodeServerOptions {
295
295
  /**
296
296
  * The content host, or a function giving it when it exists: a host made after the server listens
297
297
  * (its content domain names the port `listen(0)` chose, P074). Until it gives one, every request
298
- * is the app's; the health gate starts when it first does.
298
+ * is the app's. `nodeServer` starts the host's health gate when it listens, asking the function
299
+ * once the server's `listen` callbacks have run (a host made in one starts then), and again at
300
+ * each request until it gives one; `start` is idempotent, so an app may start the host itself
301
+ * as soon as it makes it (P076).
299
302
  */
300
303
  readonly content: ContentHost<unknown> | (() => ContentHost<unknown> | null);
301
304
  /**
@@ -384,9 +387,11 @@ export function nodeServer(options: NodeServerOptions): Server {
384
387
  });
385
388
  server.on("listening", () => {
386
389
  listening = true;
387
- current();
390
+ // After the listen callbacks: a host made in one (with the port it got) starts now.
391
+ setImmediate(current);
388
392
  });
389
393
  server.on("close", () => {
394
+ listening = false;
390
395
  const host = typeof given === "function" ? given() : given;
391
396
  host?.close();
392
397
  });
@@ -359,7 +359,10 @@ export interface PortholeFrameProps {
359
359
  readonly partial?: boolean;
360
360
  /** A whole document to start with (an MCP Apps view). */
361
361
  readonly document?: string;
362
- /** Domain and external isolation: the instance to show. */
362
+ /**
363
+ * Domain and external isolation: the instance to show. Opaque: the host's own name for what it
364
+ * shows, for its confirmations only, never sent to the frame (P077).
365
+ */
363
366
  readonly instance?: InstanceRef;
364
367
  /** The color scheme it shows in. Default: the provider's `scheme`, else light. */
365
368
  readonly scheme?: ColorScheme;
@@ -715,7 +718,14 @@ function Mount({ frame, page, initialHeightPx, placeholder, run }: MountProps):
715
718
  ? {
716
719
  confirm: (request: ConfirmRequest, proceed: Proceed) =>
717
720
  (latest().confirm ?? pageConfirm ?? (() => Promise.resolve(false)))(
718
- { ...request, display: { id: latest().displayId, title: latest().title } },
721
+ {
722
+ ...request,
723
+ display: {
724
+ ...request.display,
725
+ id: latest().displayId,
726
+ title: latest().title,
727
+ },
728
+ },
719
729
  proceed,
720
730
  ),
721
731
  }
@@ -37,7 +37,10 @@ export interface PortholeViewProps extends Omit<
37
37
  > {
38
38
  /** The display kind (`defineDisplays`). */
39
39
  readonly display: string;
40
- /** The instance to show while frames are served. */
40
+ /**
41
+ * The instance: what a served frame shows; for an opaque one, the host's own name for it, given
42
+ * back in its confirmations only, never sent to the frame (P077).
43
+ */
41
44
  readonly instance?: InstanceRef;
42
45
  /**
43
46
  * The content: a served shell's to draw, and what an opaque frame shows while frames aren't
@@ -144,7 +147,7 @@ export function PortholeView(props: PortholeViewProps): ReactElement | null {
144
147
  {...frame}
145
148
  config={config}
146
149
  generation={(frame.generation ?? 0) + generation}
147
- {...(served && instance !== undefined ? { instance } : {})}
150
+ {...(instance === undefined ? {} : { instance })}
148
151
  {...(content === undefined ? {} : { content })}
149
152
  onOutcome={(outcome: FrameOutcome) => {
150
153
  onOutcome?.(outcome);
@@ -311,7 +311,10 @@ export interface ContentHost<V> {
311
311
  ): (request: Request) => Promise<Response>;
312
312
  /** A url-mode app's access for a WebSocket upgrade (`server.access`), or null. */
313
313
  access(request: Request): Promise<Access | null>;
314
- /** Starts the health gate (after the app listens). */
314
+ /**
315
+ * Starts the health gate (after the app listens). Once: starting a started host does nothing,
316
+ * so the app and `nodeServer` may both start it (P076). After `close`, it starts again.
317
+ */
315
318
  start(): void;
316
319
  /** Runs one health check now. */
317
320
  check(): Promise<ContentHealthView>;
@@ -533,6 +536,7 @@ export function createContentHost<V>(options: ContentHostOptions<V>): ContentHos
533
536
  let timer: ReturnType<typeof setTimeout> | null = null;
534
537
  let running: Promise<ContentHealthView> | null = null;
535
538
  let closed = false;
539
+ let started = false;
536
540
  const schedule = () => {
537
541
  if (closed || gate === undefined || view.misconfigured === true || domain === null) {
538
542
  return;
@@ -1114,12 +1118,17 @@ export function createContentHost<V>(options: ContentHostOptions<V>): ContentHos
1114
1118
  access: async (request) => (server === null ? null : server.access(request)),
1115
1119
 
1116
1120
  start() {
1121
+ if (started) {
1122
+ return;
1123
+ }
1124
+ started = true;
1117
1125
  closed = false;
1118
1126
  void check();
1119
1127
  },
1120
1128
  check,
1121
1129
  close() {
1122
1130
  closed = true;
1131
+ started = false;
1123
1132
  if (timer !== null) {
1124
1133
  clearTimeout(timer);
1125
1134
  timer = null;