Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@module-federation/bridge-react

Package Overview
Dependencies
Maintainers
0
Versions
301
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@module-federation/bridge-react - npm Package Compare versions

Comparing version 0.0.0-next-20241101093646 to 0.0.0-next-20241104024700

dist/context-CefGbh9w.cjs

37

CHANGELOG.md
# @module-federation/bridge-react
## 0.0.0-next-20241101093646
## 0.0.0-next-20241104024700
### Patch Changes
- 3082116: feat: support module isolated reported
- Updated dependencies [3082116]
- @module-federation/runtime@0.0.0-next-20241101093646
- @module-federation/bridge-shared@0.0.0-next-20241101093646
- Updated dependencies [f779188]
- @module-federation/sdk@0.0.0-next-20241104024700
- @module-federation/bridge-shared@0.0.0-next-20241104024700
## 0.6.15
### Patch Changes
- @module-federation/sdk@0.6.15
- @module-federation/bridge-shared@0.6.15
## 0.6.14
### Patch Changes
- ad605d2: chore: unified logger
- Updated dependencies [ad605d2]
- @module-federation/bridge-shared@0.6.14
- @module-federation/sdk@0.6.14
## 0.6.13
### Patch Changes
- @module-federation/bridge-shared@0.6.13
## 0.6.12
### Patch Changes
- @module-federation/bridge-shared@0.6.12
## 0.6.11

@@ -13,0 +40,0 @@

84

dist/index.cjs.js
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const React = require("react");
const context = require("./context--mtFt3tp.cjs");
const context = require("./context-CefGbh9w.cjs");
const ReactRouterDOM = require("react-router-dom");
const runtime = require("@module-federation/runtime");
const ReactDOM = require("react-dom");
function _interopNamespaceDefault(e) {
function _interopNamespaceDefault(e2) {
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
if (e) {
for (const k in e) {
if (e2) {
for (const k in e2) {
if (k !== "default") {
const d = Object.getOwnPropertyDescriptor(e, k);
const d = Object.getOwnPropertyDescriptor(e2, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: () => e[k]
get: () => e2[k]
});

@@ -21,3 +20,3 @@ }

}
n.default = e;
n.default = e2;
return Object.freeze(n);

@@ -122,16 +121,7 @@ }

}
const getModuleName = (id) => {
const idArray = id.split("/");
if (idArray.length < 2) {
return id;
}
return idArray[0] + "/" + idArray[1];
};
const getRootDomDefaultClassName = (moduleName) => {
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
return `bridge-root-component-${name}`;
};
function e() {
const t = new PopStateEvent("popstate", { state: window.history.state });
window.dispatchEvent(t);
}
const RemoteAppWrapper = React.forwardRef(function(props, ref) {
const host = runtime.getInstance();
context.LoggerInstance.log(`RemoteAppWrapper host >>>`, host);
const RemoteApp2 = () => {

@@ -154,6 +144,5 @@ context.LoggerInstance.log(`RemoteAppWrapper RemoteApp props >>>`, { props });

const renderTimeout = setTimeout(() => {
var _a, _b, _c, _d;
const providerReturn = providerInfo();
providerInfoRef.current = providerReturn;
let renderProps = {
const renderProps = {
moduleName,

@@ -171,12 +160,2 @@ dom: rootRef.current,

);
if ((host == null ? void 0 : host.bridgeHook) && ((_b = (_a = host == null ? void 0 : host.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender)) {
const beforeBridgeRenderRes = (_d = (_c = host == null ? void 0 : host.bridgeHook) == null ? void 0 : _c.lifecycle) == null ? void 0 : _d.beforeBridgeRender.emit({
...renderProps
});
const extraProps = beforeBridgeRenderRes && typeof beforeBridgeRenderRes === "object" && (beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps) ? beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps : {};
renderProps = {
...renderProps,
...extraProps
};
}
providerReturn.render(renderProps);

@@ -187,3 +166,3 @@ });

setTimeout(() => {
var _a, _b, _c, _d, _e, _f;
var _a, _b;
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {

@@ -194,13 +173,3 @@ context.LoggerInstance.log(

);
if ((host == null ? void 0 : host.bridgeHook) && ((_c = (_b = host == null ? void 0 : host.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.afterBridgeDestroy)) {
(_e = (_d = host == null ? void 0 : host.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeDestroy.emit({
moduleName,
dom: renderDom.current,
basename,
memoryRoute,
fallback,
...resProps
});
}
(_f = providerInfoRef.current) == null ? void 0 : _f.destroy({
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
dom: renderDom.current

@@ -212,7 +181,6 @@ });

}, []);
const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${props == null ? void 0 : props.className}`;
return /* @__PURE__ */ React.createElement(
"div",
{
className: rootComponentClassName,
className: props == null ? void 0 : props.className,
style: props == null ? void 0 : props.style,

@@ -223,3 +191,3 @@ ref: rootRef

};
RemoteApp2["__APP_VERSION__"] = "0.6.11";
RemoteApp2["__APP_VERSION__"] = "0.6.15";
return /* @__PURE__ */ React.createElement(RemoteApp2, null);

@@ -281,3 +249,3 @@ });

});
context.f();
e();
}

@@ -375,3 +343,3 @@ setPathname(location.pathname);

function createBridgeComponent(bridgeInfo) {
return (params) => {
return () => {
const rootMap = /* @__PURE__ */ new Map();

@@ -392,3 +360,2 @@ const RawComponent = (info) => {

async render(info) {
var _a, _b;
context.LoggerInstance.log(`createBridgeComponent render Info`, info);

@@ -403,5 +370,2 @@ const {

} = info;
const beforeBridgeRender = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeRender) || ((_a = params == null ? void 0 : params.hooks) == null ? void 0 : _a.beforeBridgeRender);
const beforeBridgeRenderRes = beforeBridgeRender && beforeBridgeRender(info);
const extraProps = beforeBridgeRenderRes && typeof beforeBridgeRenderRes === "object" && (beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps) ? beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps : {};
const rootComponentWithErrorBoundary = (

@@ -417,3 +381,3 @@ // set ErrorBoundary for RawComponent rendering error, usually caused by user app rendering error

},
propsInfo: { ...propsInfo, ...extraProps }
propsInfo
}

@@ -436,15 +400,7 @@ ))

}
const afterBridgeRender = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.afterBridgeDestroy) || ((_b = params == null ? void 0 : params.hooks) == null ? void 0 : _b.afterBridgeRender);
afterBridgeRender && afterBridgeRender(info);
},
async destroy(info) {
var _a, _b;
context.LoggerInstance.log(`createBridgeComponent destroy Info`, {
dom: info.dom
});
if ((bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) && typeof (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) === "function") {
bridgeInfo.hooks.beforeBridgeDestroy(info);
}
const beforeBridgeDestroy = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) || ((_a = params == null ? void 0 : params.hooks) == null ? void 0 : _a.beforeBridgeDestroy);
beforeBridgeDestroy && beforeBridgeDestroy(info);
if (context.atLeastReact18(React__namespace)) {

@@ -457,4 +413,2 @@ const root = rootMap.get(info.dom);

}
const afterBridgeDestroy = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.afterBridgeDestroy) || ((_b = params == null ? void 0 : params.hooks) == null ? void 0 : _b.afterBridgeDestroy);
afterBridgeDestroy && afterBridgeDestroy(info);
},

@@ -461,0 +415,0 @@ rawComponent: bridgeInfo.rootComponent,

@@ -8,14 +8,7 @@ import { ComponentType } from 'react';

declare type BridgeHooks = {
beforeBridgeRender?: (params: RenderFnParams) => any;
afterBridgeRender?: (params: RenderFnParams) => any;
beforeBridgeDestroy?: (params: DestroyParams) => any;
afterBridgeDestroy?: (params: DestroyParams) => any;
};
export declare function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>): (params: {
hooks?: BridgeHooks;
}) => {
render(info: RenderParams): Promise<void>;
destroy(info: DestroyParams): Promise<void>;
export declare function createBridgeComponent<T>(bridgeInfo: ProviderFnParams<T>): () => {
render(info: RenderFnParams & any): Promise<void>;
destroy(info: {
dom: HTMLElement;
}): Promise<void>;
rawComponent: React_2.ComponentType<T>;

@@ -32,6 +25,2 @@ __BRIDGE_FN__: (_args: T) => void;

declare type DestroyParams = {
dom: HTMLElement;
};
declare type ErrorBoundaryPropsWithComponent = ErrorBoundarySharedProps & {

@@ -64,3 +53,2 @@ fallback?: never;

render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
hooks?: BridgeHooks;
};

@@ -82,6 +70,4 @@

declare type RenderParams = RenderFnParams & any;
declare type RootType = HTMLElement | default_3.Root;
export { }
import * as React from "react";
import React__default, { createContext, Component, createElement, isValidElement, forwardRef, useRef, useEffect, useContext, useState } from "react";
import { L as LoggerInstance, p as pathJoin, f, a as atLeastReact18, R as RouterContext } from "./context-Bw2PEwa6.js";
import { L as LoggerInstance, p as pathJoin, a as atLeastReact18, R as RouterContext } from "./context-DnCWjvho.js";
import * as ReactRouterDOM from "react-router-dom";
import { getInstance } from "@module-federation/runtime";
import ReactDOM from "react-dom";

@@ -102,16 +101,7 @@ const ErrorBoundaryContext = createContext(null);

}
const getModuleName = (id) => {
const idArray = id.split("/");
if (idArray.length < 2) {
return id;
}
return idArray[0] + "/" + idArray[1];
};
const getRootDomDefaultClassName = (moduleName) => {
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
return `bridge-root-component-${name}`;
};
function e() {
const t = new PopStateEvent("popstate", { state: window.history.state });
window.dispatchEvent(t);
}
const RemoteAppWrapper = forwardRef(function(props, ref) {
const host = getInstance();
LoggerInstance.log(`RemoteAppWrapper host >>>`, host);
const RemoteApp2 = () => {

@@ -134,6 +124,5 @@ LoggerInstance.log(`RemoteAppWrapper RemoteApp props >>>`, { props });

const renderTimeout = setTimeout(() => {
var _a, _b, _c, _d;
const providerReturn = providerInfo();
providerInfoRef.current = providerReturn;
let renderProps = {
const renderProps = {
moduleName,

@@ -151,12 +140,2 @@ dom: rootRef.current,

);
if ((host == null ? void 0 : host.bridgeHook) && ((_b = (_a = host == null ? void 0 : host.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender)) {
const beforeBridgeRenderRes = (_d = (_c = host == null ? void 0 : host.bridgeHook) == null ? void 0 : _c.lifecycle) == null ? void 0 : _d.beforeBridgeRender.emit({
...renderProps
});
const extraProps = beforeBridgeRenderRes && typeof beforeBridgeRenderRes === "object" && (beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps) ? beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps : {};
renderProps = {
...renderProps,
...extraProps
};
}
providerReturn.render(renderProps);

@@ -167,3 +146,3 @@ });

setTimeout(() => {
var _a, _b, _c, _d, _e, _f;
var _a, _b;
if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {

@@ -174,13 +153,3 @@ LoggerInstance.log(

);
if ((host == null ? void 0 : host.bridgeHook) && ((_c = (_b = host == null ? void 0 : host.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.afterBridgeDestroy)) {
(_e = (_d = host == null ? void 0 : host.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeDestroy.emit({
moduleName,
dom: renderDom.current,
basename,
memoryRoute,
fallback,
...resProps
});
}
(_f = providerInfoRef.current) == null ? void 0 : _f.destroy({
(_b = providerInfoRef.current) == null ? void 0 : _b.destroy({
dom: renderDom.current

@@ -192,7 +161,6 @@ });

}, []);
const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${props == null ? void 0 : props.className}`;
return /* @__PURE__ */ React__default.createElement(
"div",
{
className: rootComponentClassName,
className: props == null ? void 0 : props.className,
style: props == null ? void 0 : props.style,

@@ -203,3 +171,3 @@ ref: rootRef

};
RemoteApp2["__APP_VERSION__"] = "0.6.11";
RemoteApp2["__APP_VERSION__"] = "0.6.15";
return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);

@@ -261,3 +229,3 @@ });

});
f();
e();
}

@@ -355,3 +323,3 @@ setPathname(location.pathname);

function createBridgeComponent(bridgeInfo) {
return (params) => {
return () => {
const rootMap = /* @__PURE__ */ new Map();

@@ -372,3 +340,2 @@ const RawComponent = (info) => {

async render(info) {
var _a, _b;
LoggerInstance.log(`createBridgeComponent render Info`, info);

@@ -383,5 +350,2 @@ const {

} = info;
const beforeBridgeRender = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeRender) || ((_a = params == null ? void 0 : params.hooks) == null ? void 0 : _a.beforeBridgeRender);
const beforeBridgeRenderRes = beforeBridgeRender && beforeBridgeRender(info);
const extraProps = beforeBridgeRenderRes && typeof beforeBridgeRenderRes === "object" && (beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps) ? beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps : {};
const rootComponentWithErrorBoundary = (

@@ -397,3 +361,3 @@ // set ErrorBoundary for RawComponent rendering error, usually caused by user app rendering error

},
propsInfo: { ...propsInfo, ...extraProps }
propsInfo
}

@@ -416,15 +380,7 @@ ))

}
const afterBridgeRender = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.afterBridgeDestroy) || ((_b = params == null ? void 0 : params.hooks) == null ? void 0 : _b.afterBridgeRender);
afterBridgeRender && afterBridgeRender(info);
},
async destroy(info) {
var _a, _b;
LoggerInstance.log(`createBridgeComponent destroy Info`, {
dom: info.dom
});
if ((bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) && typeof (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) === "function") {
bridgeInfo.hooks.beforeBridgeDestroy(info);
}
const beforeBridgeDestroy = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.beforeBridgeDestroy) || ((_a = params == null ? void 0 : params.hooks) == null ? void 0 : _a.beforeBridgeDestroy);
beforeBridgeDestroy && beforeBridgeDestroy(info);
if (atLeastReact18(React)) {

@@ -437,4 +393,2 @@ const root = rootMap.get(info.dom);

}
const afterBridgeDestroy = (bridgeInfo == null ? void 0 : bridgeInfo.hooks) && (bridgeInfo == null ? void 0 : bridgeInfo.hooks.afterBridgeDestroy) || ((_b = params == null ? void 0 : params.hooks) == null ? void 0 : _b.afterBridgeDestroy);
afterBridgeDestroy && afterBridgeDestroy(info);
},

@@ -441,0 +395,0 @@ rawComponent: bridgeInfo.rootComponent,

@@ -5,3 +5,3 @@ "use strict";

const ReactRouterDom$1 = require("react-router-dom/index.js");
const context = require("./context--mtFt3tp.cjs");
const context = require("./context-CefGbh9w.cjs");
const ReactRouterDom = require("react-router-dom/index.js");

@@ -8,0 +8,0 @@ function _interopNamespaceDefault(e) {

import React__default, { useContext } from "react";
import * as ReactRouterDom$1 from "react-router-dom/index.js";
import { R as RouterContext, L as LoggerInstance } from "./context-Bw2PEwa6.js";
import { R as RouterContext, L as LoggerInstance } from "./context-DnCWjvho.js";
export * from "react-router-dom/index.js";

@@ -5,0 +5,0 @@ function WraperRouter(props) {

@@ -5,3 +5,3 @@ "use strict";

const ReactRouterDom = require("react-router-dom/dist/index.js");
const context = require("./context--mtFt3tp.cjs");
const context = require("./context-CefGbh9w.cjs");
function _interopNamespaceDefault(e) {

@@ -8,0 +8,0 @@ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });

import React__default, { useContext } from "react";
import * as ReactRouterDom from "react-router-dom/dist/index.js";
export * from "react-router-dom/dist/index.js";
import { R as RouterContext, L as LoggerInstance } from "./context-Bw2PEwa6.js";
import { R as RouterContext, L as LoggerInstance } from "./context-DnCWjvho.js";
function WraperRouter(props) {

@@ -6,0 +6,0 @@ const { basename, ...propsRes } = props;

@@ -5,3 +5,3 @@ "use strict";

const ReactRouterDom = require("react-router-dom/");
const context = require("./context--mtFt3tp.cjs");
const context = require("./context-CefGbh9w.cjs");
function _interopNamespaceDefault(e) {

@@ -69,3 +69,3 @@ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });

const BrowserRouterInstance = createBrowserRouter(routers, {
basename: routerContextProps.basename || (router == null ? void 0 : router.basename),
basename: routerContextProps.basename,
future: router.future,

@@ -72,0 +72,0 @@ window: router.window

import React__default, { useContext } from "react";
import * as ReactRouterDom from "react-router-dom/";
export * from "react-router-dom/";
import { R as RouterContext, L as LoggerInstance } from "./context-Bw2PEwa6.js";
import { R as RouterContext, L as LoggerInstance } from "./context-DnCWjvho.js";
function WrapperRouter(props) {

@@ -50,3 +50,3 @@ const { basename, ...propsRes } = props;

const BrowserRouterInstance = createBrowserRouter(routers, {
basename: routerContextProps.basename || (router == null ? void 0 : router.basename),
basename: routerContextProps.basename,
future: router.future,

@@ -53,0 +53,0 @@ window: router.window

{
"name": "@module-federation/bridge-react",
"version": "0.0.0-next-20241101093646",
"version": "0.0.0-next-20241104024700",
"publishConfig": {

@@ -38,3 +38,4 @@ "access": "public"

"react-error-boundary": "^4.0.13",
"@module-federation/bridge-shared": "0.0.0-next-20241101093646"
"@module-federation/bridge-shared": "0.0.0-next-20241104024700",
"@module-federation/sdk": "0.0.0-next-20241104024700"
},

@@ -44,4 +45,3 @@ "peerDependencies": {

"react-dom": ">=16.9.0",
"react-router-dom": ">=4",
"@module-federation/runtime": "0.0.0-next-20241101093646"
"react-router-dom": ">=4"
},

@@ -48,0 +48,0 @@ "devDependencies": {

import React from 'react';
import { Logger } from '@module-federation/bridge-shared';
import { createLogger } from '@module-federation/sdk';
export const LoggerInstance = new Logger('bridge-react');
export const LoggerInstance = createLogger(
'[ Module Federation Bridge React ]',
);

@@ -6,0 +8,0 @@ type typeReact = typeof React;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc