pull/13557/head
Rich Harris 2 years ago
parent 07f9d7f1f9
commit 25da72bfac

@ -116,5 +116,6 @@ Value cannot be cloned with `$state.snapshot` — the original value was returne
```
The following properties cannot be cloned with `$state.snapshot` — the return value contains the originals:
%properties%
```

@ -4,7 +4,7 @@ import * as acorn from 'acorn';
import { walk } from 'zimmerframe';
import * as esrap from 'esrap';
/** @type {Record<string, Record<string, { messages: string[], details: string }>>} */
/** @type {Record<string, Record<string, { messages: string[], details: string | null }>>} */
const messages = {};
const seen = new Set();
@ -31,29 +31,11 @@ for (const category of fs.readdirSync('messages')) {
sorted.push({ code, _ });
const lines = text.trim().split('\n');
let current_section = '';
let sections = [];
let details = '';
const sections = text.trim().split('\n\n');
const details = [];
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.startsWith('> ')) {
current_section += line.slice(2) + '\n';
} else if (line === '' && lines[i + 1]) {
if (lines[i + 1].startsWith('> ')) {
sections.push(current_section.trim());
current_section = '';
} else {
details = lines.slice(i + 1).join('\n');
break;
}
}
}
if (current_section.length > 0) {
sections.push(current_section.trim());
while (!sections[sections.length - 1].startsWith('> ')) {
details.unshift(/** @type {string} */ (sections.pop()));
}
if (sections.length === 0) {
@ -62,8 +44,8 @@ for (const category of fs.readdirSync('messages')) {
seen.add(code);
messages[category][code] = {
messages: sections,
details: details
messages: sections.map((section) => section.replace(/^> /gm, '').replace(/^>\n/gm, '\n')),
details: details.join('\n\n')
};
}

@ -20,6 +20,7 @@ export function dynamic_void_element_content(tag) {
/**
* The following properties cannot be cloned with `$state.snapshot` the return value contains the originals:
*
* %properties%
* @param {string | undefined | null} [properties]
*/
@ -27,6 +28,7 @@ export function state_snapshot_uncloneable(properties) {
if (DEV) {
console.warn(`%c[svelte] state_snapshot_uncloneable\n%c${properties
? `The following properties cannot be cloned with \`$state.snapshot\` — the return value contains the originals:
${properties}`
: "Value cannot be cloned with `$state.snapshot` — the original value was returned"}`, bold, normal);
} else {

Loading…
Cancel
Save