vorma 0.86.0-pre.2 → 0.86.0-pre.3

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.
Files changed (104) hide show
  1. package/.dist/core/_index.d.ts +1 -0
  2. package/.dist/core/_index.d.ts.map +1 -1
  3. package/.dist/core/_index.js +6 -0
  4. package/.dist/core/_index.js.map +1 -1
  5. package/.dist/core/vorma_client_wasm_bg.wasm +0 -0
  6. package/.dist/ui/solid/solid.js +29 -39
  7. package/.dist/ui/solid/solid.js.map +1 -1
  8. package/core/client_wasm/vorma_client_wasm_bg.wasm +0 -0
  9. package/core/create_client_core.ts +9 -1
  10. package/package.json +1 -16
  11. package/ui/solid/solid.tsx +29 -10
  12. package/.dist/kit/lab/design/components/remix/remix.d.ts +0 -2309
  13. package/.dist/kit/lab/design/components/remix/remix.d.ts.map +0 -1
  14. package/.dist/kit/lab/design/components/remix/remix.js +0 -7022
  15. package/.dist/kit/lab/design/components/remix/remix.js.map +0 -1
  16. package/.dist/kit/lab/design/core/core.d.ts +0 -527
  17. package/.dist/kit/lab/design/core/core.d.ts.map +0 -1
  18. package/.dist/kit/lab/design/core/core.js +0 -668
  19. package/.dist/kit/lab/design/core/core.js.map +0 -1
  20. package/.dist/kit/matcher/matcher.d.ts +0 -78
  21. package/.dist/kit/matcher/matcher.d.ts.map +0 -1
  22. package/.dist/kit/matcher/matcher.js +0 -517
  23. package/.dist/kit/matcher/matcher.js.map +0 -1
  24. package/.dist/ui/remix/remix.d.ts +0 -73
  25. package/.dist/ui/remix/remix.d.ts.map +0 -1
  26. package/.dist/ui/remix/remix.js +0 -409
  27. package/.dist/ui/remix/remix.js.map +0 -1
  28. package/kit/lab/design/components/remix/accordion.ts +0 -474
  29. package/kit/lab/design/components/remix/alert-dialog.ts +0 -512
  30. package/kit/lab/design/components/remix/alert.ts +0 -213
  31. package/kit/lab/design/components/remix/aspect-ratio.ts +0 -111
  32. package/kit/lab/design/components/remix/badge.ts +0 -59
  33. package/kit/lab/design/components/remix/box.ts +0 -49
  34. package/kit/lab/design/components/remix/button.ts +0 -314
  35. package/kit/lab/design/components/remix/callout.ts +0 -127
  36. package/kit/lab/design/components/remix/checkable-state.ts +0 -187
  37. package/kit/lab/design/components/remix/checkbox-group.ts +0 -443
  38. package/kit/lab/design/components/remix/checkbox.ts +0 -215
  39. package/kit/lab/design/components/remix/chip.ts +0 -165
  40. package/kit/lab/design/components/remix/code-block.ts +0 -181
  41. package/kit/lab/design/components/remix/collapsible.ts +0 -325
  42. package/kit/lab/design/components/remix/component-state.ts +0 -55
  43. package/kit/lab/design/components/remix/component-style.ts +0 -364
  44. package/kit/lab/design/components/remix/composite-navigation.ts +0 -71
  45. package/kit/lab/design/components/remix/conditions.ts +0 -25
  46. package/kit/lab/design/components/remix/controllable-state.ts +0 -58
  47. package/kit/lab/design/components/remix/description-list.ts +0 -275
  48. package/kit/lab/design/components/remix/dialog.ts +0 -653
  49. package/kit/lab/design/components/remix/empty-state.ts +0 -146
  50. package/kit/lab/design/components/remix/field.ts +0 -418
  51. package/kit/lab/design/components/remix/fieldset.ts +0 -153
  52. package/kit/lab/design/components/remix/form-mirror.ts +0 -94
  53. package/kit/lab/design/components/remix/form-reset.ts +0 -85
  54. package/kit/lab/design/components/remix/form.ts +0 -109
  55. package/kit/lab/design/components/remix/grid.ts +0 -187
  56. package/kit/lab/design/components/remix/group-label.ts +0 -47
  57. package/kit/lab/design/components/remix/icon.ts +0 -176
  58. package/kit/lab/design/components/remix/input.ts +0 -163
  59. package/kit/lab/design/components/remix/kbd.ts +0 -58
  60. package/kit/lab/design/components/remix/list.ts +0 -120
  61. package/kit/lab/design/components/remix/listbox.ts +0 -1116
  62. package/kit/lab/design/components/remix/menu.ts +0 -1477
  63. package/kit/lab/design/components/remix/ordered-collection.ts +0 -95
  64. package/kit/lab/design/components/remix/popover-scroll-lock.ts +0 -89
  65. package/kit/lab/design/components/remix/popover.ts +0 -576
  66. package/kit/lab/design/components/remix/popup-behavior.ts +0 -96
  67. package/kit/lab/design/components/remix/progress.ts +0 -185
  68. package/kit/lab/design/components/remix/radio-group.ts +0 -420
  69. package/kit/lab/design/components/remix/recipe.ts +0 -70
  70. package/kit/lab/design/components/remix/remix.ts +0 -683
  71. package/kit/lab/design/components/remix/responsive.ts +0 -106
  72. package/kit/lab/design/components/remix/root.ts +0 -137
  73. package/kit/lab/design/components/remix/select.ts +0 -1546
  74. package/kit/lab/design/components/remix/separator.ts +0 -108
  75. package/kit/lab/design/components/remix/slider.ts +0 -308
  76. package/kit/lab/design/components/remix/spinner.ts +0 -114
  77. package/kit/lab/design/components/remix/stack.ts +0 -205
  78. package/kit/lab/design/components/remix/stat.ts +0 -127
  79. package/kit/lab/design/components/remix/surface.ts +0 -71
  80. package/kit/lab/design/components/remix/switch.ts +0 -219
  81. package/kit/lab/design/components/remix/table.ts +0 -395
  82. package/kit/lab/design/components/remix/tabs.ts +0 -404
  83. package/kit/lab/design/components/remix/text.ts +0 -169
  84. package/kit/lab/design/components/remix/textarea.ts +0 -164
  85. package/kit/lab/design/components/remix/toast.ts +0 -299
  86. package/kit/lab/design/components/remix/tooltip.ts +0 -330
  87. package/kit/lab/design/components/remix/typeahead.ts +0 -81
  88. package/kit/lab/design/components/remix/types.ts +0 -19
  89. package/kit/lab/design/components/remix/visually-hidden.ts +0 -100
  90. package/kit/lab/design/core/color.ts +0 -46
  91. package/kit/lab/design/core/core.ts +0 -111
  92. package/kit/lab/design/core/create_primitive.ts +0 -455
  93. package/kit/lab/design/core/create_system.ts +0 -303
  94. package/kit/lab/design/core/css.ts +0 -127
  95. package/kit/lab/design/core/define_system.ts +0 -508
  96. package/kit/lab/design/core/math.ts +0 -12
  97. package/kit/lab/design/core/object.ts +0 -31
  98. package/kit/lab/design/core/recipe/create_recipe.ts +0 -185
  99. package/kit/lab/design/core/recipe/recipe.ts +0 -26
  100. package/kit/lab/design/core/recipe/style.ts +0 -62
  101. package/kit/lab/design/core/recipe/types.ts +0 -160
  102. package/kit/lab/design/core/resolve_token.ts +0 -118
  103. package/kit/lab/design/core/types.ts +0 -636
  104. package/ui/remix/remix.tsx +0 -901
@@ -1,508 +0,0 @@
1
- import type {
2
- NonEmptyReadonlyArray,
3
- PrimitiveInput,
4
- PrimitiveTokensForInput,
5
- RecipeStyleDefinitions,
6
- ResolvedTokenTree,
7
- SemanticInput,
8
- TokenMixSpec,
9
- TokenPath,
10
- TokenReferenceSpec,
11
- TokenSpec,
12
- TokenTemplateSpec,
13
- } from "./types.ts";
14
- import {
15
- primitive_token_keys,
16
- token_groups,
17
- token_spec_fields,
18
- token_spec_kind,
19
- token_spec_kinds,
20
- } from "./types.ts";
21
-
22
- type AppendPath<TPath extends TokenPath, TKey extends string> = readonly [
23
- ...TPath,
24
- TKey,
25
- ] extends TokenPath
26
- ? readonly [...TPath, TKey]
27
- : never;
28
-
29
- type NoInferFromUsage<T> = [T][T extends unknown ? 0 : never];
30
-
31
- export type TokenRefTree<T, TPath extends TokenPath> = T extends string | number
32
- ? TokenReferenceSpec<TPath>
33
- : T extends object
34
- ? {
35
- readonly [K in keyof T & string]: TokenRefTree<
36
- Exclude<T[K], undefined>,
37
- AppendPath<TPath, K>
38
- >;
39
- }
40
- : never;
41
-
42
- type PrimitiveRefTree<TPrimitive> = TokenRefTree<
43
- PrimitiveTokensForInput<Exclude<TPrimitive, undefined>>,
44
- readonly [typeof token_groups.primitive]
45
- >;
46
-
47
- type SemanticRefTree<TSemantic> = TokenRefTree<
48
- ResolvedTokenTree<Exclude<TSemantic, undefined>[keyof Exclude<TSemantic, undefined>]>,
49
- readonly [typeof token_groups.semantic]
50
- >;
51
-
52
- type TextStyleName<TPrimitive> = TPrimitive extends {
53
- typography?: {
54
- [primitive_token_keys.text_style]?: infer TTextStyle;
55
- };
56
- }
57
- ? keyof TTextStyle & string
58
- : never;
59
-
60
- type FocusRingName<TPrimitive> = TPrimitive extends {
61
- focus?: {
62
- ring?: infer TRing;
63
- };
64
- }
65
- ? keyof TRing & string
66
- : never;
67
-
68
- type TextStyleReferences<TName extends string> = Partial<{
69
- [primitive_token_keys.font_family]: TokenReferenceSpec<
70
- readonly [
71
- typeof token_groups.primitive,
72
- "typography",
73
- typeof primitive_token_keys.text_style,
74
- TName,
75
- typeof primitive_token_keys.font_family,
76
- ]
77
- >;
78
- [primitive_token_keys.font_size]: TokenReferenceSpec<
79
- readonly [
80
- typeof token_groups.primitive,
81
- "typography",
82
- typeof primitive_token_keys.text_style,
83
- TName,
84
- typeof primitive_token_keys.font_size,
85
- ]
86
- >;
87
- [primitive_token_keys.font_weight]: TokenReferenceSpec<
88
- readonly [
89
- typeof token_groups.primitive,
90
- "typography",
91
- typeof primitive_token_keys.text_style,
92
- TName,
93
- typeof primitive_token_keys.font_weight,
94
- ]
95
- >;
96
- [primitive_token_keys.letter_spacing]: TokenReferenceSpec<
97
- readonly [
98
- typeof token_groups.primitive,
99
- "typography",
100
- typeof primitive_token_keys.text_style,
101
- TName,
102
- typeof primitive_token_keys.letter_spacing,
103
- ]
104
- >;
105
- [primitive_token_keys.line_height]: TokenReferenceSpec<
106
- readonly [
107
- typeof token_groups.primitive,
108
- "typography",
109
- typeof primitive_token_keys.text_style,
110
- TName,
111
- typeof primitive_token_keys.line_height,
112
- ]
113
- >;
114
- }>;
115
-
116
- export type StyleAuthoringHelpers<TPrimitive> = {
117
- template(strings: TemplateStringsArray, ...values: TokenSpec[]): TokenTemplateSpec;
118
- focusRing<TName extends FocusRingName<TPrimitive>>(
119
- name: TName,
120
- options?: {
121
- offset?: TokenSpec;
122
- },
123
- ): {
124
- outline: TokenReferenceSpec<
125
- readonly [typeof token_groups.primitive, "focus", "ring", TName]
126
- >;
127
- "outline-offset"?: TokenSpec;
128
- };
129
- outline(
130
- outline:
131
- | TokenSpec
132
- | {
133
- color: TokenSpec;
134
- style: TokenSpec;
135
- width: TokenSpec;
136
- },
137
- options?: {
138
- offset?: TokenSpec;
139
- },
140
- ): {
141
- outline?: TokenSpec;
142
- "outline-color"?: TokenSpec;
143
- "outline-offset"?: TokenSpec;
144
- "outline-style"?: TokenSpec;
145
- "outline-width"?: TokenSpec;
146
- };
147
- textStyle<TName extends TextStyleName<TPrimitive>>(
148
- name: TName,
149
- ): TextStyleReferences<TName>;
150
- };
151
-
152
- export type SemanticAuthoringContext<TPrimitive> = {
153
- mix: typeof tokenMix;
154
- ref: {
155
- primitive: PrimitiveRefTree<TPrimitive>;
156
- };
157
- style: StyleAuthoringHelpers<TPrimitive>;
158
- };
159
-
160
- export type RecipeAuthoringContext<TPrimitive, TSemantic> = {
161
- mix: typeof tokenMix;
162
- ref: {
163
- primitive: PrimitiveRefTree<TPrimitive>;
164
- semantic: SemanticRefTree<TSemantic>;
165
- };
166
- style: StyleAuthoringHelpers<TPrimitive>;
167
- };
168
-
169
- /////////////////////////////////////////////////////////////////////
170
- /////// Authoring Specs
171
- /////////////////////////////////////////////////////////////////////
172
-
173
- // Ref proxies let authors write token paths naturally while preserving the path as data for the compiler.
174
- export function tokenMix(
175
- input: TokenMixSpec[typeof token_spec_fields.mix],
176
- ): TokenMixSpec {
177
- return {
178
- [token_spec_kind]: token_spec_kinds.mix,
179
- [token_spec_fields.mix]: input,
180
- };
181
- }
182
-
183
- function create_token_ref_proxy(path: TokenPath): unknown {
184
- const handler: ProxyHandler<object> = {
185
- get(_target, property): unknown {
186
- if (property === token_spec_kind) {
187
- return token_spec_kinds.ref;
188
- }
189
-
190
- if (property === token_spec_fields.path) {
191
- return path;
192
- }
193
-
194
- if (typeof property !== "string") {
195
- return undefined;
196
- }
197
-
198
- return create_token_ref_proxy([...path, property] as TokenPath);
199
- },
200
- has(_target, property): boolean {
201
- return property === token_spec_kind || property === token_spec_fields.path;
202
- },
203
- };
204
-
205
- return new Proxy({}, handler);
206
- }
207
-
208
- function create_style_authoring_helpers<TPrimitive>(
209
- primitive: PrimitiveRefTree<TPrimitive>,
210
- primitive_input?: TPrimitive,
211
- ): StyleAuthoringHelpers<TPrimitive> {
212
- const token = primitive as unknown as {
213
- focus: {
214
- ring: Record<string, TokenReferenceSpec<TokenPath>>;
215
- };
216
- typography: {
217
- [primitive_token_keys.text_style]: Record<
218
- string,
219
- {
220
- [primitive_token_keys.font_family]: TokenReferenceSpec<TokenPath>;
221
- [primitive_token_keys.font_size]: TokenReferenceSpec<TokenPath>;
222
- [primitive_token_keys.font_weight]: TokenReferenceSpec<TokenPath>;
223
- [primitive_token_keys.letter_spacing]: TokenReferenceSpec<TokenPath>;
224
- [primitive_token_keys.line_height]: TokenReferenceSpec<TokenPath>;
225
- }
226
- >;
227
- };
228
- };
229
-
230
- return {
231
- template(strings, ...values): TokenTemplateSpec {
232
- return {
233
- [token_spec_kind]: token_spec_kinds.template,
234
- [token_spec_fields.parts]: strings.flatMap(
235
- (string, index): TokenSpec[] => {
236
- const value = values[index];
237
-
238
- if (value === undefined) {
239
- return [string];
240
- }
241
-
242
- return [string, value];
243
- },
244
- ),
245
- };
246
- },
247
- focusRing(name, options) {
248
- return {
249
- outline: token.focus.ring[name] as TokenReferenceSpec<
250
- readonly [typeof token_groups.primitive, "focus", "ring", typeof name]
251
- >,
252
- "outline-offset": options?.offset,
253
- };
254
- },
255
- outline(outline, options) {
256
- if (
257
- typeof outline === "object" &&
258
- outline !== null &&
259
- !(token_spec_kind in outline) &&
260
- "color" in outline &&
261
- "style" in outline &&
262
- "width" in outline
263
- ) {
264
- return {
265
- "outline-color": outline.color,
266
- "outline-offset": options?.offset,
267
- "outline-style": outline.style,
268
- "outline-width": outline.width,
269
- };
270
- }
271
-
272
- return {
273
- outline,
274
- "outline-offset": options?.offset,
275
- };
276
- },
277
- textStyle(name) {
278
- const text_style = token.typography[primitive_token_keys.text_style][name]!;
279
- const typography =
280
- typeof primitive_input === "object" && primitive_input !== null
281
- ? (
282
- primitive_input as {
283
- typography?: {
284
- family?: Record<string, unknown>;
285
- [primitive_token_keys.letter_spacing]?: Record<
286
- string,
287
- unknown
288
- >;
289
- [primitive_token_keys.line_height]?: Record<
290
- string,
291
- unknown
292
- >;
293
- size?: { step: Record<string, unknown> };
294
- [primitive_token_keys.text_style]?: Record<
295
- string,
296
- {
297
- family: string;
298
- letterSpacing: string;
299
- lineHeight: string;
300
- size: string;
301
- weight: string;
302
- }
303
- >;
304
- weight?: Record<string, unknown>;
305
- };
306
- }
307
- ).typography
308
- : undefined;
309
- const text_style_input =
310
- typography?.[primitive_token_keys.text_style]?.[name];
311
- const letter_spacing = typography?.[primitive_token_keys.letter_spacing];
312
- const line_height = typography?.[primitive_token_keys.line_height];
313
-
314
- return {
315
- ...(text_style_input &&
316
- typography?.family &&
317
- text_style_input.family in typography.family
318
- ? {
319
- [primitive_token_keys.font_family]: text_style[
320
- primitive_token_keys.font_family
321
- ] as TextStyleReferences<
322
- typeof name
323
- >[typeof primitive_token_keys.font_family],
324
- }
325
- : {}),
326
- ...(text_style_input &&
327
- typography?.size &&
328
- text_style_input.size in typography.size.step
329
- ? {
330
- [primitive_token_keys.font_size]: text_style[
331
- primitive_token_keys.font_size
332
- ] as TextStyleReferences<
333
- typeof name
334
- >[typeof primitive_token_keys.font_size],
335
- }
336
- : {}),
337
- ...(text_style_input &&
338
- typography?.weight &&
339
- text_style_input.weight in typography.weight
340
- ? {
341
- [primitive_token_keys.font_weight]: text_style[
342
- primitive_token_keys.font_weight
343
- ] as TextStyleReferences<
344
- typeof name
345
- >[typeof primitive_token_keys.font_weight],
346
- }
347
- : {}),
348
- ...(text_style_input &&
349
- letter_spacing &&
350
- text_style_input.letterSpacing in letter_spacing
351
- ? {
352
- [primitive_token_keys.letter_spacing]: text_style[
353
- primitive_token_keys.letter_spacing
354
- ] as TextStyleReferences<
355
- typeof name
356
- >[typeof primitive_token_keys.letter_spacing],
357
- }
358
- : {}),
359
- ...(text_style_input &&
360
- line_height &&
361
- text_style_input.lineHeight in line_height
362
- ? {
363
- [primitive_token_keys.line_height]: text_style[
364
- primitive_token_keys.line_height
365
- ] as TextStyleReferences<
366
- typeof name
367
- >[typeof primitive_token_keys.line_height],
368
- }
369
- : {}),
370
- };
371
- },
372
- };
373
- }
374
-
375
- export function defineSystem<
376
- const TModes extends NonEmptyReadonlyArray<string>,
377
- const TColorSource extends string,
378
- const TFontFamily extends string,
379
- const TLetterSpacing extends string,
380
- const TLineHeight extends string,
381
- const TFontSize extends string,
382
- const TFontWeight extends string,
383
- const TPrimitive extends PrimitiveInput<
384
- TModes[number],
385
- TColorSource,
386
- TFontFamily,
387
- TLetterSpacing,
388
- TLineHeight,
389
- TFontSize,
390
- TFontWeight
391
- >,
392
- const TSemantic extends Partial<Record<TModes[number], object>>,
393
- >(system: {
394
- css: {
395
- variablePrefix: string;
396
- };
397
- modes: TModes;
398
- primitive: TPrimitive;
399
- semantic: (context: SemanticAuthoringContext<TPrimitive>) => TSemantic;
400
- }): {
401
- css: {
402
- variablePrefix: string;
403
- };
404
- modes: TModes;
405
- primitive: TPrimitive;
406
- semantic: TSemantic & Partial<Record<TModes[number], SemanticInput>>;
407
- };
408
-
409
- export function defineSystem<
410
- const TModes extends NonEmptyReadonlyArray<string>,
411
- const TColorSource extends string,
412
- const TFontFamily extends string,
413
- const TLetterSpacing extends string,
414
- const TLineHeight extends string,
415
- const TFontSize extends string,
416
- const TFontWeight extends string,
417
- const TPrimitive extends PrimitiveInput<
418
- TModes[number],
419
- TColorSource,
420
- TFontFamily,
421
- TLetterSpacing,
422
- TLineHeight,
423
- TFontSize,
424
- TFontWeight
425
- > = PrimitiveInput<
426
- TModes[number],
427
- TColorSource,
428
- TFontFamily,
429
- TLetterSpacing,
430
- TLineHeight,
431
- TFontSize,
432
- TFontWeight
433
- >,
434
- const TSemantic extends Partial<Record<TModes[number], object>> = {},
435
- >(system: {
436
- css: {
437
- variablePrefix: string;
438
- };
439
- modes: TModes;
440
- primitive?: TPrimitive;
441
- semantic?: (context: SemanticAuthoringContext<TPrimitive>) => TSemantic;
442
- }): {
443
- css: {
444
- variablePrefix: string;
445
- };
446
- modes: TModes;
447
- primitive?: TPrimitive;
448
- semantic?: TSemantic & Partial<Record<TModes[number], SemanticInput>>;
449
- } {
450
- const primitive = create_token_ref_proxy([
451
- token_groups.primitive,
452
- ]) as PrimitiveRefTree<TPrimitive>;
453
- const style = create_style_authoring_helpers(primitive, system.primitive);
454
- const semantic_input = system.semantic?.({
455
- mix: tokenMix,
456
- ref: {
457
- primitive,
458
- },
459
- style,
460
- });
461
-
462
- return {
463
- css: system.css,
464
- modes: system.modes,
465
- ...(system.primitive
466
- ? {
467
- primitive: system.primitive,
468
- }
469
- : {}),
470
- ...(semantic_input
471
- ? {
472
- semantic: semantic_input as TSemantic &
473
- Partial<Record<TModes[number], SemanticInput>>,
474
- }
475
- : {}),
476
- };
477
- }
478
-
479
- export function defineRecipeStyles<
480
- const TPrimitive,
481
- const TSemantic extends Partial<Record<string, object>>,
482
- const TRecipes extends RecipeStyleDefinitions,
483
- >(
484
- system: {
485
- primitive?: TPrimitive;
486
- semantic?: TSemantic;
487
- },
488
- recipe: (
489
- context: RecipeAuthoringContext<TPrimitive, NoInferFromUsage<TSemantic>>,
490
- ) => TRecipes,
491
- ): TRecipes {
492
- const primitive = create_token_ref_proxy([
493
- token_groups.primitive,
494
- ]) as PrimitiveRefTree<TPrimitive>;
495
- const semantic = create_token_ref_proxy([
496
- token_groups.semantic,
497
- ]) as SemanticRefTree<TSemantic>;
498
- const style = create_style_authoring_helpers(primitive, system.primitive);
499
-
500
- return recipe({
501
- mix: tokenMix,
502
- ref: {
503
- primitive,
504
- semantic,
505
- },
506
- style,
507
- }) as TRecipes;
508
- }
@@ -1,12 +0,0 @@
1
- export function round_number(value: number, precision = 4): number {
2
- const scale = 10 ** precision;
3
- return Math.round(value * scale) / scale;
4
- }
5
-
6
- export function format_px(value: number): string {
7
- return `${round_number(value)}px`;
8
- }
9
-
10
- export function format_rem(px_value: number, base_font_size_px: number): string {
11
- return `${round_number(px_value / base_font_size_px)}rem`;
12
- }
@@ -1,31 +0,0 @@
1
- export function compact_object<T extends object>(input: T): T {
2
- return Object.fromEntries(
3
- Object.entries(input).filter((entry): entry is [string, unknown] => {
4
- return entry[1] !== undefined;
5
- }),
6
- ) as T;
7
- }
8
-
9
- function is_mergeable_token_shape(value: unknown): value is Record<string, unknown> {
10
- return typeof value === "object" && value !== null && !Array.isArray(value);
11
- }
12
-
13
- export function merge_token_shapes(left: unknown, right: unknown): unknown {
14
- if (left === undefined) {
15
- return right;
16
- }
17
-
18
- if (right === undefined) {
19
- return left;
20
- }
21
-
22
- if (!is_mergeable_token_shape(left) || !is_mergeable_token_shape(right)) {
23
- return left;
24
- }
25
-
26
- return Object.fromEntries(
27
- Array.from(new Set([...Object.keys(left), ...Object.keys(right)])).map((key) => {
28
- return [key, merge_token_shapes(left[key], right[key])];
29
- }),
30
- );
31
- }