Skip to content
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

Sverdle #6979

Merged
merged 50 commits into from
Sep 28, 2022
Merged

Sverdle #6979

Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0895100
WIP sverdle
Rich-Harris Sep 22, 2022
ec351ad
small fixes
Rich-Harris Sep 23, 2022
d9f36e5
fix some tests
Rich-Harris Sep 26, 2022
1b3b48c
tweak global styles
Rich-Harris Sep 26, 2022
e5a761e
Merge branch 'master' into sverdle
Rich-Harris Sep 26, 2022
f1c8d67
remove unused rule
Rich-Harris Sep 26, 2022
8ba3e6b
rename global.css to styles.css for a more pleasing lexical ordering
Rich-Harris Sep 26, 2022
432578d
add github logo
Rich-Harris Sep 26, 2022
88cd07c
fix link
Rich-Harris Sep 26, 2022
d851e42
fix keyboard logic
Rich-Harris Sep 26, 2022
f4d4ef8
remove info box
Rich-Harris Sep 26, 2022
9b54d5c
gussy it up a bit
Rich-Harris Sep 26, 2022
05b6372
simplify
Rich-Harris Sep 26, 2022
829fac4
tweaks
Rich-Harris Sep 26, 2022
866972b
tweak
Rich-Harris Sep 26, 2022
3f30e1d
fix broken logic
Rich-Harris Sep 26, 2022
8851705
simplify
Rich-Harris Sep 26, 2022
d89ae3a
remove logging
Rich-Harris Sep 26, 2022
6bd1a49
use CSS vars
Rich-Harris Sep 26, 2022
0b55782
.js files should be .ts
Rich-Harris Sep 26, 2022
b2526d1
work around bugs and annoyances
Rich-Harris Sep 26, 2022
77ecc49
fix
Rich-Harris Sep 26, 2022
b37e6a3
rename r and c to row and column
Rich-Harris Sep 27, 2022
b01092c
Merge branch 'master' into sverdle
Rich-Harris Sep 27, 2022
f51034b
add the ability to preserve JSDoc comment descriptions when convertin…
Rich-Harris Sep 27, 2022
66dfcdc
calculate classnames in Keyboard.svelte, change name to make it clear…
Rich-Harris Sep 27, 2022
edc0102
simplify confetti
Rich-Harris Sep 27, 2022
d45d139
remove unnecessary initialiser
Rich-Harris Sep 27, 2022
f9c7f2d
small tweak
Rich-Harris Sep 27, 2022
b8965ed
add some comments etc
Rich-Harris Sep 27, 2022
cf0b94a
consolidate logic
Rich-Harris Sep 27, 2022
bfbeb74
tweaks
Rich-Harris Sep 27, 2022
fb6b510
move game logic into +page.server.ts
Rich-Harris Sep 27, 2022
f8b3226
make more self-contained
Rich-Harris Sep 27, 2022
e32d886
add some more comments
Rich-Harris Sep 27, 2022
287f223
prevent cmd-r flashing an r
Rich-Harris Sep 27, 2022
c7b60a3
reveal answer
Rich-Harris Sep 27, 2022
79efdaa
lol whoops
Rich-Harris Sep 27, 2022
b142003
tweaks
Rich-Harris Sep 27, 2022
1b73d0e
tweak
Rich-Harris Sep 27, 2022
975aee3
add some more descriptions
Rich-Harris Sep 27, 2022
97f6cc2
safari tweaks
Rich-Harris Sep 27, 2022
fed2740
remove unused static assets
Rich-Harris Sep 28, 2022
eb29141
put data-sveltekit-prefetch on <body>
Rich-Harris Sep 28, 2022
7cadf2a
fix windows test assertion
ignatiusmb Sep 28, 2022
51e29f3
finesse output
Rich-Harris Sep 28, 2022
6f3c5ee
Merge branch 'sverdle' of github.com:sveltejs/kit into sverdle
Rich-Harris Sep 28, 2022
321a6eb
tweaks
Rich-Harris Sep 28, 2022
a1eb420
add instructions, make some style tweaks
Rich-Harris Sep 28, 2022
ecc109d
tweak how-to-play
Rich-Harris Sep 28, 2022
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
5 changes: 5 additions & 0 deletions .changeset/chatty-years-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Replace /todos page in demo app with /sverdle
36 changes: 30 additions & 6 deletions packages/create-svelte/scripts/build-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ import { mkdirp, rimraf } from '../utils.js';

/** @param {string} content */
function convert_typescript(content) {
const transformed = transform(content, {
transforms: ['typescript']
let { code } = transform(content, {
transforms: ['typescript'],
disableESTransforms: true
});

return prettier.format(transformed.code, {
// sucrase leaves invalid class fields intact
code = code.replace(/^\s*[a-z]+;$/gm, '');

// Prettier strips 'unnecessary' parens from .ts files, we need to hack them back in
code = code.replace(/(\/\*\* @type.+? \*\/) (.+?) \/\*\*\*\//g, '$1($2)');

return prettier.format(code, {
Copy link
Member

@dummdidumm dummdidumm Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember having the same problem in prettier-plugin-svelte (the parentheses thing) when using the typescript parser (sveltejs/prettier-plugin-svelte#218), using the babel-ts parser fixed it. I wonder though why it doesn't work in this case, because the formatter uses the babel parser, which I would have expected to be a JS parser which should keep the parentheses. Maybe babel-ts is worth a try?

parser: 'babel',
useTabs: true,
singleQuote: true,
Expand All @@ -23,22 +30,38 @@ function convert_typescript(content) {

/** @param {string} content */
function strip_jsdoc(content) {
return content.replace(/\/\*\*[\s\S]+?\*\/[\s\n]+/g, '');
return content
.replace(/\/\*\*\*\//g, '')
.replace(
/\/\*\*([\s\S]+?)(@[\s\S]+?)?\*\/([\s\n]+)/g,
(match, description, tags, whitespace) => {
if (/^\s+(\*\s*)?$/.test(description)) {
return '';
}

return `/**${description.replace(/\*\ $/, '')}*/${whitespace}`;
}
);
}

/** @param {Set<string>} shared */
async function generate_templates(shared) {
const templates = fs.readdirSync('templates');

for (const template of templates) {
if (template[0] === '.') continue;

const dir = `dist/templates/${template}`;
const assets = `${dir}/assets`;
mkdirp(assets);

const cwd = path.resolve('templates', template);

const gitignore_file = path.join(cwd, '.gitignore');
if (!fs.existsSync(gitignore_file)) throw new Error('Template must have a .gitignore file');
if (!fs.existsSync(gitignore_file)) {
throw new Error(`"${template}" template must have a .gitignore file`);
}

const gitignore = parser.compile(fs.readFileSync(gitignore_file, 'utf-8'));

const ignore_file = path.join(cwd, '.ignore');
Expand Down Expand Up @@ -122,7 +145,8 @@ async function generate_templates(shared) {
const suffix = `\n${imports.join(',')}`;

const transformed = transform(typescript + suffix, {
transforms: ['typescript']
transforms: ['typescript'],
disableESTransforms: true
}).code.slice(0, -suffix.length);

const contents = prettier
Expand Down
5 changes: 2 additions & 3 deletions packages/create-svelte/templates/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"preview": "vite preview"
},
"devDependencies": {
"@neoconfetti/svelte": "^1.0.0",
"@sveltejs/adapter-auto": "workspace:*",
"@sveltejs/kit": "workspace:*",
"svelte": "^3.48.0",
Expand All @@ -17,8 +18,6 @@
},
"type": "module",
"dependencies": {
"@fontsource/fira-mono": "^4.5.8",
"@lukeed/uuid": "^2.0.0",
"cookie": "^0.5.0"
"@fontsource/fira-mono": "^4.5.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
"preview": "vite preview"
},
"devDependencies": {
"@fontsource/fira-mono": "^4.5.0",
"@neoconfetti/svelte": "^1.0.0",
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "next",
"svelte": "^3.46.0",
"vite": "^3.1.0"
},
"type": "module",
"dependencies": {
"@fontsource/fira-mono": "^4.5.0"
}
"type": "module"
}
107 changes: 0 additions & 107 deletions packages/create-svelte/templates/default/src/app.css

This file was deleted.

12 changes: 1 addition & 11 deletions packages/create-svelte/templates/default/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
interface Locals {
userid: string;
}

// interface PageData {}

// interface Error {}

// interface Platform {}
}
declare namespace App {}
2 changes: 1 addition & 1 deletion packages/create-svelte/templates/default/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body>
<body data-sveltekit-prefetch>
<div>%sveltekit.body%</div>
</body>
</html>
17 changes: 0 additions & 17 deletions packages/create-svelte/templates/default/src/hooks.server.ts

This file was deleted.

16 changes: 16 additions & 0 deletions packages/create-svelte/templates/default/src/lib/images/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 20 additions & 12 deletions packages/create-svelte/templates/default/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
<script lang="ts">
import Header from '$lib/header/Header.svelte';
import '../app.css';
<script>
import Header from './Header.svelte';
import './styles.css';
</script>

<Header />
<div class="app">
<Header />

<main>
<slot />
</main>
<main>
<slot />
</main>

<footer>
<p>visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to learn SvelteKit</p>
</footer>
<footer>
<p>visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to learn SvelteKit</p>
</footer>
</div>

<style>
.app {
display: flex;
flex-direction: column;
min-height: 100vh;
}

main {
flex: 1;
display: flex;
Expand All @@ -30,7 +38,7 @@
flex-direction: column;
justify-content: center;
align-items: center;
padding: 40px;
padding: 12px;
}

footer a {
Expand All @@ -39,7 +47,7 @@

@media (min-width: 480px) {
footer {
padding: 40px 0;
padding: 12px 0;
}
}
</style>
12 changes: 7 additions & 5 deletions packages/create-svelte/templates/default/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script lang="ts">
import Counter from '$lib/Counter.svelte';
<script>
import Counter from './Counter.svelte';
import welcome from '$lib/images/svelte-welcome.webp';
import welcome_fallback from '$lib/images/svelte-welcome.png';
</script>

<svelte:head>
Expand All @@ -11,8 +13,8 @@
<h1>
<span class="welcome">
<picture>
<source srcset="svelte-welcome.webp" type="image/webp" />
<img src="svelte-welcome.png" alt="Welcome" />
<source srcset={welcome} type="image/webp" />
<img src={welcome_fallback} alt="Welcome" />
</picture>
</span>

Expand All @@ -32,7 +34,7 @@
flex-direction: column;
justify-content: center;
align-items: center;
flex: 1;
flex: 0.6;
}

h1 {
Expand Down
Loading