@lolyjs/core 0.2.0-alpha.4 → 0.2.0-alpha.6

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.
package/dist/index.cjs CHANGED
@@ -5762,6 +5762,28 @@ function AppShell({
5762
5762
  window.removeEventListener("popstate", handlePopState, false);
5763
5763
  };
5764
5764
  }, []);
5765
+ (0, import_react3.useEffect)(() => {
5766
+ const handleDataRefresh = () => {
5767
+ const freshData = window?.__FW_DATA__;
5768
+ if (!freshData) return;
5769
+ const currentPathname = window.location.pathname;
5770
+ const freshPathname = freshData.pathname;
5771
+ if (freshPathname === currentPathname) {
5772
+ if (freshData.metadata !== void 0) {
5773
+ applyMetadata(freshData.metadata);
5774
+ }
5775
+ setState((prevState) => ({
5776
+ ...prevState,
5777
+ props: freshData.props ?? prevState.props,
5778
+ params: freshData.params ?? prevState.params
5779
+ }));
5780
+ }
5781
+ };
5782
+ window.addEventListener("fw-data-refresh", handleDataRefresh);
5783
+ return () => {
5784
+ window.removeEventListener("fw-data-refresh", handleDataRefresh);
5785
+ };
5786
+ }, [state.url]);
5765
5787
  const isError = state.route === errorRoute;
5766
5788
  const isNotFound = state.route === notFoundRoute;
5767
5789
  const routeType = isError ? "error" : isNotFound ? "notfound" : "normal";
@@ -5914,7 +5936,6 @@ function bootstrapClient(routes, notFoundRoute, errorRoute = null) {
5914
5936
  function withCache(fn, options) {
5915
5937
  const ttl = options.ttl ?? 60;
5916
5938
  return async function cachedGssp(ctx) {
5917
- console.log("TTL", ttl);
5918
5939
  return await fn(ctx);
5919
5940
  };
5920
5941
  }