@egen-civitas/esm-embed-testing 0.8.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @egen-civitas/esm-embed-testing
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 772b92a: Intents (lot C4) — briques communes. `esm-embed-protocol` : `expandIntentPath(gabarit, params)` remplace les paramètres `:nom` du chemin d'un intent (`provides[].path`) par des valeurs encodées ; paramètre manquant ou de type refusé ⇒ échec explicite, aucune valeur ne sort de son segment. `esm-embed-testing` : option `intents` de `createTestHost` (`navigation.intent` servie, `NOT_FOUND` si inconnu). `sdk` : `createTestShell` sert par défaut les intents déclarés dans `provides` du manifeste (sous `/<route>`), ou une table fournie, ou `intents: false`.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [772b92a]
12
+ - @egen-civitas/esm-embed-protocol@0.13.0
13
+ - @egen-civitas/esm-embed-client@0.13.1
14
+ - @egen-civitas/esm-embed-host@0.12.2
15
+
16
+ ## 0.9.0
17
+
18
+ ### Minor Changes
19
+
20
+ - 94ab5bd: B12 — `createTestShell` (sous-chemin `@egen-civitas/sdk/testing`) : Shell simulé pour tester une app EGEN dans le mode `embedded` (vrai `HostConnection` en mémoire) ou `standalone`, sans navigateur ni Core. Expose `app`, `calls`, `notifications`, `published`, `provide`, `emit.*`, `hostDown`, `advance`, `destroy` ; valide le manifeste comme le Shell. `createTestHost` gagne l'option `providers`, `providers` (fournisseurs vivants) et `hostDown()`. `@egen-civitas/esm-embed-testing` devient pair facultatif du SDK.
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [6e10d7e]
25
+ - Updated dependencies [1e5122b]
26
+ - @egen-civitas/esm-embed-host@0.12.1
27
+
3
28
  ## 0.8.0
4
29
 
5
30
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  import { type ApprovedGrants, type CapabilityId, type EffectiveIframeRights, type GrantConfig, type IframeRights } from '@egen-civitas/esm-embed-protocol';
2
2
  import type { ConnectOptions } from '@egen-civitas/esm-embed-client';
3
- import { HostConnection, type ExtensionInfo } from '@egen-civitas/esm-embed-host';
3
+ import { HostConnection, type ExtensionInfo, type HostProviders } from '@egen-civitas/esm-embed-host';
4
4
  export interface TestHostOptions {
5
5
  moduleName?: string;
6
6
  /** Origine simulée du Shell (à mettre dans `hostOrigins` de l'app). */
@@ -24,6 +24,17 @@ export interface TestHostOptions {
24
24
  message: string;
25
25
  danger?: boolean;
26
26
  }) => boolean);
27
+ /**
28
+ * Fournisseurs du Shell qui remplacent ceux du simulateur (par capacité), y compris les facultatifs que le simulateur ne sert pas
29
+ * (`environment`, `locale.set`, `dialogs.alert`, `routeExists`, `intents`…). Les facultatifs doivent être fournis AVANT la connexion :
30
+ * la table des capacités est construite à la poignée de main.
31
+ */
32
+ providers?: Partial<HostProviders>;
33
+ /**
34
+ * Table d'intents du Shell simulé : `objet-action` → chemin du Shell, ou `null` (intent inconnu : `NOT_FOUND`).
35
+ * Absente : `navigation.intent` n'est pas servie (`UNKNOWN_METHOD`), comme sur un Shell sans table d'intents.
36
+ */
37
+ intents?: (slug: string, params: Record<string, unknown>) => string | null | Promise<string | null>;
27
38
  }
28
39
  export interface CallRecord {
29
40
  cap: string;
@@ -34,6 +45,8 @@ export interface TestHost {
34
45
  /** À passer à `connectToEgen({ ...host.connectOptions, capabilities: [...] })`. */
35
46
  connectOptions: Pick<ConnectOptions, 'moduleName' | 'hostOrigins' | 'window' | 'host' | 'timeoutMs'>;
36
47
  connection: HostConnection;
48
+ /** Fournisseurs vivants du Shell : `Object.assign(host.providers, …)` remplace le comportement d'une capacité déjà servie, à chaud. */
49
+ providers: HostProviders;
37
50
  /** Droits d'iframe que le Core appliquerait (`demande ∩ plafond`) : de quoi vérifier ce que l'app obtient réellement. */
38
51
  iframe: EffectiveIframeRights;
39
52
  /** Journal des services du Core sollicités par l'app. */
@@ -61,6 +74,8 @@ export interface TestHost {
61
74
  goto(path: string): void;
62
75
  visibility(visible: boolean): void;
63
76
  };
77
+ /** Coupe la liaison côté Shell (comme un Shell qui disparaît) : les appels suivants de l'app sont rejetés. */
78
+ hostDown(): void;
64
79
  destroy(): void;
65
80
  }
66
81
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"test-host.d.ts","sourceRoot":"","sources":["../src/test-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,qBAAqB,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC7L,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAa,cAAc,EAAE,KAAK,aAAa,EAAsB,MAAM,8BAA8B,CAAC;AAEjH,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oHAAoH;IACpH,oBAAoB,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;IAClE,2EAA2E;IAC3E,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,sIAAsI;IACtI,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,OAAO,GAAG,CA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C;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpE,iEAAiE;IACjE,IAAI,EAAE;QACJ,MAAM,CAAC,CAAC,EAAE;YAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,GAAG,IAAI,CAAC;QACvC,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;QACtD,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QACzC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;QAC9C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;KACpC,CAAC;IACF,8GAA8G;IAC9G,QAAQ,IAAI,IAAI,CAAC;IACjB,OAAO,IAAI,IAAI,CAAC;CACjB;AAeD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAE,eAAoB,GAAG,QAAQ,CA8IhE"}
package/dist/test-host.js CHANGED
@@ -1,4 +1,184 @@
1
- import { effectiveGrants, effectiveIframe } from '@egen-civitas/esm-embed-protocol';
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _define_property(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
43
+ function _object_spread(target) {
44
+ for(var i = 1; i < arguments.length; i++){
45
+ var source = arguments[i] != null ? arguments[i] : {};
46
+ var ownKeys = Object.keys(source);
47
+ if (typeof Object.getOwnPropertySymbols === "function") {
48
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
+ }));
51
+ }
52
+ ownKeys.forEach(function(key) {
53
+ _define_property(target, key, source[key]);
54
+ });
55
+ }
56
+ return target;
57
+ }
58
+ function ownKeys(object, enumerableOnly) {
59
+ var keys = Object.keys(object);
60
+ if (Object.getOwnPropertySymbols) {
61
+ var symbols = Object.getOwnPropertySymbols(object);
62
+ if (enumerableOnly) {
63
+ symbols = symbols.filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
+ });
66
+ }
67
+ keys.push.apply(keys, symbols);
68
+ }
69
+ return keys;
70
+ }
71
+ function _object_spread_props(target, source) {
72
+ source = source != null ? source : {};
73
+ if (Object.getOwnPropertyDescriptors) {
74
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
75
+ } else {
76
+ ownKeys(Object(source)).forEach(function(key) {
77
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78
+ });
79
+ }
80
+ return target;
81
+ }
82
+ function _ts_generator(thisArg, body) {
83
+ var f, y, t, _ = {
84
+ label: 0,
85
+ sent: function() {
86
+ if (t[0] & 1) throw t[1];
87
+ return t[1];
88
+ },
89
+ trys: [],
90
+ ops: []
91
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
92
+ return d(g, "next", {
93
+ value: verb(0)
94
+ }), d(g, "throw", {
95
+ value: verb(1)
96
+ }), d(g, "return", {
97
+ value: verb(2)
98
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
99
+ value: function() {
100
+ return this;
101
+ }
102
+ }), g;
103
+ function verb(n) {
104
+ return function(v) {
105
+ return step([
106
+ n,
107
+ v
108
+ ]);
109
+ };
110
+ }
111
+ function step(op) {
112
+ if (f) throw new TypeError("Generator is already executing.");
113
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
114
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
115
+ if (y = 0, t) op = [
116
+ op[0] & 2,
117
+ t.value
118
+ ];
119
+ switch(op[0]){
120
+ case 0:
121
+ case 1:
122
+ t = op;
123
+ break;
124
+ case 4:
125
+ _.label++;
126
+ return {
127
+ value: op[1],
128
+ done: false
129
+ };
130
+ case 5:
131
+ _.label++;
132
+ y = op[1];
133
+ op = [
134
+ 0
135
+ ];
136
+ continue;
137
+ case 7:
138
+ op = _.ops.pop();
139
+ _.trys.pop();
140
+ continue;
141
+ default:
142
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
143
+ _ = 0;
144
+ continue;
145
+ }
146
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
147
+ _.label = op[1];
148
+ break;
149
+ }
150
+ if (op[0] === 6 && _.label < t[1]) {
151
+ _.label = t[1];
152
+ t = op;
153
+ break;
154
+ }
155
+ if (t && _.label < t[2]) {
156
+ _.label = t[2];
157
+ _.ops.push(op);
158
+ break;
159
+ }
160
+ if (t[2]) _.ops.pop();
161
+ _.trys.pop();
162
+ continue;
163
+ }
164
+ op = body.call(thisArg, _);
165
+ } catch (e) {
166
+ op = [
167
+ 6,
168
+ e
169
+ ];
170
+ y = 0;
171
+ } finally{
172
+ f = t = 0;
173
+ }
174
+ if (op[0] & 5) throw op[1];
175
+ return {
176
+ value: op[0] ? op[1] : void 0,
177
+ done: true
178
+ };
179
+ }
180
+ }
181
+ import { effectiveGrants, effectiveIframe, EmbedError } from '@egen-civitas/esm-embed-protocol';
2
182
  import { createBus, HostConnection } from '@egen-civitas/esm-embed-host';
3
183
  function watchable(initial) {
4
184
  var value = initial;
@@ -142,6 +322,7 @@ function watchable(initial) {
142
322
  }
143
323
  }
144
324
  };
325
+ if (o.providers) Object.assign(providers, o.providers);
145
326
  var appWindow = new EventTarget();
146
327
  var hostWindow = {
147
328
  postMessage: function postMessage(message) {
@@ -154,14 +335,45 @@ function watchable(initial) {
154
335
  moduleName: moduleName,
155
336
  grants: effectiveGrants(o.manifestCapabilities, (_o_approved = o.approved) !== null && _o_approved !== void 0 ? _o_approved : {}),
156
337
  providers: providers,
157
- controls: {
338
+ controls: _object_spread_props(_object_spread({
158
339
  channel: channel,
159
340
  report: function report(p) {
160
341
  return log('navigation', 'report', p);
161
342
  },
162
343
  navigate: function navigate(t) {
163
344
  return log('navigation', 'navigate', t);
164
- },
345
+ }
346
+ }, o.intents ? {
347
+ intent: function intent(slug, params) {
348
+ return _async_to_generator(function() {
349
+ var target;
350
+ return _ts_generator(this, function(_state) {
351
+ switch(_state.label){
352
+ case 0:
353
+ log('navigation', 'intent', {
354
+ slug: slug,
355
+ params: params !== null && params !== void 0 ? params : {}
356
+ });
357
+ return [
358
+ 4,
359
+ o.intents(slug, params !== null && params !== void 0 ? params : {})
360
+ ];
361
+ case 1:
362
+ target = _state.sent();
363
+ if (target === null) throw new EmbedError('NOT_FOUND', "Intent inconnu : ".concat(slug));
364
+ log('navigation', 'navigate', target);
365
+ return [
366
+ 2,
367
+ {
368
+ status: 'done',
369
+ path: target
370
+ }
371
+ ];
372
+ }
373
+ });
374
+ })();
375
+ }
376
+ } : {}), {
165
377
  notFound: function notFound(p) {
166
378
  return log('navigation', 'notFound', p !== null && p !== void 0 ? p : null);
167
379
  },
@@ -174,7 +386,7 @@ function watchable(initial) {
174
386
  onReady: function onReady() {
175
387
  return log('lifecycle', 'ready');
176
388
  }
177
- },
389
+ }),
178
390
  limits: {
179
391
  pingIntervalMs: 0
180
392
  },
@@ -200,6 +412,7 @@ function watchable(initial) {
200
412
  timeoutMs: 500
201
413
  },
202
414
  connection: connection,
415
+ providers: providers,
203
416
  iframe: effectiveIframe(o.manifestIframe, (_o_approved1 = o.approved) === null || _o_approved1 === void 0 ? void 0 : _o_approved1.iframe),
204
417
  calls: calls,
205
418
  notifications: notifications,
@@ -237,6 +450,9 @@ function watchable(initial) {
237
450
  return channel.emit('visibility', v);
238
451
  }
239
452
  },
453
+ hostDown: function hostDown() {
454
+ return connection.reset();
455
+ },
240
456
  destroy: function destroy() {
241
457
  return connection.destroy();
242
458
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egen-civitas/esm-embed-testing",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Développer et tester une app embarquée sans le Core : hôte de test en mémoire, suite de conformité du protocole v2, simulateur de Shell (egen-embed-sim).",
6
6
  "type": "module",
@@ -76,9 +76,9 @@
76
76
  "vitest": "^4.1.2"
77
77
  },
78
78
  "dependencies": {
79
- "@egen-civitas/esm-embed-client": "^0.13.0",
80
- "@egen-civitas/esm-embed-host": "^0.12.0",
81
- "@egen-civitas/esm-embed-protocol": "^0.12.0"
79
+ "@egen-civitas/esm-embed-client": "^0.13.1",
80
+ "@egen-civitas/esm-embed-host": "^0.12.2",
81
+ "@egen-civitas/esm-embed-protocol": "^0.13.0"
82
82
  },
83
83
  "bin": {
84
84
  "egen-embed-check": "bin/egen-embed-check.mjs",
package/src/test-host.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { effectiveGrants, effectiveIframe, type ApprovedGrants, type CapabilityId, type EffectiveIframeRights, type GrantConfig, type IframeRights } from '@egen-civitas/esm-embed-protocol';
1
+ import { effectiveGrants, effectiveIframe, EmbedError, type ApprovedGrants, type CapabilityId, type EffectiveIframeRights, type GrantConfig, type IframeRights } from '@egen-civitas/esm-embed-protocol';
2
2
  import type { ConnectOptions } from '@egen-civitas/esm-embed-client';
3
3
  import { createBus, HostConnection, type ExtensionInfo, type HostProviders } from '@egen-civitas/esm-embed-host';
4
4
 
@@ -19,6 +19,17 @@ export interface TestHostOptions {
19
19
  /** Extensions attachées à chaque slot (`{ 'topbar-nav-slot': [...] }`). */
20
20
  extensions?: Record<string, ExtensionInfo[]>;
21
21
  confirm?: boolean | ((d: { title: string; message: string; danger?: boolean }) => boolean);
22
+ /**
23
+ * Fournisseurs du Shell qui remplacent ceux du simulateur (par capacité), y compris les facultatifs que le simulateur ne sert pas
24
+ * (`environment`, `locale.set`, `dialogs.alert`, `routeExists`, `intents`…). Les facultatifs doivent être fournis AVANT la connexion :
25
+ * la table des capacités est construite à la poignée de main.
26
+ */
27
+ providers?: Partial<HostProviders>;
28
+ /**
29
+ * Table d'intents du Shell simulé : `objet-action` → chemin du Shell, ou `null` (intent inconnu : `NOT_FOUND`).
30
+ * Absente : `navigation.intent` n'est pas servie (`UNKNOWN_METHOD`), comme sur un Shell sans table d'intents.
31
+ */
32
+ intents?: (slug: string, params: Record<string, unknown>) => string | null | Promise<string | null>;
22
33
  }
23
34
 
24
35
  export interface CallRecord {
@@ -31,6 +42,8 @@ export interface TestHost {
31
42
  /** À passer à `connectToEgen({ ...host.connectOptions, capabilities: [...] })`. */
32
43
  connectOptions: Pick<ConnectOptions, 'moduleName' | 'hostOrigins' | 'window' | 'host' | 'timeoutMs'>;
33
44
  connection: HostConnection;
45
+ /** Fournisseurs vivants du Shell : `Object.assign(host.providers, …)` remplace le comportement d'une capacité déjà servie, à chaud. */
46
+ providers: HostProviders;
34
47
  /** Droits d'iframe que le Core appliquerait (`demande ∩ plafond`) : de quoi vérifier ce que l'app obtient réellement. */
35
48
  iframe: EffectiveIframeRights;
36
49
  /** Journal des services du Core sollicités par l'app. */
@@ -47,6 +60,8 @@ export interface TestHost {
47
60
  goto(path: string): void;
48
61
  visibility(visible: boolean): void;
49
62
  };
63
+ /** Coupe la liaison côté Shell (comme un Shell qui disparaît) : les appels suivants de l'app sont rejetés. */
64
+ hostDown(): void;
50
65
  destroy(): void;
51
66
  }
52
67
 
@@ -150,6 +165,8 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
150
165
  telemetry: { log: (l, m, c) => log('telemetry', 'log', l, m, c), metric: (n, v, t) => log('telemetry', 'metric', n, v, t) },
151
166
  };
152
167
 
168
+ if (o.providers) Object.assign(providers, o.providers);
169
+
153
170
  const appWindow = new EventTarget();
154
171
  const hostWindow: { postMessage(message: unknown, targetOrigin: string): void } = {
155
172
  postMessage: (message) => void queueMicrotask(() => connection.handle(message)),
@@ -162,6 +179,17 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
162
179
  channel,
163
180
  report: (p) => log('navigation', 'report', p),
164
181
  navigate: (t) => log('navigation', 'navigate', t),
182
+ ...(o.intents
183
+ ? {
184
+ intent: async (slug: string, params?: Record<string, unknown>) => {
185
+ log('navigation', 'intent', { slug, params: params ?? {} });
186
+ const target = await o.intents!(slug, params ?? {});
187
+ if (target === null) throw new EmbedError('NOT_FOUND', `Intent inconnu : ${slug}`);
188
+ log('navigation', 'navigate', target);
189
+ return { status: 'done' as const, path: target };
190
+ },
191
+ }
192
+ : {}),
165
193
  notFound: (p) => log('navigation', 'notFound', p ?? null),
166
194
  setTitle: (t) => log('navigation', 'setTitle', t),
167
195
  resize: (h) => log('navigation', 'resize', h),
@@ -181,6 +209,7 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
181
209
  return {
182
210
  connectOptions: { moduleName, hostOrigins: [origin], window: appWindow as any, host: hostWindow as any, timeoutMs: 500 },
183
211
  connection,
212
+ providers,
184
213
  iframe: effectiveIframe(o.manifestIframe, o.approved?.iframe),
185
214
  calls,
186
215
  notifications,
@@ -197,6 +226,7 @@ export function createTestHost(o: TestHostOptions = {}): TestHost {
197
226
  goto: (path) => channel.emit('goto', { path, seq: Date.now() }),
198
227
  visibility: (v) => channel.emit('visibility', v),
199
228
  },
229
+ hostDown: () => connection.reset(),
200
230
  destroy: () => connection.destroy(),
201
231
  };
202
232
  }