Skip to content

Commit

Permalink
feat(taro.ver & demo): update taro version to 3.3.6(latest); improvme…
Browse files Browse the repository at this point in the history
…nt some demo page;
  • Loading branch information
innocces committed Sep 6, 2021
1 parent b249275 commit 547080a
Show file tree
Hide file tree
Showing 160 changed files with 6,060 additions and 76,790 deletions.
18 changes: 9 additions & 9 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
"dependencies": {
"@babel/plugin-transform-typescript": "^7.14.6",
"@babel/runtime": "^7.7.7",
"@tarojs/cli": "3.3.1",
"@tarojs/components": "3.3.1",
"@tarojs/react": "3.3.1",
"@tarojs/runtime": "3.3.1",
"@tarojs/taro": "3.3.1",
"@tarojs/cli": "3.3.6",
"@tarojs/components": "3.3.6",
"@tarojs/react": "3.3.6",
"@tarojs/runtime": "3.3.6",
"@tarojs/taro": "3.3.6",
"ahooks": "^2.10.8",
"axios": "^0.21.1",
"axios-miniprogram-adapter": "^0.3.2",
Expand All @@ -55,16 +55,16 @@
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@tarojs/mini-runner": "3.3.1",
"@tarojs/webpack-runner": "3.3.1",
"@tarojs/mini-runner": "3.3.6",
"@tarojs/webpack-runner": "3.3.6",
"@types/react": "^17.0.2",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"babel-preset-taro": "3.3.1",
"babel-preset-taro": "3.3.6",
"cross-env": "^7.0.3",
"eslint": "^6.8.0",
"eslint-config-taro": "3.3.1",
"eslint-config-taro": "3.3.6",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/pages/panel/index.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default {
navigationBarTitleText: 'taro-hooks',
navigationBarTitleText: 'Taro-hooks',
};
9 changes: 8 additions & 1 deletion packages/app/src/pages/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { View, Text } from '@tarojs/components';
import { AtIcon } from 'taro-ui';

import { Current, navigateTo } from '@tarojs/taro';
import { useModal } from 'taro-hooks';
import { useModal, useNavigationBar } from 'taro-hooks';

import {
List,
Expand All @@ -20,6 +20,7 @@ const Panel = ({}: IPanelProps) => {
const [panelInfo, setPanelInfo] = useState<APIListItem>();
const [panelItemInfo, setPanelItemInfo] = useState<APIChildrenItem[]>();
const [show] = useModal({ mask: true, title: '温馨提示', showCancel: false });
const [_, { setTitle }] = useNavigationBar({ title: 'Taro-hooks' });

useEffect(() => {
const { id } = Current.router?.params || {};
Expand All @@ -31,6 +32,12 @@ const Panel = ({}: IPanelProps) => {
}
}, []);

useEffect(() => {
if (panelInfo && panelInfo.title) {
setTitle(panelInfo.title);
}
}, [panelInfo, setTitle]);

const handleItemAction = useCallback(
(id: string) => {
if (BUILD_MODE && id === 'useVideo') {
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/pages/useBrightness/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.taro-hooks-bri-padding {
padding: 10px 30px;
}
13 changes: 11 additions & 2 deletions packages/app/src/pages/useBrightness/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@ import React from 'react';
import { AtProgress, AtSlider } from 'taro-ui';
import DocPage from '@components/DocPage';
import { View } from '@tarojs/components';
import { ENV_TYPE } from '@tarojs/taro';

import { useBrightness } from 'taro-hooks';
import { useBrightness, useEnv } from 'taro-hooks';

import './index.less';

export default () => {
const [brightness, setBrightness] = useBrightness(true);
const env = useEnv();

return (
<DocPage title="useBrightness 屏幕亮度" panelTitle="useBrightness">
<View className="at-article__h3">当前亮度</View>
<AtProgress percent={brightness * 100} />
<AtProgress
percent={Math.round(brightness * 100)}
className="taro-hooks-bri-padding"
/>
<View className="at-article__h3">设置亮度</View>
<AtSlider
min={0}
max={1}
step={0.1}
value={brightness}
customStyle={env && env === ENV_TYPE.WEB ? { padding: '0.1rem' } : {}}
onChange={(value) => setBrightness(value.toFixed(1))}
></AtSlider>
</DocPage>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/pages/useLaunchOptions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default () => {
<>
<AtNoticebar marquee>请尝试从不同场景打开小程序观察参数变化</AtNoticebar>
<DocPage title="useLaunchOptions 启动参数" panelTitle="useLaunchOptions">
{env !== ENV_TYPE.WEAPP && '改hook仅可在小程序中使用'}
{env !== ENV_TYPE.WEAPP && '该hook仅可在小程序中使用'}
<AtRadio
options={transferOptions(launchOptions)}
value={MOCK}
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
],
"dependencies": {
"@babel/runtime": "^7.14.6",
"@tarojs/taro": "3.3.1",
"@tarojs/taro": "3.3.6",
"compressorjs": "^1.0.7",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
Expand Down
4 changes: 1 addition & 3 deletions packages/taro-runtime/dist/constants/identifiers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ declare const SERVICE_IDENTIFIER: {
TaroTextFactory: string;
TaroNodeImpl: string;
TaroElementImpl: string;
InnerHTMLImpl: string;
insertAdjacentHTMLImpl: string;
getBoundingClientRectImpl: string;
Hooks: string;
onRemoveAttribute: string;
getLifecycle: string;
Expand All @@ -27,5 +24,6 @@ declare const SERVICE_IDENTIFIER: {
modifySetAttrPayload: string;
modifyRmAttrPayload: string;
onAddEvent: string;
patchElement: string;
};
export default SERVICE_IDENTIFIER;
1 change: 1 addition & 0 deletions packages/taro-runtime/dist/constants/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export declare const BODY = 'body';
export declare const APP = 'app';
export declare const CONTAINER = 'container';
export declare const DOCUMENT_ELEMENT_NAME = '#document';
export declare const DOCUMENT_FRAGMENT = 'document-fragment';
export declare const ID = 'id';
export declare const UID = 'uid';
export declare const CLASS = 'class';
Expand Down
4 changes: 0 additions & 4 deletions packages/taro-runtime/dist/dom-external/element-impl.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type { Ctx } from '../interface';
import type { getBoundingClientRectImpl } from './element';
export declare class TaroElementImpl {
rectImpl: typeof getBoundingClientRectImpl;
constructor(rectImpl: typeof getBoundingClientRectImpl); // eslint-disable-next-line @typescript-eslint/indent
bind(ctx: Ctx): void;
bindRect(ctx: Ctx): void;
}
2 changes: 2 additions & 0 deletions packages/taro-runtime/dist/dom-external/element.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import type { Ctx } from '../interface';
export declare function getBoundingClientRectImpl(): Promise<null>;
export declare function getTemplateContent(ctx: Ctx): string | undefined;
16 changes: 1 addition & 15 deletions packages/taro-runtime/dist/dom-external/node-impl.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import { InstanceNamedFactory } from '../interface';
import type { Ctx, GetDoc } from '../interface';
import type { setInnerHTML } from '../dom-external/inner-html/html';
import type { insertAdjacentHTMLImpl } from './node';
declare type SetInnerHTML = typeof setInnerHTML;
declare type InsertAdjacentHTMLImpl = typeof insertAdjacentHTMLImpl;
export declare class TaroNodeImpl {
ctx: Ctx;
getDoc: GetDoc;
innerHTMLImpl: SetInnerHTML;
adjacentImpl: InsertAdjacentHTMLImpl;
constructor( // eslint-disable-next-line @typescript-eslint/indent
getElement: InstanceNamedFactory,
innerHTMLImpl: SetInnerHTML,
adjacentImpl: InsertAdjacentHTMLImpl,
);
constructor(getElement: InstanceNamedFactory); // eslint-disable-next-line @typescript-eslint/indent
bind(ctx: Ctx): void;
private bindInnerHTML;
private bindAdjacentHTML;
}
export {};
2 changes: 2 additions & 0 deletions packages/taro-runtime/dist/dom-external/node.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GetDoc } from '../interface';
import type { Ctx } from '../interface';
export declare type IPosition =
| 'beforebegin'
| 'afterbegin'
Expand All @@ -13,3 +14,4 @@ export declare function insertAdjacentHTMLImpl(
html: string,
getDoc: GetDoc,
): void;
export declare function cloneNode(ctx: Ctx, getDoc: any, isDeep?: boolean): any;
1 change: 1 addition & 0 deletions packages/taro-runtime/dist/dom/document.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ export declare class TaroDocument extends TaroElement {
id: string | undefined | null,
): T | null;
querySelector<T extends TaroElement>(query: string): T | null;
querySelectorAll(): never[];
createComment(): TaroText;
}
3 changes: 2 additions & 1 deletion packages/taro-runtime/dist/dom/node.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NodeType } from './node_types';
import { TaroEventTarget } from './event-target';
import type { UpdatePayload, InstanceNamedFactory } from '../interface';
import type { TaroDocument } from './document';
import type { TaroRootElement } from './root';
import type { TaroElement } from './element';
import type { TaroNodeImpl } from '../dom-external/node-impl';
Expand Down Expand Up @@ -46,10 +47,10 @@ export declare class TaroNode extends TaroEventTarget {
remove(isReplace?: boolean): void;
hasChildNodes(): boolean;
enqueueUpdate(payload: UpdatePayload): void;
cloneNode(isDeep?: boolean): any;
contains(
node: TaroNode & {
id?: string;
},
): boolean;
get ownerDocument(): TaroDocument;
}
2 changes: 1 addition & 1 deletion packages/taro-runtime/dist/dom/root.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import type { TaroElementImpl } from '../dom-external/element-impl';
import type { Hooks } from '../hooks';
import type { Events } from '../emitter/emitter';
export declare class TaroRootElement extends TaroElement {
private pendingUpdate;
private pendingFlush;
private updatePayloads;
private updateCallbacks;
private eventCenter;
pendingUpdate: boolean;
ctx: null | MpInstance;
constructor( // eslint-disable-next-line @typescript-eslint/indent
nodeImpl: TaroNodeImpl,
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-runtime/dist/dsl/instance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Component, ComponentClass } from 'react';
import VueCtor, { ComponentOptions, VNode } from 'vue';
import type { Component as Vue3Component } from '@vue/runtime-core';
import type { CombinedVueInstance } from 'vue/types/vue';
import type { MpEvent } from '../interface';
import type { Func, MpEvent } from '../interface';
import type { TaroElement } from '../dom/element';
export interface Instance<T = Record<string, any>>
extends Component<T>,
Expand Down Expand Up @@ -68,7 +68,7 @@ export interface PageLifeCycle extends Show {
onShareTimeline?(): void;
onAddToFavorites?(): void;
eh?(event: MpEvent): void;
onLoad(options: Record<string, unknown>): void;
onLoad(options: Record<string, unknown>, cb?: Func): void;
onUnload(): void;
}
export interface PageInstance extends PageLifeCycle {
Expand Down
3 changes: 3 additions & 0 deletions packages/taro-runtime/dist/hooks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
ModifyRmAttrPayload,
MpEvent,
OnAddEvent,
patchElement,
} from './interface';
import type { TaroElement } from './dom/element';
import type { TaroEvent } from './dom/event';
Expand All @@ -40,4 +41,6 @@ export declare class Hooks implements IHooks {
modifyTaroEvent(e: TaroEvent, element: TaroElement): void;
initNativeApiImpls?: InitNativeApi[];
initNativeApi(taro: Record<string, any>): void;
patchElementImpls?: patchElement[];
patchElement(element: TaroElement): void;
}
2 changes: 2 additions & 0 deletions packages/taro-runtime/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ export { TaroText } from './dom/text';
export { TaroElement } from './dom/element';
export { TaroRootElement } from './dom/root';
export { FormElement } from './dom/form';
export { SVGElement } from './dom/svg';
export { TaroEvent, createEvent } from './dom/event';
export { createDocument, document } from './bom/document';
export { window } from './bom/window';
export { navigator } from './bom/navigator';
export { default as container } from './container';
export { default as processPluginHooks } from './container/plugin-hooks';
export { default as SERVICE_IDENTIFIER } from './constants/identifiers';
export {
connectReactPage,
Expand Down
13 changes: 12 additions & 1 deletion packages/taro-runtime/dist/interface/hooks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export interface ModifyRmAttrPayload {
export interface OnAddEvent<T extends TaroEventTarget = TaroEventTarget> {
(type: string, handler: EventHandler, options: any, node: T): void;
}
export interface patchElement {
(node: TaroElement): void;
}
export interface IHooks {
/** 解决 React 生命周期名称的兼容问题 */
getLifecycle: GetLifecycle;
Expand Down Expand Up @@ -88,7 +91,10 @@ export interface IHooks {
createPullDownComponent?: CreatePullDownComponent;
/** H5 获取原生 DOM 对象 */
getDOMNode?: GetDOMNode;
/** 挂载属性或 API 到 Taro 对象上 */
/**
* @multi-inject
* 挂载属性或 API 到 Taro 对象上
**/
initNativeApi?: InitNativeApi;
/**
* @todo: mutiInject
Expand All @@ -110,5 +116,10 @@ export interface IHooks {
* 调用 addEventListener 时触发
**/
onAddEvent?: OnAddEvent;
/**
* @todo: mutiInject
* 给 TaroElement 实例注入属性或方法
**/
patchElement?: patchElement;
}
export {};
Loading

2 comments on commit 547080a

@vercel
Copy link

@vercel vercel bot commented on 547080a Sep 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

taro-hooks – ./

taro-hooks-git-main-innocces.vercel.app
taro-hooks-theta.vercel.app
taro-hooks-innocces.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 547080a Sep 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

taro-hooks-h5 – ./

taro-hooks-h5-green.vercel.app
taro-hooks-h5-innocces.vercel.app
taro-hooks-h5-git-main-innocces.vercel.app

Please sign in to comment.