This repository has been archived by the owner on Nov 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: app store * chore: store example * chore: lock * feat: init page store * feat: update page store * fix: disable reset page state * feat: createModel * test: with-store test * fix: comment * chore: lock
- Loading branch information
Showing
30 changed files
with
585 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from '@ice/app'; | ||
import store from '@ice/plugin-store'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
store(), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "with-store", | ||
"private": true, | ||
"version": "1.0.0", | ||
"scripts": { | ||
"start": "ice start", | ||
"build": "ice build" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@ice/app": "workspace:*", | ||
"@ice/runtime": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@ice/plugin-store": "workspace:*", | ||
"@types/react": "^18.0.0", | ||
"@types/react-dom": "^18.0.0", | ||
"browserslist": "^4.19.3", | ||
"regenerator-runtime": "^0.13.9" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { defineAppConfig } from 'ice'; | ||
|
||
export default defineAppConfig({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Meta, Title, Links, Main, Scripts } from 'ice'; | ||
|
||
function Document() { | ||
return ( | ||
<html> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="description" content="with-store" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<Meta /> | ||
<Title /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<Main /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
|
||
export default Document; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createModel } from '@ice/plugin-store/esm/runtime'; | ||
|
||
export default createModel({ | ||
state: { | ||
name: 'ICE 3', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Link } from 'ice'; | ||
import pageStore from './store'; | ||
|
||
function FirstPost() { | ||
const [infoState] = pageStore.useModel('info'); | ||
|
||
return ( | ||
<> | ||
<article> | ||
<h2>{infoState.posts[0].title}</h2> | ||
</article> | ||
<div><Link to="/blog">Back</Link></div> | ||
</> | ||
); | ||
} | ||
|
||
export default FirstPost; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Link } from 'ice'; | ||
import pageStore from './store'; | ||
|
||
function Blog() { | ||
const [infoState] = pageStore.useModel('info'); | ||
|
||
return ( | ||
<div> | ||
Blog Count: {infoState.posts.length} | ||
<ul> | ||
{infoState.posts.map(({ title, id }) => { | ||
return <Link to={id} key={id}><li>{title}</li></Link>; | ||
})} | ||
</ul> | ||
<Link to="/">Home</Link> | ||
</div> | ||
); | ||
} | ||
|
||
export default Blog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Outlet } from 'ice'; | ||
import store from './store'; | ||
|
||
function layout() { | ||
const [infoState] = store.useModel('info'); | ||
return ( | ||
<> | ||
<h1>{infoState.title}</h1> | ||
<Outlet /> | ||
</> | ||
); | ||
} | ||
|
||
export default layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createModel } from '@ice/plugin-store/esm/runtime'; | ||
|
||
export default createModel({ | ||
state: { | ||
title: 'ICE Blog', | ||
posts: [ | ||
{ title: 'First Post', id: 'first-post' }, | ||
], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createStore } from '@ice/plugin-store/esm/runtime'; | ||
import info from './models/info'; | ||
|
||
export default createStore({ info }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Link } from 'ice'; | ||
import pageStore from './store'; | ||
import appStore from '@/store'; | ||
|
||
function Home() { | ||
const [userState] = appStore.useModel('user'); | ||
const [countState, countDispatcher] = pageStore.useModel('counter'); | ||
return ( | ||
<> | ||
<div id="username"> | ||
name: {userState.name} | ||
</div> | ||
<div> | ||
<button type="button" id="inc" onClick={() => countDispatcher.inc()}>+</button> | ||
<span id="count">{countState.count}</span> | ||
<button type="button" id="dec" onClick={() => countDispatcher.dec()}>-</button> | ||
</div> | ||
<Link to="/blog">Blog</Link> | ||
</> | ||
); | ||
} | ||
|
||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createModel } from '@ice/plugin-store/esm/runtime'; | ||
|
||
export default createModel({ | ||
state: { | ||
count: 0, | ||
}, | ||
reducers: { | ||
inc(prevState, count = 1) { | ||
prevState.count += count; | ||
}, | ||
dec(prevState, count = 1) { | ||
prevState.count -= count; | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createStore } from '@ice/plugin-store/esm/runtime'; | ||
import counter from './models/counter'; | ||
|
||
const store = createStore({ counter }); | ||
|
||
export default store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createStore } from '@ice/plugin-store/esm/runtime'; | ||
import user from './models/user'; | ||
|
||
export default createStore({ user }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"compileOnSave": false, | ||
"buildOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build", | ||
"module": "esnext", | ||
"target": "es6", | ||
"jsx": "react-jsx", | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true, | ||
"lib": ["es6", "dom"], | ||
"sourceMap": true, | ||
"allowJs": true, | ||
"rootDir": "./", | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": false, | ||
"importHelpers": true, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true, | ||
"paths": { | ||
"@/*": ["./src/*"], | ||
"ice": [".ice"] | ||
} | ||
}, | ||
"include": ["src", ".ice", "ice.config.*"], | ||
"exclude": ["node_modules", "build", "public"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# CHANGELOG | ||
|
||
## 1.0.0 | ||
|
||
- feat: init plugin store |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "@ice/plugin-store", | ||
"version": "1.0.0", | ||
"description": "", | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./esm/index.d.ts", | ||
"import": "./esm/index.js", | ||
"default": "./esm/index.js" | ||
}, | ||
"./runtime": { | ||
"types": "./esm/runtime.d.ts", | ||
"import": "./esm/runtime.js", | ||
"default": "./esm/runtime.js" | ||
}, | ||
"./esm/runtime": { | ||
"types": "./esm/runtime.d.ts", | ||
"import": "./esm/runtime.js", | ||
"default": "./esm/runtime.js" | ||
} | ||
}, | ||
"main": "./esm/index.js", | ||
"types": "./esm/index.d.ts", | ||
"files": [ | ||
"esm", | ||
"!esm/**/*.map" | ||
], | ||
"dependencies": { | ||
"@ice/store": "^2.0.1", | ||
"fast-glob": "^3.2.11", | ||
"micromatch": "^4.0.5" | ||
}, | ||
"devDependencies": { | ||
"@ice/types": "^1.0.0", | ||
"@types/react": "^18.0.0", | ||
"@types/react-dom": "^18.0.0", | ||
"@types/micromatch": "^4.0.2", | ||
"regenerator-runtime": "^0.13.9" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0" | ||
}, | ||
"repository": { | ||
"type": "http", | ||
"url": "https://github.com/ice-lab/ice-next/tree/master/packages/plugin-store" | ||
}, | ||
"scripts": { | ||
"watch": "tsc -w", | ||
"build": "tsc" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { IcestoreDispatch, IcestoreRootState } from '@ice/store'; | ||
import { createStore } from '@ice/store'; | ||
|
||
const models = {}; | ||
|
||
const store = createStore(models); | ||
|
||
export default store; | ||
export type IRootDispatch = IcestoreDispatch<typeof models>; | ||
export type IRootState = IcestoreRootState<typeof models>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const PAGE_STORE_MODULE = '__PAGE_STORE__'; | ||
export const PAGE_STORE_PROVIDER = '__PAGE_STORE_PROVIDER__'; | ||
export const PAGE_STORE_INITIAL_STATES = '__PAGE_STORE_INITIAL_STATES__'; |
Oops, something went wrong.
45dc7a8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ice-v3 – ./
ice-v3-git-release-next-ice-v3.vercel.app
ice-v3-ice-v3.vercel.app
ice-v3.vercel.app