Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Support for Hidden & Mesh Networks #15

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ESPConnect.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"folders": [
{
"path": ".",
"name": "Root"
},
{
"path": "./src",
"name": "Lib"
},
{
"path": "./portal",
"name": "Portal"
}
],
"settings": {}
}
24 changes: 22 additions & 2 deletions portal/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
/node_modules/
/public/build/
# 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?
51 changes: 26 additions & 25 deletions portal/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
# ESPConnect Portal Source
# Svelte + Vite

*Note that you will need to have [Node.js](https://nodejs.org) installed.*
This template should help get you started developing with Svelte in Vite.

## Recommended IDE Setup

## To Modify
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).

Install the dependencies...
## Need an official Svelte framework?

```bash
cd portal
npm install
```
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.

...then start development mode:
## Technical considerations

```bash
npm run dev
```
**Why use this over SvelteKit?**

Navigate to [localhost:5000](http://localhost:5000). You should see the portal. Edit a component file in `src`, save it, and reload the page to see your changes.
- 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.

By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
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.

If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
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.

## Building and running in production mode
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**

To create an optimised version of the app:
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.

```bash
npm run build
```
**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.

You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
**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.

## Single-page app mode
**Why is HMR not preserving my local component state?**

By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
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're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
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
"start": "sirv public --single"
// store.js
// An extremely simple external store
import { writable } from 'svelte/store'
export default writable(0)
```
77 changes: 0 additions & 77 deletions portal/compress.js

This file was deleted.

47 changes: 47 additions & 0 deletions portal/cppheader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//const FS = require('fs');
//const path = require('path');
import * as FS from 'fs';
import * as path from 'path';

const GZIPPED_PAGE = FS.readFileSync(path.resolve('./dist/index.html.gz'));

function chunkArray(myArray, chunk_size){
var index = 0;
var arrayLength = myArray.length;
var tempArray = [];
for (index = 0; index < arrayLength; index += chunk_size) {
let myChunk = myArray.slice(index, index+chunk_size);
// Do something if you want with the group
tempArray.push(myChunk);
}
return tempArray;
}

function addLineBreaks(buffer){
let data = '';
let chunks = chunkArray(buffer, 30);
chunks.forEach((chunk, index) => {
data += chunk.join(',');
if(index+1 !== chunks.length){
data+=',\n';
}
});
return data;
}

const CPPHEADER =
`
#ifndef _espconnect_webpage_h
#define _espconnect_webpage_h

const uint32_t ESPCONNECT_HTML_SIZE = ${GZIPPED_PAGE.length};
const uint8_t ESPCONNECT_HTML[] PROGMEM = {
${ addLineBreaks(GZIPPED_PAGE) }
};

#endif
`;

FS.writeFileSync(path.resolve('./dist/espconnect_webpage.h'), CPPHEADER);


12 changes: 12 additions & 0 deletions portal/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ESPConnect</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions portal/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"compilerOptions": {
"moduleResolution": "Node",
"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.
*/
"importsNotUsedAsValues": "error",
"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,
"forceConsistentCasingInFileNames": 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"]
}
Loading