Skip to content

Commit

Permalink
chore: remove vite
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Nov 20, 2024
1 parent 300bb2e commit d6d3fe1
Show file tree
Hide file tree
Showing 8 changed files with 358 additions and 1,113 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
JK = @pnpm exec jiek --root .

FLAGS += --bundle
FLAGS += --loader:.html=copy
FLAGS += --loader:.json=copy
FLAGS += --outdir=./display
FLAGS += --target=chrome51
FLAGS += ./dev/index.html
FLAGS += ./dev/data.json
FLAGS += ./dev/main.ts


bootstrap:
@echo "Install dependiences"
corepack enable
Expand All @@ -19,8 +29,8 @@ build-pub: bootstrap build-lib

dev-server:
@echo "Start dev server"
@pnpm exec vite
./node_modules/.bin/esbuild $(FLAGS) --define:LIVE_RELOAD=true --watch --servedir=./display

build-server:
@echo "Build server"
@pnpm exec vite build
./node_modules/.bin/esbuild $(FLAGS) --define:LIVE_RELOAD=false
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@

![display](./data.gif)

## Usage

```ts
import { createTreemap, presetDecorator } from 'squarified'

const root = document.querySelector('#app')
## Install

const treemap = createTreemap()
treemap.use('decorator', presetDecorator)
```shell
$ yarn add squarified
```

treemap.init(root)
## Usage

treemap.setOptions({ data: [] })
```
See the dev directory for a minimal example.

### Auth

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
</head>
<body>
<div id="app"></div>
<script type="module" src="./main.ts"></script>
<script src="main.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions dev/live-reload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
declare const LIVE_RELOAD: boolean

if (LIVE_RELOAD) {
new EventSource('/esbuild').addEventListener('change', e => {
const { added, removed, updated } = JSON.parse(e.data)

if (!added.length && !removed.length && updated.length === 1) {
for (const link of document.getElementsByTagName('link')) {
const url = new URL(link.href)

if (url.host === location.host && url.pathname === updated[0]) {
const next = link.cloneNode() as HTMLLinkElement
next.href = updated[0] + '?' + Math.random().toString(36).slice(2)
next.onload = () => link.remove()
link.parentNode!.insertBefore(next, link.nextSibling)
return
}
}
}

location.reload()
})
}
5 changes: 3 additions & 2 deletions dev/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { c2m, createTreemap, presetDecorator, sortChildrenByKey } from '../src'

const root = document.querySelector('#app')!
import './live-reload'

const root = document.querySelector('#app')!
const treemap = createTreemap()
treemap.use('decorator', presetDecorator)

function loadData() {
return fetch('./data.json').then((res) => res.json()).then((data: any[]) => data)
return fetch('data.json').then((res) => res.json()).then((data: any[]) => data)
}

async function main() {
Expand Down
23 changes: 21 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,30 @@
"devDependencies": {
"@types/node": "^22.7.4",
"dprint": "^0.47.2",
"esbuild": "^0.24.0",
"eslint": "8",
"eslint-config-kagura": "^2.2.1",
"jiek": "^1.1.3",
"typescript": "^5.6.2",
"vite": "^5.4.8"
"typescript": "^5.6.2"
},
"pnpm": {
"overrides": {
"esbuild": "0.24.0",
"array-includes": "npm:@nolyfill/array-includes@^1",
"array.prototype.flat": "npm:@nolyfill/array.prototype.flat@^1",
"array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@^1",
"deep-equal": "npm:@nolyfill/deep-equal@^1",
"es-iterator-helpers": "npm:@nolyfill/es-iterator-helpers@^1",
"hasown": "npm:@nolyfill/hasown@^1",
"is-core-module": "npm:@nolyfill/is-core-module@^1",
"object.assign": "npm:@nolyfill/object.assign@^1",
"object.fromentries": "npm:@nolyfill/object.fromentries@^1",
"object.values": "npm:@nolyfill/object.values@^1",
"safe-buffer": "npm:@nolyfill/safe-buffer@^1",
"safe-regex-test": "npm:@nolyfill/safe-regex-test@^1",
"safer-buffer": "npm:@nolyfill/safer-buffer@^1",
"string.prototype.includes": "npm:@nolyfill/string.prototype.includes@^1"
}
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit d6d3fe1

Please sign in to comment.