@thoughtbot/superglue 1.0.3 → 2.0.0-alpha.10
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/.tool-versions +1 -2
- package/dist/action_creators.d.mts +1 -1
- package/dist/action_creators.mjs +1 -1
- package/dist/{chunk-ENOVWJUC.mjs → chunk-J2XH5QTK.mjs} +565 -68
- package/dist/chunk-J2XH5QTK.mjs.map +1 -0
- package/dist/cjs/action_creators.cjs +535 -66
- package/dist/cjs/action_creators.cjs.map +1 -1
- package/dist/cjs/superglue.cjs +780 -112
- package/dist/cjs/superglue.cjs.map +1 -1
- package/dist/{index-BYr1PoYr.d.mts → index-j0c-9ZLt.d.mts} +69 -18
- package/dist/superglue.d.mts +46 -14
- package/dist/superglue.mjs +267 -54
- package/dist/superglue.mjs.map +1 -1
- package/package.json +16 -8
- package/thoughtbot-superglue-2.0.0-alpha.10.tgz +0 -0
- package/typedoc.json +1 -0
- package/dist/chunk-ENOVWJUC.mjs.map +0 -1
package/dist/superglue.mjs
CHANGED
|
@@ -1,42 +1,210 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GRAFTING_ERROR,
|
|
3
3
|
GRAFTING_SUCCESS,
|
|
4
|
+
appendToFragment,
|
|
4
5
|
argsForHistory,
|
|
5
6
|
beforeFetch,
|
|
6
7
|
beforeRemote,
|
|
7
8
|
beforeVisit,
|
|
8
9
|
config,
|
|
9
10
|
copyPage,
|
|
11
|
+
createProxy,
|
|
10
12
|
getIn,
|
|
13
|
+
handleFragmentGraft,
|
|
11
14
|
handleGraft,
|
|
15
|
+
handleStreamMessage,
|
|
12
16
|
historyChange,
|
|
17
|
+
lastRequestIds,
|
|
13
18
|
parsePageKey,
|
|
19
|
+
prependToFragment,
|
|
20
|
+
receiveResponse,
|
|
14
21
|
removePage,
|
|
15
22
|
saveAndProcessPage,
|
|
23
|
+
saveFragment,
|
|
16
24
|
saveResponse,
|
|
17
25
|
setActivePage,
|
|
18
26
|
setCSRFToken,
|
|
19
27
|
setIn,
|
|
28
|
+
streamAppend,
|
|
29
|
+
streamPrepend,
|
|
30
|
+
streamSave,
|
|
20
31
|
ujsHandlers,
|
|
21
|
-
|
|
32
|
+
unproxy,
|
|
22
33
|
urlToPageKey
|
|
23
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-J2XH5QTK.mjs";
|
|
24
35
|
|
|
25
36
|
// lib/index.tsx
|
|
26
|
-
import React2, { useRef, useMemo } from "react";
|
|
37
|
+
import React2, { useRef as useRef3, useMemo as useMemo2 } from "react";
|
|
27
38
|
import { Provider } from "react-redux";
|
|
39
|
+
|
|
40
|
+
// lib/hooks/useStreamSource.tsx
|
|
41
|
+
import { useState, useEffect, useRef as useRef2, createContext, useContext } from "react";
|
|
42
|
+
|
|
43
|
+
// lib/hooks/index.ts
|
|
44
|
+
import { useSelector as useSelector3 } from "react-redux";
|
|
45
|
+
|
|
46
|
+
// lib/hooks/useContent.tsx
|
|
47
|
+
import { useSelector, useStore } from "react-redux";
|
|
48
|
+
import { useMemo, useRef } from "react";
|
|
49
|
+
function useContent(fragmentRef) {
|
|
50
|
+
const superglueState = useSuperglue();
|
|
51
|
+
const currentPageKey = superglueState.currentPageKey;
|
|
52
|
+
const dependencies = useRef(/* @__PURE__ */ new Set());
|
|
53
|
+
const fragmentId = typeof fragmentRef === "string" ? fragmentRef : fragmentRef?.__id;
|
|
54
|
+
const sourceData = useSelector((state) => {
|
|
55
|
+
if (fragmentId) {
|
|
56
|
+
return state.fragments[fragmentId];
|
|
57
|
+
} else {
|
|
58
|
+
return state.pages[currentPageKey].data;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const trackedFragments = useSelector(
|
|
62
|
+
(state) => state.fragments,
|
|
63
|
+
(oldFragments, newFragments) => {
|
|
64
|
+
if (oldFragments === newFragments) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
return Array.from(dependencies.current).every((id) => {
|
|
68
|
+
const prevVal = oldFragments[id];
|
|
69
|
+
const nextVal = newFragments[id];
|
|
70
|
+
return prevVal === nextVal;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
const store = useStore();
|
|
75
|
+
const proxy = useMemo(() => {
|
|
76
|
+
const proxyCache = /* @__PURE__ */ new WeakMap();
|
|
77
|
+
if (fragmentId && !sourceData) {
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
return createProxy(
|
|
81
|
+
sourceData,
|
|
82
|
+
{ current: store.getState().fragments },
|
|
83
|
+
dependencies.current,
|
|
84
|
+
proxyCache
|
|
85
|
+
);
|
|
86
|
+
}, [sourceData, trackedFragments]);
|
|
87
|
+
return proxy;
|
|
88
|
+
}
|
|
89
|
+
function unproxy2(proxy) {
|
|
90
|
+
return unproxy(proxy);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// lib/hooks/useSetFragment.tsx
|
|
94
|
+
import { useDispatch, useSelector as useSelector2 } from "react-redux";
|
|
95
|
+
import { Immer } from "immer";
|
|
96
|
+
var immer = new Immer();
|
|
97
|
+
immer.setAutoFreeze(false);
|
|
98
|
+
function useSetFragment() {
|
|
99
|
+
const dispatch = useDispatch();
|
|
100
|
+
const fragments = useSelector2((state) => state.fragments);
|
|
101
|
+
function setter(fragmentRefOrId, updater) {
|
|
102
|
+
const fragmentId = typeof fragmentRefOrId === "string" ? fragmentRefOrId : fragmentRefOrId.__id;
|
|
103
|
+
const currentFragment = fragments[fragmentId];
|
|
104
|
+
if (currentFragment === void 0) {
|
|
105
|
+
throw new Error(`Fragment with id "${fragmentId}" not found`);
|
|
106
|
+
}
|
|
107
|
+
const updatedFragment = immer.produce(currentFragment, updater);
|
|
108
|
+
dispatch(
|
|
109
|
+
saveFragment({
|
|
110
|
+
fragmentId,
|
|
111
|
+
data: updatedFragment
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return setter;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// lib/hooks/index.ts
|
|
119
|
+
function useSuperglue() {
|
|
120
|
+
return useSelector3((state) => state.superglue);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// lib/hooks/useStreamSource.tsx
|
|
124
|
+
import debounce from "lodash.debounce";
|
|
125
|
+
var StreamActions = class {
|
|
126
|
+
constructor({
|
|
127
|
+
remote,
|
|
128
|
+
store
|
|
129
|
+
}) {
|
|
130
|
+
this.store = store;
|
|
131
|
+
this.remote = debounce(remote, 300);
|
|
132
|
+
}
|
|
133
|
+
refresh(pageKey) {
|
|
134
|
+
this.remote(pageKey);
|
|
135
|
+
}
|
|
136
|
+
prepend(fragments, data, options = {}) {
|
|
137
|
+
this.store.dispatch(streamPrepend(fragments, data, options));
|
|
138
|
+
}
|
|
139
|
+
save(fragment, data) {
|
|
140
|
+
this.store.dispatch(streamSave(fragment, data));
|
|
141
|
+
}
|
|
142
|
+
append(fragments, data, options = {}) {
|
|
143
|
+
this.store.dispatch(streamAppend(fragments, data, options));
|
|
144
|
+
}
|
|
145
|
+
handle(rawMessage, currentPageKey) {
|
|
146
|
+
const message = JSON.parse(rawMessage);
|
|
147
|
+
const { superglue } = this.store.getState();
|
|
148
|
+
const nextPageKey = superglue.currentPageKey;
|
|
149
|
+
if (message.action === "handleStreamMessage") {
|
|
150
|
+
if (message.handler === "refresh" && currentPageKey === nextPageKey && !lastRequestIds.has(message.requestId)) {
|
|
151
|
+
this.refresh(currentPageKey);
|
|
152
|
+
}
|
|
153
|
+
if (message.handler !== "refresh") {
|
|
154
|
+
this.store.dispatch(handleStreamMessage(rawMessage));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var CableContext = createContext({
|
|
160
|
+
cable: null,
|
|
161
|
+
streamActions: null
|
|
162
|
+
});
|
|
163
|
+
function useStreamSource(channel) {
|
|
164
|
+
const { cable: cable2, streamActions } = useContext(CableContext);
|
|
165
|
+
const [connected, setConnected] = useState(false);
|
|
166
|
+
const { currentPageKey } = useSuperglue();
|
|
167
|
+
const subscriptionRef = useRef2(null);
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
if (cable2) {
|
|
170
|
+
const subscription = cable2.subscriptions.create(channel, {
|
|
171
|
+
received: (message) => {
|
|
172
|
+
streamActions?.handle(message, currentPageKey);
|
|
173
|
+
},
|
|
174
|
+
connected: () => {
|
|
175
|
+
setConnected(true);
|
|
176
|
+
},
|
|
177
|
+
disconnected: () => setConnected(false)
|
|
178
|
+
});
|
|
179
|
+
subscriptionRef.current = subscription;
|
|
180
|
+
return () => subscription.unsubscribe();
|
|
181
|
+
} else {
|
|
182
|
+
subscriptionRef.current = null;
|
|
183
|
+
setConnected(false);
|
|
184
|
+
return () => {
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}, [cable2, JSON.stringify(channel), currentPageKey]);
|
|
188
|
+
return {
|
|
189
|
+
connected,
|
|
190
|
+
subscription: subscriptionRef.current
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// lib/index.tsx
|
|
195
|
+
import { createConsumer } from "@rails/actioncable";
|
|
28
196
|
import { createBrowserHistory, createMemoryHistory } from "history";
|
|
29
197
|
|
|
30
198
|
// lib/components/Navigation.tsx
|
|
31
199
|
import React, {
|
|
32
|
-
createContext,
|
|
33
|
-
useEffect,
|
|
200
|
+
createContext as createContext2,
|
|
201
|
+
useEffect as useEffect2,
|
|
34
202
|
useLayoutEffect,
|
|
35
203
|
forwardRef,
|
|
36
204
|
useImperativeHandle
|
|
37
205
|
} from "react";
|
|
38
|
-
import { useDispatch, useSelector, useStore } from "react-redux";
|
|
39
|
-
var NavigationContext =
|
|
206
|
+
import { useDispatch as useDispatch2, useSelector as useSelector4, useStore as useStore2 } from "react-redux";
|
|
207
|
+
var NavigationContext = createContext2(
|
|
40
208
|
{}
|
|
41
209
|
);
|
|
42
210
|
var hasWindow = typeof window !== "undefined";
|
|
@@ -54,16 +222,16 @@ var notFound = (identifier) => {
|
|
|
54
222
|
throw error;
|
|
55
223
|
};
|
|
56
224
|
var NavigationProvider = forwardRef(function NavigationProvider2({ history, visit, remote, mapping }, ref) {
|
|
57
|
-
const dispatch =
|
|
58
|
-
const pages =
|
|
59
|
-
const superglue =
|
|
225
|
+
const dispatch = useDispatch2();
|
|
226
|
+
const pages = useSelector4((state) => state.pages);
|
|
227
|
+
const superglue = useSelector4(
|
|
60
228
|
(state) => state.superglue
|
|
61
229
|
);
|
|
62
|
-
const currentPageKey =
|
|
230
|
+
const currentPageKey = useSelector4(
|
|
63
231
|
(state) => state.superglue.currentPageKey
|
|
64
232
|
);
|
|
65
|
-
const store =
|
|
66
|
-
|
|
233
|
+
const store = useStore2();
|
|
234
|
+
useEffect2(() => {
|
|
67
235
|
return history.listen(onHistoryChange);
|
|
68
236
|
}, []);
|
|
69
237
|
useLayoutEffect(() => {
|
|
@@ -98,7 +266,6 @@ var NavigationProvider = forwardRef(function NavigationProvider2({ history, visi
|
|
|
98
266
|
hash: location.hash
|
|
99
267
|
},
|
|
100
268
|
{
|
|
101
|
-
pageKey: nextPageKey,
|
|
102
269
|
superglue: true,
|
|
103
270
|
posY: window.pageYOffset,
|
|
104
271
|
posX: window.pageXOffset
|
|
@@ -107,7 +274,7 @@ var NavigationProvider = forwardRef(function NavigationProvider2({ history, visi
|
|
|
107
274
|
}
|
|
108
275
|
}
|
|
109
276
|
if (state && "superglue" in state) {
|
|
110
|
-
const
|
|
277
|
+
const pageKey = urlToPageKey(location.pathname + location.search);
|
|
111
278
|
const prevPageKey = store.getState().superglue.currentPageKey;
|
|
112
279
|
const containsKey = !!pages[pageKey];
|
|
113
280
|
if (containsKey) {
|
|
@@ -156,7 +323,6 @@ var NavigationProvider = forwardRef(function NavigationProvider2({ history, visi
|
|
|
156
323
|
const historyArgs = [
|
|
157
324
|
path,
|
|
158
325
|
{
|
|
159
|
-
pageKey: nextPageKey,
|
|
160
326
|
superglue: true,
|
|
161
327
|
posY: 0,
|
|
162
328
|
posX: 0
|
|
@@ -215,17 +381,6 @@ var NavigationProvider = forwardRef(function NavigationProvider2({ history, visi
|
|
|
215
381
|
});
|
|
216
382
|
|
|
217
383
|
// lib/reducers/index.ts
|
|
218
|
-
function addPlaceholdersToDeferredNodes(existingPage, page) {
|
|
219
|
-
const { defers = [] } = existingPage;
|
|
220
|
-
const prevDefers = defers.map(({ path }) => {
|
|
221
|
-
const node = getIn(existingPage, path);
|
|
222
|
-
const copy = JSON.stringify(node);
|
|
223
|
-
return [path, JSON.parse(copy)];
|
|
224
|
-
});
|
|
225
|
-
return prevDefers.reduce((memo, [path, node]) => {
|
|
226
|
-
return setIn(page, path, node);
|
|
227
|
-
}, page);
|
|
228
|
-
}
|
|
229
384
|
function constrainPagesSize(state) {
|
|
230
385
|
const { maxPages } = config;
|
|
231
386
|
const allPageKeys = Object.keys(state);
|
|
@@ -238,14 +393,10 @@ function constrainPagesSize(state) {
|
|
|
238
393
|
}
|
|
239
394
|
function handleSaveResponse(state, pageKey, page) {
|
|
240
395
|
state = { ...state };
|
|
241
|
-
|
|
396
|
+
const nextPage = {
|
|
242
397
|
...page,
|
|
243
398
|
savedAt: Date.now()
|
|
244
399
|
};
|
|
245
|
-
const existingPage = state[pageKey];
|
|
246
|
-
if (existingPage) {
|
|
247
|
-
nextPage = addPlaceholdersToDeferredNodes(existingPage, nextPage);
|
|
248
|
-
}
|
|
249
400
|
constrainPagesSize(state);
|
|
250
401
|
state[pageKey] = nextPage;
|
|
251
402
|
return state;
|
|
@@ -275,7 +426,7 @@ function appendReceivedFragmentsOntoPage(state, pageKey, receivedFragments) {
|
|
|
275
426
|
nextState[pageKey] = nextPage;
|
|
276
427
|
return nextState;
|
|
277
428
|
}
|
|
278
|
-
function
|
|
429
|
+
function graftNodeOntoTarget(state, pageKey, node, pathToNode) {
|
|
279
430
|
if (!node) {
|
|
280
431
|
console.warn(
|
|
281
432
|
"There was no node returned in the response. Do you have the correct key path in your props_at?"
|
|
@@ -288,6 +439,17 @@ function graftNodeOntoPage(state, pageKey, node, pathToNode) {
|
|
|
288
439
|
const fullPathToNode = [pageKey, pathToNode].join(".");
|
|
289
440
|
return setIn(state, fullPathToNode, node);
|
|
290
441
|
}
|
|
442
|
+
function handleFragmentGraftResponse(state, key, response) {
|
|
443
|
+
const target = state[key];
|
|
444
|
+
if (!target) {
|
|
445
|
+
const error = new Error(
|
|
446
|
+
`Superglue was looking for ${key} in your fragments, but could not find it.`
|
|
447
|
+
);
|
|
448
|
+
throw error;
|
|
449
|
+
}
|
|
450
|
+
const { data: receivedNode, path: pathToNode } = response;
|
|
451
|
+
return graftNodeOntoTarget(state, key, receivedNode, pathToNode);
|
|
452
|
+
}
|
|
291
453
|
function handleGraftResponse(state, pageKey, page) {
|
|
292
454
|
const currentPage = state[pageKey];
|
|
293
455
|
if (!currentPage) {
|
|
@@ -302,7 +464,7 @@ function handleGraftResponse(state, pageKey, page) {
|
|
|
302
464
|
fragments: receivedFragments = []
|
|
303
465
|
} = page;
|
|
304
466
|
return [
|
|
305
|
-
(nextState) =>
|
|
467
|
+
(nextState) => graftNodeOntoTarget(nextState, pageKey, receivedNode, pathToNode),
|
|
306
468
|
(nextState) => appendReceivedFragmentsOntoPage(nextState, pageKey, receivedFragments)
|
|
307
469
|
].reduce((memo, fn) => fn(memo), state);
|
|
308
470
|
}
|
|
@@ -365,25 +527,68 @@ function superglueReducer(state = {
|
|
|
365
527
|
}
|
|
366
528
|
return state;
|
|
367
529
|
}
|
|
530
|
+
function fragmentReducer(state = {}, action) {
|
|
531
|
+
if (handleFragmentGraft.match(action)) {
|
|
532
|
+
const { fragmentId, response } = action.payload;
|
|
533
|
+
return handleFragmentGraftResponse(state, fragmentId, response);
|
|
534
|
+
}
|
|
535
|
+
if (saveFragment.match(action)) {
|
|
536
|
+
const { fragmentId, data } = action.payload;
|
|
537
|
+
return {
|
|
538
|
+
...state,
|
|
539
|
+
[fragmentId]: data
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
if (appendToFragment.match(action)) {
|
|
543
|
+
const { data, fragmentId } = action.payload;
|
|
544
|
+
let targetFragment = state[fragmentId];
|
|
545
|
+
if (Array.isArray(targetFragment)) {
|
|
546
|
+
targetFragment = [...targetFragment, data];
|
|
547
|
+
return {
|
|
548
|
+
...state,
|
|
549
|
+
[fragmentId]: targetFragment
|
|
550
|
+
};
|
|
551
|
+
} else {
|
|
552
|
+
return state;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
if (prependToFragment.match(action)) {
|
|
556
|
+
const { data, fragmentId } = action.payload;
|
|
557
|
+
let targetFragment = state[fragmentId];
|
|
558
|
+
if (Array.isArray(targetFragment)) {
|
|
559
|
+
targetFragment = [data, ...targetFragment];
|
|
560
|
+
return {
|
|
561
|
+
...state,
|
|
562
|
+
[fragmentId]: targetFragment
|
|
563
|
+
};
|
|
564
|
+
} else {
|
|
565
|
+
return state;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return state;
|
|
569
|
+
}
|
|
368
570
|
var rootReducer = {
|
|
369
571
|
superglue: superglueReducer,
|
|
370
|
-
pages: pageReducer
|
|
572
|
+
pages: pageReducer,
|
|
573
|
+
fragments: fragmentReducer
|
|
371
574
|
};
|
|
372
575
|
|
|
373
|
-
// lib/hooks/index.ts
|
|
374
|
-
import { useSelector as useSelector2 } from "react-redux";
|
|
375
|
-
function useSuperglue() {
|
|
376
|
-
return useSelector2((state) => state.superglue);
|
|
377
|
-
}
|
|
378
|
-
function useContent() {
|
|
379
|
-
const superglueState = useSuperglue();
|
|
380
|
-
const currentPageKey = superglueState.currentPageKey;
|
|
381
|
-
return useSelector2(
|
|
382
|
-
(state) => state.pages[currentPageKey]
|
|
383
|
-
).data;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
576
|
// lib/index.tsx
|
|
577
|
+
function getConfig(name) {
|
|
578
|
+
if (typeof document !== "undefined") {
|
|
579
|
+
const element = document.head.querySelector(
|
|
580
|
+
`meta[name='action-cable-${name}']`
|
|
581
|
+
);
|
|
582
|
+
if (element) {
|
|
583
|
+
return element.getAttribute("content") || "/cable";
|
|
584
|
+
} else {
|
|
585
|
+
return "/cable";
|
|
586
|
+
}
|
|
587
|
+
} else {
|
|
588
|
+
return "/cable";
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
var cable = createConsumer(getConfig("url"));
|
|
387
592
|
var hasWindow2 = typeof window !== "undefined";
|
|
388
593
|
var createHistory = () => {
|
|
389
594
|
if (hasWindow2) {
|
|
@@ -400,6 +605,9 @@ var prepareStore = (store, initialPage, path) => {
|
|
|
400
605
|
pageKey: initialPageKey
|
|
401
606
|
})
|
|
402
607
|
);
|
|
608
|
+
store.dispatch(
|
|
609
|
+
receiveResponse({ pageKey: initialPageKey, response: initialPage })
|
|
610
|
+
);
|
|
403
611
|
store.dispatch(saveAndProcessPage(initialPageKey, initialPage));
|
|
404
612
|
store.dispatch(setCSRFToken({ csrfToken }));
|
|
405
613
|
};
|
|
@@ -424,12 +632,14 @@ var setup = ({
|
|
|
424
632
|
ujsAttributePrefix: "data-sg",
|
|
425
633
|
store
|
|
426
634
|
});
|
|
635
|
+
const streamActions = new StreamActions({ remote, store });
|
|
427
636
|
return {
|
|
428
637
|
visit,
|
|
429
638
|
remote,
|
|
430
639
|
nextHistory,
|
|
431
640
|
initialPageKey,
|
|
432
|
-
ujs: handlers
|
|
641
|
+
ujs: handlers,
|
|
642
|
+
streamActions
|
|
433
643
|
};
|
|
434
644
|
};
|
|
435
645
|
function Application({
|
|
@@ -442,8 +652,8 @@ function Application({
|
|
|
442
652
|
mapping,
|
|
443
653
|
...rest
|
|
444
654
|
}) {
|
|
445
|
-
const navigatorRef =
|
|
446
|
-
const { visit, remote, nextHistory, initialPageKey, ujs } =
|
|
655
|
+
const navigatorRef = useRef3(null);
|
|
656
|
+
const { visit, remote, nextHistory, initialPageKey, ujs, streamActions } = useMemo2(() => {
|
|
447
657
|
return setup({
|
|
448
658
|
initialPage,
|
|
449
659
|
baseUrl,
|
|
@@ -454,7 +664,7 @@ function Application({
|
|
|
454
664
|
navigatorRef
|
|
455
665
|
});
|
|
456
666
|
}, []);
|
|
457
|
-
return /* @__PURE__ */ React2.createElement("div", { onClick: ujs.onClick, onSubmit: ujs.onSubmit, ...rest }, /* @__PURE__ */ React2.createElement(Provider, { store }, /* @__PURE__ */ React2.createElement(
|
|
667
|
+
return /* @__PURE__ */ React2.createElement("div", { onClick: ujs.onClick, onSubmit: ujs.onSubmit, ...rest }, /* @__PURE__ */ React2.createElement(Provider, { store }, /* @__PURE__ */ React2.createElement(CableContext.Provider, { value: { streamActions, cable } }, /* @__PURE__ */ React2.createElement(
|
|
458
668
|
NavigationProvider,
|
|
459
669
|
{
|
|
460
670
|
ref: navigatorRef,
|
|
@@ -464,7 +674,7 @@ function Application({
|
|
|
464
674
|
history: nextHistory,
|
|
465
675
|
initialPageKey
|
|
466
676
|
}
|
|
467
|
-
)));
|
|
677
|
+
))));
|
|
468
678
|
}
|
|
469
679
|
export {
|
|
470
680
|
Application,
|
|
@@ -479,15 +689,18 @@ export {
|
|
|
479
689
|
getIn,
|
|
480
690
|
pageReducer,
|
|
481
691
|
prepareStore,
|
|
692
|
+
receiveResponse,
|
|
482
693
|
removePage,
|
|
483
694
|
rootReducer,
|
|
484
695
|
saveAndProcessPage,
|
|
485
696
|
saveResponse,
|
|
486
697
|
setup,
|
|
487
698
|
superglueReducer,
|
|
488
|
-
|
|
699
|
+
unproxy2 as unproxy,
|
|
489
700
|
urlToPageKey,
|
|
490
701
|
useContent,
|
|
702
|
+
useSetFragment,
|
|
703
|
+
useStreamSource,
|
|
491
704
|
useSuperglue
|
|
492
705
|
};
|
|
493
706
|
//# sourceMappingURL=superglue.mjs.map
|
package/dist/superglue.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/index.tsx","../lib/components/Navigation.tsx","../lib/reducers/index.ts","../lib/hooks/index.ts"],"sourcesContent":["import React, { useRef, useMemo } from 'react'\nimport { config } from './config'\nimport { urlToPageKey, ujsHandlers, argsForHistory } from './utils'\nimport { saveAndProcessPage } from './action_creators'\nimport { historyChange, setCSRFToken } from './actions'\nimport { Provider } from 'react-redux'\n\nimport { createBrowserHistory, createMemoryHistory } from 'history'\n\nimport { NavigationProvider } from './components/Navigation'\nexport { NavigationProvider, NavigationContext } from './components/Navigation'\nexport { saveAndProcessPage } from './action_creators'\nexport {\n beforeFetch,\n beforeVisit,\n beforeRemote,\n updateFragments,\n copyPage,\n removePage,\n saveResponse,\n GRAFTING_ERROR,\n GRAFTING_SUCCESS,\n} from './actions'\nexport * from './types'\n\nimport {\n VisitResponse,\n ApplicationProps,\n NavigateTo,\n SuperglueStore,\n SetupProps,\n} from './types'\nexport { superglueReducer, pageReducer, rootReducer } from './reducers'\nexport { getIn } from './utils/immutability'\nexport { urlToPageKey }\nexport * from './hooks'\n\nconst hasWindow = typeof window !== 'undefined'\n\nconst createHistory = () => {\n if (hasWindow) {\n // This is used for client side rendering\n return createBrowserHistory({})\n } else {\n // This is used for server side rendering\n return createMemoryHistory({})\n }\n}\n\nexport const prepareStore = (\n store: SuperglueStore,\n initialPage: VisitResponse,\n path: string\n) => {\n const initialPageKey = urlToPageKey(path)\n const { csrfToken } = initialPage\n\n store.dispatch(\n historyChange({\n pageKey: initialPageKey,\n })\n )\n store.dispatch(saveAndProcessPage(initialPageKey, initialPage))\n store.dispatch(setCSRFToken({ csrfToken }))\n}\n\n/**\n * This is the setup function that the Application calls. Use this function if\n * you like to build your own Application component.\n */\nexport const setup = ({\n initialPage,\n baseUrl,\n path,\n store,\n buildVisitAndRemote,\n history,\n navigatorRef,\n}: SetupProps) => {\n config.baseUrl = baseUrl\n\n const { visit, remote } = buildVisitAndRemote(navigatorRef, store)\n\n const initialPageKey = urlToPageKey(path)\n const nextHistory = history || createHistory()\n nextHistory.replace(...argsForHistory(path))\n prepareStore(store, initialPage, path)\n\n const handlers = ujsHandlers({\n visit,\n remote,\n ujsAttributePrefix: 'data-sg',\n store,\n })\n\n return {\n visit,\n remote,\n nextHistory,\n initialPageKey,\n ujs: handlers,\n }\n}\n\n/**\n * The entry point to your superglue application. It sets up the redux Provider,\n * redux state and the Navigation component.\n *\n * This is a simple component, you can override this by copying the source code and\n * use the exported methods used by this component (`start` and `ujsHandler`).\n */\nfunction Application({\n initialPage,\n baseUrl,\n path,\n store,\n buildVisitAndRemote,\n history,\n mapping,\n ...rest\n}: ApplicationProps) {\n const navigatorRef = useRef<{ navigateTo: NavigateTo } | null>(null)\n\n const { visit, remote, nextHistory, initialPageKey, ujs } = useMemo(() => {\n return setup({\n initialPage,\n baseUrl,\n path,\n store,\n buildVisitAndRemote,\n history,\n navigatorRef,\n })\n }, [])\n\n // The Nav component is pretty bare and can be inherited from for custom\n // behavior or replaced with your own.\n return (\n <div onClick={ujs.onClick} onSubmit={ujs.onSubmit} {...rest}>\n <Provider store={store}>\n <NavigationProvider\n ref={navigatorRef}\n visit={visit}\n remote={remote}\n mapping={mapping}\n history={nextHistory}\n initialPageKey={initialPageKey}\n />\n </Provider>\n </div>\n )\n}\n\nexport { Application }\n","import React, {\n createContext,\n useEffect,\n useLayoutEffect,\n forwardRef,\n useImperativeHandle,\n ForwardedRef,\n} from 'react'\nimport { urlToPageKey } from '../utils'\nimport { removePage, setActivePage } from '../actions'\nimport {\n HistoryState,\n RootState,\n NavigateTo,\n NavigationContextProps,\n NavigationProviderProps,\n AllPages,\n SuperglueState,\n} from '../types'\nimport { Update } from 'history'\nimport { useDispatch, useSelector, useStore } from 'react-redux'\n\nconst NavigationContext = createContext<NavigationContextProps>(\n {} as NavigationContextProps\n)\n\nconst hasWindow = typeof window !== 'undefined'\n\nconst setWindowScroll = (posX: number, posY: number): void => {\n hasWindow && window.scrollTo(posX, posY)\n}\n\nconst notFound = (identifier: string | undefined): never => {\n let reminder = ''\n if (!identifier) {\n reminder =\n 'Did you forget to add `json.componentIdentifier` in your application.json.props layout?'\n }\n\n const error = new Error(\n `Superglue Nav component was looking for ${identifier} but could not find it in your mapping. ${reminder}`\n )\n\n throw error\n}\n\nconst NavigationProvider = forwardRef(function NavigationProvider(\n { history, visit, remote, mapping }: NavigationProviderProps,\n ref: ForwardedRef<{ navigateTo: NavigateTo | null }>\n) {\n const dispatch = useDispatch()\n const pages = useSelector<RootState, AllPages>((state) => state.pages)\n const superglue = useSelector<RootState, SuperglueState>(\n (state) => state.superglue\n )\n const currentPageKey = useSelector<RootState, string>(\n (state) => state.superglue.currentPageKey\n )\n const store = useStore<RootState>()\n\n useEffect(() => {\n return history.listen(onHistoryChange)\n }, [])\n\n useLayoutEffect(() => {\n const state = history.location.state as HistoryState\n if (state && 'superglue' in state) {\n const { posX, posY } = state\n setWindowScroll(posX, posY)\n }\n }, [currentPageKey])\n\n useImperativeHandle(\n ref,\n () => {\n return {\n navigateTo,\n }\n },\n []\n )\n\n const onHistoryChange = ({ location, action }: Update): void => {\n const state = location.state as HistoryState\n\n if (action !== 'POP') {\n return\n }\n\n if (!state && location.hash !== '') {\n const nextPageKey = urlToPageKey(location.pathname + location.search)\n const containsKey = !!pages[nextPageKey]\n if (containsKey) {\n history.replace(\n {\n pathname: location.pathname,\n search: location.search,\n hash: location.hash,\n },\n {\n pageKey: nextPageKey,\n superglue: true,\n posY: window.pageYOffset,\n posX: window.pageXOffset,\n }\n )\n }\n }\n\n if (state && 'superglue' in state) {\n const { pageKey } = state\n const prevPageKey = store.getState().superglue.currentPageKey\n const containsKey = !!pages[pageKey]\n\n if (containsKey) {\n const { restoreStrategy } = pages[pageKey]\n\n switch (restoreStrategy) {\n case 'fromCacheOnly':\n dispatch(setActivePage({ pageKey }))\n break\n case 'fromCacheAndRevisitInBackground':\n dispatch(setActivePage({ pageKey }))\n visit(pageKey, { revisit: true })\n break\n case 'revisitOnly':\n default:\n visit(pageKey, { revisit: true }).then(() => {\n const noNav =\n prevPageKey === store.getState().superglue.currentPageKey\n if (noNav) {\n // When \"POP'ed\", revisiting (using revisit: true) a page can result in\n // a redirect, or a render of the same page.\n //\n // When its a redirect, calculateNavAction will correctly set the\n // navigationAction to `replace` this is the noop scenario.\n //\n // When its the same page, navigationAction is set to `none` and\n // no navigation took place. In that case, we have to set the\n // activePage otherwise the user is stuck on the original page.\n dispatch(setActivePage({ pageKey }))\n }\n })\n }\n } else {\n visit(pageKey, { revisit: true }).then(() => {\n const noNav =\n prevPageKey === store.getState().superglue.currentPageKey\n if (noNav) {\n dispatch(setActivePage({ pageKey }))\n }\n })\n }\n }\n }\n\n const navigateTo: NavigateTo = (\n path,\n { action } = {\n action: 'push',\n }\n ) => {\n if (action === 'none') {\n return false\n }\n\n const nextPageKey = urlToPageKey(path)\n const hasPage = Object.prototype.hasOwnProperty.call(\n store.getState().pages,\n nextPageKey\n )\n\n if (hasPage) {\n const location = history.location\n const state = location.state as HistoryState\n const historyArgs = [\n path,\n {\n pageKey: nextPageKey,\n superglue: true,\n posY: 0,\n posX: 0,\n },\n ] as const\n\n if (action === 'push') {\n if (hasWindow) {\n history.replace(\n {\n pathname: location.pathname,\n search: location.search,\n hash: location.hash,\n },\n {\n ...state,\n posY: window.scrollY,\n posX: window.scrollX,\n }\n )\n }\n\n history.push(...historyArgs)\n dispatch(setActivePage({ pageKey: nextPageKey }))\n }\n\n if (action === 'replace') {\n history.replace(...historyArgs)\n\n if (currentPageKey !== nextPageKey) {\n dispatch(setActivePage({ pageKey: nextPageKey }))\n dispatch(removePage({ pageKey: currentPageKey }))\n }\n }\n return true\n } else {\n console.warn(\n `\\`navigateTo\\` was called , but could not find\n the pageKey in the store. This may happen when the wrong\n content_location was set in your non-get controller action.\n No navigation will take place`\n )\n return false\n }\n }\n\n const { search } = superglue\n const { componentIdentifier } = pages[currentPageKey]\n const Component = mapping[componentIdentifier]\n\n if (Component) {\n return (\n <NavigationContext.Provider\n value={{ pageKey: currentPageKey, search, navigateTo, visit, remote }}\n >\n <Component />\n </NavigationContext.Provider>\n )\n } else {\n notFound(componentIdentifier)\n }\n})\n\nexport { NavigationContext, NavigationProvider }\n","import { setIn, getIn, urlToPageKey, parsePageKey } from '../utils'\nimport type { Action } from '@reduxjs/toolkit'\nimport {\n saveResponse,\n handleGraft,\n historyChange,\n copyPage,\n setCSRFToken,\n setActivePage,\n removePage,\n} from '../actions'\nimport { config } from '../config'\nimport {\n AllPages,\n Page,\n VisitResponse,\n Fragment,\n GraftResponse,\n SuperglueState,\n JSONMappable,\n} from '../types'\n\nfunction addPlaceholdersToDeferredNodes(existingPage: Page, page: Page): Page {\n const { defers = [] } = existingPage\n\n const prevDefers = defers.map(({ path }) => {\n const node = getIn(existingPage, path)\n const copy = JSON.stringify(node)\n return [path, JSON.parse(copy)]\n })\n\n return prevDefers.reduce((memo, [path, node]) => {\n return setIn(page, path, node)\n }, page)\n}\n\nfunction constrainPagesSize(state: AllPages) {\n const { maxPages } = config\n const allPageKeys = Object.keys(state)\n const cacheTimesRecentFirst = allPageKeys\n .map((key) => state[key].savedAt)\n .sort((a, b) => b - a)\n\n for (const key of Array.from(allPageKeys)) {\n if (state[key].savedAt <= cacheTimesRecentFirst[maxPages - 1]) {\n delete state[key]\n }\n }\n}\n\nfunction handleSaveResponse(\n state: AllPages,\n pageKey: string,\n page: VisitResponse\n): AllPages {\n state = { ...state }\n\n let nextPage: Page = {\n ...page,\n savedAt: Date.now(),\n }\n\n const existingPage = state[pageKey]\n\n if (existingPage) {\n nextPage = addPlaceholdersToDeferredNodes(existingPage, nextPage)\n }\n constrainPagesSize(state)\n state[pageKey] = nextPage\n\n return state\n}\n\nexport function appendReceivedFragmentsOntoPage(\n state: AllPages,\n pageKey: string,\n receivedFragments: Fragment[]\n): AllPages {\n if (!pageKey) {\n return state\n }\n\n if (receivedFragments.length === 0) {\n return state\n }\n\n const currentPage = state[pageKey]\n const { fragments: prevFragments = [] } = currentPage\n const nextFragments = [...prevFragments]\n const existingKeys: Record<string, boolean> = {}\n prevFragments.forEach((frag) => (existingKeys[frag.path] = true))\n\n receivedFragments.forEach((frag) => {\n if (!existingKeys[frag.path]) {\n nextFragments.push(frag)\n }\n })\n\n const nextPage = {\n ...currentPage,\n fragments: nextFragments,\n }\n\n const nextState = { ...state }\n nextState[pageKey] = nextPage\n\n return nextState\n}\n\nexport function graftNodeOntoPage(\n state: AllPages,\n pageKey: string,\n node: JSONMappable,\n pathToNode: string\n): AllPages {\n if (!node) {\n console.warn(\n 'There was no node returned in the response. Do you have the correct key path in your props_at?'\n )\n return state\n }\n\n if (!pathToNode || !pageKey) {\n return state\n }\n const fullPathToNode = [pageKey, pathToNode].join('.')\n return setIn(state, fullPathToNode, node)\n}\n\nfunction handleGraftResponse(\n state: AllPages,\n pageKey: string,\n page: GraftResponse\n): AllPages {\n const currentPage = state[pageKey]\n if (!currentPage) {\n const error = new Error(\n `Superglue was looking for ${pageKey} in your state, but could not find it in your mapping. Did you forget to pass in a valid pageKey to this.props.remote or this.props.visit?`\n )\n throw error\n }\n const {\n data: receivedNode,\n path: pathToNode,\n fragments: receivedFragments = [],\n } = page\n\n return [\n (nextState: AllPages) =>\n graftNodeOntoPage(nextState, pageKey, receivedNode, pathToNode),\n (nextState: AllPages) =>\n appendReceivedFragmentsOntoPage(nextState, pageKey, receivedFragments),\n ].reduce((memo, fn) => fn(memo), state)\n}\n\nexport function pageReducer(state: AllPages = {}, action: Action): AllPages {\n if (removePage.match(action)) {\n const { pageKey } = action.payload\n const nextState = { ...state }\n delete nextState[pageKey]\n\n return nextState\n }\n\n if (copyPage.match(action)) {\n const nextState = { ...state }\n const { from, to } = action.payload\n\n nextState[urlToPageKey(to)] = JSON.parse(JSON.stringify(nextState[from]))\n\n return nextState\n }\n\n if (handleGraft.match(action)) {\n const { pageKey, page } = action.payload\n\n return handleGraftResponse(state, pageKey, page)\n }\n\n if (saveResponse.match(action)) {\n const { pageKey, page } = action.payload\n const nextState = handleSaveResponse(state, pageKey, page)\n return nextState\n }\n\n return state\n}\n\nexport function superglueReducer(\n state: SuperglueState = {\n currentPageKey: '',\n search: {},\n assets: [],\n },\n action: Action\n): SuperglueState {\n if (setCSRFToken.match(action)) {\n const { csrfToken } = action.payload\n return { ...state, csrfToken: csrfToken }\n }\n\n if (setActivePage.match(action)) {\n const { pageKey } = action.payload\n const { search } = parsePageKey(pageKey)\n\n return {\n ...state,\n search,\n currentPageKey: pageKey,\n }\n }\n\n if (historyChange.match(action)) {\n const { pageKey } = action.payload\n const { search } = parsePageKey(pageKey)\n\n return {\n ...state,\n currentPageKey: pageKey,\n search,\n }\n }\n\n if (saveResponse.match(action)) {\n const {\n page: { csrfToken, assets },\n } = action.payload\n\n return { ...state, csrfToken, assets }\n }\n\n return state\n}\n\nexport const rootReducer = {\n superglue: superglueReducer,\n pages: pageReducer,\n}\n","import { useSelector } from 'react-redux'\nimport { JSONMappable, Page, RootState, SuperglueState } from '../types'\n\n/**\n * A lightweight hook that grabs the superglue state from the store.\n */\nexport function useSuperglue() {\n return useSelector<RootState, SuperglueState>((state) => state.superglue)\n}\n\n/**\n * A lightweight hook that grabs the current page's content from the store.\n */\nexport function useContent<T = JSONMappable>() {\n const superglueState = useSuperglue()\n const currentPageKey = superglueState.currentPageKey\n\n return useSelector<RootState<T>, Page<T>>(\n (state) => state.pages[currentPageKey]\n ).data\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,UAAS,QAAQ,eAAe;AAKvC,SAAS,gBAAgB;AAEzB,SAAS,sBAAsB,2BAA2B;;;ACP1D,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAaP,SAAS,aAAa,aAAa,gBAAgB;AAEnD,IAAM,oBAAoB;AAAA,EACxB,CAAC;AACH;AAEA,IAAM,YAAY,OAAO,WAAW;AAEpC,IAAM,kBAAkB,CAAC,MAAc,SAAuB;AAC5D,eAAa,OAAO,SAAS,MAAM,IAAI;AACzC;AAEA,IAAM,WAAW,CAAC,eAA0C;AAC1D,MAAI,WAAW;AACf,MAAI,CAAC,YAAY;AACf,eACE;AAAA,EACJ;AAEA,QAAM,QAAQ,IAAI;AAAA,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AW,cAAc;AAC7C,cAAY,QAAQ,GAAG,eAAe,IAAI,CAAC;AAC3C,eAAa,OAAO,aAAa,IAAI;AAErC,QAAM,WAAW,YAAY;AAAA,IAC3B;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK;AAAA,EACP;AACF;AASA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAqB;AACnB,QAAM,eAAe,OAA0C,IAAI;AAEnE,QAAM,EAAE,OAAO,QAAQ,aAAa,gBAAgB,IAAI,IAAI,QAAQ,MAAM;AACxE,WAAO,MAAM;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAIL,SACE,gBAAAC,OAAA,cAAC,SAAI,SAAS,IAAI,SAAS,UAAU,IAAI,UAAW,GAAG,QACrD,gBAAAA,OAAA,cAAC,YAAS,SACR,gBAAAA,OAAA;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT;AAAA;AAAA,EACF,CACF,CACF;AAEJ;","names":["React","NavigationProvider","useSelector","hasWindow","React"]}
|
|
1
|
+
{"version":3,"sources":["../lib/index.tsx","../lib/hooks/useStreamSource.tsx","../lib/hooks/index.ts","../lib/hooks/useContent.tsx","../lib/hooks/useSetFragment.tsx","../lib/components/Navigation.tsx","../lib/reducers/index.ts"],"sourcesContent":["import React, { useRef, useMemo } from 'react'\nimport { config } from './config'\nimport { urlToPageKey, ujsHandlers, argsForHistory } from './utils'\nimport { saveAndProcessPage } from './action_creators'\nimport { historyChange, setCSRFToken, receiveResponse } from './actions'\nimport { Provider } from 'react-redux'\n\nimport { CableContext, StreamActions } from './hooks/useStreamSource'\nimport { createConsumer } from '@rails/actioncable'\n\nimport { createBrowserHistory, createMemoryHistory } from 'history'\n\nimport { NavigationProvider } from './components/Navigation'\nexport { NavigationProvider, NavigationContext } from './components/Navigation'\nexport { saveAndProcessPage } from './action_creators'\nexport {\n beforeFetch,\n beforeVisit,\n beforeRemote,\n copyPage,\n removePage,\n saveResponse,\n receiveResponse,\n GRAFTING_ERROR,\n GRAFTING_SUCCESS,\n} from './actions'\nexport * from './types'\n\nimport {\n SaveResponse,\n ApplicationProps,\n NavigateTo,\n SuperglueStore,\n SetupProps,\n} from './types'\nexport { superglueReducer, pageReducer, rootReducer } from './reducers'\nexport { getIn } from './utils/immutability'\nexport { urlToPageKey }\nexport * from './hooks'\nexport { unproxy } from './hooks/useContent'\n\nfunction getConfig(name: string) {\n if (typeof document !== 'undefined') {\n const element = document.head.querySelector(\n `meta[name='action-cable-${name}']`\n )\n if (element) {\n return element.getAttribute('content') || '/cable'\n } else {\n return '/cable'\n }\n } else {\n return '/cable'\n }\n}\n\nconst cable = createConsumer(getConfig('url'))\n\nconst hasWindow = typeof window !== 'undefined'\n\nconst createHistory = () => {\n if (hasWindow) {\n // This is used for client side rendering\n return createBrowserHistory({})\n } else {\n // This is used for server side rendering\n return createMemoryHistory({})\n }\n}\n\nexport const prepareStore = (\n store: SuperglueStore,\n initialPage: SaveResponse,\n path: string\n) => {\n const initialPageKey = urlToPageKey(path)\n const { csrfToken } = initialPage\n\n store.dispatch(\n historyChange({\n pageKey: initialPageKey,\n })\n )\n store.dispatch(\n receiveResponse({ pageKey: initialPageKey, response: initialPage })\n )\n store.dispatch(saveAndProcessPage(initialPageKey, initialPage))\n store.dispatch(setCSRFToken({ csrfToken }))\n}\n\n/**\n * This is the setup function that the Application calls. Use this function if\n * you like to build your own Application component.\n */\nexport const setup = ({\n initialPage,\n baseUrl,\n path,\n store,\n buildVisitAndRemote,\n history,\n navigatorRef,\n}: SetupProps) => {\n config.baseUrl = baseUrl\n\n const { visit, remote } = buildVisitAndRemote(navigatorRef, store)\n\n const initialPageKey = urlToPageKey(path)\n const nextHistory = history || createHistory()\n nextHistory.replace(...argsForHistory(path))\n prepareStore(store, initialPage, path)\n\n const handlers = ujsHandlers({\n visit,\n remote,\n ujsAttributePrefix: 'data-sg',\n store,\n })\n\n const streamActions = new StreamActions({ remote, store })\n\n return {\n visit,\n remote,\n nextHistory,\n initialPageKey,\n ujs: handlers,\n streamActions,\n }\n}\n\n/**\n * The entry point to your superglue application. It sets up the redux Provider,\n * redux state and the Navigation component.\n *\n * This is a simple component, you can override this by copying the source code and\n * use the exported methods used by this component (`start` and `ujsHandler`).\n */\nfunction Application({\n initialPage,\n baseUrl,\n path,\n store,\n buildVisitAndRemote,\n history,\n mapping,\n ...rest\n}: ApplicationProps) {\n const navigatorRef = useRef<{ navigateTo: NavigateTo } | null>(null)\n\n const { visit, remote, nextHistory, initialPageKey, ujs, streamActions } =\n useMemo(() => {\n return setup({\n initialPage,\n baseUrl,\n path,\n store,\n buildVisitAndRemote,\n history,\n navigatorRef,\n })\n }, [])\n\n // The Nav component is pretty bare and can be inherited from for custom\n // behavior or replaced with your own.\n return (\n <div onClick={ujs.onClick} onSubmit={ujs.onSubmit} {...rest}>\n <Provider store={store}>\n <CableContext.Provider value={{ streamActions, cable }}>\n <NavigationProvider\n ref={navigatorRef}\n visit={visit}\n remote={remote}\n mapping={mapping}\n history={nextHistory}\n initialPageKey={initialPageKey}\n />\n </CableContext.Provider>\n </Provider>\n </div>\n )\n}\n\nexport { Application }\n","import {\n ChannelNameWithParams,\n Consumer,\n Subscription,\n} from '@rails/actioncable'\nimport { useState, useEffect, useRef, createContext, useContext } from 'react'\nimport { ApplicationRemote, FragmentPath } from '../types'\nimport { useSuperglue } from '.'\nimport debounce from 'lodash.debounce'\nimport type { DebouncedFunc } from 'lodash'\nimport { lastRequestIds } from '../utils'\nimport {\n streamPrepend,\n streamAppend,\n streamSave,\n handleStreamMessage,\n} from '../action_creators/stream'\n\n/**\n * Channel configuration for stream sources\n * @public\n */\nexport type StreamSourceProps = string | ChannelNameWithParams\n\nexport type StreamMessage =\n | {\n action: 'handleStreamMessage'\n data: JSONMappable\n fragmentIds: string[]\n handler: 'append' | 'prepend' | 'save'\n options: Record<string, string>\n fragments: FragmentPath[]\n }\n | {\n action: 'handleStreamMessage'\n handler: 'refresh'\n requestId: string\n options: Record<string, string>\n }\n\nimport { SuperglueStore, JSONMappable } from '../types'\n\n/**\n * Actions for handling stream operations like append, prepend, save and refresh\n * @public\n */\nexport class StreamActions {\n public attributePrefix: string\n public remote: DebouncedFunc<ApplicationRemote>\n private store: SuperglueStore\n\n constructor({\n remote,\n store,\n }: {\n remote: ApplicationRemote\n store: SuperglueStore\n }) {\n this.store = store\n this.remote = debounce(remote, 300)\n }\n\n refresh(pageKey: string) {\n this.remote(pageKey)\n }\n\n prepend(\n fragments: string[],\n data: JSONMappable,\n options: { saveAs?: string } = {}\n ) {\n this.store.dispatch(streamPrepend(fragments, data, options))\n }\n\n save(fragment: string, data: JSONMappable) {\n this.store.dispatch(streamSave(fragment, data))\n }\n\n append(\n fragments: string[],\n data: JSONMappable,\n options: { saveAs?: string } = {}\n ) {\n this.store.dispatch(streamAppend(fragments, data, options))\n }\n\n handle(rawMessage: string, currentPageKey: string) {\n const message = JSON.parse(rawMessage) as StreamMessage\n const { superglue } = this.store.getState()\n const nextPageKey = superglue.currentPageKey\n\n if (message.action === 'handleStreamMessage') {\n if (\n message.handler === 'refresh' &&\n currentPageKey === nextPageKey &&\n !lastRequestIds.has(message.requestId)\n ) {\n this.refresh(currentPageKey)\n }\n\n if (message.handler !== 'refresh') {\n this.store.dispatch(handleStreamMessage(rawMessage))\n }\n }\n }\n}\n\nexport const CableContext = createContext<{\n cable: Consumer | null\n streamActions: StreamActions | null\n}>({\n cable: null,\n streamActions: null,\n})\n\n/**\n * Creates a subscription to an ActionCable channel for real-time streaming\n * updates.\n *\n * This hook manages the lifecycle of an ActionCable subscription, automatically\n * connecting when the cable is available and cleaning up on unmount. Stream\n * messages are processed through StreamActions to update the Redux store.\n *\n * Typically used with channel configuration generated by the Rails helper\n * `stream_from_props` helper in your `props` templates.\n *\n * * @example\n * Using the helper:\n *\n * ```ruby\n * # app/views/chat_rooms/show.json.props\n * json.chatChannel stream_from_props(\"messages\")\n * ```\n * ```tsx\n * const content = useContent()\n * const { connected } = useStreamSource(content.chatChannel)\n * ```\n *\n * @example\n * Basic channel subscription:\n * ```tsx\n * const { connected } = useStreamSource('ChatChannel')\n * ```\n *\n * @example\n * Channel with parameters:\n * ```tsx\n * const { connected } = useStreamSource({\n * channel: 'ChatChannel',\n * room_id: roomId\n * })\n * ```\n *\n * @example\n * Using connection status:\n * ```tsx\n * const { connected, subscription } = useStreamSource('NotificationsChannel')\n *\n * return (\n * <div>\n * {connected ? 'Connected' : 'Connecting...'}\n * {subscription && <span>Subscription active</span>}\n * </div>\n * )\n * ```\n *\n * @param channel - Channel configuration as string or ChannelNameWithParams object,\n * typically generated by Rails `stream_from_props` helper\n * @returns Object containing connection status and subscription instance\n *\n * @public\n */\nexport function useStreamSource(channel: StreamSourceProps): {\n /** Whether the ActionCable subscription is currently connected */\n connected: boolean\n /** The active ActionCable subscription instance, null if not connected */\n subscription: Subscription | null\n} {\n const { cable, streamActions } = useContext(CableContext)\n const [connected, setConnected] = useState(false)\n const { currentPageKey } = useSuperglue()\n const subscriptionRef = useRef<Subscription | null>(null)\n\n useEffect(() => {\n if (cable) {\n const subscription = cable.subscriptions.create(channel, {\n received: (message) => {\n streamActions?.handle(message, currentPageKey)\n },\n connected: () => {\n setConnected(true)\n },\n disconnected: () => setConnected(false),\n })\n\n subscriptionRef.current = subscription\n\n return () => subscription.unsubscribe()\n } else {\n subscriptionRef.current = null\n setConnected(false)\n\n return () => {}\n }\n }, [cable, JSON.stringify(channel), currentPageKey])\n\n return {\n connected,\n subscription: subscriptionRef.current,\n }\n}\n","import { useSelector } from 'react-redux'\nimport { RootState, SuperglueState } from '../types'\nexport { useContent, unproxy } from './useContent'\nexport { useSetFragment } from './useSetFragment'\nexport { useStreamSource } from './useStreamSource'\n\n/**\n * A lightweight hook that grabs the superglue state from the store.\n */\nexport function useSuperglue() {\n return useSelector<RootState, SuperglueState>((state) => state.superglue)\n}\n","import { useSelector, useStore } from 'react-redux'\nimport { useMemo, useRef } from 'react'\nimport {\n JSONMappable,\n RootState,\n Unproxy,\n Fragment,\n FragmentRef,\n} from '../types'\nimport { useSuperglue } from './index'\nimport { createProxy, unproxy as unproxyUtil } from '../utils/proxy'\n\nexport type FragmentProxy = { __fragment: true }\n\n/**\n * A proxy type that enables reactive access to nested content with automatic fragment resolution\n */\nexport type ProxiedContent<T> = T extends Fragment<infer U, true>\n ? ProxiedContent<U> & FragmentProxy\n : T extends Fragment<infer U, false | undefined>\n ? (ProxiedContent<U> & FragmentProxy) | undefined\n : T extends (infer U)[]\n ? ProxiedContent<U>[]\n : T extends object\n ? { [K in keyof T]: ProxiedContent<T[K]> }\n : T\n\n/**\n * Union type for fragment references, accepting either FragmentRef objects or string IDs\n * @public\n */\nexport type FragmentRefOrId = FragmentRef | string\n\n/**\n * Returns a proxy for accessing your page's content e.g, `index.json.props`,\n * `show.json.props`, etc.\n *\n * For advanced scenarios where you are using Fragments.\n *\n * ```js\n * {\n * data: {\n * body: {\n * cart: {__id: 'user_cart'}\n * },\n * footer: {title: \"welcome\"}},\n * },\n * fragments: {user_cart: {total: 100}}\n * }\n * ```\n *\n * The proxy will lazily and automatically resolve any {@link FragmentRef}s making it\n * as easy as\n *\n * ```\n * const data = useContent()\n * const total = data.body.cart.total\n * ```\n *\n * The hook will also automatically tracks fragment dependencies and triggers\n * re-renders only when accessed fragments change.\n *\n * @template T - The data type being accessed (defaults to JSONMappable)\n * @returns Reactive proxy to page data or fragment data, undefined if fragment not found\n *\n * @example\n * ```tsx\n * // Access current page data\n * const page = useContent()\n *\n * // Access specific fragment by reference\n * const user = useContent({__id: 'user_123'})\n *\n * // Access specific fragment by ID string\n * const cart = useContent('userCart')\n * ```\n */\nexport function useContent<T = JSONMappable>(): ProxiedContent<T>\n\n/**\n * Passing in a fragment to useContent allows us to scope the tracking of\n * fragments to that hook usage. Its useful in performance scenarios where you\n * want a child component to update, but not the parent.\n *\n *\n * ```js\n * import {unproxy} from '@thoughtbot/superglue'\n *\n * const content = useContent()\n * const rawContent = unproxy(content)\n *\n * <h1>{content.title}</h1>\n * <SlidingCart cartRef={rawContent.cart} />\n * ```\n *\n * then in SlidingCart\n *\n * ```js\n * const SlidingCart = (cartRef) => {\n * const cart = useContent(cartRef)\n * }\n * ```\n *\n * SlidingCart will update only if the fragment referenced by `cartRef` updates.\n *\n * @param fragmentRef Optional fragment reference for scoped access\n */\nexport function useContent<T = JSONMappable>(\n fragmentRef: FragmentRefOrId\n): ProxiedContent<T>\nexport function useContent<T = JSONMappable>(\n fragmentRef?: FragmentRefOrId\n): ProxiedContent<T> | undefined {\n const superglueState = useSuperglue()\n const currentPageKey = superglueState.currentPageKey\n\n const dependencies = useRef<Set<string>>(new Set())\n // const fragmentsHookRef = useRef<RootState['fragments']>({})\n\n const fragmentId =\n typeof fragmentRef === 'string' ? fragmentRef : fragmentRef?.__id\n const sourceData = useSelector((state: RootState) => {\n if (fragmentId) {\n return state.fragments[fragmentId]\n } else {\n return state.pages[currentPageKey].data\n }\n })\n\n const trackedFragments = useSelector(\n (state: RootState) => state.fragments,\n (oldFragments, newFragments) => {\n if (oldFragments === newFragments) {\n return true\n }\n\n return Array.from(dependencies.current).every((id: string) => {\n const prevVal = oldFragments[id]\n const nextVal = newFragments[id]\n return prevVal === nextVal\n })\n }\n )\n\n // Update the ref BEFORE the useMemo so proxy creation sees current fragments\n // fragmentsHookRef.current = fragments\n\n const store = useStore<RootState>()\n\n const proxy = useMemo(() => {\n const proxyCache = new WeakMap()\n\n if (fragmentId && !sourceData) {\n return undefined\n }\n\n return createProxy(\n sourceData,\n { current: store.getState().fragments },\n dependencies.current,\n proxyCache\n ) as ProxiedContent<T>\n }, [sourceData, trackedFragments])\n\n return proxy\n}\n\n/**\n * Extracts the underlying state from an {@link useContent} proxy\n *\n */\nexport function unproxy<T>(proxy: T): Unproxy<T> {\n return unproxyUtil(proxy)\n}\n","import { useDispatch, useSelector } from 'react-redux'\nimport { Immer } from 'immer'\nimport { saveFragment } from '../actions'\nimport { RootState, Fragment } from '../types'\nimport { Unproxy } from '../types'\nimport { FragmentProxy } from './useContent'\n\nconst immer = new Immer()\nimmer.setAutoFreeze(false)\n\n/**\n * Utility type to extract the data type from a Fragment wrapper\n * @public\n */\nexport type Unpack<T> = T extends Fragment<infer U, unknown>\n ? U\n : T extends FragmentProxy\n ? T\n : never\n/**\n * Hook for mutating fragments using Immer drafts.\n *\n * @example\n * ```tsx\n * const set = useSetFragment()\n *\n * // Update via fragment reference\n * set(userRef, draft => {\n * draft.name = \"Updated Name\"\n * draft.email = \"new@email.com\"\n * })\n *\n * // Update via fragment ID directly\n * set('user_123', draft => {\n * draft.profile.bio = \"Updated bio\"\n * })\n * ```\n *\n */\nexport function useSetFragment() {\n const dispatch = useDispatch()\n const fragments = useSelector((state: RootState) => state.fragments)\n\n /**\n * Updates a fragment using a {@link FragmentRef} object.\n *\n * @param fragmentRef - Fragment reference object containing __id\n * @param updater - Immer draft function for mutating fragment data\n */\n function setter<T extends Fragment<unknown, unknown>>(\n fragmentRef: T,\n updater: (draft: Unproxy<Unpack<T>>) => void\n ): void\n\n /**\n * Updates a fragment using a fragment ID string.\n *\n * @param fragmentId - The fragment ID string\n * @param updater - Immer draft function for mutating fragment data\n */\n function setter<T = unknown>(\n fragmentId: string,\n updater: (draft: T) => void\n ): void\n\n function setter(\n fragmentRefOrId: Fragment<unknown, unknown> | string,\n updater: (draft: unknown) => void\n ): void {\n const fragmentId =\n typeof fragmentRefOrId === 'string'\n ? fragmentRefOrId\n : fragmentRefOrId.__id\n\n const currentFragment = fragments[fragmentId]\n\n if (currentFragment === undefined) {\n throw new Error(`Fragment with id \"${fragmentId}\" not found`)\n }\n\n const updatedFragment = immer.produce(currentFragment, updater)\n\n dispatch(\n saveFragment({\n fragmentId: fragmentId,\n data: updatedFragment,\n })\n )\n }\n\n return setter\n}\n","import React, {\n createContext,\n useEffect,\n useLayoutEffect,\n forwardRef,\n useImperativeHandle,\n ForwardedRef,\n} from 'react'\nimport { urlToPageKey } from '../utils'\nimport { removePage, setActivePage } from '../actions'\nimport {\n HistoryState,\n RootState,\n NavigateTo,\n NavigationContextProps,\n NavigationProviderProps,\n AllPages,\n SuperglueState,\n} from '../types'\nimport { Update } from 'history'\nimport { useDispatch, useSelector, useStore } from 'react-redux'\n\nconst NavigationContext = createContext<NavigationContextProps>(\n {} as NavigationContextProps\n)\n\nconst hasWindow = typeof window !== 'undefined'\n\nconst setWindowScroll = (posX: number, posY: number): void => {\n hasWindow && window.scrollTo(posX, posY)\n}\n\nconst notFound = (identifier: string | undefined): never => {\n let reminder = ''\n if (!identifier) {\n reminder =\n 'Did you forget to add `json.componentIdentifier` in your application.json.props layout?'\n }\n\n const error = new Error(\n `Superglue Nav component was looking for ${identifier} but could not find it in your mapping. ${reminder}`\n )\n\n throw error\n}\n\nconst NavigationProvider = forwardRef(function NavigationProvider(\n { history, visit, remote, mapping }: NavigationProviderProps,\n ref: ForwardedRef<{ navigateTo: NavigateTo | null }>\n) {\n const dispatch = useDispatch()\n const pages = useSelector<RootState, AllPages>((state) => state.pages)\n const superglue = useSelector<RootState, SuperglueState>(\n (state) => state.superglue\n )\n const currentPageKey = useSelector<RootState, string>(\n (state) => state.superglue.currentPageKey\n )\n const store = useStore<RootState>()\n\n useEffect(() => {\n return history.listen(onHistoryChange)\n }, [])\n\n useLayoutEffect(() => {\n const state = history.location.state as HistoryState\n if (state && 'superglue' in state) {\n const { posX, posY } = state\n setWindowScroll(posX, posY)\n }\n }, [currentPageKey])\n\n useImperativeHandle(\n ref,\n () => {\n return {\n navigateTo,\n }\n },\n []\n )\n\n const onHistoryChange = ({ location, action }: Update): void => {\n const state = location.state as HistoryState\n\n if (action !== 'POP') {\n return\n }\n\n if (!state && location.hash !== '') {\n const nextPageKey = urlToPageKey(location.pathname + location.search)\n const containsKey = !!pages[nextPageKey]\n if (containsKey) {\n history.replace(\n {\n pathname: location.pathname,\n search: location.search,\n hash: location.hash,\n },\n {\n superglue: true,\n posY: window.pageYOffset,\n posX: window.pageXOffset,\n }\n )\n }\n }\n\n if (state && 'superglue' in state) {\n const pageKey = urlToPageKey(location.pathname + location.search)\n const prevPageKey = store.getState().superglue.currentPageKey\n const containsKey = !!pages[pageKey]\n\n if (containsKey) {\n const { restoreStrategy } = pages[pageKey]\n\n switch (restoreStrategy) {\n case 'fromCacheOnly':\n dispatch(setActivePage({ pageKey }))\n break\n case 'fromCacheAndRevisitInBackground':\n dispatch(setActivePage({ pageKey }))\n visit(pageKey, { revisit: true })\n break\n case 'revisitOnly':\n default:\n visit(pageKey, { revisit: true }).then(() => {\n const noNav =\n prevPageKey === store.getState().superglue.currentPageKey\n if (noNav) {\n // When \"POP'ed\", revisiting (using revisit: true) a page can result in\n // a redirect, or a render of the same page.\n //\n // When its a redirect, calculateNavAction will correctly set the\n // navigationAction to `replace` this is the noop scenario.\n //\n // When its the same page, navigationAction is set to `none` and\n // no navigation took place. In that case, we have to set the\n // activePage otherwise the user is stuck on the original page.\n dispatch(setActivePage({ pageKey }))\n }\n })\n }\n } else {\n visit(pageKey, { revisit: true }).then(() => {\n const noNav =\n prevPageKey === store.getState().superglue.currentPageKey\n if (noNav) {\n dispatch(setActivePage({ pageKey }))\n }\n })\n }\n }\n }\n\n const navigateTo: NavigateTo = (\n path,\n { action } = {\n action: 'push',\n }\n ) => {\n if (action === 'none') {\n return false\n }\n\n const nextPageKey = urlToPageKey(path)\n const hasPage = Object.prototype.hasOwnProperty.call(\n store.getState().pages,\n nextPageKey\n )\n\n if (hasPage) {\n const location = history.location\n const state = location.state as HistoryState\n const historyArgs = [\n path,\n {\n superglue: true,\n posY: 0,\n posX: 0,\n },\n ] as const\n\n if (action === 'push') {\n if (hasWindow) {\n history.replace(\n {\n pathname: location.pathname,\n search: location.search,\n hash: location.hash,\n },\n {\n ...state,\n posY: window.scrollY,\n posX: window.scrollX,\n }\n )\n }\n\n history.push(...historyArgs)\n dispatch(setActivePage({ pageKey: nextPageKey }))\n }\n\n if (action === 'replace') {\n history.replace(...historyArgs)\n\n if (currentPageKey !== nextPageKey) {\n dispatch(setActivePage({ pageKey: nextPageKey }))\n dispatch(removePage({ pageKey: currentPageKey }))\n }\n }\n return true\n } else {\n console.warn(\n `\\`navigateTo\\` was called , but could not find\n the pageKey in the store. This may happen when the wrong\n content_location was set in your non-get controller action.\n No navigation will take place`\n )\n return false\n }\n }\n\n const { search } = superglue\n const { componentIdentifier } = pages[currentPageKey]\n const Component = mapping[componentIdentifier]\n\n if (Component) {\n return (\n <NavigationContext.Provider\n value={{ pageKey: currentPageKey, search, navigateTo, visit, remote }}\n >\n <Component />\n </NavigationContext.Provider>\n )\n } else {\n notFound(componentIdentifier)\n }\n})\n\nexport { NavigationContext, NavigationProvider }\n","import { setIn, urlToPageKey, parsePageKey } from '../utils'\nimport type { Action } from '@reduxjs/toolkit'\nimport {\n saveResponse,\n handleGraft,\n historyChange,\n copyPage,\n setCSRFToken,\n setActivePage,\n removePage,\n handleFragmentGraft,\n saveFragment,\n appendToFragment,\n prependToFragment,\n} from '../actions'\nimport { config } from '../config'\nimport {\n AllPages,\n Page,\n SaveResponse,\n FragmentPath,\n GraftResponse,\n SuperglueState,\n JSONMappable,\n AllFragments,\n} from '../types'\n\nfunction constrainPagesSize(state: AllPages) {\n const { maxPages } = config\n const allPageKeys = Object.keys(state)\n const cacheTimesRecentFirst = allPageKeys\n .map((key) => state[key].savedAt)\n .sort((a, b) => b - a)\n\n for (const key of Array.from(allPageKeys)) {\n if (state[key].savedAt <= cacheTimesRecentFirst[maxPages - 1]) {\n delete state[key]\n }\n }\n}\n\nfunction handleSaveResponse(\n state: AllPages,\n pageKey: string,\n page: SaveResponse\n): AllPages {\n state = { ...state }\n\n const nextPage: Page = {\n ...page,\n savedAt: Date.now(),\n }\n constrainPagesSize(state)\n state[pageKey] = nextPage\n\n return state\n}\n\nexport function appendReceivedFragmentsOntoPage(\n state: AllPages,\n pageKey: string,\n receivedFragments: FragmentPath[]\n): AllPages {\n if (!pageKey) {\n return state\n }\n\n if (receivedFragments.length === 0) {\n return state\n }\n\n const currentPage = state[pageKey]\n const { fragments: prevFragments = [] } = currentPage\n const nextFragments = [...prevFragments]\n const existingKeys: Record<string, boolean> = {}\n prevFragments.forEach((frag) => (existingKeys[frag.path] = true))\n\n receivedFragments.forEach((frag) => {\n if (!existingKeys[frag.path]) {\n nextFragments.push(frag)\n }\n })\n\n const nextPage = {\n ...currentPage,\n fragments: nextFragments,\n }\n\n const nextState = { ...state }\n nextState[pageKey] = nextPage\n\n return nextState\n}\n\nexport function graftNodeOntoTarget<T extends JSONMappable>(\n state: T,\n pageKey: string,\n node: JSONMappable,\n pathToNode: string\n): T {\n if (!node) {\n console.warn(\n 'There was no node returned in the response. Do you have the correct key path in your props_at?'\n )\n return state\n }\n\n if (!pathToNode || !pageKey) {\n return state\n }\n const fullPathToNode = [pageKey, pathToNode].join('.')\n return setIn(state, fullPathToNode, node)\n}\n\nfunction handleFragmentGraftResponse(\n state: AllFragments,\n key: string,\n response: GraftResponse\n): AllFragments {\n const target = state[key]\n\n if (!target) {\n const error = new Error(\n `Superglue was looking for ${key} in your fragments, but could not find it.`\n )\n throw error\n }\n const { data: receivedNode, path: pathToNode } = response\n\n return graftNodeOntoTarget(state, key, receivedNode, pathToNode)\n}\n\nfunction handleGraftResponse(\n state: AllPages,\n pageKey: string,\n page: GraftResponse\n): AllPages {\n const currentPage = state[pageKey]\n if (!currentPage) {\n const error = new Error(\n `Superglue was looking for ${pageKey} in your state, but could not find it in your mapping. Did you forget to pass in a valid pageKey to this.props.remote or this.props.visit?`\n )\n throw error\n }\n const {\n data: receivedNode,\n path: pathToNode,\n fragments: receivedFragments = [],\n } = page\n\n return [\n (nextState: AllPages) =>\n graftNodeOntoTarget(nextState, pageKey, receivedNode, pathToNode),\n (nextState: AllPages) =>\n appendReceivedFragmentsOntoPage(nextState, pageKey, receivedFragments),\n ].reduce((memo, fn) => fn(memo), state)\n}\n\nexport function pageReducer(state: AllPages = {}, action: Action): AllPages {\n if (removePage.match(action)) {\n const { pageKey } = action.payload\n const nextState = { ...state }\n delete nextState[pageKey]\n\n return nextState\n }\n\n if (copyPage.match(action)) {\n const nextState = { ...state }\n const { from, to } = action.payload\n\n nextState[urlToPageKey(to)] = JSON.parse(JSON.stringify(nextState[from]))\n\n return nextState\n }\n\n if (handleGraft.match(action)) {\n const { pageKey, page } = action.payload\n\n return handleGraftResponse(state, pageKey, page)\n }\n\n if (saveResponse.match(action)) {\n const { pageKey, page } = action.payload\n const nextState = handleSaveResponse(state, pageKey, page)\n return nextState\n }\n\n return state\n}\n\nexport function superglueReducer(\n state: SuperglueState = {\n currentPageKey: '',\n search: {},\n assets: [],\n },\n action: Action\n): SuperglueState {\n if (setCSRFToken.match(action)) {\n const { csrfToken } = action.payload\n return { ...state, csrfToken: csrfToken }\n }\n\n if (setActivePage.match(action)) {\n const { pageKey } = action.payload\n const { search } = parsePageKey(pageKey)\n\n return {\n ...state,\n search,\n currentPageKey: pageKey,\n }\n }\n\n if (historyChange.match(action)) {\n const { pageKey } = action.payload\n const { search } = parsePageKey(pageKey)\n\n return {\n ...state,\n currentPageKey: pageKey,\n search,\n }\n }\n\n if (saveResponse.match(action)) {\n const {\n page: { csrfToken, assets },\n } = action.payload\n\n return { ...state, csrfToken, assets }\n }\n\n return state\n}\n\nexport function fragmentReducer(\n state: AllFragments = {},\n action: Action\n): AllFragments {\n if (handleFragmentGraft.match(action)) {\n const { fragmentId, response } = action.payload\n return handleFragmentGraftResponse(state, fragmentId, response)\n }\n\n if (saveFragment.match(action)) {\n const { fragmentId, data } = action.payload\n\n return {\n ...state,\n [fragmentId]: data,\n }\n }\n\n if (appendToFragment.match(action)) {\n const { data, fragmentId } = action.payload\n let targetFragment = state[fragmentId]\n\n if (Array.isArray(targetFragment)) {\n targetFragment = [...targetFragment, data]\n\n return {\n ...state,\n [fragmentId]: targetFragment,\n }\n } else {\n return state\n }\n }\n\n if (prependToFragment.match(action)) {\n const { data, fragmentId } = action.payload\n let targetFragment = state[fragmentId]\n\n if (Array.isArray(targetFragment)) {\n targetFragment = [data, ...targetFragment]\n return {\n ...state,\n [fragmentId]: targetFragment,\n }\n } else {\n return state\n }\n }\n\n return state\n}\n\nexport const rootReducer = {\n superglue: superglueReducer,\n pages: pageReducer,\n fragments: fragmentReducer,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,UAAS,UAAAC,SAAQ,WAAAC,gBAAe;AAKvC,SAAS,gBAAgB;;;ACAzB,SAAS,UAAU,WAAW,UAAAC,SAAQ,eAAe,kBAAkB;;;ACLvE,SAAS,eAAAC,oBAAmB;;;ACA5B,SAAS,aAAa,gBAAgB;AACtC,SAAS,SAAS,cAAc;AA6GzB,SAAS,WACd,aAC+B;AAC/B,QAAM,iBAAiB,aAAa;AACpC,QAAM,iBAAiB,eAAe;AAEtC,QAAM,eAAe,OAAoB,oBAAI,IAAI,CAAC;AAGlD,QAAM,aACJ,OAAO,gBAAgB,WAAW,cAAc,aAAa;AAC/D,QAAM,aAAa,YAAY,CAAC,UAAqB;AACnD,QAAI,YAAY;AACd,aAAO,MAAM,UAAU,UAAU;AAAA,IACnC,OAAO;AACL,aAAO,MAAM,MAAM,cAAc,EAAE;AAAA,IACrC;AAAA,EACF,CAAC;AAED,QAAM,mBAAmB;AAAA,IACvB,CAAC,UAAqB,MAAM;AAAA,IAC5B,CAAC,cAAc,iBAAiB;AAC9B,UAAI,iBAAiB,cAAc;AACjC,eAAO;AAAA,MACT;AAEA,aAAO,MAAM,KAAK,aAAa,OAAO,EAAE,MAAM,CAAC,OAAe;AAC5D,cAAM,UAAU,aAAa,EAAE;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A,MACA;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAIP,SACE,gBAAAC,OAAA,cAAC,SAAI,SAAS,IAAI,SAAS,UAAU,IAAI,UAAW,GAAG,QACrD,gBAAAA,OAAA,cAAC,YAAS,SACR,gBAAAA,OAAA,cAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,eAAe,MAAM,KACnD,gBAAAA,OAAA;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT;AAAA;AAAA,EACF,CACF,CACF,CACF;AAEJ;","names":["React","useRef","useMemo","useRef","useSelector","unproxy","useSelector","useSelector","useSelector","cable","useRef","createContext","useEffect","useDispatch","useSelector","useStore","createContext","NavigationProvider","useEffect","hasWindow","useRef","useMemo","React"]}
|