Skip to content

Commit d6ab3d8

Browse files
committed
Revert "fix"
This reverts commit 03c62c9.
1 parent 9338774 commit d6ab3d8

File tree

4 files changed

+29
-1124
lines changed

4 files changed

+29
-1124
lines changed

apps/svelte.dev/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,15 @@
4747
"yootils": "^0.3.1"
4848
},
4949
"devDependencies": {
50-
"@cloudflare/workers-types": "^4.20250620.0",
50+
"@cloudflare/workers-types": "^4.20241127.0",
5151
"@resvg/resvg-js": "^2.6.2",
5252
"@supabase/supabase-js": "^2.43.4",
53-
"@sveltejs/adapter-cloudflare": "^7.0.4",
54-
"@sveltejs/adapter-netlify": "^5.0.2",
55-
"@sveltejs/adapter-node": "^5.2.12",
56-
"@sveltejs/adapter-static": "^3.0.8",
5753
"@sveltejs/adapter-vercel": "^5.7.0",
5854
"@sveltejs/enhanced-img": "^0.4.3",
5955
"@sveltejs/kit": "^2.20.0",
6056
"@sveltejs/site-kit": "workspace:*",
6157
"@sveltejs/vite-plugin-svelte": "4.0.3",
6258
"@types/cookie": "^0.6.0",
63-
"@types/express": "^5.0.3",
6459
"@types/node": "^20.14.2",
6560
"browserslist": "^4.24.2",
6661
"chokidar": "^4.0.1",

apps/svelte.dev/src/lib/server/renderer.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ export const render_content = (
77
) => {
88
return render_content_markdown(filename, body, options, (filename, source) => {
99
// TODO these are copied from Svelte and SvelteKit - adjust for new filenames
10-
const injected: string[] = [];
10+
const injected = [];
11+
12+
if (/(svelte)/.test(source) || filename.includes('typescript')) {
13+
injected.push(`// @filename: ambient.d.ts`, `/// <reference types="svelte" />`);
14+
}
1115

1216
if (filename.includes('svelte-compiler')) {
1317
injected.push('// @esModuleInterop');
@@ -18,7 +22,7 @@ export const render_content = (
1822
}
1923

2024
// Actions JSDoc examples are invalid. Too many errors, edge cases
21-
// TODO: d.ts files are not properly supported right now, fix this later
25+
// d.ts files are not properly supported right now, fix this later
2226
if (filename.includes('svelte-action') || source.includes(' declare const ')) {
2327
injected.push('// @noErrors');
2428
}
@@ -27,11 +31,10 @@ export const render_content = (
2731
injected.push('// @errors: 2304');
2832
}
2933

30-
// twoslash doesn't recognise these as SvelteKit imports, so we need to
31-
// explicitly reference the types in these instances
3234
if (
3335
source.includes('$app/') ||
34-
source.includes('$service-worker')
36+
source.includes('$service-worker') ||
37+
source.includes('@sveltejs/kit/')
3538
) {
3639
injected.push(`// @filename: ambient-kit.d.ts`, `/// <reference types="@sveltejs/kit" />`);
3740
}
@@ -40,11 +43,10 @@ export const render_content = (
4043
// TODO we're hardcoding static env vars that are used in code examples
4144
// in the types, which isn't... totally ideal, but will do for now
4245
injected.push(
43-
`declare module '$env/dynamic/private' { export const env: Record<string, string>; }`,
44-
`declare module '$env/dynamic/public' { export const env: Record<string, string>; }`,
45-
// TODO: detect when a snippet imports from $env/static then generate the types on the fly
46-
`declare module '$env/static/private' { export const API_KEY: string; export const BYPASS_TOKEN: string; export const VERCEL_COMMIT_REF: string; }`,
47-
`declare module '$env/static/public' { export const PUBLIC_BASE_URL: string; }`
46+
`declare module '$env/dynamic/private' { export const env: Record<string, string> }`,
47+
`declare module '$env/dynamic/public' { export const env: Record<string, string> }`,
48+
`declare module '$env/static/private' { export const API_KEY: string }`,
49+
`declare module '$env/static/public' { export const PUBLIC_BASE_URL: string }`
4850
);
4951
}
5052

@@ -69,6 +71,10 @@ export const render_content = (
6971
injected.push('// @errors: 7006 7031');
7072
}
7173

74+
if (filename.endsWith('10-configuration.md')) {
75+
injected.push('// @errors: 2307');
76+
}
77+
7278
// another special case
7379
if (source.includes('$lib/types')) {
7480
injected.push(`declare module '$lib/types' { export interface User {} }`);

packages/site-kit/src/lib/markdown/renderer.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ const highlighter = await createHighlighterCore({
5454
import('@shikijs/langs/css'),
5555
import('@shikijs/langs/bash'),
5656
import('@shikijs/langs/yaml'),
57-
import('@shikijs/langs/toml'),
5857
import('@shikijs/langs/svelte')
5958
],
6059
engine: createOnigurumaEngine(import('shiki/wasm'))
@@ -235,14 +234,7 @@ export async function render_content_markdown(
235234

236235
if ((token.lang === 'js' || token.lang === 'ts') && check) {
237236
const match = /((?:[\s\S]+)\/\/ ---cut---\n)?([\s\S]+)/.exec(source)!;
238-
// we need to ensure that the source content is separated from the
239-
// injected content by a '// @filename: ...' otherwise it will be
240-
// interpreted as the same file and prevent types from working
241-
[
242-
,
243-
prelude = `${source.includes('// @filename:') ? '' : '// @filename: dummy.' + token.lang}\n// ---cut---\n`,
244-
source
245-
] = match;
237+
[, prelude = '// ---cut---\n', source] = match;
246238

247239
const banner = twoslashBanner?.(filename, source);
248240
if (banner) prelude = '// @filename: injected.d.ts\n' + banner + '\n' + prelude;
@@ -765,7 +757,7 @@ async function syntax_highlight({
765757
/** We need to stash code wrapped in `---` highlights, because otherwise TS will error on e.g. bad syntax, duplicate declarations */
766758
const redactions: string[] = [];
767759

768-
let redacted = source.replace(/( {13}(?:[^ ][^]+?) {13})/g, (_, content) => {
760+
const redacted = source.replace(/( {13}(?:[^ ][^]+?) {13})/g, (_, content) => {
769761
redactions.push(content);
770762
return ' '.repeat(content.length);
771763
});
@@ -781,9 +773,7 @@ async function syntax_highlight({
781773
compilerOptions: {
782774
allowJs: true,
783775
checkJs: true,
784-
// we always include the Svelte types because it's easier
785-
// than adding a reference when we detect a rune being used
786-
types: ['node', 'svelte']
776+
types: ['svelte', '@sveltejs/kit']
787777
}
788778
},
789779
// by default, twoslash does not run on .js files, change that through this option
@@ -870,7 +860,7 @@ async function syntax_highlight({
870860
html = replace_blank_lines(html);
871861
} else {
872862
const highlighted = highlighter.codeToHtml(source, {
873-
lang: SHIKI_LANGUAGE_MAP[language as keyof typeof SHIKI_LANGUAGE_MAP] ?? language,
863+
lang: SHIKI_LANGUAGE_MAP[language as keyof typeof SHIKI_LANGUAGE_MAP],
874864
theme
875865
});
876866

@@ -894,7 +884,6 @@ async function syntax_highlight({
894884
.replace(/ {11}([^ ][^]+?) {11}/g, (_, content) => {
895885
return highlight_spans(content, 'highlight add');
896886
})
897-
// TODO: make this not highlight the static adapter's github yaml deploy file
898887
.replace(/ {9}([^ ][^]+?) {9}/g, (_, content) => {
899888
return highlight_spans(content, 'highlight');
900889
});

0 commit comments

Comments
 (0)