@lexical/headless 0.35.1-nightly.20250924.0 → 0.36.0
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/LexicalHeadlessDom.browser.dev.js +32 -0
- package/LexicalHeadlessDom.browser.dev.mjs +30 -0
- package/LexicalHeadlessDom.browser.js +11 -0
- package/LexicalHeadlessDom.browser.mjs +12 -0
- package/LexicalHeadlessDom.browser.node.mjs +10 -0
- package/LexicalHeadlessDom.browser.prod.js +9 -0
- package/LexicalHeadlessDom.browser.prod.mjs +9 -0
- package/LexicalHeadlessDom.dev.js +79 -0
- package/LexicalHeadlessDom.dev.mjs +64 -0
- package/LexicalHeadlessDom.js +11 -0
- package/LexicalHeadlessDom.js.flow +13 -0
- package/LexicalHeadlessDom.mjs +12 -0
- package/LexicalHeadlessDom.node.mjs +10 -0
- package/LexicalHeadlessDom.prod.js +9 -0
- package/LexicalHeadlessDom.prod.mjs +9 -0
- package/dom.browser.d.ts +1 -0
- package/dom.d.ts +20 -0
- package/package.json +26 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// Do not require this module directly! Use normal `invariant` calls.
|
|
20
|
+
|
|
21
|
+
function formatDevErrorMessage(message) {
|
|
22
|
+
throw new Error(message);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function withDOM(f) {
|
|
26
|
+
if (!!!globalThis.window) {
|
|
27
|
+
formatDevErrorMessage(`@lexical/headless/dom compiled for browser used in an environment without a global window`);
|
|
28
|
+
}
|
|
29
|
+
return f(globalThis.window);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.withDOM = withDOM;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Do not require this module directly! Use normal `invariant` calls.
|
|
18
|
+
|
|
19
|
+
function formatDevErrorMessage(message) {
|
|
20
|
+
throw new Error(message);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function withDOM(f) {
|
|
24
|
+
if (!!!globalThis.window) {
|
|
25
|
+
formatDevErrorMessage(`@lexical/headless/dom compiled for browser used in an environment without a global window`);
|
|
26
|
+
}
|
|
27
|
+
return f(globalThis.window);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { withDOM };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict'
|
|
10
|
+
const LexicalHeadlessDom.browser = process.env.NODE_ENV !== 'production' ? require('./LexicalHeadlessDom.browser.dev.js') : require('./LexicalHeadlessDom.browser.prod.js');
|
|
11
|
+
module.exports = LexicalHeadlessDom.browser;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as modDev from './LexicalHeadlessDom.browser.dev.mjs';
|
|
10
|
+
import * as modProd from './LexicalHeadlessDom.browser.prod.mjs';
|
|
11
|
+
const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
|
|
12
|
+
export const withDOM = mod.withDOM;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalHeadlessDom.browser.dev.mjs') : import('./LexicalHeadlessDom.browser.prod.mjs'));
|
|
10
|
+
export const withDOM = mod.withDOM;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
"use strict";exports.withDOM=function(r){return globalThis.window||function(r,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",r);for(const r of e)o.append("v",r);throw n.search=o.toString(),Error(`Minified Lexical error #${r}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(318),r(globalThis.window)};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function r(r){return globalThis.window||function(r,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",r);for(const r of e)o.append("v",r);throw n.search=o.toString(),Error(`Minified Lexical error #${r}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(318),r(globalThis.window)}export{r as withDOM};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
var HappyDOM = require('happy-dom');
|
|
12
|
+
|
|
13
|
+
function _interopNamespaceDefault(e) {
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
for (var k in e) {
|
|
17
|
+
n[k] = e[k];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return n;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var HappyDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(HappyDOM);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the MIT license found in the
|
|
30
|
+
* LICENSE file in the root directory of this source tree.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function createWindow() {
|
|
35
|
+
if ('Window' in HappyDOM__namespace) {
|
|
36
|
+
// @ts-expect-error -- DOMWindow is not exactly Window
|
|
37
|
+
return new HappyDOM__namespace.Window();
|
|
38
|
+
} else {
|
|
39
|
+
const jsdom = HappyDOM__namespace;
|
|
40
|
+
// @ts-expect-error -- this is jsdom in www
|
|
41
|
+
return new jsdom.JSDOM().window;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Call the given synchronous function with a window object,
|
|
47
|
+
* either from the browser or happy-dom in a non-browser
|
|
48
|
+
* environment. It will also set window, document, and MutationObserver
|
|
49
|
+
* on globalThis while the callback is running. This is
|
|
50
|
+
* useful primarily to parse and render HTML server-side.
|
|
51
|
+
*
|
|
52
|
+
* It is not safe to do anything asynchronous during this callback.
|
|
53
|
+
*
|
|
54
|
+
* @param f A function that uses the window object
|
|
55
|
+
* @returns The result of that function.
|
|
56
|
+
*/
|
|
57
|
+
function withDOM(f) {
|
|
58
|
+
const prevWindow = globalThis.window;
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- handle recursive case
|
|
60
|
+
if (prevWindow) {
|
|
61
|
+
return f(globalThis.window);
|
|
62
|
+
}
|
|
63
|
+
const prevMutationObserver = globalThis.MutationObserver;
|
|
64
|
+
const prevDocument = globalThis.document;
|
|
65
|
+
const newWindow = createWindow();
|
|
66
|
+
globalThis.window = newWindow;
|
|
67
|
+
globalThis.document = newWindow.document;
|
|
68
|
+
globalThis.MutationObserver = newWindow.MutationObserver;
|
|
69
|
+
try {
|
|
70
|
+
return f(newWindow);
|
|
71
|
+
} finally {
|
|
72
|
+
globalThis.MutationObserver = prevMutationObserver;
|
|
73
|
+
globalThis.document = prevDocument;
|
|
74
|
+
globalThis.window = prevWindow;
|
|
75
|
+
newWindow.close();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.withDOM = withDOM;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as HappyDOM from 'happy-dom';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
function createWindow() {
|
|
20
|
+
if ('Window' in HappyDOM) {
|
|
21
|
+
// @ts-expect-error -- DOMWindow is not exactly Window
|
|
22
|
+
return new HappyDOM.Window();
|
|
23
|
+
} else {
|
|
24
|
+
const jsdom = HappyDOM;
|
|
25
|
+
// @ts-expect-error -- this is jsdom in www
|
|
26
|
+
return new jsdom.JSDOM().window;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Call the given synchronous function with a window object,
|
|
32
|
+
* either from the browser or happy-dom in a non-browser
|
|
33
|
+
* environment. It will also set window, document, and MutationObserver
|
|
34
|
+
* on globalThis while the callback is running. This is
|
|
35
|
+
* useful primarily to parse and render HTML server-side.
|
|
36
|
+
*
|
|
37
|
+
* It is not safe to do anything asynchronous during this callback.
|
|
38
|
+
*
|
|
39
|
+
* @param f A function that uses the window object
|
|
40
|
+
* @returns The result of that function.
|
|
41
|
+
*/
|
|
42
|
+
function withDOM(f) {
|
|
43
|
+
const prevWindow = globalThis.window;
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- handle recursive case
|
|
45
|
+
if (prevWindow) {
|
|
46
|
+
return f(globalThis.window);
|
|
47
|
+
}
|
|
48
|
+
const prevMutationObserver = globalThis.MutationObserver;
|
|
49
|
+
const prevDocument = globalThis.document;
|
|
50
|
+
const newWindow = createWindow();
|
|
51
|
+
globalThis.window = newWindow;
|
|
52
|
+
globalThis.document = newWindow.document;
|
|
53
|
+
globalThis.MutationObserver = newWindow.MutationObserver;
|
|
54
|
+
try {
|
|
55
|
+
return f(newWindow);
|
|
56
|
+
} finally {
|
|
57
|
+
globalThis.MutationObserver = prevMutationObserver;
|
|
58
|
+
globalThis.document = prevDocument;
|
|
59
|
+
globalThis.window = prevWindow;
|
|
60
|
+
newWindow.close();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { withDOM };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict'
|
|
10
|
+
const LexicalHeadlessDom = process.env.NODE_ENV !== 'production' ? require('./LexicalHeadlessDom.dev.js') : require('./LexicalHeadlessDom.prod.js');
|
|
11
|
+
module.exports = LexicalHeadlessDom;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* LexicalHeadlessDom
|
|
12
|
+
*/
|
|
13
|
+
declare export function withDOM<T>(f: (window: typeof globalThis.window) => T): T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as modDev from './LexicalHeadlessDom.dev.mjs';
|
|
10
|
+
import * as modProd from './LexicalHeadlessDom.prod.mjs';
|
|
11
|
+
const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
|
|
12
|
+
export const withDOM = mod.withDOM;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalHeadlessDom.dev.mjs') : import('./LexicalHeadlessDom.prod.mjs'));
|
|
10
|
+
export const withDOM = mod.withDOM;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
"use strict";function o(o){var i=Object.create(null);if(o)for(var n in o)i[n]=o[n];return i.default=o,i}var i=o(require("happy-dom"));exports.withDOM=function(o){const n=globalThis.window;if(n)return o(globalThis.window);const t=globalThis.MutationObserver,e=globalThis.document,l="Window"in i?new i.Window:(new i.JSDOM).window;globalThis.window=l,globalThis.document=l.document,globalThis.MutationObserver=l.MutationObserver;try{return o(l)}finally{globalThis.MutationObserver=t,globalThis.document=e,globalThis.window=n,l.close()}};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import*as o from"happy-dom";function i(i){const n=globalThis.window;if(n)return i(globalThis.window);const l=globalThis.MutationObserver,t=globalThis.document,e="Window"in o?new o.Window:(new o.JSDOM).window;globalThis.window=e,globalThis.document=e.document,globalThis.MutationObserver=e.MutationObserver;try{return i(e)}finally{globalThis.MutationObserver=l,globalThis.document=t,globalThis.window=n,e.close()}}export{i as withDOM};
|
package/dom.browser.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withDOM<T>(f: (window: Window) => T): T;
|
package/dom.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Call the given synchronous function with a window object,
|
|
10
|
+
* either from the browser or happy-dom in a non-browser
|
|
11
|
+
* environment. It will also set window, document, and MutationObserver
|
|
12
|
+
* on globalThis while the callback is running. This is
|
|
13
|
+
* useful primarily to parse and render HTML server-side.
|
|
14
|
+
*
|
|
15
|
+
* It is not safe to do anything asynchronous during this callback.
|
|
16
|
+
*
|
|
17
|
+
* @param f A function that uses the window object
|
|
18
|
+
* @returns The result of that function.
|
|
19
|
+
*/
|
|
20
|
+
export declare function withDOM<T>(f: (window: Window) => T): T;
|
package/package.json
CHANGED
|
@@ -8,17 +8,35 @@
|
|
|
8
8
|
"headless"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
12
|
-
"main": "LexicalHeadless.js",
|
|
13
|
-
"types": "index.d.ts",
|
|
11
|
+
"version": "0.36.0",
|
|
14
12
|
"repository": {
|
|
15
13
|
"type": "git",
|
|
16
14
|
"url": "https://github.com/facebook/lexical",
|
|
17
15
|
"directory": "packages/lexical-headless"
|
|
18
16
|
},
|
|
19
|
-
"module": "LexicalHeadless.mjs",
|
|
20
17
|
"sideEffects": false,
|
|
21
18
|
"exports": {
|
|
19
|
+
"./dom": {
|
|
20
|
+
"browser": {
|
|
21
|
+
"types": "./LexicalHeadlessDom.d.ts",
|
|
22
|
+
"development": "./LexicalHeadlessDom.dev.browser.mjs",
|
|
23
|
+
"production": "./LexicalHeadlessDom.prod.browser.mjs",
|
|
24
|
+
"default": "./LexicalHeadlessDom.browser.mjs"
|
|
25
|
+
},
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./LexicalHeadlessDom.d.ts",
|
|
28
|
+
"development": "./LexicalHeadlessDom.dev.mjs",
|
|
29
|
+
"production": "./LexicalHeadlessDom.prod.mjs",
|
|
30
|
+
"node": "./LexicalHeadlessDom.node.mjs",
|
|
31
|
+
"default": "./LexicalHeadlessDom.mjs"
|
|
32
|
+
},
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./LexicalHeadlessDom.d.ts",
|
|
35
|
+
"development": "./LexicalHeadlessDom.dev.js",
|
|
36
|
+
"production": "./LexicalHeadlessDom.prod.js",
|
|
37
|
+
"default": "./LexicalHeadlessDom.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
22
40
|
".": {
|
|
23
41
|
"import": {
|
|
24
42
|
"types": "./index.d.ts",
|
|
@@ -36,6 +54,9 @@
|
|
|
36
54
|
}
|
|
37
55
|
},
|
|
38
56
|
"dependencies": {
|
|
39
|
-
"lexical": "0.
|
|
57
|
+
"lexical": "0.36.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"happy-dom": "^18.0.1"
|
|
40
61
|
}
|
|
41
62
|
}
|