Inital commit
This commit is contained in:
commit
7193d876db
15 changed files with 1677 additions and 0 deletions
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
48
README.md
Normal file
48
README.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Svelte + Vite
|
||||
|
||||
This template should help get you started developing with Svelte in Vite.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
|
||||
|
||||
## Need an official Svelte framework?
|
||||
|
||||
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
|
||||
|
||||
## Technical considerations
|
||||
|
||||
**Why use this over SvelteKit?**
|
||||
|
||||
- It brings its own routing solution which might not be preferable for some users.
|
||||
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
|
||||
`vite dev` and `vite build` wouldn't work in a SvelteKit environment, for example.
|
||||
|
||||
This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
|
||||
|
||||
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
|
||||
|
||||
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
|
||||
|
||||
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
|
||||
|
||||
**Why include `.vscode/extensions.json`?**
|
||||
|
||||
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
|
||||
|
||||
**Why enable `checkJs` in the JS template?**
|
||||
|
||||
It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration.
|
||||
|
||||
**Why is HMR not preserving my local component state?**
|
||||
|
||||
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
|
||||
|
||||
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
|
||||
|
||||
```js
|
||||
// store.js
|
||||
// An extremely simple external store
|
||||
import { writable } from 'svelte/store';
|
||||
export default writable(0);
|
||||
```
|
32
jsconfig.json
Normal file
32
jsconfig.json
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "bundler",
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
/**
|
||||
* svelte-preprocess cannot figure out whether you have
|
||||
* a value or a type, so tell TypeScript to enforce using
|
||||
* `import type` instead of `import` for Types.
|
||||
*/
|
||||
"verbatimModuleSyntax": true,
|
||||
"isolatedModules": true,
|
||||
"resolveJsonModule": true,
|
||||
/**
|
||||
* To have warnings / errors of the Svelte compiler at the
|
||||
* correct position, enable source maps by default.
|
||||
*/
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
/**
|
||||
* Typecheck JS in `.svelte` and `.js` files by default.
|
||||
* Disable this if you'd like to use dynamic types.
|
||||
*/
|
||||
"checkJs": true
|
||||
},
|
||||
/**
|
||||
* Use global.d.ts instead of compilerOptions.types
|
||||
* to avoid limiting type declarations.
|
||||
*/
|
||||
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
|
||||
}
|
21
package.json
Normal file
21
package.json
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "wplace-tile-dump",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^6.1.2",
|
||||
"svelte": "^5.38.2",
|
||||
"vite": "^7.1.3",
|
||||
"vite-plugin-monkey": "^7.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@neodrag/svelte": "^2.3.3",
|
||||
"@svelte-put/inline-svg": "^4.0.1"
|
||||
}
|
||||
}
|
1373
pnpm-lock.yaml
Normal file
1373
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load diff
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
onlyBuiltDependencies:
|
||||
- esbuild
|
112
src/App.svelte
Normal file
112
src/App.svelte
Normal file
|
@ -0,0 +1,112 @@
|
|||
<script>
|
||||
import { draggable } from '@neodrag/svelte';
|
||||
import Tile from './lib/Tile.svelte';
|
||||
import { tileRegex } from './lib/regex.js';
|
||||
import { SvelteSet as Set } from 'svelte/reactivity';
|
||||
|
||||
let handle;
|
||||
let tiles = $state(new Set([]));
|
||||
let show = $state(true);
|
||||
|
||||
const dragOptions = {
|
||||
bounds: 'body',
|
||||
defaultPosition: {
|
||||
x: 50,
|
||||
y: 50,
|
||||
}
|
||||
};
|
||||
|
||||
function onMessage(e) {
|
||||
if (e?.data?.source !== 'blue-marble') return;
|
||||
if (!e?.data?.endpoint) return;
|
||||
const url = new URL(e.data.endpoint);
|
||||
if (url.origin !== 'https://backend.wplace.live') return;
|
||||
if (!url.pathname.match(tileRegex)) return;
|
||||
tiles.add(e.data.endpoint);
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onmessage={onMessage} />
|
||||
|
||||
<dialog use:draggable={{...dragOptions, handle}} class="tile-dumper" {open}>
|
||||
<div class="title-bar" bind:this={handle}>
|
||||
<div class="bar-start">
|
||||
<h2 class="title">Tiles</h2>
|
||||
</div>
|
||||
<div class="bar-end">
|
||||
<button>
|
||||
<svg inline-src="./assets/cross.svg" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tile-list">
|
||||
{#each [...tiles] as tile}
|
||||
<Tile image={tile} />
|
||||
{/each}
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<style>
|
||||
:global {
|
||||
html {
|
||||
--tile-dumper-primary: oklch(.7 .1577 160);
|
||||
}
|
||||
}
|
||||
|
||||
.tile-dumper {
|
||||
position: absolute;
|
||||
inset: auto;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
aspect-ratio: 1 / 1;
|
||||
|
||||
overflow-x: scroll;
|
||||
background-color: #fffffff0;
|
||||
}
|
||||
|
||||
.tile-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 5px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.title-bar {
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
justify-content: space-between;
|
||||
padding: 0 5px;
|
||||
|
||||
cursor: grab;
|
||||
color: white;
|
||||
background-color: var(--tile-dumper-primary);
|
||||
|
||||
|
||||
|
||||
h2 {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.bar-start,
|
||||
.bar-end {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
svg {
|
||||
color: white;
|
||||
width: 1rem;
|
||||
aspect-ratio: 1 / 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.tile-dumper {
|
||||
width: 35vw;
|
||||
}
|
||||
}
|
||||
</style>
|
0
src/assets/.gitkeep
Normal file
0
src/assets/.gitkeep
Normal file
5
src/assets/cross.svg
Normal file
5
src/assets/cross.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<!-- Created with PixiEditor (https://pixieditor.net) -->
|
||||
<svg version="1.1" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="28" y="8" width="8" height="48" transform="matrix(0.7071353, -0.7070779, 0.7070781, 0.7071354, -25.449253, 19.79772)" fill="currentColor" fill-opacity="1" stroke="currentColor" stroke-width="0" opacity="1" id="Rectangle" />
|
||||
<rect x="28" y="8" width="8" height="48" transform="matrix(0.7067771, 0.7074366, -0.70743626, 0.7067763, 19.826672, -25.45527)" fill="currentColor" fill-opacity="1" stroke="currentColor" stroke-width="0" opacity="1" id="Rectangle" />
|
||||
</svg>
|
After Width: | Height: | Size: 611 B |
18
src/lib/Tile.svelte
Normal file
18
src/lib/Tile.svelte
Normal file
|
@ -0,0 +1,18 @@
|
|||
<script>
|
||||
import { tileRegex } from './regex.js';
|
||||
const { image } = $props();
|
||||
const url = new URL(image);
|
||||
const [full, tileX, tileY] = url.pathname.match(tileRegex);
|
||||
</script>
|
||||
|
||||
<a class="tile" href={image} target="_blank" download={`${tileX}-${tileY}.png`}><img src={image} /></a>
|
||||
|
||||
<style>
|
||||
.tile {
|
||||
border: solid 2px transparent;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--tile-dumper-primary);
|
||||
}
|
||||
}
|
||||
</style>
|
1
src/lib/regex.js
Normal file
1
src/lib/regex.js
Normal file
|
@ -0,0 +1 @@
|
|||
export const tileRegex = /\/files\/s0\/tiles\/(\d+)\/(\d+)\.png/;
|
10
src/main.js
Normal file
10
src/main.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { mount } from 'svelte';
|
||||
import App from './App.svelte';
|
||||
|
||||
const app = mount(App, {
|
||||
target: (() => {
|
||||
return document.body
|
||||
})(),
|
||||
});
|
||||
|
||||
export default app;
|
4
src/vite-env.d.ts
vendored
Normal file
4
src/vite-env.d.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
/// <reference types="svelte" />
|
||||
/// <reference types="vite/client" />
|
||||
/// <reference types="vite-plugin-monkey/client" />
|
||||
//// <reference types="vite-plugin-monkey/global" />
|
7
svelte.config.js
Normal file
7
svelte.config.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
export default {
|
||||
// Consult https://svelte.dev/docs#compile-time-svelte-preprocess
|
||||
// for more information about preprocessors
|
||||
preprocess: vitePreprocess(),
|
||||
};
|
20
vite.config.js
Normal file
20
vite.config.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { defineConfig } from 'vite';
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
||||
import monkey from 'vite-plugin-monkey';
|
||||
import { inlineSvg } from '@svelte-put/inline-svg/vite';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
inlineSvg(),
|
||||
svelte(),
|
||||
monkey({
|
||||
entry: 'src/main.js',
|
||||
userscript: {
|
||||
icon: 'https://vitejs.dev/logo.svg',
|
||||
namespace: 'npm/vite-plugin-monkey',
|
||||
match: ['https://wplace.live/'],
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
Loading…
Reference in a new issue