New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@module-federation/bridge-react

Package Overview
Dependencies
Maintainers
0
Versions
402
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-20240909092952 to 0.0.0-next-20240909101028

src/hooks.tsx

11

CHANGELOG.md
# @module-federation/bridge-react
## 0.0.0-next-20240909092952
## 0.0.0-next-20240909101028
### Patch Changes
- @module-federation/bridge-shared@0.0.0-next-20240909092952
- chore: bump next
- @module-federation/bridge-shared@0.0.0-next-20240909101028
## 0.6.1
### Patch Changes
- @module-federation/bridge-shared@0.6.1
## 0.6.0

@@ -10,0 +17,0 @@

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

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

@@ -403,3 +403,35 @@ });

}
function useBridgeRouteChange(onRouteChange) {
const previousUrlRef = React.useRef(window.location.pathname);
React.useEffect(() => {
const handleRouteChange = () => {
const currentUrl = window.location.pathname;
const from = previousUrlRef.current;
const to = currentUrl;
if (from !== to) {
onRouteChange({ from, to });
previousUrlRef.current = currentUrl;
}
};
const originalPushState = window.history.pushState;
const originalReplaceState = window.history.replaceState;
window.history.pushState = function(...args) {
originalPushState.apply(window.history, args);
handleRouteChange();
};
window.history.replaceState = function(...args) {
console.log("<<<<< replaceState called >>>>>>>", args);
originalReplaceState.apply(window.history, args);
handleRouteChange();
};
window.addEventListener("popstate", handleRouteChange);
return () => {
window.history.pushState = originalPushState;
window.history.replaceState = originalReplaceState;
window.removeEventListener("popstate", handleRouteChange);
};
}, [onRouteChange]);
}
exports.createBridgeComponent = createBridgeComponent;
exports.createRemoteComponent = createRemoteComponent;
exports.useBridgeRouteChange = useBridgeRouteChange;

@@ -69,2 +69,7 @@ import { ComponentType } from 'react';

export declare function useBridgeRouteChange(onRouteChange: ({ from, to }: {
from: string;
to: string;
}) => void): void;
export { }

@@ -161,3 +161,3 @@ import * as React from "react";

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

@@ -384,5 +384,37 @@ });

}
function useBridgeRouteChange(onRouteChange) {
const previousUrlRef = useRef(window.location.pathname);
useEffect(() => {
const handleRouteChange = () => {
const currentUrl = window.location.pathname;
const from = previousUrlRef.current;
const to = currentUrl;
if (from !== to) {
onRouteChange({ from, to });
previousUrlRef.current = currentUrl;
}
};
const originalPushState = window.history.pushState;
const originalReplaceState = window.history.replaceState;
window.history.pushState = function(...args) {
originalPushState.apply(window.history, args);
handleRouteChange();
};
window.history.replaceState = function(...args) {
console.log("<<<<< replaceState called >>>>>>>", args);
originalReplaceState.apply(window.history, args);
handleRouteChange();
};
window.addEventListener("popstate", handleRouteChange);
return () => {
window.history.pushState = originalPushState;
window.history.replaceState = originalReplaceState;
window.removeEventListener("popstate", handleRouteChange);
};
}, [onRouteChange]);
}
export {
createBridgeComponent,
createRemoteComponent
createRemoteComponent,
useBridgeRouteChange
};

4

package.json
{
"name": "@module-federation/bridge-react",
"version": "0.0.0-next-20240909092952",
"version": "0.0.0-next-20240909101028",
"publishConfig": {

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

"react-error-boundary": "^4.0.13",
"@module-federation/bridge-shared": "0.0.0-next-20240909092952"
"@module-federation/bridge-shared": "0.0.0-next-20240909101028"
},

@@ -41,0 +41,0 @@ "peerDependencies": {

export { createRemoteComponent } from './create';
export { createBridgeComponent } from './provider';
export { useBridgeRouteChange } from './hooks';
export type {

@@ -4,0 +5,0 @@ ProviderParams,

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