@automattic/jetpack-critical-css-gen 0.1.0 → 1.0.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 +19 -1
- package/build/browser-interface-iframe.d.ts +31 -0
- package/build/browser-interface-iframe.js +130 -0
- package/build/browser-interface-iframe.js.map +1 -0
- package/build/browser.d.ts +5 -0
- package/build/browser.js +6 -0
- package/build/browser.js.map +1 -0
- package/{build-node/node.js → build/playwright.js} +1 -1
- package/build/playwright.js.map +1 -0
- package/package.json +18 -21
- package/build-browser/bundle.full.js +0 -37567
- package/build-browser/bundle.full.js.map +0 -1
- package/build-browser/bundle.js +0 -4
- package/build-browser/bundle.js.map +0 -1
- package/build-node/node.js.map +0 -1
- /package/{build-node → build}/browser-interface-playwright.d.ts +0 -0
- /package/{build-node → build}/browser-interface-playwright.js +0 -0
- /package/{build-node → build}/browser-interface-playwright.js.map +0 -0
- /package/{build-node → build}/browser-interface.d.ts +0 -0
- /package/{build-node → build}/browser-interface.js +0 -0
- /package/{build-node → build}/browser-interface.js.map +0 -0
- /package/{build-node → build}/css-file-set.d.ts +0 -0
- /package/{build-node → build}/css-file-set.js +0 -0
- /package/{build-node → build}/css-file-set.js.map +0 -0
- /package/{build-node → build}/errors.d.ts +0 -0
- /package/{build-node → build}/errors.js +0 -0
- /package/{build-node → build}/errors.js.map +0 -0
- /package/{build-node → build}/generate-critical-css.d.ts +0 -0
- /package/{build-node → build}/generate-critical-css.js +0 -0
- /package/{build-node → build}/generate-critical-css.js.map +0 -0
- /package/{build-node → build}/ignored-pseudo-elements.d.ts +0 -0
- /package/{build-node → build}/ignored-pseudo-elements.js +0 -0
- /package/{build-node → build}/ignored-pseudo-elements.js.map +0 -0
- /package/{build-node → build}/minify-css.d.ts +0 -0
- /package/{build-node → build}/minify-css.js +0 -0
- /package/{build-node → build}/minify-css.js.map +0 -0
- /package/{build-node → build}/object-promise-all.d.ts +0 -0
- /package/{build-node → build}/object-promise-all.js +0 -0
- /package/{build-node → build}/object-promise-all.js.map +0 -0
- /package/{build-node/node.d.ts → build/playwright.d.ts} +0 -0
- /package/{build-node → build}/style-ast.d.ts +0 -0
- /package/{build-node → build}/style-ast.js +0 -0
- /package/{build-node → build}/style-ast.js.map +0 -0
- /package/{build-node → build}/types.d.ts +0 -0
- /package/{build-node → build}/types.js +0 -0
- /package/{build-node → build}/types.js.map +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,8 +5,26 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## 0.1
|
|
8
|
+
## [1.0.1] - 2024-10-10
|
|
9
|
+
### Changed
|
|
10
|
+
- Updated package dependencies. [#39670]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Add missing build folder to package. [#39723]
|
|
14
|
+
|
|
15
|
+
## [1.0.0] - 2024-10-07
|
|
16
|
+
### Security
|
|
17
|
+
- Security: Fix XSS vulnerability. [#39507]
|
|
9
18
|
|
|
10
19
|
### Added
|
|
20
|
+
- Add /playwright entry point for BrowserInterfacePlaywright. [#39509]
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Change default entry point of package to include BrowserInterfaceIframe instead of BrowserInterfacePlaywright. [#39509]
|
|
11
24
|
|
|
25
|
+
## 0.1.0 - 2024-09-24
|
|
26
|
+
### Added
|
|
12
27
|
- Initial version. [#38429]
|
|
28
|
+
|
|
29
|
+
[1.0.1]: https://github.com/Automattic/jetpack-critical-css-gen/compare/v1.0.0...v1.0.1
|
|
30
|
+
[1.0.0]: https://github.com/Automattic/jetpack-critical-css-gen/compare/v0.1.0...v1.0.0
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BrowserInterface, BrowserRunnable } from './browser-interface.js';
|
|
2
|
+
import { UrlError } from './errors.js';
|
|
3
|
+
import { Viewport } from './types.js';
|
|
4
|
+
type VerifyMethod = (rawUrl: string, contentWindow: Window, contentDocument: Document) => boolean;
|
|
5
|
+
type BrowserInterfaceIframeOptions = {
|
|
6
|
+
requestGetParameters?: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
loadTimeout?: number;
|
|
10
|
+
verifyPage: VerifyMethod;
|
|
11
|
+
allowScripts?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare class BrowserInterfaceIframe extends BrowserInterface {
|
|
14
|
+
private requestGetParameters;
|
|
15
|
+
private loadTimeout;
|
|
16
|
+
private verifyPage;
|
|
17
|
+
private currentUrl;
|
|
18
|
+
private currentSize;
|
|
19
|
+
private wrapperDiv;
|
|
20
|
+
private iframe;
|
|
21
|
+
constructor({ requestGetParameters, loadTimeout, verifyPage, allowScripts, }: BrowserInterfaceIframeOptions);
|
|
22
|
+
cleanup(): Promise<void>;
|
|
23
|
+
fetch(url: string, options: RequestInit, _role: 'css' | 'html'): Promise<Response>;
|
|
24
|
+
runInPage<ReturnType>(pageUrl: string, viewport: Viewport | null, method: BrowserRunnable<ReturnType>, ...args: unknown[]): Promise<ReturnType>;
|
|
25
|
+
addGetParameters(rawUrl: string): string;
|
|
26
|
+
diagnoseUrlError(url: string): Promise<UrlError | null>;
|
|
27
|
+
sameOrigin(url: string): boolean;
|
|
28
|
+
loadPage(rawUrl: string): Promise<void>;
|
|
29
|
+
resize({ width, height }: Viewport): Promise<unknown>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { BrowserInterface } from './browser-interface.js';
|
|
2
|
+
import { CrossDomainError, HttpError, LoadTimeoutError, RedirectError, UrlVerifyError, UnknownError, XFrameDenyError, } from './errors.js';
|
|
3
|
+
const defaultLoadTimeout = 60 * 1000;
|
|
4
|
+
export class BrowserInterfaceIframe extends BrowserInterface {
|
|
5
|
+
constructor({ requestGetParameters, loadTimeout, verifyPage, allowScripts, }) {
|
|
6
|
+
super();
|
|
7
|
+
this.requestGetParameters = requestGetParameters || {};
|
|
8
|
+
this.loadTimeout = loadTimeout || defaultLoadTimeout;
|
|
9
|
+
this.verifyPage = verifyPage;
|
|
10
|
+
// Default 'allowScripts' to true if not specified.
|
|
11
|
+
allowScripts = allowScripts !== false;
|
|
12
|
+
this.currentUrl = null;
|
|
13
|
+
this.currentSize = { width: null, height: null };
|
|
14
|
+
// Create a wrapper div to keep the iframe invisible.
|
|
15
|
+
this.wrapperDiv = document.createElement('div');
|
|
16
|
+
this.wrapperDiv.setAttribute('style', 'position:fixed; z-index: -1000; opacity: 0; top: 50px;');
|
|
17
|
+
document.body.append(this.wrapperDiv);
|
|
18
|
+
// Create iframe itself.
|
|
19
|
+
this.iframe = document.createElement('iframe');
|
|
20
|
+
this.iframe.setAttribute('style', 'max-width: none; max-height: none; border: 0px;');
|
|
21
|
+
this.iframe.setAttribute('aria-hidden', 'true');
|
|
22
|
+
this.iframe.setAttribute('sandbox', 'allow-same-origin ' + (allowScripts ? 'allow-scripts' : ''));
|
|
23
|
+
this.wrapperDiv.append(this.iframe);
|
|
24
|
+
}
|
|
25
|
+
async cleanup() {
|
|
26
|
+
this.iframe.remove();
|
|
27
|
+
this.wrapperDiv.remove();
|
|
28
|
+
}
|
|
29
|
+
async fetch(url, options, _role) {
|
|
30
|
+
return window.fetch(url, options);
|
|
31
|
+
}
|
|
32
|
+
async runInPage(pageUrl, viewport, method, ...args) {
|
|
33
|
+
await this.loadPage(pageUrl);
|
|
34
|
+
if (viewport) {
|
|
35
|
+
await this.resize(viewport);
|
|
36
|
+
}
|
|
37
|
+
// The inner window in the iframe is separate from the main window object.
|
|
38
|
+
// Pass the iframe window object to the evaluating method.
|
|
39
|
+
return method({ innerWindow: this.iframe.contentWindow, args });
|
|
40
|
+
}
|
|
41
|
+
addGetParameters(rawUrl) {
|
|
42
|
+
const urlObject = new URL(rawUrl);
|
|
43
|
+
for (const key of Object.keys(this.requestGetParameters)) {
|
|
44
|
+
urlObject.searchParams.append(key, this.requestGetParameters[key]);
|
|
45
|
+
}
|
|
46
|
+
return urlObject.toString();
|
|
47
|
+
}
|
|
48
|
+
async diagnoseUrlError(url) {
|
|
49
|
+
try {
|
|
50
|
+
const response = await this.fetch(url, { redirect: 'manual' }, 'html');
|
|
51
|
+
const headers = response.headers;
|
|
52
|
+
if (headers.get('x-frame-options') === 'DENY') {
|
|
53
|
+
return new XFrameDenyError({ url });
|
|
54
|
+
}
|
|
55
|
+
if (response.type === 'opaqueredirect') {
|
|
56
|
+
return new RedirectError({
|
|
57
|
+
url,
|
|
58
|
+
redirectUrl: response.url,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (response.status === 200) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return new HttpError({ url, code: response.status });
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
return new UnknownError({ url, message: err.message });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
sameOrigin(url) {
|
|
71
|
+
return new URL(url).origin === window.location.origin;
|
|
72
|
+
}
|
|
73
|
+
async loadPage(rawUrl) {
|
|
74
|
+
if (rawUrl === this.currentUrl) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const fullUrl = this.addGetParameters(rawUrl);
|
|
78
|
+
return new Promise((resolve, rawReject) => {
|
|
79
|
+
// Track all URL errors.
|
|
80
|
+
const reject = err => {
|
|
81
|
+
this.trackUrlError(rawUrl, err);
|
|
82
|
+
rawReject(err);
|
|
83
|
+
};
|
|
84
|
+
// Catch cross-domain errors before they occur.
|
|
85
|
+
if (!this.sameOrigin(fullUrl)) {
|
|
86
|
+
reject(new CrossDomainError({ url: fullUrl }));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// Set a timeout.
|
|
90
|
+
const timeoutId = setTimeout(() => {
|
|
91
|
+
this.iframe.onload = null;
|
|
92
|
+
reject(new LoadTimeoutError({ url: fullUrl }));
|
|
93
|
+
}, this.loadTimeout);
|
|
94
|
+
// Catch load event.
|
|
95
|
+
this.iframe.onload = async () => {
|
|
96
|
+
try {
|
|
97
|
+
this.iframe.onload = null;
|
|
98
|
+
clearTimeout(timeoutId);
|
|
99
|
+
// Verify the inner document is readable.
|
|
100
|
+
if (!this.iframe.contentDocument || !this.iframe.contentWindow) {
|
|
101
|
+
throw ((await this.diagnoseUrlError(fullUrl)) || new CrossDomainError({ url: fullUrl }));
|
|
102
|
+
}
|
|
103
|
+
if (!this.verifyPage(rawUrl, this.iframe.contentWindow, this.iframe.contentDocument)) {
|
|
104
|
+
// Diagnose and throw an appropriate error.
|
|
105
|
+
throw ((await this.diagnoseUrlError(fullUrl)) || new UrlVerifyError({ url: fullUrl }));
|
|
106
|
+
}
|
|
107
|
+
this.currentUrl = rawUrl;
|
|
108
|
+
resolve();
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
reject(err);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
this.iframe.src = fullUrl;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async resize({ width, height }) {
|
|
118
|
+
if (this.currentSize.width === width && this.currentSize.height === height) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
return new Promise(resolve => {
|
|
122
|
+
// Set iframe size.
|
|
123
|
+
this.iframe.width = width.toString();
|
|
124
|
+
this.iframe.height = height.toString();
|
|
125
|
+
// Bounce to browser main loop to allow resize to complete.
|
|
126
|
+
setTimeout(resolve, 1);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=browser-interface-iframe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-interface-iframe.js","sourceRoot":"","sources":["../src/browser-interface-iframe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,wBAAwB,CAAC;AAC3E,OAAO,E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C;oBACzB,OAAO,EAAE,CAAC;iBACV;gBAAC,OAAQ,GAAG,EAAG;oBACf,MAAM,CAAE,GAAG,CAAE,CAAC;iBACd;YACF,CAAC,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC;QAC3B,CAAC,CAAE,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,EAAE,KAAK,EAAE,MAAM,EAAY;QACxC,IAAK,IAAI,CAAC,WAAW,CAAC,KAAK,KAAK,KAAK,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,MAAM,EAAG;YAC7E,OAAO;SACP;QAED,OAAO,IAAI,OAAO,CAAE,OAAO,CAAC,EAAE;YAC7B,mBAAmB;YACnB,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;YACrC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;YAEvC,2DAA2D;YAC3D,UAAU,CAAE,OAAO,EAAE,CAAC,CAAE,CAAC;QAC1B,CAAC,CAAE,CAAC;IACL,CAAC;CACD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BrowserInterfaceIframe } from './browser-interface-iframe.js';
|
|
2
|
+
export { BrowserInterface } from './browser-interface.js';
|
|
3
|
+
export { generateCriticalCSS } from './generate-critical-css.js';
|
|
4
|
+
export * from './errors.js';
|
|
5
|
+
export declare const version = "0.0.11";
|
package/build/browser.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { BrowserInterfaceIframe } from './browser-interface-iframe.js';
|
|
2
|
+
export { BrowserInterface } from './browser-interface.js';
|
|
3
|
+
export { generateCriticalCSS } from './generate-critical-css.js';
|
|
4
|
+
export * from './errors.js';
|
|
5
|
+
export const version = '0.0.11';
|
|
6
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,cAAc,aAAa,CAAC;AAE5B,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright.js","sourceRoot":"","sources":["../src/playwright.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,cAAc,aAAa,CAAC;AAE5B,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@automattic/jetpack-critical-css-gen",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"description": "A flexible Critical CSS Generator that supports multiple URLs and viewports, with both server-side and client-side generation capabilities.",
|
|
6
6
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/critical-css-gen/#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -15,47 +15,44 @@
|
|
|
15
15
|
"license": "GPL-2.0-or-later",
|
|
16
16
|
"author": "Automattic",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build
|
|
19
|
-
"build:
|
|
20
|
-
"
|
|
21
|
-
"clean": "rm -rf
|
|
22
|
-
"test": "pnpm build && NODE_ENV=test NODE_PATH=./node_modules jest --forceExit --config=tests/config/jest.config.js"
|
|
18
|
+
"build": "pnpm run clean && tsc",
|
|
19
|
+
"build:test": "pnpm run clean:test && webpack --config tests/data/webpack.config.cjs",
|
|
20
|
+
"clean": "rm -rf build/",
|
|
21
|
+
"clean:test": "rm -rf tests/build/",
|
|
22
|
+
"test": "pnpm build && pnpm build:test && NODE_ENV=test NODE_PATH=./node_modules jest --forceExit --config=tests/config/jest.config.js"
|
|
23
23
|
},
|
|
24
|
-
"main": "./build
|
|
25
|
-
"browser": "./build-browser/bundle.js",
|
|
24
|
+
"main": "./build/browser.js",
|
|
26
25
|
"devDependencies": {
|
|
26
|
+
"@automattic/jetpack-webpack-config": "workspace:*",
|
|
27
27
|
"@babel/core": "7.24.7",
|
|
28
28
|
"@babel/preset-env": "7.24.7",
|
|
29
29
|
"@babel/preset-typescript": "7.24.7",
|
|
30
|
-
"@rollup/plugin-commonjs": "26.0.1",
|
|
31
|
-
"@rollup/plugin-json": "4.1.0",
|
|
32
|
-
"@rollup/plugin-node-resolve": "13.3.0",
|
|
33
|
-
"@rollup/plugin-terser": "0.4.3",
|
|
34
|
-
"@rollup/plugin-typescript": "8.3.3",
|
|
35
30
|
"@types/clean-css": "4.2.11",
|
|
36
31
|
"@types/css-tree": "2.3.8",
|
|
37
32
|
"@types/node": "^20.4.2",
|
|
38
|
-
"express": "4.
|
|
33
|
+
"express": "4.21.0",
|
|
39
34
|
"jest": "29.7.0",
|
|
35
|
+
"path-browserify": "1.0.1",
|
|
40
36
|
"playwright": "1.45.1",
|
|
41
37
|
"playwright-core": "^1.45.1",
|
|
42
38
|
"prettier": "npm:wp-prettier@3.0.3",
|
|
43
|
-
"
|
|
44
|
-
"rollup-plugin-polyfill-node": "0.13.0",
|
|
39
|
+
"process": "0.11.10",
|
|
45
40
|
"source-map": "0.7.4",
|
|
46
41
|
"source-map-js": "1.2.0",
|
|
47
42
|
"tslib": "2.5.0",
|
|
48
43
|
"typescript": "5.0.4",
|
|
49
44
|
"webpack": "5.94.0",
|
|
45
|
+
"webpack-cli": "4.9.1",
|
|
50
46
|
"webpack-dev-middleware": "5.3.4"
|
|
51
47
|
},
|
|
52
48
|
"exports": {
|
|
53
49
|
".": {
|
|
54
|
-
"types": "./build
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
50
|
+
"types": "./build/browser.d.ts",
|
|
51
|
+
"default": "./build/browser.js"
|
|
52
|
+
},
|
|
53
|
+
"./playwright": {
|
|
54
|
+
"types": "./build/playwright.d.ts",
|
|
55
|
+
"default": "./build/playwright.js"
|
|
59
56
|
}
|
|
60
57
|
},
|
|
61
58
|
"dependencies": {
|