Skip to content

Commit 256e609

Browse files
authored
chore: remove some junk (#12372)
1 parent 27c5440 commit 256e609

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

packages/svelte/src/internal/server/index.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** @import { Component, Payload, RenderOutput } from '#server' */
2+
/** @import { Store } from '#shared' */
13
import { is_promise, noop } from '../shared/utils.js';
24
import { subscribe_to_store } from '../../store/utils.js';
35
import {
@@ -37,36 +39,33 @@ export const VoidElements = new Set([
3739
'wbr'
3840
]);
3941

40-
/** @returns {import('#server').Payload} */
41-
function create_payload() {
42-
return { out: '', head: { title: '', out: '', anchor: 0 }, anchor: 0 };
43-
}
44-
4542
/**
46-
* @param {import('#server').Payload} to_copy
47-
* @returns {import('#server').Payload}
43+
* @param {Payload} to_copy
44+
* @returns {Payload}
4845
*/
49-
export function copy_payload(to_copy) {
46+
export function copy_payload({ out, head }) {
5047
return {
51-
...to_copy,
52-
head: { ...to_copy.head }
48+
out,
49+
head: {
50+
title: head.title,
51+
out: head.out
52+
}
5353
};
5454
}
5555

5656
/**
5757
* Assigns second payload to first
58-
* @param {import('#server').Payload} p1
59-
* @param {import('#server').Payload} p2
58+
* @param {Payload} p1
59+
* @param {Payload} p2
6060
* @returns {void}
6161
*/
6262
export function assign_payload(p1, p2) {
6363
p1.out = p2.out;
6464
p1.head = p2.head;
65-
p1.anchor = p2.anchor;
6665
}
6766

6867
/**
69-
* @param {import('#server').Payload} payload
68+
* @param {Payload} payload
7069
* @param {string} tag
7170
* @param {() => void} attributes_fn
7271
* @param {() => void} children_fn
@@ -104,18 +103,19 @@ export let on_destroy = [];
104103
* @template {Record<string, any>} Props
105104
* @param {import('svelte').Component<Props> | import('svelte').ComponentType<import('svelte').SvelteComponent<Props>>} component
106105
* @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any> }} [options]
107-
* @returns {import('#server').RenderOutput}
106+
* @returns {RenderOutput}
108107
*/
109108
export function render(component, options = {}) {
110-
const payload = create_payload();
109+
/** @type {Payload} */
110+
const payload = { out: '', head: { title: '', out: '' } };
111111

112112
const prev_on_destroy = on_destroy;
113113
on_destroy = [];
114114
payload.out += BLOCK_OPEN;
115115

116116
if (options.context) {
117117
push();
118-
/** @type {import('#server').Component} */ (current_component).c = options.context;
118+
/** @type {Component} */ (current_component).c = options.context;
119119
}
120120

121121
// @ts-expect-error
@@ -137,8 +137,8 @@ export function render(component, options = {}) {
137137
}
138138

139139
/**
140-
* @param {import('#server').Payload} payload
141-
* @param {(head_payload: import('#server').Payload['head']) => void} fn
140+
* @param {Payload} payload
141+
* @param {(head_payload: Payload['head']) => void} fn
142142
* @returns {void}
143143
*/
144144
export function head(payload, fn) {
@@ -162,7 +162,7 @@ export function attr(name, value, is_boolean = false) {
162162
}
163163

164164
/**
165-
* @param {import('#server').Payload} payload
165+
* @param {Payload} payload
166166
* @param {boolean} is_html
167167
* @param {Record<string, string>} props
168168
* @param {() => void} component
@@ -309,7 +309,7 @@ export function merge_styles(attribute, styles) {
309309
* @template V
310310
* @param {Record<string, [any, any, any]>} store_values
311311
* @param {string} store_name
312-
* @param {import('#shared').Store<V> | null | undefined} store
312+
* @param {Store<V> | null | undefined} store
313313
* @returns {V}
314314
*/
315315
export function store_get(store_values, store_name, store) {
@@ -336,7 +336,7 @@ export function store_get(store_values, store_name, store) {
336336
/**
337337
* Sets the new value of a store and returns that value.
338338
* @template V
339-
* @param {import('#shared').Store<V>} store
339+
* @param {Store<V>} store
340340
* @param {V} value
341341
* @returns {V}
342342
*/
@@ -350,7 +350,7 @@ export function store_set(store, value) {
350350
* @template V
351351
* @param {Record<string, [any, any, any]>} store_values
352352
* @param {string} store_name
353-
* @param {import('#shared').Store<V>} store
353+
* @param {Store<V>} store
354354
* @param {any} expression
355355
*/
356356
export function mutate_store(store_values, store_name, store, expression) {
@@ -361,7 +361,7 @@ export function mutate_store(store_values, store_name, store, expression) {
361361
/**
362362
* @param {Record<string, [any, any, any]>} store_values
363363
* @param {string} store_name
364-
* @param {import('#shared').Store<number>} store
364+
* @param {Store<number>} store
365365
* @param {1 | -1} [d]
366366
* @returns {number}
367367
*/
@@ -374,7 +374,7 @@ export function update_store(store_values, store_name, store, d = 1) {
374374
/**
375375
* @param {Record<string, [any, any, any]>} store_values
376376
* @param {string} store_name
377-
* @param {import('#shared').Store<number>} store
377+
* @param {Store<number>} store
378378
* @param {1 | -1} [d]
379379
* @returns {number}
380380
*/
@@ -412,8 +412,8 @@ export async function value_or_fallback_async(value, fallback) {
412412
}
413413

414414
/**
415-
* @param {import('#server').Payload} payload
416-
* @param {void | ((payload: import('#server').Payload, props: Record<string, unknown>) => void)} slot_fn
415+
* @param {Payload} payload
416+
* @param {void | ((payload: Payload, props: Record<string, unknown>) => void)} slot_fn
417417
* @param {Record<string, unknown>} slot_props
418418
* @param {null | (() => void)} fallback_fn
419419
* @returns {void}

packages/svelte/src/internal/server/types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ export interface Component {
1313

1414
export interface Payload {
1515
out: string;
16-
anchor: number;
1716
head: {
1817
title: string;
1918
out: string;
20-
anchor: number;
2119
};
2220
}
2321

0 commit comments

Comments
 (0)