From ef978ce87e9ea0804480ca0fa514626041a36661 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 26 Jul 2024 20:32:29 -0400 Subject: [PATCH] rename link_state to linked_state for grammatical consistency --- .../src/compiler/phases/2-analyze/index.js | 6 ++-- .../compiler/phases/2-analyze/validation.js | 4 +-- .../phases/3-transform/client/types.d.ts | 2 +- .../phases/3-transform/client/utils.js | 10 +++--- .../3-transform/client/visitors/global.js | 4 +-- .../client/visitors/javascript-runes.js | 8 ++--- packages/svelte/src/compiler/types/index.d.ts | 2 +- packages/svelte/types/index.d.ts | 36 +++++++++---------- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index 37ff04573a..67efa28f68 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -927,7 +927,7 @@ const runes_scope_js_tweaker = { rune === '$state' ? 'state' : rune === '$state.link' - ? 'link_state' + ? 'linked_state' : rune === '$state.frozen' ? 'frozen_state' : 'derived'; @@ -973,7 +973,7 @@ const runes_scope_tweaker = { : rune === '$state.frozen' ? 'frozen_state' : rune === '$state.link' - ? 'link_state' + ? 'linked_state' : rune === '$derived' || rune === '$derived.by' ? 'derived' : path.is_rest @@ -1288,7 +1288,7 @@ const common_visitors = { context.state.function_depth === binding.scope.function_depth && // If we have $state that can be proxied or frozen and isn't re-assigned, then that means // it's likely not using a primitive value and thus this warning isn't that helpful. - (((binding.kind === 'state' || binding.kind === 'link_state') && + (((binding.kind === 'state' || binding.kind === 'linked_state') && (binding.reassigned || (binding.initial?.type === 'CallExpression' && binding.initial.arguments.length === 1 && diff --git a/packages/svelte/src/compiler/phases/2-analyze/validation.js b/packages/svelte/src/compiler/phases/2-analyze/validation.js index 734ea338a9..1d062bcab0 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/validation.js +++ b/packages/svelte/src/compiler/phases/2-analyze/validation.js @@ -395,7 +395,7 @@ const validation = { !binding || (binding.kind !== 'state' && binding.kind !== 'frozen_state' && - binding.kind !== 'link_state' && + binding.kind !== 'linked_state' && binding.kind !== 'prop' && binding.kind !== 'bindable_prop' && binding.kind !== 'each' && @@ -878,7 +878,7 @@ function validate_export(node, scope, name) { if ( (binding.kind === 'state' || binding.kind === 'frozen_state' || - binding.kind === 'link_state') && + binding.kind === 'linked_state') && binding.reassigned ) { e.state_invalid_export(node); diff --git a/packages/svelte/src/compiler/phases/3-transform/client/types.d.ts b/packages/svelte/src/compiler/phases/3-transform/client/types.d.ts index 0a62520270..9e3c2aa76b 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/types.d.ts +++ b/packages/svelte/src/compiler/phases/3-transform/client/types.d.ts @@ -73,7 +73,7 @@ export interface ComponentClientTransformState extends ClientTransformState { } export interface StateField { - kind: 'state' | 'frozen_state' | 'link_state' | 'derived' | 'derived_call'; + kind: 'state' | 'frozen_state' | 'linked_state' | 'derived' | 'derived_call'; id: PrivateIdentifier; } diff --git a/packages/svelte/src/compiler/phases/3-transform/client/utils.js b/packages/svelte/src/compiler/phases/3-transform/client/utils.js index 793a471489..1ebe80f225 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/utils.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/utils.js @@ -105,7 +105,7 @@ export function serialize_get_binding(node, state) { return b.member(b.id('$$props'), node); } - if (binding.kind === 'link_state') { + if (binding.kind === 'linked_state') { return b.call(node); } @@ -291,7 +291,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) if ( binding.kind !== 'state' && binding.kind !== 'frozen_state' && - binding.kind !== 'link_state' && + binding.kind !== 'linked_state' && binding.kind !== 'prop' && binding.kind !== 'bindable_prop' && binding.kind !== 'each' && @@ -312,7 +312,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) if ( (binding.kind === 'prop' || binding.kind === 'bindable_prop' || - binding.kind === 'link_state') && + binding.kind === 'linked_state') && !is_initial_proxy ) { return b.call(left, value); @@ -343,7 +343,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) } else if ( (binding.kind === 'prop' || binding.kind === 'bindable_prop' || - binding.kind === 'link_state') && + binding.kind === 'linked_state') && is_initial_proxy ) { call = b.call( @@ -351,7 +351,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) context.state.analysis.runes && !options?.skip_proxy_and_freeze && should_proxy_or_freeze(value, context.state.scope) && - (binding.kind === 'bindable_prop' || binding.kind === 'link_state') + (binding.kind === 'bindable_prop' || binding.kind === 'linked_state') ? serialize_proxy_reassignment(value, left_name, state) : value ); diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js index c9ea7053b3..7d22936681 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js @@ -70,7 +70,7 @@ export const global_visitors = { if ( binding?.kind === 'state' || binding?.kind === 'frozen_state' || - binding?.kind === 'link_state' || + binding?.kind === 'linked_state' || binding?.kind === 'each' || binding?.kind === 'legacy_reactive' || binding?.kind === 'prop' || @@ -88,7 +88,7 @@ export const global_visitors = { args.push(serialize_get_binding(b.id(name), state), b.call('$' + name)); } else { if (binding.kind === 'prop' || binding.kind === 'bindable_prop') fn += '_prop'; - if (binding.kind === 'link_state') fn += '_link'; + if (binding.kind === 'linked_state') fn += '_link'; args.push(b.id(name)); } diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js index 2a43cdf09c..f50f48bf20 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js @@ -58,7 +58,7 @@ export const javascript_visitors_runes = { : rune === '$state.frozen' ? 'frozen_state' : rune === '$state.link' - ? 'link_state' + ? 'linked_state' : rune === '$derived.by' ? 'derived_call' : 'derived', @@ -120,7 +120,7 @@ export const javascript_visitors_runes = { '$.source', should_proxy_or_freeze(init, state.scope) ? b.call('$.proxy', init) : init ) - : field.kind === 'link_state' + : field.kind === 'linked_state' ? b.call( '$.source_link', should_proxy_or_freeze(init, state.scope) @@ -147,7 +147,7 @@ export const javascript_visitors_runes = { const member = b.member(b.this, field.id); body.push(b.prop_def(field.id, value)); - if (field.kind === 'link_state') { + if (field.kind === 'linked_state') { // get foo() { return this.#foo; } body.push(b.method('get', definition.key, [], [b.return(b.call(member))])); @@ -344,7 +344,7 @@ export const javascript_visitors_runes = { value ); } - if (binding.kind === 'link_state') { + if (binding.kind === 'linked_state') { return b.call('$.source_link', b.thunk(value)); } if (is_state_source(binding, state)) { diff --git a/packages/svelte/src/compiler/types/index.d.ts b/packages/svelte/src/compiler/types/index.d.ts index d10761c05d..7e6eb30696 100644 --- a/packages/svelte/src/compiler/types/index.d.ts +++ b/packages/svelte/src/compiler/types/index.d.ts @@ -280,7 +280,7 @@ export interface Binding { | 'rest_prop' | 'state' | 'frozen_state' - | 'link_state' + | 'linked_state' | 'derived' | 'each' | 'snippet' diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts index 58fc05dcc7..895bcb064e 100644 --- a/packages/svelte/types/index.d.ts +++ b/packages/svelte/types/index.d.ts @@ -930,7 +930,7 @@ declare module 'svelte/compiler' { | 'rest_prop' | 'state' | 'frozen_state' - | 'link_state' + | 'linked_state' | 'derived' | 'each' | 'snippet' @@ -1239,9 +1239,9 @@ declare module 'svelte/compiler' { | LegacyCssNode | Text; class Scope { - + constructor(root: ScopeRoot, parent: Scope | null, porous: boolean); - + root: ScopeRoot; /** * The immediate parent scope @@ -1269,25 +1269,25 @@ declare module 'svelte/compiler' { * which is usually an error. Block statements do not increase this value */ function_depth: number; - + declare(node: Identifier, kind: Binding["kind"], declaration_kind: DeclarationKind, initial?: null | Expression | FunctionDeclaration | ClassDeclaration | ImportDeclaration | EachBlock): Binding; child(porous?: boolean): Scope; - + generate(preferred_name: string): string; - + get(name: string): Binding | null; - + get_bindings(node: VariableDeclarator | LetDirective): Binding[]; - + owner(name: string): Scope | null; - + reference(node: Identifier, path: SvelteNode[]): void; #private; } class ScopeRoot { - + conflicts: Set; - + unique(preferred_name: string): Identifier; } namespace Css { @@ -2188,21 +2188,21 @@ declare module 'svelte/reactivity' { /** @deprecated Use `SvelteURLSearchParams` instead */ function URLSearchParams_1(): void; export class SvelteDate extends Date { - + constructor(...params: any[]); #private; } export class SvelteSet extends Set { - + constructor(value?: Iterable | null | undefined); - + add(value: T): this; #private; } export class SvelteMap extends Map { - + constructor(value?: Iterable | null | undefined); - + set(key: K, value: V): this; #private; } @@ -2212,7 +2212,7 @@ declare module 'svelte/reactivity' { } const REPLACE: unique symbol; export class SvelteURLSearchParams extends URLSearchParams { - + [REPLACE](params: URLSearchParams): void; #private; } @@ -3212,4 +3212,4 @@ declare function $inspect( */ declare function $host(): El; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file +//# sourceMappingURL=index.d.ts.map