Skip to content

Commit 445472b

Browse files
wip
1 parent b278a82 commit 445472b

23 files changed

+2126
-73
lines changed

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"dev:next-page": "cd ui/next-page-example && pnpm run dev",
1515
"dev:next-app": "cd ui/next-app-example && pnpm run dev",
1616
"dev:solid": "cd ui/solid-example && pnpm run dev",
17+
"dev:svelte": "cd packages/svelte && pnpm run dev",
1718
"build:react": "cd ui/react-example && pnpm run build",
1819
"pre:release": "pnpm run lint && pnpm run prettier && pnpm run clean && pnpm run build:packages",
1920
"release": "pnpm run pre:release && pnpm run start:release",
@@ -51,5 +52,10 @@
5152
"ts-node": "^10.9.2",
5253
"tslib": "^2.8.0",
5354
"typescript": "5.3.3"
55+
},
56+
"pnpm": {
57+
"onlyBuiltDependencies": [
58+
"esbuild"
59+
]
5460
}
55-
}
61+
}

packages/svelte/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
node_modules
2+
3+
# Output
4+
.output
5+
.vercel
6+
.netlify
7+
.wrangler
8+
/.svelte-kit
9+
/build
10+
/dist
11+
12+
# OS
13+
.DS_Store
14+
Thumbs.db
15+
16+
# Env
17+
.env
18+
.env.*
19+
!.env.example
20+
!.env.test
21+
22+
# Vite
23+
vite.config.js.timestamp-*
24+
vite.config.ts.timestamp-*

packages/svelte/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

packages/svelte/.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Package Managers
2+
package-lock.json
3+
pnpm-lock.yaml
4+
yarn.lock
5+
bun.lock
6+
bun.lockb

packages/svelte/.prettierrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"useTabs": true,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"printWidth": 100,
6+
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
7+
"overrides": [
8+
{
9+
"files": "*.svelte",
10+
"options": {
11+
"parser": "svelte"
12+
}
13+
}
14+
]
15+
}

packages/svelte/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Svelte library
2+
3+
Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4+
5+
Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6+
7+
## Creating a project
8+
9+
If you're seeing this, you've probably already done this step. Congrats!
10+
11+
```bash
12+
# create a new project in the current directory
13+
npx sv create
14+
15+
# create a new project in my-app
16+
npx sv create my-app
17+
```
18+
19+
## Developing
20+
21+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
22+
23+
```bash
24+
npm run dev
25+
26+
# or start the server and open the app in a new browser tab
27+
npm run dev -- --open
28+
```
29+
30+
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
31+
32+
## Building
33+
34+
To build your library:
35+
36+
```bash
37+
npm run package
38+
```
39+
40+
To create a production version of your showcase app:
41+
42+
```bash
43+
npm run build
44+
```
45+
46+
You can preview the production build with `npm run preview`.
47+
48+
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
49+
50+
## Publishing
51+
52+
Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53+
54+
To publish your library to [npm](https://www.npmjs.com):
55+
56+
```bash
57+
npm publish
58+
```

packages/svelte/eslint.config.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import prettier from 'eslint-config-prettier';
2+
import { includeIgnoreFile } from '@eslint/compat';
3+
import js from '@eslint/js';
4+
import svelte from 'eslint-plugin-svelte';
5+
import globals from 'globals';
6+
import { fileURLToPath } from 'node:url';
7+
import ts from 'typescript-eslint';
8+
import svelteConfig from './svelte.config.js';
9+
10+
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
11+
12+
export default ts.config(
13+
includeIgnoreFile(gitignorePath),
14+
js.configs.recommended,
15+
...ts.configs.recommended,
16+
...svelte.configs.recommended,
17+
prettier,
18+
...svelte.configs.prettier,
19+
{
20+
languageOptions: {
21+
globals: { ...globals.browser, ...globals.node }
22+
},
23+
rules: { 'no-undef': 'off' }
24+
},
25+
{
26+
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
27+
languageOptions: {
28+
parserOptions: {
29+
projectService: true,
30+
extraFileExtensions: ['.svelte'],
31+
parser: ts.parser,
32+
svelteConfig
33+
}
34+
}
35+
}
36+
);

packages/svelte/package.json

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,70 @@
11
{
2-
"name": "@git-diff-view/svelte"
3-
}
2+
"name": "@git-diff-view/svelte",
3+
"version": "0.0.1",
4+
"scripts": {
5+
"dev": "vite dev",
6+
"build": "vite build && npm run prepack",
7+
"preview": "vite preview",
8+
"prepare": "svelte-kit sync || echo ''",
9+
"prepack": "svelte-kit sync && svelte-package && publint",
10+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12+
"format": "prettier --write .",
13+
"lint": "prettier --check . && eslint ."
14+
},
15+
"files": [
16+
"dist",
17+
"!dist/**/*.test.*",
18+
"!dist/**/*.spec.*"
19+
],
20+
"sideEffects": [
21+
"**/*.css"
22+
],
23+
"svelte": "./src/lib/index.ts",
24+
"types": "./dist/index.d.ts",
25+
"type": "module",
26+
"exports": {
27+
".": {
28+
"types": "./src/lib/index.ts",
29+
"svelte": "./src/lib/index.ts"
30+
}
31+
},
32+
"dependencies": {
33+
"@git-diff-view/core": "^0.0.29",
34+
"@types/hast": "^3.0.0",
35+
"highlight.js": "^11.11.0",
36+
"lowlight": "^3.3.0",
37+
"fast-diff": "^1.3.0",
38+
"reactivity-store": "^0.3.11"
39+
},
40+
"peerDependencies": {
41+
"svelte": "^5.0.0"
42+
},
43+
"devDependencies": {
44+
"@eslint/compat": "^1.2.5",
45+
"@eslint/js": "^9.18.0",
46+
"@sveltejs/adapter-auto": "^6.0.0",
47+
"@sveltejs/kit": "^2.16.0",
48+
"@sveltejs/package": "^2.0.0",
49+
"@sveltejs/vite-plugin-svelte": "^5.0.0",
50+
"autoprefixer": "^10.4.20",
51+
"eslint": "^9.18.0",
52+
"eslint-config-prettier": "^10.0.1",
53+
"eslint-plugin-svelte": "^3.0.0",
54+
"globals": "^16.0.0",
55+
"postcss": "^8.5.1",
56+
"prettier": "^3.4.2",
57+
"prettier-plugin-svelte": "^3.3.3",
58+
"publint": "^0.3.2",
59+
"svelte": "^5.0.0",
60+
"svelte-check": "^4.0.0",
61+
"tailwindcss": "^3.4.17",
62+
"typescript": "^5.0.0",
63+
"typescript-eslint": "^8.20.0",
64+
"vite": "^6.2.6",
65+
"vite-plugin-devtools-json": "^0.2.0"
66+
},
67+
"keywords": [
68+
"svelte"
69+
]
70+
}

packages/svelte/postcss.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export default {
2+
plugins: {
3+
"postcss-import": {},
4+
tailwindcss: { config: "./tailwind.config.js" },
5+
"postcss-prefix-selector": {
6+
prefix: ".diff-tailwindcss-wrapper",
7+
transform: function (prefix, selector, prefixedSelector, _filePath, rule) {
8+
const filePath = rule.source?.input?.file;
9+
if (filePath.includes("_base.css")) {
10+
if (rule.source?.start?.line === 1) {
11+
return selector;
12+
} else {
13+
return prefixedSelector;
14+
}
15+
}
16+
if (filePath.includes("_base_pure.css")) {
17+
return prefixedSelector;
18+
}
19+
if (selector.includes("diff-line-extend-wrapper") || selector.includes("diff-line-widget-wrapper")) {
20+
return selector;
21+
}
22+
if (selector.includes("[data-theme")) {
23+
return prefix + selector;
24+
}
25+
if (filePath.includes("node_modules")) {
26+
if (filePath.includes("dark.css")) {
27+
return `${prefix}[data-theme="dark"] .diff-line-syntax-raw ${selector}`;
28+
} else {
29+
return `${prefix}[data-theme="light"] .diff-line-syntax-raw ${selector}`;
30+
}
31+
} else {
32+
return prefixedSelector;
33+
}
34+
},
35+
},
36+
autoprefixer: {},
37+
},
38+
};

packages/svelte/src/app.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

0 commit comments

Comments
 (0)