Skip to content

Commit

Permalink
feat: wip adding svelte sample app (#89)
Browse files Browse the repository at this point in the history
* feat: wip adding svelte sample app

* fix: add node polyfill plugin

* fix: connex-driver import

* fix: svelte sample app

* fix: sonar lint due to tile

* fix: lint
  • Loading branch information
davidecarpini authored Nov 23, 2023
1 parent 5d00c4b commit 8141127
Show file tree
Hide file tree
Showing 16 changed files with 201 additions and 2 deletions.
13 changes: 13 additions & 0 deletions apps/sample-svelte-app/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
10 changes: 10 additions & 0 deletions apps/sample-svelte-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions apps/sample-svelte-app/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
38 changes: 38 additions & 0 deletions apps/sample-svelte-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
36 changes: 36 additions & 0 deletions apps/sample-svelte-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "sample-svelte-app",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite dev"
},
"dependencies": {
"@vechainfoundation/dapp-kit-ui": "*",
"lru-cache": "5.1.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0"
},
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.27.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vechain/repo-config": "https://github.com/vechainfoundation/repo-config#v0.0.1",
"eslint": "^8.28.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.30.0",
"prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.0.0",
"svelte": "^4.0.5",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.4.2",
"vite-plugin-node-polyfills": "^0.16.0"
}
}
12 changes: 12 additions & 0 deletions apps/sample-svelte-app/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}

export {};
18 changes: 18 additions & 0 deletions apps/sample-svelte-app/src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="en">
<head>
<title>svelte kit</title>
<script>
if (global === undefined) {
var global = window;
}
</script>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
19 changes: 19 additions & 0 deletions apps/sample-svelte-app/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { DAppKit } from '@vechainfoundation/dapp-kit-ui';

const walletConnectOptions = {
projectId: 'a0b855ceaf109dbc8426479a4c3d38d8',
metadata: {
name: 'Sample VeChain dApp',
description: 'A sample VeChain dApp',
url: window.location.origin,
icons: [`${window.location.origin}/images/logo/my-dapp.png`],
},
};

const vechainWalletKitOptions = {
nodeUrl: 'https://testnet.vechain.org/',
network: 'test',
walletConnectOptions,
};

DAppKit.configure(vechainWalletKitOptions);
1 change: 1 addition & 0 deletions apps/sample-svelte-app/src/routes/+layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ssr = false;
5 changes: 5 additions & 0 deletions apps/sample-svelte-app/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
import '$lib';
</script>

<vwk-connect-button-with-modal mode="DARK"></vwk-connect-button-with-modal>
Binary file added apps/sample-svelte-app/static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions apps/sample-svelte-app/svelte.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';

/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),

kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter(),
},
};

// eslint-disable-next-line import/no-default-export
export default config;
18 changes: 18 additions & 0 deletions apps/sample-svelte-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"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
//
// 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
}
7 changes: 7 additions & 0 deletions apps/sample-svelte-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';

export default defineConfig({
plugins: [nodePolyfills(), sveltekit()],
});
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build:deps": "turbo build --no-daemon --filter='@vechainfoundation/*'",
"clean": "rm -rf .turbo .parcel-cache build && npx turbo@latest run clean",
"cucumber": "yarn && cucumber-js",
"dev": "turbo run dev --no-daemon",
"format": "prettier --write \"**/*.{ts,tsx,md,json,js,jsx}\"",
"install:all": "yarn && yarn run build:deps",
"lint": "turbo run lint",
Expand Down
5 changes: 4 additions & 1 deletion packages/dapp-kit/src/connex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { DriverNoVendor, SimpleNet } from '@vechain/connex-driver';
import {
DriverNoVendor,
SimpleNet,
} from '@vechain/connex-driver/dist/index.js';
import { Framework } from '@vechain/connex-framework';
import { blake2b256 } from 'thor-devkit';
import type { ConnexOptions } from './types';
Expand Down

0 comments on commit 8141127

Please sign in to comment.