Skip to content

Commit

Permalink
v0.0.35
Browse files Browse the repository at this point in the history
  • Loading branch information
yandeu committed Dec 20, 2022
1 parent dedc61d commit c706e29
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bundles/nano.full.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundles/nano.slim.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundles/nano.ui.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions deno_lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<a href="https://deno.land/x/nano_jsx"><img src="https://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno&labelColor=black&style=flat-square"></a>
<br/><br/>
<img src="https://badgen.net/badgesize/gzip/nanojsx/nano/master/bundles/nano.core.min.js?style=flat-square" alt="gzip size">
<a href="https://github.com/nanojsx/nano/actions?query=workflow%3ANodeJS"><img src="https://img.shields.io/github/workflow/status/nanojsx/nano/NodeJS/master?label=NodeJS&logo=github&style=flat-square"></a>
<a href="https://github.com/nanojsx/nano/actions?query=workflow%3ADeno"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/nanojsx/nano/Deno?label=Deno&logo=github&style=flat-square"></a>
<a href="https://github.com/nanojsx/nano/actions?query=workflow%3ANodeJS"><img src="https://img.shields.io/github/actions/workflow/status/nanojsx/nano/nodejs.yml?branch=master&label=NodeJS&logo=github&style=flat-square"></a>
<a href="https://github.com/nanojsx/nano/actions?query=workflow%3ADeno"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/nanojsx/nano/deno.yml?branch=master&label=Deno&logo=github&style=flat-square"></a>
<a href="https://github.com/nanojsx/nano/commits/master"><img src="https://img.shields.io/github/last-commit/nanojsx/nano.svg?style=flat-square" alt="GitHub last commit"></a>
<a href="https://github.com/sponsors/yandeu"><img src="https://img.shields.io/github/sponsors/yandeu?style=flat-square" alt="Sponsors"></a>
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square" alt="code style: prettier"></a>
Expand Down
7 changes: 7 additions & 0 deletions deno_lib/components/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ export class Switch extends Component<{ fallback?: any; children?: any }> {
// alias for <Switch />
export class Routes extends Switch {}

export interface RouteProps {
path: string
regex: { [param: string]: RegExp }
pathname: string
params: { [param: string]: string }
}

export const Route: FC<{ path: string; exact?: boolean; regex?: { [param: string]: RegExp }; children?: any }> = ({
path,
regex,
Expand Down
23 changes: 11 additions & 12 deletions deno_lib/store.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { isSSR } from './core.ts'

type State = any

export class Store {
private _state: any
private _prevState: any
export class Store<S = any> {
private _state: S
private _prevState: S
private _listeners: Map<string, Function> = new Map()
private _storage: 'memory' | 'local' | 'session'
private _id: string
Expand Down Expand Up @@ -34,25 +32,26 @@ export class Store {
} else Storage.setItem(this._id, JSON.stringify(defaultState))
}

private persist(newState: any) {
private persist(newState: S) {
if (this._storage === 'memory') return
const Storage = this._storage === 'local' ? localStorage : sessionStorage
Storage.setItem(this._id, JSON.stringify(newState))
}

/** Clears the state of the whole store. */
public clear() {
// @ts-ignore
this._state = this._prevState = undefined

if (this._storage === 'local') localStorage.removeItem(this._id)
else if (this._storage === 'session') sessionStorage.removeItem(this._id)
}

public setState(newState: any) {
public setState(newState: S) {
this.state = newState
}

public set state(newState: any) {
public set state(newState: S) {
this._prevState = this._state
this._state = newState

Expand All @@ -63,21 +62,21 @@ export class Store {
})
}

public get state(): State {
public get state(): S {
return this._state
}

public use() {
const id = Math.random().toString(36).substring(2, 9)
const _this = this
return {
get state(): State {
get state(): S {
return _this.state
},
setState: (newState: State) => {
setState: (newState: S) => {
this.state = newState
},
subscribe: (fnc: (newState: State, prevState: State) => void) => {
subscribe: (fnc: (newState: S, prevState: S) => void) => {
this._listeners.set(id, fnc)
},
cancel: () => {
Expand Down
2 changes: 1 addition & 1 deletion deno_lib/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
export const VERSION = '0.0.34'
export const VERSION = '0.0.35'
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nano-jsx",
"version": "0.0.34",
"version": "0.0.35",
"description": "SSR first, lightweight 1kB JSX library.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down Expand Up @@ -95,4 +95,4 @@
"node": ">=12"
},
"funding": "https://github.com/sponsors/yandeu"
}
}
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
export const VERSION = '0.0.34'
export const VERSION = '0.0.35'

0 comments on commit c706e29

Please sign in to comment.