1
+ /** @import { ProxyMetadata, ProxyStateObject, Source } from '#client' */
1
2
import { DEV } from 'esm-env' ;
2
3
import { get , current_component_context , untrack , current_effect } from './runtime.js' ;
3
4
import {
@@ -18,9 +19,9 @@ import * as e from './errors.js';
18
19
/**
19
20
* @template T
20
21
* @param {T } value
21
- * @param {import('#client'). ProxyMetadata | null } [parent]
22
- * @param {import('#client'). Source<T> } [prev] dev mode only
23
- * @returns {import('#client'). ProxyStateObject<T> | T }
22
+ * @param {ProxyMetadata | null } [parent]
23
+ * @param {Source<T> } [prev] dev mode only
24
+ * @returns {ProxyStateObject<T> | T }
24
25
*/
25
26
export function proxy ( value , parent = null , prev ) {
26
27
if (
@@ -31,7 +32,7 @@ export function proxy(value, parent = null, prev) {
31
32
) {
32
33
// If we have an existing proxy, return it...
33
34
if ( STATE_SYMBOL in value ) {
34
- const metadata = /** @type {import('#client'). ProxyMetadata<T> } */ ( value [ STATE_SYMBOL ] ) ;
35
+ const metadata = /** @type {ProxyMetadata<T> } */ ( value [ STATE_SYMBOL ] ) ;
35
36
36
37
// ...unless the proxy belonged to a different object, because
37
38
// someone copied the state symbol using `Reflect.ownKeys(...)`
@@ -53,7 +54,7 @@ export function proxy(value, parent = null, prev) {
53
54
const proxy = new Proxy ( value , state_proxy_handler ) ;
54
55
55
56
define_property ( value , STATE_SYMBOL , {
56
- value : /** @type {import('#client'). ProxyMetadata } */ ( {
57
+ value : /** @type {ProxyMetadata } */ ( {
57
58
s : new Map ( ) ,
58
59
v : source ( 0 ) ,
59
60
a : is_array ( value ) ,
@@ -94,18 +95,18 @@ export function proxy(value, parent = null, prev) {
94
95
}
95
96
96
97
/**
97
- * @param {import('#client'). Source<number> } signal
98
+ * @param {Source<number> } signal
98
99
* @param {1 | -1 } [d]
99
100
*/
100
101
function update_version ( signal , d = 1 ) {
101
102
set ( signal , signal . v + d ) ;
102
103
}
103
104
104
- /** @type {ProxyHandler<import('#client'). ProxyStateObject<any>> } */
105
+ /** @type {ProxyHandler<ProxyStateObject<any>> } */
105
106
const state_proxy_handler = {
106
107
defineProperty ( target , prop , descriptor ) {
107
108
if ( descriptor . value ) {
108
- /** @type {import('#client'). ProxyMetadata } */
109
+ /** @type {ProxyMetadata } */
109
110
const metadata = target [ STATE_SYMBOL ] ;
110
111
111
112
const s = metadata . s . get ( prop ) ;
@@ -116,7 +117,7 @@ const state_proxy_handler = {
116
117
} ,
117
118
118
119
deleteProperty ( target , prop ) {
119
- /** @type {import('#client'). ProxyMetadata } */
120
+ /** @type {ProxyMetadata } */
120
121
const metadata = target [ STATE_SYMBOL ] ;
121
122
const s = metadata . s . get ( prop ) ;
122
123
const is_array = metadata . a ;
@@ -149,7 +150,7 @@ const state_proxy_handler = {
149
150
return Reflect . get ( target , STATE_SYMBOL ) ;
150
151
}
151
152
152
- /** @type {import('#client'). ProxyMetadata } */
153
+ /** @type {ProxyMetadata } */
153
154
const metadata = target [ STATE_SYMBOL ] ;
154
155
let s = metadata . s . get ( prop ) ;
155
156
@@ -170,7 +171,7 @@ const state_proxy_handler = {
170
171
getOwnPropertyDescriptor ( target , prop ) {
171
172
const descriptor = Reflect . getOwnPropertyDescriptor ( target , prop ) ;
172
173
if ( descriptor && 'value' in descriptor ) {
173
- /** @type {import('#client'). ProxyMetadata } */
174
+ /** @type {ProxyMetadata } */
174
175
const metadata = target [ STATE_SYMBOL ] ;
175
176
const s = metadata . s . get ( prop ) ;
176
177
@@ -186,7 +187,7 @@ const state_proxy_handler = {
186
187
if ( prop === STATE_SYMBOL ) {
187
188
return true ;
188
189
}
189
- /** @type {import('#client'). ProxyMetadata } */
190
+ /** @type {ProxyMetadata } */
190
191
const metadata = target [ STATE_SYMBOL ] ;
191
192
const has = Reflect . has ( target , prop ) ;
192
193
@@ -208,7 +209,7 @@ const state_proxy_handler = {
208
209
} ,
209
210
210
211
set ( target , prop , value , receiver ) {
211
- /** @type {import('#client'). ProxyMetadata } */
212
+ /** @type {ProxyMetadata } */
212
213
const metadata = target [ STATE_SYMBOL ] ;
213
214
let s = metadata . s . get ( prop ) ;
214
215
// If we haven't yet created a source for this property, we need to ensure
@@ -227,7 +228,7 @@ const state_proxy_handler = {
227
228
const not_has = ! ( prop in target ) ;
228
229
229
230
if ( DEV ) {
230
- /** @type {import('#client'). ProxyMetadata | undefined } */
231
+ /** @type {ProxyMetadata | undefined } */
231
232
const prop_metadata = value ?. [ STATE_SYMBOL ] ;
232
233
if ( prop_metadata && prop_metadata ?. parent !== metadata ) {
233
234
widen_ownership ( metadata , prop_metadata ) ;
@@ -271,7 +272,7 @@ const state_proxy_handler = {
271
272
} ,
272
273
273
274
ownKeys ( target ) {
274
- /** @type {import('#client'). ProxyMetadata } */
275
+ /** @type {ProxyMetadata } */
275
276
const metadata = target [ STATE_SYMBOL ] ;
276
277
277
278
get ( metadata . v ) ;
0 commit comments