omi/README.md

701 lines
20 KiB
Markdown
Raw Normal View History

2018-10-27 11:05:31 +08:00
English | [简体中文](./README.CN.md) | [한국어](./README.KR.md)
2018-10-20 10:59:36 +08:00
<p align="center"><img src="./assets/omi-logo.svg" alt="omi" width="300"/></p>
<h2 align="center">Omi: Next Generation Web Framework in 4kb JavaScript</h2>
2018-10-20 12:45:14 +08:00
<p align="center"><b>Merge JSX, Web Components, Proxy, Store, Path Updating together</b></p>
2018-10-20 10:59:36 +08:00
## Why Omi?
2018-10-22 03:50:09 +08:00
- Tiny size. _(**4kb** gzipped)_
2018-10-20 10:59:36 +08:00
- Supports TypeScript.
- Reactive data-binding
- [Based on Shadow DOM](https://developers.google.com/web/fundamentals/web-components/shadowdom)
2018-10-20 22:27:50 +08:00
- Easy to debug via [Omi DevTools Extension](https://github.com/f/omi-devtools) [[Install from Chrome WebStore](https://chrome.google.com/webstore/detail/omijs-devtools/pjgglfliglbhpcpalbpeloghnbceocmd)]
2018-10-20 10:59:36 +08:00
- Compliance with browser trend and API design.
2018-10-23 09:18:59 +08:00
- Merge [**Web Components**](https://developers.google.com/web/fundamentals/web-components/) and [**JSX**](https://reactjs.org/docs/introducing-jsx.html) into one framework.
2018-10-29 09:10:17 +08:00
- Built in observe feature (No need to call `this.update()`).
2018-10-20 10:59:36 +08:00
- Web Components can also be a data-driven view, **`UI = fn(data)`**.
2018-11-01 15:33:00 +08:00
- JSX is the best development experience (code intelligent completion and tip) UI Expression with least [grammatical noise](https://github.com/facebook/jsx#why-not-template-literals) and it's turing complete(template engine is not).
2018-10-20 10:59:36 +08:00
- The original **Path Updating** system. Proxy-based automatic **accurate** update, **low power consumption**, high degree of freedom, excellent performance, easy integration of `requestIdleCallback`
- Say goodbye to `this.update` method when using **store system**! It will automatically update UI partially when data is changed.
- Look at [Facebook React vs Web Components](https://softwareengineering.stackexchange.com/questions/225400/pros-and-cons-of-facebooks-react-vs-web-components-polymer)Omi **combines their advantages** and gives developers the **freedom to choose the way they like**.
- **Shadow DOM merges with Virtual DOM**, Omi uses both virtual DOM and real Shadow DOM to make view updates more accurate and faster.
- With a Store system, 99.9% of projects don't need time travel, and not only Redux can travel, please don't come up on Redux, Omi store system can meet all projects
2018-10-22 03:50:09 +08:00
- **Scoped CSS**'s best solution is **Shadow DOM**, the community churning out frameworks and libraries for Scoped CSS (using JS or JSON writing styles such as Radium, jsxstyle, react-style; binding to webpack using generated unique `className` `filename-classname-hash`, such as CSS Modules, Vue), are hack technologies; _and Shadow DOM Style is the perfect solution_.
2018-10-20 10:59:36 +08:00
Compare TodoApp by Omi and React, Omi and React rendering DOM structure:
2018-10-22 03:50:09 +08:00
| **Omi** | **React** |
| ------------------------------- | ----------------------------------- |
2018-10-20 10:59:36 +08:00
| ![Omi](./assets/omi-render.jpg) | ![React](./assets/react-render.jpg) |
2018-10-26 22:03:55 +08:00
Omi uses Shadow DOM based style isolation and semantic structure.
2018-10-20 10:59:36 +08:00
---
2018-10-26 22:21:53 +08:00
- [Ecosystem of Omi](#ecosystem-of-omi)
2018-10-20 10:59:36 +08:00
- [Add Omi in One Minute](#add-omi-in-one-minute)
2018-10-29 09:20:52 +08:00
- [Add Omi in 30 Seconds](#add-omi-in-30-seconds)
2018-10-20 10:59:36 +08:00
- [Getting Started](#getting-started)
2018-10-25 21:30:18 +08:00
- [Install](#install)
- [Hello Element](#hello-element)
- [TodoApp](#todoapp)
- [Store](#store)
- [Summary](#summary)
2018-10-28 08:19:56 +08:00
- [Observe](#observe)
- [Omi Observe](#omi-observe)
- [Omi Mobx](#omi-mobx)
2018-10-25 21:30:18 +08:00
- [Lifecycle](#lifecycle)
2018-10-20 11:14:19 +08:00
- [Debugging](#debugging)
2018-10-20 10:59:36 +08:00
- [Browsers Support](#browsers-support)
- [Contribution](#contribution)
2018-10-29 14:58:04 +08:00
- [Thanks](#thanks)
2018-10-29 15:19:36 +08:00
- [Web Components Resource](#web-components-resource)
2018-10-20 11:14:19 +08:00
- [License](#license)
2018-10-20 10:59:36 +08:00
2018-10-26 22:21:53 +08:00
## Ecosystem of Omi
2018-10-26 22:03:55 +08:00
| **Project** | **Description** |
| ------------------------------- | ----------------------------------- |
2018-10-26 22:05:32 +08:00
| [omi-docs](https://github.com/Tencent/omi/blob/master/docs/main-concepts.md)| Omi official documents |
2018-10-26 22:11:36 +08:00
| [omi-devtools](https://github.com/f/omi-devtools)| Browser DevTools extension |
2018-10-26 22:09:17 +08:00
| [omi-cli](https://github.com/Tencent/omi/tree/master/packages/omi-cli)| Project scaffolding |
2018-10-26 22:03:55 +08:00
|[omi-i18n](https://github.com/i18next/omi-i18n)| Internationalization solution for omi.js using i18next ecosystem |
2018-10-28 07:14:13 +08:00
| [omi-transform](https://github.com/Tencent/omi/tree/master/packages/omi-transform)|Omi / [css3transform](https://tencent.github.io/omi/packages/omi-transform/css3transform/) integration. Made css3 transform super easy in your Omi project.|
2018-10-26 22:03:55 +08:00
| [omi-page](https://github.com/Tencent/omi/tree/master/packages/omi-page) |Tiny client-side router by [page](https://github.com/visionmedia/page.js)|
| [omi-tap](https://github.com/Tencent/omi/tree/master/packages/omi-tap)|Support tap event in your omi project|
2018-10-28 21:57:44 +08:00
| [omi-finger](https://github.com/Tencent/omi/tree/master/packages/omi-finger)|Support touch and gesture events in your Omi project.|
2018-11-01 15:12:52 +08:00
| [omi-touch](https://github.com/Tencent/omi/tree/master/packages/omi-touch)|Smooth scrolling, rotation, pull to refresh and any motion for the web.|
2018-10-26 22:03:55 +08:00
| [omi-mobx](https://github.com/Tencent/omi/tree/master/packages/omi-mobx)|Omi Mobx Adapter|
2018-10-31 17:41:58 +08:00
| [omi-use](https://github.com/Tencent/omi/blob/master/docs/main-concepts.md#use)|React hooks like API|
2018-11-01 17:46:11 +08:00
| [omi-native](https://github.com/Tencent/omi/tree/master/packages/omi-native)|Render web components to native|
2018-10-26 22:03:55 +08:00
|[omi element ui(working)](https://github.com/Tencent/omi/tree/master/packages/omi-element-ui)|Omi version of element-ui|
Other:
- [https://www.webcomponents.org/](https://www.webcomponents.org/)
- [https://www.webcomponents.org/elements](https://www.webcomponents.org/elements)
2018-10-20 10:59:36 +08:00
## Add Omi in One Minute
This page demonstrates using Omi **with no build tooling**.
2018-10-22 03:50:09 +08:00
- [Online Demo!](https://tencent.github.io/omi/assets/)
- [Omi.js CDN](https://unpkg.com/omi)
2018-10-20 10:59:36 +08:00
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Add Omi in One Minute</title>
</head>
<body>
<script src="https://unpkg.com/omi"></script>
<script>
2018-10-30 06:19:42 +08:00
const { WeElement, h, render, define } = Omi
define('like-button',
class extends WeElement {
install() {
this.data = { liked: false }
}
render() {
if (this.data.liked) {
return 'You liked this.'
}
return h(
'button',
{
onClick: () => {
this.data.liked = true
this.update()
}
},
'Like'
)
}
})
render(h('like-button'), 'body')
2018-10-20 10:59:36 +08:00
</script>
</body>
</html>
```
You can also use `like-button` tag directly in HTML
```jsx
<body>
2018-10-25 21:30:18 +08:00
<like-button />
2018-10-20 10:59:36 +08:00
</body>
```
2018-10-29 09:20:52 +08:00
### Add Omi in 30 Seconds
You can also quickly build omi projects using modern JS code:
```js
import { render, WeElement, tag, observe } from "omi"
@observe
@tag("my-counter")
2018-10-30 06:13:12 +08:00
class MyCounter extends WeElement {
2018-10-29 09:20:52 +08:00
2018-10-29 21:25:46 +08:00
data = {
count: 0
}
2018-10-29 09:20:52 +08:00
sub = () => {
this.data.count--
}
add = () => {
this.data.count++
}
render() {
return (
<div>
<button onClick={this.sub}>-</button>
<span>{this.data.count}</span>
<button onClick={this.add}>+</button>
</div>
)
}
}
render(<my-counter />, "body")
```
[→ counter demo](https://tencent.github.io/omi/packages/omi/examples/counter/)
2018-10-30 06:13:12 +08:00
You will find that the `MyCounter` class name defined above is never used. So you can also use the following way to avoid Eslint hints:
```js
2018-10-30 06:39:32 +08:00
import { render, WeElement, define } from 'omi'
2018-10-30 06:13:12 +08:00
2018-10-30 06:39:32 +08:00
define('my-counter', class extends WeElement {
static observe = true
2018-10-30 06:19:42 +08:00
data = {
count: 1
}
sub = () => {
this.data.count--
}
add = () => {
this.data.count++
}
render() {
return (
<div>
<button onClick={this.sub}>-</button>
<span>{this.data.count}</span>
<button onClick={this.add}>+</button>
</div>
)
}
})
2018-10-30 06:13:12 +08:00
render(<my-counter />, 'body')
```
2018-10-31 17:39:18 +08:00
You can also be defined as a form of pure functions:
```js
import { define, render } from 'omi'
define('my-counter', function() {
const [count, setCount] = this.use({
data: 0,
effect: function() {
document.title = `The num is ${this.data}.`
}
})
return (
<div>
<button onClick={() => setCount(count - 1)}>-</button>
<span>{count}</span>
<button onClick={() => setCount(count + 1)}>+</button>
</div>
)
})
render(<my-counter />, 'body')
```
2018-10-31 19:44:01 +08:00
If you don't need effect, you can use `useData` directly:
```js
const [count, setCount] = this.useData(0)
```
2018-10-20 10:59:36 +08:00
## Getting Started
### Install
```bash
$ npm i omi-cli -g # install cli
$ omi init your_project_name # init project, you can also exec 'omi init' in an empty folder
$ cd your_project_name # please ignore this command if you executed 'omi init' in an empty folder
$ npm start # develop
$ npm run build # release
```
Directory description:
```
├─ config
├─ public
├─ scripts
├─ src
│ ├─ assets
│ ├─ elements //Store all custom elements
│ ├─ store //Store all this store of pages
│ ├─ admin.js //Entry js of compilerwill build to admin.html
│ └─ index.js //Entry js of compilerwill build to index.html
```
2018-10-29 11:55:16 +08:00
About compiled website URL
* [build env doc](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#referencing-environment-variables-in-the-html)
* [build problem](https://stackoverflow.com/questions/42686149/create-react-app-build-with-public-url)
Such as in windows:
```json
"scripts": {
"start": "node scripts/start.js",
"_build": "node scripts/build.js",
"build":"set PUBLIC_URL=https://fe.wxpay.oa.com/dv&& npm run _build"
}
```
2018-10-25 11:29:50 +08:00
TypeScript Template(omi-cli v3.0.3+):
2018-10-24 02:04:13 +08:00
```bash
$ npm i omi-cli -g # install cli
$ omi init-ts your_project_name # init project, you can also exec 'omi init-ts' in an empty folder
$ cd your_project_name # please ignore this command if you executed 'omi init' in an empty folder
$ npm start # develop
$ npm run build # release
```
2018-10-29 11:55:16 +08:00
CLI's auto-created project scaffolding is based on a single-page create-react-app to be converted into a multi-page one, with configuration issues to see [create-react-app user guide](https://facebook.github.io/create-react-app/docs/getting-started)
2018-10-20 10:59:36 +08:00
### Hello Element
2018-10-30 09:08:59 +08:00
Define a custom element by extending **`WeElement`** base class:
2018-10-20 10:59:36 +08:00
```js
2018-10-30 09:08:59 +08:00
import { define, WeElement } from 'omi'
2018-10-20 10:59:36 +08:00
2018-10-30 09:08:59 +08:00
define('hello-element', class extends WeElement {
2018-10-25 21:30:18 +08:00
onClick = evt => {
// trigger CustomEvent
2018-10-30 09:08:59 +08:00
this.fire('abc', { name: 'dntzhang', age: 12 })
evt.stopPropagation()
}
2018-10-25 21:30:18 +08:00
css() {
return `
2018-10-20 10:59:36 +08:00
div {
color: red;
cursor: pointer;
2018-10-30 09:08:59 +08:00
}`
2018-10-25 21:30:18 +08:00
}
render(props) {
return (
<div onClick={this.onClick}>
Hello {props.msg} {props.propFromParent}
<div>Click Me!</div>
</div>
2018-10-30 09:08:59 +08:00
)
2018-10-25 21:30:18 +08:00
}
2018-10-30 09:08:59 +08:00
})
2018-10-20 10:59:36 +08:00
```
Using `hello-element`:
2018-10-22 03:50:09 +08:00
```js
2018-10-30 09:08:59 +08:00
import { define, render, WeElement } from 'omi'
import './hello-element'
2018-10-20 10:59:36 +08:00
2018-10-30 09:08:59 +08:00
define('my-app', class extends WeElement {
data = { abc: 'abc', passToChild: 123 }
2018-10-25 21:30:18 +08:00
2018-10-30 09:08:59 +08:00
// define CustomEvent Handler
2018-10-25 21:30:18 +08:00
onAbc = evt => {
// get evt data by evt.detail
2018-10-30 09:08:59 +08:00
this.data.abc = ' by ' + evt.detail.name
this.data.passToChild = 1234
this.update()
}
2018-10-25 21:30:18 +08:00
css() {
return `
2018-10-30 09:08:59 +08:00
div{
color: green;
}`
2018-10-25 21:30:18 +08:00
}
render(props, data) {
return (
<div>
Hello {props.name} {data.abc}
<hello-element
onAbc={this.onAbc}
prop-from-parent={data.passToChild}
msg="WeElement"
/>
</div>
2018-10-30 09:08:59 +08:00
)
2018-10-25 21:30:18 +08:00
}
2018-10-30 09:08:59 +08:00
})
2018-10-20 10:59:36 +08:00
2018-10-30 09:08:59 +08:00
render(<my-app name="Omi v4.0" />, 'body')
2018-10-20 10:59:36 +08:00
```
Tell Babel to transform JSX into `Omi.h()` call:
2018-10-22 03:50:09 +08:00
```json
2018-10-20 10:59:36 +08:00
{
2018-10-25 21:30:18 +08:00
"presets": ["env", "omi"]
2018-10-20 10:59:36 +08:00
}
```
The following two NPM packages need to be installed to support the above configuration:
2018-10-22 03:50:09 +08:00
```bash
2018-10-20 10:59:36 +08:00
"babel-preset-env": "^1.6.0",
"babel-preset-omi": "^0.1.1",
```
2018-10-27 16:08:24 +08:00
If you use babel7, you can also use the following packages and configuration:
```bash
npm install --save-dev @babel/preset-env
npm install --save-dev @babel/preset-react
```
```js
{
"presets": [
"@babel/preset-env",
[
"@babel/preset-react",
{
"pragma": "Omi.h",
}
]
]
}
```
2018-10-23 09:18:59 +08:00
If you don't want to write CSS in JS, you can use [to-string-loader](https://www.npmjs.com/package/to-string-loader) of webpack,
2018-10-20 10:59:36 +08:00
For example, the following configuration:
2018-10-22 03:50:09 +08:00
```js
2018-10-20 10:59:36 +08:00
{
test: /[\\|\/]_[\S]*\.css$/,
use: [
'to-string-loader',
'css-loader'
]
}
```
If your CSS file starts with "`_`", CSS will use `to-string-loader`., such as:
2018-10-22 03:50:09 +08:00
```js
2018-10-20 10:59:36 +08:00
import { tag, WeElement render } from 'omi'
// typeof cssStr is string
import cssStr from './_index.css'
@tag('my-app')
class MyApp extends WeElement {
css() {
return cssStr
}
...
...
...
```
2018-10-27 16:12:05 +08:00
You can also forget the tedious configuration and use omi-cli directly, no need to configure anything.
2018-10-20 10:59:36 +08:00
### TodoApp
Here is a relatively complete example of TodoApp:
```js
2018-11-03 06:49:36 +08:00
import { define, render, WeElement } from 'omi'
2018-10-20 10:59:36 +08:00
2018-11-03 06:49:36 +08:00
define('todo-list', function(props) {
return (
<ul>
{props.items.map(item => (
<li key={item.id}>{item.text}</li>
))}
</ul>
)
2018-10-30 06:42:07 +08:00
})
define('todo-app', class extends WeElement {
2018-10-30 07:01:01 +08:00
static observe = true
2018-11-03 06:49:36 +08:00
data = { items: [], text: '' }
2018-10-30 07:01:01 +08:00
render() {
return (
<div>
<h3>TODO</h3>
<todo-list items={this.data.items} />
<form onSubmit={this.handleSubmit}>
<input
id="new-todo"
onChange={this.handleChange}
value={this.data.text}
/>
<button>Add #{this.data.items.length + 1}</button>
</form>
</div>
)
}
handleChange = e => {
this.data.text = e.target.value
}
handleSubmit = e => {
e.preventDefault()
if (!this.data.text.trim().length) {
return
}
this.data.items.push({
text: this.data.text,
id: Date.now()
})
this.data.text = ''
}
2018-10-30 06:42:07 +08:00
})
render(<todo-app />, 'body')
2018-10-20 10:59:36 +08:00
```
### Store
Say goodbye to `this.update` method when using store system! It will automatically update the UI partially when data is changed. The powerful **Store architecture** is high-performanced since all the data is mounted on the store, except for components that rely on props to determine the state of the component.
```js
export default {
2018-10-25 21:30:18 +08:00
data: {
items: [],
text: "",
firstName: "dnt",
lastName: "zhang",
fullName: function() {
return this.firstName + this.lastName;
},
globalPropTest: "abc", // Change it will refresh all elements without changing the components and page declaring data dependency.
ccc: { ddd: 1 } // Change it will refresh all elements without changing the components and page declaring data dependency.
},
globalData: ["globalPropTest", "ccc.ddd"],
add: function() {
if (!this.data.text.trim().length) {
return;
}
this.data.items.push({
text: this.data.text,
id: Date.now()
});
this.data.text = "";
}
// Default value is false, set to true will update all instances when data changing.
// updateAll: true
2018-10-25 20:44:42 +08:00
};
2018-10-20 10:59:36 +08:00
```
Custom Element requires declaring dependent data so that Omi stores compute the dependency path based on the data declared on the custom component and update it locally as needed. Such as:
```js
2018-10-30 09:15:43 +08:00
define('todo-app', class extends WeElement {
2018-10-25 21:30:18 +08:00
// If you use store, the data is only used to declare dependencies.
static get data() {
return { items: [], text: "" };
}
// ...
handleChange = e => {
this.store.data.text = e.target.value;
};
handleSubmit = e => {
e.preventDefault();
this.store.add();
};
2018-10-30 09:15:43 +08:00
})
2018-10-20 10:59:36 +08:00
```
2018-10-22 03:50:09 +08:00
- The logic of data is **encapsulated in the store definition method** (such as `store.add`).
- Views are only **responsible for passing data to store**, such as calling `store.add` or setting `store.data.text` on top.
2018-10-20 10:59:36 +08:00
You need to inject `store` from the root node at render time to use this store:
```js
2018-10-22 03:50:09 +08:00
render(<todo-app />, "body", store);
2018-10-20 10:59:36 +08:00
```
[→ Store Source Code](https://github.com/Tencent/omi/blob/master/packages/omi/examples/store/main.js)
#### Summary
2018-10-22 03:50:09 +08:00
- `store.data` is used to list all attributes and default values (except the components of the view decided by props).
- The static data of the element is used to list the attributes of the dependent store.data _(Omi will record path)_ and update on demand.
- If there are few simple components on the page, `updateAll` can be set to `true`, and components and pages don't need to declare data, and they don't update on demand
- The path declared in `globalData` refreshes all pages and components by modifying the value of the corresponding path, which can be used to list all pages or most of the public properties path
2018-10-20 10:59:36 +08:00
2018-10-28 08:19:56 +08:00
## Observe
2018-10-20 10:59:36 +08:00
2018-10-28 08:19:56 +08:00
### Omi Observe
2018-10-20 10:59:36 +08:00
2018-10-28 08:19:56 +08:00
You can also use observe to create response views for element who no need `store`, such as:
2018-10-20 11:14:19 +08:00
2018-10-28 08:19:56 +08:00
```js
2018-10-30 09:15:43 +08:00
import { define, WeElement } from "omi"
define("my-app", class extends WeElement {
static observe = true
2018-10-20 11:14:19 +08:00
2018-10-28 08:19:56 +08:00
install() {
this.data.name = "omi"
}
2018-10-20 11:14:19 +08:00
2018-10-28 08:19:56 +08:00
onClick = () => {
this.data.name = "Omi V4.0"
2018-10-28 08:23:07 +08:00
}
2018-10-28 08:19:56 +08:00
render(props, data) {
return (
<div onClick={this.onClick}>
<h1>Welcome to {data.name}</h1>
</div>
)
}
2018-10-30 09:15:43 +08:00
})
2018-10-28 08:19:56 +08:00
```
2018-10-20 11:14:19 +08:00
2018-11-01 18:06:05 +08:00
It should be noted that if `observe` is used, do not set the value of data in some of the following functions: some complex objects such as obj or arr:
2018-11-01 17:46:11 +08:00
* render
* beforeRender
* beforeUpdate
* afterUpdate
2018-11-01 18:06:05 +08:00
Because data settings will simply compare the value before and after, complex objects will not be deep contrast, the contrast value will trigger different update, update will trigger the above function, infinite recursion.
2018-11-01 17:46:11 +08:00
2018-11-01 15:12:52 +08:00
If you want to be compatible with IE11, please use the `omi-mobx` instead of omi's own observe.
2018-10-21 17:19:49 +08:00
2018-10-28 08:19:56 +08:00
### Omi Mobx
2018-10-21 17:19:49 +08:00
```js
2018-10-28 08:19:56 +08:00
import { tag, WeElement } from "omi"
import { observe } from "omi-mobx"
2018-10-21 17:19:49 +08:00
@observe
2018-10-22 03:50:09 +08:00
@tag("my-app")
2018-10-21 17:19:49 +08:00
class MyApp extends WeElement {
2018-10-25 21:30:18 +08:00
install() {
2018-10-28 08:19:56 +08:00
this.data.name = "omi"
2018-10-25 21:30:18 +08:00
}
onClick = () => {
2018-10-28 08:19:56 +08:00
this.data.name = "Omi V4.0"
}
2018-10-25 21:30:18 +08:00
render(props, data) {
return (
<div onClick={this.onClick}>
<h1>Welcome to {data.name}</h1>
</div>
2018-10-28 08:19:56 +08:00
)
2018-10-25 21:30:18 +08:00
}
2018-10-21 17:19:49 +08:00
}
```
2018-10-28 08:19:56 +08:00
### Lifecycle
| Lifecycle method | When it gets called |
| ---------------- | -------------------------------------------- |
| `install` | before the component gets mounted to the DOM |
| `installed` | after the component gets mounted to the DOM |
| `uninstall` | prior to removal from the DOM |
| `beforeUpdate` | before update |
| `afterUpdate` | after update |
| `beforeRender` | before `render()` |
## Debugging
Using [Omi DevTools](https://chrome.google.com/webstore/detail/omijs-devtools/pjgglfliglbhpcpalbpeloghnbceocmd) you can simply debug and manage your UI **without any configuration**. Just install and debug.
Since Omi uses Web Components and Shadow-DOM, it doesn't need to have another elements panel such as React or Vue has. It just adds a panel to the **Elements' sidebar** and it's powerful as much as React and Vue DevTools.
![Omi DevTools](https://github.com/f/omi-devtools/raw/master/omi-devtools.gif)
2018-10-20 10:59:36 +08:00
## Browsers Support
Omi 4.0+ works in the latest two versions of all major browsers: Safari 10+, IE 11+, and the evergreen Chrome, Firefox, and Edge.
2018-10-23 06:47:28 +08:00
![→ Browsers Support](./assets/browsers-support.png)
2018-10-20 10:59:36 +08:00
[→ Polyfills](https://github.com/webcomponents/webcomponentsjs)
> If you want to be compatible with IE11, use the Omi file of [→ this project](https://github.com/Tencent/omi/tree/master/packages/omi-ie11). This project uses JSON Diff + Timer instead of Proxy.
2018-10-23 05:41:20 +08:00
> You can dynamically load the JS of this project in the IE11 environment, and the proxy version is still used in other environments.
> You can also give up the store system and use omi-mobx to be compatible with IE11.
2018-10-20 10:59:36 +08:00
## Contribution
1. Fork it (https://github.com/Tencent/omi/fork)
2. Create your branch (`git checkout -b my-urgent-hotfix`)
3. Commit your changes (`git commit -am 'Fixed something'`)
4. Push to the branch (`git push origin my-urgent-hotfix`)
5. Create a new Pull Request
Please contact us for any questions:
2018-10-22 03:50:09 +08:00
- [@f](https://github.com/f)
2018-11-01 10:43:37 +08:00
- [@LeeHyungGeun](https://github.com/LeeHyungGeun)
2018-10-22 03:50:09 +08:00
- [@dntzhang](https://github.com/dntzhang)
2018-10-25 11:38:56 +08:00
- [@xcatliu](https://github.com/xcatliu)
2018-10-20 10:59:36 +08:00
2018-10-29 14:58:04 +08:00
## Thanks
* [preact](https://github.com/developit/preact)
* [JSONPatcherProxy](https://github.com/Palindrom/JSONPatcherProxy)
2018-10-29 15:19:36 +08:00
## Web Components Resource
2018-10-29 15:23:54 +08:00
* [Web Components MDN](https://developer.mozilla.org/en-US/docs/Web/Web_Components)
* [Web Components Google](https://developers.google.com/web/fundamentals/web-components/)
* [Web Components Org](https://www.webcomponents.org/introduction)
2018-10-30 15:30:18 +08:00
* [Proxy MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
2018-10-29 15:19:36 +08:00
2018-10-20 10:59:36 +08:00
## License
MIT © Tencent