@modern-js/plugin-garfish 2.68.14 → 2.68.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,13 +56,13 @@ function pathJoin(...args) {
56
56
  return res || "/";
57
57
  }
58
58
  function getAppInstance(options, appInfo, manifest) {
59
- let locationHref = "";
60
59
  const componentSetterRegistry = {
61
60
  current: null
62
61
  };
63
62
  function MicroApp(props) {
64
63
  var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
65
64
  const appRef = (0, import_react.useRef)(null);
65
+ const locationHrefRef = (0, import_react.useRef)("");
66
66
  const domId = (0, import_util.generateSubAppContainerKey)(appInfo);
67
67
  const [{ component: SubModuleComponent }, setSubModuleComponent] = (0, import_react.useState)({
68
68
  component: null
@@ -117,16 +117,21 @@ or directly pass the "basename":
117
117
  if (props.basename && typeof props.basename === "string") {
118
118
  basename = props.basename;
119
119
  }
120
+ const locationPathname = (0, import_react.useMemo)(function() {
121
+ return location ? location.pathname : "";
122
+ }, [
123
+ location ? location.pathname : ""
124
+ ]);
120
125
  (0, import_react.useEffect)(() => {
121
- if (location && locationHref !== location.pathname && !import_garfish.default.running) {
122
- locationHref = location.pathname;
126
+ if (location && locationHrefRef.current !== location.pathname && !import_garfish.default.running) {
127
+ locationHrefRef.current = location.pathname;
123
128
  const popStateEvent = new PopStateEvent("popstate");
124
129
  popStateEvent.garfish = true;
125
130
  dispatchEvent(popStateEvent);
126
131
  (0, import_util.logger)(`MicroApp Garfish.loadApp popstate`);
127
132
  }
128
133
  }, [
129
- location
134
+ locationPathname
130
135
  ]);
131
136
  (0, import_react.useEffect)(() => {
132
137
  componentSetterRegistry.current = setSubModuleComponent;
@@ -8,7 +8,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
8
8
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
9
9
  import { RuntimeReactContext } from "@meta/runtime";
10
10
  import Garfish from "garfish";
11
- import { useContext, useEffect, useRef, useState } from "react";
11
+ import { useContext, useEffect, useMemo, useRef, useState } from "react";
12
12
  import { generateSubAppContainerKey, logger } from "../../util";
13
13
  import { Loadable } from "../loadable";
14
14
  function pathJoin() {
@@ -32,13 +32,13 @@ function pathJoin() {
32
32
  return res || "/";
33
33
  }
34
34
  function getAppInstance(options, appInfo, manifest) {
35
- var locationHref = "";
36
35
  var componentSetterRegistry = {
37
36
  current: null
38
37
  };
39
38
  function MicroApp(props) {
40
39
  var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
41
40
  var appRef = useRef(null);
41
+ var locationHrefRef = useRef("");
42
42
  var domId = generateSubAppContainerKey(appInfo);
43
43
  var _useState = _sliced_to_array(useState({
44
44
  component: null
@@ -91,16 +91,21 @@ or directly pass the "basename":
91
91
  if (props.basename && typeof props.basename === "string") {
92
92
  basename = props.basename;
93
93
  }
94
+ var locationPathname = useMemo(function() {
95
+ return location ? location.pathname : "";
96
+ }, [
97
+ location ? location.pathname : ""
98
+ ]);
94
99
  useEffect(function() {
95
- if (location && locationHref !== location.pathname && !Garfish.running) {
96
- locationHref = location.pathname;
100
+ if (location && locationHrefRef.current !== location.pathname && !Garfish.running) {
101
+ locationHrefRef.current = location.pathname;
97
102
  var popStateEvent = new PopStateEvent("popstate");
98
103
  popStateEvent.garfish = true;
99
104
  dispatchEvent(popStateEvent);
100
105
  logger("MicroApp Garfish.loadApp popstate");
101
106
  }
102
107
  }, [
103
- location
108
+ locationPathname
104
109
  ]);
105
110
  useEffect(function() {
106
111
  var renderApp = function renderApp2() {
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { RuntimeReactContext } from "@meta/runtime";
3
3
  import Garfish from "garfish";
4
- import { useContext, useEffect, useRef, useState } from "react";
4
+ import { useContext, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { generateSubAppContainerKey, logger } from "../../util";
6
6
  import { Loadable } from "../loadable";
7
7
  function pathJoin(...args) {
@@ -22,13 +22,13 @@ function pathJoin(...args) {
22
22
  return res || "/";
23
23
  }
24
24
  function getAppInstance(options, appInfo, manifest) {
25
- let locationHref = "";
26
25
  const componentSetterRegistry = {
27
26
  current: null
28
27
  };
29
28
  function MicroApp(props) {
30
29
  var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
31
30
  const appRef = useRef(null);
31
+ const locationHrefRef = useRef("");
32
32
  const domId = generateSubAppContainerKey(appInfo);
33
33
  const [{ component: SubModuleComponent }, setSubModuleComponent] = useState({
34
34
  component: null
@@ -83,16 +83,21 @@ or directly pass the "basename":
83
83
  if (props.basename && typeof props.basename === "string") {
84
84
  basename = props.basename;
85
85
  }
86
+ const locationPathname = useMemo(function() {
87
+ return location ? location.pathname : "";
88
+ }, [
89
+ location ? location.pathname : ""
90
+ ]);
86
91
  useEffect(() => {
87
- if (location && locationHref !== location.pathname && !Garfish.running) {
88
- locationHref = location.pathname;
92
+ if (location && locationHrefRef.current !== location.pathname && !Garfish.running) {
93
+ locationHrefRef.current = location.pathname;
89
94
  const popStateEvent = new PopStateEvent("popstate");
90
95
  popStateEvent.garfish = true;
91
96
  dispatchEvent(popStateEvent);
92
97
  logger(`MicroApp Garfish.loadApp popstate`);
93
98
  }
94
99
  }, [
95
- location
100
+ locationPathname
96
101
  ]);
97
102
  useEffect(() => {
98
103
  componentSetterRegistry.current = setSubModuleComponent;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.68.14",
18
+ "version": "2.68.15",
19
19
  "jsnext:source": "./src/cli/index.ts",
20
20
  "types": "./dist/types/cli/index.d.ts",
21
21
  "typesVersions": {
@@ -69,12 +69,12 @@
69
69
  "debug": "4.3.7",
70
70
  "garfish": "^1.8.1",
71
71
  "react-loadable": "^5.5.0",
72
- "@modern-js/plugin-v2": "2.68.14",
73
- "@modern-js/runtime-utils": "2.68.14",
74
- "@modern-js/utils": "2.68.14"
72
+ "@modern-js/plugin-v2": "2.68.15",
73
+ "@modern-js/runtime-utils": "2.68.15",
74
+ "@modern-js/utils": "2.68.15"
75
75
  },
76
76
  "peerDependencies": {
77
- "@modern-js/runtime": "^2.68.14",
77
+ "@modern-js/runtime": "^2.68.15",
78
78
  "react": ">=17",
79
79
  "react-dom": ">=17"
80
80
  },
@@ -93,12 +93,12 @@
93
93
  "react-dom": "^18.3.1",
94
94
  "react-router-dom": "6.27.0",
95
95
  "typescript": "^5",
96
- "@modern-js/app-tools": "2.68.14",
97
- "@modern-js/core": "2.68.14",
98
- "@modern-js/plugin-router-v5": "2.68.14",
99
- "@modern-js/types": "2.68.14",
100
- "@modern-js/runtime": "2.68.14",
96
+ "@modern-js/app-tools": "2.68.15",
97
+ "@modern-js/core": "2.68.15",
98
+ "@modern-js/runtime": "2.68.15",
101
99
  "@scripts/build": "2.66.0",
100
+ "@modern-js/plugin-router-v5": "2.68.15",
101
+ "@modern-js/types": "2.68.15",
102
102
  "@scripts/jest-config": "2.66.0"
103
103
  },
104
104
  "sideEffects": false,