|
| 1 | +#include <stdarg.h> |
| 2 | +#include <stdbool.h> |
| 3 | +#include <stdint.h> |
| 4 | +#include <stdlib.h> |
| 5 | + |
| 6 | +typedef struct CssError CssError; |
| 7 | + |
| 8 | +typedef struct StyleSheet StyleSheet; |
| 9 | + |
| 10 | +typedef struct Targets { |
| 11 | + uint32_t android; |
| 12 | + uint32_t chrome; |
| 13 | + uint32_t edge; |
| 14 | + uint32_t firefox; |
| 15 | + uint32_t ie; |
| 16 | + uint32_t ios_saf; |
| 17 | + uint32_t opera; |
| 18 | + uint32_t safari; |
| 19 | + uint32_t samsung; |
| 20 | +} Targets; |
| 21 | + |
| 22 | +typedef struct ParseOptions { |
| 23 | + const char *filename; |
| 24 | + bool nesting; |
| 25 | + bool custom_media; |
| 26 | + bool css_modules; |
| 27 | + const char *css_modules_pattern; |
| 28 | + bool css_modules_dashed_idents; |
| 29 | + bool error_recovery; |
| 30 | +} ParseOptions; |
| 31 | + |
| 32 | +typedef struct TransformOptions { |
| 33 | + struct Targets targets; |
| 34 | + char **unused_symbols; |
| 35 | + uintptr_t unused_symbols_len; |
| 36 | +} TransformOptions; |
| 37 | + |
| 38 | +typedef struct RawString { |
| 39 | + char *text; |
| 40 | + uintptr_t len; |
| 41 | +} RawString; |
| 42 | + |
| 43 | +typedef enum CssModuleReference_Tag { |
| 44 | + /** |
| 45 | + * A local reference. |
| 46 | + */ |
| 47 | + CssModuleReference_Local, |
| 48 | + /** |
| 49 | + * A global reference. |
| 50 | + */ |
| 51 | + CssModuleReference_Global, |
| 52 | + /** |
| 53 | + * A reference to an export in a different file. |
| 54 | + */ |
| 55 | + CssModuleReference_Dependency, |
| 56 | +} CssModuleReference_Tag; |
| 57 | + |
| 58 | +typedef struct CssModuleReference_Local_Body { |
| 59 | + /** |
| 60 | + * The local (compiled) name for the reference. |
| 61 | + */ |
| 62 | + struct RawString name; |
| 63 | +} CssModuleReference_Local_Body; |
| 64 | + |
| 65 | +typedef struct CssModuleReference_Global_Body { |
| 66 | + /** |
| 67 | + * The referenced global name. |
| 68 | + */ |
| 69 | + struct RawString name; |
| 70 | +} CssModuleReference_Global_Body; |
| 71 | + |
| 72 | +typedef struct CssModuleReference_Dependency_Body { |
| 73 | + /** |
| 74 | + * The name to reference within the dependency. |
| 75 | + */ |
| 76 | + struct RawString name; |
| 77 | + /** |
| 78 | + * The dependency specifier for the referenced file. |
| 79 | + */ |
| 80 | + struct RawString specifier; |
| 81 | +} CssModuleReference_Dependency_Body; |
| 82 | + |
| 83 | +typedef struct CssModuleReference { |
| 84 | + CssModuleReference_Tag tag; |
| 85 | + union { |
| 86 | + CssModuleReference_Local_Body local; |
| 87 | + CssModuleReference_Global_Body global; |
| 88 | + CssModuleReference_Dependency_Body dependency; |
| 89 | + }; |
| 90 | +} CssModuleReference; |
| 91 | + |
| 92 | +typedef struct CssModuleExport { |
| 93 | + struct RawString exported; |
| 94 | + struct RawString local; |
| 95 | + bool is_referenced; |
| 96 | + struct CssModuleReference *composes; |
| 97 | + uintptr_t composes_len; |
| 98 | +} CssModuleExport; |
| 99 | + |
| 100 | +typedef struct CssModulePlaceholder { |
| 101 | + struct RawString placeholder; |
| 102 | + struct CssModuleReference reference; |
| 103 | +} CssModulePlaceholder; |
| 104 | + |
| 105 | +typedef struct ToCssResult { |
| 106 | + struct RawString code; |
| 107 | + struct RawString map; |
| 108 | + struct CssModuleExport *exports; |
| 109 | + uintptr_t exports_len; |
| 110 | + struct CssModulePlaceholder *references; |
| 111 | + uintptr_t references_len; |
| 112 | +} ToCssResult; |
| 113 | + |
| 114 | +typedef struct PseudoClasses { |
| 115 | + const char *hover; |
| 116 | + const char *active; |
| 117 | + const char *focus; |
| 118 | + const char *focus_visible; |
| 119 | + const char *focus_within; |
| 120 | +} PseudoClasses; |
| 121 | + |
| 122 | +typedef struct ToCssOptions { |
| 123 | + bool minify; |
| 124 | + bool source_map; |
| 125 | + const char *input_source_map; |
| 126 | + uintptr_t input_source_map_len; |
| 127 | + struct Targets targets; |
| 128 | + bool analyze_dependencies; |
| 129 | + struct PseudoClasses pseudo_classes; |
| 130 | +} ToCssOptions; |
| 131 | + |
| 132 | +bool parcel_css_browserslist_to_targets(const char *query, |
| 133 | + struct Targets *targets, |
| 134 | + struct CssError **error); |
| 135 | + |
| 136 | +struct StyleSheet *parcel_css_stylesheet_parse(const char *source, |
| 137 | + uintptr_t len, |
| 138 | + struct ParseOptions options, |
| 139 | + struct CssError **error); |
| 140 | + |
| 141 | +bool parcel_css_stylesheet_transform(struct StyleSheet *stylesheet, |
| 142 | + struct TransformOptions options, |
| 143 | + struct CssError **error); |
| 144 | + |
| 145 | +struct ToCssResult parcel_css_stylesheet_to_css(struct StyleSheet *stylesheet, |
| 146 | + struct ToCssOptions options, |
| 147 | + struct CssError **error); |
| 148 | + |
| 149 | +void parcel_css_stylesheet_free(struct StyleSheet *stylesheet); |
| 150 | + |
| 151 | +void parcel_css_to_css_result_free(struct ToCssResult result); |
| 152 | + |
| 153 | +const char *parcel_css_error_message(struct CssError *error); |
| 154 | + |
| 155 | +void parcel_css_error_free(struct CssError *error); |
| 156 | + |
| 157 | +uintptr_t parcel_css_stylesheet_get_warning_count(struct StyleSheet *stylesheet); |
| 158 | + |
| 159 | +const char *parcel_css_stylesheet_get_warning(struct StyleSheet *stylesheet, uintptr_t index); |
0 commit comments