@reykjavik/webtools 0.3.0 → 0.3.2
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 +9 -1
- package/CookieHubConsent.d.ts +2 -2
- package/CookieHubConsent.js +2 -2
- package/README.md +24 -0
- 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 +17 -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 +17 -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/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(``);
|