@formspec/build 0.1.0-alpha.8 → 0.1.0-alpha.9
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/README.md +14 -14
- package/dist/__tests__/analyzer-edge-cases.test.d.ts +13 -0
- package/dist/__tests__/analyzer-edge-cases.test.d.ts.map +1 -0
- package/dist/__tests__/analyzer-edge-cases.test.js +376 -0
- package/dist/__tests__/analyzer-edge-cases.test.js.map +1 -0
- package/dist/__tests__/analyzer.test.d.ts +5 -0
- package/dist/__tests__/analyzer.test.d.ts.map +1 -0
- package/dist/__tests__/analyzer.test.js +190 -0
- package/dist/__tests__/analyzer.test.js.map +1 -0
- package/dist/__tests__/cli.test.js.map +1 -1
- package/dist/__tests__/codegen.test.d.ts +5 -0
- package/dist/__tests__/codegen.test.d.ts.map +1 -0
- package/dist/__tests__/codegen.test.js +506 -0
- package/dist/__tests__/codegen.test.js.map +1 -0
- package/dist/__tests__/decorator-pipeline.test.d.ts +11 -0
- package/dist/__tests__/decorator-pipeline.test.d.ts.map +1 -0
- package/dist/__tests__/decorator-pipeline.test.js +460 -0
- package/dist/__tests__/decorator-pipeline.test.js.map +1 -0
- package/dist/__tests__/edge-cases.test.js +1 -3
- package/dist/__tests__/edge-cases.test.js.map +1 -1
- package/dist/__tests__/fixtures/edge-cases.d.ts +110 -0
- package/dist/__tests__/fixtures/edge-cases.d.ts.map +1 -0
- package/dist/__tests__/fixtures/edge-cases.js +137 -0
- package/dist/__tests__/fixtures/edge-cases.js.map +1 -0
- package/dist/__tests__/fixtures/example-a-builtins.d.ts +12 -0
- package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-a-builtins.js +100 -0
- package/dist/__tests__/fixtures/example-a-builtins.js.map +1 -0
- package/dist/__tests__/fixtures/example-b-decorators.d.ts +5 -0
- package/dist/__tests__/fixtures/example-b-decorators.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-b-decorators.js +5 -0
- package/dist/__tests__/fixtures/example-b-decorators.js.map +1 -0
- package/dist/__tests__/fixtures/example-b-extended.d.ts +5 -0
- package/dist/__tests__/fixtures/example-b-extended.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-b-extended.js +60 -0
- package/dist/__tests__/fixtures/example-b-extended.js.map +1 -0
- package/dist/__tests__/fixtures/example-c-custom.d.ts +5 -0
- package/dist/__tests__/fixtures/example-c-custom.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-c-custom.js +61 -0
- package/dist/__tests__/fixtures/example-c-custom.js.map +1 -0
- package/dist/__tests__/fixtures/example-c-decorators.d.ts +5 -0
- package/dist/__tests__/fixtures/example-c-decorators.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-c-decorators.js +4 -0
- package/dist/__tests__/fixtures/example-c-decorators.js.map +1 -0
- package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts +6 -0
- package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-d-mixed-decorators.js +75 -0
- package/dist/__tests__/fixtures/example-d-mixed-decorators.js.map +1 -0
- package/dist/__tests__/fixtures/example-e-decorators.d.ts +11 -0
- package/dist/__tests__/fixtures/example-e-decorators.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-e-decorators.js +10 -0
- package/dist/__tests__/fixtures/example-e-decorators.js.map +1 -0
- package/dist/__tests__/fixtures/example-e-no-namespace.d.ts +5 -0
- package/dist/__tests__/fixtures/example-e-no-namespace.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-e-no-namespace.js +61 -0
- package/dist/__tests__/fixtures/example-e-no-namespace.js.map +1 -0
- package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts +16 -0
- package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-jsdoc-constraints.js +98 -0
- package/dist/__tests__/fixtures/example-jsdoc-constraints.js.map +1 -0
- package/dist/__tests__/fixtures/example-nested-class.d.ts +45 -0
- package/dist/__tests__/fixtures/example-nested-class.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-nested-class.js +248 -0
- package/dist/__tests__/fixtures/example-nested-class.js.map +1 -0
- package/dist/__tests__/fixtures/sample-forms.d.ts +55 -0
- package/dist/__tests__/fixtures/sample-forms.d.ts.map +1 -0
- package/dist/__tests__/fixtures/sample-forms.js +78 -0
- package/dist/__tests__/fixtures/sample-forms.js.map +1 -0
- package/dist/__tests__/generator.test.js +6 -6
- package/dist/__tests__/generator.test.js.map +1 -1
- package/dist/__tests__/integration.test.js +1 -3
- package/dist/__tests__/integration.test.js.map +1 -1
- package/dist/__tests__/jsdoc-constraints.test.d.ts +10 -0
- package/dist/__tests__/jsdoc-constraints.test.d.ts.map +1 -0
- package/dist/__tests__/jsdoc-constraints.test.js +199 -0
- package/dist/__tests__/jsdoc-constraints.test.js.map +1 -0
- package/dist/__tests__/write-schemas.test.js.map +1 -1
- package/dist/analyzer/class-analyzer.d.ts +85 -0
- package/dist/analyzer/class-analyzer.d.ts.map +1 -0
- package/dist/analyzer/class-analyzer.js +215 -0
- package/dist/analyzer/class-analyzer.js.map +1 -0
- package/dist/analyzer/decorator-extractor.d.ts +78 -0
- package/dist/analyzer/decorator-extractor.d.ts.map +1 -0
- package/dist/analyzer/decorator-extractor.js +336 -0
- package/dist/analyzer/decorator-extractor.js.map +1 -0
- package/dist/analyzer/jsdoc-constraints.d.ts +27 -0
- package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -0
- package/dist/analyzer/jsdoc-constraints.js +91 -0
- package/dist/analyzer/jsdoc-constraints.js.map +1 -0
- package/dist/analyzer/program.d.ts +37 -0
- package/dist/analyzer/program.d.ts.map +1 -0
- package/dist/analyzer/program.js +87 -0
- package/dist/analyzer/program.js.map +1 -0
- package/dist/analyzer/type-converter.d.ts +75 -0
- package/dist/analyzer/type-converter.d.ts.map +1 -0
- package/dist/analyzer/type-converter.js +436 -0
- package/dist/analyzer/type-converter.js.map +1 -0
- package/dist/browser.d.ts +3 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -0
- package/dist/browser.js.map +1 -1
- package/dist/build.d.ts +196 -2
- package/dist/cli.js +1 -3
- package/dist/cli.js.map +1 -1
- package/dist/codegen/index.d.ts +75 -0
- package/dist/codegen/index.d.ts.map +1 -0
- package/dist/codegen/index.js +597 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/generators/class-schema.d.ts +84 -0
- package/dist/generators/class-schema.d.ts.map +1 -0
- package/dist/generators/class-schema.js +91 -0
- package/dist/generators/class-schema.js.map +1 -0
- package/dist/generators/method-schema.d.ts +67 -0
- package/dist/generators/method-schema.d.ts.map +1 -0
- package/dist/generators/method-schema.js +108 -0
- package/dist/generators/method-schema.js.map +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/internals.d.ts +19 -0
- package/dist/internals.d.ts.map +1 -0
- package/dist/internals.js +22 -0
- package/dist/internals.js.map +1 -0
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/json-schema/generator.js +1 -2
- package/dist/json-schema/generator.js.map +1 -1
- package/dist/json-schema/types.d.ts +28 -0
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/json-schema/types.js +27 -1
- package/dist/json-schema/types.js.map +1 -1
- package/dist/ui-schema/generator.d.ts.map +1 -1
- package/dist/ui-schema/generator.js +1 -3
- package/dist/ui-schema/generator.js.map +1 -1
- package/dist/ui-schema/types.d.ts.map +1 -1
- package/package.json +11 -3
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge case fixtures for testing type converter and analyzer.
|
|
3
|
+
*
|
|
4
|
+
* These test various TypeScript type patterns that might cause issues.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Mixed type union (not just literals) - should produce oneOf.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MixedUnionTypes {
|
|
10
|
+
mixedPrimitive: string | number;
|
|
11
|
+
complexUnion: string | {
|
|
12
|
+
nested: boolean;
|
|
13
|
+
};
|
|
14
|
+
objectUnion: {
|
|
15
|
+
type: "a";
|
|
16
|
+
valueA: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "b";
|
|
19
|
+
valueB: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Various nullable patterns.
|
|
24
|
+
*/
|
|
25
|
+
export declare class NullablePatterns {
|
|
26
|
+
nullableString: string | null;
|
|
27
|
+
undefinedString: string | undefined;
|
|
28
|
+
optionalNullable?: string | null;
|
|
29
|
+
tripleUnion: string | null | undefined;
|
|
30
|
+
nullableStatus: "active" | "inactive" | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Various array patterns.
|
|
34
|
+
*/
|
|
35
|
+
export declare class ArrayEdgeCases {
|
|
36
|
+
strings: string[];
|
|
37
|
+
mixedArray: (string | number)[];
|
|
38
|
+
nullableArray: string[] | null;
|
|
39
|
+
objectArray: {
|
|
40
|
+
id: number;
|
|
41
|
+
name: string;
|
|
42
|
+
}[];
|
|
43
|
+
anyArray: unknown[];
|
|
44
|
+
nestedArray: string[][];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Various object type patterns.
|
|
48
|
+
*/
|
|
49
|
+
export declare class ObjectEdgeCases {
|
|
50
|
+
emptyObject: {};
|
|
51
|
+
stringRecord: Record<string, string>;
|
|
52
|
+
deepNested: {
|
|
53
|
+
level1: {
|
|
54
|
+
level2: {
|
|
55
|
+
level3: {
|
|
56
|
+
value: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
optionalProps: {
|
|
62
|
+
required: string;
|
|
63
|
+
optional?: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Special TypeScript types.
|
|
68
|
+
*/
|
|
69
|
+
export declare class SpecialTypes {
|
|
70
|
+
anyField: any;
|
|
71
|
+
unknownField: unknown;
|
|
72
|
+
voidField: void;
|
|
73
|
+
dateField: Date;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Various enum patterns.
|
|
77
|
+
*/
|
|
78
|
+
export declare class EnumVariations {
|
|
79
|
+
singleLiteral: "only";
|
|
80
|
+
numberEnum: 1 | 2 | 3;
|
|
81
|
+
mixedLiterals: "string" | 42;
|
|
82
|
+
largeEnum: "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Simple class with no decorators for testing analyzer edge cases.
|
|
86
|
+
*/
|
|
87
|
+
export declare class NoDecoratorsClass {
|
|
88
|
+
name: string;
|
|
89
|
+
count?: number;
|
|
90
|
+
active: boolean;
|
|
91
|
+
}
|
|
92
|
+
export declare const notFormSpec1: null;
|
|
93
|
+
export declare const notFormSpec2: undefined;
|
|
94
|
+
export declare const notFormSpec3 = "string";
|
|
95
|
+
export declare const notFormSpec4 = 123;
|
|
96
|
+
export declare const notFormSpec5: {
|
|
97
|
+
notElements: never[];
|
|
98
|
+
};
|
|
99
|
+
export declare const notFormSpec6: {
|
|
100
|
+
elements: string;
|
|
101
|
+
};
|
|
102
|
+
export declare const notFormSpec7: {
|
|
103
|
+
elements: {
|
|
104
|
+
missingType: boolean;
|
|
105
|
+
}[];
|
|
106
|
+
};
|
|
107
|
+
export declare const notFormSpec8: {
|
|
108
|
+
elements: null[];
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=edge-cases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-cases.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/edge-cases.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;GAEG;AACH,qBAAa,eAAe;IAE1B,cAAc,EAAG,MAAM,GAAG,MAAM,CAAC;IAGjC,YAAY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MAAM,CAAC;KACnB,CAAC;CACH;AAMD;;GAEG;AACH,qBAAa,YAAY;IAGvB,QAAQ,EAAG,GAAG,CAAC;IAGf,YAAY,EAAG,OAAO,CAAC;IAOvB,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAClB;AAMD;;GAEG;AACH,qBAAa,cAAc;IAEzB,aAAa,EAAG,MAAM,CAAC;IAGvB,UAAU,EAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAIvB,aAAa,EAAG,QAAQ,GAAG,EAAE,CAAC;IAG9B,SAAS,EAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CACvE;AAMD;;GAEG;AACH,qBAAa,iBAAiB;IAE5B,IAAI,EAAG,MAAM,CAAC;IAGd,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,MAAM,EAAG,OAAO,CAAC;CAClB;AAMD,eAAO,MAAM,YAAY,MAAO,CAAC;AACjC,eAAO,MAAM,YAAY,WAAY,CAAC;AACtC,eAAO,MAAM,YAAY,WAAW,CAAC;AACrC,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,eAAO,MAAM,YAAY;;CAAsB,CAAC;AAChD,eAAO,MAAM,YAAY;;CAA4B,CAAC;AACtD,eAAO,MAAM,YAAY;;;;CAAwC,CAAC;AAClE,eAAO,MAAM,YAAY;;CAAuB,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge case fixtures for testing type converter and analyzer.
|
|
3
|
+
*
|
|
4
|
+
* These test various TypeScript type patterns that might cause issues.
|
|
5
|
+
*/
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Complex Union Types
|
|
8
|
+
// ============================================================================
|
|
9
|
+
/**
|
|
10
|
+
* Mixed type union (not just literals) - should produce oneOf.
|
|
11
|
+
*/
|
|
12
|
+
export class MixedUnionTypes {
|
|
13
|
+
// string | number - incompatible union
|
|
14
|
+
mixedPrimitive;
|
|
15
|
+
// Complex union with object and primitive
|
|
16
|
+
complexUnion;
|
|
17
|
+
// Union of different object shapes
|
|
18
|
+
objectUnion;
|
|
19
|
+
}
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Nullable and Optional Patterns
|
|
22
|
+
// ============================================================================
|
|
23
|
+
/**
|
|
24
|
+
* Various nullable patterns.
|
|
25
|
+
*/
|
|
26
|
+
export class NullablePatterns {
|
|
27
|
+
// Nullable string (T | null)
|
|
28
|
+
nullableString;
|
|
29
|
+
// Undefined union (T | undefined) - different from optional
|
|
30
|
+
undefinedString;
|
|
31
|
+
// Both nullable and optional
|
|
32
|
+
optionalNullable;
|
|
33
|
+
// Triple union (T | null | undefined)
|
|
34
|
+
tripleUnion;
|
|
35
|
+
// Nullable enum
|
|
36
|
+
nullableStatus;
|
|
37
|
+
}
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// Array Edge Cases
|
|
40
|
+
// ============================================================================
|
|
41
|
+
/**
|
|
42
|
+
* Various array patterns.
|
|
43
|
+
*/
|
|
44
|
+
export class ArrayEdgeCases {
|
|
45
|
+
// Array of primitives
|
|
46
|
+
strings;
|
|
47
|
+
// Array of unions
|
|
48
|
+
mixedArray;
|
|
49
|
+
// Nullable array
|
|
50
|
+
nullableArray;
|
|
51
|
+
// Array of objects
|
|
52
|
+
objectArray;
|
|
53
|
+
// Empty array type (any[])
|
|
54
|
+
anyArray;
|
|
55
|
+
// Nested arrays
|
|
56
|
+
nestedArray;
|
|
57
|
+
}
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// Object Edge Cases
|
|
60
|
+
// ============================================================================
|
|
61
|
+
/**
|
|
62
|
+
* Various object type patterns.
|
|
63
|
+
*/
|
|
64
|
+
export class ObjectEdgeCases {
|
|
65
|
+
// Empty object - Allow this as a test case for empty object type handling
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
67
|
+
emptyObject;
|
|
68
|
+
// Record type
|
|
69
|
+
stringRecord;
|
|
70
|
+
// Deeply nested object
|
|
71
|
+
deepNested;
|
|
72
|
+
// Object with optional properties
|
|
73
|
+
optionalProps;
|
|
74
|
+
}
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// Special Types
|
|
77
|
+
// ============================================================================
|
|
78
|
+
/**
|
|
79
|
+
* Special TypeScript types.
|
|
80
|
+
*/
|
|
81
|
+
export class SpecialTypes {
|
|
82
|
+
// any type (should handle gracefully)
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
anyField;
|
|
85
|
+
// unknown type
|
|
86
|
+
unknownField;
|
|
87
|
+
// never type (edge case)
|
|
88
|
+
// Note: never is not typically used as a property type
|
|
89
|
+
// void type - Test case for void type handling, used in FormSpec codegen tests
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
91
|
+
voidField;
|
|
92
|
+
// Date (built-in object)
|
|
93
|
+
dateField;
|
|
94
|
+
}
|
|
95
|
+
// ============================================================================
|
|
96
|
+
// Enum Variations
|
|
97
|
+
// ============================================================================
|
|
98
|
+
/**
|
|
99
|
+
* Various enum patterns.
|
|
100
|
+
*/
|
|
101
|
+
export class EnumVariations {
|
|
102
|
+
// Single literal (degenerates to const)
|
|
103
|
+
singleLiteral;
|
|
104
|
+
// Number literal enum
|
|
105
|
+
numberEnum;
|
|
106
|
+
// Mixed literal types (should NOT be valid enum)
|
|
107
|
+
// Note: This is a union, not an enum
|
|
108
|
+
mixedLiterals;
|
|
109
|
+
// Large enum (many options)
|
|
110
|
+
largeEnum;
|
|
111
|
+
}
|
|
112
|
+
// ============================================================================
|
|
113
|
+
// Class without decorators (for testing analyzer handles undecorated classes)
|
|
114
|
+
// ============================================================================
|
|
115
|
+
/**
|
|
116
|
+
* Simple class with no decorators for testing analyzer edge cases.
|
|
117
|
+
*/
|
|
118
|
+
export class NoDecoratorsClass {
|
|
119
|
+
// Regular string field
|
|
120
|
+
name;
|
|
121
|
+
// Optional number field
|
|
122
|
+
count;
|
|
123
|
+
// Boolean field
|
|
124
|
+
active;
|
|
125
|
+
}
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// Invalid FormSpec-like Objects (for testing isFormSpec)
|
|
128
|
+
// ============================================================================
|
|
129
|
+
export const notFormSpec1 = null;
|
|
130
|
+
export const notFormSpec2 = undefined;
|
|
131
|
+
export const notFormSpec3 = "string";
|
|
132
|
+
export const notFormSpec4 = 123;
|
|
133
|
+
export const notFormSpec5 = { notElements: [] };
|
|
134
|
+
export const notFormSpec6 = { elements: "not-array" };
|
|
135
|
+
export const notFormSpec7 = { elements: [{ missingType: true }] };
|
|
136
|
+
export const notFormSpec8 = { elements: [null] };
|
|
137
|
+
//# sourceMappingURL=edge-cases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-cases.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/edge-cases.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B,uCAAuC;IACvC,cAAc,CAAmB;IAEjC,0CAA0C;IAC1C,YAAY,CAAgC;IAE5C,mCAAmC;IACnC,WAAW,CAAiE;CAC7E;AAED,+EAA+E;AAC/E,iCAAiC;AACjC,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B,6BAA6B;IAC7B,cAAc,CAAiB;IAE/B,4DAA4D;IAC5D,eAAe,CAAsB;IAErC,6BAA6B;IAC7B,gBAAgB,CAAiB;IAEjC,sCAAsC;IACtC,WAAW,CAA6B;IAExC,gBAAgB;IAChB,cAAc,CAAgC;CAC/C;AAED,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB,sBAAsB;IACtB,OAAO,CAAY;IAEnB,k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Y,GAAG,SAAS,CAAC;AACtC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;AAChD,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAClE,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class ExampleAForm {
|
|
2
|
+
name: string;
|
|
3
|
+
age: number;
|
|
4
|
+
score: number;
|
|
5
|
+
email?: string;
|
|
6
|
+
country: "us" | "ca";
|
|
7
|
+
state?: string;
|
|
8
|
+
/** @deprecated Use email instead */
|
|
9
|
+
fax?: string;
|
|
10
|
+
role: "admin" | "user";
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=example-a-builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-a-builtins.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-a-builtins.ts"],"names":[],"mappings":"AAaA,qBAAa,YAAY;IAIvB,IAAI,EAAG,MAAM,CAAC;IAKd,GAAG,EAAG,MAAM,CAAC;IAIb,KAAK,EAAG,MAAM,CAAC;IAIf,KAAK,CAAC,EAAE,MAAM,CAAC;IAQf,OAAO,EAAG,IAAI,GAAG,IAAI,CAAC;IAItB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,oCAAoC;IAEpC,GAAG,CAAC,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,OAAO,GAAG,MAAM,CAAU;CACjC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { Field, Minimum, Maximum, ExclusiveMinimum, MinLength, MaxLength, Pattern, Group, ShowWhen, EnumOptions, } from "@formspec/decorators";
|
|
36
|
+
let ExampleAForm = (() => {
|
|
37
|
+
let _name_decorators;
|
|
38
|
+
let _name_initializers = [];
|
|
39
|
+
let _name_extraInitializers = [];
|
|
40
|
+
let _age_decorators;
|
|
41
|
+
let _age_initializers = [];
|
|
42
|
+
let _age_extraInitializers = [];
|
|
43
|
+
let _score_decorators;
|
|
44
|
+
let _score_initializers = [];
|
|
45
|
+
let _score_extraInitializers = [];
|
|
46
|
+
let _email_decorators;
|
|
47
|
+
let _email_initializers = [];
|
|
48
|
+
let _email_extraInitializers = [];
|
|
49
|
+
let _country_decorators;
|
|
50
|
+
let _country_initializers = [];
|
|
51
|
+
let _country_extraInitializers = [];
|
|
52
|
+
let _state_decorators;
|
|
53
|
+
let _state_initializers = [];
|
|
54
|
+
let _state_extraInitializers = [];
|
|
55
|
+
let _fax_decorators;
|
|
56
|
+
let _fax_initializers = [];
|
|
57
|
+
let _fax_extraInitializers = [];
|
|
58
|
+
let _role_decorators;
|
|
59
|
+
let _role_initializers = [];
|
|
60
|
+
let _role_extraInitializers = [];
|
|
61
|
+
return class ExampleAForm {
|
|
62
|
+
static {
|
|
63
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
64
|
+
_name_decorators = [Field({ displayName: "Full Name", description: "Your legal name" }), MinLength(2), MaxLength(100)];
|
|
65
|
+
_age_decorators = [Field({ displayName: "Age" }), Minimum(0), Maximum(150)];
|
|
66
|
+
_score_decorators = [Field({ displayName: "Score" }), ExclusiveMinimum(0)];
|
|
67
|
+
_email_decorators = [Field({ displayName: "Email" }), Pattern("^[^@]+@[^@]+$")];
|
|
68
|
+
_country_decorators = [Group("Preferences"), Field({ displayName: "Country" }), EnumOptions([
|
|
69
|
+
{ id: "us", label: "United States" },
|
|
70
|
+
{ id: "ca", label: "Canada" },
|
|
71
|
+
])];
|
|
72
|
+
_state_decorators = [ShowWhen({ field: "country", value: "us" }), Field({ displayName: "State" })];
|
|
73
|
+
_fax_decorators = [Field({ displayName: "Fax Number" })];
|
|
74
|
+
_role_decorators = [Field({ displayName: "Role" })];
|
|
75
|
+
__esDecorate(null, null, _name_decorators, { kind: "field", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
|
|
76
|
+
__esDecorate(null, null, _age_decorators, { kind: "field", name: "age", static: false, private: false, access: { has: obj => "age" in obj, get: obj => obj.age, set: (obj, value) => { obj.age = value; } }, metadata: _metadata }, _age_initializers, _age_extraInitializers);
|
|
77
|
+
__esDecorate(null, null, _score_decorators, { kind: "field", name: "score", static: false, private: false, access: { has: obj => "score" in obj, get: obj => obj.score, set: (obj, value) => { obj.score = value; } }, metadata: _metadata }, _score_initializers, _score_extraInitializers);
|
|
78
|
+
__esDecorate(null, null, _email_decorators, { kind: "field", name: "email", static: false, private: false, access: { has: obj => "email" in obj, get: obj => obj.email, set: (obj, value) => { obj.email = value; } }, metadata: _metadata }, _email_initializers, _email_extraInitializers);
|
|
79
|
+
__esDecorate(null, null, _country_decorators, { kind: "field", name: "country", static: false, private: false, access: { has: obj => "country" in obj, get: obj => obj.country, set: (obj, value) => { obj.country = value; } }, metadata: _metadata }, _country_initializers, _country_extraInitializers);
|
|
80
|
+
__esDecorate(null, null, _state_decorators, { kind: "field", name: "state", static: false, private: false, access: { has: obj => "state" in obj, get: obj => obj.state, set: (obj, value) => { obj.state = value; } }, metadata: _metadata }, _state_initializers, _state_extraInitializers);
|
|
81
|
+
__esDecorate(null, null, _fax_decorators, { kind: "field", name: "fax", static: false, private: false, access: { has: obj => "fax" in obj, get: obj => obj.fax, set: (obj, value) => { obj.fax = value; } }, metadata: _metadata }, _fax_initializers, _fax_extraInitializers);
|
|
82
|
+
__esDecorate(null, null, _role_decorators, { kind: "field", name: "role", static: false, private: false, access: { has: obj => "role" in obj, get: obj => obj.role, set: (obj, value) => { obj.role = value; } }, metadata: _metadata }, _role_initializers, _role_extraInitializers);
|
|
83
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
84
|
+
}
|
|
85
|
+
name = __runInitializers(this, _name_initializers, void 0);
|
|
86
|
+
age = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _age_initializers, void 0));
|
|
87
|
+
score = (__runInitializers(this, _age_extraInitializers), __runInitializers(this, _score_initializers, void 0));
|
|
88
|
+
email = (__runInitializers(this, _score_extraInitializers), __runInitializers(this, _email_initializers, void 0));
|
|
89
|
+
country = (__runInitializers(this, _email_extraInitializers), __runInitializers(this, _country_initializers, void 0));
|
|
90
|
+
state = (__runInitializers(this, _country_extraInitializers), __runInitializers(this, _state_initializers, void 0));
|
|
91
|
+
/** @deprecated Use email instead */
|
|
92
|
+
fax = (__runInitializers(this, _state_extraInitializers), __runInitializers(this, _fax_initializers, void 0));
|
|
93
|
+
role = (__runInitializers(this, _fax_extraInitializers), __runInitializers(this, _role_initializers, "user"));
|
|
94
|
+
constructor() {
|
|
95
|
+
__runInitializers(this, _role_extraInitializers);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
})();
|
|
99
|
+
export { ExampleAForm };
|
|
100
|
+
//# sourceMappingURL=example-a-builtins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-a-builtins.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-a-builtins.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,SAAS,EAC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,uKAAA,OAAO,6BAAP,OAAO,yFAAe;YAItB,iKAAA,KAAK,6BAAL,KAAK,qFAAU;YAIf,2JAAA,GAAG,6BAAH,GAAG,iFAAU;YAGb,8JAAA,IAAI,6BAAJ,IAAI,mFAA4B;;;QAhChC,IAAI,uDAAU;QAKd,GAAG,0GAAU;QAIb,KAAK,2GAAU;QAIf,KAAK,6GAAU;QAQf,OAAO,+GAAe;QAItB,KAAK,+GAAU;QAEf,oCAAoC;QAEpC,GAAG,2GAAU;QAGb,IAAI,iGAAqB,MAAM,GAAC;;;;;;SApCrB,YAAY"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FieldOptions } from "@formspec/decorators";
|
|
2
|
+
export declare const CustomField: ((_args: FieldOptions) => (value: undefined, context: ClassFieldDecoratorContext) => void) & import("@formspec/decorators").FormSpecExtendsBrand<"Field">;
|
|
3
|
+
export declare const Floor: ((_args: number) => (value: undefined, context: ClassFieldDecoratorContext) => void) & import("@formspec/decorators").FormSpecExtendsBrand<"Minimum">;
|
|
4
|
+
export declare const Ceiling: ((_args: number) => (value: undefined, context: ClassFieldDecoratorContext) => void) & import("@formspec/decorators").FormSpecExtendsBrand<"Maximum">;
|
|
5
|
+
//# sourceMappingURL=example-b-decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-b-decorators.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-b-decorators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,eAAO,MAAM,WAAW,2JAA2D,CAAC;AACpF,eAAO,MAAM,KAAK,uJAAiD,CAAC;AACpE,eAAO,MAAM,OAAO,uJAAmD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { extendDecorator } from "@formspec/decorators";
|
|
2
|
+
export const CustomField = extendDecorator("Field").as("CustomField");
|
|
3
|
+
export const Floor = extendDecorator("Minimum").as("Floor");
|
|
4
|
+
export const Ceiling = extendDecorator("Maximum").as("Ceiling");
|
|
5
|
+
//# sourceMappingURL=example-b-decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-b-decorators.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-b-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,CAAe,aAAa,CAAC,CAAC;AACpF,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,EAAE,CAAS,OAAO,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,EAAE,CAAS,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-b-extended.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-b-extended.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IAIvB,MAAM,EAAG,MAAM,CAAC;IAGhB,KAAK,EAAG,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { CustomField, Floor, Ceiling } from "./example-b-decorators.js";
|
|
36
|
+
let ExampleBForm = (() => {
|
|
37
|
+
let _amount_decorators;
|
|
38
|
+
let _amount_initializers = [];
|
|
39
|
+
let _amount_extraInitializers = [];
|
|
40
|
+
let _label_decorators;
|
|
41
|
+
let _label_initializers = [];
|
|
42
|
+
let _label_extraInitializers = [];
|
|
43
|
+
return class ExampleBForm {
|
|
44
|
+
static {
|
|
45
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
46
|
+
_amount_decorators = [CustomField({ displayName: "Amount", description: "Total amount in cents" }), Floor(0), Ceiling(1000000)];
|
|
47
|
+
_label_decorators = [CustomField({ displayName: "Label" })];
|
|
48
|
+
__esDecorate(null, null, _amount_decorators, { kind: "field", name: "amount", static: false, private: false, access: { has: obj => "amount" in obj, get: obj => obj.amount, set: (obj, value) => { obj.amount = value; } }, metadata: _metadata }, _amount_initializers, _amount_extraInitializers);
|
|
49
|
+
__esDecorate(null, null, _label_decorators, { kind: "field", name: "label", static: false, private: false, access: { has: obj => "label" in obj, get: obj => obj.label, set: (obj, value) => { obj.label = value; } }, metadata: _metadata }, _label_initializers, _label_extraInitializers);
|
|
50
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
51
|
+
}
|
|
52
|
+
amount = __runInitializers(this, _amount_initializers, void 0);
|
|
53
|
+
label = (__runInitializers(this, _amount_extraInitializers), __runInitializers(this, _label_initializers, void 0));
|
|
54
|
+
constructor() {
|
|
55
|
+
__runInitializers(this, _label_extraInitializers);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
})();
|
|
59
|
+
export { ExampleBForm };
|
|
60
|
+
//# sourceMappingURL=example-b-extended.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-b-extended.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-b-extended.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;IAE3D,YAAY;;;;;;;iBAAZ,YAAY;;;kCACtB,WAAW,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC,EAC5E,KAAK,CAAC,CAAC,CAAC,EACR,OAAO,CAAC,OAAO,CAAC;iCAGhB,WAAW,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;YAFtC,oKAAA,MAAM,6BAAN,MAAM,uFAAU;YAGhB,iKAAA,KAAK,6BAAL,KAAK,qFAAU;;;QAHf,MAAM,yDAAU;QAGhB,KAAK,8GAAU;;;;;;SAPJ,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-c-custom.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-c-custom.ts"],"names":[],"mappings":"AAGA,qBAAa,YAAY;IAGvB,OAAO,EAAG,MAAM,CAAC;IAKjB,OAAO,EAAG,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { Field, Minimum } from "@formspec/decorators";
|
|
36
|
+
import { Title, Priority } from "./example-c-decorators.js";
|
|
37
|
+
let ExampleCForm = (() => {
|
|
38
|
+
let _heading_decorators;
|
|
39
|
+
let _heading_initializers = [];
|
|
40
|
+
let _heading_extraInitializers = [];
|
|
41
|
+
let _urgency_decorators;
|
|
42
|
+
let _urgency_initializers = [];
|
|
43
|
+
let _urgency_extraInitializers = [];
|
|
44
|
+
return class ExampleCForm {
|
|
45
|
+
static {
|
|
46
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
47
|
+
_heading_decorators = [Title, Field({ displayName: "Heading" })];
|
|
48
|
+
_urgency_decorators = [Priority({ level: "high" }), Field({ displayName: "Urgency Score" }), Minimum(1)];
|
|
49
|
+
__esDecorate(null, null, _heading_decorators, { kind: "field", name: "heading", static: false, private: false, access: { has: obj => "heading" in obj, get: obj => obj.heading, set: (obj, value) => { obj.heading = value; } }, metadata: _metadata }, _heading_initializers, _heading_extraInitializers);
|
|
50
|
+
__esDecorate(null, null, _urgency_decorators, { kind: "field", name: "urgency", static: false, private: false, access: { has: obj => "urgency" in obj, get: obj => obj.urgency, set: (obj, value) => { obj.urgency = value; } }, metadata: _metadata }, _urgency_initializers, _urgency_extraInitializers);
|
|
51
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
52
|
+
}
|
|
53
|
+
heading = __runInitializers(this, _heading_initializers, void 0);
|
|
54
|
+
urgency = (__runInitializers(this, _heading_extraInitializers), __runInitializers(this, _urgency_initializers, void 0));
|
|
55
|
+
constructor() {
|
|
56
|
+
__runInitializers(this, _urgency_extraInitializers);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
})();
|
|
60
|
+
export { ExampleCForm };
|
|
61
|
+
//# sourceMappingURL=example-c-custom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-c-custom.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-c-custom.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;IAE/C,YAAY;;;;;;;iBAAZ,YAAY;;;mCACtB,KAAK,EACL,KAAK,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;mCAGjC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAC3B,KAAK,CAAC,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,EACvC,OAAO,CAAC,CAAC,CAAC;YAJX,uKAAA,OAAO,6BAAP,OAAO,yFAAU;YAKjB,uKAAA,OAAO,6BAAP,OAAO,yFAAU;;;QALjB,OAAO,0DAAU;QAKjB,OAAO,iHAAU;;;;;;SARN,YAAY"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const Title: ((value: undefined, context: ClassFieldDecoratorContext) => void) & import("@formspec/decorators").FormSpecMarkerBrand & import("@formspec/decorators").FormSpecExtensionBrand<"title-field">;
|
|
2
|
+
export declare const Priority: ((_args: {
|
|
3
|
+
level: string;
|
|
4
|
+
}) => (value: undefined, context: ClassFieldDecoratorContext) => void) & import("@formspec/decorators").FormSpecExtensionBrand<"priority">;
|
|
5
|
+
//# sourceMappingURL=example-c-decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-c-decorators.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-c-decorators.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,+LAAiD,CAAC;AACpE,eAAO,MAAM,QAAQ;WAA2C,MAAM;0IAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-c-decorators.js","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-c-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC,EAAE,CAAoB,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-d-mixed-decorators.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/example-d-mixed-decorators.ts"],"names":[],"mappings":"AAYA,qBAAa,YAAY;IAGvB,QAAQ,EAAG,MAAM,CAAC;IAIlB,KAAK,EAAG,MAAM,CAAC;IAGf,KAAK,EAAG,MAAM,CAAC;CAChB"}
|