@formvk/core 0.1.0 → 1.0.0
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 +14 -0
- package/README.md +63 -0
- package/package.json +8 -4
- package/src/__tests__/array.spec.ts +0 -168
- package/src/__tests__/effects.spec.ts +0 -595
- package/src/__tests__/externals.spec.ts +0 -101
- package/src/__tests__/field.spec.ts +0 -572
- package/src/__tests__/form.spec.ts +0 -720
- package/src/__tests__/graph.spec.ts +0 -56
- package/src/__tests__/heart.spec.ts +0 -60
- package/src/__tests__/internals.spec.ts +0 -138
- package/src/__tests__/lifecycle.spec.ts +0 -51
- package/src/__tests__/object.spec.ts +0 -107
- package/src/__tests__/query.spec.ts +0 -100
- package/src/__tests__/shared.ts +0 -10
- package/src/__tests__/typed.spec.ts +0 -52
- package/src/__tests__/void.spec.ts +0 -163
- package/src/effects/index.ts +0 -2
- package/src/effects/onFieldEffects.ts +0 -97
- package/src/effects/onFormEffects.ts +0 -48
- package/src/global.d.ts +0 -8
- package/src/index.ts +0 -4
- package/src/models/ArrayField.ts +0 -133
- package/src/models/BaseField.ts +0 -359
- package/src/models/Field.ts +0 -450
- package/src/models/Form.ts +0 -586
- package/src/models/Graph.ts +0 -56
- package/src/models/Heart.ts +0 -75
- package/src/models/LifeCycle.ts +0 -42
- package/src/models/ObjectField.ts +0 -48
- package/src/models/Query.ts +0 -97
- package/src/models/VoidField.ts +0 -64
- package/src/models/index.ts +0 -9
- package/src/models/types.ts +0 -9
- package/src/shared/checkers.ts +0 -85
- package/src/shared/constants.ts +0 -60
- package/src/shared/effective.ts +0 -69
- package/src/shared/externals.ts +0 -65
- package/src/shared/internals.ts +0 -965
- package/src/types.ts +0 -401
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -4
- package/vite.config.ts +0 -46
package/src/types.ts
DELETED
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
import type { FormPath, FormPathPattern } from '@formvk/shared'
|
|
2
|
-
import type { IValidatorRules, Validator, ValidatorTriggerType } from '@formvk/validator'
|
|
3
|
-
|
|
4
|
-
import type { ArrayField, Field, Form, LifeCycle, ObjectField, Query, VoidField } from './models'
|
|
5
|
-
|
|
6
|
-
export type { FormPathPattern }
|
|
7
|
-
|
|
8
|
-
export type NonFunctionPropertyNames<T> = {
|
|
9
|
-
[K in keyof T]: T[K] extends (...args: any) => any ? never : K
|
|
10
|
-
}[keyof T]
|
|
11
|
-
|
|
12
|
-
export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>
|
|
13
|
-
|
|
14
|
-
export type AnyFunction = (...args: any[]) => any
|
|
15
|
-
|
|
16
|
-
export type JSXComponent = any
|
|
17
|
-
|
|
18
|
-
export type LifeCycleHandler<T> = (payload: T, context: any) => void
|
|
19
|
-
|
|
20
|
-
export type LifeCyclePayload<T> = (
|
|
21
|
-
params: {
|
|
22
|
-
type: string
|
|
23
|
-
payload: T
|
|
24
|
-
},
|
|
25
|
-
context: any
|
|
26
|
-
) => void
|
|
27
|
-
|
|
28
|
-
export enum LifeCycleTypes {
|
|
29
|
-
/**
|
|
30
|
-
* Form LifeCycle
|
|
31
|
-
**/
|
|
32
|
-
|
|
33
|
-
ON_FORM_INIT = 'onFormInit',
|
|
34
|
-
ON_FORM_MOUNT = 'onFormMount',
|
|
35
|
-
ON_FORM_UNMOUNT = 'onFormUnmount',
|
|
36
|
-
|
|
37
|
-
ON_FORM_INPUT_CHANGE = 'onFormInputChange',
|
|
38
|
-
ON_FORM_VALUES_CHANGE = 'onFormValuesChange',
|
|
39
|
-
ON_FORM_INITIAL_VALUES_CHANGE = 'onFormInitialValuesChange',
|
|
40
|
-
|
|
41
|
-
ON_FORM_SUBMIT = 'onFormSubmit',
|
|
42
|
-
ON_FORM_RESET = 'onFormReset',
|
|
43
|
-
ON_FORM_SUBMIT_START = 'onFormSubmitStart',
|
|
44
|
-
ON_FORM_SUBMITTING = 'onFormSubmitting',
|
|
45
|
-
ON_FORM_SUBMIT_END = 'onFormSubmitEnd',
|
|
46
|
-
ON_FORM_SUBMIT_VALIDATE_START = 'onFormSubmitValidateStart',
|
|
47
|
-
ON_FORM_SUBMIT_VALIDATE_SUCCESS = 'onFormSubmitValidateSuccess',
|
|
48
|
-
ON_FORM_SUBMIT_VALIDATE_FAILED = 'onFormSubmitValidateFailed',
|
|
49
|
-
ON_FORM_SUBMIT_VALIDATE_END = 'onFormSubmitValidateEnd',
|
|
50
|
-
ON_FORM_SUBMIT_SUCCESS = 'onFormSubmitSuccess',
|
|
51
|
-
ON_FORM_SUBMIT_FAILED = 'onFormSubmitFailed',
|
|
52
|
-
ON_FORM_VALIDATE_START = 'onFormValidateStart',
|
|
53
|
-
ON_FORM_VALIDATING = 'onFormValidating',
|
|
54
|
-
ON_FORM_VALIDATE_SUCCESS = 'onFormValidateSuccess',
|
|
55
|
-
ON_FORM_VALIDATE_FAILED = 'onFormValidateFailed',
|
|
56
|
-
ON_FORM_VALIDATE_END = 'onFormValidateEnd',
|
|
57
|
-
|
|
58
|
-
ON_FORM_GRAPH_CHANGE = 'onFormGraphChange',
|
|
59
|
-
ON_FORM_LOADING = 'onFormLoading',
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Field LifeCycle
|
|
63
|
-
**/
|
|
64
|
-
|
|
65
|
-
ON_FIELD_INIT = 'onFieldInit',
|
|
66
|
-
ON_FIELD_INPUT_VALUE_CHANGE = 'onFieldInputValueChange',
|
|
67
|
-
ON_FIELD_VALUE_CHANGE = 'onFieldValueChange',
|
|
68
|
-
ON_FIELD_INITIAL_VALUE_CHANGE = 'onFieldInitialValueChange',
|
|
69
|
-
|
|
70
|
-
ON_FIELD_SUBMIT = 'onFieldSubmit',
|
|
71
|
-
ON_FIELD_SUBMIT_START = 'onFieldSubmitStart',
|
|
72
|
-
ON_FIELD_SUBMITTING = 'onFieldSubmitting',
|
|
73
|
-
ON_FIELD_SUBMIT_END = 'onFieldSubmitEnd',
|
|
74
|
-
ON_FIELD_SUBMIT_VALIDATE_START = 'onFieldSubmitValidateStart',
|
|
75
|
-
ON_FIELD_SUBMIT_VALIDATE_SUCCESS = 'onFieldSubmitValidateSuccess',
|
|
76
|
-
ON_FIELD_SUBMIT_VALIDATE_FAILED = 'onFieldSubmitValidateFailed',
|
|
77
|
-
ON_FIELD_SUBMIT_VALIDATE_END = 'onFieldSubmitValidateEnd',
|
|
78
|
-
ON_FIELD_SUBMIT_SUCCESS = 'onFieldSubmitSuccess',
|
|
79
|
-
ON_FIELD_SUBMIT_FAILED = 'onFieldSubmitFailed',
|
|
80
|
-
ON_FIELD_VALIDATE_START = 'onFieldValidateStart',
|
|
81
|
-
ON_FIELD_VALIDATING = 'onFieldValidating',
|
|
82
|
-
ON_FIELD_VALIDATE_SUCCESS = 'onFieldValidateSuccess',
|
|
83
|
-
ON_FIELD_VALIDATE_FAILED = 'onFieldValidateFailed',
|
|
84
|
-
ON_FIELD_VALIDATE_END = 'onFieldValidateEnd',
|
|
85
|
-
|
|
86
|
-
ON_FIELD_LOADING = 'onFieldLoading',
|
|
87
|
-
ON_FIELD_RESET = 'onFieldReset',
|
|
88
|
-
ON_FIELD_MOUNT = 'onFieldMount',
|
|
89
|
-
ON_FIELD_UNMOUNT = 'onFieldUnmount',
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export type HeartSubscriber = ({ type, payload }: { type: string; payload: any }) => void
|
|
93
|
-
|
|
94
|
-
export interface INodePatch<T> {
|
|
95
|
-
type: 'remove' | 'update'
|
|
96
|
-
address: string
|
|
97
|
-
oldAddress?: string
|
|
98
|
-
payload?: T
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface IHeartProps<Context> {
|
|
102
|
-
lifecycles?: LifeCycle[]
|
|
103
|
-
context?: Context
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface IFieldFeedback {
|
|
107
|
-
triggerType?: FieldFeedbackTriggerTypes
|
|
108
|
-
type?: FieldFeedbackTypes
|
|
109
|
-
code?: FieldFeedbackCodeTypes
|
|
110
|
-
messages?: FeedbackMessage
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export type IFormFeedback = IFieldFeedback & {
|
|
114
|
-
path?: string
|
|
115
|
-
address?: string
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface ISearchFeedback {
|
|
119
|
-
triggerType?: FieldFeedbackTriggerTypes
|
|
120
|
-
type?: FieldFeedbackTypes
|
|
121
|
-
code?: FieldFeedbackCodeTypes
|
|
122
|
-
address?: FormPathPattern
|
|
123
|
-
path?: FormPathPattern
|
|
124
|
-
messages?: FeedbackMessage
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export type FeedbackMessage = any[]
|
|
128
|
-
|
|
129
|
-
export type IFieldUpdate = {
|
|
130
|
-
pattern: FormPath
|
|
131
|
-
callbacks: ((...args: any[]) => any)[]
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface IFormRequests {
|
|
135
|
-
validate?: number
|
|
136
|
-
submit?: number
|
|
137
|
-
loading?: number
|
|
138
|
-
updates?: IFieldUpdate[]
|
|
139
|
-
updateIndexes?: Record<string, number>
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export type IFormFields = Record<string, GeneralField>
|
|
143
|
-
|
|
144
|
-
export type FieldFeedbackTypes = 'error' | 'success' | 'warning'
|
|
145
|
-
|
|
146
|
-
export type FieldFeedbackTriggerTypes = ValidatorTriggerType
|
|
147
|
-
|
|
148
|
-
export type FieldFeedbackCodeTypes =
|
|
149
|
-
| 'ValidateError'
|
|
150
|
-
| 'ValidateSuccess'
|
|
151
|
-
| 'ValidateWarning'
|
|
152
|
-
| 'EffectError'
|
|
153
|
-
| 'EffectSuccess'
|
|
154
|
-
| 'EffectWarning'
|
|
155
|
-
| (string & {})
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Form Pattern
|
|
159
|
-
* @see https://formvk.com/docs/guide/pattern.html
|
|
160
|
-
*/
|
|
161
|
-
export type FormPatternTypes = 'editable' | 'readOnly' | 'disabled' | 'readPretty'
|
|
162
|
-
|
|
163
|
-
export type FormDisplayTypes = 'none' | 'hidden' | 'visible'
|
|
164
|
-
|
|
165
|
-
type OmitState<P> = Omit<
|
|
166
|
-
P,
|
|
167
|
-
| 'selfDisplay'
|
|
168
|
-
| 'selfPattern'
|
|
169
|
-
| 'originValues'
|
|
170
|
-
| 'originInitialValues'
|
|
171
|
-
| 'id'
|
|
172
|
-
| 'address'
|
|
173
|
-
| 'path'
|
|
174
|
-
| 'lifecycles'
|
|
175
|
-
| 'disposers'
|
|
176
|
-
| 'requests'
|
|
177
|
-
| 'fields'
|
|
178
|
-
| 'graph'
|
|
179
|
-
| 'heart'
|
|
180
|
-
| 'indexes'
|
|
181
|
-
| 'props'
|
|
182
|
-
| 'displayName'
|
|
183
|
-
| 'setState'
|
|
184
|
-
| 'getState'
|
|
185
|
-
| 'getFormGraph'
|
|
186
|
-
| 'setFormGraph'
|
|
187
|
-
| 'setFormState'
|
|
188
|
-
| 'getFormState'
|
|
189
|
-
| 'records'
|
|
190
|
-
| 'record'
|
|
191
|
-
>
|
|
192
|
-
|
|
193
|
-
export type IFieldState = Partial<Pick<Field, Exclude<NonFunctionPropertyNames<OmitState<Field>>, undefined>>>
|
|
194
|
-
|
|
195
|
-
export type IVoidFieldState = Partial<
|
|
196
|
-
Pick<VoidField, Exclude<NonFunctionPropertyNames<OmitState<VoidField>>, undefined>>
|
|
197
|
-
>
|
|
198
|
-
|
|
199
|
-
export type IFormState<T extends Record<any, any> = any> = Pick<
|
|
200
|
-
Form<T>,
|
|
201
|
-
NonFunctionPropertyNames<OmitState<Form<{ [key: string]: any }>>>
|
|
202
|
-
>
|
|
203
|
-
|
|
204
|
-
export type IFormGraph = Record<string, IGeneralFieldState | IFormState>
|
|
205
|
-
|
|
206
|
-
export interface IFormProps<T extends object = any> {
|
|
207
|
-
values?: Partial<T>
|
|
208
|
-
initialValues?: Partial<T>
|
|
209
|
-
pattern?: FormPatternTypes
|
|
210
|
-
display?: FormDisplayTypes
|
|
211
|
-
hidden?: boolean
|
|
212
|
-
visible?: boolean
|
|
213
|
-
editable?: boolean
|
|
214
|
-
disabled?: boolean
|
|
215
|
-
readOnly?: boolean
|
|
216
|
-
readPretty?: boolean
|
|
217
|
-
effects?: (form: Form<T>) => void
|
|
218
|
-
validateFirst?: boolean
|
|
219
|
-
validatePattern?: FormPatternTypes[]
|
|
220
|
-
validateDisplay?: FormDisplayTypes[]
|
|
221
|
-
designable?: boolean
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export type IFormMergeStrategy = 'overwrite' | 'merge' | 'deepMerge' | 'shallowMerge'
|
|
225
|
-
|
|
226
|
-
export interface IFieldFactoryProps<
|
|
227
|
-
Decorator extends JSXComponent,
|
|
228
|
-
Component extends JSXComponent,
|
|
229
|
-
TextType = any,
|
|
230
|
-
ValueType = any,
|
|
231
|
-
> extends IFieldProps<Decorator, Component, TextType, ValueType> {
|
|
232
|
-
name: FormPathPattern
|
|
233
|
-
basePath?: FormPathPattern
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export interface IVoidFieldFactoryProps<
|
|
237
|
-
Decorator extends JSXComponent,
|
|
238
|
-
Component extends JSXComponent,
|
|
239
|
-
TextType = any,
|
|
240
|
-
> extends IVoidFieldProps<Decorator, Component, TextType> {
|
|
241
|
-
name: FormPathPattern
|
|
242
|
-
basePath?: FormPathPattern
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export interface IFieldRequests {
|
|
246
|
-
validate?: number
|
|
247
|
-
submit?: number
|
|
248
|
-
loading?: number
|
|
249
|
-
batch?: () => void
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export interface IFieldCaches {
|
|
253
|
-
value?: any
|
|
254
|
-
initialValue?: any
|
|
255
|
-
inputting?: boolean
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export type FieldDisplayTypes = 'none' | 'hidden' | 'visible' | ({} & string)
|
|
259
|
-
|
|
260
|
-
export type FieldPatternTypes = 'editable' | 'readOnly' | 'disabled' | 'readPretty' | ({} & string)
|
|
261
|
-
|
|
262
|
-
export type FieldValidatorContext = IValidatorRules & {
|
|
263
|
-
field: Field
|
|
264
|
-
form: Form
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export type FieldValidator = Validator<FieldValidatorContext>
|
|
268
|
-
|
|
269
|
-
export type FieldDataSource = {
|
|
270
|
-
label?: any
|
|
271
|
-
value?: any
|
|
272
|
-
title?: any
|
|
273
|
-
key?: any
|
|
274
|
-
text?: any
|
|
275
|
-
children?: FieldDataSource
|
|
276
|
-
[key: string]: any
|
|
277
|
-
}[]
|
|
278
|
-
|
|
279
|
-
export type FieldComponent<Component extends JSXComponent, ComponentProps = any> =
|
|
280
|
-
| [Component]
|
|
281
|
-
| [Component, ComponentProps]
|
|
282
|
-
| boolean
|
|
283
|
-
| any[]
|
|
284
|
-
|
|
285
|
-
export type FieldDecorator<Decorator extends JSXComponent, ComponentProps = any> =
|
|
286
|
-
| [Decorator]
|
|
287
|
-
| [Decorator, ComponentProps]
|
|
288
|
-
| boolean
|
|
289
|
-
| any[]
|
|
290
|
-
|
|
291
|
-
export type FieldReaction = (field: Field) => void
|
|
292
|
-
export interface IFieldProps<
|
|
293
|
-
Decorator extends JSXComponent = any,
|
|
294
|
-
Component extends JSXComponent = any,
|
|
295
|
-
TextType = any,
|
|
296
|
-
ValueType = any,
|
|
297
|
-
> {
|
|
298
|
-
name: FormPathPattern
|
|
299
|
-
basePath?: FormPathPattern
|
|
300
|
-
title?: TextType
|
|
301
|
-
description?: TextType
|
|
302
|
-
value?: ValueType
|
|
303
|
-
initialValue?: ValueType
|
|
304
|
-
required?: boolean
|
|
305
|
-
display?: FieldDisplayTypes
|
|
306
|
-
pattern?: FieldPatternTypes
|
|
307
|
-
hidden?: boolean
|
|
308
|
-
visible?: boolean
|
|
309
|
-
editable?: boolean
|
|
310
|
-
disabled?: boolean
|
|
311
|
-
readOnly?: boolean
|
|
312
|
-
readPretty?: boolean
|
|
313
|
-
dataSource?: FieldDataSource
|
|
314
|
-
validateFirst?: boolean
|
|
315
|
-
validatePattern?: FieldPatternTypes[]
|
|
316
|
-
validateDisplay?: FieldDisplayTypes[]
|
|
317
|
-
validator?: FieldValidator
|
|
318
|
-
decorator?: FieldDecorator<Decorator>
|
|
319
|
-
component?: FieldComponent<Component>
|
|
320
|
-
reactions?: FieldReaction[] | FieldReaction
|
|
321
|
-
content?: any
|
|
322
|
-
data?: any
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
export interface IVoidFieldProps<
|
|
326
|
-
Decorator extends JSXComponent = any,
|
|
327
|
-
Component extends JSXComponent = any,
|
|
328
|
-
TextType = any,
|
|
329
|
-
> {
|
|
330
|
-
name: FormPathPattern
|
|
331
|
-
basePath?: FormPathPattern
|
|
332
|
-
title?: TextType
|
|
333
|
-
description?: TextType
|
|
334
|
-
display?: FieldDisplayTypes
|
|
335
|
-
pattern?: FieldPatternTypes
|
|
336
|
-
hidden?: boolean
|
|
337
|
-
visible?: boolean
|
|
338
|
-
editable?: boolean
|
|
339
|
-
disabled?: boolean
|
|
340
|
-
readOnly?: boolean
|
|
341
|
-
readPretty?: boolean
|
|
342
|
-
decorator?: FieldDecorator<Decorator>
|
|
343
|
-
component?: FieldComponent<Component>
|
|
344
|
-
reactions?: FieldReaction[] | FieldReaction
|
|
345
|
-
content?: any
|
|
346
|
-
data?: any
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
export interface IFieldResetOptions {
|
|
350
|
-
forceClear?: boolean
|
|
351
|
-
validate?: boolean
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
export type IGeneralFieldState = IFieldState & IVoidFieldState
|
|
355
|
-
|
|
356
|
-
export type GeneralField = Field | VoidField | ArrayField | ObjectField
|
|
357
|
-
|
|
358
|
-
export type DataField = Field | ArrayField | ObjectField
|
|
359
|
-
export interface ISpliceArrayStateProps {
|
|
360
|
-
startIndex?: number
|
|
361
|
-
deleteCount?: number
|
|
362
|
-
insertCount?: number
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export interface IExchangeArrayStateProps {
|
|
366
|
-
fromIndex?: number
|
|
367
|
-
toIndex?: number
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
export interface IQueryProps {
|
|
371
|
-
pattern: FormPathPattern
|
|
372
|
-
base: FormPathPattern
|
|
373
|
-
form: Form
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export interface IModelSetter<P = any> {
|
|
377
|
-
(setter: (state: P) => void): void
|
|
378
|
-
(setter: Partial<P>): void
|
|
379
|
-
(): void
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
export interface IModelGetter<P = any> {
|
|
383
|
-
<Getter extends (state: P) => any>(getter: Getter): ReturnType<Getter>
|
|
384
|
-
(): P
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export type FieldMatchPattern = FormPathPattern | Query | GeneralField
|
|
388
|
-
|
|
389
|
-
export interface IFieldStateSetter {
|
|
390
|
-
(pattern: FieldMatchPattern, setter: (state: IFieldState) => void): void
|
|
391
|
-
(pattern: FieldMatchPattern, setter: Partial<IFieldState>): void
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
export interface IFieldStateGetter {
|
|
395
|
-
<Getter extends (state: IGeneralFieldState) => any>(pattern: FieldMatchPattern, getter: Getter): ReturnType<Getter>
|
|
396
|
-
(pattern: FieldMatchPattern): IGeneralFieldState
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
export interface IFieldActions {
|
|
400
|
-
[key: string]: (...args: any[]) => any
|
|
401
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import swc from '@rollup/plugin-swc'
|
|
2
|
-
import { defineConfig, withFilter } from 'vite'
|
|
3
|
-
import dts from 'vite-plugin-dts'
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
plugins: [
|
|
6
|
-
// rolldown/oxc 不会降级 accessor 与标准装饰器,这里用 swc 提前转换
|
|
7
|
-
withFilter(
|
|
8
|
-
swc({
|
|
9
|
-
swc: {
|
|
10
|
-
jsc: {
|
|
11
|
-
parser: { syntax: 'typescript', decorators: true },
|
|
12
|
-
transform: {
|
|
13
|
-
legacyDecorator: false,
|
|
14
|
-
decoratorVersion: '2023-11',
|
|
15
|
-
},
|
|
16
|
-
externalHelpers: true,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
}),
|
|
20
|
-
{
|
|
21
|
-
transform: { code: /^\s*@[\w$.]+/m },
|
|
22
|
-
}
|
|
23
|
-
),
|
|
24
|
-
// 依赖走 node_modules 解析,类型合并为单文件 index.d.ts
|
|
25
|
-
dts({
|
|
26
|
-
tsconfigPath: './tsconfig.build.json',
|
|
27
|
-
entryRoot: 'src',
|
|
28
|
-
bundleTypes: true,
|
|
29
|
-
}),
|
|
30
|
-
],
|
|
31
|
-
build: {
|
|
32
|
-
lib: {
|
|
33
|
-
entry: 'src/index.ts',
|
|
34
|
-
name: 'Formvk.Core',
|
|
35
|
-
fileName: 'index',
|
|
36
|
-
formats: ['es'],
|
|
37
|
-
},
|
|
38
|
-
rolldownOptions: {
|
|
39
|
-
// swc 注入的是 @swc/helpers/_/_xxx 这类子路径,需要正则才能覆盖
|
|
40
|
-
external: ['@formvk/reactive', '@formvk/shared', '@formvk/validator', /^@swc\/helpers(\/|$)/],
|
|
41
|
-
},
|
|
42
|
-
sourcemap: true,
|
|
43
|
-
minify: false,
|
|
44
|
-
target: 'es2022',
|
|
45
|
-
},
|
|
46
|
-
})
|