@rsmax/types 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.0.1 (2025-05-11)
7
+
8
+ **Note:** Version bump only for package @rsmax/types
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 当轩
4
+ Copyright (c) 2019 - present Weizhu <yesmeck@gmail.com>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/lib/index.d.ts ADDED
@@ -0,0 +1,244 @@
1
+ import React from 'react';
2
+ import yargs from 'yargs';
3
+ import WebpackConfig from 'webpack-5-chain';
4
+ import * as t from '@babel/types';
5
+ export type LogLevel = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'silent';
6
+ export type Platform = 'web' | 'wechat' | 'ali' | 'toutiao' | 'xhs';
7
+ export type BuildType = 'miniapp' | 'miniplugin' | 'minicomponent' | 'webapp';
8
+ export type WebOptions = {
9
+ mpa: boolean;
10
+ excludeNodeModulesTransform: boolean;
11
+ };
12
+ export interface PluginOptions {
13
+ errorScreen: boolean;
14
+ spm: boolean;
15
+ }
16
+ export interface BuildOptions {
17
+ turboRenders?: boolean;
18
+ pxToRpx: boolean;
19
+ cwd: string;
20
+ progress: boolean;
21
+ input?: string[] | string | {
22
+ [key: string]: string;
23
+ };
24
+ output: string;
25
+ rootDir: string;
26
+ compressTemplate?: boolean;
27
+ UNSAFE_wechatTemplateDepth: number | {
28
+ [key: string]: number;
29
+ };
30
+ configWebpack?: (params: {
31
+ config: WebpackConfig;
32
+ webpack: any;
33
+ }) => void;
34
+ plugins: Plugin[];
35
+ port?: number;
36
+ notify?: boolean;
37
+ watch?: boolean;
38
+ target?: Platform;
39
+ analyze?: boolean;
40
+ devtools?: boolean;
41
+ type?: BuildType;
42
+ component?: any;
43
+ web?: WebOptions;
44
+ minimize?: boolean;
45
+ loglevel?: LogLevel;
46
+ }
47
+ export type Options = BuildOptions & PluginOptions;
48
+ export type Config = Partial<Options>;
49
+ export interface EntryInfo {
50
+ name: string;
51
+ filename: string;
52
+ component?: boolean;
53
+ }
54
+ export interface Entries {
55
+ app: EntryInfo;
56
+ pages: EntryInfo[];
57
+ }
58
+ export interface AppConfigPlugins {
59
+ [key: string]: {
60
+ version: string;
61
+ provider: string;
62
+ };
63
+ }
64
+ export interface AppConfig {
65
+ pages: string[];
66
+ subpackages?: Array<{
67
+ root: string;
68
+ pages: string[];
69
+ plugins?: AppConfigPlugins;
70
+ }>;
71
+ subPackages?: Array<{
72
+ root: string;
73
+ pages: string[];
74
+ plugins?: AppConfigPlugins;
75
+ }>;
76
+ tabBar?: {
77
+ items?: Array<{
78
+ icon: string;
79
+ activeIcon: string;
80
+ }>;
81
+ list?: Array<{
82
+ iconPath: string;
83
+ selectedIconPath: string;
84
+ }>;
85
+ };
86
+ plugins?: AppConfigPlugins;
87
+ }
88
+ export interface MiniPluginConfig {
89
+ pages: string[];
90
+ publicComponents: {
91
+ [key: string]: string;
92
+ };
93
+ publicPages: {
94
+ [key: string]: string;
95
+ };
96
+ main: string;
97
+ }
98
+ export type Meta = {
99
+ global: string;
100
+ template: {
101
+ extension: string;
102
+ tag: string;
103
+ src: string;
104
+ };
105
+ style: string;
106
+ jsHelper?: {
107
+ extension: string;
108
+ tag: string;
109
+ src: string;
110
+ };
111
+ ejs: {
112
+ base?: string;
113
+ page: string;
114
+ jsHelper?: string;
115
+ };
116
+ staticEjs?: {
117
+ base?: string;
118
+ page: string;
119
+ jsHelper?: string;
120
+ isolatedTemplates?: string;
121
+ };
122
+ };
123
+ export type MetaOptions = {
124
+ remaxOptions: Options;
125
+ };
126
+ export type ProcessPropsOptions = {
127
+ componentName: string;
128
+ props: string[];
129
+ node?: t.JSXElement;
130
+ additional?: boolean;
131
+ };
132
+ export type ShouldHostComponentRegister = {
133
+ componentName: string;
134
+ additional?: boolean;
135
+ phase: 'import' | 'jsx' | 'extra';
136
+ };
137
+ export interface HostComponent {
138
+ props: string[];
139
+ additional?: boolean;
140
+ alias?: {
141
+ [key: string]: string;
142
+ };
143
+ }
144
+ export interface ComponentManifest {
145
+ id: string;
146
+ props: string[];
147
+ additional?: boolean;
148
+ type?: string;
149
+ }
150
+ export interface Plugin {
151
+ /** 插件名称 */
152
+ meta?: Meta;
153
+ hostComponents?: Map<string, HostComponent>;
154
+ /**
155
+ * 自定义组件属性
156
+ * options.componentName 组件名称
157
+ * options.props 组件属性
158
+ * options.node 组件 babel JSXElement
159
+ * options.additional 是否用户额外创建的 host 组件
160
+ */
161
+ processProps?: (options: ProcessPropsOptions) => string[];
162
+ /**
163
+ * 是否注册组件
164
+ * options.componentName 组件名称
165
+ * options.additional 是否是额外定义的组件
166
+ * options.phase 组件被引入的阶段,import | jsx | extra
167
+ */
168
+ shouldHostComponentRegister?: (options: ShouldHostComponentRegister) => boolean;
169
+ onBuildStart?: (params: {
170
+ config: Options;
171
+ }) => void;
172
+ /**
173
+ * 修改 webpack 配置
174
+ */
175
+ configWebpack?: (params: {
176
+ config: WebpackConfig;
177
+ }) => void;
178
+ /**
179
+ * 修改 babel 配置
180
+ */
181
+ configBabel?: (params: {
182
+ config: any;
183
+ }) => void;
184
+ /**
185
+ * 注册运行时插件
186
+ */
187
+ registerRuntimePlugin?: () => string;
188
+ /**
189
+ * 修改应用配置
190
+ */
191
+ onAppConfig?: (params: {
192
+ config: any;
193
+ }) => any;
194
+ /**
195
+ * 修改页面配置
196
+ */
197
+ onPageConfig?: (params: {
198
+ config: any;
199
+ page: string;
200
+ }) => any;
201
+ /**
202
+ * 修改页面输出的 template
203
+ */
204
+ onPageTemplate?: (params: {
205
+ template: string;
206
+ page: string;
207
+ }) => string;
208
+ unstable_onEntries?: (params: {
209
+ entries: any;
210
+ }) => any;
211
+ /**
212
+ * 扩展命令行
213
+ */
214
+ extendCLI?: (params: {
215
+ cli: yargs.Argv;
216
+ }) => any;
217
+ }
218
+ export type PluginConstructor = (options?: any) => Plugin;
219
+ export interface RuntimePlugin {
220
+ onAppConfig?: ({ config }: {
221
+ config: any;
222
+ }) => any;
223
+ onPageConfig?: ({ config, page }: {
224
+ config: any;
225
+ page: string;
226
+ }) => any;
227
+ onAppComponent?: ({ component }: {
228
+ component: React.ComponentType<any>;
229
+ }) => React.ComponentType<any>;
230
+ onPageComponent?: ({ component, page, }: {
231
+ component: React.ComponentType<any>;
232
+ page: string;
233
+ }) => React.ComponentType<any>;
234
+ onMiniComponent?: ({ component, context, }: {
235
+ component: React.ComponentType<any>;
236
+ context: any;
237
+ }) => React.ComponentType<any>;
238
+ onCreateHostComponent?: ({ component, }: {
239
+ component: React.ForwardRefExoticComponent<any> | React.ComponentType<any>;
240
+ }) => React.ForwardRefExoticComponent<any> | React.ComponentType<any>;
241
+ onCreateHostComponentElement?: ({ element }: {
242
+ element: React.ReactElement<any>;
243
+ }) => React.ReactElement<any>;
244
+ }
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@rsmax/types",
3
+ "version": "1.0.1",
4
+ "description": "Rsmax Types",
5
+ "author": "Caihuanyu <eterlf41@gmail.com>",
6
+ "license": "MIT",
7
+ "main": "lib/index.js",
8
+ "module": "lib/index.js",
9
+ "types": "lib/index.d.ts",
10
+ "scripts": {
11
+ "clean": "rimraf lib tsconfig.tsbuildinfo",
12
+ "prebuild": "npm run clean",
13
+ "build": "tsc"
14
+ },
15
+ "dependencies": {
16
+ "@babel/types": "^7.8.0",
17
+ "@types/react": "^18.3.0",
18
+ "@types/yargs": "^15.0.0",
19
+ "webpack-5-chain": "^8.0.1"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "gitHead": "d2ff644810449152d124a9da76218bcd9fdfff46"
25
+ }