From 0c88fe0dccdb4e0da88c02e16f5b06cca929a450 Mon Sep 17 00:00:00 2001 From: Andrii Konosov Date: Wed, 8 May 2024 16:38:06 -0500 Subject: [PATCH 1/6] New event to track guest calls - Added a new event `beforecallguestmethod` - Fixed warnings produced by TSdoc - Optimizations in iframes playground app - New event is added to default logger --- docs/api-report/uix-core.api.md | 8 +-- docs/api-report/uix-host.api.md | 6 +- .../uix-core.guestconnectionevents.md | 2 +- docs/markdown/uix-core.guestmetadata.md | 11 ---- docs/markdown/uix-core.md | 1 - .../uix-guest.guestconfigwithmethods.md | 2 +- .../uix-guest.guestserver.getlocalmethods.md | 2 +- docs/markdown/uix-guest.guestserver.md | 2 +- .../uix-guest.guestserver.register.md | 2 +- docs/markdown/uix-host.port.apis.md | 4 +- docs/markdown/uix-host.port.md | 4 +- examples/host-vite-react-frames/src/App.jsx | 8 +-- packages/uix-core/src/types.ts | 4 ++ packages/uix-guest/src/guest-ui.ts | 3 +- packages/uix-guest/src/guest.ts | 8 +-- packages/uix-host/src/debug-host.ts | 3 + packages/uix-host/src/port.ts | 65 ++++++++++++++++++- 17 files changed, 90 insertions(+), 45 deletions(-) delete mode 100644 docs/markdown/uix-core.guestmetadata.md diff --git a/docs/api-report/uix-core.api.md b/docs/api-report/uix-core.api.md index 0bb0099..ce8b134 100644 --- a/docs/api-report/uix-core.api.md +++ b/docs/api-report/uix-core.api.md @@ -136,7 +136,7 @@ export type GuestConnectionEvent = Record> = GuestConnectionEvent<"hostprovide"> | GuestConnectionEvent<"unload"> | GuestConnectionEvent<"beforecallhostmethod", HostMethodAddress> | GuestConnectionEvent<"guestresize", { +export type GuestConnectionEvents = Record> = GuestConnectionEvent<"hostprovide"> | GuestConnectionEvent<"unload"> | GuestConnectionEvent<"beforecallhostmethod", HostMethodAddress> | GuestConnectionEvent<"beforecallguestmethod"> | GuestConnectionEvent<"guestresize", { dimensions: UIFrameRect; iframe: HTMLIFrameElement; }>; @@ -144,7 +144,7 @@ export type GuestConnectionEvents = Reco // @internal (undocumented) export type GuestEmitter = GuestConnection & Emits; -// @public (undocumented) +// @internal (undocumented) export type GuestMetadata = Record; // @internal @@ -264,7 +264,7 @@ export function wait(ms: number): Promise; // 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 ``` diff --git a/docs/api-report/uix-host.api.md b/docs/api-report/uix-host.api.md index fed51cd..466303b 100644 --- a/docs/api-report/uix-host.api.md +++ b/docs/api-report/uix-host.api.md @@ -142,7 +142,7 @@ export type HostEvents = HostGuestEvent<"beforeload"> | HostGuestEvent<"load"> | export type InstalledExtensions = Record; // @internal -export const makeSandboxAttrs: (...sandboxes: AttrTokens[]) => ("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[]) => ("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: (...tokenLists: AttrTokens[]) => T[]; @@ -168,9 +168,7 @@ export class Port extends Emitter imp events: Emits; }); // (undocumented) - get apis(): { - [x: string]: {}; - }; + get apis(): any; attachUI(iframe: HTMLIFrameElement, privateMethods: VirtualApi): Promise>; error?: Error; // (undocumented) diff --git a/docs/markdown/uix-core.guestconnectionevents.md b/docs/markdown/uix-core.guestconnectionevents.md index 6115c9f..44b4564 100644 --- a/docs/markdown/uix-core.guestconnectionevents.md +++ b/docs/markdown/uix-core.guestconnectionevents.md @@ -8,7 +8,7 @@ **Signature:** ```typescript -export declare type GuestConnectionEvents = Record> = GuestConnectionEvent<"hostprovide"> | GuestConnectionEvent<"unload"> | GuestConnectionEvent<"beforecallhostmethod", HostMethodAddress> | GuestConnectionEvent<"guestresize", { +export declare type GuestConnectionEvents = Record> = GuestConnectionEvent<"hostprovide"> | GuestConnectionEvent<"unload"> | GuestConnectionEvent<"beforecallhostmethod", HostMethodAddress> | GuestConnectionEvent<"beforecallguestmethod"> | GuestConnectionEvent<"guestresize", { dimensions: UIFrameRect; iframe: HTMLIFrameElement; }>; diff --git a/docs/markdown/uix-core.guestmetadata.md b/docs/markdown/uix-core.guestmetadata.md deleted file mode 100644 index e9b6a7f..0000000 --- a/docs/markdown/uix-core.guestmetadata.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [@adobe/uix-core](./uix-core.md) > [GuestMetadata](./uix-core.guestmetadata.md) - -## GuestMetadata type - -**Signature:** - -```typescript -export declare type GuestMetadata = Record; -``` diff --git a/docs/markdown/uix-core.md b/docs/markdown/uix-core.md index 063780c..2b6971c 100644 --- a/docs/markdown/uix-core.md +++ b/docs/markdown/uix-core.md @@ -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) | | diff --git a/docs/markdown/uix-guest.guestconfigwithmethods.md b/docs/markdown/uix-guest.guestconfigwithmethods.md index 77b07c4..a23510e 100644 --- a/docs/markdown/uix-guest.guestconfigwithmethods.md +++ b/docs/markdown/uix-guest.guestconfigwithmethods.md @@ -13,5 +13,5 @@ declare type GuestConfigWithMethods = GuestConfig & metadata?: GuestMetadata; }; ``` -**References:** [GuestConfig](./uix-guest.guestconfig.md), [GuestMetadata](./uix-core.guestmetadata.md) +**References:** [GuestConfig](./uix-guest.guestconfig.md) diff --git a/docs/markdown/uix-guest.guestserver.getlocalmethods.md b/docs/markdown/uix-guest.guestserver.getlocalmethods.md index fa1a879..533ceba 100644 --- a/docs/markdown/uix-guest.guestserver.getlocalmethods.md +++ b/docs/markdown/uix-guest.guestserver.getlocalmethods.md @@ -25,5 +25,5 @@ protected getLocalMethods(): { ``` **Returns:** -{ apis: Outgoing; metadata: [GuestMetadata](./uix-core.guestmetadata.md); emit: (type: "contextchange" \| "beforeconnect" \| "connected" \| "error", detail: ({ context: Record<string, unknown>; } & Record<string, unknown> & { guest: Guest<import("@adobe/uix-core").VirtualApi>; }) \| (Record<string, unknown> & { guest: Guest<import("@adobe/uix-core").VirtualApi>; }) \| ({ error: Error; } & Record<string, unknown> & { guest: Guest<import("@adobe/uix-core").VirtualApi>; })) => void; } +{ apis: Outgoing; metadata: GuestMetadata; emit: (type: "contextchange" \| "beforeconnect" \| "connected" \| "error", detail: ({ context: Record<string, unknown>; } & Record<string, unknown> & { guest: Guest<import("@adobe/uix-core").VirtualApi>; }) \| (Record<string, unknown> & { guest: Guest<import("@adobe/uix-core").VirtualApi>; }) \| ({ error: Error; } & Record<string, unknown> & { guest: Guest<import("@adobe/uix-core").VirtualApi>; })) => void; } diff --git a/docs/markdown/uix-guest.guestserver.md b/docs/markdown/uix-guest.guestserver.md index 59d9b65..e344797 100644 --- a/docs/markdown/uix-guest.guestserver.md +++ b/docs/markdown/uix-guest.guestserver.md @@ -22,7 +22,7 @@ This is the Guest object returned from [register()](./uix-guest.register.md) + +[Home](./index.md) > [@adobe/uix-host](./uix-host.md) > [HostConfig](./uix-host.hostconfig.md) > [noMetrics](./uix-host.hostconfig.nometrics.md) + +## HostConfig.noMetrics property + +Disables built-in metrics of UIX SDK + +**Signature:** + +```typescript +noMetrics?: boolean; +``` diff --git a/docs/markdown/uix-host.port.apis.md b/docs/markdown/uix-host.port.apis.md index f371b2e..afb59d7 100644 --- a/docs/markdown/uix-host.port.apis.md +++ b/docs/markdown/uix-host.port.apis.md @@ -7,7 +7,5 @@ **Signature:** ```typescript -get apis(): { - [x: string]: {}; - }; +get apis(): RemoteHostApis; ``` diff --git a/docs/markdown/uix-host.port.md b/docs/markdown/uix-host.port.md index 9a806c1..2ed2c77 100644 --- a/docs/markdown/uix-host.port.md +++ b/docs/markdown/uix-host.port.md @@ -29,7 +29,7 @@ When the Host object loads extensions via [Host.load()](./uix-host.host.load.md) | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [apis](./uix-host.port.apis.md) | readonly | { \[x: string\]: {}; } | | +| [apis](./uix-host.port.apis.md) | readonly | RemoteHostApis<VirtualApi> | | | [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) | readonly | GuestMetadata | | diff --git a/package-lock.json b/package-lock.json index 758f87b..747b1ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "examples/*" ], "devDependencies": { + "@adobe/exc-app": "^1.4.0", "@adobe/react-spectrum": "^3.20.0", "@babel/core": "^7.18.10", "@babel/preset-env": "^7.18.10", @@ -135,6 +136,16 @@ "integrity": "sha512-rE0Pygv0sEZ4vBWHlAgJLGDU7Pm8xoO6p3wsEceb7GYAjScrOHpEo8KK/eVkAcnSM+slAEtXjA2JpdjLp4fJQQ==", "dev": true }, + "node_modules/@adobe/exc-app": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@adobe/exc-app/-/exc-app-1.4.0.tgz", + "integrity": "sha512-RVDQqTEmmOQvvzjFGxHXpBtsfvGERVyuHRh/30EFbSpChglA+hX8eoGuo6knhQsJnzUlgPpBLaU7ZSiFTaKkcQ==", + "dev": true, + "peerDependencies": { + "@apollo/client": "^3.8.9", + "graphql-tag": "^2.12.6" + } + }, "node_modules/@adobe/react-spectrum": { "version": "3.34.1", "resolved": "https://registry.npmjs.org/@adobe/react-spectrum/-/react-spectrum-3.34.1.tgz", @@ -233,6 +244,50 @@ "node": ">=6.0.0" } }, + "node_modules/@apollo/client": { + "version": "3.10.4", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.10.4.tgz", + "integrity": "sha512-51gk0xOwN6Ls1EbTG5svFva1kdm2APHYTzmFhaAdvUQoJFDxfc0UwQgDxGptzH84vkPlo1qunY1FuboyF9LI3Q==", + "dev": true, + "peer": true, + "dependencies": { + "@graphql-typed-document-node/core": "^3.1.1", + "@wry/caches": "^1.0.0", + "@wry/equality": "^0.5.6", + "@wry/trie": "^0.5.0", + "graphql-tag": "^2.12.6", + "hoist-non-react-statics": "^3.3.2", + "optimism": "^0.18.0", + "prop-types": "^15.7.2", + "rehackt": "^0.1.0", + "response-iterator": "^0.2.6", + "symbol-observable": "^4.0.0", + "ts-invariant": "^0.10.3", + "tslib": "^2.3.0", + "zen-observable-ts": "^1.2.5" + }, + "peerDependencies": { + "graphql": "^15.0.0 || ^16.0.0", + "graphql-ws": "^5.5.5", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", + "subscriptions-transport-ws": "^0.9.0 || ^0.11.0" + }, + "peerDependenciesMeta": { + "graphql-ws": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "subscriptions-transport-ws": { + "optional": true + } + } + }, "node_modules/@babel/code-frame": { "version": "7.23.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", @@ -2656,6 +2711,16 @@ "tslib": "^2.4.0" } }, + "node_modules/@graphql-typed-document-node/core": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz", + "integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==", + "dev": true, + "peer": true, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", @@ -9804,6 +9869,58 @@ "vite": "^3.0.0" } }, + "node_modules/@wry/caches": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@wry/caches/-/caches-1.0.1.tgz", + "integrity": "sha512-bXuaUNLVVkD20wcGBWRyo7j9N3TxePEWFZj2Y+r9OoUzfqmavM84+mFykRicNsBqatba5JLay1t48wxaXaWnlA==", + "dev": true, + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wry/context": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@wry/context/-/context-0.7.4.tgz", + "integrity": "sha512-jmT7Sb4ZQWI5iyu3lobQxICu2nC/vbUhP0vIdd6tHC9PTfenmRmuIFqktc6GH9cgi+ZHnsLWPvfSvc4DrYmKiQ==", + "dev": true, + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wry/equality": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.5.7.tgz", + "integrity": "sha512-BRFORjsTuQv5gxcXsuDXx6oGRhuVsEGwZy6LOzRRfgu+eSfxbhUQ9L9YtSEIuIjY/o7g3iWFjrc5eSY1GXP2Dw==", + "dev": true, + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wry/trie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.5.0.tgz", + "integrity": "sha512-FNoYzHawTMk/6KMQoEG5O4PuioX19UbwdQKF44yw0nLfOypfQdjtfZzo/UIJWAJ23sNIFbD1Ug9lbaDGMwbqQA==", + "dev": true, + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", @@ -13576,6 +13693,32 @@ "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, + "node_modules/graphql": { + "version": "16.8.1", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz", + "integrity": "sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==", + "dev": true, + "peer": true, + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } + }, + "node_modules/graphql-tag": { + "version": "2.12.6", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz", + "integrity": "sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==", + "dev": true, + "peer": true, + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, "node_modules/guest-nobuild-plain-hypatia": { "resolved": "examples/guest-nobuild-plain-hypatia", "link": true @@ -13695,6 +13838,23 @@ "node": "*" } }, + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "dev": true, + "peer": true, + "dependencies": { + "react-is": "^16.7.0" + } + }, + "node_modules/hoist-non-react-statics/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true, + "peer": true + }, "node_modules/host-vite-react-frames": { "resolved": "examples/host-vite-react-frames", "link": true @@ -17918,6 +18078,32 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/optimism": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/optimism/-/optimism-0.18.0.tgz", + "integrity": "sha512-tGn8+REwLRNFnb9WmcY5IfpOqeX2kpaYJ1s6Ae3mn12AeydLkR3j+jSCmVQFoXqU8D41PAJ1RG1rCRNWmNZVmQ==", + "dev": true, + "peer": true, + "dependencies": { + "@wry/caches": "^1.0.0", + "@wry/context": "^0.7.0", + "@wry/trie": "^0.4.3", + "tslib": "^2.3.0" + } + }, + "node_modules/optimism/node_modules/@wry/trie": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.4.3.tgz", + "integrity": "sha512-I6bHwH0fSf6RqQcnnXLJKhkSXG45MFral3GxPaY4uAl0LYDZM+YDVDAiU9bYwjTuysy1S0IeecWtmq1SZA3M1w==", + "dev": true, + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", @@ -19043,6 +19229,25 @@ "jsesc": "bin/jsesc" } }, + "node_modules/rehackt": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/rehackt/-/rehackt-0.1.0.tgz", + "integrity": "sha512-7kRDOuLHB87D/JESKxQoRwv4DzbIdwkAGQ7p6QKGdVlY1IZheUnVhlk/4UZlNUVxdAXpyxikE3URsG067ybVzw==", + "dev": true, + "peer": true, + "peerDependencies": { + "@types/react": "*", + "react": "*" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "react": { + "optional": true + } + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -19122,6 +19327,16 @@ "node": ">=10" } }, + "node_modules/response-iterator": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/response-iterator/-/response-iterator-0.2.6.tgz", + "integrity": "sha512-pVzEEzrsg23Sh053rmDUvLSkGXluZio0qu8VT6ukrYuvtjVfCbDZH9d6PGXb8HZfzdNZt8feXv/jvUzlhRgLnw==", + "dev": true, + "peer": true, + "engines": { + "node": ">=0.8" + } + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -19976,6 +20191,16 @@ "url": "https://opencollective.com/svgo" } }, + "node_modules/symbol-observable": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz", + "integrity": "sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ==", + "dev": true, + "peer": true, + "engines": { + "node": ">=0.10" + } + }, "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -20169,6 +20394,19 @@ "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "dev": true }, + "node_modules/ts-invariant": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.10.3.tgz", + "integrity": "sha512-uivwYcQaxAucv1CzRp2n/QdYPo4ILf9VXgH19zEIjFx2EJufV16P0JtJVpYHy89DItG6Kwj2oIUjrcK5au+4tQ==", + "dev": true, + "peer": true, + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/ts-jest": { "version": "29.1.2", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz", @@ -21426,6 +21664,23 @@ "seedrandom": "^2.4.3" } }, + "node_modules/zen-observable": { + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz", + "integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==", + "dev": true, + "peer": true + }, + "node_modules/zen-observable-ts": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.2.5.tgz", + "integrity": "sha512-QZWQekv6iB72Naeake9hS1KxHlotfRpe+WGNbNx5/ta+R3DNjVO2bswf63gXlWDcs+EMd7XY8HfVQyP1X6T4Zg==", + "dev": true, + "peer": true, + "dependencies": { + "zen-observable": "0.8.15" + } + }, "packages/uix-core": { "name": "@adobe/uix-core", "version": "0.10.2", @@ -21566,6 +21821,13 @@ "integrity": "sha512-rE0Pygv0sEZ4vBWHlAgJLGDU7Pm8xoO6p3wsEceb7GYAjScrOHpEo8KK/eVkAcnSM+slAEtXjA2JpdjLp4fJQQ==", "dev": true }, + "@adobe/exc-app": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@adobe/exc-app/-/exc-app-1.4.0.tgz", + "integrity": "sha512-RVDQqTEmmOQvvzjFGxHXpBtsfvGERVyuHRh/30EFbSpChglA+hX8eoGuo6knhQsJnzUlgPpBLaU7ZSiFTaKkcQ==", + "dev": true, + "requires": {} + }, "@adobe/react-spectrum": { "version": "3.34.1", "resolved": "https://registry.npmjs.org/@adobe/react-spectrum/-/react-spectrum-3.34.1.tgz", @@ -21731,6 +21993,29 @@ "@jridgewell/trace-mapping": "^0.3.9" } }, + "@apollo/client": { + "version": "3.10.4", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.10.4.tgz", + "integrity": "sha512-51gk0xOwN6Ls1EbTG5svFva1kdm2APHYTzmFhaAdvUQoJFDxfc0UwQgDxGptzH84vkPlo1qunY1FuboyF9LI3Q==", + "dev": true, + "peer": true, + "requires": { + "@graphql-typed-document-node/core": "^3.1.1", + "@wry/caches": "^1.0.0", + "@wry/equality": "^0.5.6", + "@wry/trie": "^0.5.0", + "graphql-tag": "^2.12.6", + "hoist-non-react-statics": "^3.3.2", + "optimism": "^0.18.0", + "prop-types": "^15.7.2", + "rehackt": "^0.1.0", + "response-iterator": "^0.2.6", + "symbol-observable": "^4.0.0", + "ts-invariant": "^0.10.3", + "tslib": "^2.3.0", + "zen-observable-ts": "^1.2.5" + } + }, "@babel/code-frame": { "version": "7.23.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", @@ -23344,6 +23629,14 @@ "tslib": "^2.4.0" } }, + "@graphql-typed-document-node/core": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz", + "integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==", + "dev": true, + "peer": true, + "requires": {} + }, "@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", @@ -28596,6 +28889,46 @@ "react-refresh": "^0.14.0" } }, + "@wry/caches": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@wry/caches/-/caches-1.0.1.tgz", + "integrity": "sha512-bXuaUNLVVkD20wcGBWRyo7j9N3TxePEWFZj2Y+r9OoUzfqmavM84+mFykRicNsBqatba5JLay1t48wxaXaWnlA==", + "dev": true, + "peer": true, + "requires": { + "tslib": "^2.3.0" + } + }, + "@wry/context": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@wry/context/-/context-0.7.4.tgz", + "integrity": "sha512-jmT7Sb4ZQWI5iyu3lobQxICu2nC/vbUhP0vIdd6tHC9PTfenmRmuIFqktc6GH9cgi+ZHnsLWPvfSvc4DrYmKiQ==", + "dev": true, + "peer": true, + "requires": { + "tslib": "^2.3.0" + } + }, + "@wry/equality": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.5.7.tgz", + "integrity": "sha512-BRFORjsTuQv5gxcXsuDXx6oGRhuVsEGwZy6LOzRRfgu+eSfxbhUQ9L9YtSEIuIjY/o7g3iWFjrc5eSY1GXP2Dw==", + "dev": true, + "peer": true, + "requires": { + "tslib": "^2.3.0" + } + }, + "@wry/trie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.5.0.tgz", + "integrity": "sha512-FNoYzHawTMk/6KMQoEG5O4PuioX19UbwdQKF44yw0nLfOypfQdjtfZzo/UIJWAJ23sNIFbD1Ug9lbaDGMwbqQA==", + "dev": true, + "peer": true, + "requires": { + "tslib": "^2.3.0" + } + }, "abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", @@ -31313,6 +31646,23 @@ "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, + "graphql": { + "version": "16.8.1", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz", + "integrity": "sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==", + "dev": true, + "peer": true + }, + "graphql-tag": { + "version": "2.12.6", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz", + "integrity": "sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==", + "dev": true, + "peer": true, + "requires": { + "tslib": "^2.1.0" + } + }, "guest-nobuild-plain-hypatia": { "version": "file:examples/guest-nobuild-plain-hypatia", "requires": { @@ -31409,6 +31759,25 @@ "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", "dev": true }, + "hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "dev": true, + "peer": true, + "requires": { + "react-is": "^16.7.0" + }, + "dependencies": { + "react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true, + "peer": true + } + } + }, "host-vite-react-frames": { "version": "file:examples/host-vite-react-frames", "requires": { @@ -34459,6 +34828,31 @@ "mimic-fn": "^2.1.0" } }, + "optimism": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/optimism/-/optimism-0.18.0.tgz", + "integrity": "sha512-tGn8+REwLRNFnb9WmcY5IfpOqeX2kpaYJ1s6Ae3mn12AeydLkR3j+jSCmVQFoXqU8D41PAJ1RG1rCRNWmNZVmQ==", + "dev": true, + "peer": true, + "requires": { + "@wry/caches": "^1.0.0", + "@wry/context": "^0.7.0", + "@wry/trie": "^0.4.3", + "tslib": "^2.3.0" + }, + "dependencies": { + "@wry/trie": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.4.3.tgz", + "integrity": "sha512-I6bHwH0fSf6RqQcnnXLJKhkSXG45MFral3GxPaY4uAl0LYDZM+YDVDAiU9bYwjTuysy1S0IeecWtmq1SZA3M1w==", + "dev": true, + "peer": true, + "requires": { + "tslib": "^2.3.0" + } + } + } + }, "optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", @@ -35265,6 +35659,14 @@ } } }, + "rehackt": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/rehackt/-/rehackt-0.1.0.tgz", + "integrity": "sha512-7kRDOuLHB87D/JESKxQoRwv4DzbIdwkAGQ7p6QKGdVlY1IZheUnVhlk/4UZlNUVxdAXpyxikE3URsG067ybVzw==", + "dev": true, + "peer": true, + "requires": {} + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -35322,6 +35724,13 @@ "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", "dev": true }, + "response-iterator": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/response-iterator/-/response-iterator-0.2.6.tgz", + "integrity": "sha512-pVzEEzrsg23Sh053rmDUvLSkGXluZio0qu8VT6ukrYuvtjVfCbDZH9d6PGXb8HZfzdNZt8feXv/jvUzlhRgLnw==", + "dev": true, + "peer": true + }, "reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -35954,6 +36363,13 @@ "picocolors": "^1.0.0" } }, + "symbol-observable": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz", + "integrity": "sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ==", + "dev": true, + "peer": true + }, "symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -36106,6 +36522,16 @@ "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "dev": true }, + "ts-invariant": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.10.3.tgz", + "integrity": "sha512-uivwYcQaxAucv1CzRp2n/QdYPo4ILf9VXgH19zEIjFx2EJufV16P0JtJVpYHy89DItG6Kwj2oIUjrcK5au+4tQ==", + "dev": true, + "peer": true, + "requires": { + "tslib": "^2.1.0" + } + }, "ts-jest": { "version": "29.1.2", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz", @@ -36965,6 +37391,23 @@ "requires": { "seedrandom": "^2.4.3" } + }, + "zen-observable": { + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz", + "integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==", + "dev": true, + "peer": true + }, + "zen-observable-ts": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.2.5.tgz", + "integrity": "sha512-QZWQekv6iB72Naeake9hS1KxHlotfRpe+WGNbNx5/ta+R3DNjVO2bswf63gXlWDcs+EMd7XY8HfVQyP1X6T4Zg==", + "dev": true, + "peer": true, + "requires": { + "zen-observable": "0.8.15" + } } } } diff --git a/package.json b/package.json index d33335b..b8a0a1a 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,8 @@ "typescript": "~4.8.4", "vite": "^3.2.3", "yalc": "^1.0.0-pre.53", - "zalgo-js": "^1.0.0" + "zalgo-js": "^1.0.0", + "@adobe/exc-app": "^1.4.0" }, "license": "Apache-2.0", "repository": { diff --git a/packages/uix-host/src/host.ts b/packages/uix-host/src/host.ts index 7d7f0df..6332988 100644 --- a/packages/uix-host/src/host.ts +++ b/packages/uix-host/src/host.ts @@ -21,6 +21,7 @@ import type { CapabilitySpec } from "./port.js"; import { Emitter, quietConsole } from "@adobe/uix-core"; import { Port, PortOptions } from "./port.js"; import { debugHost } from "./debug-host.js"; +import { addMetrics } from "./metrics.js"; /** * Dictionary of {@link Port} objects by extension ID. @@ -118,6 +119,10 @@ export interface HostConfig { * guests. */ sharedContext?: SharedContextValues; + /** + * Disables built-in metrics of UIX SDK + */ + noMetrics?: boolean; } /** @@ -237,6 +242,9 @@ export class Host extends Emitter { if (config.debug) { this.logger = debugHost(this); } + if (!config.noMetrics) { + addMetrics(this); + } } /** * Return all loaded guests. diff --git a/packages/uix-host/src/metrics.ts b/packages/uix-host/src/metrics.ts new file mode 100644 index 0000000..ead4fb0 --- /dev/null +++ b/packages/uix-host/src/metrics.ts @@ -0,0 +1,144 @@ +/* +Copyright 2024 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +/* eslint-disable @typescript-eslint/restrict-template-expressions */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/** + * Adapter to attach console logging listeners to a Host running in an app + * @hidden + */ +import { Emitter } from "@adobe/uix-core"; +import type { HostEvents } from "./host.js"; +import type { Metrics } from "@adobe/exc-app/metrics"; +import MetricsApi from "@adobe/exc-app/metrics"; + +type EventPayload = { + event: string | string[]; + args: any; +}; + +/** + * Wrapper class for handling metrics and event tracking. + */ +class MetricsWrapper { + private eventPool: EventPayload[] = []; + private metricsInstance?: Readonly | undefined = undefined; + + /** + * Sends collected events to the metrics instance. + */ + private flush(): void { + if (!this.metricsInstance) { + return; + } + + this.eventPool.forEach((eventPayload) => { + this.metricsInstance.event(eventPayload.event, eventPayload.args); + }); + this.eventPool = []; + } + + /** + * Gets the current metrics instance. + */ + public get mertricsInstance(): Readonly | undefined { + return this.metricsInstance; + } + + /** + * Sets the metrics instance and flushes any pending events. + */ + public set mertricsInstance(metrics: Readonly) { + this.metricsInstance = metrics; + this.metricsInstance && this.flush(); + } + + /** + * Tracks an event using the metrics instance, or adds it to the event pool if no instance is set. + */ + public event(event: string, args: any): void { + if (this.metricsInstance) { + this.metricsInstance.event(event, args); + } else { + this.eventPool.push({ event, args }); + } + } +} +const metrics = new MetricsWrapper(); + +const seenGuests = new Set(); +const runtimeWaitTimeout = 10000; +const createMetricsInstance = () => MetricsApi.create("exc.uix.core"); + +const startTime = Date.now(); +/** + * Monitors the availability of the runtime module and creates a metrics instance when it becomes available. + * If the runtime module is not found within the specified timeout, it exits and no events will be sent. + * @returns {void} + */ +const runtimeSpy = () => { + if (startTime + runtimeWaitTimeout < Date.now()) { + // Timeout, time to hang up + return; + } + if ("exc-module-runtime" in window) { + metrics.mertricsInstance = createMetricsInstance(); + return; + } + setTimeout(runtimeSpy, 1000); +}; +runtimeSpy(); + +/** + * Adds metrics tracking to the host. + * + * @param host - The host emitter to attach the metrics to. + */ +export function addMetrics(host: Emitter): void { + host.addEventListener("guestload", (evt) => { + const guest = evt.detail.guest; + if (seenGuests.has(guest)) { + return; + } + seenGuests.add(guest); + const addGuestId = (payload: any): any => { + payload["guestId"] = guest.id; + return payload; + }; + + metrics.event("load", addGuestId({})); + + guest.addEventListener("beforecallguestmethod", (callDetails) => { + const { path } = callDetails.detail; + metrics.event( + "callguestmethod", + addGuestId({ + path: (path as string[]).join("."), + }) + ); + }); + guest.addEventListener("beforecallhostmethod", (callDetails) => { + const { path, name } = callDetails.detail; + path.push(name); + metrics.event( + "callhostmethod", + addGuestId({ + path: (path as string[]).join("."), + }) + ); + }); + }); + + host.addEventListener("error", () => { + metrics.event("error", {}); + }); +} diff --git a/packages/uix-host/src/port.ts b/packages/uix-host/src/port.ts index ca91592..c57d151 100644 --- a/packages/uix-host/src/port.ts +++ b/packages/uix-host/src/port.ts @@ -364,7 +364,7 @@ export class Port private addApiMiddleware( subject: RemoteHostApis, path: string[] = [] - ): { [x: string]: {} } { + ): RemoteHostApis { if (typeof subject === "object") { for (const [key, value] of Object.entries(subject)) { if (typeof value === "object") { @@ -373,13 +373,18 @@ export class Port // Remote function is already wrapped. Nothing to do... continue; } else if (isFunction(value)) { - const wrapper = (...args: any) => { + const wrapper = async (...args: any) => { this.emit("beforecallguestmethod", { guestPort: this, path: [...path, key], args, }); - return (value as CallableFunction)(...args); + const res = await (value as CallableFunction)(...args); + /* + * Wraps response in middleware so consequent calls could be intercepted + * E.g. headerMenu.getButtons().onClick() + */ + return this.addApiMiddleware(res, [...path, key]); }; (wrapper as WrappedFunction)[WRAPPER_MARKER] = true; subject[key] = wrapper; diff --git a/scripts/publish-local-to.mjs b/scripts/publish-local-to.mjs index 4981086..18cbe23 100755 --- a/scripts/publish-local-to.mjs +++ b/scripts/publish-local-to.mjs @@ -33,27 +33,27 @@ const bullets = (iter) => ["", ...iter].join("\n • "); async function publishLocalTo({ dryRun }, dependents) { const sh = dryRun ? fakeSh : realSh; -// const yalc = resolve(await shResult("npm", ["bin"]), "yalc"); -// try { -// await shResult(yalc, ["--version"]); -// } catch (e) { -// throw new Error( -// `Could not find "yalc" in npm path: ${e.message}. Install yalc globally with yarn or npm to proceed. -// (Sorry, 'npx yalc' doesn't work in this use case.` -// ); -// } + const yalc = resolve(await shResult("npm", ["bin"]), "yalc"); + try { + await shResult(yalc, ["--version"]); + } catch (e) { + throw new Error( + `Could not find "yalc" in npm path: ${e.message}. Install yalc globally with yarn or npm to proceed. +(Sorry, 'npx yalc' doesn't work in this use case.` + ); + } const sdks = await getSdks(); logger.log.hl`Publishing ${sdks.map((s) => s.shortName).join(", ")}`; for (const { cwd } of sdks) { - await sh("npm", ["exec", "yalc", "--", "publish", "--quiet", "--changed"], { cwd, silent: true }); + await sh(yalc, ["publish", "--quiet", "--changed"], { cwd, silent: true }); } for (const dependent of dependents) { const usedSdkPackages = new Set(); const unlinkedSdkPackages = new Set(); - const yalcConfigDir = await shResult("npm", ["exec", "yalc", "--", "dir"], { + const yalcConfigDir = await shResult(yalc, ["dir"], { cwd: dependent.dir, }); let yalcInstallations = {}; @@ -98,7 +98,7 @@ async function publishLocalTo({ dryRun }, dependents) { )}`; } for (const unlinked of unlinkedSdkPackages) { - await sh("npm", ["exec", "yalc", "--", "add", "--no-pure", unlinked], { + await sh(yalc, ["add", "--no-pure", unlinked], { cwd: dependent.dir, }); } @@ -108,14 +108,14 @@ async function publishLocalTo({ dryRun }, dependents) { // now that they're all added, push again to ensure they're up to date // looks repetitive because of yalc quirks, but gets by all the weird errors for (const sdk of sdks) { - await sh("npm", ["exec", "yalc", "--", "push", "--scripts", "--quiet"], { + await sh(yalc, ["push", "--scripts", "--quiet"], { cwd: sdk.cwd, silent: true, }); } if (dependents.length > 0) { - await sh("npm", ["exec", "yalc", "--", 'installations', 'show']); + await sh('yalc', ['installations', 'show']); } logger.done("All SDKs published to yalc and up-to-date."); @@ -134,4 +134,4 @@ runWithArg(publishLocalTo, async (argv) => { } } return [argv, dependents]; -}); +}); \ No newline at end of file From 8b80163641b4107212f53bdd6185014be5d2a518 Mon Sep 17 00:00:00 2001 From: Andrii Konosov Date: Thu, 13 Jun 2024 12:46:46 -0500 Subject: [PATCH 5/6] Reset From 574ec39e25746b62bc93d6e65c4e79e9735dff88 Mon Sep 17 00:00:00 2001 From: Andrii Konosov Date: Thu, 13 Jun 2024 15:02:09 -0500 Subject: [PATCH 6/6] CR Fixes --- docs/api-report/uix-host.api.md | 2 +- ...g.nometrics.md => uix-host.hostconfig.disablemetrics.md} | 6 +++--- docs/markdown/uix-host.hostconfig.md | 2 +- packages/uix-host/src/host.ts | 4 ++-- packages/uix-host/src/metrics.ts | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename docs/markdown/{uix-host.hostconfig.nometrics.md => uix-host.hostconfig.disablemetrics.md} (57%) diff --git a/docs/api-report/uix-host.api.md b/docs/api-report/uix-host.api.md index 9fd4599..e04357e 100644 --- a/docs/api-report/uix-host.api.md +++ b/docs/api-report/uix-host.api.md @@ -117,9 +117,9 @@ export class Host extends Emitter { // @public (undocumented) export interface HostConfig { debug?: boolean; + disableMetrics?: boolean; guestOptions?: PortOptions; hostName: string; - noMetrics?: boolean; runtimeContainer?: HTMLElement; sharedContext?: SharedContextValues; } diff --git a/docs/markdown/uix-host.hostconfig.nometrics.md b/docs/markdown/uix-host.hostconfig.disablemetrics.md similarity index 57% rename from docs/markdown/uix-host.hostconfig.nometrics.md rename to docs/markdown/uix-host.hostconfig.disablemetrics.md index b1f8337..f79b91a 100644 --- a/docs/markdown/uix-host.hostconfig.nometrics.md +++ b/docs/markdown/uix-host.hostconfig.disablemetrics.md @@ -1,13 +1,13 @@ -[Home](./index.md) > [@adobe/uix-host](./uix-host.md) > [HostConfig](./uix-host.hostconfig.md) > [noMetrics](./uix-host.hostconfig.nometrics.md) +[Home](./index.md) > [@adobe/uix-host](./uix-host.md) > [HostConfig](./uix-host.hostconfig.md) > [disableMetrics](./uix-host.hostconfig.disablemetrics.md) -## HostConfig.noMetrics property +## HostConfig.disableMetrics property Disables built-in metrics of UIX SDK **Signature:** ```typescript -noMetrics?: boolean; +disableMetrics?: boolean; ``` diff --git a/docs/markdown/uix-host.hostconfig.md b/docs/markdown/uix-host.hostconfig.md index 84c5747..709db1a 100644 --- a/docs/markdown/uix-host.hostconfig.md +++ b/docs/markdown/uix-host.hostconfig.md @@ -16,9 +16,9 @@ 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) |

_(Optional)_ Default options to use for every guest Port.

If config.debug is true, then the guest options will have debug: true unless debug: false is explicitly passed in guestOptions.

| | [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. | -| [noMetrics?](./uix-host.hostconfig.nometrics.md) | | boolean | _(Optional)_ Disables built-in metrics of UIX SDK | | [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. | | [sharedContext?](./uix-host.hostconfig.sharedcontext.md) | | [SharedContextValues](./uix-host.sharedcontextvalues.md) | _(Optional)_ A read-only dictionary of values that the host will supply to all the guests. | diff --git a/packages/uix-host/src/host.ts b/packages/uix-host/src/host.ts index 6332988..ec10e64 100644 --- a/packages/uix-host/src/host.ts +++ b/packages/uix-host/src/host.ts @@ -122,7 +122,7 @@ export interface HostConfig { /** * Disables built-in metrics of UIX SDK */ - noMetrics?: boolean; + disableMetrics?: boolean; } /** @@ -242,7 +242,7 @@ export class Host extends Emitter { if (config.debug) { this.logger = debugHost(this); } - if (!config.noMetrics) { + if (!config.disableMetrics) { addMetrics(this); } } diff --git a/packages/uix-host/src/metrics.ts b/packages/uix-host/src/metrics.ts index ead4fb0..01e5c12 100644 --- a/packages/uix-host/src/metrics.ts +++ b/packages/uix-host/src/metrics.ts @@ -22,7 +22,7 @@ import type { Metrics } from "@adobe/exc-app/metrics"; import MetricsApi from "@adobe/exc-app/metrics"; type EventPayload = { - event: string | string[]; + event: string; args: any; };