npm package diff

Package: @forge/react

Versions: 10.9.0-next.0 - 10.9.0-next.1

File: package/out/components/createFrame.js

Index: package/out/components/createFrame.js
===================================================================
--- package/out/components/createFrame.js
+++ package/out/components/createFrame.js
@@ -1,56 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.createFrame = void 0;
-const jsx_runtime_1 = require("react/jsx-runtime");
-const react_1 = require("react");
-const uuid_1 = require("uuid");
-const bridge_1 = require("@forge/bridge");
-const _1 = require(".");
-const useFrameId = () => {
-    const frameId = (0, react_1.useRef)((0, uuid_1.v4)());
-    return frameId.current;
-};
-const frameEventKey = (eventKey, frameId) => `frame:${eventKey}:${frameId}`;
-const EVENT_KEY_FRAME_PROPS = 'props';
-const EVENT_KEY_FRAME_LOADED = 'loaded';
-const arePropsEqualWithShallowCheck = (prevProps, nextProps) => {
-    // Checks if props have the same reference (for the case of initial render).
-    if (prevProps === nextProps) {
-        return true;
-    }
-    const prevKeys = Object.keys(prevProps);
-    const nextKeys = Object.keys(nextProps);
-    if (prevKeys.length !== nextKeys.length) {
-        return false;
-    }
-    for (const key of prevKeys) {
-        if (!Object.hasOwn(nextProps, key) || prevProps[key] !== nextProps[key]) {
-            return false;
-        }
-    }
-    return true;
-};
-const createFrame = (resource, arePropsEqual = arePropsEqualWithShallowCheck) => {
-    return (props) => {
-        const frameId = useFrameId();
-        const propsRef = (0, react_1.useRef)(props);
-        (0, react_1.useEffect)(() => {
-            const sub = bridge_1.events.on(frameEventKey(EVENT_KEY_FRAME_LOADED, frameId), ({ loaded }) => {
-                if (loaded) {
-                    void bridge_1.events.emit(frameEventKey(EVENT_KEY_FRAME_PROPS, frameId), propsRef.current);
-                }
-            });
-            return () => {
-                void sub.then((s) => s.unsubscribe());
-            };
-        }, []);
-        (0, react_1.useEffect)(() => {
-            if (!arePropsEqual(propsRef.current, props)) {
-                propsRef.current = props;
-                void bridge_1.events.emit(frameEventKey(EVENT_KEY_FRAME_PROPS, frameId), props);
-            }
-        }, [props]);
-        return (0, jsx_runtime_1.jsx)(_1.Frame, { resource: resource, frameId: frameId });
-    };
-};
-exports.createFrame = createFrame;