Compare commits
25 Commits
609ca4d3f5
...
parcel
Author | SHA1 | Date | |
---|---|---|---|
0dff9d869d | |||
b588693ccf | |||
db5a363bff | |||
bc6b12afa1 | |||
6424f66732 | |||
b05e2d3c55 | |||
ae5257b2b3 | |||
c3f9529feb | |||
93b272ecb5 | |||
22e6cacd8e | |||
c52e08afa9 | |||
60b238d42e | |||
14dec9ce96 | |||
d67a51f83b | |||
bb1f98761d | |||
0b56f9b1a8 | |||
560828f4a2 | |||
32094f3a79 | |||
d46223c96a | |||
ffe1dd6f9f | |||
311409d36d | |||
31d9f99b77 | |||
7917a628ef | |||
cb6d5cd944 | |||
b54fbe2059 |
8581
package-lock.json
generated
8581
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
@ -4,49 +4,34 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "webpack --mode=production",
|
||||
"watch": "webpack --mode=development --watch",
|
||||
"start": "webpack-dev-server --mode=production",
|
||||
"start:prod": "webpack-dev-server --mode=production",
|
||||
"start:dev": "webpack-dev-server --mode=development"
|
||||
"build": "parcel build src/index.html",
|
||||
"dev": "parcel src/index.html"
|
||||
},
|
||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||
"license": "MIT",
|
||||
"browserslist": [
|
||||
"last 2 Chrome versions"
|
||||
],
|
||||
"dependencies": {
|
||||
"@hibas123/secure-file-wrapper": "^2.5.0",
|
||||
"@hibas123/utils": "^2.1.0",
|
||||
"@hibas123/secure-file-wrapper": "^2.5.1",
|
||||
"@hibas123/theme": "^1.2.14",
|
||||
"@hibas123/utils": "^2.2.3",
|
||||
"aes-js": "^3.1.2",
|
||||
"feather-icons": "^4.21.0",
|
||||
"idb": "3.0.2",
|
||||
"feather-icons": "^4.26.0",
|
||||
"idb": "^4.0.3",
|
||||
"js-sha256": "^0.9.0",
|
||||
"js-sha512": "^0.8.0",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"secure-file-wrapper": "git+https://git.stamm.me/OpenServer/OSSecureFileWrapper.git",
|
||||
"uikit": "^3.1.5",
|
||||
"uuid": "^3.3.2"
|
||||
"parcel": "^1.12.4",
|
||||
"uuid": "^3.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash.clonedeep": "^4.5.6",
|
||||
"@types/uikit": "^2.27.7",
|
||||
"@types/uuid": "^3.4.4",
|
||||
"copy-webpack-plugin": "^5.0.3",
|
||||
"css-loader": "^2.1.1",
|
||||
"file-loader": "^3.0.1",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"mini-css-extract-plugin": "^0.7.0",
|
||||
"node-sass": "^4.12.0",
|
||||
"preact": "^8.3.1",
|
||||
"preact-svg-loader": "^0.2.1",
|
||||
"sass-loader": "^7.1.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"ts-loader": "^6.0.2",
|
||||
"typescript": "^3.5.1",
|
||||
"webpack": "^4.32.2",
|
||||
"webpack-bundle-analyzer": "^3.3.2",
|
||||
"webpack-cli": "^3.3.2",
|
||||
"webpack-dev-server": "^3.5.0",
|
||||
"webpack-visualizer-plugin": "^0.1.11",
|
||||
"workbox-webpack-plugin": "^4.3.1",
|
||||
"worker-loader": "^2.0.0"
|
||||
"@types/uuid": "^3.4.7",
|
||||
"node-sass": "^4.13.1",
|
||||
"parcel-bundler": "^1.12.4",
|
||||
"preact": "^10.3.1",
|
||||
"ts-loader": "^6.2.1",
|
||||
"typescript": "^3.7.5"
|
||||
}
|
||||
}
|
||||
|
5
src/Views/404/index.tsx
Normal file
5
src/Views/404/index.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import { h } from "preact";
|
||||
|
||||
export default function Error404Page() {
|
||||
return <h1>Page not found!</h1>;
|
||||
}
|
37
src/Views/Settings/Settings.tsx
Normal file
37
src/Views/Settings/Settings.tsx
Normal file
@ -0,0 +1,37 @@
|
||||
import { h } from "preact";
|
||||
import { Page } from "../../page";
|
||||
import Theme, { ThemeStates } from "../../theme";
|
||||
import Navigation from "../../navigation";
|
||||
import ArrowLeft from "feather-icons/dist/icons/arrow-left.svg";
|
||||
|
||||
export default class SettingsPage extends Page<{ state: any }, { vault: string }> {
|
||||
componentWillMount() {
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
let active = Theme.active();
|
||||
return <div>
|
||||
<header class="header">
|
||||
<a class="header-icon-button" onClick={() => history.back()}><img src={ArrowLeft} height={undefined} width={undefined} /></a>
|
||||
<h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>Settings</h3>
|
||||
<span></span>
|
||||
</header>
|
||||
<div class="container">
|
||||
<div className="input-group">
|
||||
<label>Select Theme: </label>
|
||||
<select class="inp" onChange={(ev) => Theme.change(Number((ev.target as HTMLSelectElement).value))}>
|
||||
{Object.keys(ThemeStates)
|
||||
.filter(e => Number.isNaN(Number(e)))
|
||||
.map(e => <option selected={ThemeStates[e] === active} value={ThemeStates[e]}>{e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()}</option>)}
|
||||
{/* <option value={ThemeStates.AUTO}>Auto</option>
|
||||
<option value={ThemeStates.LIGHT}>Light</option>
|
||||
<option value={ThemeStates.DARK}>Dark</option> */}
|
||||
</select>
|
||||
</div>
|
||||
{/* <button class="btn" onClick={() => Theme.toggle()}>Toggle Dark Mode</button> */}
|
||||
<button class="btn" onClick={() => window.navigator.serviceWorker.controller.postMessage("message")}>Clear cache</button>
|
||||
</div>
|
||||
</div >;
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
import { h } from "preact";
|
||||
import { Page } from "../../../page";
|
||||
import VaultsPage from "../vaults/Vaults";
|
||||
import Navigation from "../../../navigation";
|
||||
import { Page } from "../../page";
|
||||
import VaultsPage from "../Vaults/Vaults";
|
||||
import Navigation from "../../navigation";
|
||||
|
||||
export default class SharePage extends Page<{ state: any }, { vault: string }> {
|
||||
text: string;
|
||||
componentWillMount() {
|
||||
let { title, text, url } = Navigation.getQuery() || {} as any;
|
||||
let { title, text, url } = this.props.state;
|
||||
let note = "";
|
||||
if (title) {
|
||||
note += title + "\n"
|
||||
@ -24,7 +24,9 @@ export default class SharePage extends Page<{ state: any }, { vault: string }> {
|
||||
|
||||
render() {
|
||||
return <VaultsPage state={undefined} selectVault onSelected={vault => {
|
||||
Navigation.setPage("/vault", { id: vault }, { entry: "true", note: this.text }, true);
|
||||
Navigation.setPage("/", undefined, undefined, true);
|
||||
Navigation.setPage("/vault", { id: vault });
|
||||
Navigation.setPage("/vault", { id: vault }, { entry: "true", note: this.text });
|
||||
}} />
|
||||
}
|
||||
}
|
@ -1,14 +1,12 @@
|
||||
import { h, Component } from "preact"
|
||||
import Notes, { IVault, ViewNote } from "../../../notes";
|
||||
import { IVault, ViewNote } from "../../notes";
|
||||
import Trash from "feather-icons/dist/icons/trash-2.svg"
|
||||
import X from "feather-icons/dist/icons/x.svg"
|
||||
import Save from "feather-icons/dist/icons/save.svg"
|
||||
|
||||
import Navigation from "../../../navigation";
|
||||
import { YesNoModal } from "../../modals/YesNoModal";
|
||||
import LoadingModal from "../../modals/LoadingModal";
|
||||
import Notifications, { MessageType } from "../../../notifications";
|
||||
import Modal from "../../modals/Modal";
|
||||
import Navigation from "../../navigation";
|
||||
import { YesNoModal } from "../../components/modals/YesNoModal";
|
||||
import Notifications, { MessageType } from "../../notifications";
|
||||
|
||||
const minRows = 3;
|
||||
export default class EntryComponent extends Component<{ vault: Promise<IVault>, id: string | undefined, note: string | undefined }, { title: string, changed: boolean }> {
|
||||
@ -21,15 +19,23 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
|
||||
private skip_save: boolean = false;
|
||||
|
||||
private inputElm: HTMLInputElement;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { changed: false, title: "" };
|
||||
this.textAreaChange = this.textAreaChange.bind(this);
|
||||
this.textAreaKeyPress = this.textAreaKeyPress.bind(this);
|
||||
}
|
||||
|
||||
private toVault() {
|
||||
history.back();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.inputElm.focus();
|
||||
}
|
||||
|
||||
async componentWillMount() {
|
||||
this.text = "";
|
||||
this.vault = undefined;
|
||||
@ -39,8 +45,6 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
this.setState({ changed: false, title: "" });
|
||||
try {
|
||||
this.skip_save = false;
|
||||
// this.loading = new LoadingModal();
|
||||
// this.loading.show();
|
||||
|
||||
this.vault = await this.props.vault;
|
||||
let note: ViewNote;
|
||||
@ -57,7 +61,6 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
|
||||
if (!note) {
|
||||
Notifications.sendNotification("Note not found!", MessageType.ERROR);
|
||||
// this.toVault()
|
||||
} else {
|
||||
this.note = note;
|
||||
this.text = note.__value;
|
||||
@ -65,14 +68,8 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
if (rows !== this.rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
// async onKeypress(event) {
|
||||
// event = event || window.event;
|
||||
//
|
||||
// }
|
||||
let [title] = this.text.split("\n", 1);
|
||||
this.setState({ title, changed })
|
||||
// if (this.loading)
|
||||
// this.loading.close();
|
||||
}
|
||||
} catch (err) {
|
||||
Notifications.sendError(err);
|
||||
@ -108,11 +105,12 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
|
||||
textAreaChange(evt: KeyboardEvent) {
|
||||
if (evt.keyCode === 17 || evt.keyCode === 27) return; //No character, so not relevant for this function
|
||||
if (!this.state.changed && this.textAreaKeyPress(evt)) this.setState({ changed: true })
|
||||
|
||||
let target = (evt.target as HTMLTextAreaElement)
|
||||
let value = target.value;
|
||||
|
||||
this.text = value;
|
||||
if (!this.state.changed && this.textAreaKeyPress(evt)) this.setState({ changed: true })
|
||||
|
||||
let [title] = value.split("\n", 1);
|
||||
if (title !== this.state.title)
|
||||
@ -138,6 +136,7 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
}
|
||||
|
||||
textAreaKeyPress(evt: KeyboardEvent) {
|
||||
console.log(evt);
|
||||
if ((evt.keyCode === 83 || evt.keyCode === 13) && evt.ctrlKey) {
|
||||
evt.preventDefault()
|
||||
this.save();
|
||||
@ -161,39 +160,27 @@ export default class EntryComponent extends Component<{ vault: Promise<IVault>,
|
||||
const delete_handler = async () => {
|
||||
await this.vault.deleteNote(this.props.id);
|
||||
this.toVault()
|
||||
// async onKeypress(event) {
|
||||
// event = event || window.event;
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
console.log("Rerender")
|
||||
|
||||
return <div>
|
||||
<header class="uk-background-primary">
|
||||
{/* <div> */}
|
||||
<a class="header-icon-button" onClick={() => this.exitHandler()}><X height={undefined} width={undefined} /></a>
|
||||
{this.state.changed ? <a class="header-icon-button" style="margin-left: 0.5em;" onClick={() => save_handler()}><Save height={undefined} width={undefined} /></a> : undefined}
|
||||
{/* </div> */}
|
||||
<header class="header">
|
||||
<a class="header-icon-button" onClick={() => this.exitHandler()}><img src={X} height={undefined} width={undefined} /></a>
|
||||
{this.state.changed ? <a class="header-icon-button" style="margin-left: 0.5em;" onClick={() => save_handler()}><img src={Save} height={undefined} width={undefined} /></a> : undefined}
|
||||
<h3 style="display:inline" class="button header-title">{this.state.title}</h3>
|
||||
<a class="header-icon-button" onClick={() => delete_handler()}><Trash height={undefined} width={undefined} /></a>
|
||||
<a class="header-icon-button" onClick={() => delete_handler()}><img src={Trash} height={undefined} width={undefined} /></a>
|
||||
</header>
|
||||
<div class="uk-container">
|
||||
<div class="container">
|
||||
<textarea
|
||||
// async onKeypress(event) {
|
||||
// event = event || window.event;
|
||||
//
|
||||
// }
|
||||
autofocus
|
||||
value={this.text}
|
||||
rows={this.rows}
|
||||
class="doc uk-textarea"
|
||||
class="inp"
|
||||
style="width:100%;"
|
||||
onInput={evt => this.textAreaChange(evt as KeyboardEvent)}
|
||||
onKeyDown={evt => this.textAreaKeyPress(evt)}
|
||||
onChange={evt => this.textAreaChange(evt as KeyboardEvent)}
|
||||
ref={elm => {
|
||||
if (elm)
|
||||
setTimeout(() => elm.focus(), 500)
|
||||
}}
|
||||
onInput={this.textAreaChange}
|
||||
onKeyDown={this.textAreaKeyPress}
|
||||
onChange={this.textAreaChange}
|
||||
ref={elm => this.inputElm = elm}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
@ -1,11 +1,11 @@
|
||||
import { h, Component } from "preact"
|
||||
import Notes, { IVault, BaseNote } from "../../../notes";
|
||||
import AddButton from "../../AddButton";
|
||||
import Navigation from "../../../navigation";
|
||||
import { h, Component, JSX } from "preact"
|
||||
import Notes, { IVault, BaseNote } from "../../notes";
|
||||
import AddButton from "../../components/AddButton";
|
||||
import Navigation from "../../navigation";
|
||||
import ArrowLeft from "feather-icons/dist/icons/arrow-left.svg"
|
||||
import Search from "feather-icons/dist/icons/search.svg"
|
||||
import ContextMenu from "../../context";
|
||||
import Notifications from "../../../notifications";
|
||||
import ContextMenu from "../../components/context";
|
||||
import Notifications from "../../notifications";
|
||||
import { Observable, Lock } from "@hibas123/utils";
|
||||
|
||||
|
||||
@ -59,6 +59,15 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
||||
|
||||
onContext(evt: MouseEvent, note: BaseNote) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
|
||||
const close = () => {
|
||||
document.documentElement.removeEventListener("click", close);
|
||||
this.setState({ context: undefined });
|
||||
}
|
||||
document.documentElement.addEventListener("click", close);
|
||||
|
||||
|
||||
const shareNote = async () => {
|
||||
let nav = window.navigator as any;
|
||||
if (nav.share !== undefined) {
|
||||
@ -72,20 +81,44 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
||||
} else {
|
||||
Notifications.sendError("Sharing not possible on this device")
|
||||
}
|
||||
}
|
||||
|
||||
const deleteNote = async () => {
|
||||
this.vault.deleteNote(note._id).then(() => {
|
||||
Notifications.sendSuccess("Deleted")
|
||||
this.rawNotes = this.rawNotes.filter(e => e._id !== note._id);
|
||||
this.setState({ notes: this.state.notes.filter(e => e._id !== note._id) });
|
||||
}).catch(err => {
|
||||
Notifications.sendError(err);
|
||||
})
|
||||
}
|
||||
|
||||
const copyNote = async () => {
|
||||
this.vault.getNote(note._id).then(note => {
|
||||
const el = document.createElement('textarea');
|
||||
el.value = note.__value;
|
||||
document.body.appendChild(el);
|
||||
el.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(el);
|
||||
Notifications.sendSuccess("Copied");
|
||||
})
|
||||
}
|
||||
|
||||
let share;
|
||||
if ((window.navigator as any).share) {
|
||||
share = <button class="uk-button" onClick={() => shareNote()}>
|
||||
share = <button class="btn" onClick={shareNote}>
|
||||
share
|
||||
</button>
|
||||
let context = <ContextMenu event={evt} >
|
||||
{share}
|
||||
</ContextMenu>
|
||||
|
||||
this.setState({ context });
|
||||
}
|
||||
|
||||
let context = <ContextMenu event={evt} >
|
||||
{share}
|
||||
<button class="btn" onClick={deleteNote}>delete</button>
|
||||
<button class="btn" onClick={copyNote}>copy</button>
|
||||
</ContextMenu>
|
||||
|
||||
this.setState({ context });
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -232,31 +265,29 @@ export default class EntryList extends Component<{ vault: Promise<IVault> }, { n
|
||||
|
||||
return <div>
|
||||
{this.state.context}
|
||||
<header class="uk-background-primary">
|
||||
<a class="header-icon-button" onClick={() => history.back()}><ArrowLeft height={undefined} width={undefined} /></a>
|
||||
<header class="header">
|
||||
<a class="header-icon-button" onClick={() => history.back()}><img src={ArrowLeft} height={undefined} width={undefined} /></a>
|
||||
<h3 style="display:inline" class="header-title" onClick={() => Navigation.setPage("/")}>{this.vault ? this.vault.name : ""}</h3>
|
||||
<span></span>
|
||||
{/* <a class="button header_icon_button"><MoreVertival height={undefined} width={undefined} /></a> */}
|
||||
</header>
|
||||
<AddButton onClick={() => open_entry(null)} />
|
||||
<div class="uk-container">
|
||||
<div class="container">
|
||||
<div style="display:flex;">
|
||||
<input class="uk-input" type="text" onKeyUp={this.searchChanged} ref={elm => this.searchInput = elm} />
|
||||
<button class="uk-button" style="padding: 0 10px;">
|
||||
<Search />
|
||||
<input class="inp" type="text" style="width: 100%; height: 40px;" onKeyUp={this.searchChanged} ref={elm => this.searchInput = elm} />
|
||||
<button class="btn btn-primary" style="padding: 5px 10px; margin: 0; height: 40px; width: 40px;">
|
||||
<img src={Search} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="uk-child-width-1-3@m uk-grid-small uk-grid-match" style="margin-top: 1rem;" uk-grid>
|
||||
<div class="vault-list" style="margin-top: 1rem;">
|
||||
{this.state.notes.map(note => {
|
||||
let [first, second] = note.preview.split("\n", 2);
|
||||
return <div class="" onContextMenu={evt => this.onContext(evt, note)} onClick={() => {
|
||||
return <div class="card vault-vault" onContextMenu={evt => this.onContext(evt, note)} onClick={() => {
|
||||
open_entry(note._id)
|
||||
}}>
|
||||
<div class="uk-card uk-card-default uk-card-body vault-vault" style="box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3)">
|
||||
<div>{first}</div>
|
||||
<div>{second}</div>
|
||||
</div>
|
||||
<div>{first}</div>
|
||||
<div>{second}</div>
|
||||
</div>
|
||||
})}
|
||||
</div>
|
@ -1,7 +1,7 @@
|
||||
import { h } from "preact"
|
||||
import { Page } from "../../../page";
|
||||
import Notes, { IVault, BaseNote } from "../../../notes";
|
||||
import Navigation from "../../../navigation";
|
||||
import { Page } from "../../page";
|
||||
import Notes, { IVault, BaseNote } from "../../notes";
|
||||
import Navigation from "../../navigation";
|
||||
import EntryComponent from "./Entry";
|
||||
import EntryList from "./EntryList";
|
||||
|
43
src/Views/Vault/vault.scss
Executable file
43
src/Views/Vault/vault.scss
Executable file
@ -0,0 +1,43 @@
|
||||
.container> :last-child {
|
||||
margin-bottom: 15px !important;
|
||||
}
|
||||
|
||||
.vault-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
grid-gap: 1rem;
|
||||
grid-auto-rows: auto;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 50rem) {
|
||||
.vault-list {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Media Query for small screens
|
||||
|
||||
.vault-vault {
|
||||
overflow: hidden;
|
||||
|
||||
>div {
|
||||
width: 100%;
|
||||
font-size: 1.1rem;
|
||||
margin-left: 1rem;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
>div:nth-of-type(1) {
|
||||
font-size: 1.3rem;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
>div:empty {
|
||||
&::before {
|
||||
content: " ";
|
||||
white-space: pre;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,16 @@
|
||||
import { h } from "preact"
|
||||
import { Page } from "../../../page";
|
||||
import Notes, { VaultList } from "../../../notes";
|
||||
import { h, JSX } from "preact"
|
||||
import { Page } from "../../page";
|
||||
import Notes, { VaultList } from "../../notes";
|
||||
import "./vaults.scss"
|
||||
import Lock from "feather-icons/dist/icons/lock.svg";
|
||||
import Unlock from "feather-icons/dist/icons/unlock.svg";
|
||||
import Navigation from "../../../navigation";
|
||||
import { InputModal } from "../../modals/InputModal";
|
||||
import { YesNoModal } from "../../modals/YesNoModal";
|
||||
import AddButton from "../../AddButton";
|
||||
import ContextMenu from "../../context";
|
||||
import Notifications from "../../../notifications";
|
||||
import Settings from "feather-icons/dist/icons/settings.svg"
|
||||
import Navigation from "../../navigation";
|
||||
import { InputModal } from "../../components/modals/InputModal";
|
||||
import { YesNoModal } from "../../components/modals/YesNoModal";
|
||||
import AddButton from "../../components/AddButton";
|
||||
import ContextMenu from "../../components/context";
|
||||
import Notifications from "../../notifications";
|
||||
|
||||
export interface VaultsProps {
|
||||
state: any;
|
||||
@ -127,21 +128,22 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
||||
|
||||
onContext(evt: MouseEvent, vault: { name: string, encrypted: boolean, id: string }) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
|
||||
const close = () => {
|
||||
window.removeEventListener("click", close);
|
||||
document.documentElement.removeEventListener("click", close);
|
||||
this.setState({ context: undefined });
|
||||
}
|
||||
window.addEventListener("click", close);
|
||||
document.documentElement.addEventListener("click", close);
|
||||
|
||||
let deleteb = <button class="uk-button" onClick={async () => {
|
||||
let deleteb = <button class="btn" onClick={async () => {
|
||||
let delete_modal = new YesNoModal("Delete Vault? Cannot be undone!");
|
||||
let result = await delete_modal.getResult();
|
||||
if (result) {
|
||||
Notes.deleteVault(vault.id).then(() => {
|
||||
this.updateVaults();
|
||||
}).catch(err => {
|
||||
Notifications.sendError("error deleting vault!")
|
||||
Notifications.sendError("Error deleting vault!")
|
||||
console.error(err);
|
||||
})
|
||||
}
|
||||
@ -151,15 +153,15 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
||||
|
||||
let delete_key;
|
||||
if (Notes.getVaultKey(vault.id)) {
|
||||
delete_key = <button class="uk-button" onClick={() => {
|
||||
delete_key = <button class="btn" onClick={() => {
|
||||
Notes.forgetVaultKey(vault.id);
|
||||
Notifications.sendSuccess("Forgot key!")
|
||||
Notifications.sendSuccess("Forgot password!")
|
||||
}}>
|
||||
forget password
|
||||
</button>;
|
||||
}
|
||||
|
||||
let exportb = <button class="uk-button" onClick={async () => {
|
||||
let exportb = <button class="btn" onClick={async () => {
|
||||
let key: Uint8Array;
|
||||
if (vault.encrypted) {
|
||||
await this.getKey(vault, false)
|
||||
@ -204,9 +206,13 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
||||
}
|
||||
|
||||
render() {
|
||||
// <Unlock height={undefined} width={undefined} />}
|
||||
// <Lock height={undefined} width={undefined} />
|
||||
let elms = this.state.vaults.map(vault => {
|
||||
return <li class="vaults_vault" onClick={() => this.openVault(vault)} onContextMenu={(evt) => this.onContext(evt, vault)}>
|
||||
{vault.encrypted ? <Lock height={undefined} width={undefined} /> : <Unlock height={undefined} width={undefined} />}
|
||||
{vault.encrypted ? <img src={Lock} /> : <img src={Unlock} />}
|
||||
|
||||
|
||||
<span>
|
||||
{vault.name}
|
||||
</span>
|
||||
@ -216,14 +222,17 @@ export default class VaultsPage extends Page<VaultsProps, { vaults: VaultList, m
|
||||
return <div style={{ marginTop: "-12px", paddingTop: "12px" }} >
|
||||
{/* {this.state.modal} */}
|
||||
{this.state.context}
|
||||
<header class="uk-background-primary">
|
||||
<span></span>
|
||||
<h3 style="display:inline" class="header_title" onClick={() => Navigation.setPage("/")}>Your vaults:</h3>
|
||||
<header class="header">
|
||||
<span></span>
|
||||
<h3 style="display:inline" onClick={() => Navigation.setPage("/")}>{this.props.selectVault ? "Select Vault for share" : "Your vaults:"}</h3>
|
||||
<a class="header-icon-button" onClick={() => Navigation.setPage("/settings")}>
|
||||
<img src={Settings} />
|
||||
{/* <Settings height={undefined} width={undefined} /> */}
|
||||
</a>
|
||||
</header>
|
||||
<AddButton onClick={() => this.addButtonClick()} />
|
||||
<div class="uk-container">
|
||||
<ul class="uk-list uk-list-divider">
|
||||
<div class="container">
|
||||
<ul class="list list-divider list-clickable">
|
||||
{elms}
|
||||
</ul>
|
||||
</div>
|
19
src/Views/Vaults/vaults.scss
Executable file
19
src/Views/Vaults/vaults.scss
Executable file
@ -0,0 +1,19 @@
|
||||
.vaults_vault {
|
||||
display: flex;
|
||||
padding: 0.5rem;
|
||||
margin-top: 0 !important;
|
||||
align-items: flex-end;
|
||||
justify-content: start;
|
||||
|
||||
>span {
|
||||
font-size: 1.5rem;
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
|
||||
>svg {
|
||||
display: inline-block;
|
||||
height: 1.5em;
|
||||
width: 1.5em;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
}
|
@ -3,10 +3,12 @@ import "./add_button.scss";
|
||||
import Plus from "feather-icons/dist/icons/plus.svg";
|
||||
export default function AddButton({ onClick }: { onClick: () => void }) {
|
||||
return <button
|
||||
title={"add button"}
|
||||
class="add-button-button uk-button-primary uk-border-circle def-shadow"
|
||||
title="add button"
|
||||
class="fab btn-primary"
|
||||
onClick={() => onClick()}
|
||||
>
|
||||
<Plus width={undefined} height={undefined} />
|
||||
<img src={Plus} />
|
||||
</button>
|
||||
}
|
||||
}
|
||||
|
||||
// <Plus width={undefined} height={undefined} />
|
@ -40,7 +40,7 @@ export class Footer extends Component<{}, { synced: boolean, syncing: boolean }>
|
||||
}
|
||||
|
||||
render() {
|
||||
let extrac = "";
|
||||
let extrac = undefined;
|
||||
let color;
|
||||
let text;
|
||||
if (this.state.syncing) {
|
||||
@ -56,15 +56,22 @@ export class Footer extends Component<{}, { synced: boolean, syncing: boolean }>
|
||||
text = "not synced";
|
||||
}
|
||||
}
|
||||
return <footer class="uk-background-default def-shadow">
|
||||
return <footer class="elv-8">
|
||||
<span>
|
||||
<span class={extrac} ><a onClick={() => this.onSyncClick()} ><Refresh style="height: 1em; width: 1em;"></Refresh></a></span>
|
||||
<span class={extrac} >
|
||||
<a onClick={() => this.onSyncClick()} >
|
||||
<img src={Refresh} style="height: 1em; width: 1em;" />
|
||||
{/* <Refresh style="height: 1em; width: 1em;"></Refresh> */}
|
||||
</a>
|
||||
</span>
|
||||
<span style={"margin-left: 8px; color:" + color}>{text}</span>
|
||||
</span>
|
||||
<span>
|
||||
Welcome <b>{Notes.name}</b>
|
||||
</span>
|
||||
<span style="color: lightgrey;">
|
||||
v1.4
|
||||
</span>
|
||||
</footer>
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { h, Component } from 'preact';
|
||||
import { h, Component, JSX } from 'preact';
|
||||
import Navigation from '../navigation';
|
||||
import "./routing.scss"
|
||||
|
||||
@ -26,7 +26,7 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
|
||||
render() {
|
||||
let overlay;
|
||||
if (this.state.next) {
|
||||
overlay = <div class="transition_container transition_slidein uk-background-default" key={this.state.next.key} ref={(elm: HTMLDivElement) => {
|
||||
overlay = <div class="transition_container transition_slidein background-default" key={this.state.next.key} ref={(elm: HTMLDivElement) => {
|
||||
let lst = () => {
|
||||
if (this.state.next)
|
||||
this.setState({ current: this.state.next, next: undefined }, () => {
|
||||
@ -42,8 +42,8 @@ export class Router extends Component<{}, { next?: JSX.Element, current: JSX.Ele
|
||||
{this.state.next}
|
||||
</div>
|
||||
}
|
||||
return <div style="position: relative; overflow-x: hidden; width: 100vw; height: 100vh;">
|
||||
<div class="transition_container uk-background-default" key={this.state.current.key} ref={elm => this.mounted = elm}>
|
||||
return <div style="position: relative; overflow-x: hidden; width: 100vw; height: calc(100vh - 2rem);">
|
||||
<div class="transition_container background-default" key={this.state.current.key} ref={elm => this.mounted = elm}>
|
||||
{this.state.current}
|
||||
</div>
|
||||
{overlay}
|
||||
|
@ -8,6 +8,8 @@
|
||||
>button {
|
||||
margin: 0;
|
||||
display: block;
|
||||
background-color: rgb(224, 224, 224);
|
||||
color: black;
|
||||
}
|
||||
|
||||
>*:not(:last-child) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { h } from "preact";
|
||||
import { h, JSX } from "preact";
|
||||
import "./context.scss";
|
||||
|
||||
export default function ContextMenu({ children, event }: { children: JSX.Element | JSX.Element[], event: MouseEvent }) {
|
||||
|
@ -1,23 +1,31 @@
|
||||
@import "../vars.scss";
|
||||
|
||||
.reloading { animation: turner 1s infinite linear }
|
||||
.reloading {
|
||||
display: inline-block;
|
||||
animation: turner 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes turner{
|
||||
from{ transform: rotate(0deg) }
|
||||
to { transform: rotate(360deg) }
|
||||
@keyframes turner {
|
||||
from {
|
||||
transform: rotate(0deg)
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(360deg)
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
z-index: 128;
|
||||
// z-index: 128;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
// border-top: 1px solid $border-color;
|
||||
|
||||
padding: 0.15em !important;
|
||||
|
||||
padding: 0.15em 1em !important;
|
||||
}
|
@ -27,27 +27,24 @@ export class InputModal extends Modal<string> {
|
||||
|
||||
render() {
|
||||
return <Modal.BaseModal modal={this.props.modal}>
|
||||
<div class="uk-form-horizontal uk-margin-large">
|
||||
<div class="uk-margin">
|
||||
<label class="uk-form-label" for={this.rand}>{this.props.modal.fieldname}</label>
|
||||
<div class="uk-form-controls">
|
||||
<input
|
||||
class="uk-input"
|
||||
id={this.rand}
|
||||
type={this.props.modal.type}
|
||||
placeholder={this.props.modal.fieldname}
|
||||
autofocus
|
||||
ref={elm => { this.input = elm; }}
|
||||
onKeyDown={evt => {
|
||||
if (evt.keyCode === 13) {
|
||||
this.props.modal.result(this.input.value)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div class="input-group">
|
||||
<label for={this.rand}>{this.props.modal.fieldname}</label>
|
||||
<input
|
||||
id={this.rand}
|
||||
type={this.props.modal.type}
|
||||
placeholder={this.props.modal.fieldname}
|
||||
autofocus
|
||||
ref={elm => { this.input = elm; }}
|
||||
onKeyDown={evt => {
|
||||
if (evt.keyCode === 13) {
|
||||
this.props.modal.result(this.input.value)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div class="uk-margin" style="text-align: right;">
|
||||
<button class="uk-button uk-button-primary" style="display: inline-block;" onClick={() => {
|
||||
<div class="modal-action">
|
||||
<button class="btn btn-primary" onClick={() => {
|
||||
this.props.modal.result(this.input.value);
|
||||
}}>Enter</button>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@ export default class LoadingModal extends Modal<undefined> {
|
||||
getComponent() {
|
||||
return <Modal.BaseModal modal={this}>
|
||||
<div style="display: flex; justify-content: center;">
|
||||
<div style="margin: 3rem;" class="uk-spinner uk-icon">
|
||||
<div style="margin: 3rem;" class="">
|
||||
<svg width="90" height="90" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg" data-svg="spinner"><circle fill="none" stroke="#000" cx="15" cy="15" r="14" style="stroke-width: 0.333333px;"></circle></svg>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Observable } from "@hibas123/utils";
|
||||
import { h, Component } from "preact";
|
||||
import { h, Component, JSX } from "preact";
|
||||
import CloseIcon from "feather-icons/dist/icons/x.svg";
|
||||
|
||||
export default abstract class Modal<T> {
|
||||
@ -65,12 +65,13 @@ export default abstract class Modal<T> {
|
||||
this.props.modal.result(null)
|
||||
}
|
||||
}}>
|
||||
<div id="ModalContent" class="uk-card uk-card-body uk-card-body" >
|
||||
<div class="modal-title uk-card-title" style="">
|
||||
<div id="ModalContent" class="modal" >
|
||||
<div class="modal-title" style="">
|
||||
<h3>{this.props.modal.title}</h3>
|
||||
{/* <div> */}
|
||||
{!this.props.modal.noClose ?
|
||||
<CloseIcon onClick={() => this.props.modal.result(null)} width={undefined} height={undefined} />
|
||||
<img src={CloseIcon} onClick={() => this.props.modal.result(null)} />
|
||||
// <CloseIcon onClick={() => this.props.modal.result(null)} width={undefined} height={undefined} />
|
||||
: undefined
|
||||
}
|
||||
{/* </div> */}
|
||||
|
@ -28,15 +28,13 @@ export class YesNoModal extends Modal<boolean> {
|
||||
|
||||
render() {
|
||||
return <Modal.BaseModal modal={this.props.modal}>
|
||||
<div class="uk-margin-large">
|
||||
<div style="text-align: right;">
|
||||
<button class="uk-button uk-button-primary uk-margin-right" style="display: inline-block;" onClick={() => {
|
||||
this.props.modal.result(false);
|
||||
}}><span style="text-decoration: underline;">N</span>o</button>
|
||||
<button class="uk-button uk-button-primary" style="display: inline-block;" onClick={() => {
|
||||
this.props.modal.result(true);
|
||||
}}><span style="text-decoration: underline;">Y</span>es</button>
|
||||
</div>
|
||||
<div class="modal-action">
|
||||
<button class="btn-primary" onClick={() => {
|
||||
this.props.modal.result(false);
|
||||
}}><span style="text-decoration: underline;">N</span>o</button>
|
||||
<button class="btn-primary" onClick={() => {
|
||||
this.props.modal.result(true);
|
||||
}}><span style="text-decoration: underline;">Y</span>es</button>
|
||||
</div>
|
||||
</Modal.BaseModal>
|
||||
}
|
||||
|
@ -4,24 +4,25 @@
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
z-index: 32;
|
||||
animation: darkenBackground .2s linear;
|
||||
background: rgba(0, 0, 0, 0.8)
|
||||
}
|
||||
|
||||
.modal-container>.uk-card {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 10%;
|
||||
width: 80%;
|
||||
max-width: 800px;
|
||||
margin: auto;
|
||||
background: white;
|
||||
@keyframes darkenBackground {
|
||||
from {
|
||||
background: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
to {
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
display:flex;
|
||||
justify-content:space-between;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
>svg {
|
||||
height: 1em;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
span {
|
||||
margin-left: 3px;
|
||||
word-break: break-word;
|
||||
@ -56,5 +57,5 @@
|
||||
margin-right:var(--notification-margin);
|
||||
padding: 0.5em;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
// transition: all .3s;
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import { h, Component } from "preact";
|
||||
import Notes from "../notes";
|
||||
|
||||
import "./notifications.scss"
|
||||
import Notifications, { MessageType } from "../notifications";
|
||||
@ -37,11 +36,11 @@ export default class NotificationsComponent extends Component<{}, {
|
||||
this.setState({ notifications: n });
|
||||
setTimeout(() => {
|
||||
this.removeNot(not);
|
||||
}, 3000);
|
||||
}, 20000);
|
||||
}
|
||||
|
||||
removeNot(not: { message: string }) {
|
||||
let n = this.state.notifications.slice(0).filter(e => e !== not);
|
||||
let n = this.state.notifications.filter(e => e !== not);
|
||||
this.setState({ notifications: n });
|
||||
}
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
|
||||
|
||||
.vault-vault {
|
||||
width: 100%;
|
||||
>div {
|
||||
width: 100%;
|
||||
font-size: 1rem;
|
||||
margin-left: 1rem;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
>div:nth-of-type(1) {
|
||||
font-size: 1.3rem;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
>div:empty {
|
||||
&::before{
|
||||
content: " ";
|
||||
white-space: pre;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// .vault_vault {
|
||||
// padding: 0.5rem;
|
||||
// border-bottom: solid 1px var(--card-border-color);
|
||||
// }
|
||||
|
||||
// .vault_vault:hover {
|
||||
// background: var(--nav-hover-back-color);
|
||||
// }
|
||||
|
||||
// .vault_vault>svg {
|
||||
// height: 2rem;
|
||||
// margin-right: 1rem;
|
||||
// }
|
||||
|
||||
// .vault_vault:last-child {
|
||||
// border-bottom: none;
|
||||
// }
|
@ -1,23 +0,0 @@
|
||||
@import "../../../vars.scss";
|
||||
|
||||
.vaults_vault {
|
||||
padding: 0.5rem;
|
||||
margin-top: 0 !important;
|
||||
|
||||
// >span {
|
||||
// font-size: 2rem !important;
|
||||
// }
|
||||
|
||||
// &:not(:last-child) {
|
||||
// border-bottom: 1px $border_color solid;
|
||||
// }
|
||||
|
||||
>svg {
|
||||
height: 2rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: $hover-background;
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
|
||||
.transition_slidein {
|
||||
@ -21,6 +20,7 @@
|
||||
from {
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
to {
|
||||
left: 0%;
|
||||
}
|
||||
|
3308
src/encoding.js
Normal file
3308
src/encoding.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,12 @@
|
||||
import { Lock } from "@hibas123/utils";
|
||||
|
||||
import { DB, openDb, Transaction } from "idb";
|
||||
import { openDB, IDBPDatabase, IDBPTransaction, } from "idb";
|
||||
|
||||
export default class IDB {
|
||||
initLock = new Lock();
|
||||
db: DB;
|
||||
db: IDBPDatabase;
|
||||
constructor(database: string, private stores: string[]) {
|
||||
let lock = this.initLock.getLock();
|
||||
lock.then(async l => {
|
||||
|
||||
this.initLock.getLock().then(async l => {
|
||||
let v = localStorage.getItem(database + "_version");
|
||||
let version = 0;
|
||||
if (v) version = Number(v)
|
||||
@ -21,12 +19,15 @@ export default class IDB {
|
||||
localStorage.setItem(database + "_version", version.toString());
|
||||
localStorage.setItem(database + "_stores", stores.join(","));
|
||||
|
||||
this.db = await openDb(database, version, db => {
|
||||
console.log("IndexedDB need update")
|
||||
stores.forEach(store => {
|
||||
if (!db.objectStoreNames.contains(store))
|
||||
db.createObjectStore(store);
|
||||
})
|
||||
this.db = await openDB(database, version, {
|
||||
upgrade: (db) => {
|
||||
console.log("IndexedDB need update")
|
||||
const check = name => (<any>db.objectStoreNames as DOMStringList).contains ? (<any>db.objectStoreNames as DOMStringList).contains(name) : db.objectStoreNames.find(e => e === name);
|
||||
stores.forEach(store => {
|
||||
if (!check(store))
|
||||
db.createObjectStore(store);
|
||||
})
|
||||
},
|
||||
})
|
||||
console.log("Got DATABASE", this.db)
|
||||
l.release();
|
||||
@ -48,42 +49,42 @@ export default class IDB {
|
||||
return {
|
||||
name: name,
|
||||
transaction: () => {
|
||||
return this.db.transaction(name, "readwrite")
|
||||
return <any>this.db.transaction(name, "readwrite") as IDBPTransaction<unknown, string[]>;
|
||||
},
|
||||
get: async (key: string, transaction?: Transaction): Promise<T> => {
|
||||
get: async (key: string, transaction?: IDBPTransaction<unknown, string[]>): Promise<T> => {
|
||||
(await this.initLock.getLock()).release()
|
||||
return (transaction || this.db.transaction(name))
|
||||
.objectStore(name).get(key);
|
||||
},
|
||||
|
||||
getAll: async (transaction?: Transaction): Promise<T[]> => {
|
||||
getAll: async (transaction?: IDBPTransaction<unknown, string[]>): Promise<T[]> => {
|
||||
(await this.initLock.getLock()).release()
|
||||
return (transaction || this.db.transaction(name))
|
||||
.objectStore(name).getAll();
|
||||
},
|
||||
|
||||
set: async (key: string, val: T, transaction?: Transaction) => {
|
||||
set: async (key: string, val: T, transaction?: IDBPTransaction<unknown, string[]>) => {
|
||||
(await this.initLock.getLock()).release()
|
||||
const tx = (transaction || this.db.transaction(name, "readwrite"));
|
||||
tx.objectStore(name).put(val, key);
|
||||
return tx.complete;
|
||||
return tx.done;
|
||||
},
|
||||
|
||||
delete: async (key: string, transaction?: Transaction) => {
|
||||
delete: async (key: string, transaction?: IDBPTransaction<unknown, string[]>) => {
|
||||
(await this.initLock.getLock()).release()
|
||||
const tx = (transaction || this.db.transaction(name, "readwrite"));
|
||||
tx.objectStore(name).delete(key);
|
||||
return tx.complete;
|
||||
return tx.done;
|
||||
},
|
||||
|
||||
clear: async (transaction?: Transaction) => {
|
||||
clear: async (transaction?: IDBPTransaction<unknown, string[]>) => {
|
||||
(await this.initLock.getLock()).release()
|
||||
const tx = (transaction || this.db.transaction(name, "readwrite"));
|
||||
tx.objectStore(name).clear();
|
||||
return tx.complete;
|
||||
return tx.done;
|
||||
},
|
||||
|
||||
keys: async (transaction?: Transaction): Promise<string[]> => {
|
||||
keys: async (transaction?: IDBPTransaction<unknown, string[]>): Promise<string[]> => {
|
||||
(await this.initLock.getLock()).release()
|
||||
const tx = (transaction || this.db.transaction(name));
|
||||
const keys: string[] = [];
|
||||
@ -91,13 +92,15 @@ export default class IDB {
|
||||
|
||||
// This would be store.getAllKeys(), but it isn't supported by Edge or Safari.
|
||||
// openKeyCursor isn't supported by Safari, so we fall back
|
||||
(store.iterateKeyCursor || store.iterateCursor).call(store, (cursor: any) => {
|
||||
if (!cursor) return;
|
||||
keys.push(cursor.key);
|
||||
cursor.continue();
|
||||
});
|
||||
store.getAllKeys()
|
||||
|
||||
return tx.complete.then(() => keys);
|
||||
// (store.iterateKeyCursor || store.iterateCursor).call(store, (cursor: any) => {
|
||||
// if (!cursor) return;
|
||||
// keys.push(cursor.key);
|
||||
// cursor.continue();
|
||||
// });
|
||||
|
||||
return tx.done.then(() => keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta charset="utf8" />
|
||||
<meta name="Description" content="Notes app">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
<link rel="manifest" href="./manifest.json">
|
||||
<!-- <link rel="shortcut icon" href="/public/icon-72x72.png"> -->
|
||||
|
||||
<!-- Add to home screen for Safari on iOS -->
|
||||
@ -15,10 +15,11 @@
|
||||
<meta name="apple-mobile-web-app-title" content="Secure Notes">
|
||||
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#3E9AE9">
|
||||
<meta name="msapplication-TileColor" content="#3E9AE9">
|
||||
<meta name="theme-color" content="#3E9AE9">
|
||||
<!-- <link rel="apple-touch-icon" sizes="180x180" href="../public/apple-touch-icon.png"> -->
|
||||
<!-- <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#1E88E5"> -->
|
||||
<script src="./encoding.js"></script>
|
||||
<meta name="msapplication-TileColor" content="#1E88E5">
|
||||
<meta name="theme-color" content="#1E88E5">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -44,7 +45,7 @@
|
||||
console.warn("Disabling Service Worker in debug mode!")
|
||||
} else {
|
||||
// Register the ServiceWorker
|
||||
navigator.serviceWorker.register('/serviceworker.js', {
|
||||
navigator.serviceWorker.register('./serviceworker.ts', {
|
||||
scope: '/'
|
||||
}).then(function (reg) {
|
||||
console.log('Service worker has been registered for scope:' + reg.scope);
|
||||
@ -55,6 +56,7 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script src="./index.tsx"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
39
src/index.scss
Executable file → Normal file
39
src/index.scss
Executable file → Normal file
@ -1,25 +1,16 @@
|
||||
@import "./vars.scss";
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Roboto', sans-serif; // font-family: Verdana, Geneva, sans-serif;
|
||||
font-size: 18px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overscroll-behavior-y: contain;
|
||||
}
|
||||
|
||||
html {
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
}
|
||||
// html {
|
||||
// min-height: 100%;
|
||||
// display: flex;
|
||||
// }
|
||||
|
||||
$header-margin: .5em;
|
||||
$header-icon-size: calc(1.5rem * 1);
|
||||
// $header-icon-size: calc(1.5rem * 1);
|
||||
// $header-icon-size: 100%;
|
||||
|
||||
header {
|
||||
@ -33,6 +24,8 @@ header {
|
||||
|
||||
>* {
|
||||
margin: 0;
|
||||
color: white;
|
||||
background: var(--primary);
|
||||
}
|
||||
|
||||
>.header-title {
|
||||
@ -49,17 +42,21 @@ header {
|
||||
display: block;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
color: black;
|
||||
min-width: $header-icon-size;
|
||||
// min-width: $header-icon-size;
|
||||
|
||||
>svg {
|
||||
height: $header-icon-size;
|
||||
width: $header-icon-size;
|
||||
}
|
||||
// >svg {
|
||||
// height: $header-icon-size;
|
||||
// width: $header-icon-size;
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
body {
|
||||
overscroll-behavior-y: contain;
|
||||
}
|
||||
|
||||
.def-shadow {
|
||||
box-shadow: 0px 5px 8px 2px rgba(66, 66, 66, 0.53);
|
||||
}
|
||||
|
@ -5,32 +5,32 @@ declare global {
|
||||
debug: any;
|
||||
}
|
||||
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
"wired-button": HTMLAttributes;
|
||||
"wired-card": HTMLAttributes;
|
||||
"wired-checkbox": HTMLAttributes;
|
||||
"wired-combo": HTMLAttributes;
|
||||
"wired-fab": HTMLAttributes;
|
||||
"wired-icon-button": HTMLAttributes;
|
||||
"wired-input": HTMLAttributes;
|
||||
"wired-item": HTMLAttributes;
|
||||
"wired-lib": HTMLAttributes;
|
||||
"wired-listbox": HTMLAttributes;
|
||||
"wired-progress": HTMLAttributes;
|
||||
"wired-radio-group": HTMLAttributes;
|
||||
"wired-radio": HTMLAttributes;
|
||||
"wired-slider": HTMLAttributes;
|
||||
"wired-spinner": HTMLAttributes;
|
||||
"wired-tabs": HTMLAttributes;
|
||||
"wired-textarea": HTMLAttributes;
|
||||
"wired-toggle": HTMLAttributes;
|
||||
"wired-tooltip": HTMLAttributes;
|
||||
// namespace JSX {
|
||||
// interface IntrinsicElements {
|
||||
// "wired-button": HTMLAttributes;
|
||||
// "wired-card": HTMLAttributes;
|
||||
// "wired-checkbox": HTMLAttributes;
|
||||
// "wired-combo": HTMLAttributes;
|
||||
// "wired-fab": HTMLAttributes;
|
||||
// "wired-icon-button": HTMLAttributes;
|
||||
// "wired-input": HTMLAttributes;
|
||||
// "wired-item": HTMLAttributes;
|
||||
// "wired-lib": HTMLAttributes;
|
||||
// "wired-listbox": HTMLAttributes;
|
||||
// "wired-progress": HTMLAttributes;
|
||||
// "wired-radio-group": HTMLAttributes;
|
||||
// "wired-radio": HTMLAttributes;
|
||||
// "wired-slider": HTMLAttributes;
|
||||
// "wired-spinner": HTMLAttributes;
|
||||
// "wired-tabs": HTMLAttributes;
|
||||
// "wired-textarea": HTMLAttributes;
|
||||
// "wired-toggle": HTMLAttributes;
|
||||
// "wired-tooltip": HTMLAttributes;
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// declare const window: Window;
|
||||
declare const window: Window;
|
||||
|
||||
window.requestIdleCallback =
|
||||
window.requestIdleCallback ||
|
||||
@ -64,21 +64,31 @@ import { h, render } from 'preact';
|
||||
import App from './components/App';
|
||||
|
||||
|
||||
import "uikit";
|
||||
import "uikit/dist/css/uikit.css"
|
||||
// import "uikit";
|
||||
// import "uikit/dist/css/uikit.css"
|
||||
import "@hibas123/theme/out/base.css"
|
||||
// import "@hibas123/theme/out/light.css"
|
||||
// import "@hibas123/theme/out/dark.css"
|
||||
|
||||
import "./index.scss";
|
||||
import Navigation from './navigation';
|
||||
import VaultsPage from './components/routes/vaults/Vaults';
|
||||
import VaultsPage from './Views/Vaults/Vaults';
|
||||
import { Page } from './page';
|
||||
|
||||
import Notes from "./notes"
|
||||
import DemoPage from './components/demo';
|
||||
import VaultPage from './components/routes/vault/Vault';
|
||||
import SharePage from './components/routes/share/Share';
|
||||
import VaultPage from './Views/Vault/Vault';
|
||||
import SharePage from './Views/Share/Share';
|
||||
import Notifications from './notifications';
|
||||
import Error404Page from './Views/404';
|
||||
import SettingsPage from './Views/Settings/Settings';
|
||||
window.debug.notes = Notes;
|
||||
|
||||
|
||||
import Theme from "./theme";
|
||||
|
||||
console.log("Dark mode:", Theme.active);
|
||||
|
||||
(async () => {
|
||||
// Initialize notes provider
|
||||
if (Notes.loginRequired()) {
|
||||
@ -89,21 +99,38 @@ window.debug.notes = Notes;
|
||||
let err = await Notes.getToken(code)
|
||||
if (err) {
|
||||
Notifications.sendError("Login failed: " + err)
|
||||
Notes.login()
|
||||
return Notes.login()
|
||||
} else {
|
||||
window.history.replaceState(null, document.title, "/" + window.location.hash);
|
||||
}
|
||||
} else {
|
||||
Notes.login()
|
||||
return Notes.login()
|
||||
}
|
||||
}
|
||||
|
||||
await Notes.start();
|
||||
|
||||
if (window.navigator.storage && navigator.storage.persist) {
|
||||
navigator.storage.persisted()
|
||||
.then(has => has ? true : navigator.storage.persist())
|
||||
.then(is => {
|
||||
console.log("Persistant Storage:", is);
|
||||
})
|
||||
}
|
||||
|
||||
Navigation.default = VaultsPage as typeof Page;
|
||||
Navigation.addPage("/vault", VaultPage as typeof Page)
|
||||
Navigation.addPage("/demo", DemoPage as typeof Page)
|
||||
Navigation.addPage("/share", SharePage as typeof Page)
|
||||
Navigation.addPage("/settings", SettingsPage as typeof Page)
|
||||
Navigation.addPage("/404", Error404Page);
|
||||
const trad = window.location.pathname;
|
||||
if (trad && trad !== "/" && trad !== "") {
|
||||
let p: any = {};
|
||||
new URL(window.location.href).searchParams.forEach((val, key) => p[key] = val);
|
||||
Navigation.setPage(trad, p, undefined, true);
|
||||
// window.location.href = "/#/" + trad;
|
||||
}
|
||||
Navigation.start();
|
||||
|
||||
render(<App />, document.body, document.getElementById('app'));
|
||||
|
@ -3,10 +3,9 @@
|
||||
"name": "Secure Notes",
|
||||
"decription": "A place to store your notes securly",
|
||||
"share_target": {
|
||||
"url_template": "/#/share?title={title}&text={text}&url={url}",
|
||||
"action": "/share",
|
||||
"method": "GET",
|
||||
"enctype": "application/x-www-form-urlencoded",
|
||||
"action": "/",
|
||||
"params": {
|
||||
"title": "title",
|
||||
"text": "text",
|
||||
@ -51,6 +50,6 @@
|
||||
],
|
||||
"start_url": "/",
|
||||
"display": "standalone",
|
||||
"theme_color": "#e188e5",
|
||||
"theme_color": "#1E88E5",
|
||||
"background_color": "#ffffff"
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { Observable } from "@hibas123/utils";
|
||||
import { Page, PageProps } from "./page";
|
||||
import { h, VNode } from "preact";
|
||||
import { h, VNode, JSX } from "preact";
|
||||
|
||||
function serializQuery(obj: any) {
|
||||
var str = [];
|
||||
@ -23,9 +23,10 @@ function parseQuery(query: string) {
|
||||
return data
|
||||
}
|
||||
|
||||
type PageFunction = () => JSX.Element;
|
||||
|
||||
export default class Navigation {
|
||||
private static _pages: Map<string, typeof Page> = new Map();
|
||||
private static _pages: Map<string, typeof Page | PageFunction> = new Map();
|
||||
private static _page: { route: string, page: JSX.Element };
|
||||
private static pageObservableServer = new Observable<JSX.Element>();
|
||||
public static pageObservable = Navigation.pageObservableServer.getPublicApi();
|
||||
@ -34,7 +35,7 @@ export default class Navigation {
|
||||
|
||||
private static _page_cache = new Map<string, VNode<any>>();
|
||||
|
||||
public static addPage(route: string, comp: typeof Page) {
|
||||
public static addPage(route: string, comp: typeof Page | PageFunction) {
|
||||
Navigation._pages.set(route, comp);
|
||||
}
|
||||
|
||||
@ -69,9 +70,9 @@ export default class Navigation {
|
||||
let oldkey = whash + serializQuery(history.state);
|
||||
if (newkey !== oldkey) {
|
||||
if (replace)
|
||||
window.history.replaceState(hidden, document.title, newhash);
|
||||
window.history.replaceState(hidden, document.title, "./" + newhash);
|
||||
else
|
||||
window.history.pushState(hidden, document.title, newhash);
|
||||
window.history.pushState(hidden, document.title, "./" + newhash);
|
||||
}
|
||||
let page = this._page_cache.get(newkey);
|
||||
if (!page) {
|
||||
|
32
src/notes.ts
32
src/notes.ts
@ -1,8 +1,14 @@
|
||||
import * as config from "../config.json"
|
||||
import { Lock, Observable } from "@hibas123/utils"
|
||||
|
||||
import SecureFile, { IFile } from "@hibas123/secure-file-wrapper";
|
||||
import * as b64 from "./helper/base64"
|
||||
import { Lock, Observable } from "@hibas123/utils";
|
||||
import * as aesjs from "aes-js";
|
||||
import { IDBPTransaction } from "idb";
|
||||
import { sha256 } from "js-sha256";
|
||||
import uuidv4 from "uuid/v4";
|
||||
import * as config from "../config.json";
|
||||
import * as b64 from "./helper/base64";
|
||||
import IDB from "./helper/indexeddb";
|
||||
import Notifications, { MessageType } from "./notifications";
|
||||
|
||||
|
||||
export class HttpError extends Error {
|
||||
constructor(public status: number, public statusText: string) {
|
||||
@ -32,13 +38,8 @@ export interface ViewNote extends BaseNote {
|
||||
__value: string;
|
||||
}
|
||||
|
||||
import * as aesjs from "aes-js";
|
||||
import { sha256 } from "js-sha256"
|
||||
import clonedeep = require("lodash.clonedeep");
|
||||
import * as uuidv4 from "uuid/v4"
|
||||
import IDB from "./helper/indexeddb";
|
||||
import { Transaction } from "idb";
|
||||
import Notifications, { MessageType } from "./notifications";
|
||||
import uuid = require("uuid");
|
||||
|
||||
const Encoder = new TextEncoder();
|
||||
const Decoder = new TextDecoder();
|
||||
@ -81,6 +82,7 @@ export interface IVault {
|
||||
saveNote(note: ViewNote, date?: Date): Promise<void>;
|
||||
getNote(id: string): Promise<ViewNote>;
|
||||
deleteNote(id: string): Promise<void>;
|
||||
// type: string; //Defines type of plugin, that is required to handle this vault
|
||||
}
|
||||
|
||||
const awaitTimeout = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms));
|
||||
@ -172,7 +174,7 @@ class NotesProvider {
|
||||
}
|
||||
this.syncedObservableServer.send((await this.oplogDB.getAll()).length <= 0);
|
||||
let prs = this.apiLockRls.then(lock => lock.release());
|
||||
prs.then(() => awaitTimeout(5000)).then(() => this.sync()).then(() => next());
|
||||
prs.then(() => awaitTimeout(2000)).then(() => this.sync()).then(() => next());
|
||||
return prs;
|
||||
}
|
||||
|
||||
@ -420,6 +422,7 @@ class NotesProvider {
|
||||
}
|
||||
|
||||
public async createVault(name: string, key?: Uint8Array) {
|
||||
// console.log(uuidv4, uuid);
|
||||
let vault: DBNote = {
|
||||
__value: this.encrypt("__BASELINE__", key),
|
||||
_id: uuidv4(),
|
||||
@ -480,7 +483,7 @@ class NotesProvider {
|
||||
return Decoder.decode(this._decrypt(msg, this.generalEncryption))
|
||||
}
|
||||
|
||||
async addop(note_id: string, type: OpLogType, values: { value: Uint8Array, preview: Uint8Array }, date: Date, transaction?: Transaction) {
|
||||
async addop(note_id: string, type: OpLogType, values: { value: Uint8Array, preview: Uint8Array }, date: Date, transaction?: IDBPTransaction<unknown, string[]>) {
|
||||
let tx = transaction || this.oplogDB.transaction();
|
||||
let oplog = await this.oplogDB.get(note_id, tx);
|
||||
if (!oplog) oplog = { logs: [], id: note_id };
|
||||
@ -524,6 +527,7 @@ class NotesProvider {
|
||||
async getAllNotes() {
|
||||
return Notes.noteDB.getAll()
|
||||
.then(all => all.filter(e => e.folder === this.vault._id)
|
||||
.sort(this.sort)
|
||||
.map<BaseNote>(e => {
|
||||
let new_note = clonedeep(<Note>e) as BaseNote
|
||||
delete (<any>new_note).__value
|
||||
@ -532,6 +536,10 @@ class NotesProvider {
|
||||
}));
|
||||
}
|
||||
|
||||
private sort(a: DBNote, b: DBNote) {
|
||||
return new Date(b.time).getTime() - new Date(a.time).getTime();
|
||||
}
|
||||
|
||||
async searchNote(term: string) {
|
||||
let all = await this.getAllNotes();
|
||||
return all.filter(e => e.preview.indexOf(term) >= 0)
|
||||
|
@ -6,6 +6,7 @@ const CACHE = "offline";
|
||||
|
||||
let precacheFiles = [
|
||||
"/",
|
||||
"/index.html",
|
||||
"/main.js",
|
||||
"/main.css",
|
||||
"/serviceworker.js"
|
||||
@ -26,19 +27,9 @@ self.addEventListener('activate', (event) => {
|
||||
});
|
||||
|
||||
self.addEventListener('message', (event) => {
|
||||
if (event.data === "clear_cache") {
|
||||
log("Clearing cache");
|
||||
caches.delete(CACHE);
|
||||
}
|
||||
|
||||
if (event.data === "update_index") {
|
||||
log("Updating index");
|
||||
event.waitUntil(caches.open(CACHE).then((cache) => {
|
||||
return cache.addAll(["/", "/index.html"]).then(() => {
|
||||
event.ports[0].postMessage("reload");
|
||||
});
|
||||
}))
|
||||
}
|
||||
log("Clearing cache");
|
||||
caches.delete(CACHE);
|
||||
event.waitUntil(precache());
|
||||
});
|
||||
|
||||
var Types;
|
||||
@ -46,6 +37,7 @@ var Types;
|
||||
Types[Types["CACHE"] = 0] = "CACHE";
|
||||
Types[Types["NOCACHE"] = 1] = "NOCACHE";
|
||||
Types[Types["REFRESH"] = 2] = "REFRESH";
|
||||
Types[Types["INDEX"] = 3] = "INDEX";
|
||||
})(Types || (Types = {}));
|
||||
|
||||
let rules = [{
|
||||
@ -53,6 +45,11 @@ let rules = [{
|
||||
return url.indexOf("/api/") >= 0;
|
||||
},
|
||||
type: Types.NOCACHE
|
||||
}, {
|
||||
match: (url) => {
|
||||
return url.indexOf("/share") >= 0;
|
||||
},
|
||||
type: Types.INDEX
|
||||
},
|
||||
{
|
||||
match: () => {
|
||||
@ -77,6 +74,11 @@ self.addEventListener('fetch', (evt) => {
|
||||
});
|
||||
case Types.NOCACHE:
|
||||
return fetch(evt.request);
|
||||
case Types.INDEX:
|
||||
return refresh(new Request("/")).then(r => {
|
||||
evt.waitUntil(r.refresh.catch(_ => {}));
|
||||
return r.result;
|
||||
})
|
||||
}
|
||||
})());
|
||||
});
|
54
src/theme.ts
Normal file
54
src/theme.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
const light = readFileSync("./node_modules/@hibas123/theme/out/light.css", "utf8")
|
||||
const dark = readFileSync("./node_modules/@hibas123/theme/out/dark.css", "utf8")
|
||||
|
||||
export enum ThemeStates {
|
||||
AUTO,
|
||||
LIGHT,
|
||||
DARK
|
||||
}
|
||||
|
||||
let themeConfig: ThemeStates = Number(localStorage.getItem("theme"));
|
||||
if (Number.isNaN(themeConfig))
|
||||
themeConfig = ThemeStates.AUTO;
|
||||
|
||||
let isDark = false;
|
||||
let mediaIsDark = false;
|
||||
|
||||
if (window.matchMedia) {
|
||||
const mediaq = matchMedia("(prefers-color-scheme: dark)");
|
||||
mediaIsDark = mediaq.matches;
|
||||
mediaq.onchange = ev => {
|
||||
mediaIsDark = ev.matches;
|
||||
apply();
|
||||
}
|
||||
console.log(mediaq);
|
||||
}
|
||||
|
||||
|
||||
let styleElm: HTMLStyleElement;
|
||||
function apply(force?: boolean) {
|
||||
let shouldDark = themeConfig === ThemeStates.AUTO ? mediaIsDark : themeConfig === ThemeStates.DARK;
|
||||
if (force || shouldDark !== isDark) {
|
||||
if (styleElm) styleElm.remove();
|
||||
styleElm = document.createElement("style");
|
||||
document.head.appendChild(styleElm);
|
||||
styleElm.innerHTML = shouldDark ? dark : light;
|
||||
isDark = shouldDark;
|
||||
}
|
||||
}
|
||||
apply(true);
|
||||
|
||||
|
||||
function change(state: ThemeStates) {
|
||||
themeConfig = state;
|
||||
localStorage.setItem("theme", String(themeConfig));
|
||||
apply();
|
||||
}
|
||||
|
||||
export default {
|
||||
active: () => themeConfig,
|
||||
change: (state: ThemeStates) => change(state)
|
||||
}
|
||||
|
17
src/types.d.ts
vendored
17
src/types.d.ts
vendored
@ -1,10 +1,15 @@
|
||||
// declare module "*.svg" {
|
||||
// const SVG: (props: {
|
||||
// width?: number | undefined
|
||||
// height?: number | undefined
|
||||
// onClick?: (evt: MouseEvent) => void;
|
||||
// style?: string;
|
||||
// }) => JSX.Element;
|
||||
// export default SVG;
|
||||
// }
|
||||
|
||||
declare module "*.svg" {
|
||||
const SVG: (props: {
|
||||
width?: number | undefined
|
||||
height?: number | undefined
|
||||
onClick?: (evt: MouseEvent) => void;
|
||||
style?: string;
|
||||
}) => JSX.Element;
|
||||
const SVG: string;
|
||||
export default SVG;
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,9 @@
|
||||
:root {
|
||||
--primary: #1E88E5;
|
||||
--on-primary: white;
|
||||
// --mdc-theme-primary: var(--primary);
|
||||
// --mdc-theme-primary-bg: var(--mdc-theme--primary);
|
||||
// --mdc-theme-on-primary: white;
|
||||
--error: #ff2f00;
|
||||
--border-color: #ababab;
|
||||
--default-font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.uk-button-primary {
|
||||
background: var(--primary) !important;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.uk-background-primary {
|
||||
background: var(--primary) !important;
|
||||
color: white;
|
||||
}
|
||||
|
||||
$hover-background: #DDDDDD;
|
||||
}
|
@ -13,7 +13,8 @@
|
||||
"dom",
|
||||
"esnext"
|
||||
],
|
||||
"resolveJsonModule": true
|
||||
"resolveJsonModule": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"include": [
|
||||
"./src/types.d.ts",
|
||||
|
@ -1,5 +1,4 @@
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
const WorkboxPlugin = require("workbox-webpack-plugin");
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
@ -25,7 +24,9 @@ module.exports = {
|
||||
public: url.parse(config.callback_url).hostname
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin([{ from: "public" }]),
|
||||
new CopyWebpackPlugin([{
|
||||
from: "public"
|
||||
}]),
|
||||
new HtmlWebpackPlugin({
|
||||
title: 'SecureNotes',
|
||||
template: "./src/index.html"
|
||||
@ -39,40 +40,18 @@ module.exports = {
|
||||
openAnalyzer: false
|
||||
}),
|
||||
new Visualizer(),
|
||||
// new WorkboxPlugin.GenerateSW({
|
||||
// swDest: "sw.js",
|
||||
// importWorkboxFrom: 'local',
|
||||
// clientsClaim: true,
|
||||
// // importsDirectory: "/dist",
|
||||
// directoryIndex: 'index.html',
|
||||
// ignoreURLParametersMatching: [/./],
|
||||
// runtimeCaching: [{
|
||||
// urlPattern: /images/,
|
||||
// handler: 'CacheFirst',
|
||||
// options: {
|
||||
// cacheName: 'images',
|
||||
// expiration: {
|
||||
// maxEntries: 1000,
|
||||
// //Recheck after 30 Days
|
||||
// maxAgeSeconds: 30 * 24 * 60 * 60
|
||||
// },
|
||||
// },
|
||||
// }, {
|
||||
// urlPattern: /api/,
|
||||
// handler: 'NetworkOnly'
|
||||
// }]
|
||||
// })
|
||||
],
|
||||
entry: "./src/index.tsx",
|
||||
entry: {
|
||||
main: "./src/index.tsx"
|
||||
},
|
||||
// Enable sourcemaps for debugging webpack's output.
|
||||
devtool: "eval",
|
||||
resolve: {
|
||||
// Add '.ts' and '.tsx' as resolvable extensions.
|
||||
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"]
|
||||
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js", ".mjs"]
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
rules: [{
|
||||
test: /\.tsx?$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/
|
||||
|
Reference in New Issue
Block a user