@cassida/compiler 0.1.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/LICENSE +21 -0
- package/config.schema.json +88 -0
- package/dist/canonicalizer.d.ts +42 -0
- package/dist/canonicalizer.d.ts.map +1 -0
- package/dist/canonicalizer.js +185 -0
- package/dist/canonicalizer.js.map +1 -0
- package/dist/compile.d.ts +46 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +84 -0
- package/dist/compile.js.map +1 -0
- package/dist/config.d.ts +182 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +150 -0
- package/dist/config.js.map +1 -0
- package/dist/emitter.d.ts +44 -0
- package/dist/emitter.d.ts.map +1 -0
- package/dist/emitter.js +189 -0
- package/dist/emitter.js.map +1 -0
- package/dist/generated-property-specs.d.ts +3193 -0
- package/dist/generated-property-specs.d.ts.map +1 -0
- package/dist/generated-property-specs.js +472 -0
- package/dist/generated-property-specs.js.map +1 -0
- package/dist/hasher.d.ts +8 -0
- package/dist/hasher.d.ts.map +1 -0
- package/dist/hasher.js +10 -0
- package/dist/hasher.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/modifier-spec.d.ts +104 -0
- package/dist/modifier-spec.d.ts.map +1 -0
- package/dist/modifier-spec.js +52 -0
- package/dist/modifier-spec.js.map +1 -0
- package/dist/plugin.d.ts +66 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +65 -0
- package/dist/plugin.js.map +1 -0
- package/dist/property-spec.d.ts +321 -0
- package/dist/property-spec.d.ts.map +1 -0
- package/dist/property-spec.js +382 -0
- package/dist/property-spec.js.map +1 -0
- package/dist/registry.d.ts +71 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +123 -0
- package/dist/registry.js.map +1 -0
- package/dist/types.d.ts +135 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +6 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +6 -0
- package/dist/util.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strongly-typed canonical method spec.
|
|
3
|
+
*
|
|
4
|
+
* This is the single source of truth from which:
|
|
5
|
+
*
|
|
6
|
+
* 1. `defaultRegistry` — runtime lookup (type-erased)
|
|
7
|
+
* 2. `CassChain` method signatures — compile-time API (typed via csstype)
|
|
8
|
+
* 3. `defaultPropertyMeta` — CSS-property → metadata lookup
|
|
9
|
+
* used by the emitter to decide `@property` rule emission
|
|
10
|
+
*
|
|
11
|
+
* are all derived. Adding a property here automatically updates them.
|
|
12
|
+
*
|
|
13
|
+
* Per-method `format` carries the typed argument signature; consumers extract
|
|
14
|
+
* it via `Parameters<typeof canonicalSpec[K]['format']>` (cheap mapped type,
|
|
15
|
+
* no template-literal recursion). Length-typed methods take `(n, unit?)` for
|
|
16
|
+
* ergonomic chaining; passthrough methods use csstype's `Property.X` so that
|
|
17
|
+
* IDE autocomplete surfaces real CSS values (`'red'`, `'flex'`, `'absolute'`).
|
|
18
|
+
*
|
|
19
|
+
* `animatable: true` marks a property as a candidate for `@property`
|
|
20
|
+
* emission *when* its value is dynamic. It does not affect static-value
|
|
21
|
+
* compilation. Continuous-interpolation properties (lengths, colors,
|
|
22
|
+
* numbers) are typically true; enum-valued properties (display, position,
|
|
23
|
+
* cursor, ...) are typically false.
|
|
24
|
+
*/
|
|
25
|
+
const length = (n, unit = 'px') => {
|
|
26
|
+
if (typeof n === 'number') {
|
|
27
|
+
const u = typeof unit === 'string' ? unit : 'px';
|
|
28
|
+
return n === 0 ? '0' : `${n}${u}`;
|
|
29
|
+
}
|
|
30
|
+
if (typeof n === 'string')
|
|
31
|
+
return n;
|
|
32
|
+
throw new TypeError(`[cassida] expected number | string for length, got ${typeof n}`);
|
|
33
|
+
};
|
|
34
|
+
const passthrough = (v) => {
|
|
35
|
+
if (v == null)
|
|
36
|
+
throw new TypeError('[cassida] value cannot be null/undefined');
|
|
37
|
+
return String(v);
|
|
38
|
+
};
|
|
39
|
+
export const canonicalSpec = {
|
|
40
|
+
// colors — typed via csstype for IDE autocomplete of named colors / hex / rgb()
|
|
41
|
+
color: {
|
|
42
|
+
property: 'color',
|
|
43
|
+
syntax: '<color>',
|
|
44
|
+
initialValue: 'transparent',
|
|
45
|
+
animatable: true,
|
|
46
|
+
format: (v) => passthrough(v),
|
|
47
|
+
},
|
|
48
|
+
backgroundColor: {
|
|
49
|
+
property: 'background-color',
|
|
50
|
+
syntax: '<color>',
|
|
51
|
+
initialValue: 'transparent',
|
|
52
|
+
animatable: true,
|
|
53
|
+
format: (v) => passthrough(v),
|
|
54
|
+
},
|
|
55
|
+
borderColor: {
|
|
56
|
+
property: 'border-color',
|
|
57
|
+
syntax: '<color>',
|
|
58
|
+
initialValue: 'transparent',
|
|
59
|
+
animatable: true,
|
|
60
|
+
format: (v) => passthrough(v),
|
|
61
|
+
},
|
|
62
|
+
// margin family — shorthand + longhands. The shorthand is allowed
|
|
63
|
+
// because Canonicalizer's shorthand.policy (default 'strict')
|
|
64
|
+
// prevents the cascade-vs-LIFO bug by forbidding shorthand ↔
|
|
65
|
+
// longhand co-occurrence within a single scope.
|
|
66
|
+
margin: {
|
|
67
|
+
property: 'margin',
|
|
68
|
+
syntax: '<length>',
|
|
69
|
+
initialValue: '0',
|
|
70
|
+
animatable: true,
|
|
71
|
+
shorthandFamily: 'margin',
|
|
72
|
+
format: (n, unit) => length(n, unit),
|
|
73
|
+
},
|
|
74
|
+
marginTop: {
|
|
75
|
+
property: 'margin-top',
|
|
76
|
+
syntax: '<length>',
|
|
77
|
+
initialValue: '0',
|
|
78
|
+
animatable: true,
|
|
79
|
+
longhandFamily: 'margin',
|
|
80
|
+
format: (n, unit) => length(n, unit),
|
|
81
|
+
},
|
|
82
|
+
marginRight: {
|
|
83
|
+
property: 'margin-right',
|
|
84
|
+
syntax: '<length>',
|
|
85
|
+
initialValue: '0',
|
|
86
|
+
animatable: true,
|
|
87
|
+
longhandFamily: 'margin',
|
|
88
|
+
format: (n, unit) => length(n, unit),
|
|
89
|
+
},
|
|
90
|
+
marginBottom: {
|
|
91
|
+
property: 'margin-bottom',
|
|
92
|
+
syntax: '<length>',
|
|
93
|
+
initialValue: '0',
|
|
94
|
+
animatable: true,
|
|
95
|
+
longhandFamily: 'margin',
|
|
96
|
+
format: (n, unit) => length(n, unit),
|
|
97
|
+
},
|
|
98
|
+
marginLeft: {
|
|
99
|
+
property: 'margin-left',
|
|
100
|
+
syntax: '<length>',
|
|
101
|
+
initialValue: '0',
|
|
102
|
+
animatable: true,
|
|
103
|
+
longhandFamily: 'margin',
|
|
104
|
+
format: (n, unit) => length(n, unit),
|
|
105
|
+
},
|
|
106
|
+
// padding family — shorthand + longhands.
|
|
107
|
+
padding: {
|
|
108
|
+
property: 'padding',
|
|
109
|
+
syntax: '<length>',
|
|
110
|
+
initialValue: '0',
|
|
111
|
+
animatable: true,
|
|
112
|
+
shorthandFamily: 'padding',
|
|
113
|
+
format: (n, unit) => length(n, unit),
|
|
114
|
+
},
|
|
115
|
+
paddingTop: {
|
|
116
|
+
property: 'padding-top',
|
|
117
|
+
syntax: '<length>',
|
|
118
|
+
initialValue: '0',
|
|
119
|
+
animatable: true,
|
|
120
|
+
longhandFamily: 'padding',
|
|
121
|
+
format: (n, unit) => length(n, unit),
|
|
122
|
+
},
|
|
123
|
+
paddingRight: {
|
|
124
|
+
property: 'padding-right',
|
|
125
|
+
syntax: '<length>',
|
|
126
|
+
initialValue: '0',
|
|
127
|
+
animatable: true,
|
|
128
|
+
longhandFamily: 'padding',
|
|
129
|
+
format: (n, unit) => length(n, unit),
|
|
130
|
+
},
|
|
131
|
+
paddingBottom: {
|
|
132
|
+
property: 'padding-bottom',
|
|
133
|
+
syntax: '<length>',
|
|
134
|
+
initialValue: '0',
|
|
135
|
+
animatable: true,
|
|
136
|
+
longhandFamily: 'padding',
|
|
137
|
+
format: (n, unit) => length(n, unit),
|
|
138
|
+
},
|
|
139
|
+
paddingLeft: {
|
|
140
|
+
property: 'padding-left',
|
|
141
|
+
syntax: '<length>',
|
|
142
|
+
initialValue: '0',
|
|
143
|
+
animatable: true,
|
|
144
|
+
longhandFamily: 'padding',
|
|
145
|
+
format: (n, unit) => length(n, unit),
|
|
146
|
+
},
|
|
147
|
+
// size — animatable lengths
|
|
148
|
+
width: {
|
|
149
|
+
property: 'width',
|
|
150
|
+
syntax: '<length>',
|
|
151
|
+
initialValue: '0',
|
|
152
|
+
animatable: true,
|
|
153
|
+
format: (n, unit) => length(n, unit),
|
|
154
|
+
},
|
|
155
|
+
height: {
|
|
156
|
+
property: 'height',
|
|
157
|
+
syntax: '<length>',
|
|
158
|
+
initialValue: '0',
|
|
159
|
+
animatable: true,
|
|
160
|
+
format: (n, unit) => length(n, unit),
|
|
161
|
+
},
|
|
162
|
+
minWidth: {
|
|
163
|
+
property: 'min-width',
|
|
164
|
+
syntax: '<length>',
|
|
165
|
+
initialValue: '0',
|
|
166
|
+
animatable: true,
|
|
167
|
+
format: (n, unit) => length(n, unit),
|
|
168
|
+
},
|
|
169
|
+
minHeight: {
|
|
170
|
+
property: 'min-height',
|
|
171
|
+
syntax: '<length>',
|
|
172
|
+
initialValue: '0',
|
|
173
|
+
animatable: true,
|
|
174
|
+
format: (n, unit) => length(n, unit),
|
|
175
|
+
},
|
|
176
|
+
maxWidth: {
|
|
177
|
+
property: 'max-width',
|
|
178
|
+
syntax: '<length>',
|
|
179
|
+
initialValue: '0',
|
|
180
|
+
animatable: true,
|
|
181
|
+
format: (n, unit) => length(n, unit),
|
|
182
|
+
},
|
|
183
|
+
maxHeight: {
|
|
184
|
+
property: 'max-height',
|
|
185
|
+
syntax: '<length>',
|
|
186
|
+
initialValue: '0',
|
|
187
|
+
animatable: true,
|
|
188
|
+
format: (n, unit) => length(n, unit),
|
|
189
|
+
},
|
|
190
|
+
// typography
|
|
191
|
+
fontFamily: {
|
|
192
|
+
property: 'font-family',
|
|
193
|
+
animatable: false,
|
|
194
|
+
format: (v) => passthrough(v),
|
|
195
|
+
},
|
|
196
|
+
fontSize: {
|
|
197
|
+
property: 'font-size',
|
|
198
|
+
syntax: '<length>',
|
|
199
|
+
initialValue: '0',
|
|
200
|
+
animatable: true,
|
|
201
|
+
format: (n, unit) => length(n, unit),
|
|
202
|
+
},
|
|
203
|
+
fontWeight: {
|
|
204
|
+
property: 'font-weight',
|
|
205
|
+
syntax: '<number>',
|
|
206
|
+
initialValue: '400',
|
|
207
|
+
animatable: true,
|
|
208
|
+
format: (v) => passthrough(v),
|
|
209
|
+
},
|
|
210
|
+
lineHeight: {
|
|
211
|
+
property: 'line-height',
|
|
212
|
+
syntax: '<number>',
|
|
213
|
+
initialValue: '1',
|
|
214
|
+
animatable: true,
|
|
215
|
+
format: (v) => passthrough(v),
|
|
216
|
+
},
|
|
217
|
+
textAlign: {
|
|
218
|
+
property: 'text-align',
|
|
219
|
+
animatable: false,
|
|
220
|
+
format: (v) => passthrough(v),
|
|
221
|
+
},
|
|
222
|
+
// layout
|
|
223
|
+
display: {
|
|
224
|
+
property: 'display',
|
|
225
|
+
animatable: false,
|
|
226
|
+
format: (v) => passthrough(v),
|
|
227
|
+
},
|
|
228
|
+
position: {
|
|
229
|
+
property: 'position',
|
|
230
|
+
animatable: false,
|
|
231
|
+
format: (v) => passthrough(v),
|
|
232
|
+
},
|
|
233
|
+
// inset family — shorthand + 4 longhands (top/right/bottom/left).
|
|
234
|
+
inset: {
|
|
235
|
+
property: 'inset',
|
|
236
|
+
syntax: '<length>',
|
|
237
|
+
initialValue: '0',
|
|
238
|
+
animatable: true,
|
|
239
|
+
shorthandFamily: 'inset',
|
|
240
|
+
format: (n, unit) => length(n, unit),
|
|
241
|
+
},
|
|
242
|
+
top: {
|
|
243
|
+
property: 'top',
|
|
244
|
+
syntax: '<length>',
|
|
245
|
+
initialValue: '0',
|
|
246
|
+
animatable: true,
|
|
247
|
+
longhandFamily: 'inset',
|
|
248
|
+
format: (n, unit) => length(n, unit),
|
|
249
|
+
},
|
|
250
|
+
right: {
|
|
251
|
+
property: 'right',
|
|
252
|
+
syntax: '<length>',
|
|
253
|
+
initialValue: '0',
|
|
254
|
+
animatable: true,
|
|
255
|
+
longhandFamily: 'inset',
|
|
256
|
+
format: (n, unit) => length(n, unit),
|
|
257
|
+
},
|
|
258
|
+
bottom: {
|
|
259
|
+
property: 'bottom',
|
|
260
|
+
syntax: '<length>',
|
|
261
|
+
initialValue: '0',
|
|
262
|
+
animatable: true,
|
|
263
|
+
longhandFamily: 'inset',
|
|
264
|
+
format: (n, unit) => length(n, unit),
|
|
265
|
+
},
|
|
266
|
+
left: {
|
|
267
|
+
property: 'left',
|
|
268
|
+
syntax: '<length>',
|
|
269
|
+
initialValue: '0',
|
|
270
|
+
animatable: true,
|
|
271
|
+
longhandFamily: 'inset',
|
|
272
|
+
format: (n, unit) => length(n, unit),
|
|
273
|
+
},
|
|
274
|
+
zIndex: {
|
|
275
|
+
property: 'z-index',
|
|
276
|
+
syntax: '<integer>',
|
|
277
|
+
initialValue: '0',
|
|
278
|
+
animatable: true,
|
|
279
|
+
format: (v) => passthrough(v),
|
|
280
|
+
},
|
|
281
|
+
// flex
|
|
282
|
+
flexDirection: {
|
|
283
|
+
property: 'flex-direction',
|
|
284
|
+
animatable: false,
|
|
285
|
+
format: (v) => passthrough(v),
|
|
286
|
+
},
|
|
287
|
+
justifyContent: {
|
|
288
|
+
property: 'justify-content',
|
|
289
|
+
animatable: false,
|
|
290
|
+
format: (v) => passthrough(v),
|
|
291
|
+
},
|
|
292
|
+
alignItems: {
|
|
293
|
+
property: 'align-items',
|
|
294
|
+
animatable: false,
|
|
295
|
+
format: (v) => passthrough(v),
|
|
296
|
+
},
|
|
297
|
+
gap: {
|
|
298
|
+
property: 'gap',
|
|
299
|
+
syntax: '<length>',
|
|
300
|
+
initialValue: '0',
|
|
301
|
+
animatable: true,
|
|
302
|
+
format: (n, unit) => length(n, unit),
|
|
303
|
+
},
|
|
304
|
+
// border
|
|
305
|
+
borderRadius: {
|
|
306
|
+
property: 'border-radius',
|
|
307
|
+
syntax: '<length>',
|
|
308
|
+
initialValue: '0',
|
|
309
|
+
animatable: true,
|
|
310
|
+
format: (n, unit) => length(n, unit),
|
|
311
|
+
},
|
|
312
|
+
borderWidth: {
|
|
313
|
+
property: 'border-width',
|
|
314
|
+
syntax: '<length>',
|
|
315
|
+
initialValue: '0',
|
|
316
|
+
animatable: true,
|
|
317
|
+
format: (n, unit) => length(n, unit),
|
|
318
|
+
},
|
|
319
|
+
borderStyle: {
|
|
320
|
+
property: 'border-style',
|
|
321
|
+
animatable: false,
|
|
322
|
+
format: (v) => passthrough(v),
|
|
323
|
+
},
|
|
324
|
+
// misc
|
|
325
|
+
opacity: {
|
|
326
|
+
property: 'opacity',
|
|
327
|
+
syntax: '<number>',
|
|
328
|
+
initialValue: '1',
|
|
329
|
+
animatable: true,
|
|
330
|
+
format: (v) => passthrough(v),
|
|
331
|
+
},
|
|
332
|
+
cursor: {
|
|
333
|
+
property: 'cursor',
|
|
334
|
+
animatable: false,
|
|
335
|
+
format: (v) => passthrough(v),
|
|
336
|
+
},
|
|
337
|
+
// ─────────────────────────────────────────────────────────────────
|
|
338
|
+
// Opaque shorthands. These CSS shorthands are accepted as
|
|
339
|
+
// single-property writes — the user passes the *whole* CSS string
|
|
340
|
+
// (`'fade 1s ease'` for animation) and FSS does not decompose into
|
|
341
|
+
// longhand subproperties.
|
|
342
|
+
//
|
|
343
|
+
// Crucially, FSS does NOT expose the matching longhands
|
|
344
|
+
// (`animationDuration`, `transitionProperty`, `transformOrigin`,
|
|
345
|
+
// etc.). That means the canonical-vs-longhand co-occurrence
|
|
346
|
+
// problem can't arise — there's nothing on the chain that could
|
|
347
|
+
// collide with these in the bag — so the family-tracking guard is
|
|
348
|
+
// structurally unnecessary.
|
|
349
|
+
//
|
|
350
|
+
// `transform` is `animatable: true` (it's the most-animated CSS
|
|
351
|
+
// property in modern UIs); the other two are discrete shorthands
|
|
352
|
+
// that don't interpolate as a single whole.
|
|
353
|
+
animation: {
|
|
354
|
+
property: 'animation',
|
|
355
|
+
animatable: false,
|
|
356
|
+
format: (v) => passthrough(v),
|
|
357
|
+
},
|
|
358
|
+
transition: {
|
|
359
|
+
property: 'transition',
|
|
360
|
+
animatable: false,
|
|
361
|
+
format: (v) => passthrough(v),
|
|
362
|
+
},
|
|
363
|
+
transform: {
|
|
364
|
+
property: 'transform',
|
|
365
|
+
syntax: '<transform-list>',
|
|
366
|
+
initialValue: 'none',
|
|
367
|
+
animatable: true,
|
|
368
|
+
format: (v) => passthrough(v),
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
const propertyMetaTable = {};
|
|
372
|
+
for (const spec of Object.values(canonicalSpec)) {
|
|
373
|
+
if (!(spec.property in propertyMetaTable)) {
|
|
374
|
+
propertyMetaTable[spec.property] = {
|
|
375
|
+
syntax: 'syntax' in spec ? spec.syntax : undefined,
|
|
376
|
+
initialValue: 'initialValue' in spec ? spec.initialValue : undefined,
|
|
377
|
+
animatable: spec.animatable,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
export const defaultPropertyMeta = Object.freeze(propertyMetaTable);
|
|
382
|
+
//# sourceMappingURL=property-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-spec.js","sourceRoot":"","sources":["../src/property-spec.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,MAAM,GAAG,CAAC,CAAU,EAAE,OAAgB,IAAI,EAAU,EAAE;IAC1D,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;Q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9D;CACyC,CAAC;AAgB7C,MAAM,iBAAiB,GAAiC,EAAE,CAAC;AAC3D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAChD,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,iBAAiB,CAAC,EAAE,CAAC;QAC1C,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG;YACjC,MAAM,EAAE,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YAClD,YAAY,EAAE,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;YACpE,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;AACH,CAAC;AACD,MAAM,CAAC,MAAM,mBAAmB,GAA2C,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export type Formatter = (...args: readonly unknown[]) => string;
|
|
2
|
+
export interface RegistryEntry {
|
|
3
|
+
readonly property: string;
|
|
4
|
+
readonly format: Formatter;
|
|
5
|
+
/**
|
|
6
|
+
* Optional `@property` syntax descriptor. Stored as metadata only;
|
|
7
|
+
* the emitter consults this when (and only when) a value gets promoted
|
|
8
|
+
* to a CSS custom property (e.g. for a dynamic value or an animated one).
|
|
9
|
+
* Static literal usages do not produce an `@property` rule.
|
|
10
|
+
*/
|
|
11
|
+
readonly syntax?: string;
|
|
12
|
+
readonly initialValue?: string;
|
|
13
|
+
readonly inherits?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether this property is a meaningful candidate for `@property`
|
|
16
|
+
* emission *when its value is dynamic*. Continuous-interpolation
|
|
17
|
+
* properties (lengths, colors, numbers) are typically true; enum-valued
|
|
18
|
+
* properties (display, position, ...) are typically false.
|
|
19
|
+
*/
|
|
20
|
+
readonly animatable?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* If this entry IS a CSS shorthand that covers a family of longhands,
|
|
23
|
+
* the family identifier (e.g. `'padding'`, `'margin'`, `'inset'`).
|
|
24
|
+
* Used by the Canonicalizer's `shorthand.policy` check to detect
|
|
25
|
+
* shorthand ↔ longhand co-occurrence within a single scope.
|
|
26
|
+
*/
|
|
27
|
+
readonly shorthandFamily?: string;
|
|
28
|
+
/**
|
|
29
|
+
* If this entry IS a longhand of a shorthand family, the family
|
|
30
|
+
* identifier. Mirrors `shorthandFamily` from the other side.
|
|
31
|
+
*/
|
|
32
|
+
readonly longhandFamily?: string;
|
|
33
|
+
}
|
|
34
|
+
export type Registry = Readonly<Record<string, RegistryEntry>>;
|
|
35
|
+
export type AliasMap = Readonly<Record<string, string>>;
|
|
36
|
+
export declare const defaultCanonicals: Registry;
|
|
37
|
+
/**
|
|
38
|
+
* Optional shorthands. Aliases are pure typing-sugar: each one resolves
|
|
39
|
+
* to the *same RegistryEntry reference* as its canonical, so behavior is
|
|
40
|
+
* identical and `mt(10).marginTop(20)` collapses correctly to a single
|
|
41
|
+
* `margin-top` declaration via LIFO.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* Optional shorthand aliases.
|
|
45
|
+
*
|
|
46
|
+
* Removed (intentionally absent): `background` and `font`. Both names
|
|
47
|
+
* refer to *real* CSS shorthands (writing many subproperties at once
|
|
48
|
+
* with implicit reset of the rest), and offering them as aliases for
|
|
49
|
+
* `backgroundColor` / `fontFamily` would silently lie about CSS
|
|
50
|
+
* semantics. Users wanting the actual CSS shorthand can route through
|
|
51
|
+
* `fss.unsafe({ background: '...' })`.
|
|
52
|
+
*/
|
|
53
|
+
export declare const defaultAliases: AliasMap;
|
|
54
|
+
/**
|
|
55
|
+
* Returns a frozen registry where every alias key points to the *same*
|
|
56
|
+
* RegistryEntry reference as its canonical target.
|
|
57
|
+
*/
|
|
58
|
+
export declare function expandAliases(canonicals: Registry, aliases: AliasMap): Registry;
|
|
59
|
+
/**
|
|
60
|
+
* The runtime registry: canonicals + default aliases, flattened. Lookup
|
|
61
|
+
* is O(1); aliases and canonicals are indistinguishable at the point of
|
|
62
|
+
* use. Use `defaultCanonicals` and `defaultAliases` directly if you need
|
|
63
|
+
* to know which is which (docs, codegen, etc.).
|
|
64
|
+
*/
|
|
65
|
+
export declare const defaultRegistry: Registry;
|
|
66
|
+
/**
|
|
67
|
+
* Returns a frozen registry that overlays `additions` on top of `base`.
|
|
68
|
+
* Later additions win on key conflict.
|
|
69
|
+
*/
|
|
70
|
+
export declare function extendRegistry(base: Registry, additions: Registry): Registry;
|
|
71
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,MAAM,CAAC;AAEhE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;AAC/D,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAkExD,eAAO,MAAM,iBAAiB,EAAE,QAG9B,CAAC;AAEH;;;;;GAKG;AACH;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,QAU3B,CAAC;AAEH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAiB/E;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,QAA2D,CAAC;AAE1F;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAE5E"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { canonicalSpec } from './property-spec.js';
|
|
2
|
+
import { generatedPropertySpecs, } from './generated-property-specs.js';
|
|
3
|
+
/** Format function for entries derived from mdn-data. */
|
|
4
|
+
const passthroughFormat = (v) => {
|
|
5
|
+
if (v === null || v === undefined) {
|
|
6
|
+
throw new TypeError('[cassida] generated property received null/undefined value');
|
|
7
|
+
}
|
|
8
|
+
return String(v);
|
|
9
|
+
};
|
|
10
|
+
function buildGeneratedEntries(generated) {
|
|
11
|
+
const out = {};
|
|
12
|
+
for (const [name, spec] of Object.entries(generated)) {
|
|
13
|
+
out[name] = {
|
|
14
|
+
property: spec.property,
|
|
15
|
+
format: passthroughFormat,
|
|
16
|
+
animatable: spec.animatable,
|
|
17
|
+
...(spec.syntax !== undefined ? { syntax: spec.syntax } : {}),
|
|
18
|
+
...(spec.initialValue !== undefined ? { initialValue: spec.initialValue } : {}),
|
|
19
|
+
...(spec.inherits !== undefined ? { inherits: spec.inherits } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return Object.freeze(out);
|
|
23
|
+
}
|
|
24
|
+
function buildHandCraftedEntries(spec) {
|
|
25
|
+
const out = {};
|
|
26
|
+
for (const [name, entry] of Object.entries(spec)) {
|
|
27
|
+
const built = {
|
|
28
|
+
property: entry.property,
|
|
29
|
+
format: entry.format,
|
|
30
|
+
animatable: entry.animatable,
|
|
31
|
+
...('syntax' in entry && entry.syntax !== undefined ? { syntax: entry.syntax } : {}),
|
|
32
|
+
...('initialValue' in entry && entry.initialValue !== undefined
|
|
33
|
+
? { initialValue: entry.initialValue }
|
|
34
|
+
: {}),
|
|
35
|
+
...('shorthandFamily' in entry && entry.shorthandFamily !== undefined
|
|
36
|
+
? { shorthandFamily: entry.shorthandFamily }
|
|
37
|
+
: {}),
|
|
38
|
+
...('longhandFamily' in entry && entry.longhandFamily !== undefined
|
|
39
|
+
? { longhandFamily: entry.longhandFamily }
|
|
40
|
+
: {}),
|
|
41
|
+
};
|
|
42
|
+
out[name] = built;
|
|
43
|
+
}
|
|
44
|
+
return Object.freeze(out);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Canonical method set: hand-crafted entries (typed via csstype, with
|
|
48
|
+
* family metadata for shorthand-policy) layered ON TOP OF the
|
|
49
|
+
* generated mdn-data set. When a method exists in both, the
|
|
50
|
+
* hand-crafted entry wins — its typed format function and family
|
|
51
|
+
* metadata are preserved while the generated version contributes only
|
|
52
|
+
* to the gap-filling.
|
|
53
|
+
*
|
|
54
|
+
* Result: every standard CSS property has a callable method, and the
|
|
55
|
+
* curated subset retains its csstype-driven IDE autocomplete +
|
|
56
|
+
* shorthand-policy guarding.
|
|
57
|
+
*/
|
|
58
|
+
const generatedEntries = buildGeneratedEntries(generatedPropertySpecs);
|
|
59
|
+
const handCraftedEntries = buildHandCraftedEntries(canonicalSpec);
|
|
60
|
+
export const defaultCanonicals = Object.freeze({
|
|
61
|
+
...generatedEntries,
|
|
62
|
+
...handCraftedEntries,
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Optional shorthands. Aliases are pure typing-sugar: each one resolves
|
|
66
|
+
* to the *same RegistryEntry reference* as its canonical, so behavior is
|
|
67
|
+
* identical and `mt(10).marginTop(20)` collapses correctly to a single
|
|
68
|
+
* `margin-top` declaration via LIFO.
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Optional shorthand aliases.
|
|
72
|
+
*
|
|
73
|
+
* Removed (intentionally absent): `background` and `font`. Both names
|
|
74
|
+
* refer to *real* CSS shorthands (writing many subproperties at once
|
|
75
|
+
* with implicit reset of the rest), and offering them as aliases for
|
|
76
|
+
* `backgroundColor` / `fontFamily` would silently lie about CSS
|
|
77
|
+
* semantics. Users wanting the actual CSS shorthand can route through
|
|
78
|
+
* `fss.unsafe({ background: '...' })`.
|
|
79
|
+
*/
|
|
80
|
+
export const defaultAliases = Object.freeze({
|
|
81
|
+
bg: 'backgroundColor',
|
|
82
|
+
mt: 'marginTop',
|
|
83
|
+
mr: 'marginRight',
|
|
84
|
+
mb: 'marginBottom',
|
|
85
|
+
ml: 'marginLeft',
|
|
86
|
+
pt: 'paddingTop',
|
|
87
|
+
pr: 'paddingRight',
|
|
88
|
+
pb: 'paddingBottom',
|
|
89
|
+
pl: 'paddingLeft',
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Returns a frozen registry where every alias key points to the *same*
|
|
93
|
+
* RegistryEntry reference as its canonical target.
|
|
94
|
+
*/
|
|
95
|
+
export function expandAliases(canonicals, aliases) {
|
|
96
|
+
const out = { ...canonicals };
|
|
97
|
+
for (const [alias, target] of Object.entries(aliases)) {
|
|
98
|
+
const entry = canonicals[target];
|
|
99
|
+
if (!entry) {
|
|
100
|
+
throw new Error(`[cassida] alias "${alias}" points to unknown canonical "${target}"`);
|
|
101
|
+
}
|
|
102
|
+
if (alias in canonicals) {
|
|
103
|
+
throw new Error(`[cassida] alias "${alias}" shadows a canonical method of the same name`);
|
|
104
|
+
}
|
|
105
|
+
out[alias] = entry;
|
|
106
|
+
}
|
|
107
|
+
return Object.freeze(out);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The runtime registry: canonicals + default aliases, flattened. Lookup
|
|
111
|
+
* is O(1); aliases and canonicals are indistinguishable at the point of
|
|
112
|
+
* use. Use `defaultCanonicals` and `defaultAliases` directly if you need
|
|
113
|
+
* to know which is which (docs, codegen, etc.).
|
|
114
|
+
*/
|
|
115
|
+
export const defaultRegistry = expandAliases(defaultCanonicals, defaultAliases);
|
|
116
|
+
/**
|
|
117
|
+
* Returns a frozen registry that overlays `additions` on top of `base`.
|
|
118
|
+
* Later additions win on key conflict.
|
|
119
|
+
*/
|
|
120
|
+
export function extendRegistry(base, additions) {
|
|
121
|
+
return Object.freeze({ ...base, ...additions });
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,sBAAsB,GAEvB,MAAM,+BAA+B,CAAC;AAwCvC,yDAAyD;AACzD,MAAM,iBAAiB,GAAc,CAAC,CAAU,EAAU,EAAE;IAC1D,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,IAAI,SAAS,CAAC,4DAA4D,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC;AAEF,SAAS,qBAAqB,CAC5B,SAAkD;IAElD,MAAM,GAAG,GAAkC,EAAE,CAAC;IAC9C,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,IAAI,CAAC,GAAG;YACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,iBAAiB;YACzB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,CAAC,IAAI,CAAC,MAAM,KA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