@lexical/internal 0.51.1-nightly.20260925.0 → 0.52.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/README.md +18 -1
- package/dist/LexicalInternalCreateDevError.dev.js +22 -0
- package/dist/LexicalInternalCreateDevError.js +12 -0
- package/dist/LexicalInternalCreateDevError.js.flow +10 -0
- package/dist/LexicalInternalCreateDevError.prod.js +9 -0
- package/dist/LexicalInternalCreateError.dev.js +41 -0
- package/dist/LexicalInternalCreateError.js +12 -0
- package/dist/LexicalInternalCreateError.js.flow +13 -0
- package/dist/LexicalInternalCreateError.prod.js +9 -0
- package/dist/LexicalInternalCreateProdError.dev.js +29 -0
- package/dist/LexicalInternalCreateProdError.js +12 -0
- package/dist/LexicalInternalCreateProdError.js.flow +13 -0
- package/dist/LexicalInternalCreateProdError.prod.js +9 -0
- package/dist/LexicalInternalFormatProdErrorMessage.dev.js +20 -6
- package/dist/LexicalInternalFormatProdErrorMessage.prod.js +1 -1
- package/dist/LexicalInternalVersion.dev.js +3 -3
- package/dist/LexicalInternalVersion.prod.js +1 -1
- package/dist/createDevError.d.ts +8 -0
- package/dist/createError.d.ts +13 -0
- package/dist/createProdError.d.ts +8 -0
- package/package.json +49 -1
- package/src/createDevError.ts +12 -0
- package/src/createError.ts +23 -0
- package/src/createProdError.ts +25 -0
- package/src/formatProdErrorMessage.ts +3 -11
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> [!WARNING]
|
|
4
4
|
> This package contains **internal** utilities shared across the Lexical
|
|
5
|
-
> packages: `invariant`/`devInvariant`, dev/prod error- and warning-message
|
|
5
|
+
> packages: `invariant`/`devInvariant`, `createError`, dev/prod error- and warning-message
|
|
6
6
|
> formatting, `warnOnlyOnce`, and the `LEXICAL_VERSION` constant. These are
|
|
7
7
|
> bound to the build's transforms and are inlined into every other package
|
|
8
8
|
> rather than shipped as a runtime dependency, so it is published only so the
|
|
@@ -12,3 +12,20 @@
|
|
|
12
12
|
> It is **not** a public API. Import from `lexical` and the `@lexical/*`
|
|
13
13
|
> feature packages instead. Nothing here follows semver and any export may
|
|
14
14
|
> change or disappear without notice.
|
|
15
|
+
|
|
16
|
+
`createError('Message with %s', value)` constructs an `Error` without throwing
|
|
17
|
+
it, for example to pass to an editor's `onWarn` handler. It shares invariant's
|
|
18
|
+
literal-message and `%s` argument convention, including production error-code
|
|
19
|
+
extraction, and can be used inside expressions.
|
|
20
|
+
|
|
21
|
+
The transform recognizes the default import from
|
|
22
|
+
`@lexical/internal/createError` (or its `.js` alias), including renamed imports.
|
|
23
|
+
Unrelated or shadowed functions with the same name are left alone. Generated
|
|
24
|
+
calls use separate `createDevError` and `createProdError` runtime helpers so
|
|
25
|
+
bundled output can pass through the transform again.
|
|
26
|
+
|
|
27
|
+
Warnings routed through `createError`, including the update-cascade warning,
|
|
28
|
+
use the minified error message in production builds with extracted error codes.
|
|
29
|
+
Arguments such as the editor namespace are encoded as `v` parameters in the
|
|
30
|
+
decoder URL instead of appearing directly in the message text. Telemetry that
|
|
31
|
+
matches the full development warning text must account for that production form.
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
// Used by the error-message transform. Call createError in source.
|
|
18
|
+
function createDevError(message) {
|
|
19
|
+
return new Error(message);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { createDevError as default };
|
|
@@ -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 './LexicalInternalCreateDevError.dev.js';
|
|
10
|
+
import * as modProd from './LexicalInternalCreateDevError.prod.js';
|
|
11
|
+
const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
|
|
12
|
+
export default mod.default;
|
|
@@ -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
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare export default function createDevError(message: string): Error;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
// Used by the error-message transform. Call createError in source.
|
|
18
|
+
function createDevError(message) {
|
|
19
|
+
return new Error(message);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the MIT license found in the
|
|
26
|
+
* LICENSE file in the root directory of this source tree.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Construct an error without throwing it. Like invariant, the message must be
|
|
33
|
+
* a literal with %s placeholders so builds can replace it with an error code.
|
|
34
|
+
* The source implementation also works without the build transform.
|
|
35
|
+
*/
|
|
36
|
+
function createError(message, ...args) {
|
|
37
|
+
let index = 0;
|
|
38
|
+
return createDevError(args.length === 0 ? message : message.replace(/%s/g, () => String(args[index++])));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { createError as default };
|
|
@@ -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 './LexicalInternalCreateError.dev.js';
|
|
10
|
+
import * as modProd from './LexicalInternalCreateError.prod.js';
|
|
11
|
+
const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
|
|
12
|
+
export default mod.default;
|
|
@@ -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
|
+
declare export default function createError(
|
|
11
|
+
message: string,
|
|
12
|
+
...args: string[]
|
|
13
|
+
): Error;
|
|
@@ -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,...e){let n=0;return function(r){return new Error(r)}(0===e.length?r:r.replace(/%s/g,()=>String(e[n++])))}export{r as default};
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
// Used by the error-message transform. Call createError or invariant in source.
|
|
18
|
+
function createProdError(code, ...args) {
|
|
19
|
+
const url = new URL('https://lexical.dev/docs/error');
|
|
20
|
+
const params = new URLSearchParams();
|
|
21
|
+
params.append('code', code);
|
|
22
|
+
for (const arg of args) {
|
|
23
|
+
params.append('v', arg);
|
|
24
|
+
}
|
|
25
|
+
url.search = params.toString();
|
|
26
|
+
return new Error(`Minified Lexical error #${code}; visit ${url.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { createProdError as default };
|
|
@@ -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 './LexicalInternalCreateProdError.dev.js';
|
|
10
|
+
import * as modProd from './LexicalInternalCreateProdError.prod.js';
|
|
11
|
+
const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
|
|
12
|
+
export default mod.default;
|
|
@@ -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
|
+
declare export default function createProdError(
|
|
11
|
+
code: string,
|
|
12
|
+
...args: string[]
|
|
13
|
+
): Error;
|
|
@@ -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 e(e,...r){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of r)o.append("v",e);return n.search=o.toString(),new Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}export{e as default};
|
|
@@ -14,11 +14,8 @@
|
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
// during build.
|
|
20
|
-
|
|
21
|
-
function formatProdErrorMessage(code, ...args) {
|
|
17
|
+
// Used by the error-message transform. Call createError or invariant in source.
|
|
18
|
+
function createProdError(code, ...args) {
|
|
22
19
|
const url = new URL('https://lexical.dev/docs/error');
|
|
23
20
|
const params = new URLSearchParams();
|
|
24
21
|
params.append('code', code);
|
|
@@ -26,7 +23,24 @@ function formatProdErrorMessage(code, ...args) {
|
|
|
26
23
|
params.append('v', arg);
|
|
27
24
|
}
|
|
28
25
|
url.search = params.toString();
|
|
29
|
-
|
|
26
|
+
return new Error(`Minified Lexical error #${code}; visit ${url.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
31
|
+
*
|
|
32
|
+
* This source code is licensed under the MIT license found in the
|
|
33
|
+
* LICENSE file in the root directory of this source tree.
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// Do not require this module directly! Use normal `invariant` calls with
|
|
39
|
+
// template literal strings. The messages will be replaced with error codes
|
|
40
|
+
// during build.
|
|
41
|
+
|
|
42
|
+
function formatProdErrorMessage(code, ...args) {
|
|
43
|
+
throw createProdError(code, ...args);
|
|
30
44
|
}
|
|
31
45
|
|
|
32
46
|
export { formatProdErrorMessage as default };
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
function e(e,...r){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of r)o.append("v",e);
|
|
9
|
+
function e(e,...r){throw function(e,...r){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of r)o.append("v",e);return n.search=o.toString(),new Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(e,...r)}export{e as default};
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* `"0.
|
|
18
|
+
* `"0.52.0+dev.esm"` is statically replaced with the build-specific
|
|
19
19
|
* version string in a Rollup build, and a consumer's bundler `define` can
|
|
20
|
-
* inject it the same way — so the exact `"0.
|
|
20
|
+
* inject it the same way — so the exact `"0.52.0+dev.esm"` member
|
|
21
21
|
* expression must be preserved for that substitution to match. Reading it
|
|
22
22
|
* inside a try/catch lets the source be consumed directly (via the `source`
|
|
23
23
|
* export condition) in a browser bundle, where `process` is undefined and
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
function readLexicalVersion() {
|
|
36
36
|
let envLexicalVersion;
|
|
37
37
|
try {
|
|
38
|
-
envLexicalVersion = "0.
|
|
38
|
+
envLexicalVersion = "0.52.0+dev.esm";
|
|
39
39
|
} catch {
|
|
40
40
|
// `process` is not defined in some browser bundles; use the fallback.
|
|
41
41
|
}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
function n(){let n;try{n="0.
|
|
9
|
+
function n(){let n;try{n="0.52.0+prod.esm"}catch{}return n??'"<unknown>+source"'}const t=/* @__PURE__ */n();export{t as LEXICAL_VERSION};
|
|
@@ -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
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Construct an error without throwing it. Like invariant, the message must be
|
|
10
|
+
* a literal with %s placeholders so builds can replace it with an error code.
|
|
11
|
+
* The source implementation also works without the build transform.
|
|
12
|
+
*/
|
|
13
|
+
export default function createError(message: string, ...args: string[]): Error;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export default function createProdError(code: string, ...args: string[]): Error;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"internal"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.52.0",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git+https://github.com/facebook/lexical.git",
|
|
@@ -16,6 +16,54 @@
|
|
|
16
16
|
},
|
|
17
17
|
"sideEffects": false,
|
|
18
18
|
"exports": {
|
|
19
|
+
"./createDevError": {
|
|
20
|
+
"source": "./src/createDevError.ts",
|
|
21
|
+
"types@<5.2": "./dist/typescript-too-old.d.ts",
|
|
22
|
+
"types": "./dist/createDevError.d.ts",
|
|
23
|
+
"development": "./dist/LexicalInternalCreateDevError.dev.js",
|
|
24
|
+
"production": "./dist/LexicalInternalCreateDevError.prod.js",
|
|
25
|
+
"default": "./dist/LexicalInternalCreateDevError.js"
|
|
26
|
+
},
|
|
27
|
+
"./createDevError.js": {
|
|
28
|
+
"source": "./src/createDevError.ts",
|
|
29
|
+
"types@<5.2": "./dist/typescript-too-old.d.ts",
|
|
30
|
+
"types": "./dist/createDevError.d.ts",
|
|
31
|
+
"development": "./dist/LexicalInternalCreateDevError.dev.js",
|
|
32
|
+
"production": "./dist/LexicalInternalCreateDevError.prod.js",
|
|
33
|
+
"default": "./dist/LexicalInternalCreateDevError.js"
|
|
34
|
+
},
|
|
35
|
+
"./createError": {
|
|
36
|
+
"source": "./src/createError.ts",
|
|
37
|
+
"types@<5.2": "./dist/typescript-too-old.d.ts",
|
|
38
|
+
"types": "./dist/createError.d.ts",
|
|
39
|
+
"development": "./dist/LexicalInternalCreateError.dev.js",
|
|
40
|
+
"production": "./dist/LexicalInternalCreateError.prod.js",
|
|
41
|
+
"default": "./dist/LexicalInternalCreateError.js"
|
|
42
|
+
},
|
|
43
|
+
"./createError.js": {
|
|
44
|
+
"source": "./src/createError.ts",
|
|
45
|
+
"types@<5.2": "./dist/typescript-too-old.d.ts",
|
|
46
|
+
"types": "./dist/createError.d.ts",
|
|
47
|
+
"development": "./dist/LexicalInternalCreateError.dev.js",
|
|
48
|
+
"production": "./dist/LexicalInternalCreateError.prod.js",
|
|
49
|
+
"default": "./dist/LexicalInternalCreateError.js"
|
|
50
|
+
},
|
|
51
|
+
"./createProdError": {
|
|
52
|
+
"source": "./src/createProdError.ts",
|
|
53
|
+
"types@<5.2": "./dist/typescript-too-old.d.ts",
|
|
54
|
+
"types": "./dist/createProdError.d.ts",
|
|
55
|
+
"development": "./dist/LexicalInternalCreateProdError.dev.js",
|
|
56
|
+
"production": "./dist/LexicalInternalCreateProdError.prod.js",
|
|
57
|
+
"default": "./dist/LexicalInternalCreateProdError.js"
|
|
58
|
+
},
|
|
59
|
+
"./createProdError.js": {
|
|
60
|
+
"source": "./src/createProdError.ts",
|
|
61
|
+
"types@<5.2": "./dist/typescript-too-old.d.ts",
|
|
62
|
+
"types": "./dist/createProdError.d.ts",
|
|
63
|
+
"development": "./dist/LexicalInternalCreateProdError.dev.js",
|
|
64
|
+
"production": "./dist/LexicalInternalCreateProdError.prod.js",
|
|
65
|
+
"default": "./dist/LexicalInternalCreateProdError.js"
|
|
66
|
+
},
|
|
19
67
|
"./devInvariant": {
|
|
20
68
|
"source": "./src/devInvariant.ts",
|
|
21
69
|
"types@<5.2": "./dist/typescript-too-old.d.ts",
|
|
@@ -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
|
+
// Used by the error-message transform. Call createError in source.
|
|
10
|
+
export default function createDevError(message: string): Error {
|
|
11
|
+
return new Error(message);
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 createDevError from './createDevError';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Construct an error without throwing it. Like invariant, the message must be
|
|
13
|
+
* a literal with %s placeholders so builds can replace it with an error code.
|
|
14
|
+
* The source implementation also works without the build transform.
|
|
15
|
+
*/
|
|
16
|
+
export default function createError(message: string, ...args: string[]): Error {
|
|
17
|
+
let index = 0;
|
|
18
|
+
return createDevError(
|
|
19
|
+
args.length === 0
|
|
20
|
+
? message
|
|
21
|
+
: message.replace(/%s/g, () => String(args[index++])),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
// Used by the error-message transform. Call createError or invariant in source.
|
|
10
|
+
export default function createProdError(
|
|
11
|
+
code: string,
|
|
12
|
+
...args: string[]
|
|
13
|
+
): Error {
|
|
14
|
+
const url = new URL('https://lexical.dev/docs/error');
|
|
15
|
+
const params = new URLSearchParams();
|
|
16
|
+
params.append('code', code);
|
|
17
|
+
for (const arg of args) {
|
|
18
|
+
params.append('v', arg);
|
|
19
|
+
}
|
|
20
|
+
url.search = params.toString();
|
|
21
|
+
|
|
22
|
+
return new Error(
|
|
23
|
+
`Minified Lexical error #${code}; visit ${url.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import createProdError from './createProdError';
|
|
10
|
+
|
|
9
11
|
// Do not require this module directly! Use normal `invariant` calls with
|
|
10
12
|
// template literal strings. The messages will be replaced with error codes
|
|
11
13
|
// during build.
|
|
@@ -14,15 +16,5 @@ export default function formatProdErrorMessage(
|
|
|
14
16
|
code: string,
|
|
15
17
|
...args: string[]
|
|
16
18
|
): never {
|
|
17
|
-
|
|
18
|
-
const params = new URLSearchParams();
|
|
19
|
-
params.append('code', code);
|
|
20
|
-
for (const arg of args) {
|
|
21
|
-
params.append('v', arg);
|
|
22
|
-
}
|
|
23
|
-
url.search = params.toString();
|
|
24
|
-
|
|
25
|
-
throw Error(
|
|
26
|
-
`Minified Lexical error #${code}; visit ${url.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`,
|
|
27
|
-
);
|
|
19
|
+
throw createProdError(code, ...args);
|
|
28
20
|
}
|