Skip to content

Commit 0a45227

Browse files
authored
Revert "feat: allow $inspect reactivity map, set, date (#11164)"
This reverts commit 43d13e9.
1 parent 42ce8d7 commit 0a45227

File tree

11 files changed

+2
-197
lines changed

11 files changed

+2
-197
lines changed

.changeset/tiny-poems-doubt.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/svelte/src/internal/client/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ export const EFFECT_RAN = 1 << 13;
1616
export const EFFECT_TRANSPARENT = 1 << 14;
1717

1818
export const STATE_SYMBOL = Symbol('$state');
19-
export const INSPECT_SYMBOL = Symbol('$inspect');

packages/svelte/src/internal/client/runtime.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import {
2727
BRANCH_EFFECT,
2828
STATE_SYMBOL,
2929
BLOCK_EFFECT,
30-
ROOT_EFFECT,
31-
INSPECT_SYMBOL
30+
ROOT_EFFECT
3231
} from './constants.js';
3332
import { flush_tasks } from './dom/task.js';
3433
import { add_owner } from './dev/ownership.js';
@@ -1118,24 +1117,6 @@ export function pop(component) {
11181117
return component || /** @type {T} */ ({});
11191118
}
11201119

1121-
/**
1122-
*
1123-
* This is called from the inspect.
1124-
* Deeply traverse every item in the array with `deep_read` to register for inspect callback
1125-
* If the item implements INSPECT_SYMBOL, will use that instead
1126-
* @param {Array<any>} value
1127-
* @returns {void}
1128-
*/
1129-
function deep_read_inpect(value) {
1130-
for (const item of value) {
1131-
if (item && typeof item[INSPECT_SYMBOL] === 'function') {
1132-
item[INSPECT_SYMBOL]();
1133-
} else {
1134-
deep_read(item);
1135-
}
1136-
}
1137-
}
1138-
11391120
/**
11401121
* Possibly traverse an object and read all its properties so that they're all reactive in case this is `$state`.
11411122
* Does only check first level of an object for performance reasons (heuristic should be good for 99% of all cases).
@@ -1266,7 +1247,7 @@ export function inspect(get_value, inspect = console.log) {
12661247

12671248
inspect_fn = fn;
12681249
const value = get_value();
1269-
deep_read_inpect(value);
1250+
deep_read(value);
12701251
inspect_fn = null;
12711252

12721253
const signals = inspect_captured_signals.slice();

packages/svelte/src/reactivity/date.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { DEV } from 'esm-env';
2-
import { INSPECT_SYMBOL } from '../internal/client/constants.js';
31
import { source, set } from '../internal/client/reactivity/sources.js';
42
import { get } from '../internal/client/runtime.js';
53

@@ -90,13 +88,6 @@ export class ReactiveDate extends Date {
9088
return v;
9189
};
9290
}
93-
94-
if (DEV) {
95-
// @ts-ignore
96-
proto[INSPECT_SYMBOL] = function () {
97-
get(this.#raw_time);
98-
};
99-
}
10091
}
10192
}
10293

packages/svelte/src/reactivity/map.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import { source, set } from '../internal/client/reactivity/sources.js';
33
import { get } from '../internal/client/runtime.js';
44
import { UNINITIALIZED } from '../constants.js';
55
import { map } from './utils.js';
6-
import { INSPECT_SYMBOL } from '../internal/client/constants.js';
7-
8-
var inited = false;
96

107
/**
118
* @template K
@@ -23,22 +20,6 @@ export class ReactiveMap extends Map {
2320
constructor(value) {
2421
super();
2522

26-
if (DEV) {
27-
if (!inited) {
28-
inited = true;
29-
// @ts-ignore
30-
ReactiveMap.prototype[INSPECT_SYMBOL] = function () {
31-
// changes could either introduced by
32-
// - modifying the value, or
33-
// - add / remove entries to the map
34-
for (const [, source] of this.#sources) {
35-
get(source);
36-
}
37-
get(this.#size);
38-
};
39-
}
40-
}
41-
4223
// If the value is invalid then the native exception will fire here
4324
if (DEV) new Map(value);
4425

packages/svelte/src/reactivity/set.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { DEV } from 'esm-env';
22
import { source, set } from '../internal/client/reactivity/sources.js';
33
import { get } from '../internal/client/runtime.js';
44
import { map } from './utils.js';
5-
import { INSPECT_SYMBOL } from '../internal/client/constants.js';
65

76
var read_methods = ['forEach', 'isDisjointFrom', 'isSubsetOf', 'isSupersetOf'];
87
var set_like_methods = ['difference', 'intersection', 'symmetricDifference', 'union'];
@@ -66,13 +65,6 @@ export class ReactiveSet extends Set {
6665
return new ReactiveSet(set);
6766
};
6867
}
69-
70-
if (DEV) {
71-
// @ts-ignore
72-
proto[INSPECT_SYMBOL] = function () {
73-
get(this.#version);
74-
};
75-
}
7668
}
7769

7870
#increment_version() {

packages/svelte/src/reactivity/url.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import { DEV } from 'esm-env';
2-
import { INSPECT_SYMBOL } from '../internal/client/constants.js';
31
import { source, set } from '../internal/client/reactivity/sources.js';
42
import { get } from '../internal/client/runtime.js';
53

64
const REPLACE = Symbol();
7-
var inited_url = false;
8-
var inited_search_params = false;
95

106
export class ReactiveURL extends URL {
117
#protocol = source(super.protocol);
@@ -25,14 +21,6 @@ export class ReactiveURL extends URL {
2521
url = new URL(url, base);
2622
super(url);
2723
this.#searchParams[REPLACE](url.searchParams);
28-
29-
if (DEV && !inited_url) {
30-
inited_url = true;
31-
// @ts-ignore
32-
ReactiveURL.prototype[INSPECT_SYMBOL] = function () {
33-
this.href;
34-
};
35-
}
3624
}
3725

3826
get hash() {
@@ -171,17 +159,6 @@ export class ReactiveURLSearchParams extends URLSearchParams {
171159
set(this.#version, this.#version.v + 1);
172160
}
173161

174-
constructor() {
175-
super();
176-
if (DEV && !inited_search_params) {
177-
inited_search_params = true;
178-
// @ts-ignore
179-
ReactiveURLSearchParams.prototype[INSPECT_SYMBOL] = function () {
180-
get(this.#version);
181-
};
182-
}
183-
}
184-
185162
/**
186163
* @param {URLSearchParams} params
187164
*/

packages/svelte/tests/runtime-runes/samples/inspect-reactivity/_config.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

packages/svelte/tests/runtime-runes/samples/inspect-reactivity/log.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/svelte/tests/runtime-runes/samples/inspect-reactivity/main.svelte

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/svelte/types/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,6 @@ declare module 'svelte/reactivity' {
20212021
#private;
20222022
}
20232023
class ReactiveURLSearchParams extends URLSearchParams {
2024-
constructor();
20252024

20262025
[REPLACE](params: URLSearchParams): void;
20272026
#private;

0 commit comments

Comments
 (0)