Skip to content

Commit

Permalink
Merge pull request #1 from NervJS/next
Browse files Browse the repository at this point in the history
拉取上游更新
  • Loading branch information
bigmeow authored Aug 22, 2022
2 parents ccb37ca + 83de5d0 commit bd4d48e
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,16 @@ export default class MultiSelector extends React.Component<MultiSelectorProps, M
}

render(): JSX.Element {
const { children, disabled } = this.props
const { children, disabled, itemStyle, indicatorStyle } = this.props
const { cols, range, value } = this.state

return (
<AntPicker
data={range}
value={value}
cols={cols}
itemStyle={itemStyle}
indicatorStyle={indicatorStyle}
onChange={this.onChange}
onPickerChange={this.onPickerChange}
onOk={this.onOk}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export default class Selector extends React.Component<SelectorProps, SelectorSta
const {
children,
disabled,
itemStyle,
indicatorStyle,
} = this.props
const {
range,
Expand All @@ -97,6 +99,8 @@ export default class Selector extends React.Component<SelectorProps, SelectorSta
data={range}
value={[selected && selected.value]}
cols={1}
itemStyle={itemStyle}
indicatorStyle={indicatorStyle}
onChange={this.onChange}
onPickerChange={this.onPickerChange}
onOk={this.onOk}
Expand Down
25 changes: 25 additions & 0 deletions packages/taro-components/types/Picker.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentType } from 'react'
import { StyleProp, TextStyle, ViewStyle } from 'react-native'
import { StandardProps, CommonEventFunction, FormItemProps } from './common'

/** 选择器通用参数 */
Expand Down Expand Up @@ -59,6 +60,18 @@ interface PickerSelectorProps extends PickerStandardProps {
* @default 0
*/
value?: number
/**
* mode为 selector 或 multiSelector 时 itemStyle 有效
* @supported rn
* @default {}
*/
itemStyle?: StyleProp<TextStyle>
/**
* mode为 selector 或 multiSelector 时 indicatorStyle 有效
* @supported rn
* @default {}
*/
indicatorStyle?: StyleProp<ViewStyle>
/**
* value 改变时触发 change 事件,event.detail = {value}
* @supported weapp, h5, rn
Expand Down Expand Up @@ -94,6 +107,18 @@ interface PickerMultiSelectorProps extends PickerStandardProps {
* @default []
*/
value: number[] | string[] | Record<string, any>[]
/**
* mode为 selector 或 multiSelector 时 itemStyle 有效
* @supported rn
* @default {}
*/
itemStyle?: StyleProp<TextStyle>
/**
* mode为 selector 或 multiSelector 时 indicatorStyle 有效
* @supported rn
* @default {}
*/
indicatorStyle?: StyleProp<ViewStyle>
/**
* 当 value 改变时触发 change 事件,event.detail = {value}
* @supported weapp, h5, rn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ require(\\"./taro\\");
needPromiseApis: needPromiseApis
});
}
var _true = \\"true\\";
var _false = \\"false\\";
var _empty = \\"\\";
var components = {
Icon: {
size: \\"24\\"
Expand All @@ -82,13 +85,28 @@ require(\\"./taro\\");
},
Video: {
\\"play-btn-position\\": undefined(\\"center\\"),
\\"pre-roll-unit-id\\": \\"\\",
\\"post-roll-unit-id\\": \\"\\",
bindAdStart: \\"\\",
bindAdEnded: \\"\\",
bindAdLoad: \\"\\",
bindAdClose: \\"\\",
bindAdError: \\"\\"
\\"pre-roll-unit-id\\": _empty,
\\"post-roll-unit-id\\": _empty,
\\"vslide-gesture\\": _false,
\\"vslide-gesture-in-fullscreen\\": _true,
\\"enable-play-gesture\\": _false,
\\"show-playback-rate-btn\\": _false,
\\"enable-play-in-background\\": _false,
signature: _empty,
bindProgress: _empty,
bindSeekComplete: _empty,
bindAdLoad: _empty,
bindAdStart: _empty,
bindAdEnded: _empty,
bindAdError: _empty,
bindAdClose: _empty,
bindLoadedMetadata: _empty,
bindPlaybackRateChange: _empty,
bindMuteChange: _empty,
bindControlTap: _empty,
bindEnterBackground: _empty,
bindCloseBackground: _empty,
bindLeaveBackground: _empty
},
Ad: {
fixed: \\"\\",
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-rn-runner/src/config/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { extname, join } from 'path'
import * as qr from 'qrcode-terminal'
import { URL } from 'url'

import { getOpenHost, PLAYGROUNDINFO } from '../utils'
import { getOpenHost, isWin, PLAYGROUNDINFO } from '../utils'

interface PreviewOption {
out: string
Expand Down Expand Up @@ -110,5 +110,5 @@ export default (opt: PreviewOption):void => {
const url = `${host}/index.js`
console.log(PLAYGROUNDINFO)
console.log(`print qrcode of ${opt.platform} bundle '${url}':`)
qr.generate(url, { small: true })
qr.generate(url, { small: !isWin })
}
4 changes: 2 additions & 2 deletions packages/taro-rn-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import buildComponent from './config/build-component'
import { getRNConfigEntry } from './config/config-holder'
import preview from './config/preview'
import { TerminalReporter } from './config/terminal-reporter'
import { getOpenHost, PLAYGROUNDINFO } from './utils'
import { getOpenHost, isWin, PLAYGROUNDINFO } from './utils'

function concatOutputFileName (config: any): string {
// 优先级:--bundle-output > config.output > config.outputRoot
Expand Down Expand Up @@ -181,7 +181,7 @@ export default async function build (_appPath: string, config: any): Promise<any
const url = `taro://${host}:${metroConfig.server.port}`
console.log(PLAYGROUNDINFO)
console.log(`print qrcode of '${url}':`)
qr.generate(url, { small: true })
qr.generate(url, { small: !isWin })
} else {
console.log('print qrcode error: host not found.')
}
Expand Down
2 changes: 2 additions & 0 deletions packages/taro-rn-runner/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ export function getOpenHost () {
export const PLAYGROUNDREPO = 'https://github.com/wuba/taro-playground'

export const PLAYGROUNDINFO = `use [Taro Playground App](${PLAYGROUNDREPO}) to scan`

export const isWin = /^win/.test(process.platform)
33 changes: 26 additions & 7 deletions packages/taro-tt/src/components.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { singleQuote } from '@tarojs/shared'

const _true = 'true'
const _false = 'false'
const _empty = ''

export const components = {
// ======== 调整属性 ========
Icon: {
Expand All @@ -21,13 +25,28 @@ export const components = {
},
Video: {
'play-btn-position': singleQuote('center'),
'pre-roll-unit-id': '',
'post-roll-unit-id': '',
bindAdStart: '',
bindAdEnded: '',
bindAdLoad: '',
bindAdClose: '',
bindAdError: ''
'pre-roll-unit-id': _empty,
'post-roll-unit-id': _empty,
'vslide-gesture': _false,
'vslide-gesture-in-fullscreen': _true,
'enable-play-gesture': _false,
'show-playback-rate-btn': _false,
'enable-play-in-background': _false,
'signature': _empty,
bindProgress: _empty,
bindSeekComplete: _empty,
bindAdLoad: _empty,
bindAdStart: _empty,
bindAdEnded: _empty,
bindAdError: _empty,
bindAdClose: _empty,
bindLoadedMetadata: _empty,
bindPlaybackRateChange: _empty,
bindMuteChange: _empty,
bindControlTap: _empty,
bindEnterBackground: _empty,
bindCloseBackground: _empty,
bindLeaveBackground: _empty,
},
Ad: {
fixed: '',
Expand Down
1 change: 1 addition & 0 deletions packages/taro-webpack5-prebundle/src/prebundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export default class BasePrebundle<T extends IPrebundleConfig = IPrebundleConfig
delete inherit.devServer
delete inherit.module
delete inherit.plugins
delete inherit.optimization?.splitChunks

return webpack(recursiveMerge(inherit, standard, custom))
}
Expand Down
23 changes: 20 additions & 3 deletions packages/taro-webpack5-runner/src/index.h5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ export default async function build (appPath: string, rawConfig: H5BuildConfig):
async function getDevServerOptions (appPath: string, config: H5BuildConfig): Promise<WebpackDevServer.Configuration> {
const publicPath = parsePublicPath(config.publicPath)
const outputPath = path.join(appPath, config.outputRoot || 'dist')
const customDevServerOption = config.devServer || {}
const { proxy: customProxy = [], ...customDevServerOption } = config.devServer || {}
const routerConfig = config.router || {}
const routerMode = routerConfig.mode || 'hash'
const isMultiRouterMode = routerMode === 'multi'
const proxy = {}
const proxy: WebpackDevServer.Configuration['proxy'] = []
if (isMultiRouterMode) {
const app = new H5AppInstance(config.entry as EntryNormalized, {
sourceDir: path.join(appPath, config.sourceRoot || SOURCE_DIR),
Expand Down Expand Up @@ -180,7 +180,24 @@ async function getDevServerOptions (appPath: string, config: H5BuildConfig): Pro
}
}
}
proxy[routerBasename] = { bypass }
proxy.push({
context: [routerBasename],
bypass
})
}

if (!(customProxy instanceof Array)) {
proxy.push(...Object.entries(customProxy).map(([url, options = {}]) => {
const item: WebpackDevServer.ProxyConfigArrayItem = {
context: [url]
}
if (typeof options === 'string') {
item.target = options
} else {
Object.assign(item, options)
}
return item
}))
}

const chunkFilename = config.output.chunkFilename ?? `${config.chunkDirectory || 'chunk'}/[name].js`
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-webpack5-runner/src/webpack/Combination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Combination<T extends MiniBuildConfig | H5BuildConfig = CommonBuild
this.outputRoot = config.outputRoot || 'dist'
this.sourceDir = path.join(appPath, this.sourceRoot)
this.outputDir = path.join(appPath, this.outputRoot)
this.enableSourceMap = process.env.NODE_ENV !== 'production'
this.enableSourceMap = config.enableSourceMap ?? process.env.NODE_ENV !== 'production'
}

async make () {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-webpack5-runner/src/webpack/H5Combination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class H5Combination extends Combination<H5BuildConfig> {
}
const optimization: Optimization = {
nodeEnv,
chunkIds: isProd ? 'natural' : 'named',
chunkIds: isProd ? 'deterministic' : 'named', // false 或导致编译错误,natural、size、total-size 与 prebundle 特性不兼容
removeEmptyChunks: true,
splitChunks: {
chunks: 'initial',
Expand Down

0 comments on commit bd4d48e

Please sign in to comment.