mise 2.0.1 → 2026.5.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +213 -81
- package/installArchSpecificPackage.js +57 -0
- package/package.json +13 -45
- package/.babelrc +0 -9
- package/.eslintrc.js +0 -30
- package/.travis.yml +0 -11
- package/LICENSE +0 -21
- package/dist/mise.js +0 -1
- package/docs/actions.md +0 -96
- package/docs/components.md +0 -40
- package/docs/lifecycle.md +0 -71
- package/docs/state.md +0 -71
- package/docs/templates.md +0 -97
- package/example/counter/counter.jsx +0 -18
- package/example/todos/todo/todo.jsx +0 -16
- package/example/todos/todo/todo.style.js +0 -6
- package/example/todos/todos.actions.js +0 -36
- package/example/todos/todos.component.js +0 -11
- package/example/todos/todos.state.js +0 -7
- package/example/todos/todos.template.jsx +0 -35
- package/src/component.js +0 -67
- package/src/dom.js +0 -27
- package/src/index.d.ts +0 -20
- package/src/index.js +0 -2
- package/src/utils.js +0 -4
- package/src/vdom.js +0 -159
- package/test/e2e/counter.test.js +0 -78
- package/test/e2e/todos.test.js +0 -211
- package/test/ts/index.test.ts +0 -12
- package/test/unit/component.test.js +0 -55
- package/test/unit/dom.test.js +0 -111
- package/test/unit/utils.test.js +0 -26
- package/test/unit/vdom/vdom.createlement.test.js +0 -42
- package/test/unit/vdom/vdom.update.test.js +0 -151
- package/tsconfig.json +0 -15
- package/webpack.config.js +0 -39
package/README.md
CHANGED
|
@@ -1,81 +1,213 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
</
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<h1 align="center">
|
|
4
|
+
<a href="https://mise.en.dev">
|
|
5
|
+
<picture>
|
|
6
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/public/logo-dark.svg" />
|
|
7
|
+
<img src="docs/public/logo-light.svg" alt="mise" width="256" height="256" />
|
|
8
|
+
</picture>
|
|
9
|
+
<br>
|
|
10
|
+
mise-en-place
|
|
11
|
+
</a>
|
|
12
|
+
</h1>
|
|
13
|
+
|
|
14
|
+
<p>
|
|
15
|
+
<a href="https://crates.io/crates/mise"><img alt="Crates.io" src="https://img.shields.io/crates/v/mise?style=for-the-badge&color=8B2252"></a>
|
|
16
|
+
<a href="https://github.com/jdx/mise/blob/main/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/jdx/mise?style=for-the-badge&color=6B7F4E"></a>
|
|
17
|
+
<a href="https://github.com/jdx/mise/actions/workflows/test.yml"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/jdx/mise/test.yml?style=for-the-badge&color=C5975B"></a>
|
|
18
|
+
<a href="https://discord.gg/mABnUDvP57"><img alt="Discord" src="https://img.shields.io/discord/1066429325269794907?style=for-the-badge&color=8B2252"></a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p><b>Dev tools, env vars, and tasks in one CLI</b></p>
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<a href="https://mise.en.dev/getting-started.html">Getting Started</a> •
|
|
25
|
+
<a href="https://mise.en.dev">Documentation</a> •
|
|
26
|
+
<a href="https://mise.en.dev/dev-tools/">Dev Tools</a> •
|
|
27
|
+
<a href="https://mise.en.dev/environments/">Environments</a> •
|
|
28
|
+
<a href="https://mise.en.dev/tasks/">Tasks</a>
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<hr />
|
|
32
|
+
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
> [!TIP]
|
|
36
|
+
> My latest project, [aube](https://aube.en.dev) just hit stable! It's the fastest Node.js package manager with strong security defaults and is compatible with npm/pnpm/yarn lockfiles!
|
|
37
|
+
|
|
38
|
+
## What is it?
|
|
39
|
+
|
|
40
|
+
`mise` prepares your development environment before each command runs. It keeps
|
|
41
|
+
project tools, environment variables, and tasks in one `mise.toml` file so new
|
|
42
|
+
shells, checkouts, and CI jobs all start from the same setup.
|
|
43
|
+
|
|
44
|
+
- Install and switch between [dev tools](https://mise.en.dev/dev-tools/) like node, python, cmake, terraform, and [hundreds more](https://mise.en.dev/registry.html).
|
|
45
|
+
- Load [environment variables](https://mise.en.dev/environments/) per project directory, including values from `.env` files and other sources.
|
|
46
|
+
- Define and run [tasks](https://mise.en.dev/tasks/) for building, testing, linting, and deploying projects.
|
|
47
|
+
|
|
48
|
+
## Demo
|
|
49
|
+
|
|
50
|
+
The following demo shows how to install and use `mise` to manage multiple versions of `node` on the same system.
|
|
51
|
+
Note that calling `which node` gives us a real path to node, not a shim.
|
|
52
|
+
|
|
53
|
+
It also shows that you can use `mise` to install and many other tools such as `jq`, `terraform`, or `go`.
|
|
54
|
+
|
|
55
|
+
[](https://mise.en.dev/demo.html)
|
|
56
|
+
|
|
57
|
+
See [demo transcript](https://mise.en.dev/demo.html).
|
|
58
|
+
|
|
59
|
+
## Quickstart
|
|
60
|
+
|
|
61
|
+
### Install mise
|
|
62
|
+
|
|
63
|
+
See [Getting started](https://mise.en.dev/getting-started.html) for more options.
|
|
64
|
+
|
|
65
|
+
```sh-session
|
|
66
|
+
$ curl https://mise.run | sh
|
|
67
|
+
$ ~/.local/bin/mise --version
|
|
68
|
+
_ __
|
|
69
|
+
____ ___ (_)_______ ___ ____ ____ / /___ _________
|
|
70
|
+
/ __ `__ \/ / ___/ _ \______/ _ \/ __ \______/ __ \/ / __ `/ ___/ _ \
|
|
71
|
+
/ / / / / / (__ ) __/_____/ __/ / / /_____/ /_/ / / /_/ / /__/ __/
|
|
72
|
+
/_/ /_/ /_/_/____/\___/ \___/_/ /_/ / .___/_/\__,_/\___/\___/
|
|
73
|
+
/_/ by @jdx
|
|
74
|
+
2026.5.18 macos-arm64 (2026-05-31)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Hook mise into your shell (pick the right one for your shell):
|
|
78
|
+
|
|
79
|
+
```sh-session
|
|
80
|
+
# note this assumes mise is located at ~/.local/bin/mise
|
|
81
|
+
# which is what https://mise.run does by default
|
|
82
|
+
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
|
|
83
|
+
echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc
|
|
84
|
+
echo '~/.local/bin/mise activate fish | source' >> ~/.config/fish/config.fish
|
|
85
|
+
echo '~/.local/bin/mise activate pwsh | Out-String | Invoke-Expression' >> ~/.config/powershell/Microsoft.PowerShell_profile.ps1
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Execute commands with specific tools
|
|
89
|
+
|
|
90
|
+
```sh-session
|
|
91
|
+
$ mise exec node@26 -- node -v
|
|
92
|
+
mise node@26.x.x ✓ installed
|
|
93
|
+
v26.x.x
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Install tools
|
|
97
|
+
|
|
98
|
+
```sh-session
|
|
99
|
+
$ mise use --global node@26 go@1
|
|
100
|
+
$ node -v
|
|
101
|
+
v26.x.x
|
|
102
|
+
$ go version
|
|
103
|
+
go version go1.x.x macos/arm64
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
See [dev tools](https://mise.en.dev/dev-tools/) for more examples.
|
|
107
|
+
|
|
108
|
+
### Manage environment variables
|
|
109
|
+
|
|
110
|
+
```toml
|
|
111
|
+
# mise.toml
|
|
112
|
+
[env]
|
|
113
|
+
SOME_VAR = "foo"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```sh-session
|
|
117
|
+
$ mise set SOME_VAR=bar
|
|
118
|
+
$ echo $SOME_VAR
|
|
119
|
+
bar
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Note that `mise` can also [load `.env` files](https://mise.en.dev/environments/#env-directives).
|
|
123
|
+
|
|
124
|
+
### Run tasks
|
|
125
|
+
|
|
126
|
+
```toml
|
|
127
|
+
# mise.toml
|
|
128
|
+
[tasks.build]
|
|
129
|
+
description = "build the project"
|
|
130
|
+
run = "echo building..."
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
```sh-session
|
|
134
|
+
$ mise run build
|
|
135
|
+
building...
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
See [tasks](https://mise.en.dev/tasks/) for more information.
|
|
139
|
+
|
|
140
|
+
### Example mise project
|
|
141
|
+
|
|
142
|
+
Here is a combined example to give you an idea of how you can use mise to manage your a project's tools, environment, and tasks.
|
|
143
|
+
|
|
144
|
+
```toml
|
|
145
|
+
# mise.toml
|
|
146
|
+
[tools]
|
|
147
|
+
terraform = "1"
|
|
148
|
+
aws-cli = "2"
|
|
149
|
+
|
|
150
|
+
[env]
|
|
151
|
+
TF_WORKSPACE = "development"
|
|
152
|
+
AWS_REGION = "us-west-2"
|
|
153
|
+
AWS_PROFILE = "dev"
|
|
154
|
+
|
|
155
|
+
[tasks.plan]
|
|
156
|
+
description = "Run terraform plan with configured workspace"
|
|
157
|
+
run = """
|
|
158
|
+
terraform init
|
|
159
|
+
terraform workspace select $TF_WORKSPACE
|
|
160
|
+
terraform plan
|
|
161
|
+
"""
|
|
162
|
+
|
|
163
|
+
[tasks.validate]
|
|
164
|
+
description = "Validate AWS credentials and terraform config"
|
|
165
|
+
run = """
|
|
166
|
+
aws sts get-caller-identity
|
|
167
|
+
terraform validate
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
[tasks.deploy]
|
|
171
|
+
description = "Deploy infrastructure after validation"
|
|
172
|
+
depends = ["validate", "plan"]
|
|
173
|
+
run = "terraform apply -auto-approve"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Run it with:
|
|
177
|
+
|
|
178
|
+
```sh-session
|
|
179
|
+
mise install # install tools specified in mise.toml
|
|
180
|
+
mise run deploy
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Find more examples in the [mise cookbook](https://mise.en.dev/mise-cookbook/).
|
|
184
|
+
|
|
185
|
+
## Full Documentation
|
|
186
|
+
|
|
187
|
+
See [mise.en.dev](https://mise.en.dev)
|
|
188
|
+
|
|
189
|
+
## GitHub Issues & Discussions
|
|
190
|
+
|
|
191
|
+
Due to the volume of issue submissions mise received, using GitHub Issues became unsustainable for
|
|
192
|
+
the project. Instead, mise uses GitHub Discussions which provide a more community-centric platform
|
|
193
|
+
for communication and require less management on the part of the maintainers.
|
|
194
|
+
|
|
195
|
+
Please note the following discussion categories, which match how issues are often used:
|
|
196
|
+
|
|
197
|
+
- [Announcements](https://github.com/jdx/mise/discussions/categories/announcements)
|
|
198
|
+
- [Ideas](https://github.com/jdx/mise/discussions/categories/ideas): for feature requests, etc.
|
|
199
|
+
- [Troubleshooting & Bug Reports](https://github.com/jdx/mise/discussions/categories/troubleshooting-and-bug-reports)
|
|
200
|
+
|
|
201
|
+
## Special Thanks
|
|
202
|
+
|
|
203
|
+
<p>
|
|
204
|
+
<a href="https://namespace.so">
|
|
205
|
+
<img src="docs/public/namespace-logo.svg" alt="Namespace" width="64" height="64">
|
|
206
|
+
</a>
|
|
207
|
+
<br>
|
|
208
|
+
Thanks to <a href="https://namespace.so">Namespace</a> for providing CI services for mise.
|
|
209
|
+
</p>
|
|
210
|
+
|
|
211
|
+
## Contributors
|
|
212
|
+
|
|
213
|
+
[](https://github.com/jdx/mise/graphs/contributors)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var spawn = require('child_process').spawn;
|
|
2
|
+
var path = require('path');
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
|
|
5
|
+
function installArchSpecificPackage(version) {
|
|
6
|
+
|
|
7
|
+
process.env.npm_config_global = 'false';
|
|
8
|
+
|
|
9
|
+
var platform = process.platform == 'win32' ? 'windows' : process.platform;
|
|
10
|
+
var arch = platform == 'windows' && process.arch == 'ia32' ? 'x86' : process.arch;
|
|
11
|
+
|
|
12
|
+
var cp = spawn(platform == 'windows' ? 'npm.cmd' : 'npm', ['install', '--no-save', ['@jdxcode/mise', platform, arch].join('-') + '@' + version], {
|
|
13
|
+
stdio: 'inherit',
|
|
14
|
+
shell: true
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
cp.on('close', function(code) {
|
|
18
|
+
var pkgJson = require.resolve(['@jdxcode/mise', platform, arch].join('-') + '/package.json');
|
|
19
|
+
var subpkg = JSON.parse(fs.readFileSync(pkgJson, 'utf8'));
|
|
20
|
+
var executable = subpkg.bin.mise;
|
|
21
|
+
var bin = path.resolve(path.dirname(pkgJson), executable);
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
fs.mkdirSync(path.resolve(process.cwd(), 'bin'));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
if (e.code != 'EEXIST') {
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
linkSync(bin, path.resolve(process.cwd(), executable));
|
|
32
|
+
|
|
33
|
+
if (platform == 'windows') {
|
|
34
|
+
var pkg = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'package.json')));
|
|
35
|
+
fs.writeFileSync(path.resolve(process.cwd(), 'bin/mise'), 'This file intentionally left blank');
|
|
36
|
+
pkg.bin.mise = 'bin/mise.exe';
|
|
37
|
+
fs.writeFileSync(path.resolve(process.cwd(), 'package.json'), JSON.stringify(pkg, null, 2));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return process.exit(code);
|
|
41
|
+
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function linkSync(src, dest) {
|
|
46
|
+
try {
|
|
47
|
+
fs.unlinkSync(dest);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
if (e.code != 'ENOENT') {
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return fs.linkSync(src, dest);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const pjson = require('./package.json')
|
|
57
|
+
installArchSpecificPackage(pjson.version)
|
package/package.json
CHANGED
|
@@ -1,56 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mise",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"main": "dist/mise.js",
|
|
3
|
+
"description": "Dev tools, env vars, and tasks in one CLI",
|
|
4
|
+
"version": "2026.5.18",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/
|
|
9
|
-
},
|
|
10
|
-
"directories": {
|
|
11
|
-
"example": "example"
|
|
7
|
+
"url": "https://github.com/jdx/mise"
|
|
12
8
|
},
|
|
9
|
+
"files": [
|
|
10
|
+
"installArchSpecificPackage.js",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
13
|
"scripts": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"build": "webpack --optimize-minimize",
|
|
17
|
-
"build:unoptimized": "webpack",
|
|
18
|
-
"lint": "eslint ./src/",
|
|
19
|
-
"lint:fix": "eslint --fix ./src/",
|
|
20
|
-
"start": "npm run lint && npm run test && npm run build",
|
|
21
|
-
"prepublish": "npm start"
|
|
14
|
+
"prepack": "rm -rf bin",
|
|
15
|
+
"preinstall": "node installArchSpecificPackage.js"
|
|
22
16
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"^.+\\.(tsx?|jsx?)$": "typescript-babel-jest"
|
|
26
|
-
},
|
|
27
|
-
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
|
28
|
-
"moduleFileExtensions": [
|
|
29
|
-
"ts",
|
|
30
|
-
"tsx",
|
|
31
|
-
"js",
|
|
32
|
-
"jsx",
|
|
33
|
-
"json"
|
|
34
|
-
]
|
|
17
|
+
"bin": {
|
|
18
|
+
"mise": "./bin/mise"
|
|
35
19
|
},
|
|
36
|
-
"author": "dan b.",
|
|
37
20
|
"license": "MIT",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"awesome-typescript-loader": "^3.2.3",
|
|
41
|
-
"babel-core": "^6.26.0",
|
|
42
|
-
"babel-loader": "^7.1.2",
|
|
43
|
-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
|
44
|
-
"babel-preset-env": "^1.6.1",
|
|
45
|
-
"babel-preset-es2015": "^6.24.1",
|
|
46
|
-
"eslint": "^4.10.0",
|
|
47
|
-
"eslint-config-airbnb": "^16.1.0",
|
|
48
|
-
"eslint-plugin-import": "^2.8.0",
|
|
49
|
-
"eslint-plugin-jsx-a11y": "^6.0.2",
|
|
50
|
-
"eslint-plugin-react": "^7.4.0",
|
|
51
|
-
"jest": "^21.2.1",
|
|
52
|
-
"typescript": "^2.5.3",
|
|
53
|
-
"typescript-babel-jest": "^1.0.5",
|
|
54
|
-
"webpack": "^3.8.1"
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=5.0.0"
|
|
55
23
|
}
|
|
56
24
|
}
|
package/.babelrc
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"env": {
|
|
3
|
-
"jest": true,
|
|
4
|
-
"browser": true,
|
|
5
|
-
"es6": true,
|
|
6
|
-
"node": true
|
|
7
|
-
},
|
|
8
|
-
"extends": "airbnb",
|
|
9
|
-
"rules": {
|
|
10
|
-
"no-param-reassign": "off", /* sadly, we have to reassign params to deal with props */
|
|
11
|
-
"import/prefer-default-export": "off", /* named exports allow for treeshaking */
|
|
12
|
-
'no-restricted-syntax': [ /* we're omitting for of loops for this. they're pretty neat! */
|
|
13
|
-
'error',
|
|
14
|
-
{
|
|
15
|
-
selector: 'ForInStatement',
|
|
16
|
-
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
selector: 'LabeledStatement',
|
|
20
|
-
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
selector: 'WithStatement',
|
|
24
|
-
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
"no-loop-func": "off", /* we create functions within a loop to close over our actions. this is intentional! */
|
|
28
|
-
"linebreak-style": "off", /* we accept those of all line endings */
|
|
29
|
-
}
|
|
30
|
-
};
|
package/.travis.yml
DELETED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/mise.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(r,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("mise",[],t):"object"==typeof exports?exports.mise=t():r.mise=t()}(this,function(){return function(r){function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var e={};return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{configurable:!1,enumerable:!0,get:n})},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},t.p="",t(t.s=0)}([function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=e(1);Object.defineProperty(t,"component",{enumerable:!0,get:function(){return n.component}});var o=e(4);Object.defineProperty(t,"dom",{enumerable:!0,get:function(){return o.dom}})},function(r,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.component=void 0;var n=function(){function r(r,t){var e=[],n=!0,o=!1,i=void 0;try{for(var u,a=r[Symbol.iterator]();!(n=(u=a.next()).done)&&(e.push(u.value),!t||e.length!==t);n=!0);}catch(r){o=!0,i=r}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}return e}return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return r(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},i=e(2),u=function(r){var t=r.template,e=r.state,u=r.actions,a=r.root,c=void 0===a?document.body:a,f=(0,i.vdom)(),l=void 0,y=void 0,p=void 0,s=function(r){return function(e){var n=o({},r),i=o({},e);return t(n)(i)}},d=function(){var r=y;y=s(l)(p),f.update(c,c.childNodes[0],r,y)},v=function(){requestAnimationFrame(d)},m=function(r){l=o({},l,r),v()},b=function(r){var t={},e=!0,o=!1,i=void 0;try{for(var u,a=Object.entries(r)[Symbol.iterator]();!(e=(u=a.next()).done);e=!0){var c=u.value,f=n(c,2),y=f[0],s=f[1];!function(r,e){t[r]=function(r){var t=e(l,p,r);"function"==typeof t?t(m):m(t)}}(y,s)}}catch(r){o=!0,i=r}finally{try{!e&&a.return&&a.return()}finally{if(o)throw i}}return t};!function(r){l=e,p=b(r),y=s(l)(p),c.appendChild(f.createElement(y))}(u)};t.component=u},function(r,t,e){"use strict";function n(r){if(Array.isArray(r)){for(var t=0,e=Array(r.length);t<r.length;t++)e[t]=r[t];return e}return Array.from(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.vdom=void 0;var o=function(){function r(r,t){var e=[],n=!0,o=!1,i=void 0;try{for(var u,a=r[Symbol.iterator]();!(n=(u=a.next()).done)&&(e.push(u.value),!t||e.length!==t);n=!0);}catch(r){o=!0,i=r}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}return e}return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return r(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},u=e(3),a=function(){var r=function(r,t,e,n){if("value"===t)return void((n||0===n||""===n)&&(r[t]=n));if("boolean"==typeof n)return void(n&&(r.setAttribute(t,n),r[t]=n));if("function"!=typeof n){if(!n||"object"===(void 0===n?"undefined":i(n))&&!Object.keys(n).length)return void r.removeAttribute(t);if("style"!==t)r.setAttribute(t,n);else{var o=(0,u.getUniques)(n,e),a=!0,c=!1,f=void 0;try{for(var l,y=o[Symbol.iterator]();!(a=(l=y.next()).done);a=!0){var p=l.value;n[p]?e&&e[p]&&e[p]===n[p]||(r.style[p]=n[p]):r.style[p]=""}}catch(r){c=!0,f=r}finally{try{!a&&y.return&&y.return()}finally{if(c)throw f}}}}else try{r[t]=n}catch(r){}},t=function(t,e){var n=!0,i=!1,u=void 0;try{for(var a,c=Object.entries(e)[Symbol.iterator]();!(n=(a=c.next()).done);n=!0){var f=a.value,l=o(f,2),y=l[0],p=l[1];r(t,y,{},p)}}catch(r){i=!0,u=r}finally{try{!n&&c.return&&c.return()}finally{if(i)throw u}}},e=function r(e){if("string"==typeof e)return document.createTextNode(e);var n=e.type,o=e.props,i=e.children,u=document.createElement(n);return t(u,o),i.map(r).forEach(function(r){return u.appendChild(r)}),u},a=function(r,t){return(void 0===r?"undefined":i(r))!==(void 0===t?"undefined":i(t))||"string"==typeof r&&r!==t||r.type!==t.type},c=function(t,e,n){var o=(0,u.getUniques)(e,n),i=!0,a=!1,c=void 0;try{for(var f,l=o[Symbol.iterator]();!(i=(f=l.next()).done);i=!0){var y=f.value;r(t,y,e[y],n[y])}}catch(r){a=!0,c=r}finally{try{!i&&l.return&&l.return()}finally{if(a)throw c}}},f=function(r,t,n,o){if(!n){var i=e(o);return o.props.oncreate&&o.props.oncreate(i),r.appendChild(i),!1}if(!o){var u=function(){return t.remove()};return n.props&&n.props.onremove?n.props.onremove(t)(u):u(),!1}if(a(n,o)){var f=e(o);return o.props&&o.props.onupdate&&o.props.onupdate(f)(n.props),r.replaceChild(f,t),!0}return o.props&&o.props.onupdate&&o.props.onupdate(t)(n.props),c(t,n.props,o.props),!0};return{createElement:e,update:function r(t,e,o,i){if(f(t,e,o,i))for(var u=o.children||[],a=i.children||[],c=Math.max(u.length,a.length),l=[].concat(n(e&&e.childNodes||[])),y=0;y<c;y+=1)r(e,l[y],o.children[y],i.children[y])}}};t.vdom=a},function(r,t,e){"use strict";function n(r){if(Array.isArray(r)){for(var t=0,e=Array(r.length);t<r.length;t++)e[t]=r[t];return e}return Array.from(r)}Object.defineProperty(t,"__esModule",{value:!0});var o=function(r,t){return new Set([].concat(n(Object.keys(r||{})),n(Object.keys(t||{}))))};t.getUniques=o},function(r,t,e){"use strict";function n(r){if(Array.isArray(r)){for(var t=0,e=Array(r.length);t<r.length;t++)e[t]=r[t];return e}return Array.from(r)}Object.defineProperty(t,"__esModule",{value:!0});var o=function(r){for(var t=arguments.length,e=Array(t>2?t-2:0),o=2;o<t;o++)e[o-2]=arguments[o];var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=[],a=i,c=!0,f=!1,l=void 0;try{for(var y,p=e[Symbol.iterator]();!(c=(y=p.next()).done);c=!0){var s=y.value;u=Array.isArray(s)?[].concat(n(u),n(s)):[].concat(n(u),["number"==typeof s?String(s):s])}}catch(r){f=!0,l=r}finally{try{!c&&p.return&&p.return()}finally{if(f)throw l}}return null===i&&(a={}),a.className&&(a.class=a.className,a.className=void 0),"function"==typeof r?r(a,u):{type:r,props:a,children:u}};t.dom=o}])});
|
package/docs/actions.md
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Actions
|
|
2
|
-
|
|
3
|
-
Actions are how you generate change in Mise. By triggering an action, you modify the state and create a new template.
|
|
4
|
-
|
|
5
|
-
```javascript
|
|
6
|
-
const actions = {
|
|
7
|
-
increment: state => ({ state.counter + 1 }),
|
|
8
|
-
decrement: state => ({ state.counter - 1 }),
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
#### State can only be modified by actions.
|
|
13
|
-
|
|
14
|
-
If you intend to modify the state, this needs to be done via an action. The above example
|
|
15
|
-
|
|
16
|
-
#### Actions can call other actions.
|
|
17
|
-
|
|
18
|
-
```javascript
|
|
19
|
-
const actions = {
|
|
20
|
-
clearInput = state => ({ input: '' }),
|
|
21
|
-
submit = (state, actions) => {
|
|
22
|
-
const todo = { text: state.input };
|
|
23
|
-
actions.clearInput();
|
|
24
|
-
|
|
25
|
-
return { todos : [ ...state.todos, todo ] };
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
#### Actions can take additional parameters.
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
import { dom, component } from 'mise';
|
|
34
|
-
|
|
35
|
-
component({
|
|
36
|
-
template: state => actions => (
|
|
37
|
-
<div onclick={e => actions.eventHandler(e)}>
|
|
38
|
-
click me!
|
|
39
|
-
</div>
|
|
40
|
-
),
|
|
41
|
-
state:
|
|
42
|
-
//...
|
|
43
|
-
actions: {
|
|
44
|
-
eventHandler = (state, actions, event) => {
|
|
45
|
-
if (e.button === 2) {
|
|
46
|
-
// ...
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
#### Actions can provide thunks
|
|
53
|
-
> A thunk is a function that encapsulates synchronous or asynchronous code
|
|
54
|
-
|
|
55
|
-
Thunks allow developers a little leeway into *when* an application should re-render. You can delay a re-render until a certain condition is met via thunks
|
|
56
|
-
|
|
57
|
-
``` javascript
|
|
58
|
-
const actions = {
|
|
59
|
-
getAlerts: (state, actions) => async update => {
|
|
60
|
-
await data = actions.fetchAlerts(state.alertValue);
|
|
61
|
-
|
|
62
|
-
if (data.shouldUpdate)
|
|
63
|
-
update({ alerts: data.alerts });
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
#### Testing
|
|
69
|
-
|
|
70
|
-
Testing actions is very straightforward. All actions should strive to be pure functions.
|
|
71
|
-
|
|
72
|
-
```javascript
|
|
73
|
-
import { actions } from './todos.actions';
|
|
74
|
-
|
|
75
|
-
let state = {};
|
|
76
|
-
beforeEach(
|
|
77
|
-
state = {};
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
describe('todo actions', () => {
|
|
81
|
-
it('should add the input to a todo', () => {
|
|
82
|
-
const input = 'hello world!';
|
|
83
|
-
expect(actions.addInput(state, actions, input)).toEqual({
|
|
84
|
-
input,
|
|
85
|
-
})
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it ('should remove all todos', () => {
|
|
89
|
-
state.todos = [{ id: 1, text: 'hello, world', } { id: 2, text: 'goodbye, world' }];
|
|
90
|
-
|
|
91
|
-
expect(actions.removeTodos(state, actions)).toEqual({
|
|
92
|
-
todos: [],
|
|
93
|
-
});
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
```
|
package/docs/components.md
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# Components
|
|
2
|
-
|
|
3
|
-
Components are how Mise wires together the template, state, and actions to render your application.
|
|
4
|
-
|
|
5
|
-
```javascript
|
|
6
|
-
import { dom, component } from 'mise';
|
|
7
|
-
|
|
8
|
-
component({
|
|
9
|
-
template: state => actions => (
|
|
10
|
-
<div>
|
|
11
|
-
<span>{state.counter}</span>
|
|
12
|
-
<button onclick={actions.increment}>+</button>
|
|
13
|
-
<button onclick={actions.decrement}>-</button>
|
|
14
|
-
</div>
|
|
15
|
-
),
|
|
16
|
-
state: {
|
|
17
|
-
counter: 0,
|
|
18
|
-
},
|
|
19
|
-
actions: {
|
|
20
|
-
increment: state => ({ counter: state.counter + 1 }),
|
|
21
|
-
decrement: state => ({ counter: state.counter - 1 }),
|
|
22
|
-
},
|
|
23
|
-
root: document.querySelector('#app'),
|
|
24
|
-
});
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
#### Applications should only have one root-level component.
|
|
28
|
-
|
|
29
|
-
Your application should be structured in a way that only one root level component is ever necessary. Having a single, shared state and a single pool of actions allows you to do some pretty neat things.
|
|
30
|
-
|
|
31
|
-
* Load the state of your application from a local storage object
|
|
32
|
-
* Hydrate your SSR application with the proper state
|
|
33
|
-
* Easily automate bug reporting by passing the whole state and the action called.
|
|
34
|
-
|
|
35
|
-
It also forces you to keep your templates presentational. The assumption is that basically no logic should ever live in your templates. Templates can thus be really simple to maintain and to test.
|
|
36
|
-
|
|
37
|
-
#### Root items shouldn't have anything else in them.
|
|
38
|
-
|
|
39
|
-
Mise doesn't play nice with others. Please make sure your root items dont get anything added/removed to them. Mise works by diffing a VDOM and applying updates to the real DOM. The real DOM isn't the real source of truth, and as such it's possible for Mise to fall out of sync if the DOM changes out of Mise's purview.
|
|
40
|
-
|