happy-dom 14.1.1 → 14.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.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/cjs/window/GlobalWindow.cjs +39 -2
- package/cjs/window/GlobalWindow.cjs.map +1 -1
- package/cjs/window/GlobalWindow.d.ts +25 -0
- package/cjs/window/GlobalWindow.d.ts.map +1 -1
- package/lib/window/GlobalWindow.d.ts +25 -0
- package/lib/window/GlobalWindow.d.ts.map +1 -1
- package/lib/window/GlobalWindow.js +39 -2
- package/lib/window/GlobalWindow.js.map +1 -1
- package/package.json +3 -3
- package/src/window/GlobalWindow.ts +57 -0
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
const PropertySymbol = __importStar(require("../PropertySymbol.cjs"));
|
30
|
+
const BrowserWindow_js_1 = __importDefault(require("./BrowserWindow.cjs"));
|
30
31
|
const Window_js_1 = __importDefault(require("./Window.cjs"));
|
31
32
|
const buffer_1 = require("buffer");
|
32
33
|
/**
|
@@ -36,8 +37,20 @@ const buffer_1 = require("buffer");
|
|
36
37
|
* https://developer.mozilla.org/en-US/docs/Web/API/Window.
|
37
38
|
*/
|
38
39
|
class GlobalWindow extends Window_js_1.default {
|
39
|
-
|
40
|
-
|
40
|
+
/**
|
41
|
+
* Constructor.
|
42
|
+
*
|
43
|
+
* @param [options] Options.
|
44
|
+
* @param [options.width] Window width. Defaults to "1024".
|
45
|
+
* @param [options.height] Window height. Defaults to "768".
|
46
|
+
* @param [options.innerWidth] Inner width. Deprecated. Defaults to "1024".
|
47
|
+
* @param [options.innerHeight] Inner height. Deprecated. Defaults to "768".
|
48
|
+
* @param [options.url] URL.
|
49
|
+
* @param [options.console] Console.
|
50
|
+
* @param [options.settings] Settings.
|
51
|
+
*/
|
52
|
+
constructor(options) {
|
53
|
+
super(options);
|
41
54
|
// Node.js Globals
|
42
55
|
this.Array = globalThis.Array;
|
43
56
|
this.ArrayBuffer = globalThis.ArrayBuffer;
|
@@ -98,6 +111,30 @@ class GlobalWindow extends Window_js_1.default {
|
|
98
111
|
this.unescape = globalThis.unescape;
|
99
112
|
this.gc = globalThis.gc;
|
100
113
|
this.v8debug = globalThis.v8debug;
|
114
|
+
/**
|
115
|
+
* Binds getts and setters, so that they will appear as an "own" property when using Object.getOwnPropertyNames().
|
116
|
+
*
|
117
|
+
* This is needed for Vitest to work as it relies on Object.getOwnPropertyNames() to get the list of properties.
|
118
|
+
*
|
119
|
+
* @see https://github.com/capricorn86/happy-dom/issues/1339
|
120
|
+
*/
|
121
|
+
for (const windowClass of [GlobalWindow, Window_js_1.default, BrowserWindow_js_1.default]) {
|
122
|
+
const propertyDescriptors = Object.getOwnPropertyDescriptors(Reflect.getPrototypeOf(windowClass.prototype));
|
123
|
+
for (const key of Object.keys(propertyDescriptors)) {
|
124
|
+
const windowPropertyDescriptor = propertyDescriptors[key];
|
125
|
+
if (windowPropertyDescriptor.get || windowPropertyDescriptor.set) {
|
126
|
+
const ownPropertyDescriptor = Object.getOwnPropertyDescriptor(this, key);
|
127
|
+
if (!ownPropertyDescriptor) {
|
128
|
+
Object.defineProperty(this, key, {
|
129
|
+
configurable: true,
|
130
|
+
enumerable: windowPropertyDescriptor.enumerable,
|
131
|
+
get: windowPropertyDescriptor.get?.bind(this),
|
132
|
+
set: windowPropertyDescriptor.set?.bind(this)
|
133
|
+
});
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
101
138
|
}
|
102
139
|
/**
|
103
140
|
* Setup of VM context.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GlobalWindow.cjs","sourceRoot":"","sources":["../../src/window/GlobalWindow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAAuD;
|
1
|
+
{"version":3,"file":"GlobalWindow.cjs","s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" />
|
2
3
|
import * as PropertySymbol from '../PropertySymbol.cjs';
|
4
|
+
import { IOptionalBrowserSettings } from '../index.cjs';
|
3
5
|
import Window from './Window.cjs';
|
4
6
|
import { Buffer } from 'buffer';
|
5
7
|
/**
|
@@ -68,6 +70,29 @@ export default class GlobalWindow extends Window {
|
|
68
70
|
unescape: (str: string) => string;
|
69
71
|
gc: () => void;
|
70
72
|
v8debug?: unknown;
|
73
|
+
/**
|
74
|
+
* Constructor.
|
75
|
+
*
|
76
|
+
* @param [options] Options.
|
77
|
+
* @param [options.width] Window width. Defaults to "1024".
|
78
|
+
* @param [options.height] Window height. Defaults to "768".
|
79
|
+
* @param [options.innerWidth] Inner width. Deprecated. Defaults to "1024".
|
80
|
+
* @param [options.innerHeight] Inner height. Deprecated. Defaults to "768".
|
81
|
+
* @param [options.url] URL.
|
82
|
+
* @param [options.console] Console.
|
83
|
+
* @param [options.settings] Settings.
|
84
|
+
*/
|
85
|
+
constructor(options?: {
|
86
|
+
width?: number;
|
87
|
+
height?: number;
|
88
|
+
/** @deprecated Replaced by the "width" property. */
|
89
|
+
innerWidth?: number;
|
90
|
+
/** @deprecated Replaced by the "height" property. */
|
91
|
+
innerHeight?: number;
|
92
|
+
url?: string;
|
93
|
+
console?: Console;
|
94
|
+
settings?: IOptionalBrowserSettings;
|
95
|
+
});
|
71
96
|
/**
|
72
97
|
* Setup of VM context.
|
73
98
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GlobalWindow.d.ts","sourceRoot":"","sources":["../../src/window/GlobalWindow.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"GlobalWindow.d.ts","sourceRoot":"","sources":["../../src/window/GlobalWindow.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE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AAC,EAAE,wBAAwB,CAAC;KACpC;IAiCD;;OAEG;cACgB,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,IAAI;CAG1D"}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
2
3
|
import * as PropertySymbol from '../PropertySymbol.js';
|
4
|
+
import { IOptionalBrowserSettings } from '../index.js';
|
3
5
|
import Window from './Window.js';
|
4
6
|
import { Buffer } from 'buffer';
|
5
7
|
/**
|
@@ -68,6 +70,29 @@ export default class GlobalWindow extends Window {
|
|
68
70
|
unescape: (str: string) => string;
|
69
71
|
gc: () => void;
|
70
72
|
v8debug?: unknown;
|
73
|
+
/**
|
74
|
+
* Constructor.
|
75
|
+
*
|
76
|
+
* @param [options] Options.
|
77
|
+
* @param [options.width] Window width. Defaults to "1024".
|
78
|
+
* @param [options.height] Window height. Defaults to "768".
|
79
|
+
* @param [options.innerWidth] Inner width. Deprecated. Defaults to "1024".
|
80
|
+
* @param [options.innerHeight] Inner height. Deprecated. Defaults to "768".
|
81
|
+
* @param [options.url] URL.
|
82
|
+
* @param [options.console] Console.
|
83
|
+
* @param [options.settings] Settings.
|
84
|
+
*/
|
85
|
+
constructor(options?: {
|
86
|
+
width?: number;
|
87
|
+
height?: number;
|
88
|
+
/** @deprecated Replaced by the "width" property. */
|
89
|
+
innerWidth?: number;
|
90
|
+
/** @deprecated Replaced by the "height" property. */
|
91
|
+
innerHeight?: number;
|
92
|
+
url?: string;
|
93
|
+
console?: Console;
|
94
|
+
settings?: IOptionalBrowserSettings;
|
95
|
+
});
|
71
96
|
/**
|
72
97
|
* Setup of VM context.
|
73
98
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GlobalWindow.d.ts","sourceRoot":"","sources":["../../src/window/GlobalWindow.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"GlobalWindow.d.ts","sourceRoot":"","sources":["../../src/window/Glob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QAChB,oDAAoD;QACpD,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,qDAAqD;QACrD,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,wBAAwB,CAAC;KACpC;IAiCD;;OAEG;cACgB,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,IAAI;CAG1D"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import * as PropertySymbol from '../PropertySymbol.js';
|
2
|
+
import BrowserWindow from './BrowserWindow.js';
|
2
3
|
import Window from './Window.js';
|
3
4
|
import { Buffer } from 'buffer';
|
4
5
|
/**
|
@@ -8,8 +9,20 @@ import { Buffer } from 'buffer';
|
|
8
9
|
* https://developer.mozilla.org/en-US/docs/Web/API/Window.
|
9
10
|
*/
|
10
11
|
export default class GlobalWindow extends Window {
|
11
|
-
|
12
|
-
|
12
|
+
/**
|
13
|
+
* Constructor.
|
14
|
+
*
|
15
|
+
* @param [options] Options.
|
16
|
+
* @param [options.width] Window width. Defaults to "1024".
|
17
|
+
* @param [options.height] Window height. Defaults to "768".
|
18
|
+
* @param [options.innerWidth] Inner width. Deprecated. Defaults to "1024".
|
19
|
+
* @param [options.innerHeight] Inner height. Deprecated. Defaults to "768".
|
20
|
+
* @param [options.url] URL.
|
21
|
+
* @param [options.console] Console.
|
22
|
+
* @param [options.settings] Settings.
|
23
|
+
*/
|
24
|
+
constructor(options) {
|
25
|
+
super(options);
|
13
26
|
// Node.js Globals
|
14
27
|
this.Array = globalThis.Array;
|
15
28
|
this.ArrayBuffer = globalThis.ArrayBuffer;
|
@@ -70,6 +83,30 @@ export default class GlobalWindow extends Window {
|
|
70
83
|
this.unescape = globalThis.unescape;
|
71
84
|
this.gc = globalThis.gc;
|
72
85
|
this.v8debug = globalThis.v8debug;
|
86
|
+
/**
|
87
|
+
* Binds getts and setters, so that they will appear as an "own" property when using Object.getOwnPropertyNames().
|
88
|
+
*
|
89
|
+
* This is needed for Vitest to work as it relies on Object.getOwnPropertyNames() to get the list of properties.
|
90
|
+
*
|
91
|
+
* @see https://github.com/capricorn86/happy-dom/issues/1339
|
92
|
+
*/
|
93
|
+
for (const windowClass of [GlobalWindow, Window, BrowserWindow]) {
|
94
|
+
const propertyDescriptors = Object.getOwnPropertyDescriptors(Reflect.getPrototypeOf(windowClass.prototype));
|
95
|
+
for (const key of Object.keys(propertyDescriptors)) {
|
96
|
+
const windowPropertyDescriptor = propertyDescriptors[key];
|
97
|
+
if (windowPropertyDescriptor.get || windowPropertyDescriptor.set) {
|
98
|
+
const ownPropertyDescriptor = Object.getOwnPropertyDescriptor(this, key);
|
99
|
+
if (!ownPropertyDescriptor) {
|
100
|
+
Object.defineProperty(this, key, {
|
101
|
+
configurable: true,
|
102
|
+
enumerable: windowPropertyDescriptor.enumerable,
|
103
|
+
get: windowPropertyDescriptor.get?.bind(this),
|
104
|
+
set: windowPropertyDescriptor.set?.bind(this)
|
105
|
+
});
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
73
110
|
}
|
74
111
|
/**
|
75
112
|
* Setup of VM context.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GlobalWindow.js","sourceRoot":"","sources":["../../src/window/GlobalWindow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;
|
1
|
+
{"version":3,"file":"GlobalWindow.js","sourceRoot":"","sources":["../../src/window/GlobalWindow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAEvD,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,MAAM;IA8D/C;;;;;;;;;;;OAW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I,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC;YACjE,MAAM,mBAAmB,GAAG,MAAM,CAAC,yBAAyB,CAC3D,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,CAAC,CAC7C,CAAC;YAEF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBACpD,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;gBAC1D,IAAI,wBAAwB,CAAC,GAAG,IAAI,wBAAwB,CAAC,GAAG,EAAE,CAAC;oBAClE,MAAM,qBAAqB,GAAG,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;oBAEzE,IAAI,CAAC,qBAAqB,EAAE,CAAC;wBAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE;4BAChC,YAAY,EAAE,IAAI;4BAClB,UAAU,EAAE,wBAAwB,CAAC,UAAU;4BAC/C,GAAG,EAAE,wBAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC;4BAC7C,GAAG,EAAE,wBAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC;yBAC7C,CAAC,CAAC;oBACJ,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED;;OAEG;IACgB,CAAC,cAAc,CAAC,cAAc,CAAC;QACjD,aAAa;IACd,CAAC;CACD"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "happy-dom",
|
3
|
-
"version": "14.1.
|
3
|
+
"version": "14.1.2",
|
4
4
|
"license": "MIT",
|
5
5
|
"homepage": "https://github.com/capricorn86/happy-dom",
|
6
6
|
"repository": "https://github.com/capricorn86/happy-dom",
|
@@ -67,8 +67,8 @@
|
|
67
67
|
"scripts": {
|
68
68
|
"compile": "npm run compile:esm && npm run compile:cjs npm run build-version-file",
|
69
69
|
"compile:esm": "tsc",
|
70
|
-
"compile:cjs": "rm -rf ./cjs && tsc --moduleResolution Node --module CommonJS --outDir cjs && npm run change-cjs-file-extension",
|
71
|
-
"change-cjs-file-extension": "node ./bin/change-file-extension.cjs --dir=./cjs --fromExt=.js --toExt=.cjs",
|
70
|
+
"compile:cjs": "rm -rf ./cjs && tsc --moduleResolution Node --module CommonJS --outDir cjs && npm run compile:change-cjs-file-extension",
|
71
|
+
"compile:change-cjs-file-extension": "node ./bin/change-file-extension.cjs --dir=./cjs --fromExt=.js --toExt=.cjs",
|
72
72
|
"build-version-file": "node ./bin/build-version-file.cjs",
|
73
73
|
"watch": "tsc -w --preserveWatchOutput",
|
74
74
|
"test": "vitest run --singleThread",
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import * as PropertySymbol from '../PropertySymbol.js';
|
2
|
+
import { IOptionalBrowserSettings } from '../index.js';
|
3
|
+
import BrowserWindow from './BrowserWindow.js';
|
2
4
|
import Window from './Window.js';
|
3
5
|
import { Buffer } from 'buffer';
|
4
6
|
|
@@ -70,6 +72,61 @@ export default class GlobalWindow extends Window {
|
|
70
72
|
public gc: () => void = globalThis.gc;
|
71
73
|
public v8debug?: unknown = globalThis.v8debug;
|
72
74
|
|
75
|
+
/**
|
76
|
+
* Constructor.
|
77
|
+
*
|
78
|
+
* @param [options] Options.
|
79
|
+
* @param [options.width] Window width. Defaults to "1024".
|
80
|
+
* @param [options.height] Window height. Defaults to "768".
|
81
|
+
* @param [options.innerWidth] Inner width. Deprecated. Defaults to "1024".
|
82
|
+
* @param [options.innerHeight] Inner height. Deprecated. Defaults to "768".
|
83
|
+
* @param [options.url] URL.
|
84
|
+
* @param [options.console] Console.
|
85
|
+
* @param [options.settings] Settings.
|
86
|
+
*/
|
87
|
+
constructor(options?: {
|
88
|
+
width?: number;
|
89
|
+
height?: number;
|
90
|
+
/** @deprecated Replaced by the "width" property. */
|
91
|
+
innerWidth?: number;
|
92
|
+
/** @deprecated Replaced by the "height" property. */
|
93
|
+
innerHeight?: number;
|
94
|
+
url?: string;
|
95
|
+
console?: Console;
|
96
|
+
settings?: IOptionalBrowserSettings;
|
97
|
+
}) {
|
98
|
+
super(options);
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Binds getts and setters, so that they will appear as an "own" property when using Object.getOwnPropertyNames().
|
102
|
+
*
|
103
|
+
* This is needed for Vitest to work as it relies on Object.getOwnPropertyNames() to get the list of properties.
|
104
|
+
*
|
105
|
+
* @see https://github.com/capricorn86/happy-dom/issues/1339
|
106
|
+
*/
|
107
|
+
for (const windowClass of [GlobalWindow, Window, BrowserWindow]) {
|
108
|
+
const propertyDescriptors = Object.getOwnPropertyDescriptors(
|
109
|
+
Reflect.getPrototypeOf(windowClass.prototype)
|
110
|
+
);
|
111
|
+
|
112
|
+
for (const key of Object.keys(propertyDescriptors)) {
|
113
|
+
const windowPropertyDescriptor = propertyDescriptors[key];
|
114
|
+
if (windowPropertyDescriptor.get || windowPropertyDescriptor.set) {
|
115
|
+
const ownPropertyDescriptor = Object.getOwnPropertyDescriptor(this, key);
|
116
|
+
|
117
|
+
if (!ownPropertyDescriptor) {
|
118
|
+
Object.defineProperty(this, key, {
|
119
|
+
configurable: true,
|
120
|
+
enumerable: windowPropertyDescriptor.enumerable,
|
121
|
+
get: windowPropertyDescriptor.get?.bind(this),
|
122
|
+
set: windowPropertyDescriptor.set?.bind(this)
|
123
|
+
});
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
73
130
|
/**
|
74
131
|
* Setup of VM context.
|
75
132
|
*/
|