Skip to content

Commit e361a20

Browse files
committed
move code to new module
1 parent 442334f commit e361a20

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

packages/svelte/src/index-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ export async function tick() {}
3636

3737
export { getAllContexts, getContext, hasContext, setContext } from './internal/server/context.js';
3838

39-
export { createRawSnippet } from './internal/server/index.js';
39+
export { createRawSnippet } from './internal/server/blocks/snippet.js';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/** @import { Payload } from '#server' */
2+
import { add_snippet_symbol } from '../../shared/validate.js';
3+
import * as e from '../errors.js';
4+
5+
/**
6+
* Create a snippet imperatively using mount, hyrdate and render functions.
7+
* @param {{
8+
* mount?: (...params: any[]) => Element,
9+
* hydrate?: (element: Element, ...params: any[]) => void,
10+
* render?: (...params: any[]) => string
11+
* }} options
12+
*/
13+
export function createRawSnippet({ render }) {
14+
if (render === undefined) {
15+
e.snippet_missing_render();
16+
}
17+
18+
const snippet_fn = (/** @type {Payload} */ payload, /** @type {any[]} */ ...args) => {
19+
payload.out += render(...args);
20+
};
21+
add_snippet_symbol(snippet_fn);
22+
return snippet_fn;
23+
}

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import { escape_html } from '../../escaping.js';
1313
import { DEV } from 'esm-env';
1414
import { current_component, pop, push } from './context.js';
1515
import { EMPTY_COMMENT, BLOCK_CLOSE, BLOCK_OPEN } from './hydration.js';
16-
import { add_snippet_symbol, validate_store } from '../shared/validate.js';
17-
import * as e from './errors.js';
16+
import { validate_store } from '../shared/validate.js';
1817

1918
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
2019
// https://infra.spec.whatwg.org/#noncharacter
@@ -156,26 +155,6 @@ export function head(payload, fn) {
156155
head_payload.out += BLOCK_CLOSE;
157156
}
158157

159-
/**
160-
* Create a snippet imperatively using mount, hyrdate and render functions.
161-
* @param {{
162-
* mount?: (...params: any[]) => Element,
163-
* hydrate?: (element: Element, ...params: any[]) => void,
164-
* render?: (...params: any[]) => string
165-
* }} options
166-
*/
167-
export function createRawSnippet({ render }) {
168-
if (render === undefined) {
169-
e.snippet_missing_render();
170-
}
171-
172-
const snippet_fn = (/** @type {Payload} */ payload, /** @type {any[]} */ ...args) => {
173-
payload.out += render(...args);
174-
};
175-
add_snippet_symbol(snippet_fn);
176-
return snippet_fn;
177-
}
178-
179158
/**
180159
* @template V
181160
* @param {string} name

0 commit comments

Comments
 (0)