Skip to content

Commit

Permalink
Merge pull request #62 from adobe/oncallevent2
Browse files Browse the repository at this point in the history
Oncallevent2
  • Loading branch information
kokoc authored Jun 13, 2024
2 parents 3533795 + 574ec39 commit d8b6b0b
Show file tree
Hide file tree
Showing 24 changed files with 711 additions and 47 deletions.
8 changes: 4 additions & 4 deletions docs/api-report/uix-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ export type GuestConnectionEvent<Type extends string = string, Detail = Record<s
// Warning: (ae-incompatible-release-tags) The symbol "GuestConnectionEvents" is marked as @public, but its signature references "HostMethodAddress" which is marked as @internal
//
// @public (undocumented)
export type GuestConnectionEvents<HostApi extends Record<string, unknown> = Record<string, unknown>> = GuestConnectionEvent<"hostprovide"> | GuestConnectionEvent<"unload"> | GuestConnectionEvent<"beforecallhostmethod", HostMethodAddress<HostApi>> | GuestConnectionEvent<"guestresize", {
export type GuestConnectionEvents<HostApi extends Record<string, unknown> = Record<string, unknown>> = GuestConnectionEvent<"hostprovide"> | GuestConnectionEvent<"unload"> | GuestConnectionEvent<"beforecallhostmethod", HostMethodAddress<HostApi>> | GuestConnectionEvent<"beforecallguestmethod"> | GuestConnectionEvent<"guestresize", {
dimensions: UIFrameRect;
iframe: HTMLIFrameElement;
}>;

// @internal (undocumented)
export type GuestEmitter = GuestConnection & Emits<GuestConnectionEvents>;

// @public (undocumented)
// @internal (undocumented)
export type GuestMetadata = Record<string, any>;

// @internal
Expand Down Expand Up @@ -264,7 +264,7 @@ export function wait(ms: number): Promise<unknown>;
// src/debuglog.ts:98:1 - (ae-forgotten-export) The symbol "Colors" needs to be exported by the entry point index.d.ts
// src/debuglog.ts:98:1 - (ae-forgotten-export) The symbol "Layouts" needs to be exported by the entry point index.d.ts
// src/debuglog.ts:181:21 - (ae-forgotten-export) The symbol "stateTypes" needs to be exported by the entry point index.d.ts
// src/types.ts:208:7 - (ae-incompatible-release-tags) The symbol "guestPort" is marked as @public, but its signature references "GuestConnection" which is marked as @internal
// src/types.ts:221:9 - (ae-incompatible-release-tags) The symbol "dimensions" is marked as @public, but its signature references "UIFrameRect" which is marked as @internal
// src/types.ts:211:7 - (ae-incompatible-release-tags) The symbol "guestPort" is marked as @public, but its signature references "GuestConnection" which is marked as @internal
// src/types.ts:225:9 - (ae-incompatible-release-tags) The symbol "dimensions" is marked as @public, but its signature references "UIFrameRect" which is marked as @internal

```
7 changes: 3 additions & 4 deletions docs/api-report/uix-host.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class Host extends Emitter<HostEvents> {
// @public (undocumented)
export interface HostConfig {
debug?: boolean;
disableMetrics?: boolean;
guestOptions?: PortOptions;
hostName: string;
runtimeContainer?: HTMLElement;
Expand Down Expand Up @@ -151,7 +152,7 @@ export type HostEvents = HostGuestEvent<"beforeload"> | HostGuestEvent<"load"> |
export type InstalledExtensions = Record<Extension["id"], Extension["url"] | Extension>;

// @internal
export const makeSandboxAttrs: (...sandboxes: AttrTokens<SandboxToken>[]) => ("allow-presentation" | "allow-same-origin" | "allow-downloads" | "allow-orientation-lock" | "allow-pointer-lock" | "allow-popups" | "allow-scripts" | "allow-storage-access-by-user-activation" | "allow-top-navigation-by-user-activation")[];
export const makeSandboxAttrs: (...sandboxes: AttrTokens<SandboxToken>[]) => ("allow-same-origin" | "allow-presentation" | "allow-downloads" | "allow-orientation-lock" | "allow-pointer-lock" | "allow-popups" | "allow-scripts" | "allow-storage-access-by-user-activation" | "allow-top-navigation-by-user-activation")[];

// @internal
export const mergeAttrValues: <T>(...tokenLists: AttrTokens<T>[]) => T[];
Expand All @@ -177,9 +178,7 @@ export class Port<GuestApi = unknown> extends Emitter<GuestConnectionEvents> imp
events: Emits;
});
// (undocumented)
get apis(): {
[x: string]: {};
};
get apis(): RemoteHostApis<VirtualApi>;
attachUI<T = unknown>(iframe: HTMLIFrameElement, privateMethods: VirtualApi): Promise<CrossRealmObject<T>>;
error?: Error;
// (undocumented)
Expand Down
2 changes: 1 addition & 1 deletion docs/markdown/uix-core.guestconnectionevents.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
**Signature:**

```typescript
export declare type GuestConnectionEvents<HostApi extends Record<string, unknown> = Record<string, unknown>> = GuestConnectionEvent<"hostprovide"> | GuestConnectionEvent<"unload"> | GuestConnectionEvent<"beforecallhostmethod", HostMethodAddress<HostApi>> | GuestConnectionEvent<"guestresize", {
export declare type GuestConnectionEvents<HostApi extends Record<string, unknown> = Record<string, unknown>> = GuestConnectionEvent<"hostprovide"> | GuestConnectionEvent<"unload"> | GuestConnectionEvent<"beforecallhostmethod", HostMethodAddress<HostApi>> | GuestConnectionEvent<"beforecallguestmethod"> | GuestConnectionEvent<"guestresize", {
dimensions: UIFrameRect;
iframe: HTMLIFrameElement;
}>;
Expand Down
11 changes: 0 additions & 11 deletions docs/markdown/uix-core.guestmetadata.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/markdown/uix-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ Core utilities, types and contracts for the Adobe UIX SDK.
| --- | --- |
| [GuestConnectionEvent](./uix-core.guestconnectionevent.md) | |
| [GuestConnectionEvents](./uix-core.guestconnectionevents.md) | |
| [GuestMetadata](./uix-core.guestmetadata.md) | |

2 changes: 1 addition & 1 deletion docs/markdown/uix-guest.guestconfigwithmethods.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ declare type GuestConfigWithMethods<Outgoing extends GuestApis> = GuestConfig &
metadata?: GuestMetadata;
};
```
**References:** [GuestConfig](./uix-guest.guestconfig.md)<!-- -->, [GuestMetadata](./uix-core.guestmetadata.md)
**References:** [GuestConfig](./uix-guest.guestconfig.md)

2 changes: 1 addition & 1 deletion docs/markdown/uix-guest.guestserver.getlocalmethods.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ protected getLocalMethods(): {
```
**Returns:**

{ apis: Outgoing; metadata: [GuestMetadata](./uix-core.guestmetadata.md)<!-- -->; emit: (type: "contextchange" \| "beforeconnect" \| "connected" \| "error", detail: ({ context: Record&lt;string, unknown&gt;; } &amp; Record&lt;string, unknown&gt; &amp; { guest: Guest&lt;import("@adobe/uix-core").VirtualApi&gt;; }) \| (Record&lt;string, unknown&gt; &amp; { guest: Guest&lt;import("@adobe/uix-core").VirtualApi&gt;; }) \| ({ error: Error; } &amp; Record&lt;string, unknown&gt; &amp; { guest: Guest&lt;import("@adobe/uix-core").VirtualApi&gt;; })) =&gt; void; }
{ apis: Outgoing; metadata: GuestMetadata; emit: (type: "contextchange" \| "beforeconnect" \| "connected" \| "error", detail: ({ context: Record&lt;string, unknown&gt;; } &amp; Record&lt;string, unknown&gt; &amp; { guest: Guest&lt;import("@adobe/uix-core").VirtualApi&gt;; }) \| (Record&lt;string, unknown&gt; &amp; { guest: Guest&lt;import("@adobe/uix-core").VirtualApi&gt;; }) \| ({ error: Error; } &amp; Record&lt;string, unknown&gt; &amp; { guest: Guest&lt;import("@adobe/uix-core").VirtualApi&gt;; })) =&gt; void; }

2 changes: 1 addition & 1 deletion docs/markdown/uix-guest.guestserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This is the Guest object returned from [register()](./uix-guest.register.md)<!--
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [host](./uix-guest.guestserver.host.md) | | Guest&lt;Outgoing&gt;\["host"\] | Proxy object for calling methods on the host. |
| [metadata](./uix-guest.guestserver.metadata.md) | | [GuestMetadata](./uix-core.guestmetadata.md) | |
| [metadata](./uix-guest.guestserver.metadata.md) | | GuestMetadata | |
| [sharedContext](./uix-guest.guestserver.sharedcontext.md) | | [SharedContext](./uix-guest.sharedcontext.md) | |
## Methods
Expand Down
2 changes: 1 addition & 1 deletion docs/markdown/uix-guest.guestserver.register.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ register(implementedMethods: Outgoing, metadata: GuestMetadata): Promise<void>;
| Parameter | Type | Description |
| --- | --- | --- |
| implementedMethods | Outgoing | |
| metadata | [GuestMetadata](./uix-core.guestmetadata.md) | |
| metadata | GuestMetadata | |

**Returns:**

Expand Down
13 changes: 13 additions & 0 deletions docs/markdown/uix-host.hostconfig.disablemetrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@adobe/uix-host](./uix-host.md) &gt; [HostConfig](./uix-host.hostconfig.md) &gt; [disableMetrics](./uix-host.hostconfig.disablemetrics.md)

## HostConfig.disableMetrics property

Disables built-in metrics of UIX SDK

**Signature:**

```typescript
disableMetrics?: boolean;
```
1 change: 1 addition & 0 deletions docs/markdown/uix-host.hostconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface HostConfig
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [debug?](./uix-host.hostconfig.debug.md) | | boolean | _(Optional)_ Copiously log lifecycle events. |
| [disableMetrics?](./uix-host.hostconfig.disablemetrics.md) | | boolean | _(Optional)_ Disables built-in metrics of UIX SDK |
| [guestOptions?](./uix-host.hostconfig.guestoptions.md) | | [PortOptions](./uix-host.portoptions.md) | <p>_(Optional)_ Default options to use for every guest Port.</p><p>If <code>config.debug</code> is true, then the guest options will have <code>debug: true</code> unless <code>debug: false</code> is explicitly passed in <code>guestOptions</code>.</p> |
| [hostName](./uix-host.hostconfig.hostname.md) | | string | Human-readable "slug" name of the extensible area--often an entire app. This string serves as a namespace for extension points within the area. |
| [runtimeContainer?](./uix-host.hostconfig.runtimecontainer.md) | | HTMLElement | _(Optional)_ A DOM element \_outside\_ of the React root. This is necessary to preserve the lifetime of the iframes which are running extension objects; if they live inside the React root, then React could unexpectedly re-render the iframe tags themselves at any time, causing a reload of the frame. |
Expand Down
4 changes: 1 addition & 3 deletions docs/markdown/uix-host.port.apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
**Signature:**

```typescript
get apis(): {
[x: string]: {};
};
get apis(): RemoteHostApis<VirtualApi>;
```
4 changes: 2 additions & 2 deletions docs/markdown/uix-host.port.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ When the Host object loads extensions via [Host.load()](./uix-host.host.load.md)
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [apis](./uix-host.port.apis.md) | <code>readonly</code> | { \[x: string\]: {}; } | |
| [apis](./uix-host.port.apis.md) | <code>readonly</code> | RemoteHostApis&lt;VirtualApi&gt; | |
| [error?](./uix-host.port.error.md) | | Error | _(Optional)_ If any errors occurred during the loading of guests, this property will contain the error that was raised. |
| [extensionPoints](./uix-host.port.extensionpoints.md) | | string\[\] | |
| [metadata](./uix-host.port.metadata.md) | <code>readonly</code> | [GuestMetadata](./uix-core.guestmetadata.md) | |
| [metadata](./uix-host.port.metadata.md) | <code>readonly</code> | GuestMetadata | |
| [url](./uix-host.port.url.md) | | URL | The URL of the guest provided by the extension registry. The Host will load this URL in the background, in the invisible the bootstrap frame, so this URL must point to a page that calls [register()](./uix-guest.register.md) when it loads. |
## Methods
Expand Down
8 changes: 3 additions & 5 deletions examples/host-vite-react-frames/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ import {
View,
ProgressCircle,
} from "@adobe/react-spectrum";
import { useHost, useExtensions, GuestUIFrame } from "@adobe/uix-host-react";
import { useExtensions, GuestUIFrame } from "@adobe/uix-host-react";
import React, { useCallback, useEffect, useMemo, useReducer, useState } from "react";

function App() {
const [urls, setUrls] = useState(undefined);
const { host } = useHost();


const { extensions } = useExtensions(() => ({
updateOn: "each",
updateOn: "all",
requires: {
frame: ["getUrls"]
}
Expand All @@ -45,7 +43,7 @@ function App() {
}))
setUrls(fetchedUrls);
}
});
}, [extensions]);

useEffect(() => {
fetchUrls().catch(e => console.error(e))
Expand Down
Loading

0 comments on commit d8b6b0b

Please sign in to comment.