Skip to content

chore: use #client alias #10974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/svelte/src/internal/client/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function run_tasks(now) {
/**
* Creates a new task that runs on each raf frame
* until it returns a falsy value or is aborted
* @param {import('./types.js').TaskCallback} callback
* @returns {import('./types.js').Task}
* @param {import('#client').TaskCallback} callback
* @returns {import('#client').Task}
*/
export function loop(callback) {
/** @type {import('./types.js').TaskEntry} */
/** @type {import('#client').TaskEntry} */
let task;

if (raf.tasks.size === 0) {
Expand Down
28 changes: 14 additions & 14 deletions packages/svelte/src/internal/client/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import { UNINITIALIZED } from '../../constants.js';
* @param {T} value
* @param {boolean} [immutable]
* @param {Set<Function> | null} [owners]
* @returns {import('./types.js').ProxyStateObject<T> | T}
* @returns {import('#client').ProxyStateObject<T> | T}
*/
export function proxy(value, immutable = true, owners) {
if (typeof value === 'object' && value != null && !is_frozen(value)) {
// If we have an existing proxy, return it...
if (STATE_SYMBOL in value) {
const metadata = /** @type {import('./types.js').ProxyMetadata<T>} */ (value[STATE_SYMBOL]);
const metadata = /** @type {import('#client').ProxyMetadata<T>} */ (value[STATE_SYMBOL]);
// ...unless the proxy belonged to a different object, because
// someone copied the state symbol using `Reflect.ownKeys(...)`
if (metadata.t === value || metadata.p === value) {
Expand All @@ -53,7 +53,7 @@ export function proxy(value, immutable = true, owners) {
const proxy = new Proxy(value, state_proxy_handler);

define_property(value, STATE_SYMBOL, {
value: /** @type {import('./types.js').ProxyMetadata} */ ({
value: /** @type {import('#client').ProxyMetadata} */ ({
s: new Map(),
v: source(0),
a: is_array(value),
Expand Down Expand Up @@ -86,7 +86,7 @@ export function proxy(value, immutable = true, owners) {
}

/**
* @template {import('./types.js').ProxyStateObject} T
* @template {import('#client').ProxyStateObject} T
* @param {T} value
* @param {Map<T, Record<string | symbol, any>>} already_unwrapped
* @returns {Record<string | symbol, any>}
Expand Down Expand Up @@ -138,23 +138,23 @@ function unwrap(value, already_unwrapped) {
*/
export function unstate(value) {
return /** @type {T} */ (
unwrap(/** @type {import('./types.js').ProxyStateObject} */ (value), new Map())
unwrap(/** @type {import('#client').ProxyStateObject} */ (value), new Map())
);
}

/**
* @param {import('./types.js').Source<number>} signal
* @param {import('#client').Source<number>} signal
* @param {1 | -1} [d]
*/
function update_version(signal, d = 1) {
set(signal, signal.v + d);
}

/** @type {ProxyHandler<import('./types.js').ProxyStateObject<any>>} */
/** @type {ProxyHandler<import('#client').ProxyStateObject<any>>} */
const state_proxy_handler = {
defineProperty(target, prop, descriptor) {
if (descriptor.value) {
/** @type {import('./types.js').ProxyMetadata} */
/** @type {import('#client').ProxyMetadata} */
const metadata = target[STATE_SYMBOL];

const s = metadata.s.get(prop);
Expand All @@ -165,7 +165,7 @@ const state_proxy_handler = {
},

deleteProperty(target, prop) {
/** @type {import('./types.js').ProxyMetadata} */
/** @type {import('#client').ProxyMetadata} */
const metadata = target[STATE_SYMBOL];
const s = metadata.s.get(prop);
const is_array = metadata.a;
Expand Down Expand Up @@ -198,7 +198,7 @@ const state_proxy_handler = {
return Reflect.get(target, STATE_SYMBOL);
}

/** @type {import('./types.js').ProxyMetadata} */
/** @type {import('#client').ProxyMetadata} */
const metadata = target[STATE_SYMBOL];
let s = metadata.s.get(prop);

Expand Down Expand Up @@ -229,7 +229,7 @@ const state_proxy_handler = {
getOwnPropertyDescriptor(target, prop) {
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
if (descriptor && 'value' in descriptor) {
/** @type {import('./types.js').ProxyMetadata} */
/** @type {import('#client').ProxyMetadata} */
const metadata = target[STATE_SYMBOL];
const s = metadata.s.get(prop);

Expand All @@ -245,7 +245,7 @@ const state_proxy_handler = {
if (prop === STATE_SYMBOL) {
return true;
}
/** @type {import('./types.js').ProxyMetadata} */
/** @type {import('#client').ProxyMetadata} */
const metadata = target[STATE_SYMBOL];
const has = Reflect.has(target, prop);

Expand All @@ -266,7 +266,7 @@ const state_proxy_handler = {
},

set(target, prop, value, receiver) {
/** @type {import('./types.js').ProxyMetadata} */
/** @type {import('#client').ProxyMetadata} */
const metadata = target[STATE_SYMBOL];
let s = metadata.s.get(prop);
// If we haven't yet created a source for this property, we need to ensure
Expand Down Expand Up @@ -329,7 +329,7 @@ const state_proxy_handler = {
},

ownKeys(target) {
/** @type {import('./types.js').ProxyMetadata} */
/** @type {import('#client').ProxyMetadata} */
const metadata = target[STATE_SYMBOL];

get(metadata.v);
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/client/timing.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const request_animation_frame = is_client ? requestAnimationFrame : noop;

const now = is_client ? () => performance.now() : () => Date.now();

/** @type {import('./types.js').Raf} */
/** @type {import('#client').Raf} */
export const raf = {
tick: /** @param {any} _ */ (_) => request_animation_frame(_),
now: () => now(),
Expand Down