This commit is contained in:
张磊 2018-12-11 14:48:09 +08:00
commit 7e4100ec83
16 changed files with 1103 additions and 27657 deletions

View File

@ -41,7 +41,7 @@
| [mp-mvvm![](https://raw.githubusercontent.com/dntzhang/cax/master/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/mp-mvvm)| 小程序插上 MVVM 的翅膀, [mappingjs](https://github.com/Tencent/omi/tree/master/packages/mappingjs) 强力加持。|
| [omi-html](https://github.com/Tencent/omi/tree/master/packages/omi-html)| Using [htm](https://github.com/developit/htm) in omi.|
| [omi-30-seconds![](https://raw.githubusercontent.com/dntzhang/cax/master/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/omi-30-seconds)| 30 秒理解一段有用的 Omi 代码片段.|
| [omi-spritejs](https://github.com/Tencent/omi/tree/master/packages/omi-spritejs)| Web Components, JSX 和 Canvas 的完美融合|
| [omi-sprite](https://github.com/Tencent/omi/tree/master/packages/omi-sprite)| Web Components, JSX 和 Canvas 的完美融合|
| [omi-canvas](https://github.com/Tencent/omi/tree/master/packages/omi-canvas)| Web Components, JSX 和 Canvas 的完美融合|
| [omi-mp![](https://raw.githubusercontent.com/dntzhang/cax/master/asset/hot.png) ](https://github.com/Tencent/omi/tree/master/packages/omi-mp)| 通过微信小程序开发和生成 Web 单页应用(H5 SPA)|
| [omi-router ](https://github.com/Tencent/omi/tree/master/packages/omi-router) |Omi 官方路由。[→ DEMO](https://tencent.github.io/omi/packages/omi-router/examples/spa/build/)|

View File

@ -4,6 +4,8 @@
The current version is v0.0.0. v1.0.0 is coming soon.
[→ Online DEMO](https://tencent.github.io/omi/packages/omi-sprite/examples/simple/)
```js
import { render, define, WeElement } from 'omi'
import '../../src/index'

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

1065
packages/omi-sprite/dist/omi-sprite.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -4220,7 +4220,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
'Omi'
),
Omi.h(
'omi-spritejs',
'omi-sprite',
{ viewport: [400, 400], resolution: 'flex' },
Omi.h(
'layer',
@ -4382,7 +4382,7 @@ function parseVNode(vdom) {
}));
}
(0, _omi.define)('omi-spritejs', function (_WeElement) {
(0, _omi.define)('omi-sprite', function (_WeElement) {
_inherits(_class, _WeElement);
function _class() {

View File

@ -40,7 +40,7 @@ define('my-app', class extends WeElement {
return (
<div>
<h1>Omi</h1>
<omi-spritejs viewport={[400, 400]} resolution="flex">
<omi-sprite viewport={[400, 400]} resolution="flex">
<layer id="fglayer">
<group>
<label text="SpriteJS" y={100} x={400}></label>
@ -51,7 +51,7 @@ define('my-app', class extends WeElement {
></sprite>
</group>
</layer>
</omi-spritejs>
</omi-sprite>
</div>
)
}

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,5 +1,5 @@
{
"name": "omi-spritejs",
"name": "omi-sprite",
"version": "0.0.0",
"description": "Omi spritejs.",
"main": "dist/index.js",
@ -15,9 +15,9 @@
"url": "https://github.com/Tencent/omi.git"
},
"keywords": [
"omi-spritejs",
"omi-sprite",
"spritejs",
"cax"
"canvas"
],
"dependencies": {
"file-loader": "^2.0.0",

View File

@ -58,7 +58,7 @@ function parseVNode(vdom) {
return h(sel, props, children.map(child => parseVNode(child)))
}
define('omi-spritejs', class extends WeElement {
define('omi-sprite', class extends WeElement {
install() {
}

View File

@ -1,56 +1,56 @@
import {createNode, BaseSprite} from 'spritejs';
import {createNode, BaseSprite} from 'spritejs'
export function createElement(tagName) {
return createNode(tagName);
return createNode(tagName)
}
export function createElementNS(namespaceURI, qualifiedName) {
return createNode(qualifiedName);
return createNode(qualifiedName)
}
export function createTextNode(text) {
return text;
return text
}
export function createComment(text) {
// no def
}
export function insertBefore(parentNode, newNode, referenceNode) {
if(parentNode) {
parentNode.insertBefore(newNode, referenceNode);
parentNode.insertBefore(newNode, referenceNode)
}
}
export function removeChild(node, child) {
node.removeChild(child);
node.removeChild(child)
}
export function appendChild(node, child) {
if(typeof child === 'string') {
node.text = child;
node.text = child
} else {
node.appendChild(child);
node.appendChild(child)
}
}
export function parentNode(node) {
return node.parent;
return node.parent
}
export function nextSibling(node) {
if(node.parent) {
const idx = node.parent.children.indexOf(node);
return node.parent[idx + 1];
const idx = node.parent.children.indexOf(node)
return node.parent[idx + 1]
}
}
export function tagName(elm) {
return elm.tagName;
return elm.tagName
}
export function setTextContent(node, text) {
node.text = text;
node.text = text
}
export function getTextContent(node) {
return node.text;
return node.text
}
export function isElement(node) {
return node instanceof BaseSprite;
return node instanceof BaseSprite
}
export function isText(node) {
return typeof node === 'string';
return typeof node === 'string'
}
export function isComment(node) {
return false;
return false
}

View File

@ -57,7 +57,7 @@ var config = {
if(ENV === 'build'||ENV === 'build-min'){
config = {
entry: {
'omi-spritejs': './src/index.js'
'omi-sprite': './src/index.js'
},
output: {
// path: __dirname,
@ -69,7 +69,7 @@ if(ENV === 'build'||ENV === 'build-min'){
},
externals: {
"omi": 'omi',
"cax": 'cax'
"spritejs": "spritejs",
},
resolve: {
alias: {
@ -95,7 +95,7 @@ if(ENV === 'build'||ENV === 'build-min'){
},
plugins: [
// Avoid publishing files when compilation fails
new webpack.BannerPlugin(" omi-spritejs v"+packageJSON.version+" By akira-cn \r\n Github: https://github.com/AlloyTeam/omi\r\n MIT Licensed."),
new webpack.BannerPlugin(" omi-sprite v"+packageJSON.version+" By akira-cn \r\n Github: https://github.com/AlloyTeam/omi\r\n MIT Licensed."),
new webpack.NoEmitOnErrorsPlugin()
],
stats: {
@ -109,7 +109,7 @@ if(ENV === 'build'||ENV === 'build-min'){
if(ENV === 'build-min'){
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
config.entry = {
'omi-spritejs.min': './src/index.js'
'omi-sprite.min': './src/index.js'
};
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long