Git Product home page Git Product logo

kuhlaid / svelte2 Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 726 KB

Svelte offline data example for Edge or Chrome web browser, Bootstrap styling, indexedDb storage, dynamic form generation, and navigation to give a 'multi-page' feel. It also includes PWA cache clearing. This front-end code is meant to be used against a back-end API similar to https://github.com/kuhlaid/laravel2020.03.31

CSS 1.47% HTML 2.38% JavaScript 24.35% Shell 1.50% Svelte 70.31%
svelte-framework node-js pwa indexeddb bootstrap chrome-browser offline rollup pwa-audits

svelte2's People

Contributors

dependabot[bot] avatar kuhlaid avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

svelte2's Issues

Backend integration

After some thought I am treating the server-side, that this front-end connects to, as an API for data pushes and pulls. The reason for this is that I want this front-end app to be not be tied to a specific back-end database or service, and certainly did not want it embedded in this code base. So the front-end UI code is completely separate from the back-end code. This will make it easier for others to work with this code for their own purposes.

The next step will be to create a Svelte component for entering information about the back-end API to connect to (to be saved to local storage). The user will enter/copy the API URL into the front-end which would be saved to local storage, so that will be my next step in this development.

Other thoughts -------------------

Work on server side CSRF token generation from a user authenticated session (this session and CSRF token need to be saved on the server to validate data requests from the client); reference https://portswigger.net/web-security/csrf/tokens.

I really debated if the app needed unique URLs for each component/page (since these could sort of be routed using server requests to specify the component). I felt the Every framework handled this well, but I couldn't justify it in Svelte. Since this will be used as a non-public app, unique URLs do not seem important or useful so I will not bother with routing to more than one URL to deliver content.

Offline file cache incomplete

While some files are being cached by the service worker, some are being cached to disk. Looking into reason for this.

Look into using the localforage module for data storage

One of the problems I am having is understanding how Svelte processes Promises when a component is loaded (either initially or subsequently). I was working specifically with the Articles.svelte component but could not find a way to pull the values of a Promise into a text field from bound data store. What I was seeing was '[object Promise]' in the place of the Promise value but when writing to the console I see that a value is resolved in the Promise. I understanding of Svelte or Promises seems to be lacking in this area but I can't tell where the issue lies.

HTML comment

Comment like this https://github.com/kuhlaid/svelte2/blob/master/src/ApiSettingsIdb.svelte#L1
made debugging very hard. It's much easier if you move that as JS comment.

<script>
/* 
    @abstract This component will be used to update the URL of the server-side API to connect to.
    We need to read the localstorage strApiUrl value and copy to a writable variable.

    @todo Check the session token with the API server.
    Check if the user has an active session with a back-end API and save session.
*/ 
...
</script>

Workbox cache problem

Most of my cache issues come from the Workbox precache 'injectManifest' that happens with the service worker. What I need to happen is copy the src files to a 'staging area' where I can replace the 'cache' constants in the scripts BEFORE the Workbox precache is executed and the run the build rollup off of the staging files. This 'should' cause Workbox to treat the files as updated since the files will be actually updating and thus assign them different revision numbers from the new file hashes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.