Skip to content

Commit

Permalink
feat!: remove redundant types and reduce dependency on uni-app-types
Browse files Browse the repository at this point in the history
  • Loading branch information
ModyQyW committed Aug 6, 2024
1 parent 0d0c7bf commit 2b03b3e
Show file tree
Hide file tree
Showing 112 changed files with 262 additions and 294 deletions.
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/ad/ad-content-page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent, CustomEvent } from "../events";

type _AdContentPageOnLoadEvent = BaseEvent;
Expand Down Expand Up @@ -142,7 +142,7 @@ type _AdContentPageProps = Partial<{
}>;

/** 短视频内容联盟广告 */
type _AdContentPage = Component<_AdContentPageProps>;
type _AdContentPage = DefineComponent<_AdContentPageProps>;

/** 短视频内容联盟广告实例 */
type _AdContentPageInstance = InstanceType<_AdContentPage>;
Expand Down
6 changes: 3 additions & 3 deletions packages/uni-app-types/src/ad/ad-draw.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyRecord, Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent, CustomEvent } from "../events";

type _AdDrawOnLoadEvent = BaseEvent;
Expand All @@ -23,15 +23,15 @@ type _AdDrawProps = Partial<{
/** APP 广告位 id */
adpid: string;
/** 广告数据 */
data: AnyRecord;
data: Record<string, any>;
/** 广告加载成功的回调 */
onLoad: _AdDrawOnLoad;
/** 广告加载失败的回调 */
onError: _AdDrawOnError;
}>;

/** 沉浸视频流广告 */
type _AdDraw = Component<_AdDrawProps>;
type _AdDraw = DefineComponent<_AdDrawProps>;

/** 沉浸视频流广告实例 */
type _AdDrawInstance = InstanceType<_AdDraw>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/ad/ad-fullscreen-video.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent, CustomEvent } from "../events";

type _AdFullscreenVideoOnLoadEvent = BaseEvent;
Expand Down Expand Up @@ -53,7 +53,7 @@ type _AdFullscreenVideoProps = Partial<{
}>;

/** 全屏视频广告 */
type _AdFullscreenVideo = Component<_AdFullscreenVideoProps>;
type _AdFullscreenVideo = DefineComponent<_AdFullscreenVideoProps>;

/** 全屏视频广告实例 */
type _AdFullscreenVideoInstance = InstanceType<_AdFullscreenVideo>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/ad/ad-interactive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent, CustomEvent } from "../events";

type _AdInteractiveOnLoadEvent = BaseEvent;
Expand Down Expand Up @@ -31,7 +31,7 @@ type _AdInteractiveProps = Partial<{
}>;

/** 互动广告 */
type _AdInteractive = Component<_AdInteractiveProps>;
type _AdInteractive = DefineComponent<_AdInteractiveProps>;

/** 互动广告实例 */
type _AdInteractiveInstance = InstanceType<_AdInteractive>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/ad/ad-interstitial.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent, CustomEvent } from "../events";

type _AdInterstitialOnLoadEvent = BaseEvent;
Expand Down Expand Up @@ -48,7 +48,7 @@ type _AdInterstitialProps = Partial<{
}>;

/** 插屏广告 */
type _AdInterstitial = Component<_AdInterstitialProps>;
type _AdInterstitial = DefineComponent<_AdInterstitialProps>;

/** 插屏广告实例 */
type _AdInterstitialInstance = InstanceType<_AdInterstitial>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/ad/ad-rewarded-video.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent, CustomEvent } from "../events";

/** 服务器回调透传数据 */
Expand Down Expand Up @@ -56,7 +56,7 @@ type _AdRewardedVideoProps = Partial<{
}>;

/** 激励视频广告 */
type _AdRewardedVideo = Component<_AdRewardedVideoProps>;
type _AdRewardedVideo = DefineComponent<_AdRewardedVideoProps>;

/** 激励视频广告实例 */
type _AdRewardedVideoInstance = InstanceType<_AdRewardedVideo>;
Expand Down
6 changes: 3 additions & 3 deletions packages/uni-app-types/src/ad/ad.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyRecord, Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent, CustomEvent } from "../events";

type _AdOnLoadEvent = BaseEvent;
Expand Down Expand Up @@ -38,7 +38,7 @@ type _AdProps = Partial<{
*/
adIntervals: number;
/** 广告数据,优先级高于 adpid */
data: AnyRecord;
data: Record<string, any>;
/** 小程序应用 ID */
appid: string;
/** 小程序广告位 ID */
Expand Down Expand Up @@ -80,7 +80,7 @@ type _AdProps = Partial<{
}>;

/** 信息流广告 */
type _Ad = Component<_AdProps>;
type _Ad = DefineComponent<_AdProps>;

/** 信息流广告实例 */
type _AdInstance = InstanceType<_Ad>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/basic-components/icon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";

/** 图标属性 */
type _IconProps = Partial<{
Expand All @@ -17,7 +17,7 @@ type _IconProps = Partial<{
}>;

/** 图标 */
type _Icon = Component<_IconProps>;
type _Icon = DefineComponent<_IconProps>;

/** 图标实例 */
type _IconInstance = InstanceType<_Icon>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/basic-components/progress.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent } from "../events";

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ type _ProgressProps = Partial<{
}>;

/** 进度条 */
type _Progress = Component<_ProgressProps>;
type _Progress = DefineComponent<_ProgressProps>;

/** 进度条实例 */
type _ProgressInstance = InstanceType<_Progress>;
Expand Down
6 changes: 3 additions & 3 deletions packages/uni-app-types/src/basic-components/rich-text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyRecord, Component } from "../component";
import type { DefineComponent } from "vue";
import type { CustomEvent } from "../events";

/** 显示连续空格 */
Expand All @@ -14,7 +14,7 @@ interface _RichTextTextNode {
interface _RichTextNodeNode {
type?: "node";
name: string;
attrs?: AnyRecord;
attrs?: Record<string, any>;
children?: Array<_RichTextTextNode | _RichTextNodeNode>;
}

Expand Down Expand Up @@ -66,7 +66,7 @@ type _RichTextProps = Partial<{
}>;

/** 富文本 */
type _RichText = Component<_RichTextProps>;
type _RichText = DefineComponent<_RichTextProps>;

/** 富文本实例 */
type _RichTextInstance = InstanceType<_RichText>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/basic-components/text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";

/**
* 显示连续空格
Expand Down Expand Up @@ -50,7 +50,7 @@ type _TextProps = Partial<{
*
* 用于包裹文本内容
*/
type _Text = Component<_TextProps>;
type _Text = DefineComponent<_TextProps>;

/** 文本组件实例 */
type _TextInstance = InstanceType<_Text>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/canvas/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent, CustomEvent, TouchCanvasEvent } from "../events";

/** 类型 */
Expand Down Expand Up @@ -72,7 +72,7 @@ type _CanvasProps = Partial<{
}>;

/** 画布 */
type _Canvas = Component<_CanvasProps>;
type _Canvas = DefineComponent<_CanvasProps>;

/** 画布实例 */
type _CanvasInstance = InstanceType<_Canvas>;
Expand Down
39 changes: 0 additions & 39 deletions packages/uni-app-types/src/component.ts

This file was deleted.

39 changes: 20 additions & 19 deletions packages/uni-app-types/src/events/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// https://github.com/wechat-miniprogram/api-typings/blob/5dab2fb5f471f683ad297de32c0e33ede295dcff/types/wx/lib.wx.event.d.ts
import type { AnyRecord } from "../component";

/** 组件的一些属性值集合 */
interface _EventTarget<Dataset extends AnyRecord = AnyRecord> {
interface _EventTarget<
Dataset extends Record<string, any> = Record<string, any>,
> {
/** 事件源组件的id */
id?: string;
/** 当前组件的类型 */
Expand All @@ -18,9 +19,9 @@ interface _EventTarget<Dataset extends AnyRecord = AnyRecord> {

/** 基础事件 */
interface _BaseEvent<
Mark extends AnyRecord = AnyRecord,
CurrentTargetDataset extends AnyRecord = AnyRecord,
TargetDataset extends AnyRecord = CurrentTargetDataset,
Mark extends Record<string, any> = Record<string, any>,
CurrentTargetDataset extends Record<string, any> = Record<string, any>,
TargetDataset extends Record<string, any> = CurrentTargetDataset,
> {
/** 事件类型 */
type?: string;
Expand All @@ -37,10 +38,10 @@ interface _BaseEvent<

/** 自定义事件 */
interface _CustomEvent<
Detail extends AnyRecord = AnyRecord,
Mark extends AnyRecord = AnyRecord,
CurrentTargetDataset extends AnyRecord = AnyRecord,
TargetDataset extends AnyRecord = CurrentTargetDataset,
Detail extends Record<string, any> = Record<string, any>,
Mark extends Record<string, any> = Record<string, any>,
CurrentTargetDataset extends Record<string, any> = Record<string, any>,
TargetDataset extends Record<string, any> = CurrentTargetDataset,
> extends _BaseEvent<Mark, CurrentTargetDataset, TargetDataset> {
/** 额外信息 */
detail: Detail;
Expand Down Expand Up @@ -73,11 +74,11 @@ interface _TouchCanvasDetail {

/** 触摸事件 */
interface _BaseTouchEvent<
Detail extends AnyRecord = AnyRecord,
Detail extends Record<string, any> = Record<string, any>,
T extends _TouchDetail | _TouchCanvasDetail = _TouchDetail,
Mark extends AnyRecord = AnyRecord,
CurrentTargetDataset extends AnyRecord = AnyRecord,
TargetDataset extends AnyRecord = CurrentTargetDataset,
Mark extends Record<string, any> = Record<string, any>,
CurrentTargetDataset extends Record<string, any> = Record<string, any>,
TargetDataset extends Record<string, any> = CurrentTargetDataset,
> extends _CustomEvent<Detail, Mark, CurrentTargetDataset, TargetDataset> {
/** 当前停留在屏幕中的触摸点信息的数组 */
touches: T[];
Expand All @@ -87,10 +88,10 @@ interface _BaseTouchEvent<

/** 触摸事件响应 */
interface _TouchEvent<
Detail extends AnyRecord = AnyRecord,
Mark extends AnyRecord = AnyRecord,
CurrentTargetDataset extends AnyRecord = AnyRecord,
TargetDataset extends AnyRecord = CurrentTargetDataset,
Detail extends Record<string, any> = Record<string, any>,
Mark extends Record<string, any> = Record<string, any>,
CurrentTargetDataset extends Record<string, any> = Record<string, any>,
TargetDataset extends Record<string, any> = CurrentTargetDataset,
> extends _BaseTouchEvent<
Detail,
_TouchDetail,
Expand All @@ -101,8 +102,8 @@ interface _TouchEvent<

/** canvas 触摸事件响应 */
interface _TouchCanvasEvent<
Mark extends AnyRecord = AnyRecord,
TargetDataset extends AnyRecord = AnyRecord,
Mark extends Record<string, any> = Record<string, any>,
TargetDataset extends Record<string, any> = Record<string, any>,
> extends _BaseTouchEvent<
never,
_TouchCanvasDetail,
Expand Down
6 changes: 3 additions & 3 deletions packages/uni-app-types/src/form-components/button.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyRecord, Component } from "../component";
import type { DefineComponent } from "vue";
import type { BaseEvent, CustomEvent } from "../events";

/**
Expand Down Expand Up @@ -158,7 +158,7 @@ type _ButtonOnErrorEvent = BaseEvent;
type _ButtonOnError = (event: _ButtonOnErrorEvent) => void;

interface _ButtonOnOpensettingDetail {
authSetting: AnyRecord;
authSetting: Record<string, any>;
}

type _ButtonOnOpensettingEvent = CustomEvent<_ButtonOnOpensettingDetail>;
Expand Down Expand Up @@ -524,7 +524,7 @@ type _ButtonProps = Partial<{
}>;

/** 按钮 */
type _Button = Component<_ButtonProps>;
type _Button = DefineComponent<_ButtonProps>;

/** 按钮实例 */
type _ButtonInstance = InstanceType<_Button>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/form-components/checkbox-group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";
import type { CustomEvent } from "../events";
import type { CheckboxValue } from "./checkbox";

Expand All @@ -18,7 +18,7 @@ type _CheckboxGroupProps = Partial<{
}>;

/** 多项选择器,内部由多个 checkbox 组成 */
type _CheckboxGroup = Component<_CheckboxGroupProps>;
type _CheckboxGroup = DefineComponent<_CheckboxGroupProps>;

/** 多项选择器实例 */
type _CheckboxGroupInstance = InstanceType<_CheckboxGroup>;
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-types/src/form-components/checkbox.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Component } from "../component";
import type { DefineComponent } from "vue";

/**
* 标识
Expand Down Expand Up @@ -34,7 +34,7 @@ type _CheckboxProps = Partial<{
}>;

/** 多选项目 */
type _Checkbox = Component<_CheckboxProps>;
type _Checkbox = DefineComponent<_CheckboxProps>;

/** 多选项目实例 */
type _CheckboxInstance = InstanceType<_Checkbox>;
Expand Down
Loading

0 comments on commit 2b03b3e

Please sign in to comment.