Skip to content

Commit

Permalink
use sveltekit
Browse files Browse the repository at this point in the history
  • Loading branch information
Akatuoro committed Apr 23, 2024
1 parent 07e241c commit b4d501b
Show file tree
Hide file tree
Showing 19 changed files with 217 additions and 199 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ['main', 'master']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload dist folder
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
34 changes: 0 additions & 34 deletions .github/workflows/manual.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

celeba/
__pycache__
*.png
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
19 changes: 19 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}
39 changes: 21 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"description": "Generate icons and logos with machine learning",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"bundle": "npm run build && mkdir -p build/dist && cp dist/* build/dist && cp index.html build/index.html",
"build": "rollup -c",
"watch": "rollup -c -w",
"dev": "run-p watch start",
"start": "serve"
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch"
},
"repository": {
"type": "git",
Expand All @@ -27,19 +26,23 @@
"url": "https://github.com/Akatuoro/icon-gan/issues"
},
"homepage": "https://github.com/Akatuoro/icon-gan#readme",
"type": "module",
"dependencies": {
"@tensorflow/tfjs": "^2.0.1",
"@tensorflow/tfjs": "^4.18.0",
"npm-run-all": "^4.1.5",
"rollup-plugin-svelte": "^6.1.1",
"svelte": "^3.29.6"
"rollup-plugin-svelte": "^7.2.0",
"svelte": "^4.2.15"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"comlink": "^4.3.0",
"file-saver": "^2.0.2",
"rollup": "^2.22.2",
"rollup-plugin-terser": "^6.1.0",
"serve": "^11.3.2"
}
"devDependencies": {
"@tensorflow/tfjs": "^4.18.0",
"comlink": "^4.4.1",
"file-saver": "^2.0.5",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"typescript": "^5.0.0",
"vite": "^5.0.3"
}
}
35 changes: 0 additions & 35 deletions rollup.config.js

This file was deleted.

12 changes: 0 additions & 12 deletions serve.json

This file was deleted.

31 changes: 0 additions & 31 deletions src/App.svelte

This file was deleted.

13 changes: 13 additions & 0 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}

export {};
68 changes: 9 additions & 59 deletions index.html → src/app.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
%sveltekit.head%

<title></title>

<script async src="dist/bundle.js"></script>

<style>
html,
Expand All @@ -26,7 +27,6 @@
top: 0px;
width: 100%;
height: 100%;
background-image: url("public/icons.png");
background-position: center;
background-color: #051A33;
}
Expand Down Expand Up @@ -263,7 +263,7 @@
function load() {
const overlay = document.getElementById("overlay")
overlay.hidden = false
location.hash = '#model'
location.href = '/model'
}

function reset() {
Expand Down Expand Up @@ -331,58 +331,8 @@
}
</script>
</head>
<body onload="onload()">
<div id="home">
<div class="container">
<div class="container-content" style="position: absolute;">
<div class="header">
<div style="text-align: left;"><noscript>Enable JavaScript!</noscript></div>
<div></div>
<div style="text-align: right;">
<div id="support" hidden style="color: gray; animation: fadein 0.5s;">
<span id="webgl">WebGL</span>
<span id="plus"> + </span>
<span id="worker">Worker</span>
</div>
</div>
</div>

<h1>Icon GAN</h1>
<div class="flex-center btn-container">
<div style="position: absolute;">
<button class="btn" onclick="load()">
<svg width="180px" height="60px" viewBox="0 0 180 60" class="border">
<polyline points="179,1 179,59 1,59 1,1 179,1" class="bg-line" />
<polyline points="179,1 179,59 1,59 1,1 179,1" class="hl-line" />
</svg>
<span>LOAD<br><span>(16MB)</span></span>
</button>
</div>
</div>

<div class="footer">
<div style="text-align: left;"><a href="https://github.com/Akatuoro/icon-gan">GitHub</a></div>
<div style="text-align: center;"><a onclick="document.getElementById('aboutDialog').showModal()">About</a></div>
<div style="text-align: right;">License: CC-BY-NC</div>
</div>
</div>
</div>
</div>
<div id="overlay" hidden="true" onclick="reset()">
<div class="container">
<div class="lds-grid"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
</div>
</div>
<dialog id="aboutDialog" onclick="dialogCloseHandler(event)">
<p>Icon GAN is a <a href="https://en.wikipedia.org/wiki/Generative_adversarial_network">generative adversarial network</a> for interactively generating favicons.</p>
<p>
Usually designers work together with clients to iterate on icon designs, presenting drafts and iterating on the final design.
This icon generator can help provide inspiration to the artist and client or serve as base for the iterative process.
</p>
<p>The interface facilitates exploring the latent space of the trained model. It features exploring a 2d subspace and selectively choosing directions - representing style and form -, interpolating between 2 or 3 icons and moving generated icons and their respective latent space representations between different tools via drag & drop.</p>
<br>
<menu>
<button onclick="document.getElementById('aboutDialog').close()">Close</button>
</menu>
</dialog>
<body onload="onload()" data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
<!DOCTYPE html>
5 changes: 3 additions & 2 deletions src/exploration/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Exploration } from './exploration';
import workerURL from './worker?url';
import * as Comlink from 'comlink'
window.Comlink = Comlink
// window.Comlink = Comlink


let _useWorker
Expand All @@ -25,7 +26,7 @@ export const useWorker = () => {
export const explore = async () => {
if (useWorker()) {
console.info('using worker')
const exploration = Comlink.wrap(new Worker('dist/exploration-worker.js'))
const exploration = Comlink.wrap(new Worker(workerURL, {type: 'module'}))
return exploration
}
else {
Expand Down
5 changes: 0 additions & 5 deletions src/main.js

This file was deleted.

Loading

0 comments on commit b4d501b

Please sign in to comment.