@reykjavik/webtools 0.1.1 → 0.1.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 +1 -1
- package/esm/next/SiteImprove.js +1 -1
- package/esm/next/http.d.ts +4 -4
- package/esm/next/http.js +2 -2
- package/next/SiteImprove.js +2 -2
- package/next/http.d.ts +4 -4
- package/next/http.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/esm/next/SiteImprove.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { Router } from 'next/router';
|
|
3
3
|
import Script from 'next/script';
|
|
4
|
-
import { useCookieHubConsent } from '../CookieHubConsent';
|
|
4
|
+
import { useCookieHubConsent } from '../CookieHubConsent.js';
|
|
5
5
|
// END: Mock typing of SiteImprove's event tracking API
|
|
6
6
|
// --------------------------------------------------------------------------
|
|
7
7
|
//
|
package/esm/next/http.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import React, { FunctionComponent } from 'react';
|
|
|
3
3
|
import { Cleanup } from '@reykjavik/hanna-utils';
|
|
4
4
|
import { ServerResponse } from 'http';
|
|
5
5
|
import type { AppType } from 'next/app';
|
|
6
|
-
import type { HTTP_418_ImATeapot, HTTP_ERROR, TTLConfig } from '../http';
|
|
6
|
+
import type { HTTP_418_ImATeapot, HTTP_ERROR, TTLConfig } from '../http.js';
|
|
7
7
|
type HTTP_ERROR_all = HTTP_ERROR | typeof HTTP_418_ImATeapot;
|
|
8
|
-
export * from '../http';
|
|
8
|
+
export * from '../http.js';
|
|
9
9
|
type NextContextLike = {
|
|
10
10
|
res: ServerResponse;
|
|
11
11
|
};
|
|
@@ -33,10 +33,10 @@ export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorP
|
|
|
33
33
|
<P extends {
|
|
34
34
|
[key: string]: unknown;
|
|
35
35
|
__error?: undefined;
|
|
36
|
-
}>(App: AppType<P>): React.FunctionComponent<import("next/dist/shared/lib/utils").AppPropsType<any, P | ({
|
|
36
|
+
}>(App: AppType<P>): React.FunctionComponent<import("next/dist/shared/lib/utils.js").AppPropsType<any, P | ({
|
|
37
37
|
__error: ErrorProps;
|
|
38
38
|
} & Omit<ErrorProps & EP, keyof ErrorProps>)>> & {
|
|
39
|
-
getInitialProps?(context: import("next/dist/shared/lib/utils").AppContextType<import("next/router").NextRouter>): P | ({
|
|
39
|
+
getInitialProps?(context: import("next/dist/shared/lib/utils.js").AppContextType<import("next/router.js").NextRouter>): P | ({
|
|
40
40
|
__error: ErrorProps;
|
|
41
41
|
} & Omit<ErrorProps & EP, keyof ErrorProps>) | Promise<P | ({
|
|
42
42
|
__error: ErrorProps;
|
package/esm/next/http.js
CHANGED
|
@@ -10,12 +10,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { cacheControl, HTTP_304_NotModified } from '../http';
|
|
13
|
+
import { cacheControl, HTTP_304_NotModified } from '../http.js';
|
|
14
14
|
/*
|
|
15
15
|
Re-export all of the base [http module](#reykjavikwebtoolshttp)'s exports,
|
|
16
16
|
purely for convenience.
|
|
17
17
|
*/
|
|
18
|
-
export * from '../http';
|
|
18
|
+
export * from '../http.js';
|
|
19
19
|
/**
|
|
20
20
|
* Use this method inside a `getServerSideProps` method (or API route)
|
|
21
21
|
* to return an error page with proper HTTP status code and all the shit.
|
package/next/SiteImprove.js
CHANGED
|
@@ -30,7 +30,7 @@ exports.pingSiteImprove = exports.SiteImprove = void 0;
|
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
31
|
const router_1 = require("next/router");
|
|
32
32
|
const script_1 = __importDefault(require("next/script"));
|
|
33
|
-
const
|
|
33
|
+
const CookieHubConsent_js_1 = require("../CookieHubConsent.js");
|
|
34
34
|
// END: Mock typing of SiteImprove's event tracking API
|
|
35
35
|
// --------------------------------------------------------------------------
|
|
36
36
|
//
|
|
@@ -83,7 +83,7 @@ const scriptUrlTemplate = `https://siteimproveanalytics.com/js/siteanalyze_${idT
|
|
|
83
83
|
* @see https://github.com/reykjavikcity/webtools/tree/v0.1##siteimprove-component
|
|
84
84
|
*/
|
|
85
85
|
const SiteImprove = (props) => {
|
|
86
|
-
const { analytics } = (0,
|
|
86
|
+
const { analytics } = (0, CookieHubConsent_js_1.useCookieHubConsent)();
|
|
87
87
|
const consented = (analytics && props.hasConstented !== false) ||
|
|
88
88
|
(analytics === undefined && props.hasConstented);
|
|
89
89
|
(0, react_1.useEffect)(() => {
|
package/next/http.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import React, { FunctionComponent } from 'react';
|
|
|
3
3
|
import { Cleanup } from '@reykjavik/hanna-utils';
|
|
4
4
|
import { ServerResponse } from 'http';
|
|
5
5
|
import type { AppType } from 'next/app';
|
|
6
|
-
import type { HTTP_418_ImATeapot, HTTP_ERROR, TTLConfig } from '../http';
|
|
6
|
+
import type { HTTP_418_ImATeapot, HTTP_ERROR, TTLConfig } from '../http.js';
|
|
7
7
|
type HTTP_ERROR_all = HTTP_ERROR | typeof HTTP_418_ImATeapot;
|
|
8
|
-
export * from '../http';
|
|
8
|
+
export * from '../http.js';
|
|
9
9
|
type NextContextLike = {
|
|
10
10
|
res: ServerResponse;
|
|
11
11
|
};
|
|
@@ -33,10 +33,10 @@ export declare const makeErrorizeAppHOC: <EP extends Partial<ErrorProps>>(ErrorP
|
|
|
33
33
|
<P extends {
|
|
34
34
|
[key: string]: unknown;
|
|
35
35
|
__error?: undefined;
|
|
36
|
-
}>(App: AppType<P>): React.FunctionComponent<import("next/dist/shared/lib/utils").AppPropsType<any, P | ({
|
|
36
|
+
}>(App: AppType<P>): React.FunctionComponent<import("next/dist/shared/lib/utils.js").AppPropsType<any, P | ({
|
|
37
37
|
__error: ErrorProps;
|
|
38
38
|
} & Omit<ErrorProps & EP, keyof ErrorProps>)>> & {
|
|
39
|
-
getInitialProps?(context: import("next/dist/shared/lib/utils").AppContextType<import("next/router").NextRouter>): P | ({
|
|
39
|
+
getInitialProps?(context: import("next/dist/shared/lib/utils.js").AppContextType<import("next/router.js").NextRouter>): P | ({
|
|
40
40
|
__error: ErrorProps;
|
|
41
41
|
} & Omit<ErrorProps & EP, keyof ErrorProps>) | Promise<P | ({
|
|
42
42
|
__error: ErrorProps;
|
package/next/http.js
CHANGED
|
@@ -30,12 +30,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
31
|
exports.notModified304 = exports.makeErrorizeAppHOC = void 0;
|
|
32
32
|
const react_1 = __importDefault(require("react"));
|
|
33
|
-
const
|
|
33
|
+
const http_js_1 = require("../http.js");
|
|
34
34
|
/*
|
|
35
35
|
Re-export all of the base [http module](#reykjavikwebtoolshttp)'s exports,
|
|
36
36
|
purely for convenience.
|
|
37
37
|
*/
|
|
38
|
-
__exportStar(require("../http"), exports);
|
|
38
|
+
__exportStar(require("../http.js"), exports);
|
|
39
39
|
/**
|
|
40
40
|
* Use this method inside a `getServerSideProps` method (or API route)
|
|
41
41
|
* to return an error page with proper HTTP status code and all the shit.
|
|
@@ -50,7 +50,7 @@ const showErrorPage = (response, error, ttl = '2s') => {
|
|
|
50
50
|
const { statusCode, message } = error, otherProps = __rest(error, ["statusCode", "message"]);
|
|
51
51
|
response = 'res' in response ? response.res : response;
|
|
52
52
|
response.statusCode = error.statusCode;
|
|
53
|
-
(0,
|
|
53
|
+
(0, http_js_1.cacheControl)(response, ttl);
|
|
54
54
|
return {
|
|
55
55
|
props: Object.assign(Object.assign({}, otherProps), { __error: { statusCode, message } }),
|
|
56
56
|
};
|
|
@@ -92,7 +92,7 @@ exports.makeErrorizeAppHOC = makeErrorizeAppHOC;
|
|
|
92
92
|
*/
|
|
93
93
|
const notModified304 = (response) => {
|
|
94
94
|
response = 'res' in response ? response.res : response;
|
|
95
|
-
response.statusCode =
|
|
95
|
+
response.statusCode = http_js_1.HTTP_304_NotModified;
|
|
96
96
|
return {
|
|
97
97
|
props:
|
|
98
98
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/package.json
CHANGED