@trojanbox-vcp-test/site-edit-engine 0.1.0 → 0.2.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/dist/index.d.ts +3 -0
- package/dist/index.js +127 -2
- package/dist/internal/protocol/operation.d.ts +2 -0
- package/dist/internal/protocol/render.d.ts +3 -30
- package/dist/internal/protocol.d.ts +1 -1
- package/dist/next-app-router.js +1 -140
- package/dist/preview-runtime.d.ts +249 -303
- package/dist/runtime-sync.d.ts +8 -8
- package/dist/runtime.d.ts +1 -127
- package/dist/site-edit-instrumentation.d.ts +1 -1
- package/dist/source-watcher.js +1 -150
- package/dist/types.d.ts +12 -14
- package/dist/webpack-loader.cjs +50 -588
- package/package.json +2 -2
- package/dist/execute-integration/execute-fixture-harness.d.ts +0 -25
- package/dist/execute-integration/execute-fixture-harness.js +0 -37
- package/dist/internal/ast/diagnostics/index.d.ts +0 -5
- package/dist/internal/ast/diagnostics/index.js +0 -25
- package/dist/internal/ast/history/index.d.ts +0 -15
- package/dist/internal/ast/history/index.js +0 -62
- package/dist/internal/ast/index.d.ts +0 -8
- package/dist/internal/ast/index.js +0 -5
- package/dist/internal/ast/locators/index.d.ts +0 -1
- package/dist/internal/ast/locators/index.js +0 -1
- package/dist/internal/ast/locators/resolve-locator.d.ts +0 -16
- package/dist/internal/ast/locators/resolve-locator.js +0 -920
- package/dist/internal/ast/parser/SourceParser.d.ts +0 -30
- package/dist/internal/ast/parser/SourceParser.js +0 -49
- package/dist/internal/ast/parser/index.d.ts +0 -21
- package/dist/internal/ast/parser/index.js +0 -64
- package/dist/internal/ast/primitives/conditional/conditional-primitives.d.ts +0 -18
- package/dist/internal/ast/primitives/conditional/conditional-primitives.js +0 -237
- package/dist/internal/ast/primitives/conditional/index.d.ts +0 -1
- package/dist/internal/ast/primitives/conditional/index.js +0 -1
- package/dist/internal/ast/primitives/imports/add-import.d.ts +0 -18
- package/dist/internal/ast/primitives/imports/add-import.js +0 -111
- package/dist/internal/ast/primitives/imports/index.d.ts +0 -2
- package/dist/internal/ast/primitives/imports/index.js +0 -2
- package/dist/internal/ast/primitives/imports/remove-import.d.ts +0 -15
- package/dist/internal/ast/primitives/imports/remove-import.js +0 -72
- package/dist/internal/ast/primitives/index.d.ts +0 -10
- package/dist/internal/ast/primitives/index.js +0 -10
- package/dist/internal/ast/primitives/jsx/index.d.ts +0 -4
- package/dist/internal/ast/primitives/jsx/index.js +0 -4
- package/dist/internal/ast/primitives/jsx/insert-child.d.ts +0 -11
- package/dist/internal/ast/primitives/jsx/insert-child.js +0 -69
- package/dist/internal/ast/primitives/jsx/move-node.d.ts +0 -9
- package/dist/internal/ast/primitives/jsx/move-node.js +0 -76
- package/dist/internal/ast/primitives/jsx/remove-node.d.ts +0 -7
- package/dist/internal/ast/primitives/jsx/remove-node.js +0 -36
- package/dist/internal/ast/primitives/jsx/update-text.d.ts +0 -8
- package/dist/internal/ast/primitives/jsx/update-text.js +0 -81
- package/dist/internal/ast/primitives/next/index.d.ts +0 -1
- package/dist/internal/ast/primitives/next/index.js +0 -1
- package/dist/internal/ast/primitives/next/next-primitives.d.ts +0 -43
- package/dist/internal/ast/primitives/next/next-primitives.js +0 -211
- package/dist/internal/ast/primitives/shared.d.ts +0 -60
- package/dist/internal/ast/primitives/shared.js +0 -176
- package/dist/internal/ast/primitives/style/class-expression.d.ts +0 -23
- package/dist/internal/ast/primitives/style/class-expression.js +0 -174
- package/dist/internal/ast/primitives/style/index.d.ts +0 -1
- package/dist/internal/ast/primitives/style/index.js +0 -1
- package/dist/internal/ast/primitives/style/style-primitives.d.ts +0 -49
- package/dist/internal/ast/primitives/style/style-primitives.js +0 -555
- package/dist/internal/ast/primitives/values/index.d.ts +0 -1
- package/dist/internal/ast/primitives/values/index.js +0 -1
- package/dist/internal/ast/primitives/values/value-primitives.d.ts +0 -42
- package/dist/internal/ast/primitives/values/value-primitives.js +0 -158
- package/dist/internal/ast/printer/SourcePrinter.d.ts +0 -21
- package/dist/internal/ast/printer/SourcePrinter.js +0 -76
- package/dist/internal/ast/printer/index.d.ts +0 -6
- package/dist/internal/ast/printer/index.js +0 -126
- package/dist/internal/ast/types.d.ts +0 -190
- package/dist/internal/ast/types.js +0 -1
- package/dist/internal/capability/capability-resolver.d.ts +0 -16
- package/dist/internal/capability/capability-resolver.js +0 -127
- package/dist/internal/classname-source.d.ts +0 -24
- package/dist/internal/classname-source.js +0 -220
- package/dist/internal/contracts/IEditEngineRuntime.d.ts +0 -18
- package/dist/internal/contracts/IEditEngineRuntime.js +0 -1
- package/dist/internal/domain/EditDiagnostic.d.ts +0 -38
- package/dist/internal/domain/EditDiagnostic.js +0 -43
- package/dist/internal/events/event-bus.d.ts +0 -14
- package/dist/internal/events/event-bus.js +0 -21
- package/dist/internal/graph/graph-builder.d.ts +0 -12
- package/dist/internal/graph/graph-builder.js +0 -1371
- package/dist/internal/graph/import-resolver.d.ts +0 -31
- package/dist/internal/graph/import-resolver.js +0 -109
- package/dist/internal/graph/project-graph-builder.d.ts +0 -32
- package/dist/internal/graph/project-graph-builder.js +0 -133
- package/dist/internal/graph/types.d.ts +0 -114
- package/dist/internal/graph/types.js +0 -6
- package/dist/internal/history/undo-redo.d.ts +0 -28
- package/dist/internal/history/undo-redo.js +0 -42
- package/dist/internal/index.d.ts +0 -2
- package/dist/internal/index.js +0 -1
- package/dist/internal/planner/planner.d.ts +0 -104
- package/dist/internal/planner/planner.js +0 -2533
- package/dist/internal/planner/types.d.ts +0 -275
- package/dist/internal/planner/types.js +0 -6
- package/dist/internal/protocol/boundary.js +0 -3
- package/dist/internal/protocol/capability.js +0 -8
- package/dist/internal/protocol/error.js +0 -38
- package/dist/internal/protocol/event.js +0 -3
- package/dist/internal/protocol/identity.js +0 -30
- package/dist/internal/protocol/operation.js +0 -8
- package/dist/internal/protocol/render.js +0 -3
- package/dist/internal/protocol.js +0 -2
- package/dist/internal/provenance/binding-graph.d.ts +0 -39
- package/dist/internal/provenance/binding-graph.js +0 -184
- package/dist/internal/provenance/capability-policy.d.ts +0 -15
- package/dist/internal/provenance/capability-policy.js +0 -96
- package/dist/internal/provenance/data-source-classifier.d.ts +0 -14
- package/dist/internal/provenance/data-source-classifier.js +0 -281
- package/dist/internal/provenance/resolve-text-provenance.d.ts +0 -45
- package/dist/internal/provenance/resolve-text-provenance.js +0 -3090
- package/dist/internal/provenance/types.d.ts +0 -89
- package/dist/internal/provenance/types.js +0 -1
- package/dist/internal/render/component-semantic.d.ts +0 -11
- package/dist/internal/render/component-semantic.js +0 -141
- package/dist/internal/render/content-model.d.ts +0 -3
- package/dist/internal/render/content-model.js +0 -89
- package/dist/internal/render/media-model.d.ts +0 -3
- package/dist/internal/render/media-model.js +0 -45
- package/dist/internal/render/provenance-types.d.ts +0 -33
- package/dist/internal/render/provenance-types.js +0 -1
- package/dist/internal/render/render-projection.d.ts +0 -24
- package/dist/internal/render/render-projection.js +0 -281
- package/dist/internal/render/tailwind-style-model.d.ts +0 -19
- package/dist/internal/render/tailwind-style-model.js +0 -1187
- package/dist/internal/runtime/EditEngineRuntime.d.ts +0 -25
- package/dist/internal/runtime/EditEngineRuntime.js +0 -89
- package/dist/internal/runtime/EditEngineRuntimeSnapshot.d.ts +0 -31
- package/dist/internal/runtime/EditEngineRuntimeSnapshot.js +0 -15
- package/dist/internal/runtime/InternalEditEngine.d.ts +0 -44
- package/dist/internal/runtime/InternalEditEngine.js +0 -1391
- package/dist/internal/runtime.d.ts +0 -3
- package/dist/internal/runtime.js +0 -1
- package/dist/internal/topology/topology.d.ts +0 -6
- package/dist/internal/topology/topology.js +0 -98
- package/dist/internal/topology/types.d.ts +0 -35
- package/dist/internal/topology/types.js +0 -5
- package/dist/internal/types.d.ts +0 -1
- package/dist/internal/types.js +0 -1
- package/dist/internal/writeback/in-memory-fs.d.ts +0 -7
- package/dist/internal/writeback/in-memory-fs.js +0 -44
- package/dist/internal/writeback/types.d.ts +0 -45
- package/dist/internal/writeback/types.js +0 -7
- package/dist/internal/writeback/writeback-service.d.ts +0 -7
- package/dist/internal/writeback/writeback-service.js +0 -568
- package/dist/internal-adapter.d.ts +0 -18
- package/dist/internal-adapter.js +0 -350
- package/dist/next-app-router-fs.js +0 -64
- package/dist/preview-runtime.js +0 -102
- package/dist/public-file-system.js +0 -1
- package/dist/runtime-sync.js +0 -321
- package/dist/runtime.js +0 -134
- package/dist/site-edit-instrumentation.js +0 -322
- package/dist/snapshot-file-system.d.ts +0 -19
- package/dist/snapshot-file-system.js +0 -49
- package/dist/source-writeback-test-harness.d.ts +0 -244
- package/dist/source-writeback-test-harness.js +0 -119
- package/dist/types.js +0 -1
|
@@ -1,1187 +0,0 @@
|
|
|
1
|
-
const RESPONSIVE_BREAKPOINTS = new Set([
|
|
2
|
-
"sm",
|
|
3
|
-
"md",
|
|
4
|
-
"lg",
|
|
5
|
-
"xl",
|
|
6
|
-
"2xl",
|
|
7
|
-
]);
|
|
8
|
-
const STATE_VARIANTS = new Set([
|
|
9
|
-
"hover",
|
|
10
|
-
"active",
|
|
11
|
-
"focus",
|
|
12
|
-
"disabled",
|
|
13
|
-
]);
|
|
14
|
-
const DISPLAY_TOKENS = [
|
|
15
|
-
"block",
|
|
16
|
-
"inline-block",
|
|
17
|
-
"inline",
|
|
18
|
-
"flex",
|
|
19
|
-
"inline-flex",
|
|
20
|
-
"grid",
|
|
21
|
-
"inline-grid",
|
|
22
|
-
"hidden",
|
|
23
|
-
];
|
|
24
|
-
const POSITION_TOKENS = [
|
|
25
|
-
"static",
|
|
26
|
-
"fixed",
|
|
27
|
-
"absolute",
|
|
28
|
-
"relative",
|
|
29
|
-
"sticky",
|
|
30
|
-
];
|
|
31
|
-
const Z_INDEX_TOKENS = [
|
|
32
|
-
"z-auto",
|
|
33
|
-
"z-0",
|
|
34
|
-
"z-10",
|
|
35
|
-
"z-20",
|
|
36
|
-
"z-30",
|
|
37
|
-
"z-40",
|
|
38
|
-
"z-50",
|
|
39
|
-
];
|
|
40
|
-
const FLEX_DIRECTION_TOKENS = [
|
|
41
|
-
"flex-row",
|
|
42
|
-
"flex-row-reverse",
|
|
43
|
-
"flex-col",
|
|
44
|
-
"flex-col-reverse",
|
|
45
|
-
];
|
|
46
|
-
const FLEX_WRAP_TOKENS = [
|
|
47
|
-
"flex-nowrap",
|
|
48
|
-
"flex-wrap",
|
|
49
|
-
"flex-wrap-reverse",
|
|
50
|
-
];
|
|
51
|
-
const FLEX_GROW_TOKENS = ["grow", "grow-0"];
|
|
52
|
-
const FLEX_SHRINK_TOKENS = ["shrink", "shrink-0"];
|
|
53
|
-
const FLEX_BASIS_TOKENS = [
|
|
54
|
-
"basis-auto",
|
|
55
|
-
"basis-full",
|
|
56
|
-
"basis-1/2",
|
|
57
|
-
"basis-1/3",
|
|
58
|
-
"basis-2/3",
|
|
59
|
-
"basis-1/4",
|
|
60
|
-
"basis-3/4",
|
|
61
|
-
"basis-px",
|
|
62
|
-
];
|
|
63
|
-
const ORDER_TOKENS = [
|
|
64
|
-
"order-first",
|
|
65
|
-
"order-last",
|
|
66
|
-
"order-none",
|
|
67
|
-
"order-1",
|
|
68
|
-
"order-2",
|
|
69
|
-
"order-3",
|
|
70
|
-
"order-4",
|
|
71
|
-
"order-5",
|
|
72
|
-
"order-6",
|
|
73
|
-
];
|
|
74
|
-
const GRID_TEMPLATE_COLUMNS_TOKENS = [
|
|
75
|
-
"grid-cols-1",
|
|
76
|
-
"grid-cols-2",
|
|
77
|
-
"grid-cols-3",
|
|
78
|
-
"grid-cols-4",
|
|
79
|
-
"grid-cols-5",
|
|
80
|
-
"grid-cols-6",
|
|
81
|
-
"grid-cols-12",
|
|
82
|
-
"grid-cols-none",
|
|
83
|
-
"grid-cols-subgrid",
|
|
84
|
-
];
|
|
85
|
-
const GRID_TEMPLATE_ROWS_TOKENS = [
|
|
86
|
-
"grid-rows-1",
|
|
87
|
-
"grid-rows-2",
|
|
88
|
-
"grid-rows-3",
|
|
89
|
-
"grid-rows-4",
|
|
90
|
-
"grid-rows-5",
|
|
91
|
-
"grid-rows-6",
|
|
92
|
-
"grid-rows-none",
|
|
93
|
-
"grid-rows-subgrid",
|
|
94
|
-
];
|
|
95
|
-
const GRID_COLUMN_TOKENS = [
|
|
96
|
-
"col-auto",
|
|
97
|
-
"col-span-1",
|
|
98
|
-
"col-span-2",
|
|
99
|
-
"col-span-3",
|
|
100
|
-
"col-span-4",
|
|
101
|
-
"col-span-6",
|
|
102
|
-
"col-span-12",
|
|
103
|
-
"col-span-full",
|
|
104
|
-
];
|
|
105
|
-
const GRID_ROW_TOKENS = [
|
|
106
|
-
"row-auto",
|
|
107
|
-
"row-span-1",
|
|
108
|
-
"row-span-2",
|
|
109
|
-
"row-span-3",
|
|
110
|
-
"row-span-4",
|
|
111
|
-
"row-span-6",
|
|
112
|
-
"row-span-full",
|
|
113
|
-
];
|
|
114
|
-
const ALIGN_ITEMS_TOKENS = [
|
|
115
|
-
"items-start",
|
|
116
|
-
"items-end",
|
|
117
|
-
"items-center",
|
|
118
|
-
"items-baseline",
|
|
119
|
-
"items-stretch",
|
|
120
|
-
];
|
|
121
|
-
const JUSTIFY_CONTENT_TOKENS = [
|
|
122
|
-
"justify-normal",
|
|
123
|
-
"justify-start",
|
|
124
|
-
"justify-end",
|
|
125
|
-
"justify-center",
|
|
126
|
-
"justify-between",
|
|
127
|
-
"justify-around",
|
|
128
|
-
"justify-evenly",
|
|
129
|
-
"justify-stretch",
|
|
130
|
-
];
|
|
131
|
-
const OVERFLOW_TOKENS = [
|
|
132
|
-
"overflow-auto",
|
|
133
|
-
"overflow-hidden",
|
|
134
|
-
"overflow-clip",
|
|
135
|
-
"overflow-visible",
|
|
136
|
-
"overflow-scroll",
|
|
137
|
-
];
|
|
138
|
-
const FONT_FAMILY_TOKENS = ["font-sans", "font-serif", "font-mono"];
|
|
139
|
-
const FONT_WEIGHT_TOKENS = [
|
|
140
|
-
"font-thin",
|
|
141
|
-
"font-extralight",
|
|
142
|
-
"font-light",
|
|
143
|
-
"font-normal",
|
|
144
|
-
"font-medium",
|
|
145
|
-
"font-semibold",
|
|
146
|
-
"font-bold",
|
|
147
|
-
"font-extrabold",
|
|
148
|
-
"font-black",
|
|
149
|
-
];
|
|
150
|
-
const FONT_SIZE_TOKENS = [
|
|
151
|
-
"text-xs",
|
|
152
|
-
"text-sm",
|
|
153
|
-
"text-base",
|
|
154
|
-
"text-lg",
|
|
155
|
-
"text-xl",
|
|
156
|
-
"text-2xl",
|
|
157
|
-
"text-3xl",
|
|
158
|
-
"text-4xl",
|
|
159
|
-
"text-5xl",
|
|
160
|
-
"text-6xl",
|
|
161
|
-
"text-7xl",
|
|
162
|
-
"text-8xl",
|
|
163
|
-
"text-9xl",
|
|
164
|
-
];
|
|
165
|
-
const TEXT_ALIGN_TOKENS = [
|
|
166
|
-
"text-left",
|
|
167
|
-
"text-center",
|
|
168
|
-
"text-right",
|
|
169
|
-
"text-justify",
|
|
170
|
-
"text-start",
|
|
171
|
-
"text-end",
|
|
172
|
-
];
|
|
173
|
-
const TEXT_TRANSFORM_TOKENS = [
|
|
174
|
-
"uppercase",
|
|
175
|
-
"lowercase",
|
|
176
|
-
"capitalize",
|
|
177
|
-
"normal-case",
|
|
178
|
-
];
|
|
179
|
-
const TEXT_DECORATION_TOKENS = [
|
|
180
|
-
"underline",
|
|
181
|
-
"overline",
|
|
182
|
-
"line-through",
|
|
183
|
-
"no-underline",
|
|
184
|
-
];
|
|
185
|
-
const TEXT_INDENT_TOKENS = [
|
|
186
|
-
"indent-0",
|
|
187
|
-
"indent-4",
|
|
188
|
-
"indent-8",
|
|
189
|
-
"indent-12",
|
|
190
|
-
];
|
|
191
|
-
const WRITING_MODE_TOKENS = [
|
|
192
|
-
"[writing-mode:horizontal-tb]",
|
|
193
|
-
"[writing-mode:vertical-rl]",
|
|
194
|
-
];
|
|
195
|
-
const WHITE_SPACE_TOKENS = [
|
|
196
|
-
"whitespace-normal",
|
|
197
|
-
"whitespace-nowrap",
|
|
198
|
-
"whitespace-pre",
|
|
199
|
-
"whitespace-pre-line",
|
|
200
|
-
"whitespace-pre-wrap",
|
|
201
|
-
"whitespace-break-spaces",
|
|
202
|
-
];
|
|
203
|
-
const WORD_BREAK_TOKENS = [
|
|
204
|
-
"break-normal",
|
|
205
|
-
"break-words",
|
|
206
|
-
"break-all",
|
|
207
|
-
"break-keep",
|
|
208
|
-
];
|
|
209
|
-
const LINE_CLAMP_TOKENS = [
|
|
210
|
-
"line-clamp-none",
|
|
211
|
-
"line-clamp-1",
|
|
212
|
-
"line-clamp-2",
|
|
213
|
-
"line-clamp-3",
|
|
214
|
-
"line-clamp-4",
|
|
215
|
-
"line-clamp-5",
|
|
216
|
-
"line-clamp-6",
|
|
217
|
-
];
|
|
218
|
-
const LETTER_SPACING_TOKENS = [
|
|
219
|
-
"tracking-tighter",
|
|
220
|
-
"tracking-tight",
|
|
221
|
-
"tracking-normal",
|
|
222
|
-
"tracking-wide",
|
|
223
|
-
"tracking-wider",
|
|
224
|
-
"tracking-widest",
|
|
225
|
-
];
|
|
226
|
-
const BORDER_STYLE_TOKENS = [
|
|
227
|
-
"border-solid",
|
|
228
|
-
"border-dashed",
|
|
229
|
-
"border-dotted",
|
|
230
|
-
"border-double",
|
|
231
|
-
"border-hidden",
|
|
232
|
-
"border-none",
|
|
233
|
-
];
|
|
234
|
-
const BORDER_WIDTH_TOKENS = [
|
|
235
|
-
"border",
|
|
236
|
-
"border-0",
|
|
237
|
-
"border-2",
|
|
238
|
-
"border-4",
|
|
239
|
-
"border-8",
|
|
240
|
-
];
|
|
241
|
-
const OBJECT_FIT_TOKENS = [
|
|
242
|
-
"object-contain",
|
|
243
|
-
"object-cover",
|
|
244
|
-
"object-fill",
|
|
245
|
-
"object-none",
|
|
246
|
-
"object-scale-down",
|
|
247
|
-
];
|
|
248
|
-
const ASPECT_RATIO_TOKENS = [
|
|
249
|
-
"aspect-auto",
|
|
250
|
-
"aspect-square",
|
|
251
|
-
"aspect-video",
|
|
252
|
-
];
|
|
253
|
-
const BOX_SHADOW_TOKENS = [
|
|
254
|
-
"shadow-none",
|
|
255
|
-
"shadow-sm",
|
|
256
|
-
"shadow",
|
|
257
|
-
"shadow-md",
|
|
258
|
-
"shadow-lg",
|
|
259
|
-
"shadow-xl",
|
|
260
|
-
"shadow-2xl",
|
|
261
|
-
];
|
|
262
|
-
const SPACING_VALUE_MAP = {
|
|
263
|
-
"0": "0",
|
|
264
|
-
"0px": "0",
|
|
265
|
-
"1px": "px",
|
|
266
|
-
"4px": "1",
|
|
267
|
-
"0.25rem": "1",
|
|
268
|
-
"8px": "2",
|
|
269
|
-
"0.5rem": "2",
|
|
270
|
-
"12px": "3",
|
|
271
|
-
"0.75rem": "3",
|
|
272
|
-
"16px": "4",
|
|
273
|
-
"1rem": "4",
|
|
274
|
-
"20px": "5",
|
|
275
|
-
"1.25rem": "5",
|
|
276
|
-
"24px": "6",
|
|
277
|
-
"1.5rem": "6",
|
|
278
|
-
"32px": "8",
|
|
279
|
-
"2rem": "8",
|
|
280
|
-
"40px": "10",
|
|
281
|
-
"2.5rem": "10",
|
|
282
|
-
"48px": "12",
|
|
283
|
-
"3rem": "12",
|
|
284
|
-
"64px": "16",
|
|
285
|
-
"4rem": "16",
|
|
286
|
-
};
|
|
287
|
-
const FONT_WEIGHT_VALUE_MAP = {
|
|
288
|
-
"100": "font-thin",
|
|
289
|
-
"200": "font-extralight",
|
|
290
|
-
"300": "font-light",
|
|
291
|
-
"400": "font-normal",
|
|
292
|
-
normal: "font-normal",
|
|
293
|
-
"500": "font-medium",
|
|
294
|
-
"600": "font-semibold",
|
|
295
|
-
"700": "font-bold",
|
|
296
|
-
bold: "font-bold",
|
|
297
|
-
"800": "font-extrabold",
|
|
298
|
-
"900": "font-black",
|
|
299
|
-
};
|
|
300
|
-
const TEXT_ALIGN_VALUE_MAP = {
|
|
301
|
-
left: "text-left",
|
|
302
|
-
center: "text-center",
|
|
303
|
-
right: "text-right",
|
|
304
|
-
justify: "text-justify",
|
|
305
|
-
start: "text-start",
|
|
306
|
-
end: "text-end",
|
|
307
|
-
};
|
|
308
|
-
const BORDER_RADIUS_VALUE_MAP = {
|
|
309
|
-
"0": "rounded-none",
|
|
310
|
-
"0px": "rounded-none",
|
|
311
|
-
"2px": "rounded-sm",
|
|
312
|
-
"4px": "rounded",
|
|
313
|
-
"6px": "rounded-md",
|
|
314
|
-
"8px": "rounded-lg",
|
|
315
|
-
"12px": "rounded-xl",
|
|
316
|
-
"16px": "rounded-2xl",
|
|
317
|
-
"24px": "rounded-3xl",
|
|
318
|
-
"9999px": "rounded-full",
|
|
319
|
-
};
|
|
320
|
-
const OPACITY_VALUE_MAP = {
|
|
321
|
-
"0": "opacity-0",
|
|
322
|
-
"0%": "opacity-0",
|
|
323
|
-
"0.05": "opacity-5",
|
|
324
|
-
"5%": "opacity-5",
|
|
325
|
-
"0.1": "opacity-10",
|
|
326
|
-
"10%": "opacity-10",
|
|
327
|
-
"0.25": "opacity-25",
|
|
328
|
-
"25%": "opacity-25",
|
|
329
|
-
"0.5": "opacity-50",
|
|
330
|
-
"50%": "opacity-50",
|
|
331
|
-
"0.75": "opacity-75",
|
|
332
|
-
"75%": "opacity-75",
|
|
333
|
-
"1": "opacity-100",
|
|
334
|
-
"100%": "opacity-100",
|
|
335
|
-
};
|
|
336
|
-
const COLOR_VALUE_MAP = {
|
|
337
|
-
"#111827": "gray-900",
|
|
338
|
-
"#1f2937": "gray-800",
|
|
339
|
-
"#374151": "gray-700",
|
|
340
|
-
"#4b5563": "gray-600",
|
|
341
|
-
"#6b7280": "gray-500",
|
|
342
|
-
"#9ca3af": "gray-400",
|
|
343
|
-
"#d1d5db": "gray-300",
|
|
344
|
-
"#e5e7eb": "gray-200",
|
|
345
|
-
"#f3f4f6": "gray-100",
|
|
346
|
-
"#f9fafb": "gray-50",
|
|
347
|
-
"#ffffff": "white",
|
|
348
|
-
white: "white",
|
|
349
|
-
"#000000": "black",
|
|
350
|
-
black: "black",
|
|
351
|
-
};
|
|
352
|
-
export const TAILWIND_STYLE_RULES = [
|
|
353
|
-
{
|
|
354
|
-
property: "display",
|
|
355
|
-
exact: DISPLAY_TOKENS,
|
|
356
|
-
isMatch: (token) => token === "gallery-item",
|
|
357
|
-
options: [...DISPLAY_TOKENS],
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
property: "position",
|
|
361
|
-
exact: POSITION_TOKENS,
|
|
362
|
-
isMatch: (token) => token === "cta-shine",
|
|
363
|
-
options: [...POSITION_TOKENS],
|
|
364
|
-
},
|
|
365
|
-
{ property: "top", isMatch: (token) => isInsetSideToken("top", token) },
|
|
366
|
-
{
|
|
367
|
-
property: "right",
|
|
368
|
-
isMatch: (token) => isInsetSideToken("right", token),
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
property: "bottom",
|
|
372
|
-
isMatch: (token) => isInsetSideToken("bottom", token),
|
|
373
|
-
},
|
|
374
|
-
{ property: "left", isMatch: (token) => isInsetSideToken("left", token) },
|
|
375
|
-
{
|
|
376
|
-
property: "zIndex",
|
|
377
|
-
exact: Z_INDEX_TOKENS,
|
|
378
|
-
isMatch: isZIndexToken,
|
|
379
|
-
options: [...Z_INDEX_TOKENS],
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
property: "flexDirection",
|
|
383
|
-
exact: FLEX_DIRECTION_TOKENS,
|
|
384
|
-
options: [...FLEX_DIRECTION_TOKENS],
|
|
385
|
-
},
|
|
386
|
-
{
|
|
387
|
-
property: "flexWrap",
|
|
388
|
-
exact: FLEX_WRAP_TOKENS,
|
|
389
|
-
options: [...FLEX_WRAP_TOKENS],
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
property: "flexGrow",
|
|
393
|
-
exact: FLEX_GROW_TOKENS,
|
|
394
|
-
isMatch: (token) => FLEX_GROW_TOKENS.includes(token) ||
|
|
395
|
-
/^grow-\[.+\]$/.test(token),
|
|
396
|
-
options: [...FLEX_GROW_TOKENS],
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
property: "flexShrink",
|
|
400
|
-
exact: FLEX_SHRINK_TOKENS,
|
|
401
|
-
isMatch: (token) => FLEX_SHRINK_TOKENS.includes(token) ||
|
|
402
|
-
/^shrink-\[.+\]$/.test(token) ||
|
|
403
|
-
/^flex-shrink-(?:0|\[.+\])$/.test(token),
|
|
404
|
-
options: [...FLEX_SHRINK_TOKENS],
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
property: "flexBasis",
|
|
408
|
-
exact: FLEX_BASIS_TOKENS,
|
|
409
|
-
isMatch: isFlexBasisToken,
|
|
410
|
-
options: [...FLEX_BASIS_TOKENS],
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
property: "flex",
|
|
414
|
-
isMatch: (token) => /^flex-(?:\d+|auto|initial|none|\[.+\])$/.test(token),
|
|
415
|
-
},
|
|
416
|
-
{
|
|
417
|
-
property: "order",
|
|
418
|
-
exact: ORDER_TOKENS,
|
|
419
|
-
isMatch: isOrderToken,
|
|
420
|
-
options: [...ORDER_TOKENS],
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
property: "gridTemplateColumns",
|
|
424
|
-
exact: GRID_TEMPLATE_COLUMNS_TOKENS,
|
|
425
|
-
isMatch: isGridTemplateColumnsToken,
|
|
426
|
-
options: [...GRID_TEMPLATE_COLUMNS_TOKENS],
|
|
427
|
-
},
|
|
428
|
-
{
|
|
429
|
-
property: "gridTemplateRows",
|
|
430
|
-
exact: GRID_TEMPLATE_ROWS_TOKENS,
|
|
431
|
-
isMatch: isGridTemplateRowsToken,
|
|
432
|
-
options: [...GRID_TEMPLATE_ROWS_TOKENS],
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
property: "columns",
|
|
436
|
-
isMatch: (token) => token === "gallery-grid" ||
|
|
437
|
-
/^columns-(?:\d+|auto|3xs|2xs|xs|sm|md|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|\[.+\])$/.test(token),
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
property: "gridColumn",
|
|
441
|
-
exact: GRID_COLUMN_TOKENS,
|
|
442
|
-
isMatch: isGridColumnToken,
|
|
443
|
-
options: [...GRID_COLUMN_TOKENS],
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
property: "gridRow",
|
|
447
|
-
exact: GRID_ROW_TOKENS,
|
|
448
|
-
isMatch: isGridRowToken,
|
|
449
|
-
options: [...GRID_ROW_TOKENS],
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
property: "gap",
|
|
453
|
-
prefix: "gap-",
|
|
454
|
-
isMatch: (token) => token.startsWith("gap-") &&
|
|
455
|
-
!token.startsWith("gap-x-") &&
|
|
456
|
-
!token.startsWith("gap-y-"),
|
|
457
|
-
},
|
|
458
|
-
{ property: "gapX", prefix: "gap-x-" },
|
|
459
|
-
{ property: "gapY", prefix: "gap-y-" },
|
|
460
|
-
{ property: "spaceX", prefix: "space-x-" },
|
|
461
|
-
{ property: "spaceY", prefix: "space-y-" },
|
|
462
|
-
{
|
|
463
|
-
property: "alignItems",
|
|
464
|
-
exact: ALIGN_ITEMS_TOKENS,
|
|
465
|
-
options: [...ALIGN_ITEMS_TOKENS],
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
property: "alignSelf",
|
|
469
|
-
isMatch: (token) => /^self-(?:auto|start|end|center|stretch|baseline)$/.test(token),
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
property: "justifyContent",
|
|
473
|
-
exact: JUSTIFY_CONTENT_TOKENS,
|
|
474
|
-
options: [...JUSTIFY_CONTENT_TOKENS],
|
|
475
|
-
},
|
|
476
|
-
{
|
|
477
|
-
property: "marginTop",
|
|
478
|
-
isMatch: (token) => isBoxSideToken("m", "t", token),
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
property: "marginRight",
|
|
482
|
-
isMatch: (token) => isBoxSideToken("m", "r", token),
|
|
483
|
-
},
|
|
484
|
-
{
|
|
485
|
-
property: "marginBottom",
|
|
486
|
-
isMatch: (token) => isBoxSideToken("m", "b", token),
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
property: "marginLeft",
|
|
490
|
-
isMatch: (token) => isBoxSideToken("m", "l", token),
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
property: "paddingTop",
|
|
494
|
-
isMatch: (token) => isBoxSideToken("p", "t", token),
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
property: "paddingRight",
|
|
498
|
-
isMatch: (token) => isBoxSideToken("p", "r", token),
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
property: "paddingBottom",
|
|
502
|
-
isMatch: (token) => isBoxSideToken("p", "b", token),
|
|
503
|
-
},
|
|
504
|
-
{
|
|
505
|
-
property: "paddingLeft",
|
|
506
|
-
isMatch: (token) => isBoxSideToken("p", "l", token),
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
property: "width",
|
|
510
|
-
isMatch: (token) => token.startsWith("w-") || isSizeToken(token),
|
|
511
|
-
},
|
|
512
|
-
{
|
|
513
|
-
property: "height",
|
|
514
|
-
isMatch: (token) => token.startsWith("h-") || isSizeToken(token),
|
|
515
|
-
},
|
|
516
|
-
{ property: "minWidth", prefix: "min-w-" },
|
|
517
|
-
{ property: "minHeight", prefix: "min-h-" },
|
|
518
|
-
{
|
|
519
|
-
property: "maxWidth",
|
|
520
|
-
isMatch: (token) => token === "container" || token.startsWith("max-w-"),
|
|
521
|
-
},
|
|
522
|
-
{ property: "maxHeight", prefix: "max-h-" },
|
|
523
|
-
{
|
|
524
|
-
property: "overflow",
|
|
525
|
-
exact: OVERFLOW_TOKENS,
|
|
526
|
-
isMatch: (token) => /^overflow(?:-[xy])?-.+$/.test(token),
|
|
527
|
-
options: [...OVERFLOW_TOKENS],
|
|
528
|
-
},
|
|
529
|
-
{
|
|
530
|
-
property: "fontFamily",
|
|
531
|
-
exact: FONT_FAMILY_TOKENS,
|
|
532
|
-
isMatch: (token) => FONT_FAMILY_TOKENS.includes(token) ||
|
|
533
|
-
/^font-\[.+\]$/.test(token) ||
|
|
534
|
-
(/^font-[a-z][\w-]*$/.test(token) && !isFontWeightToken(token)),
|
|
535
|
-
options: [...FONT_FAMILY_TOKENS],
|
|
536
|
-
},
|
|
537
|
-
{
|
|
538
|
-
property: "fontSize",
|
|
539
|
-
exact: FONT_SIZE_TOKENS,
|
|
540
|
-
isMatch: isFontSizeToken,
|
|
541
|
-
options: [...FONT_SIZE_TOKENS],
|
|
542
|
-
},
|
|
543
|
-
{
|
|
544
|
-
property: "fontWeight",
|
|
545
|
-
exact: FONT_WEIGHT_TOKENS,
|
|
546
|
-
options: [...FONT_WEIGHT_TOKENS],
|
|
547
|
-
},
|
|
548
|
-
{ property: "lineHeight", prefix: "leading-" },
|
|
549
|
-
{
|
|
550
|
-
property: "letterSpacing",
|
|
551
|
-
exact: LETTER_SPACING_TOKENS,
|
|
552
|
-
isMatch: (token) => LETTER_SPACING_TOKENS.includes(token) || token.startsWith("tracking-["),
|
|
553
|
-
options: [...LETTER_SPACING_TOKENS],
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
property: "textAlign",
|
|
557
|
-
exact: TEXT_ALIGN_TOKENS,
|
|
558
|
-
options: [...TEXT_ALIGN_TOKENS],
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
property: "textTransform",
|
|
562
|
-
exact: TEXT_TRANSFORM_TOKENS,
|
|
563
|
-
options: [...TEXT_TRANSFORM_TOKENS],
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
property: "textDecoration",
|
|
567
|
-
exact: TEXT_DECORATION_TOKENS,
|
|
568
|
-
options: [...TEXT_DECORATION_TOKENS],
|
|
569
|
-
},
|
|
570
|
-
{
|
|
571
|
-
property: "textOverflow",
|
|
572
|
-
exact: ["truncate", "text-ellipsis", "text-clip"],
|
|
573
|
-
},
|
|
574
|
-
{ property: "fontStyle", exact: ["italic", "not-italic"] },
|
|
575
|
-
{ property: "textUnderlineOffset", prefix: "underline-offset-" },
|
|
576
|
-
{
|
|
577
|
-
property: "textIndent",
|
|
578
|
-
exact: TEXT_INDENT_TOKENS,
|
|
579
|
-
isMatch: isTextIndentToken,
|
|
580
|
-
options: [...TEXT_INDENT_TOKENS],
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
property: "writingMode",
|
|
584
|
-
exact: WRITING_MODE_TOKENS,
|
|
585
|
-
options: [...WRITING_MODE_TOKENS],
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
property: "whiteSpace",
|
|
589
|
-
exact: WHITE_SPACE_TOKENS,
|
|
590
|
-
options: [...WHITE_SPACE_TOKENS],
|
|
591
|
-
},
|
|
592
|
-
{
|
|
593
|
-
property: "wordBreak",
|
|
594
|
-
exact: WORD_BREAK_TOKENS,
|
|
595
|
-
options: [...WORD_BREAK_TOKENS],
|
|
596
|
-
},
|
|
597
|
-
{
|
|
598
|
-
property: "lineClamp",
|
|
599
|
-
exact: LINE_CLAMP_TOKENS,
|
|
600
|
-
isMatch: isLineClampToken,
|
|
601
|
-
options: [...LINE_CLAMP_TOKENS],
|
|
602
|
-
},
|
|
603
|
-
{
|
|
604
|
-
property: "fontVariantNumeric",
|
|
605
|
-
isMatch: (token) => /^(?:normal-nums|ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions)$/.test(token),
|
|
606
|
-
},
|
|
607
|
-
{ property: "screenReaderOnly", exact: ["sr-only", "not-sr-only"] },
|
|
608
|
-
{ property: "color", isMatch: isTextColorToken },
|
|
609
|
-
{ property: "backgroundColor", isMatch: isBackgroundColorToken },
|
|
610
|
-
{
|
|
611
|
-
property: "backgroundImage",
|
|
612
|
-
isMatch: (token) => token.startsWith("bg-[url") || token.startsWith("bg-gradient-"),
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
property: "borderStyle",
|
|
616
|
-
exact: BORDER_STYLE_TOKENS,
|
|
617
|
-
options: [...BORDER_STYLE_TOKENS],
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
property: "borderWidth",
|
|
621
|
-
exact: BORDER_WIDTH_TOKENS,
|
|
622
|
-
isMatch: isBorderWidthToken,
|
|
623
|
-
options: [...BORDER_WIDTH_TOKENS],
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
property: "divideWidth",
|
|
627
|
-
isMatch: (token) => /^divide-[xy](?:-\d+|-0|-reverse)?$/.test(token),
|
|
628
|
-
},
|
|
629
|
-
{ property: "borderRadius", prefix: "rounded" },
|
|
630
|
-
{ property: "borderColor", isMatch: isBorderColorToken },
|
|
631
|
-
{
|
|
632
|
-
property: "divideColor",
|
|
633
|
-
isMatch: (token) => token.startsWith("divide-") &&
|
|
634
|
-
!/^divide-[xy](?:-\d+|-0|-reverse)?$/.test(token),
|
|
635
|
-
},
|
|
636
|
-
{
|
|
637
|
-
property: "objectFit",
|
|
638
|
-
exact: OBJECT_FIT_TOKENS,
|
|
639
|
-
options: [...OBJECT_FIT_TOKENS],
|
|
640
|
-
},
|
|
641
|
-
{
|
|
642
|
-
property: "objectPosition",
|
|
643
|
-
isMatch: (token) => /^object-(?:bottom|center|left|left-bottom|left-top|right|right-bottom|right-top|top|\[.+\])$/.test(token),
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
property: "aspectRatio",
|
|
647
|
-
exact: ASPECT_RATIO_TOKENS,
|
|
648
|
-
isMatch: isAspectRatioToken,
|
|
649
|
-
options: [...ASPECT_RATIO_TOKENS],
|
|
650
|
-
},
|
|
651
|
-
{ property: "opacity", prefix: "opacity-" },
|
|
652
|
-
{
|
|
653
|
-
property: "boxShadow",
|
|
654
|
-
exact: BOX_SHADOW_TOKENS,
|
|
655
|
-
isMatch: isBoxShadowToken,
|
|
656
|
-
options: [...BOX_SHADOW_TOKENS],
|
|
657
|
-
},
|
|
658
|
-
{ property: "transform", isMatch: isTransformToken },
|
|
659
|
-
{
|
|
660
|
-
property: "transformOrigin",
|
|
661
|
-
isMatch: (token) => /^origin-(?:center|top|top-right|right|bottom-right|bottom|bottom-left|left|top-left|\[.+\])$/.test(token),
|
|
662
|
-
},
|
|
663
|
-
{
|
|
664
|
-
property: "transitionProperty",
|
|
665
|
-
isMatch: (token) => /^transition(?:-(?:none|all|colors|opacity|shadow|transform|\[.+\]))?$/.test(token) ||
|
|
666
|
-
[
|
|
667
|
-
"motion-link",
|
|
668
|
-
"image-zoom",
|
|
669
|
-
"card-lift",
|
|
670
|
-
"cta-shine",
|
|
671
|
-
"gallery-item-img",
|
|
672
|
-
"showcase-img",
|
|
673
|
-
].includes(token),
|
|
674
|
-
},
|
|
675
|
-
{
|
|
676
|
-
property: "transitionDuration",
|
|
677
|
-
isMatch: (token) => /^duration-(?:\d+|slow|\[.+\])$/.test(token),
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
property: "transitionTimingFunction",
|
|
681
|
-
isMatch: (token) => /^ease-(?:linear|in|out|in-out|\[.+\])$/.test(token),
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
property: "animation",
|
|
685
|
-
isMatch: (token) => /^(?:animate-.+|fade-.+|slide-in-.+)$/.test(token) ||
|
|
686
|
-
[
|
|
687
|
-
"section-reveal",
|
|
688
|
-
"scroll-reveal",
|
|
689
|
-
"first-viewport-entrance",
|
|
690
|
-
"media-reveal",
|
|
691
|
-
"media-entrance",
|
|
692
|
-
"gallery-fade-enter",
|
|
693
|
-
"number-pop",
|
|
694
|
-
].includes(token),
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
property: "pointerEvents",
|
|
698
|
-
exact: ["pointer-events-none", "pointer-events-auto"],
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
property: "cursor",
|
|
702
|
-
isMatch: (token) => /^cursor-(?:auto|default|pointer|wait|text|move|help|not-allowed|none|context-menu|progress|cell|crosshair|vertical-text|alias|copy|no-drop|grab|grabbing|all-scroll|col-resize|row-resize|n-resize|e-resize|s-resize|w-resize|ne-resize|nw-resize|se-resize|sw-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|zoom-in|zoom-out|\[.+\])$/.test(token),
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
property: "userSelect",
|
|
706
|
-
exact: ["select-none", "select-text", "select-all", "select-auto"],
|
|
707
|
-
},
|
|
708
|
-
{
|
|
709
|
-
property: "outlineStyle",
|
|
710
|
-
isMatch: (token) => /^outline(?:-(?:none|hidden|solid|dashed|dotted|double|\d+|\[.+\]))?$/.test(token),
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
property: "resize",
|
|
714
|
-
exact: ["resize-none", "resize", "resize-y", "resize-x"],
|
|
715
|
-
},
|
|
716
|
-
{
|
|
717
|
-
property: "ringWidth",
|
|
718
|
-
isMatch: (token) => /^ring(?:-\d+|-\[.+\]|-inset)?$/.test(token),
|
|
719
|
-
},
|
|
720
|
-
{
|
|
721
|
-
property: "ringColor",
|
|
722
|
-
isMatch: (token) => token.startsWith("ring-") &&
|
|
723
|
-
!/^ring(?:-\d+|-\[.+\]|-inset)?$/.test(token),
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
property: "backdropFilter",
|
|
727
|
-
isMatch: (token) => /^backdrop-(?:blur|brightness|contrast|grayscale|hue-rotate|invert|opacity|saturate|sepia)(?:-.+)?$/.test(token),
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
property: "overscrollBehavior",
|
|
731
|
-
isMatch: (token) => /^overscroll(?:-[xy])?-(?:auto|contain|none)$/.test(token),
|
|
732
|
-
},
|
|
733
|
-
{ property: "scrollMarginTop", prefix: "scroll-mt-" },
|
|
734
|
-
];
|
|
735
|
-
export function buildStyleModel(element) {
|
|
736
|
-
const source = buildStyleSource(element);
|
|
737
|
-
return createModel(source.className, source.editable, {
|
|
738
|
-
sourcePath: source.sourcePath,
|
|
739
|
-
diagnostics: source.diagnostics,
|
|
740
|
-
operationBoundary: source.operationBoundary,
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
export function buildStyleSource(element) {
|
|
744
|
-
const classAttribute = element.attributes?.find((attribute) => attribute.name === "className");
|
|
745
|
-
if (!classAttribute) {
|
|
746
|
-
return {
|
|
747
|
-
kind: "class-name-source",
|
|
748
|
-
className: "",
|
|
749
|
-
sourceKind: "missing",
|
|
750
|
-
editable: true,
|
|
751
|
-
operationBoundary: ["set-style-property", "set-style-properties"],
|
|
752
|
-
diagnostics: [
|
|
753
|
-
{
|
|
754
|
-
code: "missing-class-name",
|
|
755
|
-
message: "No className attribute is present on this element",
|
|
756
|
-
},
|
|
757
|
-
],
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
if (classAttribute.source?.expression) {
|
|
761
|
-
const expression = classAttribute.source.expression;
|
|
762
|
-
const resolvedValue = typeof classAttribute.resolvedValue === "string"
|
|
763
|
-
? classAttribute.resolvedValue
|
|
764
|
-
: classAttribute.value !== expression
|
|
765
|
-
? classAttribute.value
|
|
766
|
-
: undefined;
|
|
767
|
-
if (typeof resolvedValue !== "string") {
|
|
768
|
-
return {
|
|
769
|
-
kind: "class-name-source",
|
|
770
|
-
className: "",
|
|
771
|
-
sourceKind: "dynamic-expression",
|
|
772
|
-
editable: false,
|
|
773
|
-
operationBoundary: [],
|
|
774
|
-
sourcePath: expression,
|
|
775
|
-
diagnostics: [
|
|
776
|
-
{
|
|
777
|
-
code: classAttribute.resolvedValue === undefined
|
|
778
|
-
? "dynamic-binding"
|
|
779
|
-
: "non-string-binding",
|
|
780
|
-
message: classAttribute.resolvedValue === undefined
|
|
781
|
-
? "Style binding is dynamic and cannot be edited"
|
|
782
|
-
: "Style binding must resolve to a static string before it can be edited",
|
|
783
|
-
},
|
|
784
|
-
],
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
return {
|
|
788
|
-
kind: "class-name-source",
|
|
789
|
-
className: resolvedValue,
|
|
790
|
-
sourceKind: "static-expression",
|
|
791
|
-
editable: true,
|
|
792
|
-
operationBoundary: ["set-style-property", "set-style-properties"],
|
|
793
|
-
sourcePath: expression,
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
return {
|
|
797
|
-
kind: "class-name-source",
|
|
798
|
-
className: classAttribute.value,
|
|
799
|
-
sourceKind: classAttribute.resolvedValue === undefined
|
|
800
|
-
? "static-attribute"
|
|
801
|
-
: "static-expression",
|
|
802
|
-
editable: true,
|
|
803
|
-
operationBoundary: ["set-style-property", "set-style-properties"],
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
export function updateStylePropertyInClassName(currentValue, property, value, context = {}) {
|
|
807
|
-
const rule = getTailwindStyleRule(property);
|
|
808
|
-
if (!rule) {
|
|
809
|
-
return null;
|
|
810
|
-
}
|
|
811
|
-
const nextUtility = toTailwindStyleUtility(rule, value);
|
|
812
|
-
if (value !== null && !nextUtility) {
|
|
813
|
-
return null;
|
|
814
|
-
}
|
|
815
|
-
const nextTokens = splitClassTokens(currentValue).filter((currentToken) => !matchesTailwindStyleRule(rule, getUtilityToken(currentToken)) ||
|
|
816
|
-
!matchesTailwindStyleContext(currentToken, context));
|
|
817
|
-
if (nextUtility) {
|
|
818
|
-
nextTokens.push(formatTailwindStyleContextToken(nextUtility, context));
|
|
819
|
-
}
|
|
820
|
-
return dedupeTokens(nextTokens).join(" ");
|
|
821
|
-
}
|
|
822
|
-
export function matchesStyleProperty(property, token) {
|
|
823
|
-
const rule = getTailwindStyleRule(property);
|
|
824
|
-
return Boolean(rule && matchesTailwindStyleRule(rule, getUtilityToken(token)));
|
|
825
|
-
}
|
|
826
|
-
function createModel(className, editable, overrides = {}) {
|
|
827
|
-
const tokens = splitClassTokens(className);
|
|
828
|
-
const properties = TAILWIND_STYLE_RULES.flatMap((rule) => {
|
|
829
|
-
const matchedTokens = tokens
|
|
830
|
-
.map((token) => parseTailwindStyleToken(token))
|
|
831
|
-
.filter((token) => token !== null && matchesTailwindStyleRule(rule, token.utility));
|
|
832
|
-
const effectiveTokens = matchedTokens.filter((token, index) => {
|
|
833
|
-
const context = token.variants.join(":");
|
|
834
|
-
return (matchedTokens.findLastIndex((candidate) => candidate.variants.join(":") === context) === index);
|
|
835
|
-
});
|
|
836
|
-
const baseView = createPropertyView(rule, editable);
|
|
837
|
-
if (effectiveTokens.length === 0) {
|
|
838
|
-
return [baseView];
|
|
839
|
-
}
|
|
840
|
-
const hasBaseToken = effectiveTokens.some((token) => !token.breakpoint && !token.state);
|
|
841
|
-
return [
|
|
842
|
-
...(hasBaseToken ? [] : [baseView]),
|
|
843
|
-
...effectiveTokens.map((token) => createPropertyView(rule, editable, token)),
|
|
844
|
-
];
|
|
845
|
-
});
|
|
846
|
-
return {
|
|
847
|
-
kind: "css-style-model",
|
|
848
|
-
editable,
|
|
849
|
-
operationBoundary: editable
|
|
850
|
-
? ["set-style-property", "set-style-properties"]
|
|
851
|
-
: [],
|
|
852
|
-
properties,
|
|
853
|
-
...overrides,
|
|
854
|
-
};
|
|
855
|
-
}
|
|
856
|
-
function createPropertyView(rule, editable, token) {
|
|
857
|
-
return {
|
|
858
|
-
property: rule.property,
|
|
859
|
-
value: token?.raw ?? null,
|
|
860
|
-
editable,
|
|
861
|
-
operationBoundary: editable ? ["set-style-property"] : [],
|
|
862
|
-
...(token
|
|
863
|
-
? {
|
|
864
|
-
resolvedValue: token.raw,
|
|
865
|
-
...(token.breakpoint ? { breakpoint: token.breakpoint } : {}),
|
|
866
|
-
...(token.state ? { state: token.state } : {}),
|
|
867
|
-
...(token.variants.length ? { variants: token.variants } : {}),
|
|
868
|
-
}
|
|
869
|
-
: {}),
|
|
870
|
-
...(rule.options ? { options: rule.options } : {}),
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
function getTailwindStyleRule(property) {
|
|
874
|
-
return TAILWIND_STYLE_RULES.find((rule) => rule.property === property);
|
|
875
|
-
}
|
|
876
|
-
function toTailwindStyleUtility(rule, value) {
|
|
877
|
-
if (value === null) {
|
|
878
|
-
return null;
|
|
879
|
-
}
|
|
880
|
-
if (typeof value !== "string" &&
|
|
881
|
-
typeof value !== "number" &&
|
|
882
|
-
typeof value !== "boolean") {
|
|
883
|
-
return null;
|
|
884
|
-
}
|
|
885
|
-
const rawValue = String(value).trim();
|
|
886
|
-
if (!rawValue) {
|
|
887
|
-
return null;
|
|
888
|
-
}
|
|
889
|
-
const utility = parseTailwindStyleToken(rawValue)?.utility ?? rawValue;
|
|
890
|
-
if (matchesTailwindStyleRule(rule, utility)) {
|
|
891
|
-
return utility;
|
|
892
|
-
}
|
|
893
|
-
const mapped = mapCssValueToTailwindUtility(rule, rawValue);
|
|
894
|
-
if (mapped && matchesTailwindStyleRule(rule, mapped)) {
|
|
895
|
-
return mapped;
|
|
896
|
-
}
|
|
897
|
-
return null;
|
|
898
|
-
}
|
|
899
|
-
function mapCssValueToTailwindUtility(rule, rawValue) {
|
|
900
|
-
const normalized = rawValue.toLowerCase();
|
|
901
|
-
switch (rule.property) {
|
|
902
|
-
case "fontWeight":
|
|
903
|
-
return FONT_WEIGHT_VALUE_MAP[normalized] ?? null;
|
|
904
|
-
case "textAlign":
|
|
905
|
-
return TEXT_ALIGN_VALUE_MAP[normalized] ?? null;
|
|
906
|
-
case "borderRadius":
|
|
907
|
-
return BORDER_RADIUS_VALUE_MAP[normalized] ?? null;
|
|
908
|
-
case "opacity":
|
|
909
|
-
return OPACITY_VALUE_MAP[normalized] ?? null;
|
|
910
|
-
case "color":
|
|
911
|
-
return COLOR_VALUE_MAP[normalized]
|
|
912
|
-
? `text-${COLOR_VALUE_MAP[normalized]}`
|
|
913
|
-
: null;
|
|
914
|
-
case "backgroundColor":
|
|
915
|
-
return COLOR_VALUE_MAP[normalized]
|
|
916
|
-
? `bg-${COLOR_VALUE_MAP[normalized]}`
|
|
917
|
-
: null;
|
|
918
|
-
case "borderColor":
|
|
919
|
-
return COLOR_VALUE_MAP[normalized]
|
|
920
|
-
? `border-${COLOR_VALUE_MAP[normalized]}`
|
|
921
|
-
: null;
|
|
922
|
-
default:
|
|
923
|
-
break;
|
|
924
|
-
}
|
|
925
|
-
if (rule.prefix) {
|
|
926
|
-
const scale = SPACING_VALUE_MAP[normalized];
|
|
927
|
-
return scale ? `${rule.prefix}${scale}` : null;
|
|
928
|
-
}
|
|
929
|
-
return null;
|
|
930
|
-
}
|
|
931
|
-
function matchesTailwindStyleRule(rule, rawToken) {
|
|
932
|
-
const token = getUtilityToken(rawToken);
|
|
933
|
-
if (!token) {
|
|
934
|
-
return false;
|
|
935
|
-
}
|
|
936
|
-
if (!hasCleanTailwindUtilitySyntax(token)) {
|
|
937
|
-
return false;
|
|
938
|
-
}
|
|
939
|
-
if (rule.isMatch?.(token)) {
|
|
940
|
-
return true;
|
|
941
|
-
}
|
|
942
|
-
if (rule.exact?.includes(token)) {
|
|
943
|
-
return true;
|
|
944
|
-
}
|
|
945
|
-
if (rule.prefix) {
|
|
946
|
-
return (isPrefixUtilityBaseToken(rule.prefix, token) ||
|
|
947
|
-
token.startsWith(rule.prefix));
|
|
948
|
-
}
|
|
949
|
-
return false;
|
|
950
|
-
}
|
|
951
|
-
function getUtilityToken(rawToken) {
|
|
952
|
-
return parseTailwindStyleToken(rawToken)?.utility ?? rawToken.trim();
|
|
953
|
-
}
|
|
954
|
-
function parseTailwindStyleToken(rawToken) {
|
|
955
|
-
const segments = splitTailwindTokenSegments(rawToken);
|
|
956
|
-
const utility = segments[segments.length - 1];
|
|
957
|
-
if (!utility) {
|
|
958
|
-
return null;
|
|
959
|
-
}
|
|
960
|
-
const variants = segments.slice(0, -1);
|
|
961
|
-
const breakpoint = variants.find((variant) => RESPONSIVE_BREAKPOINTS.has(variant));
|
|
962
|
-
const state = variants.find((variant) => STATE_VARIANTS.has(variant));
|
|
963
|
-
return {
|
|
964
|
-
raw: rawToken.trim(),
|
|
965
|
-
utility,
|
|
966
|
-
...(breakpoint ? { breakpoint } : {}),
|
|
967
|
-
...(state ? { state } : {}),
|
|
968
|
-
variants,
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
function matchesTailwindStyleContext(rawToken, context) {
|
|
972
|
-
const parsed = parseTailwindStyleToken(rawToken);
|
|
973
|
-
if (!parsed) {
|
|
974
|
-
return false;
|
|
975
|
-
}
|
|
976
|
-
return ((context.breakpoint ?? undefined) === parsed.breakpoint &&
|
|
977
|
-
(context.state ?? undefined) === parsed.state);
|
|
978
|
-
}
|
|
979
|
-
function formatTailwindStyleContextToken(token, context) {
|
|
980
|
-
const utility = parseTailwindStyleToken(token)?.utility ?? token.trim();
|
|
981
|
-
const variants = [context.breakpoint, context.state].filter((variant) => Boolean(variant));
|
|
982
|
-
return variants.length ? `${variants.join(":")}:${utility}` : utility;
|
|
983
|
-
}
|
|
984
|
-
function splitTailwindTokenSegments(rawToken) {
|
|
985
|
-
const segments = [];
|
|
986
|
-
let current = "";
|
|
987
|
-
let bracketDepth = 0;
|
|
988
|
-
for (const character of rawToken.trim()) {
|
|
989
|
-
if (character === "[") {
|
|
990
|
-
bracketDepth += 1;
|
|
991
|
-
current += character;
|
|
992
|
-
continue;
|
|
993
|
-
}
|
|
994
|
-
if (character === "]") {
|
|
995
|
-
bracketDepth = Math.max(0, bracketDepth - 1);
|
|
996
|
-
current += character;
|
|
997
|
-
continue;
|
|
998
|
-
}
|
|
999
|
-
if (character === ":" && bracketDepth === 0) {
|
|
1000
|
-
if (current) {
|
|
1001
|
-
segments.push(current);
|
|
1002
|
-
}
|
|
1003
|
-
current = "";
|
|
1004
|
-
continue;
|
|
1005
|
-
}
|
|
1006
|
-
current += character;
|
|
1007
|
-
}
|
|
1008
|
-
if (current) {
|
|
1009
|
-
segments.push(current);
|
|
1010
|
-
}
|
|
1011
|
-
return segments;
|
|
1012
|
-
}
|
|
1013
|
-
function splitClassTokens(value) {
|
|
1014
|
-
return value
|
|
1015
|
-
.split(/\s+/)
|
|
1016
|
-
.map((token) => token.trim())
|
|
1017
|
-
.filter(Boolean);
|
|
1018
|
-
}
|
|
1019
|
-
function dedupeTokens(tokens) {
|
|
1020
|
-
const seen = new Set();
|
|
1021
|
-
const next = [];
|
|
1022
|
-
for (const token of tokens) {
|
|
1023
|
-
if (!token || seen.has(token)) {
|
|
1024
|
-
continue;
|
|
1025
|
-
}
|
|
1026
|
-
seen.add(token);
|
|
1027
|
-
next.push(token);
|
|
1028
|
-
}
|
|
1029
|
-
return next;
|
|
1030
|
-
}
|
|
1031
|
-
function isFontSizeToken(token) {
|
|
1032
|
-
return (FONT_SIZE_TOKENS.includes(token) ||
|
|
1033
|
-
(/^text-\[.+\]$/.test(token) && !looksLikeColorValue(token.slice(6, -1))));
|
|
1034
|
-
}
|
|
1035
|
-
function isTextColorToken(token) {
|
|
1036
|
-
if (!token.startsWith("text-") ||
|
|
1037
|
-
TEXT_ALIGN_TOKENS.includes(token)) {
|
|
1038
|
-
return false;
|
|
1039
|
-
}
|
|
1040
|
-
return !isFontSizeToken(token);
|
|
1041
|
-
}
|
|
1042
|
-
function isBackgroundColorToken(token) {
|
|
1043
|
-
if (!token.startsWith("bg-")) {
|
|
1044
|
-
return false;
|
|
1045
|
-
}
|
|
1046
|
-
return !(token.startsWith("bg-gradient-") ||
|
|
1047
|
-
token.startsWith("bg-[url") ||
|
|
1048
|
-
[
|
|
1049
|
-
"bg-fixed",
|
|
1050
|
-
"bg-local",
|
|
1051
|
-
"bg-scroll",
|
|
1052
|
-
"bg-clip-border",
|
|
1053
|
-
"bg-clip-padding",
|
|
1054
|
-
"bg-clip-content",
|
|
1055
|
-
"bg-clip-text",
|
|
1056
|
-
"bg-origin-border",
|
|
1057
|
-
"bg-origin-padding",
|
|
1058
|
-
"bg-origin-content",
|
|
1059
|
-
].includes(token));
|
|
1060
|
-
}
|
|
1061
|
-
function isBorderWidthToken(token) {
|
|
1062
|
-
return (BORDER_WIDTH_TOKENS.includes(token) ||
|
|
1063
|
-
/^border-\[.+\]$/.test(token) ||
|
|
1064
|
-
/^border-(?:x|y|t|r|b|l)(?:-\d+|-\[.+\])?$/.test(token));
|
|
1065
|
-
}
|
|
1066
|
-
function isInsetSideToken(side, token) {
|
|
1067
|
-
const sideAxis = side === "top" || side === "bottom"
|
|
1068
|
-
? "y"
|
|
1069
|
-
: side === "right" || side === "left"
|
|
1070
|
-
? "x"
|
|
1071
|
-
: "";
|
|
1072
|
-
return (new RegExp(`^-?${side}-.+$`).test(token) ||
|
|
1073
|
-
new RegExp(`^-?inset-${sideAxis}-.+$`).test(token) ||
|
|
1074
|
-
/^-?inset-.+$/.test(token));
|
|
1075
|
-
}
|
|
1076
|
-
function isFlexBasisToken(token) {
|
|
1077
|
-
return (FLEX_BASIS_TOKENS.includes(token) ||
|
|
1078
|
-
/^basis-\[.+\]$/.test(token));
|
|
1079
|
-
}
|
|
1080
|
-
function isOrderToken(token) {
|
|
1081
|
-
return (ORDER_TOKENS.includes(token) ||
|
|
1082
|
-
/^-?order-(?:\d+|\[.+\])$/.test(token));
|
|
1083
|
-
}
|
|
1084
|
-
function isGridTemplateColumnsToken(token) {
|
|
1085
|
-
return (GRID_TEMPLATE_COLUMNS_TOKENS.includes(token) || /^grid-cols-\[.+\]$/.test(token));
|
|
1086
|
-
}
|
|
1087
|
-
function isGridTemplateRowsToken(token) {
|
|
1088
|
-
return (GRID_TEMPLATE_ROWS_TOKENS.includes(token) || /^grid-rows-\[.+\]$/.test(token));
|
|
1089
|
-
}
|
|
1090
|
-
function isGridColumnToken(token) {
|
|
1091
|
-
return (GRID_COLUMN_TOKENS.includes(token) ||
|
|
1092
|
-
/^(?:col|col-span|col-start|col-end)-.+$/.test(token));
|
|
1093
|
-
}
|
|
1094
|
-
function isGridRowToken(token) {
|
|
1095
|
-
return (GRID_ROW_TOKENS.includes(token) ||
|
|
1096
|
-
/^(?:row|row-span|row-start|row-end)-.+$/.test(token));
|
|
1097
|
-
}
|
|
1098
|
-
function isZIndexToken(token) {
|
|
1099
|
-
return (Z_INDEX_TOKENS.includes(token) ||
|
|
1100
|
-
/^-?z-(?:\d+|\[.+\])$/.test(token));
|
|
1101
|
-
}
|
|
1102
|
-
function isBorderColorToken(token) {
|
|
1103
|
-
if (!token.startsWith("border-")) {
|
|
1104
|
-
return false;
|
|
1105
|
-
}
|
|
1106
|
-
return !(BORDER_STYLE_TOKENS.includes(token) ||
|
|
1107
|
-
isBorderWidthToken(token) ||
|
|
1108
|
-
token.startsWith("border-spacing-") ||
|
|
1109
|
-
/^border-(?:x|y|t|r|b|l)(?:-|$)/.test(token));
|
|
1110
|
-
}
|
|
1111
|
-
function isLineClampToken(token) {
|
|
1112
|
-
return (LINE_CLAMP_TOKENS.includes(token) ||
|
|
1113
|
-
/^line-clamp-\[.+\]$/.test(token));
|
|
1114
|
-
}
|
|
1115
|
-
function isTextIndentToken(token) {
|
|
1116
|
-
return (TEXT_INDENT_TOKENS.includes(token) ||
|
|
1117
|
-
/^-?indent-\[.+\]$/.test(token));
|
|
1118
|
-
}
|
|
1119
|
-
function isAspectRatioToken(token) {
|
|
1120
|
-
return (ASPECT_RATIO_TOKENS.includes(token) || /^aspect-\[.+\]$/.test(token));
|
|
1121
|
-
}
|
|
1122
|
-
function isBoxShadowToken(token) {
|
|
1123
|
-
return (BOX_SHADOW_TOKENS.includes(token) ||
|
|
1124
|
-
/^shadow-(?:\[.+\]|[a-z][\w-]*)$/.test(token));
|
|
1125
|
-
}
|
|
1126
|
-
function isFontWeightToken(token) {
|
|
1127
|
-
return FONT_WEIGHT_TOKENS.includes(token);
|
|
1128
|
-
}
|
|
1129
|
-
function isBoxSideToken(prefix, side, token) {
|
|
1130
|
-
const axis = side === "t" || side === "b" ? "y" : "x";
|
|
1131
|
-
return (new RegExp(`^-?${prefix}${side}-.+$`).test(token) ||
|
|
1132
|
-
new RegExp(`^-?${prefix}${axis}-.+$`).test(token) ||
|
|
1133
|
-
new RegExp(`^-?${prefix}-.+$`).test(token));
|
|
1134
|
-
}
|
|
1135
|
-
function isSizeToken(token) {
|
|
1136
|
-
return /^size-.+$/.test(token);
|
|
1137
|
-
}
|
|
1138
|
-
function isPrefixUtilityBaseToken(prefix, token) {
|
|
1139
|
-
return token === prefix.replace(/-$/, "");
|
|
1140
|
-
}
|
|
1141
|
-
function hasCleanTailwindUtilitySyntax(token) {
|
|
1142
|
-
if (!token) {
|
|
1143
|
-
return false;
|
|
1144
|
-
}
|
|
1145
|
-
let bracketDepth = 0;
|
|
1146
|
-
for (const character of token) {
|
|
1147
|
-
if (character === "[") {
|
|
1148
|
-
bracketDepth += 1;
|
|
1149
|
-
continue;
|
|
1150
|
-
}
|
|
1151
|
-
if (character === "]") {
|
|
1152
|
-
bracketDepth -= 1;
|
|
1153
|
-
if (bracketDepth < 0) {
|
|
1154
|
-
return false;
|
|
1155
|
-
}
|
|
1156
|
-
continue;
|
|
1157
|
-
}
|
|
1158
|
-
if (bracketDepth === 0 &&
|
|
1159
|
-
(character === "," ||
|
|
1160
|
-
character === '"' ||
|
|
1161
|
-
character === "'" ||
|
|
1162
|
-
character === "\\")) {
|
|
1163
|
-
return false;
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
return bracketDepth === 0;
|
|
1167
|
-
}
|
|
1168
|
-
function isTransformToken(token) {
|
|
1169
|
-
return (token === "transform" ||
|
|
1170
|
-
token === "transform-gpu" ||
|
|
1171
|
-
token === "transform-none" ||
|
|
1172
|
-
token.startsWith("translate-") ||
|
|
1173
|
-
token.startsWith("-translate-") ||
|
|
1174
|
-
token.startsWith("scale-") ||
|
|
1175
|
-
token.startsWith("-scale-") ||
|
|
1176
|
-
token.startsWith("rotate-") ||
|
|
1177
|
-
token.startsWith("-rotate-") ||
|
|
1178
|
-
token.startsWith("skew-") ||
|
|
1179
|
-
token.startsWith("-skew-"));
|
|
1180
|
-
}
|
|
1181
|
-
function looksLikeColorValue(value) {
|
|
1182
|
-
return (value.startsWith("#") ||
|
|
1183
|
-
value.startsWith("rgb") ||
|
|
1184
|
-
value.startsWith("hsl") ||
|
|
1185
|
-
value.startsWith("oklch") ||
|
|
1186
|
-
value.startsWith("color("));
|
|
1187
|
-
}
|