@reykjavik/webtools 0.3.0 → 0.3.1
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/CHANGELOG.md +6 -0
- package/CookieHubConsent.d.ts +2 -2
- package/CookieHubConsent.js +2 -2
- package/SiteImprove.d.ts +3 -3
- package/SiteImprove.js +3 -3
- package/async.d.ts +4 -4
- package/async.js +3 -3
- package/errorhandling.d.ts +10 -10
- package/errorhandling.js +7 -7
- package/esm/CookieHubConsent.d.ts +2 -2
- package/esm/CookieHubConsent.js +2 -2
- package/esm/SiteImprove.d.ts +3 -3
- package/esm/SiteImprove.js +3 -3
- package/esm/async.d.ts +4 -4
- package/esm/async.js +3 -3
- package/esm/errorhandling.d.ts +10 -10
- package/esm/errorhandling.js +7 -7
- package/esm/hooks.d.ts +2 -2
- package/esm/hooks.js +2 -2
- package/esm/http.d.ts +5 -5
- package/esm/http.js +4 -4
- package/esm/next/http.d.ts +2 -2
- package/esm/next/http.js +3 -3
- package/esm/react-router/Wait.d.ts +2 -2
- package/esm/react-router/Wait.js +1 -1
- package/esm/react-router/http.d.ts +1 -1
- package/esm/react-router/http.js +1 -1
- package/esm/vanillaExtract.d.ts +4 -4
- package/esm/vanillaExtract.js +3 -3
- package/hooks.d.ts +2 -2
- package/hooks.js +2 -2
- package/http.d.ts +5 -5
- package/http.js +4 -4
- package/next/http.d.ts +2 -2
- package/next/http.js +3 -3
- package/package.json +1 -1
- package/react-router/Wait.d.ts +2 -2
- package/react-router/Wait.js +1 -1
- package/react-router/http.d.ts +1 -1
- package/react-router/http.js +1 -1
- package/vanillaExtract.d.ts +4 -4
- package/vanillaExtract.js +3 -3
package/CHANGELOG.md
CHANGED
package/CookieHubConsent.d.ts
CHANGED
|
@@ -220,14 +220,14 @@ export type CookieHubProviderProps = EitherObj<{
|
|
|
220
220
|
* management script and sets up a React state object with the relevant user
|
|
221
221
|
* consent flags.
|
|
222
222
|
*
|
|
223
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
223
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cookiehubprovider-component
|
|
224
224
|
*/
|
|
225
225
|
export declare const CookieHubProvider: (props: CookieHubProviderProps) => React.JSX.Element;
|
|
226
226
|
/**
|
|
227
227
|
* Returns up-to-date cookie consent flags. For use in React components or hook
|
|
228
228
|
* functions.
|
|
229
229
|
*
|
|
230
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
230
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usecookiehubconsent
|
|
231
231
|
*/
|
|
232
232
|
export declare const useCookieHubConsent: () => Partial<CookieHubContextState["consent"]>;
|
|
233
233
|
export {};
|
package/CookieHubConsent.js
CHANGED
|
@@ -71,7 +71,7 @@ const moveCookiehubScriptInDomTree = () => {
|
|
|
71
71
|
* management script and sets up a React state object with the relevant user
|
|
72
72
|
* consent flags.
|
|
73
73
|
*
|
|
74
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
74
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cookiehubprovider-component
|
|
75
75
|
*/
|
|
76
76
|
const CookieHubProvider = (props) => {
|
|
77
77
|
const [state, setState] = (0, react_1.useState)(initialConsentState);
|
|
@@ -159,7 +159,7 @@ exports.CookieHubProvider = CookieHubProvider;
|
|
|
159
159
|
* Returns up-to-date cookie consent flags. For use in React components or hook
|
|
160
160
|
* functions.
|
|
161
161
|
*
|
|
162
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
162
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usecookiehubconsent
|
|
163
163
|
*/
|
|
164
164
|
const useCookieHubConsent = () => { var _a; return ((_a = (0, react_1.useContext)(CookieHubContext)) === null || _a === void 0 ? void 0 : _a.consent) || {}; };
|
|
165
165
|
exports.useCookieHubConsent = useCookieHubConsent;
|
package/SiteImprove.d.ts
CHANGED
|
@@ -45,14 +45,14 @@ type SiteImproveCustomEvent = [
|
|
|
45
45
|
/**
|
|
46
46
|
* A small helper for tracking custom UI events and reporting them to SiteImrove.
|
|
47
47
|
*
|
|
48
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
48
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimprove-helper
|
|
49
49
|
*/
|
|
50
50
|
export declare const pingSiteImprove: (category: string, action: string, label?: string) => void;
|
|
51
51
|
/**
|
|
52
52
|
* A small helper for reporting to SiteImrove when the user is programmatically
|
|
53
53
|
* being sent to a different URL/resource.
|
|
54
54
|
*
|
|
55
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
55
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimproveoutbound-helper
|
|
56
56
|
*/
|
|
57
57
|
export declare const pingSiteImproveOutbound: (ourl: string) => void;
|
|
58
58
|
export type SiteImproveProps = EitherObj<{
|
|
@@ -94,7 +94,7 @@ export type SiteImproveProps = EitherObj<{
|
|
|
94
94
|
* A component for loading a SiteImprove analytics script and set up page-view
|
|
95
95
|
* tracking across client-side (pushState, replaceState) routing.
|
|
96
96
|
*
|
|
97
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
97
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#siteimprove-component
|
|
98
98
|
*/
|
|
99
99
|
export declare const SiteImprove: (props: SiteImproveProps) => null;
|
|
100
100
|
export {};
|
package/SiteImprove.js
CHANGED
|
@@ -29,7 +29,7 @@ const trackDynamicPageView = (url, refUrl, title) => _emitEvent(['trackdynamic',
|
|
|
29
29
|
/**
|
|
30
30
|
* A small helper for tracking custom UI events and reporting them to SiteImrove.
|
|
31
31
|
*
|
|
32
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
32
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimprove-helper
|
|
33
33
|
*/
|
|
34
34
|
const pingSiteImprove = (category, action, label) => {
|
|
35
35
|
if (process.env.NODE_ENV === 'development' &&
|
|
@@ -44,7 +44,7 @@ exports.pingSiteImprove = pingSiteImprove;
|
|
|
44
44
|
* A small helper for reporting to SiteImrove when the user is programmatically
|
|
45
45
|
* being sent to a different URL/resource.
|
|
46
46
|
*
|
|
47
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
47
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimproveoutbound-helper
|
|
48
48
|
*/
|
|
49
49
|
const pingSiteImproveOutbound = (ourl) => {
|
|
50
50
|
if (process.env.NODE_ENV === 'development' &&
|
|
@@ -125,7 +125,7 @@ const loc = typeof document !== 'undefined' ? document.location : {};
|
|
|
125
125
|
* A component for loading a SiteImprove analytics script and set up page-view
|
|
126
126
|
* tracking across client-side (pushState, replaceState) routing.
|
|
127
127
|
*
|
|
128
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
128
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#siteimprove-component
|
|
129
129
|
*/
|
|
130
130
|
const SiteImprove = (props) => {
|
|
131
131
|
const consented = useResolvedAnalyticsConsent(props.hasConsented);
|
package/async.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const addLag: (length: number, opts?: {
|
|
|
18
18
|
* Resolves as soon as all of the passed `promises` have resolved/settled,
|
|
19
19
|
* or after `timeout` milliseconds — whichever comes first.
|
|
20
20
|
*
|
|
21
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
21
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#maxwait
|
|
22
22
|
*/
|
|
23
23
|
export declare function maxWait(timeout: number, promises: Array<unknown>): Promise<void>;
|
|
24
24
|
export declare function maxWait<PromiseMap extends PlainObj>(timeout: number, promises: PromiseMap): Promise<{
|
|
@@ -28,7 +28,7 @@ export declare function maxWait<PromiseMap extends PlainObj>(timeout: number, pr
|
|
|
28
28
|
* A variation of `Promise.all()` that accepts an object with named promises
|
|
29
29
|
* and returns a same-shaped object with the resolved values.
|
|
30
30
|
*
|
|
31
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
31
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#promiseallobject
|
|
32
32
|
*/
|
|
33
33
|
export declare const promiseAllObject: <T extends PlainObj>(promisesMap: T) => Promise<{ -readonly [K in keyof T]: Awaited<T[K]>; }>;
|
|
34
34
|
type Cancellable<A extends Array<unknown>> = ((...args: A) => void) & {
|
|
@@ -44,7 +44,7 @@ type Cancellable<A extends Array<unknown>> = ((...args: A) => void) & {
|
|
|
44
44
|
* of quiet-time. \
|
|
45
45
|
* The returned function also has a nice `.cancel()` method.
|
|
46
46
|
*
|
|
47
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
47
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#debounce
|
|
48
48
|
*/
|
|
49
49
|
export declare const debounce: {
|
|
50
50
|
<A extends Array<unknown>>(func: (...args: A) => void, delay: number, immediate?: boolean): Cancellable<A>;
|
|
@@ -64,7 +64,7 @@ type Finishable<A extends Array<unknown>> = ((...args: A) => void) & {
|
|
|
64
64
|
* The returned function also has a nice `.finish()` method to reset the
|
|
65
65
|
* throttle timer
|
|
66
66
|
*
|
|
67
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
67
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#throttle
|
|
68
68
|
*/
|
|
69
69
|
export declare const throttle: {
|
|
70
70
|
<A extends Array<unknown>>(func: (...args: A) => void, delay: number, skipFirst?: boolean): Finishable<A>;
|
package/async.js
CHANGED
|
@@ -67,7 +67,7 @@ function maxWait(timeout, promises) {
|
|
|
67
67
|
* A variation of `Promise.all()` that accepts an object with named promises
|
|
68
68
|
* and returns a same-shaped object with the resolved values.
|
|
69
69
|
*
|
|
70
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
70
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#promiseallobject
|
|
71
71
|
*/
|
|
72
72
|
/*#__NO_SIDE_EFFECTS__*/
|
|
73
73
|
const promiseAllObject = (promisesMap) => Promise.all(Object.values(promisesMap)).then((results) => {
|
|
@@ -84,7 +84,7 @@ exports.promiseAllObject = promiseAllObject;
|
|
|
84
84
|
* of quiet-time. \
|
|
85
85
|
* The returned function also has a nice `.cancel()` method.
|
|
86
86
|
*
|
|
87
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
87
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#debounce
|
|
88
88
|
*/
|
|
89
89
|
/*#__NO_SIDE_EFFECTS__*/
|
|
90
90
|
const debounce = (
|
|
@@ -136,7 +136,7 @@ exports.debounce.d = (delay, immediate) => (0, exports.debounce)(function (fn, .
|
|
|
136
136
|
* The returned function also has a nice `.finish()` method to reset the
|
|
137
137
|
* throttle timer
|
|
138
138
|
*
|
|
139
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
139
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#throttle
|
|
140
140
|
*/
|
|
141
141
|
/*#__NO_SIDE_EFFECTS__*/
|
|
142
142
|
const throttle = (
|
package/errorhandling.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Error subclass for thrown NON-Error values that got turned into an actual
|
|
3
3
|
* Error, with the original thrown value as the `payload` property.
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
|
|
6
6
|
*/
|
|
7
7
|
export declare class ErrorFromPayload extends Error {
|
|
8
8
|
/**
|
|
@@ -25,7 +25,7 @@ export declare class ErrorFromPayload extends Error {
|
|
|
25
25
|
* something else it is wrapped in a new `ErrorFromPayload` instance, and the
|
|
26
26
|
* original value is stored in a `payload`
|
|
27
27
|
*
|
|
28
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
28
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
|
|
29
29
|
*/
|
|
30
30
|
export declare const asError: (maybeError: unknown) => ErrorFromPayload;
|
|
31
31
|
type SuccessResult<T> = [error: undefined, result: T] & {
|
|
@@ -41,14 +41,14 @@ type FailResult<E extends Error> = [error: E, result?: undefined] & {
|
|
|
41
41
|
/**
|
|
42
42
|
* Simple bare-bones discriminated tuple type for a [error, result] pair.
|
|
43
43
|
*
|
|
44
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
44
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-resulttuple
|
|
45
45
|
*/
|
|
46
46
|
export type ResultTuple<T, E extends Error = Error> = [error: undefined, result: T] | [error: E, result?: undefined];
|
|
47
47
|
/**
|
|
48
48
|
* Discriminated tuple type for a `[error, result]` pair (same as `ResultTuple`)
|
|
49
49
|
* but with named properties `error` and `result` attached for dev convenience.
|
|
50
50
|
*
|
|
51
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
51
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-resulttupleobj
|
|
52
52
|
*/
|
|
53
53
|
export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | FailResult<E>;
|
|
54
54
|
/**
|
|
@@ -60,7 +60,7 @@ export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | Fail
|
|
|
60
60
|
*
|
|
61
61
|
* Works on both promises and (synchronous) callback functions.
|
|
62
62
|
*
|
|
63
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
63
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultcatch
|
|
64
64
|
*/
|
|
65
65
|
declare function catch_<T, E extends Error = ErrorFromPayload>(promise: Promise<T>): Promise<ResultTupleObj<T, E>>;
|
|
66
66
|
declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T): ResultTupleObj<T, E>;
|
|
@@ -68,19 +68,19 @@ declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T
|
|
|
68
68
|
* Singleton object with small methods for creating, mapping or handling
|
|
69
69
|
* `ResultTupleObj` instances.
|
|
70
70
|
*
|
|
71
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
71
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#result-singleton
|
|
72
72
|
*/
|
|
73
73
|
export declare const Result: {
|
|
74
74
|
/**
|
|
75
75
|
* Factory for creating a successful `Result.TupleObj`.
|
|
76
76
|
*
|
|
77
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
77
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsuccess
|
|
78
78
|
*/
|
|
79
79
|
Success: <T>(result: T) => SuccessResult<T>;
|
|
80
80
|
/**
|
|
81
81
|
* Factory for creating a failed `Result.TupleObj`.
|
|
82
82
|
*
|
|
83
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
83
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsfail
|
|
84
84
|
*/
|
|
85
85
|
Fail: <E extends Error = Error>(e: unknown) => FailResult<E>;
|
|
86
86
|
catch: typeof catch_;
|
|
@@ -90,14 +90,14 @@ export declare const Result: {
|
|
|
90
90
|
* object, applying a transformation function to the result, but retaining
|
|
91
91
|
* the error as-is.
|
|
92
92
|
*
|
|
93
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
93
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulmap
|
|
94
94
|
*/
|
|
95
95
|
map: <T, T2, E extends Error>(result: ResultTuple<T, E>, mapFn: (resultValue: T) => T2) => ResultTupleObj<T2, E>;
|
|
96
96
|
/**
|
|
97
97
|
* Unwraps a discriminated [error, result] `Result.Tuple`-like object
|
|
98
98
|
* and throws if there's an error, but returns the result otherwise.
|
|
99
99
|
*
|
|
100
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
100
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulthrow
|
|
101
101
|
*/
|
|
102
102
|
throw: <T>(result: ResultTuple<T>) => T;
|
|
103
103
|
};
|
package/errorhandling.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.Result = exports.asError = exports.ErrorFromPayload = void 0;
|
|
|
5
5
|
* Error subclass for thrown NON-Error values that got turned into an actual
|
|
6
6
|
* Error, with the original thrown value as the `payload` property.
|
|
7
7
|
*
|
|
8
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
8
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
|
|
9
9
|
*/
|
|
10
10
|
/*#__NO_SIDE_EFFECTS__*/
|
|
11
11
|
class ErrorFromPayload extends Error {
|
|
@@ -28,7 +28,7 @@ exports.ErrorFromPayload = ErrorFromPayload;
|
|
|
28
28
|
* something else it is wrapped in a new `ErrorFromPayload` instance, and the
|
|
29
29
|
* original value is stored in a `payload`
|
|
30
30
|
*
|
|
31
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
31
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
|
|
32
32
|
*/
|
|
33
33
|
/*#__NO_SIDE_EFFECTS__*/
|
|
34
34
|
const asError = (maybeError) => {
|
|
@@ -79,19 +79,19 @@ mapFn) => {
|
|
|
79
79
|
* Singleton object with small methods for creating, mapping or handling
|
|
80
80
|
* `ResultTupleObj` instances.
|
|
81
81
|
*
|
|
82
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
82
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#result-singleton
|
|
83
83
|
*/
|
|
84
84
|
exports.Result = {
|
|
85
85
|
/**
|
|
86
86
|
* Factory for creating a successful `Result.TupleObj`.
|
|
87
87
|
*
|
|
88
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
88
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsuccess
|
|
89
89
|
*/
|
|
90
90
|
Success,
|
|
91
91
|
/**
|
|
92
92
|
* Factory for creating a failed `Result.TupleObj`.
|
|
93
93
|
*
|
|
94
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
94
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsfail
|
|
95
95
|
*/
|
|
96
96
|
Fail,
|
|
97
97
|
// NOTE: The JSDoc must be placed above the `catch_` function above.
|
|
@@ -102,7 +102,7 @@ exports.Result = {
|
|
|
102
102
|
* object, applying a transformation function to the result, but retaining
|
|
103
103
|
* the error as-is.
|
|
104
104
|
*
|
|
105
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
105
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulmap
|
|
106
106
|
*/
|
|
107
107
|
/*#__NO_SIDE_EFFECTS__*/
|
|
108
108
|
map: (result, mapFn) => {
|
|
@@ -116,7 +116,7 @@ exports.Result = {
|
|
|
116
116
|
* Unwraps a discriminated [error, result] `Result.Tuple`-like object
|
|
117
117
|
* and throws if there's an error, but returns the result otherwise.
|
|
118
118
|
*
|
|
119
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
119
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulthrow
|
|
120
120
|
*/
|
|
121
121
|
/*#__NO_SIDE_EFFECTS__*/
|
|
122
122
|
throw: (result) => {
|
|
@@ -220,14 +220,14 @@ export type CookieHubProviderProps = EitherObj<{
|
|
|
220
220
|
* management script and sets up a React state object with the relevant user
|
|
221
221
|
* consent flags.
|
|
222
222
|
*
|
|
223
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
223
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cookiehubprovider-component
|
|
224
224
|
*/
|
|
225
225
|
export declare const CookieHubProvider: (props: CookieHubProviderProps) => React.JSX.Element;
|
|
226
226
|
/**
|
|
227
227
|
* Returns up-to-date cookie consent flags. For use in React components or hook
|
|
228
228
|
* functions.
|
|
229
229
|
*
|
|
230
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
230
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usecookiehubconsent
|
|
231
231
|
*/
|
|
232
232
|
export declare const useCookieHubConsent: () => Partial<CookieHubContextState["consent"]>;
|
|
233
233
|
export {};
|
package/esm/CookieHubConsent.js
CHANGED
|
@@ -35,7 +35,7 @@ const moveCookiehubScriptInDomTree = () => {
|
|
|
35
35
|
* management script and sets up a React state object with the relevant user
|
|
36
36
|
* consent flags.
|
|
37
37
|
*
|
|
38
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
38
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cookiehubprovider-component
|
|
39
39
|
*/
|
|
40
40
|
export const CookieHubProvider = (props) => {
|
|
41
41
|
const [state, setState] = useState(initialConsentState);
|
|
@@ -122,6 +122,6 @@ export const CookieHubProvider = (props) => {
|
|
|
122
122
|
* Returns up-to-date cookie consent flags. For use in React components or hook
|
|
123
123
|
* functions.
|
|
124
124
|
*
|
|
125
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
125
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usecookiehubconsent
|
|
126
126
|
*/
|
|
127
127
|
export const useCookieHubConsent = () => { var _a; return ((_a = useContext(CookieHubContext)) === null || _a === void 0 ? void 0 : _a.consent) || {}; };
|
package/esm/SiteImprove.d.ts
CHANGED
|
@@ -45,14 +45,14 @@ type SiteImproveCustomEvent = [
|
|
|
45
45
|
/**
|
|
46
46
|
* A small helper for tracking custom UI events and reporting them to SiteImrove.
|
|
47
47
|
*
|
|
48
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
48
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimprove-helper
|
|
49
49
|
*/
|
|
50
50
|
export declare const pingSiteImprove: (category: string, action: string, label?: string) => void;
|
|
51
51
|
/**
|
|
52
52
|
* A small helper for reporting to SiteImrove when the user is programmatically
|
|
53
53
|
* being sent to a different URL/resource.
|
|
54
54
|
*
|
|
55
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
55
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimproveoutbound-helper
|
|
56
56
|
*/
|
|
57
57
|
export declare const pingSiteImproveOutbound: (ourl: string) => void;
|
|
58
58
|
export type SiteImproveProps = EitherObj<{
|
|
@@ -94,7 +94,7 @@ export type SiteImproveProps = EitherObj<{
|
|
|
94
94
|
* A component for loading a SiteImprove analytics script and set up page-view
|
|
95
95
|
* tracking across client-side (pushState, replaceState) routing.
|
|
96
96
|
*
|
|
97
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
97
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#siteimprove-component
|
|
98
98
|
*/
|
|
99
99
|
export declare const SiteImprove: (props: SiteImproveProps) => null;
|
|
100
100
|
export {};
|
package/esm/SiteImprove.js
CHANGED
|
@@ -26,7 +26,7 @@ const trackDynamicPageView = (url, refUrl, title) => _emitEvent(['trackdynamic',
|
|
|
26
26
|
/**
|
|
27
27
|
* A small helper for tracking custom UI events and reporting them to SiteImrove.
|
|
28
28
|
*
|
|
29
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
29
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimprove-helper
|
|
30
30
|
*/
|
|
31
31
|
export const pingSiteImprove = (category, action, label) => {
|
|
32
32
|
if (process.env.NODE_ENV === 'development' &&
|
|
@@ -40,7 +40,7 @@ export const pingSiteImprove = (category, action, label) => {
|
|
|
40
40
|
* A small helper for reporting to SiteImrove when the user is programmatically
|
|
41
41
|
* being sent to a different URL/resource.
|
|
42
42
|
*
|
|
43
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
43
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimproveoutbound-helper
|
|
44
44
|
*/
|
|
45
45
|
export const pingSiteImproveOutbound = (ourl) => {
|
|
46
46
|
if (process.env.NODE_ENV === 'development' &&
|
|
@@ -120,7 +120,7 @@ const loc = typeof document !== 'undefined' ? document.location : {};
|
|
|
120
120
|
* A component for loading a SiteImprove analytics script and set up page-view
|
|
121
121
|
* tracking across client-side (pushState, replaceState) routing.
|
|
122
122
|
*
|
|
123
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
123
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#siteimprove-component
|
|
124
124
|
*/
|
|
125
125
|
export const SiteImprove = (props) => {
|
|
126
126
|
const consented = useResolvedAnalyticsConsent(props.hasConsented);
|
package/esm/async.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const addLag: (length: number, opts?: {
|
|
|
18
18
|
* Resolves as soon as all of the passed `promises` have resolved/settled,
|
|
19
19
|
* or after `timeout` milliseconds — whichever comes first.
|
|
20
20
|
*
|
|
21
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
21
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#maxwait
|
|
22
22
|
*/
|
|
23
23
|
export declare function maxWait(timeout: number, promises: Array<unknown>): Promise<void>;
|
|
24
24
|
export declare function maxWait<PromiseMap extends PlainObj>(timeout: number, promises: PromiseMap): Promise<{
|
|
@@ -28,7 +28,7 @@ export declare function maxWait<PromiseMap extends PlainObj>(timeout: number, pr
|
|
|
28
28
|
* A variation of `Promise.all()` that accepts an object with named promises
|
|
29
29
|
* and returns a same-shaped object with the resolved values.
|
|
30
30
|
*
|
|
31
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
31
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#promiseallobject
|
|
32
32
|
*/
|
|
33
33
|
export declare const promiseAllObject: <T extends PlainObj>(promisesMap: T) => Promise<{ -readonly [K in keyof T]: Awaited<T[K]>; }>;
|
|
34
34
|
type Cancellable<A extends Array<unknown>> = ((...args: A) => void) & {
|
|
@@ -44,7 +44,7 @@ type Cancellable<A extends Array<unknown>> = ((...args: A) => void) & {
|
|
|
44
44
|
* of quiet-time. \
|
|
45
45
|
* The returned function also has a nice `.cancel()` method.
|
|
46
46
|
*
|
|
47
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
47
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#debounce
|
|
48
48
|
*/
|
|
49
49
|
export declare const debounce: {
|
|
50
50
|
<A extends Array<unknown>>(func: (...args: A) => void, delay: number, immediate?: boolean): Cancellable<A>;
|
|
@@ -64,7 +64,7 @@ type Finishable<A extends Array<unknown>> = ((...args: A) => void) & {
|
|
|
64
64
|
* The returned function also has a nice `.finish()` method to reset the
|
|
65
65
|
* throttle timer
|
|
66
66
|
*
|
|
67
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
67
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#throttle
|
|
68
68
|
*/
|
|
69
69
|
export declare const throttle: {
|
|
70
70
|
<A extends Array<unknown>>(func: (...args: A) => void, delay: number, skipFirst?: boolean): Finishable<A>;
|
package/esm/async.js
CHANGED
|
@@ -61,7 +61,7 @@ export function maxWait(timeout, promises) {
|
|
|
61
61
|
* A variation of `Promise.all()` that accepts an object with named promises
|
|
62
62
|
* and returns a same-shaped object with the resolved values.
|
|
63
63
|
*
|
|
64
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
64
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#promiseallobject
|
|
65
65
|
*/
|
|
66
66
|
/*#__NO_SIDE_EFFECTS__*/
|
|
67
67
|
export const promiseAllObject = (promisesMap) => Promise.all(Object.values(promisesMap)).then((results) => {
|
|
@@ -77,7 +77,7 @@ export const promiseAllObject = (promisesMap) => Promise.all(Object.values(promi
|
|
|
77
77
|
* of quiet-time. \
|
|
78
78
|
* The returned function also has a nice `.cancel()` method.
|
|
79
79
|
*
|
|
80
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
80
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#debounce
|
|
81
81
|
*/
|
|
82
82
|
/*#__NO_SIDE_EFFECTS__*/
|
|
83
83
|
export const debounce = (
|
|
@@ -128,7 +128,7 @@ debounce.d = (delay, immediate) => debounce(function (fn, ...args) {
|
|
|
128
128
|
* The returned function also has a nice `.finish()` method to reset the
|
|
129
129
|
* throttle timer
|
|
130
130
|
*
|
|
131
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
131
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#throttle
|
|
132
132
|
*/
|
|
133
133
|
/*#__NO_SIDE_EFFECTS__*/
|
|
134
134
|
export const throttle = (
|
package/esm/errorhandling.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Error subclass for thrown NON-Error values that got turned into an actual
|
|
3
3
|
* Error, with the original thrown value as the `payload` property.
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
|
|
6
6
|
*/
|
|
7
7
|
export declare class ErrorFromPayload extends Error {
|
|
8
8
|
/**
|
|
@@ -25,7 +25,7 @@ export declare class ErrorFromPayload extends Error {
|
|
|
25
25
|
* something else it is wrapped in a new `ErrorFromPayload` instance, and the
|
|
26
26
|
* original value is stored in a `payload`
|
|
27
27
|
*
|
|
28
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
28
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
|
|
29
29
|
*/
|
|
30
30
|
export declare const asError: (maybeError: unknown) => ErrorFromPayload;
|
|
31
31
|
type SuccessResult<T> = [error: undefined, result: T] & {
|
|
@@ -41,14 +41,14 @@ type FailResult<E extends Error> = [error: E, result?: undefined] & {
|
|
|
41
41
|
/**
|
|
42
42
|
* Simple bare-bones discriminated tuple type for a [error, result] pair.
|
|
43
43
|
*
|
|
44
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
44
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-resulttuple
|
|
45
45
|
*/
|
|
46
46
|
export type ResultTuple<T, E extends Error = Error> = [error: undefined, result: T] | [error: E, result?: undefined];
|
|
47
47
|
/**
|
|
48
48
|
* Discriminated tuple type for a `[error, result]` pair (same as `ResultTuple`)
|
|
49
49
|
* but with named properties `error` and `result` attached for dev convenience.
|
|
50
50
|
*
|
|
51
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
51
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-resulttupleobj
|
|
52
52
|
*/
|
|
53
53
|
export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | FailResult<E>;
|
|
54
54
|
/**
|
|
@@ -60,7 +60,7 @@ export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | Fail
|
|
|
60
60
|
*
|
|
61
61
|
* Works on both promises and (synchronous) callback functions.
|
|
62
62
|
*
|
|
63
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
63
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultcatch
|
|
64
64
|
*/
|
|
65
65
|
declare function catch_<T, E extends Error = ErrorFromPayload>(promise: Promise<T>): Promise<ResultTupleObj<T, E>>;
|
|
66
66
|
declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T): ResultTupleObj<T, E>;
|
|
@@ -68,19 +68,19 @@ declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T
|
|
|
68
68
|
* Singleton object with small methods for creating, mapping or handling
|
|
69
69
|
* `ResultTupleObj` instances.
|
|
70
70
|
*
|
|
71
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
71
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#result-singleton
|
|
72
72
|
*/
|
|
73
73
|
export declare const Result: {
|
|
74
74
|
/**
|
|
75
75
|
* Factory for creating a successful `Result.TupleObj`.
|
|
76
76
|
*
|
|
77
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
77
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsuccess
|
|
78
78
|
*/
|
|
79
79
|
Success: <T>(result: T) => SuccessResult<T>;
|
|
80
80
|
/**
|
|
81
81
|
* Factory for creating a failed `Result.TupleObj`.
|
|
82
82
|
*
|
|
83
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
83
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsfail
|
|
84
84
|
*/
|
|
85
85
|
Fail: <E extends Error = Error>(e: unknown) => FailResult<E>;
|
|
86
86
|
catch: typeof catch_;
|
|
@@ -90,14 +90,14 @@ export declare const Result: {
|
|
|
90
90
|
* object, applying a transformation function to the result, but retaining
|
|
91
91
|
* the error as-is.
|
|
92
92
|
*
|
|
93
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
93
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulmap
|
|
94
94
|
*/
|
|
95
95
|
map: <T, T2, E extends Error>(result: ResultTuple<T, E>, mapFn: (resultValue: T) => T2) => ResultTupleObj<T2, E>;
|
|
96
96
|
/**
|
|
97
97
|
* Unwraps a discriminated [error, result] `Result.Tuple`-like object
|
|
98
98
|
* and throws if there's an error, but returns the result otherwise.
|
|
99
99
|
*
|
|
100
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
100
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulthrow
|
|
101
101
|
*/
|
|
102
102
|
throw: <T>(result: ResultTuple<T>) => T;
|
|
103
103
|
};
|
package/esm/errorhandling.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Error subclass for thrown NON-Error values that got turned into an actual
|
|
3
3
|
* Error, with the original thrown value as the `payload` property.
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
|
|
6
6
|
*/
|
|
7
7
|
/*#__NO_SIDE_EFFECTS__*/
|
|
8
8
|
export class ErrorFromPayload extends Error {
|
|
@@ -24,7 +24,7 @@ export class ErrorFromPayload extends Error {
|
|
|
24
24
|
* something else it is wrapped in a new `ErrorFromPayload` instance, and the
|
|
25
25
|
* original value is stored in a `payload`
|
|
26
26
|
*
|
|
27
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
27
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
|
|
28
28
|
*/
|
|
29
29
|
/*#__NO_SIDE_EFFECTS__*/
|
|
30
30
|
export const asError = (maybeError) => {
|
|
@@ -74,19 +74,19 @@ mapFn) => {
|
|
|
74
74
|
* Singleton object with small methods for creating, mapping or handling
|
|
75
75
|
* `ResultTupleObj` instances.
|
|
76
76
|
*
|
|
77
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
77
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#result-singleton
|
|
78
78
|
*/
|
|
79
79
|
export const Result = {
|
|
80
80
|
/**
|
|
81
81
|
* Factory for creating a successful `Result.TupleObj`.
|
|
82
82
|
*
|
|
83
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
83
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsuccess
|
|
84
84
|
*/
|
|
85
85
|
Success,
|
|
86
86
|
/**
|
|
87
87
|
* Factory for creating a failed `Result.TupleObj`.
|
|
88
88
|
*
|
|
89
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
89
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsfail
|
|
90
90
|
*/
|
|
91
91
|
Fail,
|
|
92
92
|
// NOTE: The JSDoc must be placed above the `catch_` function above.
|
|
@@ -97,7 +97,7 @@ export const Result = {
|
|
|
97
97
|
* object, applying a transformation function to the result, but retaining
|
|
98
98
|
* the error as-is.
|
|
99
99
|
*
|
|
100
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
100
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulmap
|
|
101
101
|
*/
|
|
102
102
|
/*#__NO_SIDE_EFFECTS__*/
|
|
103
103
|
map: (result, mapFn) => {
|
|
@@ -111,7 +111,7 @@ export const Result = {
|
|
|
111
111
|
* Unwraps a discriminated [error, result] `Result.Tuple`-like object
|
|
112
112
|
* and throws if there's an error, but returns the result otherwise.
|
|
113
113
|
*
|
|
114
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
114
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulthrow
|
|
115
115
|
*/
|
|
116
116
|
/*#__NO_SIDE_EFFECTS__*/
|
|
117
117
|
throw: (result) => {
|
package/esm/hooks.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* **NOTE:** The supplied callback does not need to be memoized. The debouncer
|
|
7
7
|
* will always invoke the last supplied version.
|
|
8
8
|
*
|
|
9
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
9
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usedebounced
|
|
10
10
|
*/
|
|
11
11
|
export declare const useDebounced: <A extends Array<unknown>>(
|
|
12
12
|
/** The function to debounce */
|
|
@@ -23,7 +23,7 @@ immediate?: boolean) => ((...args: A) => void) & {
|
|
|
23
23
|
* **NOTE:** The supplied callback does not need to be memoized. The throttler
|
|
24
24
|
* will always invoke the last supplied version.
|
|
25
25
|
*
|
|
26
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
26
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usethrottled
|
|
27
27
|
*/
|
|
28
28
|
export declare const useThrottled: <A extends Array<unknown>>(
|
|
29
29
|
/** The function to throttle */
|
package/esm/hooks.js
CHANGED
|
@@ -8,7 +8,7 @@ import { debounce, throttle } from './async.js';
|
|
|
8
8
|
* **NOTE:** The supplied callback does not need to be memoized. The debouncer
|
|
9
9
|
* will always invoke the last supplied version.
|
|
10
10
|
*
|
|
11
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
11
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usedebounced
|
|
12
12
|
*/
|
|
13
13
|
export const useDebounced = (
|
|
14
14
|
/** The function to debounce */
|
|
@@ -29,7 +29,7 @@ immediate) => {
|
|
|
29
29
|
* **NOTE:** The supplied callback does not need to be memoized. The throttler
|
|
30
30
|
* will always invoke the last supplied version.
|
|
31
31
|
*
|
|
32
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
32
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usethrottled
|
|
33
33
|
*/
|
|
34
34
|
export const useThrottled = (
|
|
35
35
|
/** The function to throttle */
|
package/esm/http.d.ts
CHANGED
|
@@ -154,21 +154,21 @@ type TTLObj = {
|
|
|
154
154
|
/**
|
|
155
155
|
* Configures quick TTL-related settings for a HTTP request object
|
|
156
156
|
*
|
|
157
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
157
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-ttlconfig
|
|
158
158
|
*/
|
|
159
159
|
export type TTLConfig = TTL | TTLKeywords | TTLObj;
|
|
160
160
|
/**
|
|
161
161
|
* Converts a `TTL` (duration) value into milliseconds. Returns `0` for bad
|
|
162
162
|
* and/or negative input values.
|
|
163
163
|
*
|
|
164
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
164
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#toms-duration-helper
|
|
165
165
|
*/
|
|
166
166
|
export declare const toMs: (ttl: TTL) => number;
|
|
167
167
|
/**
|
|
168
168
|
* Converts a `TTL` (max-age) value into seconds. Returns `0` for bad and/or
|
|
169
169
|
* negative input values.
|
|
170
170
|
*
|
|
171
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
171
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#tosec-ttl-helper
|
|
172
172
|
*/
|
|
173
173
|
export declare const toSec: (ttl: TTL) => number;
|
|
174
174
|
type ServerResponseStub = Pick<ServerResponse, 'setHeader' | 'getHeader' | 'removeHeader'> & {
|
|
@@ -181,7 +181,7 @@ type ResponseStub = {
|
|
|
181
181
|
* Use this function to quickly set the `Cache-Control` header with a `max-age=`
|
|
182
182
|
* on a HTTP response
|
|
183
183
|
*
|
|
184
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
184
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cachecontrol-helper
|
|
185
185
|
*/
|
|
186
186
|
export declare const cacheControl: (response: ServerResponseStub | ResponseStub | Map<string, string> | {
|
|
187
187
|
res: ServerResponseStub | ResponseStub;
|
|
@@ -191,7 +191,7 @@ export declare const cacheControl: (response: ServerResponseStub | ResponseStub
|
|
|
191
191
|
* situations requiring a `HeadersInit` compatible object.
|
|
192
192
|
*
|
|
193
193
|
* Accepts the same arguments as `cacheControl()`.
|
|
194
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
194
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cachecontrolheaders-helper
|
|
195
195
|
*/
|
|
196
196
|
export declare const cacheControlHeaders: (ttlCfg: TTLConfig, eTag?: string | number) => Record<string, string>;
|
|
197
197
|
export {};
|
package/esm/http.js
CHANGED
|
@@ -136,7 +136,7 @@ const unitToMilliseconds = {
|
|
|
136
136
|
* Converts a `TTL` (duration) value into milliseconds. Returns `0` for bad
|
|
137
137
|
* and/or negative input values.
|
|
138
138
|
*
|
|
139
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
139
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#toms-duration-helper
|
|
140
140
|
*/
|
|
141
141
|
/*#__NO_SIDE_EFFECTS__*/
|
|
142
142
|
export const toMs = (ttl) => {
|
|
@@ -154,7 +154,7 @@ export const toMs = (ttl) => {
|
|
|
154
154
|
* Converts a `TTL` (max-age) value into seconds. Returns `0` for bad and/or
|
|
155
155
|
* negative input values.
|
|
156
156
|
*
|
|
157
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
157
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#tosec-ttl-helper
|
|
158
158
|
*/
|
|
159
159
|
/*#__NO_SIDE_EFFECTS__*/
|
|
160
160
|
export const toSec = (ttl) => {
|
|
@@ -207,7 +207,7 @@ const setCC = (response, cc) => {
|
|
|
207
207
|
* Use this function to quickly set the `Cache-Control` header with a `max-age=`
|
|
208
208
|
* on a HTTP response
|
|
209
209
|
*
|
|
210
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
210
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cachecontrol-helper
|
|
211
211
|
*/
|
|
212
212
|
/*#__NO_SIDE_EFFECTS__*/ // eslint-disable-next-line complexity
|
|
213
213
|
export const cacheControl = (response, ttlCfg, eTag) => {
|
|
@@ -250,7 +250,7 @@ export const cacheControl = (response, ttlCfg, eTag) => {
|
|
|
250
250
|
* situations requiring a `HeadersInit` compatible object.
|
|
251
251
|
*
|
|
252
252
|
* Accepts the same arguments as `cacheControl()`.
|
|
253
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
253
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cachecontrolheaders-helper
|
|
254
254
|
*/
|
|
255
255
|
/*#__NO_SIDE_EFFECTS__*/
|
|
256
256
|
export const cacheControlHeaders = (ttlCfg, eTag) => {
|
package/esm/next/http.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type InferErrorPageProps<SEP extends ShowErrorPageFn<any>> = Cleanup<Retu
|
|
|
25
25
|
* cases when `getServerSideProps` returns an `__error` prop with `statusCode`
|
|
26
26
|
* and optional friendly `message`.
|
|
27
27
|
*
|
|
28
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
28
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#makeerrorizeapphoc
|
|
29
29
|
*/
|
|
30
30
|
export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorPage: FunctionComponent<EP>) => {
|
|
31
31
|
<P extends {
|
|
@@ -47,7 +47,7 @@ export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorP
|
|
|
47
47
|
* to return an `HTTP_304_NotModified` response with an empty props object,
|
|
48
48
|
* in a way that doesn't make TypeScript shout at you.
|
|
49
49
|
*
|
|
50
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
50
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#notmodified304-helper
|
|
51
51
|
*/
|
|
52
52
|
export declare const notModified304: (response: ServerResponse | NextContextLike) => {
|
|
53
53
|
readonly props: any;
|
package/esm/next/http.js
CHANGED
|
@@ -9,7 +9,7 @@ export * from '../http.js';
|
|
|
9
9
|
* Use this method inside a `getServerSideProps` method (or API route)
|
|
10
10
|
* to return an error page with proper HTTP status code and all the shit.
|
|
11
11
|
*
|
|
12
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
12
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#showerrorpage-helper
|
|
13
13
|
*/
|
|
14
14
|
/*#__NO_SIDE_EFFECTS__*/
|
|
15
15
|
const showErrorPage = (response, error, ttl = '2s') => {
|
|
@@ -34,7 +34,7 @@ const showErrorPage = (response, error, ttl = '2s') => {
|
|
|
34
34
|
* cases when `getServerSideProps` returns an `__error` prop with `statusCode`
|
|
35
35
|
* and optional friendly `message`.
|
|
36
36
|
*
|
|
37
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
37
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#makeerrorizeapphoc
|
|
38
38
|
*/
|
|
39
39
|
/*#__NO_SIDE_EFFECTS__*/
|
|
40
40
|
export const makeErrorizeAppHOC = (ErrorPage) => {
|
|
@@ -64,7 +64,7 @@ export const makeErrorizeAppHOC = (ErrorPage) => {
|
|
|
64
64
|
* to return an `HTTP_304_NotModified` response with an empty props object,
|
|
65
65
|
* in a way that doesn't make TypeScript shout at you.
|
|
66
66
|
*
|
|
67
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
67
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#notmodified304-helper
|
|
68
68
|
*/
|
|
69
69
|
/*#__NO_SIDE_EFFECTS__*/
|
|
70
70
|
export const notModified304 = (response) => {
|
|
@@ -31,7 +31,7 @@ export type WaitProps<T> = WaitPropsBase<T> & WaitFallbacks;
|
|
|
31
31
|
* custom properties for `meanwhile` and `error` fallbacks, and/or other
|
|
32
32
|
* behaviors.
|
|
33
33
|
*
|
|
34
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
34
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#type-waitcomponent
|
|
35
35
|
*/
|
|
36
36
|
export type WaitComponent<CustomProps extends Record<string, unknown> = Record<never, never>> = (<T>(props: WaitPropsBase<T> & CustomProps) => ReactElement) & {
|
|
37
37
|
displayName?: string;
|
|
@@ -43,7 +43,7 @@ export type WaitComponent<CustomProps extends Record<string, unknown> = Record<n
|
|
|
43
43
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
|
44
44
|
* `$error` property, the `$error` will be thrown.
|
|
45
45
|
*
|
|
46
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
46
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#wait-component
|
|
47
47
|
*/
|
|
48
48
|
export declare const Wait: WaitComponent<WaitFallbacks>;
|
|
49
49
|
export {};
|
package/esm/react-router/Wait.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Await } from 'react-router';
|
|
|
7
7
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
|
8
8
|
* `$error` property, the `$error` will be thrown.
|
|
9
9
|
*
|
|
10
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
10
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#wait-component
|
|
11
11
|
*/
|
|
12
12
|
export const Wait = (props) => (React.createElement(Suspense, { fallback: props.meanwhile || 'Loading...' },
|
|
13
13
|
React.createElement(Await, { resolve: props.for, errorElement: props.error || 'An error occurred.' }, (value) => {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Detects if the request is a client fetch, or an initial/full-page load.
|
|
3
3
|
* Useful for deciding whether to defer data fetching or not.
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#isclientfetch
|
|
6
6
|
*/
|
|
7
7
|
export declare const isClientFetch: (request: Request) => boolean;
|
package/esm/react-router/http.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Detects if the request is a client fetch, or an initial/full-page load.
|
|
3
3
|
* Useful for deciding whether to defer data fetching or not.
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#isclientfetch
|
|
6
6
|
*/
|
|
7
7
|
/*#__NO_SIDE_EFFECTS__*/
|
|
8
8
|
export const isClientFetch = (request) =>
|
package/esm/vanillaExtract.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import { GlobalStyleRule } from '@vanilla-extract/css';
|
|
|
2
2
|
/**
|
|
3
3
|
* Adds free-form CSS as a globalStyle
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaglobal
|
|
6
6
|
*/
|
|
7
7
|
export declare const vanillaGlobal: (css: string) => void;
|
|
8
8
|
/**
|
|
9
9
|
* Spreads the return value into a style object, to inject free-form CSS
|
|
10
10
|
* properties (or nested blocks)
|
|
11
11
|
*
|
|
12
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
12
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaprops
|
|
13
13
|
*/
|
|
14
14
|
export declare const vanillaProps: (css: string) => GlobalStyleRule;
|
|
15
15
|
type ClassNameCallback = (
|
|
@@ -27,7 +27,7 @@ classNameSelector: string) => string;
|
|
|
27
27
|
*
|
|
28
28
|
* To opt out of the `&&` replacement, use the callback function signature.
|
|
29
29
|
*
|
|
30
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
30
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaclass
|
|
31
31
|
*/
|
|
32
32
|
export declare function vanillaClass(css: string | ClassNameCallback): string;
|
|
33
33
|
export declare function vanillaClass(debugId: string, css: string | ClassNameCallback): string;
|
|
@@ -35,7 +35,7 @@ export declare function vanillaClass(debugId: string, css: string | ClassNameCal
|
|
|
35
35
|
* Returns an object with privately scoped CSS variables props.
|
|
36
36
|
* Pass them around and use them in your CSS.
|
|
37
37
|
*
|
|
38
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
38
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillacvars
|
|
39
39
|
*/
|
|
40
40
|
export declare const vanillaVars: <T extends string>(...varNames: Array<T>) => Record<`var${Capitalize<T>}`, string> & {
|
|
41
41
|
/** Allows initializing all or some of the variables in CSS, without offending VSCode's CSS syntax parser too much. */
|
package/esm/vanillaExtract.js
CHANGED
|
@@ -3,7 +3,7 @@ import { globalStyle, style } from '@vanilla-extract/css';
|
|
|
3
3
|
/**
|
|
4
4
|
* Adds free-form CSS as a globalStyle
|
|
5
5
|
*
|
|
6
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
6
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaglobal
|
|
7
7
|
*/
|
|
8
8
|
export const vanillaGlobal = (css) => globalStyle('x', { x: `} ${css} x{x:` });
|
|
9
9
|
// ---------------------------------------------------------------------------
|
|
@@ -11,7 +11,7 @@ export const vanillaGlobal = (css) => globalStyle('x', { x: `} ${css} x{x:` });
|
|
|
11
11
|
* Spreads the return value into a style object, to inject free-form CSS
|
|
12
12
|
* properties (or nested blocks)
|
|
13
13
|
*
|
|
14
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
14
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaprops
|
|
15
15
|
*/
|
|
16
16
|
export const vanillaProps = (css) => ({ x: `; ${css}` });
|
|
17
17
|
export function vanillaClass(cssOrDebugId, css) {
|
|
@@ -31,7 +31,7 @@ export function vanillaClass(cssOrDebugId, css) {
|
|
|
31
31
|
* Returns an object with privately scoped CSS variables props.
|
|
32
32
|
* Pass them around and use them in your CSS.
|
|
33
33
|
*
|
|
34
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
34
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillacvars
|
|
35
35
|
*/
|
|
36
36
|
export const vanillaVars = (...varNames) => {
|
|
37
37
|
const id = vanillaClass(``);
|
package/hooks.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* **NOTE:** The supplied callback does not need to be memoized. The debouncer
|
|
7
7
|
* will always invoke the last supplied version.
|
|
8
8
|
*
|
|
9
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
9
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usedebounced
|
|
10
10
|
*/
|
|
11
11
|
export declare const useDebounced: <A extends Array<unknown>>(
|
|
12
12
|
/** The function to debounce */
|
|
@@ -23,7 +23,7 @@ immediate?: boolean) => ((...args: A) => void) & {
|
|
|
23
23
|
* **NOTE:** The supplied callback does not need to be memoized. The throttler
|
|
24
24
|
* will always invoke the last supplied version.
|
|
25
25
|
*
|
|
26
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
26
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usethrottled
|
|
27
27
|
*/
|
|
28
28
|
export declare const useThrottled: <A extends Array<unknown>>(
|
|
29
29
|
/** The function to throttle */
|
package/hooks.js
CHANGED
|
@@ -11,7 +11,7 @@ const async_js_1 = require("./async.js");
|
|
|
11
11
|
* **NOTE:** The supplied callback does not need to be memoized. The debouncer
|
|
12
12
|
* will always invoke the last supplied version.
|
|
13
13
|
*
|
|
14
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
14
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usedebounced
|
|
15
15
|
*/
|
|
16
16
|
const useDebounced = (
|
|
17
17
|
/** The function to debounce */
|
|
@@ -33,7 +33,7 @@ exports.useDebounced = useDebounced;
|
|
|
33
33
|
* **NOTE:** The supplied callback does not need to be memoized. The throttler
|
|
34
34
|
* will always invoke the last supplied version.
|
|
35
35
|
*
|
|
36
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
36
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usethrottled
|
|
37
37
|
*/
|
|
38
38
|
const useThrottled = (
|
|
39
39
|
/** The function to throttle */
|
package/http.d.ts
CHANGED
|
@@ -154,21 +154,21 @@ type TTLObj = {
|
|
|
154
154
|
/**
|
|
155
155
|
* Configures quick TTL-related settings for a HTTP request object
|
|
156
156
|
*
|
|
157
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
157
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-ttlconfig
|
|
158
158
|
*/
|
|
159
159
|
export type TTLConfig = TTL | TTLKeywords | TTLObj;
|
|
160
160
|
/**
|
|
161
161
|
* Converts a `TTL` (duration) value into milliseconds. Returns `0` for bad
|
|
162
162
|
* and/or negative input values.
|
|
163
163
|
*
|
|
164
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
164
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#toms-duration-helper
|
|
165
165
|
*/
|
|
166
166
|
export declare const toMs: (ttl: TTL) => number;
|
|
167
167
|
/**
|
|
168
168
|
* Converts a `TTL` (max-age) value into seconds. Returns `0` for bad and/or
|
|
169
169
|
* negative input values.
|
|
170
170
|
*
|
|
171
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
171
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#tosec-ttl-helper
|
|
172
172
|
*/
|
|
173
173
|
export declare const toSec: (ttl: TTL) => number;
|
|
174
174
|
type ServerResponseStub = Pick<ServerResponse, 'setHeader' | 'getHeader' | 'removeHeader'> & {
|
|
@@ -181,7 +181,7 @@ type ResponseStub = {
|
|
|
181
181
|
* Use this function to quickly set the `Cache-Control` header with a `max-age=`
|
|
182
182
|
* on a HTTP response
|
|
183
183
|
*
|
|
184
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
184
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cachecontrol-helper
|
|
185
185
|
*/
|
|
186
186
|
export declare const cacheControl: (response: ServerResponseStub | ResponseStub | Map<string, string> | {
|
|
187
187
|
res: ServerResponseStub | ResponseStub;
|
|
@@ -191,7 +191,7 @@ export declare const cacheControl: (response: ServerResponseStub | ResponseStub
|
|
|
191
191
|
* situations requiring a `HeadersInit` compatible object.
|
|
192
192
|
*
|
|
193
193
|
* Accepts the same arguments as `cacheControl()`.
|
|
194
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
194
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cachecontrolheaders-helper
|
|
195
195
|
*/
|
|
196
196
|
export declare const cacheControlHeaders: (ttlCfg: TTLConfig, eTag?: string | number) => Record<string, string>;
|
|
197
197
|
export {};
|
package/http.js
CHANGED
|
@@ -140,7 +140,7 @@ const unitToMilliseconds = {
|
|
|
140
140
|
* Converts a `TTL` (duration) value into milliseconds. Returns `0` for bad
|
|
141
141
|
* and/or negative input values.
|
|
142
142
|
*
|
|
143
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
143
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#toms-duration-helper
|
|
144
144
|
*/
|
|
145
145
|
/*#__NO_SIDE_EFFECTS__*/
|
|
146
146
|
const toMs = (ttl) => {
|
|
@@ -159,7 +159,7 @@ exports.toMs = toMs;
|
|
|
159
159
|
* Converts a `TTL` (max-age) value into seconds. Returns `0` for bad and/or
|
|
160
160
|
* negative input values.
|
|
161
161
|
*
|
|
162
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
162
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#tosec-ttl-helper
|
|
163
163
|
*/
|
|
164
164
|
/*#__NO_SIDE_EFFECTS__*/
|
|
165
165
|
const toSec = (ttl) => {
|
|
@@ -213,7 +213,7 @@ const setCC = (response, cc) => {
|
|
|
213
213
|
* Use this function to quickly set the `Cache-Control` header with a `max-age=`
|
|
214
214
|
* on a HTTP response
|
|
215
215
|
*
|
|
216
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
216
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cachecontrol-helper
|
|
217
217
|
*/
|
|
218
218
|
/*#__NO_SIDE_EFFECTS__*/ // eslint-disable-next-line complexity
|
|
219
219
|
const cacheControl = (response, ttlCfg, eTag) => {
|
|
@@ -257,7 +257,7 @@ exports.cacheControl = cacheControl;
|
|
|
257
257
|
* situations requiring a `HeadersInit` compatible object.
|
|
258
258
|
*
|
|
259
259
|
* Accepts the same arguments as `cacheControl()`.
|
|
260
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
260
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cachecontrolheaders-helper
|
|
261
261
|
*/
|
|
262
262
|
/*#__NO_SIDE_EFFECTS__*/
|
|
263
263
|
const cacheControlHeaders = (ttlCfg, eTag) => {
|
package/next/http.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type InferErrorPageProps<SEP extends ShowErrorPageFn<any>> = Cleanup<Retu
|
|
|
25
25
|
* cases when `getServerSideProps` returns an `__error` prop with `statusCode`
|
|
26
26
|
* and optional friendly `message`.
|
|
27
27
|
*
|
|
28
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
28
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#makeerrorizeapphoc
|
|
29
29
|
*/
|
|
30
30
|
export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorPage: FunctionComponent<EP>) => {
|
|
31
31
|
<P extends {
|
|
@@ -47,7 +47,7 @@ export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorP
|
|
|
47
47
|
* to return an `HTTP_304_NotModified` response with an empty props object,
|
|
48
48
|
* in a way that doesn't make TypeScript shout at you.
|
|
49
49
|
*
|
|
50
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
50
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#notmodified304-helper
|
|
51
51
|
*/
|
|
52
52
|
export declare const notModified304: (response: ServerResponse | NextContextLike) => {
|
|
53
53
|
readonly props: any;
|
package/next/http.js
CHANGED
|
@@ -29,7 +29,7 @@ __exportStar(require("../http.js"), exports);
|
|
|
29
29
|
* Use this method inside a `getServerSideProps` method (or API route)
|
|
30
30
|
* to return an error page with proper HTTP status code and all the shit.
|
|
31
31
|
*
|
|
32
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
32
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#showerrorpage-helper
|
|
33
33
|
*/
|
|
34
34
|
/*#__NO_SIDE_EFFECTS__*/
|
|
35
35
|
const showErrorPage = (response, error, ttl = '2s') => {
|
|
@@ -54,7 +54,7 @@ const showErrorPage = (response, error, ttl = '2s') => {
|
|
|
54
54
|
* cases when `getServerSideProps` returns an `__error` prop with `statusCode`
|
|
55
55
|
* and optional friendly `message`.
|
|
56
56
|
*
|
|
57
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
57
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#makeerrorizeapphoc
|
|
58
58
|
*/
|
|
59
59
|
/*#__NO_SIDE_EFFECTS__*/
|
|
60
60
|
const makeErrorizeAppHOC = (ErrorPage) => {
|
|
@@ -85,7 +85,7 @@ exports.makeErrorizeAppHOC = makeErrorizeAppHOC;
|
|
|
85
85
|
* to return an `HTTP_304_NotModified` response with an empty props object,
|
|
86
86
|
* in a way that doesn't make TypeScript shout at you.
|
|
87
87
|
*
|
|
88
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
88
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-nextjs.md#notmodified304-helper
|
|
89
89
|
*/
|
|
90
90
|
/*#__NO_SIDE_EFFECTS__*/
|
|
91
91
|
const notModified304 = (response) => {
|
package/package.json
CHANGED
package/react-router/Wait.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type WaitProps<T> = WaitPropsBase<T> & WaitFallbacks;
|
|
|
31
31
|
* custom properties for `meanwhile` and `error` fallbacks, and/or other
|
|
32
32
|
* behaviors.
|
|
33
33
|
*
|
|
34
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
34
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#type-waitcomponent
|
|
35
35
|
*/
|
|
36
36
|
export type WaitComponent<CustomProps extends Record<string, unknown> = Record<never, never>> = (<T>(props: WaitPropsBase<T> & CustomProps) => ReactElement) & {
|
|
37
37
|
displayName?: string;
|
|
@@ -43,7 +43,7 @@ export type WaitComponent<CustomProps extends Record<string, unknown> = Record<n
|
|
|
43
43
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
|
44
44
|
* `$error` property, the `$error` will be thrown.
|
|
45
45
|
*
|
|
46
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
46
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#wait-component
|
|
47
47
|
*/
|
|
48
48
|
export declare const Wait: WaitComponent<WaitFallbacks>;
|
|
49
49
|
export {};
|
package/react-router/Wait.js
CHANGED
|
@@ -43,7 +43,7 @@ const react_router_1 = require("react-router");
|
|
|
43
43
|
* If the awaited promise (`props.for`) resolves to an object with a truthy
|
|
44
44
|
* `$error` property, the `$error` will be thrown.
|
|
45
45
|
*
|
|
46
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
46
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#wait-component
|
|
47
47
|
*/
|
|
48
48
|
const Wait = (props) => (react_1.default.createElement(react_1.Suspense, { fallback: props.meanwhile || 'Loading...' },
|
|
49
49
|
react_1.default.createElement(react_router_1.Await, { resolve: props.for, errorElement: props.error || 'An error occurred.' }, (value) => {
|
package/react-router/http.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Detects if the request is a client fetch, or an initial/full-page load.
|
|
3
3
|
* Useful for deciding whether to defer data fetching or not.
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#isclientfetch
|
|
6
6
|
*/
|
|
7
7
|
export declare const isClientFetch: (request: Request) => boolean;
|
package/react-router/http.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.isClientFetch = void 0;
|
|
|
5
5
|
* Detects if the request is a client fetch, or an initial/full-page load.
|
|
6
6
|
* Useful for deciding whether to defer data fetching or not.
|
|
7
7
|
*
|
|
8
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
8
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README-rr.md#isclientfetch
|
|
9
9
|
*/
|
|
10
10
|
/*#__NO_SIDE_EFFECTS__*/
|
|
11
11
|
const isClientFetch = (request) =>
|
package/vanillaExtract.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import { GlobalStyleRule } from '@vanilla-extract/css';
|
|
|
2
2
|
/**
|
|
3
3
|
* Adds free-form CSS as a globalStyle
|
|
4
4
|
*
|
|
5
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
5
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaglobal
|
|
6
6
|
*/
|
|
7
7
|
export declare const vanillaGlobal: (css: string) => void;
|
|
8
8
|
/**
|
|
9
9
|
* Spreads the return value into a style object, to inject free-form CSS
|
|
10
10
|
* properties (or nested blocks)
|
|
11
11
|
*
|
|
12
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
12
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaprops
|
|
13
13
|
*/
|
|
14
14
|
export declare const vanillaProps: (css: string) => GlobalStyleRule;
|
|
15
15
|
type ClassNameCallback = (
|
|
@@ -27,7 +27,7 @@ classNameSelector: string) => string;
|
|
|
27
27
|
*
|
|
28
28
|
* To opt out of the `&&` replacement, use the callback function signature.
|
|
29
29
|
*
|
|
30
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
30
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaclass
|
|
31
31
|
*/
|
|
32
32
|
export declare function vanillaClass(css: string | ClassNameCallback): string;
|
|
33
33
|
export declare function vanillaClass(debugId: string, css: string | ClassNameCallback): string;
|
|
@@ -35,7 +35,7 @@ export declare function vanillaClass(debugId: string, css: string | ClassNameCal
|
|
|
35
35
|
* Returns an object with privately scoped CSS variables props.
|
|
36
36
|
* Pass them around and use them in your CSS.
|
|
37
37
|
*
|
|
38
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
38
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillacvars
|
|
39
39
|
*/
|
|
40
40
|
export declare const vanillaVars: <T extends string>(...varNames: Array<T>) => Record<`var${Capitalize<T>}`, string> & {
|
|
41
41
|
/** Allows initializing all or some of the variables in CSS, without offending VSCode's CSS syntax parser too much. */
|
package/vanillaExtract.js
CHANGED
|
@@ -7,7 +7,7 @@ const css_1 = require("@vanilla-extract/css");
|
|
|
7
7
|
/**
|
|
8
8
|
* Adds free-form CSS as a globalStyle
|
|
9
9
|
*
|
|
10
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
10
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaglobal
|
|
11
11
|
*/
|
|
12
12
|
const vanillaGlobal = (css) => (0, css_1.globalStyle)('x', { x: `} ${css} x{x:` });
|
|
13
13
|
exports.vanillaGlobal = vanillaGlobal;
|
|
@@ -16,7 +16,7 @@ exports.vanillaGlobal = vanillaGlobal;
|
|
|
16
16
|
* Spreads the return value into a style object, to inject free-form CSS
|
|
17
17
|
* properties (or nested blocks)
|
|
18
18
|
*
|
|
19
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
19
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillaprops
|
|
20
20
|
*/
|
|
21
21
|
const vanillaProps = (css) => ({ x: `; ${css}` });
|
|
22
22
|
exports.vanillaProps = vanillaProps;
|
|
@@ -37,7 +37,7 @@ function vanillaClass(cssOrDebugId, css) {
|
|
|
37
37
|
* Returns an object with privately scoped CSS variables props.
|
|
38
38
|
* Pass them around and use them in your CSS.
|
|
39
39
|
*
|
|
40
|
-
* @see https://github.com/reykjavikcity/webtools/blob/v0.
|
|
40
|
+
* @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#vanillacvars
|
|
41
41
|
*/
|
|
42
42
|
const vanillaVars = (...varNames) => {
|
|
43
43
|
const id = vanillaClass(``);
|