@reykjavik/webtools 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/CookieHubConsent.d.ts +1 -1
- package/CookieHubConsent.js +17 -7
- package/async.d.ts +6 -2
- package/async.js +27 -4
- package/errorhandling.d.ts +2 -2
- package/errorhandling.js +10 -1
- package/esm/CookieHubConsent.d.ts +1 -1
- package/esm/async.d.ts +6 -2
- package/esm/async.js +25 -2
- package/esm/errorhandling.d.ts +2 -2
- package/esm/errorhandling.js +10 -1
- package/esm/fixIcelandicLocale.privates.d.ts +16 -42
- package/esm/fixIcelandicLocale.privates.js +3 -3
- package/esm/http.d.ts +0 -1
- package/esm/http.js +6 -1
- package/esm/next/http.d.ts +2 -3
- package/esm/next/http.js +3 -0
- package/esm/react-router/http.js +1 -0
- package/fixIcelandicLocale.privates.d.ts +16 -42
- package/fixIcelandicLocale.privates.js +3 -3
- package/http.d.ts +0 -1
- package/http.js +6 -1
- package/next/http.d.ts +2 -3
- package/next/http.js +3 -0
- package/package.json +2 -2
- package/react-router/Wait.js +17 -7
- package/react-router/http.js +1 -0
- package/vanillaExtract.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.2.5
|
|
8
|
+
|
|
9
|
+
_2025-05-21_
|
|
10
|
+
|
|
11
|
+
- `@reykjavik/webtools/async`:
|
|
12
|
+
- feat: Support passing `AbortSignal` to `sleep` and `addLag` helpers
|
|
13
|
+
|
|
14
|
+
## 0.2.4
|
|
15
|
+
|
|
16
|
+
_2025-05-09_
|
|
17
|
+
|
|
18
|
+
- perf: Add `#__NO_SIDE_EFFECTS__` compiler notation to selected functions
|
|
19
|
+
|
|
7
20
|
## 0.2.3
|
|
8
21
|
|
|
9
22
|
_2025-03-31_
|
|
@@ -33,7 +46,7 @@ _2024-12-17_
|
|
|
33
46
|
_2024-12-12_
|
|
34
47
|
|
|
35
48
|
- feat: Add `@reykjavik/webtools/react-router/*` (previously `/remix/*`)
|
|
36
|
-
- **BREAKING** feat: Remove all `@reykjavik/webtools/
|
|
49
|
+
- **BREAKING** feat: Remove all `@reykjavik/webtools/remix/*` modules
|
|
37
50
|
- **BREAKING** feat: Bump `pkg.engines.node` version to >=20
|
|
38
51
|
- **BREAKING** feat: Remove `@reykjavik/webtools/next/SiteImprove` (deprecated
|
|
39
52
|
module)
|
package/CookieHubConsent.d.ts
CHANGED
|
@@ -229,5 +229,5 @@ export declare const CookieHubProvider: (props: CookieHubProviderProps) => React
|
|
|
229
229
|
*
|
|
230
230
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#usecookiehubconsent
|
|
231
231
|
*/
|
|
232
|
-
export declare const useCookieHubConsent: () => Partial<CookieHubContextState[
|
|
232
|
+
export declare const useCookieHubConsent: () => Partial<CookieHubContextState["consent"]>;
|
|
233
233
|
export {};
|
package/CookieHubConsent.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.useCookieHubConsent = exports.CookieHubProvider = void 0;
|
|
27
37
|
const react_1 = __importStar(require("react"));
|
package/async.d.ts
CHANGED
|
@@ -4,12 +4,16 @@ type PlainObj = Record<string, unknown>;
|
|
|
4
4
|
* Simple sleep function. Returns a promise that resolves after `length`
|
|
5
5
|
* milliseconds.
|
|
6
6
|
*/
|
|
7
|
-
export declare const sleep: (length: number
|
|
7
|
+
export declare const sleep: (length: number, opts?: {
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}) => Promise<void>;
|
|
8
10
|
/**
|
|
9
11
|
* Returns a function that adds lag/delay to a promise chain,
|
|
10
12
|
* passing the promise payload through.
|
|
11
13
|
*/
|
|
12
|
-
export declare const addLag: (length: number
|
|
14
|
+
export declare const addLag: (length: number, opts?: {
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}) => <T>(res: T) => Promise<T>;
|
|
13
17
|
/**
|
|
14
18
|
* Resolves as soon as all of the passed `promises` have resolved/settled,
|
|
15
19
|
* or after `timeout` milliseconds — whichever comes first.
|
package/async.js
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promiseAllObject = exports.
|
|
3
|
+
exports.promiseAllObject = exports.addLag = exports.sleep = void 0;
|
|
4
|
+
exports.maxWait = maxWait;
|
|
4
5
|
/**
|
|
5
6
|
* Simple sleep function. Returns a promise that resolves after `length`
|
|
6
7
|
* milliseconds.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
10
|
+
const sleep = (length, opts) => new Promise((resolve, reject) => {
|
|
11
|
+
const signal = opts && opts.signal;
|
|
12
|
+
if (!signal) {
|
|
13
|
+
return setTimeout(resolve, length);
|
|
14
|
+
}
|
|
15
|
+
if (signal.aborted) {
|
|
16
|
+
return reject(signal.reason);
|
|
17
|
+
}
|
|
18
|
+
const onAbort = () => {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
20
|
+
clearTimeout(timer);
|
|
21
|
+
signal.removeEventListener('abort', onAbort);
|
|
22
|
+
reject(signal.reason);
|
|
23
|
+
};
|
|
24
|
+
signal.addEventListener('abort', onAbort);
|
|
25
|
+
const timer = setTimeout(() => {
|
|
26
|
+
signal.removeEventListener('abort', onAbort);
|
|
27
|
+
resolve();
|
|
28
|
+
}, length);
|
|
29
|
+
});
|
|
9
30
|
exports.sleep = sleep;
|
|
10
31
|
/**
|
|
11
32
|
* Returns a function that adds lag/delay to a promise chain,
|
|
12
33
|
* passing the promise payload through.
|
|
13
34
|
*/
|
|
14
|
-
|
|
35
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
36
|
+
const addLag = (length, opts) => (res) => (0, exports.sleep)(length, opts).then(() => res);
|
|
15
37
|
exports.addLag = addLag;
|
|
38
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
16
39
|
function maxWait(timeout, promises) {
|
|
17
40
|
if (Array.isArray(promises)) {
|
|
18
41
|
return Promise.race([
|
|
@@ -38,7 +61,6 @@ function maxWait(timeout, promises) {
|
|
|
38
61
|
return Promise.resolve().then(() => ({ ...retObj }));
|
|
39
62
|
});
|
|
40
63
|
}
|
|
41
|
-
exports.maxWait = maxWait;
|
|
42
64
|
// ---------------------------------------------------------------------------
|
|
43
65
|
// Adapted from https://github.com/marcelowa/promise-all-properties
|
|
44
66
|
/**
|
|
@@ -47,6 +69,7 @@ exports.maxWait = maxWait;
|
|
|
47
69
|
*
|
|
48
70
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#promiseallobject
|
|
49
71
|
*/
|
|
72
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
50
73
|
const promiseAllObject = (promisesMap) => Promise.all(Object.values(promisesMap)).then((results) => {
|
|
51
74
|
const keys = Object.keys(promisesMap);
|
|
52
75
|
const resolvedMap = {};
|
package/errorhandling.d.ts
CHANGED
|
@@ -83,14 +83,14 @@ export declare const Result: {
|
|
|
83
83
|
*
|
|
84
84
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulmap
|
|
85
85
|
*/
|
|
86
|
-
map: <
|
|
86
|
+
map: <T, T2, E extends Error>(result: ResultTuple<T, E>, mapFn: (resultValue: T) => T2) => ResultTupleObj<T2, E>;
|
|
87
87
|
/**
|
|
88
88
|
* Unwraps a discriminated [error, result] `Result.Tuple`-like object
|
|
89
89
|
* and throws if there's an error, but returns the result otherwise.
|
|
90
90
|
*
|
|
91
91
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulthrow
|
|
92
92
|
*/
|
|
93
|
-
throw: <
|
|
93
|
+
throw: <T>(result: ResultTuple<T>) => T;
|
|
94
94
|
};
|
|
95
95
|
export declare namespace Result {
|
|
96
96
|
type Tuple<T, E extends Error = Error> = ResultTuple<T, E>;
|
package/errorhandling.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.Result = exports.asError = exports.ErrorFromPayload = void 0;
|
|
|
7
7
|
*
|
|
8
8
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
|
|
9
9
|
*/
|
|
10
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
10
11
|
class ErrorFromPayload extends Error {
|
|
11
12
|
constructor(payload) {
|
|
12
13
|
if (process.env.NODE_ENV !== 'production' && payload instanceof Error) {
|
|
@@ -29,6 +30,7 @@ exports.ErrorFromPayload = ErrorFromPayload;
|
|
|
29
30
|
*
|
|
30
31
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
|
|
31
32
|
*/
|
|
33
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
32
34
|
const asError = (maybeError) => {
|
|
33
35
|
if (maybeError instanceof Error) {
|
|
34
36
|
return maybeError;
|
|
@@ -36,6 +38,7 @@ const asError = (maybeError) => {
|
|
|
36
38
|
return new ErrorFromPayload(maybeError);
|
|
37
39
|
};
|
|
38
40
|
exports.asError = asError;
|
|
41
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
39
42
|
const Success = (result) => {
|
|
40
43
|
const tuple = [undefined, result];
|
|
41
44
|
tuple.result = result;
|
|
@@ -44,12 +47,14 @@ const Success = (result) => {
|
|
|
44
47
|
map(tuple, fn);
|
|
45
48
|
return tuple;
|
|
46
49
|
};
|
|
50
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
47
51
|
const Fail = (e) => {
|
|
48
52
|
const tuple = [(0, exports.asError)(e)];
|
|
49
53
|
tuple.error = tuple[0];
|
|
50
54
|
tuple.mapTo = () => tuple;
|
|
51
55
|
return tuple;
|
|
52
56
|
};
|
|
57
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
53
58
|
function catch_(something) {
|
|
54
59
|
if (something instanceof Promise) {
|
|
55
60
|
return something.then(Success, (e) => Fail(e));
|
|
@@ -61,7 +66,9 @@ function catch_(something) {
|
|
|
61
66
|
return Fail(e);
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
|
-
const map = (result,
|
|
69
|
+
const map = (result,
|
|
70
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
71
|
+
mapFn) => {
|
|
65
72
|
const [error, resultValue] = result;
|
|
66
73
|
if (error) {
|
|
67
74
|
return Fail(error);
|
|
@@ -96,6 +103,7 @@ exports.Result = {
|
|
|
96
103
|
*
|
|
97
104
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulmap
|
|
98
105
|
*/
|
|
106
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
99
107
|
map: (result, mapFn) => {
|
|
100
108
|
const [error, resultValue] = result;
|
|
101
109
|
if (error) {
|
|
@@ -109,6 +117,7 @@ exports.Result = {
|
|
|
109
117
|
*
|
|
110
118
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulthrow
|
|
111
119
|
*/
|
|
120
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
112
121
|
throw: (result) => {
|
|
113
122
|
if (result[0]) {
|
|
114
123
|
throw result[0];
|
|
@@ -229,5 +229,5 @@ export declare const CookieHubProvider: (props: CookieHubProviderProps) => React
|
|
|
229
229
|
*
|
|
230
230
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#usecookiehubconsent
|
|
231
231
|
*/
|
|
232
|
-
export declare const useCookieHubConsent: () => Partial<CookieHubContextState[
|
|
232
|
+
export declare const useCookieHubConsent: () => Partial<CookieHubContextState["consent"]>;
|
|
233
233
|
export {};
|
package/esm/async.d.ts
CHANGED
|
@@ -4,12 +4,16 @@ type PlainObj = Record<string, unknown>;
|
|
|
4
4
|
* Simple sleep function. Returns a promise that resolves after `length`
|
|
5
5
|
* milliseconds.
|
|
6
6
|
*/
|
|
7
|
-
export declare const sleep: (length: number
|
|
7
|
+
export declare const sleep: (length: number, opts?: {
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}) => Promise<void>;
|
|
8
10
|
/**
|
|
9
11
|
* Returns a function that adds lag/delay to a promise chain,
|
|
10
12
|
* passing the promise payload through.
|
|
11
13
|
*/
|
|
12
|
-
export declare const addLag: (length: number
|
|
14
|
+
export declare const addLag: (length: number, opts?: {
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}) => <T>(res: T) => Promise<T>;
|
|
13
17
|
/**
|
|
14
18
|
* Resolves as soon as all of the passed `promises` have resolved/settled,
|
|
15
19
|
* or after `timeout` milliseconds — whichever comes first.
|
package/esm/async.js
CHANGED
|
@@ -2,12 +2,34 @@
|
|
|
2
2
|
* Simple sleep function. Returns a promise that resolves after `length`
|
|
3
3
|
* milliseconds.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
6
|
+
export const sleep = (length, opts) => new Promise((resolve, reject) => {
|
|
7
|
+
const signal = opts && opts.signal;
|
|
8
|
+
if (!signal) {
|
|
9
|
+
return setTimeout(resolve, length);
|
|
10
|
+
}
|
|
11
|
+
if (signal.aborted) {
|
|
12
|
+
return reject(signal.reason);
|
|
13
|
+
}
|
|
14
|
+
const onAbort = () => {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
signal.removeEventListener('abort', onAbort);
|
|
18
|
+
reject(signal.reason);
|
|
19
|
+
};
|
|
20
|
+
signal.addEventListener('abort', onAbort);
|
|
21
|
+
const timer = setTimeout(() => {
|
|
22
|
+
signal.removeEventListener('abort', onAbort);
|
|
23
|
+
resolve();
|
|
24
|
+
}, length);
|
|
25
|
+
});
|
|
6
26
|
/**
|
|
7
27
|
* Returns a function that adds lag/delay to a promise chain,
|
|
8
28
|
* passing the promise payload through.
|
|
9
29
|
*/
|
|
10
|
-
|
|
30
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
31
|
+
export const addLag = (length, opts) => (res) => sleep(length, opts).then(() => res);
|
|
32
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
11
33
|
export function maxWait(timeout, promises) {
|
|
12
34
|
if (Array.isArray(promises)) {
|
|
13
35
|
return Promise.race([
|
|
@@ -41,6 +63,7 @@ export function maxWait(timeout, promises) {
|
|
|
41
63
|
*
|
|
42
64
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#promiseallobject
|
|
43
65
|
*/
|
|
66
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
44
67
|
export const promiseAllObject = (promisesMap) => Promise.all(Object.values(promisesMap)).then((results) => {
|
|
45
68
|
const keys = Object.keys(promisesMap);
|
|
46
69
|
const resolvedMap = {};
|
package/esm/errorhandling.d.ts
CHANGED
|
@@ -83,14 +83,14 @@ export declare const Result: {
|
|
|
83
83
|
*
|
|
84
84
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulmap
|
|
85
85
|
*/
|
|
86
|
-
map: <
|
|
86
|
+
map: <T, T2, E extends Error>(result: ResultTuple<T, E>, mapFn: (resultValue: T) => T2) => ResultTupleObj<T2, E>;
|
|
87
87
|
/**
|
|
88
88
|
* Unwraps a discriminated [error, result] `Result.Tuple`-like object
|
|
89
89
|
* and throws if there's an error, but returns the result otherwise.
|
|
90
90
|
*
|
|
91
91
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulthrow
|
|
92
92
|
*/
|
|
93
|
-
throw: <
|
|
93
|
+
throw: <T>(result: ResultTuple<T>) => T;
|
|
94
94
|
};
|
|
95
95
|
export declare namespace Result {
|
|
96
96
|
type Tuple<T, E extends Error = Error> = ResultTuple<T, E>;
|
package/esm/errorhandling.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
|
|
6
6
|
*/
|
|
7
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
7
8
|
export class ErrorFromPayload extends Error {
|
|
8
9
|
constructor(payload) {
|
|
9
10
|
if (process.env.NODE_ENV !== 'production' && payload instanceof Error) {
|
|
@@ -25,12 +26,14 @@ export class ErrorFromPayload extends Error {
|
|
|
25
26
|
*
|
|
26
27
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
|
|
27
28
|
*/
|
|
29
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
28
30
|
export const asError = (maybeError) => {
|
|
29
31
|
if (maybeError instanceof Error) {
|
|
30
32
|
return maybeError;
|
|
31
33
|
}
|
|
32
34
|
return new ErrorFromPayload(maybeError);
|
|
33
35
|
};
|
|
36
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
34
37
|
const Success = (result) => {
|
|
35
38
|
const tuple = [undefined, result];
|
|
36
39
|
tuple.result = result;
|
|
@@ -39,12 +42,14 @@ const Success = (result) => {
|
|
|
39
42
|
map(tuple, fn);
|
|
40
43
|
return tuple;
|
|
41
44
|
};
|
|
45
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
42
46
|
const Fail = (e) => {
|
|
43
47
|
const tuple = [asError(e)];
|
|
44
48
|
tuple.error = tuple[0];
|
|
45
49
|
tuple.mapTo = () => tuple;
|
|
46
50
|
return tuple;
|
|
47
51
|
};
|
|
52
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
48
53
|
function catch_(something) {
|
|
49
54
|
if (something instanceof Promise) {
|
|
50
55
|
return something.then(Success, (e) => Fail(e));
|
|
@@ -56,7 +61,9 @@ function catch_(something) {
|
|
|
56
61
|
return Fail(e);
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
|
-
const map = (result,
|
|
64
|
+
const map = (result,
|
|
65
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
66
|
+
mapFn) => {
|
|
60
67
|
const [error, resultValue] = result;
|
|
61
68
|
if (error) {
|
|
62
69
|
return Fail(error);
|
|
@@ -91,6 +98,7 @@ export const Result = {
|
|
|
91
98
|
*
|
|
92
99
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulmap
|
|
93
100
|
*/
|
|
101
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
94
102
|
map: (result, mapFn) => {
|
|
95
103
|
const [error, resultValue] = result;
|
|
96
104
|
if (error) {
|
|
@@ -104,6 +112,7 @@ export const Result = {
|
|
|
104
112
|
*
|
|
105
113
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulthrow
|
|
106
114
|
*/
|
|
115
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
107
116
|
throw: (result) => {
|
|
108
117
|
if (result[0]) {
|
|
109
118
|
throw result[0];
|
|
@@ -1,83 +1,57 @@
|
|
|
1
|
-
export declare const _PatchedCollator: {
|
|
2
|
-
(locales?: string | string[] | undefined, options?: Intl.CollatorOptions | undefined): Intl.Collator;
|
|
3
|
-
new (locales?: string | string[] | undefined, options?: Intl.CollatorOptions | undefined): Intl.Collator;
|
|
4
|
-
supportedLocalesOf(locales: string | string[], options?: Intl.CollatorOptions | undefined): string[];
|
|
5
|
-
} & {
|
|
1
|
+
export declare const _PatchedCollator: typeof Intl.Collator & {
|
|
6
2
|
$original: typeof Intl.Collator;
|
|
7
3
|
};
|
|
8
4
|
export declare const _patchedStringLocaleCompare: {
|
|
9
5
|
(this: string, that: string, locales?: string | Array<string>, options?: Intl.CollatorOptions): number;
|
|
10
6
|
$original: {
|
|
11
7
|
(that: string): number;
|
|
12
|
-
(that: string, locales?: string | string[]
|
|
8
|
+
(that: string, locales?: string | string[], options?: Intl.CollatorOptions): number;
|
|
9
|
+
(that: string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): number;
|
|
13
10
|
};
|
|
14
11
|
};
|
|
15
|
-
export declare const _PatchedNumberFormat: {
|
|
16
|
-
(locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat;
|
|
17
|
-
new (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat;
|
|
18
|
-
supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions | undefined): string[];
|
|
19
|
-
readonly prototype: Intl.NumberFormat;
|
|
20
|
-
} & {
|
|
12
|
+
export declare const _PatchedNumberFormat: typeof Intl.NumberFormat & {
|
|
21
13
|
$original: typeof Intl.NumberFormat;
|
|
22
14
|
};
|
|
23
15
|
export declare const _patchedNumberToLocaleString: {
|
|
24
16
|
(this: number, locales?: string | Array<string>, options?: Intl.NumberFormatOptions): string;
|
|
25
17
|
$original: {
|
|
26
|
-
(locales?: string | string[]
|
|
27
|
-
(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions
|
|
18
|
+
(locales?: string | string[], options?: Intl.NumberFormatOptions): string;
|
|
19
|
+
(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string;
|
|
28
20
|
};
|
|
29
21
|
};
|
|
30
|
-
export declare const _PatchedDateTimeFormat: {
|
|
31
|
-
(locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): Intl.DateTimeFormat;
|
|
32
|
-
new (locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): Intl.DateTimeFormat;
|
|
33
|
-
supportedLocalesOf(locales: string | string[], options?: Intl.DateTimeFormatOptions | undefined): string[];
|
|
34
|
-
readonly prototype: Intl.DateTimeFormat;
|
|
35
|
-
} & {
|
|
22
|
+
export declare const _PatchedDateTimeFormat: typeof Intl.DateTimeFormat & {
|
|
36
23
|
$original: typeof Intl.DateTimeFormat;
|
|
37
24
|
};
|
|
38
25
|
export declare const _patchedDateToLocaleString: {
|
|
39
26
|
(this: Date, locales?: string | Array<string>, options?: Intl.DateTimeFormatOptions): string;
|
|
40
27
|
$original: {
|
|
41
28
|
(): string;
|
|
42
|
-
(locales?: string | string[]
|
|
43
|
-
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions
|
|
29
|
+
(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
|
30
|
+
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
|
|
44
31
|
};
|
|
45
32
|
};
|
|
46
33
|
export declare const _patchedDateToLocaleDateString: {
|
|
47
34
|
(this: Date, locales?: string | Array<string>, options?: Intl.DateTimeFormatOptions): string;
|
|
48
35
|
$original: {
|
|
49
36
|
(): string;
|
|
50
|
-
(locales?: string | string[]
|
|
51
|
-
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions
|
|
37
|
+
(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
|
38
|
+
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
|
|
52
39
|
};
|
|
53
40
|
};
|
|
54
41
|
export declare const _patchedDateToLocaleTimeString: {
|
|
55
42
|
(this: Date, locales?: string | Array<string>, options?: Intl.DateTimeFormatOptions): string;
|
|
56
43
|
$original: {
|
|
57
44
|
(): string;
|
|
58
|
-
(locales?: string | string[]
|
|
59
|
-
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions
|
|
45
|
+
(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
|
46
|
+
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
|
|
60
47
|
};
|
|
61
48
|
};
|
|
62
|
-
export declare const _PatchedPluralRules: {
|
|
63
|
-
(locales?: string | string[] | undefined, options?: Intl.PluralRulesOptions | undefined): Intl.PluralRules;
|
|
64
|
-
new (locales?: string | string[] | undefined, options?: Intl.PluralRulesOptions | undefined): Intl.PluralRules;
|
|
65
|
-
supportedLocalesOf(locales: string | string[], options?: {
|
|
66
|
-
localeMatcher?: "best fit" | "lookup" | undefined;
|
|
67
|
-
} | undefined): string[];
|
|
68
|
-
} & {
|
|
49
|
+
export declare const _PatchedPluralRules: typeof Intl.PluralRules & {
|
|
69
50
|
$original: typeof Intl.PluralRules;
|
|
70
51
|
};
|
|
71
|
-
export declare const _PatchedListFormat: {
|
|
72
|
-
new (locales?: string | string[] | undefined, options?: Intl.ListFormatOptions | undefined): Intl.ListFormat;
|
|
73
|
-
prototype: Intl.ListFormat;
|
|
74
|
-
supportedLocalesOf(locales: string | string[], options?: Pick<Intl.ListFormatOptions, "localeMatcher"> | undefined): string[];
|
|
75
|
-
} & {
|
|
52
|
+
export declare const _PatchedListFormat: typeof Intl.ListFormat & {
|
|
76
53
|
$original: typeof Intl.ListFormat;
|
|
77
54
|
};
|
|
78
|
-
export declare const _PatchedRelativeTimeFormat: {
|
|
79
|
-
new (locales?: string | string[] | undefined, options?: Intl.RelativeTimeFormatOptions | undefined): Intl.RelativeTimeFormat;
|
|
80
|
-
supportedLocalesOf(locales?: string | string[] | undefined, options?: Intl.RelativeTimeFormatOptions | undefined): string[];
|
|
81
|
-
} & {
|
|
55
|
+
export declare const _PatchedRelativeTimeFormat: typeof Intl.RelativeTimeFormat & {
|
|
82
56
|
$original: typeof Intl.RelativeTimeFormat;
|
|
83
57
|
};
|
|
@@ -210,9 +210,9 @@ const partMappers = {
|
|
|
210
210
|
const reformatDateTimeParts = function (parent, parts) {
|
|
211
211
|
const options = parent.resolvedOptions();
|
|
212
212
|
parts.forEach((part, idx) => {
|
|
213
|
-
var
|
|
213
|
+
var _d;
|
|
214
214
|
const mapper = partMappers[part.type];
|
|
215
|
-
const newValue = mapper && mapper(part.value, (
|
|
215
|
+
const newValue = mapper && mapper(part.value, (_d = parts[idx - 1]) === null || _d === void 0 ? void 0 : _d.type, options);
|
|
216
216
|
if (newValue != null) {
|
|
217
217
|
part.value = newValue;
|
|
218
218
|
}
|
|
@@ -436,7 +436,7 @@ if (_RelativeTimeFormat) {
|
|
|
436
436
|
'i går': 'í gær',
|
|
437
437
|
'i dag': 'í dag',
|
|
438
438
|
'i morgen': 'á morgun',
|
|
439
|
-
'i overmorgen': 'eftir tvo daga',
|
|
439
|
+
'i overmorgen': 'eftir tvo daga', // 'á hinn daginn',
|
|
440
440
|
'denne time': 'þessa stundina',
|
|
441
441
|
'dette minut': 'á þessari mínútu',
|
|
442
442
|
};
|
package/esm/http.d.ts
CHANGED
package/esm/http.js
CHANGED
|
@@ -138,6 +138,7 @@ const unitToSeconds = {
|
|
|
138
138
|
*
|
|
139
139
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#tosec-ttl-helper
|
|
140
140
|
*/
|
|
141
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
141
142
|
export const toSec = (ttl) => {
|
|
142
143
|
if (typeof ttl === 'string') {
|
|
143
144
|
const value = parseFloat(ttl);
|
|
@@ -152,7 +153,9 @@ export const toSec = (ttl) => {
|
|
|
152
153
|
*
|
|
153
154
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#toms-duration-helper
|
|
154
155
|
*/
|
|
156
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
155
157
|
export const toMs = (ttl) => toSec(ttl) * 1000;
|
|
158
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
156
159
|
const toRespnseStubHeaders = (response) => {
|
|
157
160
|
if (response instanceof Map) {
|
|
158
161
|
return response;
|
|
@@ -177,6 +180,7 @@ const stabilities = {
|
|
|
177
180
|
immutable: ', immutable',
|
|
178
181
|
normal: '',
|
|
179
182
|
};
|
|
183
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
180
184
|
const setCC = (response, cc) => {
|
|
181
185
|
const devModeHeader = 'X-Cache-Control';
|
|
182
186
|
const headers = toRespnseStubHeaders(response);
|
|
@@ -197,7 +201,7 @@ const setCC = (response, cc) => {
|
|
|
197
201
|
*
|
|
198
202
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrol-helper
|
|
199
203
|
*/
|
|
200
|
-
// eslint-disable-next-line complexity
|
|
204
|
+
/*#__NO_SIDE_EFFECTS__*/ // eslint-disable-next-line complexity
|
|
201
205
|
export const cacheControl = (response, ttlCfg, eTag) => {
|
|
202
206
|
response = 'res' in response ? response.res : response;
|
|
203
207
|
const opts = typeof ttlCfg === 'number' || typeof ttlCfg === 'string'
|
|
@@ -240,6 +244,7 @@ export const cacheControl = (response, ttlCfg, eTag) => {
|
|
|
240
244
|
* Accepts the same arguments as `cacheControl()`.
|
|
241
245
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrolheaders-helper
|
|
242
246
|
*/
|
|
247
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
243
248
|
export const cacheControlHeaders = (ttlCfg, eTag) => {
|
|
244
249
|
const headers = new Map();
|
|
245
250
|
cacheControl(headers, ttlCfg, eTag);
|
package/esm/next/http.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import React, { FunctionComponent } from 'react';
|
|
3
2
|
import type { Cleanup } from '@reykjavik/hanna-utils';
|
|
4
3
|
import type { AppType } from 'next/app.js';
|
|
@@ -28,10 +27,10 @@ export type InferErrorPageProps<SEP extends ShowErrorPageFn<any>> = Cleanup<Retu
|
|
|
28
27
|
*
|
|
29
28
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#makeerrorizeapphoc
|
|
30
29
|
*/
|
|
31
|
-
export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorPage:
|
|
30
|
+
export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorPage: FunctionComponent<EP>) => {
|
|
32
31
|
<P extends {
|
|
33
32
|
[key: string]: unknown;
|
|
34
|
-
__error?:
|
|
33
|
+
__error?: never;
|
|
35
34
|
}>(App: AppType<P>): React.FunctionComponent<import("next/dist/shared/lib/utils.js").AppPropsType<any, P | ({
|
|
36
35
|
__error: ErrorProps;
|
|
37
36
|
} & Omit<ErrorProps & EP, keyof ErrorProps>)>> & {
|
package/esm/next/http.js
CHANGED
|
@@ -11,6 +11,7 @@ export * from '../http.js';
|
|
|
11
11
|
*
|
|
12
12
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#showerrorpage-helper
|
|
13
13
|
*/
|
|
14
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
14
15
|
const showErrorPage = (response, error, ttl = '2s') => {
|
|
15
16
|
error =
|
|
16
17
|
typeof error === 'number'
|
|
@@ -35,6 +36,7 @@ const showErrorPage = (response, error, ttl = '2s') => {
|
|
|
35
36
|
*
|
|
36
37
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#makeerrorizeapphoc
|
|
37
38
|
*/
|
|
39
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
38
40
|
export const makeErrorizeAppHOC = (ErrorPage) => {
|
|
39
41
|
// the HOC
|
|
40
42
|
const withErrorHandling = (App) => {
|
|
@@ -64,6 +66,7 @@ export const makeErrorizeAppHOC = (ErrorPage) => {
|
|
|
64
66
|
*
|
|
65
67
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#notmodified304-helper
|
|
66
68
|
*/
|
|
69
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
67
70
|
export const notModified304 = (response) => {
|
|
68
71
|
response = 'res' in response ? response.res : response;
|
|
69
72
|
response.statusCode = HTTP_304_NotModified;
|
package/esm/react-router/http.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#isclientfetch
|
|
6
6
|
*/
|
|
7
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
7
8
|
export const isClientFetch = (request) =>
|
|
8
9
|
// For info about this detection method:
|
|
9
10
|
// - https://github.com/remix-run/remix/discussions/5583
|
|
@@ -1,83 +1,57 @@
|
|
|
1
|
-
export declare const _PatchedCollator: {
|
|
2
|
-
(locales?: string | string[] | undefined, options?: Intl.CollatorOptions | undefined): Intl.Collator;
|
|
3
|
-
new (locales?: string | string[] | undefined, options?: Intl.CollatorOptions | undefined): Intl.Collator;
|
|
4
|
-
supportedLocalesOf(locales: string | string[], options?: Intl.CollatorOptions | undefined): string[];
|
|
5
|
-
} & {
|
|
1
|
+
export declare const _PatchedCollator: typeof Intl.Collator & {
|
|
6
2
|
$original: typeof Intl.Collator;
|
|
7
3
|
};
|
|
8
4
|
export declare const _patchedStringLocaleCompare: {
|
|
9
5
|
(this: string, that: string, locales?: string | Array<string>, options?: Intl.CollatorOptions): number;
|
|
10
6
|
$original: {
|
|
11
7
|
(that: string): number;
|
|
12
|
-
(that: string, locales?: string | string[]
|
|
8
|
+
(that: string, locales?: string | string[], options?: Intl.CollatorOptions): number;
|
|
9
|
+
(that: string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): number;
|
|
13
10
|
};
|
|
14
11
|
};
|
|
15
|
-
export declare const _PatchedNumberFormat: {
|
|
16
|
-
(locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat;
|
|
17
|
-
new (locales?: string | string[] | undefined, options?: Intl.NumberFormatOptions | undefined): Intl.NumberFormat;
|
|
18
|
-
supportedLocalesOf(locales: string | string[], options?: Intl.NumberFormatOptions | undefined): string[];
|
|
19
|
-
readonly prototype: Intl.NumberFormat;
|
|
20
|
-
} & {
|
|
12
|
+
export declare const _PatchedNumberFormat: typeof Intl.NumberFormat & {
|
|
21
13
|
$original: typeof Intl.NumberFormat;
|
|
22
14
|
};
|
|
23
15
|
export declare const _patchedNumberToLocaleString: {
|
|
24
16
|
(this: number, locales?: string | Array<string>, options?: Intl.NumberFormatOptions): string;
|
|
25
17
|
$original: {
|
|
26
|
-
(locales?: string | string[]
|
|
27
|
-
(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions
|
|
18
|
+
(locales?: string | string[], options?: Intl.NumberFormatOptions): string;
|
|
19
|
+
(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string;
|
|
28
20
|
};
|
|
29
21
|
};
|
|
30
|
-
export declare const _PatchedDateTimeFormat: {
|
|
31
|
-
(locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): Intl.DateTimeFormat;
|
|
32
|
-
new (locales?: string | string[] | undefined, options?: Intl.DateTimeFormatOptions | undefined): Intl.DateTimeFormat;
|
|
33
|
-
supportedLocalesOf(locales: string | string[], options?: Intl.DateTimeFormatOptions | undefined): string[];
|
|
34
|
-
readonly prototype: Intl.DateTimeFormat;
|
|
35
|
-
} & {
|
|
22
|
+
export declare const _PatchedDateTimeFormat: typeof Intl.DateTimeFormat & {
|
|
36
23
|
$original: typeof Intl.DateTimeFormat;
|
|
37
24
|
};
|
|
38
25
|
export declare const _patchedDateToLocaleString: {
|
|
39
26
|
(this: Date, locales?: string | Array<string>, options?: Intl.DateTimeFormatOptions): string;
|
|
40
27
|
$original: {
|
|
41
28
|
(): string;
|
|
42
|
-
(locales?: string | string[]
|
|
43
|
-
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions
|
|
29
|
+
(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
|
30
|
+
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
|
|
44
31
|
};
|
|
45
32
|
};
|
|
46
33
|
export declare const _patchedDateToLocaleDateString: {
|
|
47
34
|
(this: Date, locales?: string | Array<string>, options?: Intl.DateTimeFormatOptions): string;
|
|
48
35
|
$original: {
|
|
49
36
|
(): string;
|
|
50
|
-
(locales?: string | string[]
|
|
51
|
-
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions
|
|
37
|
+
(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
|
38
|
+
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
|
|
52
39
|
};
|
|
53
40
|
};
|
|
54
41
|
export declare const _patchedDateToLocaleTimeString: {
|
|
55
42
|
(this: Date, locales?: string | Array<string>, options?: Intl.DateTimeFormatOptions): string;
|
|
56
43
|
$original: {
|
|
57
44
|
(): string;
|
|
58
|
-
(locales?: string | string[]
|
|
59
|
-
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions
|
|
45
|
+
(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
|
46
|
+
(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
|
|
60
47
|
};
|
|
61
48
|
};
|
|
62
|
-
export declare const _PatchedPluralRules: {
|
|
63
|
-
(locales?: string | string[] | undefined, options?: Intl.PluralRulesOptions | undefined): Intl.PluralRules;
|
|
64
|
-
new (locales?: string | string[] | undefined, options?: Intl.PluralRulesOptions | undefined): Intl.PluralRules;
|
|
65
|
-
supportedLocalesOf(locales: string | string[], options?: {
|
|
66
|
-
localeMatcher?: "best fit" | "lookup" | undefined;
|
|
67
|
-
} | undefined): string[];
|
|
68
|
-
} & {
|
|
49
|
+
export declare const _PatchedPluralRules: typeof Intl.PluralRules & {
|
|
69
50
|
$original: typeof Intl.PluralRules;
|
|
70
51
|
};
|
|
71
|
-
export declare const _PatchedListFormat: {
|
|
72
|
-
new (locales?: string | string[] | undefined, options?: Intl.ListFormatOptions | undefined): Intl.ListFormat;
|
|
73
|
-
prototype: Intl.ListFormat;
|
|
74
|
-
supportedLocalesOf(locales: string | string[], options?: Pick<Intl.ListFormatOptions, "localeMatcher"> | undefined): string[];
|
|
75
|
-
} & {
|
|
52
|
+
export declare const _PatchedListFormat: typeof Intl.ListFormat & {
|
|
76
53
|
$original: typeof Intl.ListFormat;
|
|
77
54
|
};
|
|
78
|
-
export declare const _PatchedRelativeTimeFormat: {
|
|
79
|
-
new (locales?: string | string[] | undefined, options?: Intl.RelativeTimeFormatOptions | undefined): Intl.RelativeTimeFormat;
|
|
80
|
-
supportedLocalesOf(locales?: string | string[] | undefined, options?: Intl.RelativeTimeFormatOptions | undefined): string[];
|
|
81
|
-
} & {
|
|
55
|
+
export declare const _PatchedRelativeTimeFormat: typeof Intl.RelativeTimeFormat & {
|
|
82
56
|
$original: typeof Intl.RelativeTimeFormat;
|
|
83
57
|
};
|
|
@@ -215,9 +215,9 @@ const partMappers = {
|
|
|
215
215
|
const reformatDateTimeParts = function (parent, parts) {
|
|
216
216
|
const options = parent.resolvedOptions();
|
|
217
217
|
parts.forEach((part, idx) => {
|
|
218
|
-
var
|
|
218
|
+
var _d;
|
|
219
219
|
const mapper = partMappers[part.type];
|
|
220
|
-
const newValue = mapper && mapper(part.value, (
|
|
220
|
+
const newValue = mapper && mapper(part.value, (_d = parts[idx - 1]) === null || _d === void 0 ? void 0 : _d.type, options);
|
|
221
221
|
if (newValue != null) {
|
|
222
222
|
part.value = newValue;
|
|
223
223
|
}
|
|
@@ -444,7 +444,7 @@ if (_RelativeTimeFormat) {
|
|
|
444
444
|
'i går': 'í gær',
|
|
445
445
|
'i dag': 'í dag',
|
|
446
446
|
'i morgen': 'á morgun',
|
|
447
|
-
'i overmorgen': 'eftir tvo daga',
|
|
447
|
+
'i overmorgen': 'eftir tvo daga', // 'á hinn daginn',
|
|
448
448
|
'denne time': 'þessa stundina',
|
|
449
449
|
'dette minut': 'á þessari mínútu',
|
|
450
450
|
};
|
package/http.d.ts
CHANGED
package/http.js
CHANGED
|
@@ -142,6 +142,7 @@ const unitToSeconds = {
|
|
|
142
142
|
*
|
|
143
143
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#tosec-ttl-helper
|
|
144
144
|
*/
|
|
145
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
145
146
|
const toSec = (ttl) => {
|
|
146
147
|
if (typeof ttl === 'string') {
|
|
147
148
|
const value = parseFloat(ttl);
|
|
@@ -157,8 +158,10 @@ exports.toSec = toSec;
|
|
|
157
158
|
*
|
|
158
159
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#toms-duration-helper
|
|
159
160
|
*/
|
|
161
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
160
162
|
const toMs = (ttl) => (0, exports.toSec)(ttl) * 1000;
|
|
161
163
|
exports.toMs = toMs;
|
|
164
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
162
165
|
const toRespnseStubHeaders = (response) => {
|
|
163
166
|
if (response instanceof Map) {
|
|
164
167
|
return response;
|
|
@@ -183,6 +186,7 @@ const stabilities = {
|
|
|
183
186
|
immutable: ', immutable',
|
|
184
187
|
normal: '',
|
|
185
188
|
};
|
|
189
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
186
190
|
const setCC = (response, cc) => {
|
|
187
191
|
const devModeHeader = 'X-Cache-Control';
|
|
188
192
|
const headers = toRespnseStubHeaders(response);
|
|
@@ -203,7 +207,7 @@ const setCC = (response, cc) => {
|
|
|
203
207
|
*
|
|
204
208
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrol-helper
|
|
205
209
|
*/
|
|
206
|
-
// eslint-disable-next-line complexity
|
|
210
|
+
/*#__NO_SIDE_EFFECTS__*/ // eslint-disable-next-line complexity
|
|
207
211
|
const cacheControl = (response, ttlCfg, eTag) => {
|
|
208
212
|
response = 'res' in response ? response.res : response;
|
|
209
213
|
const opts = typeof ttlCfg === 'number' || typeof ttlCfg === 'string'
|
|
@@ -247,6 +251,7 @@ exports.cacheControl = cacheControl;
|
|
|
247
251
|
* Accepts the same arguments as `cacheControl()`.
|
|
248
252
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cachecontrolheaders-helper
|
|
249
253
|
*/
|
|
254
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
250
255
|
const cacheControlHeaders = (ttlCfg, eTag) => {
|
|
251
256
|
const headers = new Map();
|
|
252
257
|
(0, exports.cacheControl)(headers, ttlCfg, eTag);
|
package/next/http.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import React, { FunctionComponent } from 'react';
|
|
3
2
|
import type { Cleanup } from '@reykjavik/hanna-utils';
|
|
4
3
|
import type { AppType } from 'next/app.js';
|
|
@@ -28,10 +27,10 @@ export type InferErrorPageProps<SEP extends ShowErrorPageFn<any>> = Cleanup<Retu
|
|
|
28
27
|
*
|
|
29
28
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#makeerrorizeapphoc
|
|
30
29
|
*/
|
|
31
|
-
export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorPage:
|
|
30
|
+
export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorPage: FunctionComponent<EP>) => {
|
|
32
31
|
<P extends {
|
|
33
32
|
[key: string]: unknown;
|
|
34
|
-
__error?:
|
|
33
|
+
__error?: never;
|
|
35
34
|
}>(App: AppType<P>): React.FunctionComponent<import("next/dist/shared/lib/utils.js").AppPropsType<any, P | ({
|
|
36
35
|
__error: ErrorProps;
|
|
37
36
|
} & Omit<ErrorProps & EP, keyof ErrorProps>)>> & {
|
package/next/http.js
CHANGED
|
@@ -31,6 +31,7 @@ __exportStar(require("../http.js"), exports);
|
|
|
31
31
|
*
|
|
32
32
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#showerrorpage-helper
|
|
33
33
|
*/
|
|
34
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
34
35
|
const showErrorPage = (response, error, ttl = '2s') => {
|
|
35
36
|
error =
|
|
36
37
|
typeof error === 'number'
|
|
@@ -55,6 +56,7 @@ const showErrorPage = (response, error, ttl = '2s') => {
|
|
|
55
56
|
*
|
|
56
57
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#makeerrorizeapphoc
|
|
57
58
|
*/
|
|
59
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
58
60
|
const makeErrorizeAppHOC = (ErrorPage) => {
|
|
59
61
|
// the HOC
|
|
60
62
|
const withErrorHandling = (App) => {
|
|
@@ -85,6 +87,7 @@ exports.makeErrorizeAppHOC = makeErrorizeAppHOC;
|
|
|
85
87
|
*
|
|
86
88
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-nextjs.md#notmodified304-helper
|
|
87
89
|
*/
|
|
90
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
88
91
|
const notModified304 = (response) => {
|
|
89
92
|
response = 'res' in response ? response.res : response;
|
|
90
93
|
response.statusCode = http_js_1.HTTP_304_NotModified;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reykjavik/webtools",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Misc. JS/TS helpers used by Reykjavík City's web dev teams.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "ssh://git@github.com:reykjavikcity/webtools.git",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@reykjavik/hanna-utils": "^0.2.
|
|
14
|
+
"@reykjavik/hanna-utils": "^0.2.20"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@vanilla-extract/css": "^1.14.1",
|
package/react-router/Wait.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.Wait = void 0;
|
|
27
37
|
const react_1 = __importStar(require("react"));
|
package/react-router/http.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.isClientFetch = void 0;
|
|
|
7
7
|
*
|
|
8
8
|
* @see https://github.com/reykjavikcity/webtools/blob/v0.2/README-rr.md#isclientfetch
|
|
9
9
|
*/
|
|
10
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
10
11
|
const isClientFetch = (request) =>
|
|
11
12
|
// For info about this detection method:
|
|
12
13
|
// - https://github.com/remix-run/remix/discussions/5583
|
package/vanillaExtract.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.vanillaProps = exports.vanillaGlobal = void 0;
|
|
4
|
+
exports.vanillaClass = vanillaClass;
|
|
4
5
|
const css_1 = require("@vanilla-extract/css");
|
|
5
6
|
/**
|
|
6
7
|
* Adds free-form CSS as a globalStyle
|
|
@@ -30,4 +31,3 @@ function vanillaClass(cssOrDebugId, css) {
|
|
|
30
31
|
: css.replace(/&&/g, `.${className}`));
|
|
31
32
|
return className;
|
|
32
33
|
}
|
|
33
|
-
exports.vanillaClass = vanillaClass;
|