Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Sep 4, 2019
2 parents 25872a1 + f98b0ca commit cbdbfce
Show file tree
Hide file tree
Showing 53 changed files with 152 additions and 118 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module.exports = {
'@typescript-eslint/no-explicit-any': [0],
'@typescript-eslint/explicit-member-accessibility': [0],
'@typescript-eslint/no-non-null-assertion': [0],
'@typescript-eslint/triple-slash-reference': [0],
'react/jsx-uses-vars': 2,
'@typescript-eslint/array-type': [2, { default: 'array-simple' }],
},
};
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
- 支持在运行时访问 REMAX*APP* 开头的环境变量 ([b8fb287](https://github.com/remaxjs/remax/commit/b8fb287))
- 支持字节跳动小程序 ([d7adadc](https://github.com/remaxjs/remax/commit/d7adadc))

## [1.0.15](https://github.com/remaxjs/remax/compare/v1.0.14...v1.0.15) (2019-09-04)

### Bug Fixes

- 修复 npm 中带有非 js 后缀文件时支付宝小程序无法上传的问题 ([e53e0b9](https://github.com/remaxjs/remax/commit/e53e0b9))
- 支付宝 css 背景图片支持相对路径写法 ([#198](https://github.com/remaxjs/remax/issues/198)) ([8f01e64](https://github.com/remaxjs/remax/commit/8f01e64))

## [1.0.14](https://github.com/remaxjs/remax/compare/v1.0.13...v1.0.14) (2019-09-03)

### Bug Fixes
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ title: 样式
order: 24
---

Remax 默认支持 css/less/sass/stylus,安装你需要的样式,即可使用。如:
Remax 默认支持 css/less/sass/stylus,安装你需要的样式处理器,即可使用。如:

```bash
npm install less # less 用户
npm install node-sass # sass 用户
npm install less --save # less 用户
npm install node-sass --save # sass 用户
```

```js
Expand Down
7 changes: 7 additions & 0 deletions packages/remax-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
- 支持在运行时访问 REMAX*APP* 开头的环境变量 ([b8fb287](https://github.com/remaxjs/remax/commit/b8fb287))
- 支持字节跳动小程序 ([d7adadc](https://github.com/remaxjs/remax/commit/d7adadc))

## [1.0.15](https://github.com/remaxjs/remax/compare/v1.0.14...v1.0.15) (2019-09-04)

### Bug Fixes

- 修复 npm 中带有非 js 后缀文件时支付宝小程序无法上传的问题 ([e53e0b9](https://github.com/remaxjs/remax/commit/e53e0b9))
- 支付宝 css 背景图片支持相对路径写法 ([#198](https://github.com/remaxjs/remax/issues/198)) ([8f01e64](https://github.com/remaxjs/remax/commit/8f01e64))

## [1.0.14](https://github.com/remaxjs/remax/compare/v1.0.13...v1.0.14) (2019-09-03)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/remax-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"ejs": "^2.6.1",
"lodash": "^4.17.11",
"mkdirp": "^0.5.1",
"named-exports-db": "^0.0.1",
"postcss-url": "^8.0.0",
"rollup": "^1.16.0",
"rollup-plugin-alias": "^1.5.2",
Expand All @@ -60,7 +61,6 @@
"rollup-plugin-progress": "^1.1.1",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-url": "^2.2.2",
"scheduler": "0.13.6",
"slash2": "^2.0.0",
"yargs": "^13.2.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/remax-cli/src/build/adapters/alipay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function getIcons(config: any) {
return [];
}

const tabs: { icon: string; activeIcon: string }[] = config.tabBar.items;
const tabs: Array<{ icon: string; activeIcon: string }> = config.tabBar.items;

if (tabs) {
return tabs.reduce<string[]>(
Expand Down
2 changes: 1 addition & 1 deletion packages/remax-cli/src/build/adapters/wechat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function getIcons(config: any) {
return [];
}

const tabs: { iconPath: string; selectedIconPath: string }[] =
const tabs: Array<{ iconPath: string; selectedIconPath: string }> =
config.tabBar.list;

if (tabs) {
Expand Down
7 changes: 7 additions & 0 deletions packages/remax-cli/src/build/plugins/postcssUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RemaxOptions } from '../../getConfig';

interface Asset {
url: string;
absolutePath: string;
}

export default (options: RemaxOptions) =>
Expand All @@ -25,6 +26,12 @@ export default (options: RemaxOptions) =>
});
}
});
if (!/^\//.test(asset.url)) {
return `/${path.relative(
path.resolve(options.cwd, 'src'),
asset.absolutePath
)}`;
}
return asset.url;
},
basePath: path.resolve(options.cwd, 'src'),
Expand Down
16 changes: 2 additions & 14 deletions packages/remax-cli/src/build/plugins/removeESModuleFlag.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import { Plugin } from 'rollup';
import { simple } from 'acorn-walk';
import MagicString from 'magic-string';
import { createFilter } from 'rollup-pluginutils';

const files = [
/node_modules\/scheduler\/cjs\/scheduler-tracing.development.js$/,
/node_modules\/scheduler\/cjs\/scheduler-tracing.production.min.js$/,
/node_modules\/scheduler\/cjs\/scheduler.development.js/,
/node_modules\/scheduler\/cjs\/scheduler.production.min.js/,
];

// __esModule 标示会影响 webpack 编译出来的模块
export default function removeESModuleFlag(): Plugin {
return {
name: 'remove-esmodule-flag',
transform(code, id) {
const filter = createFilter(files);
if (!filter(id)) {
return null;
}

transform(code) {
const magicString = new MagicString(code);
const ast = this.parse(code, {
ecmaVersion: 6,
Expand Down
20 changes: 9 additions & 11 deletions packages/remax-cli/src/build/rollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ import removeSrc from './plugins/removeSrc';
import removeConfig from './plugins/removeConfig';
import rename from './plugins/rename';
import replace from 'rollup-plugin-replace';
import * as React from 'react';
import * as scheduler from 'scheduler';
import { RemaxOptions } from '../getConfig';
import app from './plugins/app';
import removeESModuleFlag from './plugins/removeESModuleFlag';
import adapters, { Adapter } from './adapters';
import { Context, Env } from '../types';
import namedExports from 'named-exports-db';

export default function rollupConfig(
options: RemaxOptions,
Expand Down Expand Up @@ -120,10 +119,7 @@ export default function rollupConfig(
}),
commonjs({
include: /node_modules/,
namedExports: {
react: Object.keys(React).filter(k => k !== 'default'),
scheduler: Object.keys(scheduler).filter(k => k !== 'default'),
},
namedExports,
}),
stub({
modules: stubModules,
Expand Down Expand Up @@ -181,11 +177,6 @@ export default function rollupConfig(

input = input
.replace(/^demo\/src\//, '')
// stlye
.replace(/\.less$/, '.less.js')
.replace(/\.sass$/, '.sass.js')
.replace(/\.scss$/, '.scss.js')
.replace(/\.styl$/, '.styl.js')
// typescript
.replace(/\.ts$/, '.js')
.replace(/\.tsx$/, '.js')
Expand Down Expand Up @@ -217,6 +208,13 @@ export default function rollupConfig(
return (
input &&
input
// npm 包可能会有 jsx
.replace(/\.jsx$/, '.js')
// npm 包里可能会有 css
.replace(/\.less$/, '.less.js')
.replace(/\.sass$/, '.sass.js')
.replace(/\.scss$/, '.scss.js')
.replace(/\.styl$/, '.styl.js')
.replace(/node_modules/g, 'npm')
.replace(/\.js_commonjs-proxy$/, '.js_commonjs-proxy.js')
// 支付宝小程序不允许目录带 @
Expand Down
8 changes: 4 additions & 4 deletions packages/remax-cli/src/getEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { Context } from './types';

interface AppConfig {
pages: string[];
subpackages: {
subpackages: Array<{
root: string;
pages: string[];
}[];
}>;
tabBar?: {
items: { icon: string; activeIcon: string }[];
list: { iconPath: string; selectedIconPath: string }[];
items: Array<{ icon: string; activeIcon: string }>;
list: Array<{ iconPath: string; selectedIconPath: string }>;
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/remax-cli/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ declare module '@babel/helper-module-imports';
declare module 'acorn-walk';
declare module 'scheduler';
declare module 'slash2';
declare module 'named-exports-db';
4 changes: 4 additions & 0 deletions packages/remax/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

- 支持字节跳动小程序 ([d7adadc](https://github.com/remaxjs/remax/commit/d7adadc))

## [1.0.15](https://github.com/remaxjs/remax/compare/v1.0.14...v1.0.15) (2019-09-04)

**Note:** Version bump only for package remax

## [1.0.14](https://github.com/remaxjs/remax/compare/v1.0.13...v1.0.14) (2019-09-03)

### Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions packages/remax/alipay.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import 'mini-types';
export * from './lib/adapters/alipay';
1 change: 1 addition & 0 deletions packages/remax/h5.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import 'typescript/lib/lib.dom';
export * from './lib/adapters/h5';
1 change: 1 addition & 0 deletions packages/remax/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test": "jest"
},
"dependencies": {
"mini-types": "^0.0.4",
"miniprogram-api-typings": "^2.8.1",
"react-reconciler": "0.20.4",
"scheduler": "0.13.6",
Expand Down
18 changes: 12 additions & 6 deletions packages/remax/src/Container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class Container {
path: Path,
start: number,
deleteCount: number,
immediately: boolean,
...items: RawNode[]
) {
const update: SpliceUpdate = {
Expand All @@ -43,10 +44,15 @@ export default class Container {
deleteCount,
items,
};
if (this.updateQueue.length === 0) {
this.updateTimer = setTimeout(() => this.applyUpdate());
if (immediately) {
this.updateQueue.push(update);
this.applyUpdate();
} else {
if (this.updateQueue.length === 0) {
this.updateTimer = setTimeout(() => this.applyUpdate());
}
this.updateQueue.push(update);
}
this.updateQueue.push(update);
}

applyUpdate() {
Expand Down Expand Up @@ -93,14 +99,14 @@ export default class Container {
}

appendChild(child: VNode) {
this.root.appendChild(child);
this.root.appendChild(child, true);
}

removeChild(child: VNode) {
this.root.removeChild(child);
this.root.removeChild(child, true);
}

insertBefore(child: VNode, beforeChild: VNode) {
this.root.insertBefore(child, beforeChild);
this.root.insertBefore(child, beforeChild, true);
}
}
16 changes: 12 additions & 4 deletions packages/remax/src/VNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,34 @@ export default class VNode {
this.children = [];
}

appendChild(node: VNode) {
appendChild(node: VNode, immediately: boolean) {
node.parent = this;
this.children.push(node);
if (this.isMounted()) {
this.container.requestUpdate(
[...this.path(), 'children'],
this.children.length - 1,
0,
immediately,
node.toJSON()
);
}
}

removeChild(node: VNode) {
removeChild(node: VNode, immediately: boolean) {
const start = this.children.indexOf(node);
this.children.splice(start, 1);
if (this.isMounted()) {
this.container.requestUpdate([...this.path(), 'children'], start, 1);
this.container.requestUpdate(
[...this.path(), 'children'],
start,
1,
immediately
);
}
}

insertBefore(newNode: VNode, referenceNode: VNode) {
insertBefore(newNode: VNode, referenceNode: VNode, immediately: boolean) {
newNode.parent = this;
const start = this.children.indexOf(referenceNode);
this.children.splice(start, 0, newNode);
Expand All @@ -69,6 +75,7 @@ export default class VNode {
[...this.path(), 'children'],
start,
0,
immediately,
newNode.toJSON()
);
}
Expand All @@ -80,6 +87,7 @@ export default class VNode {
[...this.parent!.path(), 'children'],
this.parent!.children.indexOf(this),
1,
false,
this.toJSON()
);
}
Expand Down
Loading

0 comments on commit cbdbfce

Please sign in to comment.