@thoughtbot/superglue 2.0.0-alpha.3 → 2.0.0-alpha.5
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/action_creators.mjs +1 -1
- package/dist/{chunk-EU2SLL5L.mjs → chunk-Q76JBI63.mjs} +229 -212
- package/dist/chunk-Q76JBI63.mjs.map +1 -0
- package/dist/cjs/action_creators.cjs +220 -203
- package/dist/cjs/action_creators.cjs.map +1 -1
- package/dist/cjs/superglue.cjs +222 -214
- package/dist/cjs/superglue.cjs.map +1 -1
- package/dist/superglue.mjs +10 -11
- package/dist/superglue.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-EU2SLL5L.mjs.map +0 -1
package/dist/superglue.mjs
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
ujsHandlers,
|
|
34
34
|
unproxy,
|
|
35
35
|
urlToPageKey
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-Q76JBI63.mjs";
|
|
37
37
|
|
|
38
38
|
// node_modules/lodash/lodash.js
|
|
39
39
|
var require_lodash = __commonJS({
|
|
@@ -5527,14 +5527,12 @@ import { useState, useEffect, useRef as useRef2, createContext, useContext } fro
|
|
|
5527
5527
|
import { useSelector as useSelector3 } from "react-redux";
|
|
5528
5528
|
|
|
5529
5529
|
// lib/hooks/useContent.tsx
|
|
5530
|
-
import { useSelector } from "react-redux";
|
|
5530
|
+
import { useSelector, useStore } from "react-redux";
|
|
5531
5531
|
import { useMemo, useRef } from "react";
|
|
5532
5532
|
function useContent(fragmentRef, options) {
|
|
5533
5533
|
const superglueState = useSuperglue();
|
|
5534
5534
|
const currentPageKey = superglueState.currentPageKey;
|
|
5535
5535
|
const dependencies = useRef(/* @__PURE__ */ new Set());
|
|
5536
|
-
const fragmentsHookRef = useRef({});
|
|
5537
|
-
const proxyCache = useRef(/* @__PURE__ */ new WeakMap());
|
|
5538
5536
|
const fragmentId = typeof fragmentRef === "string" ? fragmentRef : fragmentRef?.__id;
|
|
5539
5537
|
const sourceData = useSelector((state) => {
|
|
5540
5538
|
if (fragmentId) {
|
|
@@ -5543,7 +5541,7 @@ function useContent(fragmentRef, options) {
|
|
|
5543
5541
|
return state.pages[currentPageKey].data;
|
|
5544
5542
|
}
|
|
5545
5543
|
});
|
|
5546
|
-
const
|
|
5544
|
+
const trackedFragments = useSelector(
|
|
5547
5545
|
(state) => state.fragments,
|
|
5548
5546
|
(oldFragments, newFragments) => {
|
|
5549
5547
|
if (oldFragments === newFragments) {
|
|
@@ -5556,9 +5554,10 @@ function useContent(fragmentRef, options) {
|
|
|
5556
5554
|
});
|
|
5557
5555
|
}
|
|
5558
5556
|
);
|
|
5559
|
-
fragmentsHookRef.current = fragments;
|
|
5560
5557
|
const raiseOnMissing = !(options?.optional ?? false);
|
|
5558
|
+
const store = useStore();
|
|
5561
5559
|
const proxy = useMemo(() => {
|
|
5560
|
+
const proxyCache = /* @__PURE__ */ new WeakMap();
|
|
5562
5561
|
if (fragmentId && !sourceData) {
|
|
5563
5562
|
if (raiseOnMissing) {
|
|
5564
5563
|
throw new Error(`Fragment with id "${fragmentId}" not found`);
|
|
@@ -5568,11 +5567,11 @@ function useContent(fragmentRef, options) {
|
|
|
5568
5567
|
}
|
|
5569
5568
|
return createProxy(
|
|
5570
5569
|
sourceData,
|
|
5571
|
-
|
|
5570
|
+
{ current: store.getState().fragments },
|
|
5572
5571
|
dependencies.current,
|
|
5573
|
-
proxyCache
|
|
5572
|
+
proxyCache
|
|
5574
5573
|
);
|
|
5575
|
-
}, [sourceData, options?.optional]);
|
|
5574
|
+
}, [sourceData, trackedFragments, options?.optional]);
|
|
5576
5575
|
return proxy;
|
|
5577
5576
|
}
|
|
5578
5577
|
function unproxy2(proxy) {
|
|
@@ -5689,7 +5688,7 @@ import React, {
|
|
|
5689
5688
|
forwardRef,
|
|
5690
5689
|
useImperativeHandle
|
|
5691
5690
|
} from "react";
|
|
5692
|
-
import { useDispatch as useDispatch2, useSelector as useSelector4, useStore } from "react-redux";
|
|
5691
|
+
import { useDispatch as useDispatch2, useSelector as useSelector4, useStore as useStore2 } from "react-redux";
|
|
5693
5692
|
var NavigationContext = createContext2(
|
|
5694
5693
|
{}
|
|
5695
5694
|
);
|
|
@@ -5716,7 +5715,7 @@ var NavigationProvider = forwardRef(function NavigationProvider2({ history, visi
|
|
|
5716
5715
|
const currentPageKey = useSelector4(
|
|
5717
5716
|
(state) => state.superglue.currentPageKey
|
|
5718
5717
|
);
|
|
5719
|
-
const store =
|
|
5718
|
+
const store = useStore2();
|
|
5720
5719
|
useEffect2(() => {
|
|
5721
5720
|
return history.listen(onHistoryChange);
|
|
5722
5721
|
}, []);
|