@thoughtbot/superglue 2.0.0-alpha.1 → 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/dist/action_creators.d.mts +1 -1
- package/dist/action_creators.mjs +1 -1
- package/dist/{chunk-YS477OKK.mjs → chunk-J2XH5QTK.mjs} +285 -36
- package/dist/chunk-J2XH5QTK.mjs.map +1 -0
- package/dist/cjs/action_creators.cjs +275 -7
- package/dist/cjs/action_creators.cjs.map +1 -1
- package/dist/cjs/superglue.cjs +323 -5769
- package/dist/cjs/superglue.cjs.map +1 -1
- package/dist/{index-MyfFLe4E.d.mts → index-j0c-9ZLt.d.mts} +29 -17
- package/dist/superglue.d.mts +16 -25
- package/dist/superglue.mjs +47 -5747
- package/dist/superglue.mjs.map +1 -1
- package/package.json +6 -5
- package/thoughtbot-superglue-2.0.0-alpha.10.tgz +0 -0
- package/typedoc.json +1 -0
- package/dist/chunk-YS477OKK.mjs.map +0 -1
- package/thoughtbot-superglue-2.0.0-alpha.1.tgz +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action,
|
|
1
|
+
import { Action, EnhancedStore, Tuple, StoreEnhancer, ThunkDispatch, ThunkAction } from '@reduxjs/toolkit';
|
|
2
2
|
import { History } from 'history';
|
|
3
3
|
|
|
4
4
|
type FetchArgs = [string, BasicRequestInit];
|
|
@@ -42,8 +42,8 @@ interface RemoteProps extends BaseProps {
|
|
|
42
42
|
pageKey?: PageKey;
|
|
43
43
|
force?: boolean;
|
|
44
44
|
}
|
|
45
|
-
interface BeforeSave {
|
|
46
|
-
<
|
|
45
|
+
interface BeforeSave<T = JSONMappable> {
|
|
46
|
+
<U extends SaveResponse<T> | GraftResponse<T>>(prevPage: Page<T>, receivedPage: U): U;
|
|
47
47
|
}
|
|
48
48
|
interface ApplicationRemote {
|
|
49
49
|
(input: string | PageKey, options?: RemoteProps & {
|
|
@@ -69,6 +69,17 @@ declare const rootReducer: {
|
|
|
69
69
|
fragments: typeof fragmentReducer;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
type FragmentProxy = {
|
|
73
|
+
__fragment: true;
|
|
74
|
+
};
|
|
75
|
+
type ProxiedContent<T> = T extends Fragment<infer U, true> ? ProxiedContent<U> & FragmentProxy : T extends Fragment<infer U, false | undefined> ? (ProxiedContent<U> & FragmentProxy) | undefined : T extends (infer U)[] ? ProxiedContent<U>[] : T extends object ? {
|
|
76
|
+
[K in keyof T]: ProxiedContent<T[K]>;
|
|
77
|
+
} : T;
|
|
78
|
+
type FragmentRefOrId = FragmentRef | string;
|
|
79
|
+
declare function useContent<T = JSONMappable>(): ProxiedContent<T>;
|
|
80
|
+
declare function useContent<T = JSONMappable>(fragmentRef: FragmentRefOrId): ProxiedContent<T>;
|
|
81
|
+
declare function unproxy<T>(proxy: T): Unproxy<T>;
|
|
82
|
+
|
|
72
83
|
type PageKey = string;
|
|
73
84
|
type RestoreStrategy = 'fromCacheOnly' | 'revisitOnly' | 'fromCacheAndRevisitInBackground';
|
|
74
85
|
type NavigationAction = 'push' | 'replace' | 'none';
|
|
@@ -82,15 +93,13 @@ type JSONObject = {
|
|
|
82
93
|
type JSONMappable = JSONValue[] | JSONObject;
|
|
83
94
|
type JSONKeyable = JSONObject[] | JSONObject;
|
|
84
95
|
type JSONValue = JSONPrimitive | JSONMappable;
|
|
85
|
-
type Fragment<T> = {
|
|
96
|
+
type Fragment<T, Present = false> = {
|
|
86
97
|
__id: string;
|
|
87
|
-
} & {
|
|
88
98
|
__fragmentType?: T;
|
|
99
|
+
__required?: Present extends boolean ? Present : false;
|
|
89
100
|
};
|
|
90
|
-
type
|
|
91
|
-
|
|
92
|
-
} : T extends (infer U)[] ? Unproxied<U>[] : T extends object ? {
|
|
93
|
-
[K in keyof T]: Unproxied<T[K]>;
|
|
101
|
+
type Unproxy<T> = T extends FragmentProxy ? FragmentRef : T extends Fragment<unknown, unknown> ? FragmentRef : T extends (infer U)[] ? Unproxy<U>[] : T extends object ? {
|
|
102
|
+
[K in keyof T]: Unproxy<T[K]>;
|
|
94
103
|
} : T;
|
|
95
104
|
interface ParsedResponse {
|
|
96
105
|
rsp: Response;
|
|
@@ -108,7 +117,7 @@ type SaveResponse<T = JSONMappable> = {
|
|
|
108
117
|
componentIdentifier: ComponentIdentifier;
|
|
109
118
|
assets: string[];
|
|
110
119
|
csrfToken?: string;
|
|
111
|
-
fragments:
|
|
120
|
+
fragments: FragmentPath[];
|
|
112
121
|
defers: Defer[];
|
|
113
122
|
slices: JSONObject;
|
|
114
123
|
action: 'savePage';
|
|
@@ -123,34 +132,37 @@ type GraftResponse<T = JSONMappable> = {
|
|
|
123
132
|
componentIdentifier: ComponentIdentifier;
|
|
124
133
|
assets: string[];
|
|
125
134
|
csrfToken?: string;
|
|
126
|
-
fragments:
|
|
135
|
+
fragments: FragmentPath[];
|
|
127
136
|
defers: Defer[];
|
|
128
137
|
slices: JSONObject;
|
|
129
138
|
action: 'graft';
|
|
130
139
|
renderedAt: number;
|
|
131
|
-
restoreStrategy: RestoreStrategy;
|
|
132
140
|
path: Keypath;
|
|
133
141
|
fragmentContext?: string;
|
|
134
142
|
};
|
|
135
|
-
type
|
|
143
|
+
type StreamMessage = {
|
|
136
144
|
data: JSONMappable;
|
|
137
145
|
fragmentIds: string[];
|
|
138
146
|
handler: 'append' | 'prepend' | 'save';
|
|
139
147
|
options: Record<string, string>;
|
|
140
148
|
};
|
|
141
149
|
type StreamResponse = {
|
|
142
|
-
data:
|
|
143
|
-
fragments:
|
|
150
|
+
data: StreamMessage[];
|
|
151
|
+
fragments: FragmentPath[];
|
|
144
152
|
assets: string[];
|
|
145
153
|
csrfToken?: string;
|
|
146
154
|
action: 'handleStreamResponse';
|
|
147
155
|
renderedAt: number;
|
|
156
|
+
slices: JSONObject;
|
|
148
157
|
};
|
|
149
158
|
type PageResponse = GraftResponse | SaveResponse | StreamResponse;
|
|
150
|
-
type
|
|
159
|
+
type FragmentPath = {
|
|
151
160
|
id: string;
|
|
152
161
|
path: Keypath;
|
|
153
162
|
};
|
|
163
|
+
type FragmentRef = {
|
|
164
|
+
__id: string;
|
|
165
|
+
};
|
|
154
166
|
type AllPages<T = JSONMappable> = Record<PageKey, Page<T>>;
|
|
155
167
|
type AllFragments = Record<string, JSONMappable>;
|
|
156
168
|
interface SuperglueState {
|
|
@@ -268,4 +280,4 @@ declare const visit: VisitCreator;
|
|
|
268
280
|
|
|
269
281
|
declare function saveAndProcessPage(pageKey: string, page: PageResponse): SaveAndProcessPageThunk;
|
|
270
282
|
|
|
271
|
-
export { type
|
|
283
|
+
export { type BasicRequestInit as $, type ApplicationRemote as A, type AllPages as B, type ComponentIdentifier as C, type Defer as D, type AllFragments as E, type FetchArgs as F, type GraftResponse as G, type Handlers as H, type RootState as I, type JSONMappable as J, type Keypath as K, type VisitCreator as L, type Meta as M, type NavigationProviderProps as N, type RemoteCreator as O, type PageKey as P, type Dispatch as Q, type RestoreStrategy as R, type SuperglueStore as S, type UJSHandlers as T, type Unproxy as U, type VisitMeta as V, type HistoryState as W, type SaveAndProcessPageThunk as X, type MetaThunk as Y, type VisitMetaThunk as Z, type DefermentThunk as _, type JSONValue as a, type BuildStore as a0, type BuildVisitAndRemote as a1, type Visit as a2, type VisitProps as a3, type Remote as a4, type RemoteProps as a5, type BeforeSave as a6, type GraftingSuccessAction as a7, type GraftingErrorAction as a8, useContent as a9, MismatchedComponentError as aa, remote as ab, visit as ac, type NavigateTo as b, type NavigationContextProps as c, type SaveResponse as d, type PageResponse as e, type Fragment as f, type FragmentProxy as g, type SuperglueState as h, type ApplicationProps as i, type SetupProps as j, type ApplicationVisit as k, superglueReducer as l, type NavigationAction as m, type JSONPrimitive as n, type JSONObject as o, pageReducer as p, type JSONKeyable as q, rootReducer as r, saveAndProcessPage as s, type ParsedResponse as t, unproxy as u, type Page as v, type StreamMessage as w, type StreamResponse as x, type FragmentPath as y, type FragmentRef as z };
|
package/dist/superglue.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as history from 'history';
|
|
2
|
-
import { J as JSONMappable, K as Keypath, a as JSONValue, P as PageKey, A as ApplicationRemote, S as SuperglueStore, N as
|
|
3
|
-
export {
|
|
2
|
+
import { J as JSONMappable, K as Keypath, a as JSONValue, P as PageKey, A as ApplicationRemote, S as SuperglueStore, N as NavigationProviderProps, b as NavigateTo, c as NavigationContextProps, F as FetchArgs, d as SaveResponse, e as PageResponse, f as Fragment, U as Unproxy, g as FragmentProxy, h as SuperglueState, i as ApplicationProps, j as SetupProps, k as ApplicationVisit, H as Handlers } from './index-j0c-9ZLt.mjs';
|
|
3
|
+
export { E as AllFragments, B as AllPages, $ as BasicRequestInit, a6 as BeforeSave, a0 as BuildStore, a1 as BuildVisitAndRemote, C as ComponentIdentifier, D as Defer, _ as DefermentThunk, Q as Dispatch, y as FragmentPath, z as FragmentRef, G as GraftResponse, a8 as GraftingErrorAction, a7 as GraftingSuccessAction, W as HistoryState, q as JSONKeyable, o as JSONObject, n as JSONPrimitive, M as Meta, Y as MetaThunk, m as NavigationAction, v as Page, t as ParsedResponse, a4 as Remote, O as RemoteCreator, a5 as RemoteProps, R as RestoreStrategy, I as RootState, X as SaveAndProcessPageThunk, w as StreamMessage, x as StreamResponse, T as UJSHandlers, a2 as Visit, L as VisitCreator, V as VisitMeta, Z as VisitMetaThunk, a3 as VisitProps, p as pageReducer, r as rootReducer, s as saveAndProcessPage, l as superglueReducer, u as unproxy, a9 as useContent } from './index-j0c-9ZLt.mjs';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { ChannelNameWithParams, Subscription } from '@rails/actioncable';
|
|
6
6
|
import { DebouncedFunc } from 'lodash';
|
|
7
7
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
8
8
|
|
|
@@ -31,7 +31,7 @@ declare class StreamActions {
|
|
|
31
31
|
}
|
|
32
32
|
declare function useStreamSource(channel: StreamSourceProps): {
|
|
33
33
|
connected: boolean;
|
|
34
|
-
subscription: Subscription
|
|
34
|
+
subscription: Subscription | null;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
declare const NavigationContext: React.Context<NavigationContextProps>;
|
|
@@ -66,28 +66,19 @@ declare const beforeRemote: _reduxjs_toolkit.ActionCreatorWithPayload<{
|
|
|
66
66
|
currentPageKey: PageKey;
|
|
67
67
|
fetchArgs: FetchArgs;
|
|
68
68
|
}, string>;
|
|
69
|
+
declare const receiveResponse: _reduxjs_toolkit.ActionCreatorWithPreparedPayload<[{
|
|
70
|
+
pageKey: string;
|
|
71
|
+
response: PageResponse;
|
|
72
|
+
}], {
|
|
73
|
+
pageKey: string;
|
|
74
|
+
response: PageResponse;
|
|
75
|
+
}, "@@superglue/RECEIVE_RESPONSE", never, never>;
|
|
69
76
|
|
|
70
|
-
type
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
type Unpack<T> = T extends Fragment<infer U, unknown> ? U : T extends FragmentProxy ? T : never;
|
|
78
|
+
declare function useSetFragment(): {
|
|
79
|
+
<T extends Fragment<unknown, unknown>>(fragmentRef: T, updater: (draft: Unproxy<Unpack<T>>) => void): void;
|
|
80
|
+
<T = unknown>(fragmentId: string, updater: (draft: T) => void): void;
|
|
74
81
|
};
|
|
75
|
-
type FragmentRef = {
|
|
76
|
-
__id: string;
|
|
77
|
-
} | string;
|
|
78
|
-
declare function useContent<T = JSONMappable>(): ProxiedContent<T>;
|
|
79
|
-
declare function useContent<T = JSONMappable>(fragmentRef: FragmentRef): ProxiedContent<T>;
|
|
80
|
-
declare function useContent<T = JSONMappable>(fragmentRef: FragmentRef, options: {
|
|
81
|
-
optional: false;
|
|
82
|
-
}): ProxiedContent<T>;
|
|
83
|
-
declare function useContent<T = JSONMappable>(fragmentRef: FragmentRef, options: {
|
|
84
|
-
optional: true;
|
|
85
|
-
}): ProxiedContent<T> | undefined;
|
|
86
|
-
declare function unproxy<T>(proxy: T): Unproxied<T>;
|
|
87
|
-
|
|
88
|
-
declare function useSetFragment(): (fragmentRef: {
|
|
89
|
-
__id: string;
|
|
90
|
-
} | string, updater: (draft: unknown) => void) => void;
|
|
91
82
|
|
|
92
83
|
declare function useSuperglue(): SuperglueState;
|
|
93
84
|
|
|
@@ -102,4 +93,4 @@ declare const setup: ({ initialPage, baseUrl, path, store, buildVisitAndRemote,
|
|
|
102
93
|
};
|
|
103
94
|
declare function Application({ initialPage, baseUrl, path, store, buildVisitAndRemote, history, mapping, ...rest }: ApplicationProps): React.JSX.Element;
|
|
104
95
|
|
|
105
|
-
export { Application, ApplicationProps, ApplicationRemote, ApplicationVisit, FetchArgs, GRAFTING_ERROR, GRAFTING_SUCCESS, Handlers, JSONMappable, JSONValue, Keypath, NavigateTo, NavigationContext, NavigationContextProps, NavigationProvider, NavigationProviderProps, PageKey, SaveResponse, SetupProps, SuperglueState, SuperglueStore,
|
|
96
|
+
export { Application, ApplicationProps, ApplicationRemote, ApplicationVisit, FetchArgs, Fragment, GRAFTING_ERROR, GRAFTING_SUCCESS, Handlers, JSONMappable, JSONValue, Keypath, NavigateTo, NavigationContext, NavigationContextProps, NavigationProvider, NavigationProviderProps, PageKey, PageResponse, SaveResponse, SetupProps, SuperglueState, SuperglueStore, Unproxy, beforeFetch, beforeRemote, beforeVisit, copyPage, getIn, prepareStore, receiveResponse, removePage, saveResponse, setup, urlToPageKey, useSetFragment, useStreamSource, useSuperglue };
|