Skip to content

Commit

Permalink
Merge branch 'master' of github.com:broven/universal-api
Browse files Browse the repository at this point in the history
* 'master' of github.com:broven/universal-api:
  Feat quickapp asyncstorage (raxjs#77)
  fix: 兼容 1.0 class 组件在 Web 下 transitionEnd 回调失效 (raxjs#47)
  universal-unit-tool pkg (raxjs#70)
  fix: compaty node (raxjs#68)
  feat(device): support pixelRatio (raxjs#67)
  feat: support bytedance microapp in universal-env (raxjs#61)
  • Loading branch information
broven committed Apr 15, 2020
2 parents b70ef51 + 619cdd0 commit 57e6be9
Show file tree
Hide file tree
Showing 19 changed files with 181 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ module.exports = {
'@typescript-eslint/explicit-function-return-type': 'off',
'quotes': ['error', 'single']
}
};
};
9 changes: 9 additions & 0 deletions packages/asyncstorage/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
5 changes: 0 additions & 5 deletions packages/asyncstorage/.eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion packages/asyncstorage/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ module.exports = {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-function-return-type": "off"
}
};
};
20 changes: 20 additions & 0 deletions packages/asyncstorage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

*~
*.swp
*.log

.DS_Store
.idea/
.temp/

build/
dist/
lib/
coverage/
es/
types/
node_modules/

demo/miniapp/components/
_miniapp/
15 changes: 5 additions & 10 deletions packages/asyncstorage/.npmignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
*.swp
*.log

.DS_Store
.idea/
package-lock.json
yarn.lock
coverage/
node_modules/
build/
demo
.eslintignore
.eslintrc.js
.travis.yml
.tsconfig.json
3 changes: 2 additions & 1 deletion packages/asyncstorage/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
> AsyncStorage
## 支持
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px" /> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px" /> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px" /> <img alt="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px"> <img alt="bytedanceMicroApp" src="https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg" width="25px" height="25px">
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px" /> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px" /> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px" /> <img alt="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px"> <img alt="quickApp" src="https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg" width="25px" height="25px"> <img alt="bytedanceMicroApp" src="https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg" width="25px" height="25px">

## 安装

```bash
Expand Down
2 changes: 1 addition & 1 deletion packages/asyncstorage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> AsyncStorage
## Support
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px" /> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px" /> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px" /> <img alt="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px"> <img alt="bytedanceMicroApp" src="https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg" width="25px" height="25px">
<img alt="browser" src="https://gw.alicdn.com/tfs/TB1uYFobGSs3KVjSZPiXXcsiVXa-200-200.svg" width="25px" height="25px" /> <img alt="weex" src="https://gw.alicdn.com/tfs/TB1jM0ebMaH3KVjSZFjXXcFWpXa-200-200.svg" width="25px" height="25px" /> <img alt="miniApp" src="https://gw.alicdn.com/tfs/TB1bBpmbRCw3KVjSZFuXXcAOpXa-200-200.svg" width="25px" height="25px" /> <img alt="wechatMiniprogram" src="https://img.alicdn.com/tfs/TB1slcYdxv1gK0jSZFFXXb0sXXa-200-200.svg" width="25px" height="25px"> <img alt="quickApp" src="https://gw.alicdn.com/tfs/TB1MP7EwQT2gK0jSZPcXXcKkpXa-200-200.svg" width="25px" height="25px"> <img alt="bytedanceMicroApp" src="https://gw.alicdn.com/tfs/TB1jFtVzO_1gK0jSZFqXXcpaXXa-200-200.svg" width="25px" height="25px">

## Install

Expand Down
10 changes: 5 additions & 5 deletions packages/asyncstorage/build.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"plugins": [
[
"rax-plugin-component",
"build-plugin-rax-component",
{
"enableTypescript": true,
"targets": ["web", "weex"]
"type": "rax",
"targets": ["web"]
}
]
]
]
}
}
3 changes: 2 additions & 1 deletion packages/asyncstorage/docs-template/README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
> AsyncStorage
## 支持
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_quick_app__ __icon_microapp_tt__

## 安装

```bash
Expand Down
2 changes: 1 addition & 1 deletion packages/asyncstorage/docs-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> AsyncStorage
## Support
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_microapp_tt__
__icon_web__ __icon_weex__ __icon_miniapp_mp__ __icon_miniapp_wx__ __icon_quick_app__ __icon_microapp_tt__

## Install

Expand Down
38 changes: 22 additions & 16 deletions packages/asyncstorage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,36 @@
"name": "universal-asyncstorage",
"version": "1.2.0",
"description": "A universal AsyncStorage API.",
"license": "BSD-3-Clause",
"main": "lib/index.js",
"scripts": {
"start": "rax-scripts start",
"build": "rax-scripts build",
"lint": "eslint --ext .js --ext .jsx --ext .ts --ext .tsx ./src",
"prebuild": "npm run lint && npm run test",
"prepublish": "npm run build"
},
"module": "src/index.js",
"files": [
"dist",
"es",
"lib",
"src",
"types"
],
"keywords": [
"universal"
"Rax",
"rax-component"
],
"repository": {
"type": "git",
"url": "https://github.com/raxjs/universal-api.git"
"engines": {
"npm": ">=3.0.0"
},
"bugs": {
"url": "https://github.com/raxjs/universal-api/issues"
"peerDependencies": {
"rax": "^1.1.0"
},
"scripts": {
"start": "build-scripts start",
"build": "build-scripts build"
},
"homepage": "https://github.com/raxjs/universal-api#readme",
"dependencies": {
"universal-env": "^2.0.0"
"universal-env": "^3.1.0"
},
"devDependencies": {
"@alib/build-scripts": "^0.1.0",
"build-plugin-rax-component": "^0.2.2",
"driver-universal": "^3.1.0",
"@types/jest": "^24.0.12",
"@types/node": "^12.0.2",
"@typescript-eslint/eslint-plugin": "^1.7.0",
Expand Down
25 changes: 11 additions & 14 deletions packages/asyncstorage/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import { isWeb, isWeex, isMiniApp, isWeChatMiniProgram, isByteDanceMicroApp } from 'universal-env';
import { isWeb, isWeex, isMiniApp, isWeChatMiniProgram, isByteDanceMicroApp, isQuickApp } from 'universal-env';

import webModule from './web/index';
import weexModule from './weex/index';
import miniAppModule from './miniapp/ali/index';
import weChatModule from './miniapp/wechat/index';
import bytedanceModule from './miniapp/bytedance/index';
import quickModule from './quickapp/index';

import { AsyncStorage } from './types';

let AsyncStorage: AsyncStorage;

if (isWeb) {
if (isQuickApp) {
AsyncStorage = quickModule;
} else if (isWeb) {
AsyncStorage = webModule;
}

if (isWeex) {
} else if (isWeex) {
AsyncStorage = weexModule;
}

if (isMiniApp) {
} else if (isMiniApp) {
AsyncStorage = miniAppModule;
}

if (isWeChatMiniProgram) {
} else if (isWeChatMiniProgram) {
AsyncStorage = weChatModule;
}
if (isByteDanceMicroApp) {
} else if (isByteDanceMicroApp) {
AsyncStorage = bytedanceModule;
}

Expand Down
70 changes: 70 additions & 0 deletions packages/asyncstorage/src/quickapp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
function setItem(key, value) {
return new Promise(function(resolve, reject) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const storage = require('@system.storage');
storage.set({
key,
value,
success: function(data) {
resolve(data);
},
fail: function(data, code) {
reject(`handling fail, code = ${code}`);
}
});
});
}

function getItem(key) {
return new Promise(function(resolve, reject) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const storage = require('@system.storage');
storage.get({
key,
success: function(data) {
resolve(data);
},
fail: function(data, code) {
reject(`handling fail, code = ${code}`);
}
});
});
}

function removeItem(key) {
return new Promise(function(resolve, reject) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const storage = require('@system.storage');
storage.delete({
key,
success: function(data) {
resolve(data);
},
fail: function(data, code) {
reject(`handling fail, code = ${code}`);
}
});
});
}

function clear() {
return new Promise(function(resolve, reject) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const storage = require('@system.storage');
storage.clear({
success: function(data) {
resolve(data);
},
fail: function(data, code) {
reject(`handling fail, code = ${code}`);
}
});
});
}

module.exports = {
setItem,
getItem,
removeItem,
clear
};
2 changes: 1 addition & 1 deletion packages/asyncstorage/src/weex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const AsyncStorage: AsyncStorage = {
if (result === 'success') {
resolve(data);
} else {
resolve(null);
reject(null);
}
});
});
Expand Down
4 changes: 1 addition & 3 deletions packages/choose-image/src/weex/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Options } from '../types';

const choose = (options: Options = {}): Promise<null> => {
const choose = (): Promise<null> => {
return Promise.reject();
};

Expand Down
8 changes: 4 additions & 4 deletions packages/transition/build.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"plugins": [
[
"rax-plugin-component",
"build-plugin-rax-component",
{
"enableTypescript": true,
"targets": ["web", "weex"]
"type": "rax",
"targets": ["web"]
}
]
]
}
}
41 changes: 18 additions & 23 deletions packages/transition/package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
{
"name": "universal-transition",
"version": "1.0.2",
"version": "1.0.3",
"description": "A universal transition API.",
"license": "BSD-3-Clause",
"main": "lib/index.js",
"files": [
"src",
"lib",
"dist"
],
"scripts": {
"start": "rax-scripts start",
"build": "rax-scripts build",
"test": "rax-scripts test",
"lint": "eslint --ext .js --ext .jsx --ext .ts --ext .tsx ./src",
"prebuild": "npm run lint && npm run test",
"prepublish": "npm run build"
"start": "build-scripts start",
"build": "build-scripts build"
},
"pre-commit": [
"lint"
],
"keywords": [
"universal"
"Rax"
],
"engines": {
"npm": ">=3.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/raxjs/universal-api.git"
Expand All @@ -29,21 +36,9 @@
"universal-env": "^3.0.0"
},
"devDependencies": {
"@types/jest": "^24.0.18",
"@typescript-eslint/eslint-plugin": "^1.7.0",
"@typescript-eslint/parser": "^1.7.0",
"babel-eslint": "^10.0.2",
"eslint": "5.15.1",
"eslint-config-rax": "^0.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-react": "^7.12.4",
"pre-commit": "^1.2.2",
"rax": "^1.0.8",
"rax-plugin-component": "^0.1.9",
"rax-scripts": "^2.0.0"
},
"pre-commit": [
"lint",
"test"
]
"build-plugin-rax-component": "^0.1.0",
"@alib/build-scripts": "^0.1.0"
}
}
12 changes: 7 additions & 5 deletions packages/transition/src/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ export default function transition(node: any, styles: any, options: any, callbac
node.addEventListener('transitionend', transitionEndHandler);
}

for (const key in styles) {
// TODO add vendor prefix
let value = styles[key];
node.style[key] = value;
}
setTimeout(() => {
for (const key in styles) {
// TODO add vendor prefix
let value = styles[key];
node.style[key] = value;
}
}, 0);
}

0 comments on commit 57e6be9

Please sign in to comment.