@ng-native/fabric 0.5.0 → 0.7.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/css.d.ts CHANGED
@@ -222,6 +222,11 @@ export interface DeferredDeclaration {
222
222
  * unambiguous given a single-valued token, so `padding: var(--gap)` writes all four.
223
223
  */
224
224
  readonly props: readonly string[];
225
+ /**
226
+ * `inherit`, written for these props: each is the parent's value for it, or nothing where the
227
+ * parent has none.
228
+ */
229
+ readonly inherit?: true;
225
230
  /** The element a bound declaration is on, by name, for a message about it to say. */
226
231
  readonly on?: string;
227
232
  /** A `var()` reference. Exactly one of this and `compute` is present. */
@@ -294,6 +299,11 @@ export interface DeferredDeclaration {
294
299
  readonly unit: 'em' | 'vw' | 'vh' | 'vmin' | 'vmax';
295
300
  readonly factor: number;
296
301
  readonly offset?: number;
302
+ /**
303
+ * A unitless line-height: the node renders `factor` em, and what it hands down is the number,
304
+ * which each text under it multiplies its own font size by. See `LineHeightMultiple`.
305
+ */
306
+ readonly multiple?: true;
297
307
  };
298
308
  /**
299
309
  * A structured value - a transform list, a shadow, a filter - with lengths like `compute`'s
@@ -325,6 +335,8 @@ export interface LineTemplate {
325
335
  /** `color-mix(in srgb, var(--tint) 35%, transparent)`: the colour, written as a function. */
326
336
  readonly colour?: unknown;
327
337
  readonly style?: string;
338
+ /** Each side's own style, which the line's style is written to as well: see `settleBorders`. */
339
+ readonly marks?: readonly string[];
328
340
  }
329
341
  /**
330
342
  * A colour a deferred value is made of: settled at build time, a token, or a `color-mix()` of two
@@ -370,11 +382,21 @@ export type ColourExpression = {
370
382
  readonly space: MixSpace;
371
383
  readonly hue?: HueMethod;
372
384
  readonly a: ColourExpression;
373
- readonly aPercentage?: number;
385
+ readonly aPercentage?: MixShare;
374
386
  readonly b: ColourExpression;
375
- readonly bPercentage?: number;
387
+ readonly bPercentage?: MixShare;
376
388
  };
377
389
  };
390
+ /**
391
+ * The share of a colour in a mix: a percentage, or a token multiplied into one, as
392
+ * `calc(var(--opacity) * 100%)` is the token times a hundred, with the number the token falls
393
+ * back to where it wrote one.
394
+ */
395
+ export type MixShare = number | {
396
+ readonly reference: string;
397
+ readonly scale: number;
398
+ readonly fallback?: number;
399
+ };
378
400
  /** One component's compiled styles, pre-sorted by specificity then source order. */
379
401
  /**
380
402
  * A gradient with holes in it: everything but the stop colours is settled at build time.
@@ -472,7 +494,23 @@ export interface StyleCache {
472
494
  * subtree changed is compared against, to tell whether it has to be restyled.
473
495
  */
474
496
  matched?: readonly StyleRule[];
497
+ /**
498
+ * Set once a child takes a value from this node's own style, an `inherit` for a property CSS
499
+ * does not hand down: a change to the node's inline style then restyles it, and its children
500
+ * with it, where otherwise an inline style changes nothing a child resolves to.
501
+ */
502
+ heirs?: true;
503
+ /**
504
+ * The properties a rule declared `!important`, where any did: an inline style is the last of
505
+ * the plain declarations, so for these what the rules say stands over it.
506
+ */
507
+ important?: ReadonlySet<string>;
475
508
  }
509
+ /**
510
+ * Whether a child is one `:empty` sees. An anchor is a comment on the web, which it does not;
511
+ * nor text of no length, which a binding to nothing leaves behind.
512
+ */
513
+ export declare function fills(child: StyleTarget): boolean;
476
514
  /** What the matcher needs of a node. The engine's node satisfies this structurally. */
477
515
  export interface StyleTarget {
478
516
  readonly name: string;
@@ -538,6 +576,9 @@ export interface StyleTarget {
538
576
  * did: a press began or ended on it or under it. It is matched again, and keeps the style it
539
577
  * has, and everything under it, when it matches the rules it did. Not for an element a rule
540
578
  * asks about from another one, which is restyled: see `usesActive`.
579
+ *
580
+ * Set as well when its place among its siblings changed and nothing else about it did, which
581
+ * is the same case: what it is asked about from another element is `placeReadElsewhere`.
541
582
  */
542
583
  stateDirty?: boolean;
543
584
  /** `:focus`. Set by the engine from the native focus and blur events. */
@@ -577,6 +618,8 @@ export declare const styleStats: {
577
618
  ruleTests: number;
578
619
  /** Nodes cascaded, as opposed to handed back from the memo. */
579
620
  nodesResolved: number;
621
+ /** Rules filed by key selector: each sheet's once, however many sheets come after it. */
622
+ rulesFiled: number;
580
623
  };
581
624
  export declare function resetStyleStats(): void;
582
625
  /**
@@ -584,6 +627,44 @@ export declare function resetStyleStats(): void;
584
627
  * filter and rejects almost everything immediately.
585
628
  */
586
629
  export declare function matches(node: StyleTarget, rule: StyleRule, sheet?: StyleSheet | null): boolean;
630
+ /** A node's first `count` elements, or its last, skipping everything that is not one. */
631
+ export declare function elementsAtEnd<T extends StyleTarget>(siblings: readonly T[], count: number, fromEnd: boolean): T[];
632
+ /**
633
+ * Which way from a change in a child list a sheet's rules can match differently, past the
634
+ * elements at its two ends. An element's place from the start hangs on the elements before it
635
+ * and on none after, so a change moves the ones after it; its place from the end is the other
636
+ * way about.
637
+ */
638
+ export interface SiblingReach {
639
+ /**
640
+ * How many elements after a change it reaches. All of them, `Infinity`, where it counts from
641
+ * the start (`:nth-child(odd)`) or asks about any element before (`~`). Where it asks only
642
+ * about the element just before (`+`), as many as its longest run of them steps along: one for
643
+ * `.a + .b`, two for `.a + .b + .c`. Zero where it asks none of these.
644
+ */
645
+ readonly after: number;
646
+ /** It counts from the end (`:nth-last-child(2)`). */
647
+ readonly before: boolean;
648
+ }
649
+ /**
650
+ * How far a sheet asks about a child list beyond which element is first and which is last.
651
+ * Where no sheet reaches either way, only the elements at the two ends can match differently.
652
+ */
653
+ export declare function siblingReach(sheet: StyleSheet): SiblingReach;
654
+ /**
655
+ * Each compound in a sheet whose element's place among its siblings is read from another
656
+ * element: one with something under it in the rule, `.row:nth-child(odd) .label` and
657
+ * `.a + .b .c`, or one an `:is()` or `:host-context()` looks for above the element styled.
658
+ *
659
+ * An element whose place changed is matched again, and where it matches the rules it did, it
660
+ * and everything under it are left as they were: its own rules are all that its place can
661
+ * change. Not an element one of these could be. What is under that one can match differently
662
+ * though it matches the same, so it is styled again with everything under it.
663
+ *
664
+ * A place read by the element a rule styles, or by the elements before it that the rule steps
665
+ * from (`.a:first-child + .b`), is that element's own: the rules it matches say.
666
+ */
667
+ export declare function placeReadElsewhere(sheet: StyleSheet): readonly Compound[];
587
668
  /** One rule in a cascade: the sheet it came from, which `:host` needs, and its weight here. */
588
669
  interface RuleEntry {
589
670
  readonly rule: StyleRule;
@@ -600,25 +681,50 @@ interface RuleEntry {
600
681
  * is offered to everything, because the alternative is a rule that silently stops applying.
601
682
  */
602
683
  export declare function ruleKey(rule: StyleRule): string;
603
- /** Where a rule sits in the merged, weight-sorted list. The cascade depends on that order. */
684
+ /**
685
+ * Every bucket a rule is filed under. One, but for a rule whose rightmost compound is only an
686
+ * `:is()` of compounds that each have a key: it is filed under each of theirs, since a node it
687
+ * matches has one of them.
688
+ *
689
+ * A rule that says nothing of the node's own name can still say whose child it is, `.row > *`.
690
+ * It is filed under the parent's class, and offered to the children of an element that has it.
691
+ */
692
+ export declare function ruleKeys(rule: StyleRule): readonly string[];
693
+ /** A rule in an index, and where it comes among rules of the same weight: the order it was written in. */
604
694
  interface IndexedEntry {
605
695
  readonly entry: RuleEntry;
606
696
  readonly at: number;
607
697
  }
608
698
  export interface RuleIndex {
609
- readonly buckets: ReadonlyMap<string, readonly IndexedEntry[]>;
610
- readonly universal: readonly IndexedEntry[];
699
+ readonly buckets: Map<string, IndexedEntry[]>;
700
+ readonly universal: IndexedEntry[];
611
701
  }
612
- /** File a merged, sorted rule list by key selector. Done once per sheet pair, not per node. */
613
- export declare function indexRules(entries: readonly RuleEntry[]): RuleIndex;
614
702
  /**
615
- * The rules worth trying against a node, in the order they were merged in.
703
+ * File rules by key selector, each at `from` and on: its place among every rule there is, which
704
+ * settles the order of two of the same weight. Into an index there already where one is given,
705
+ * so a sheet that arrives later is added to what is filed and nothing is filed again.
706
+ */
707
+ export declare function indexRules(entries: readonly RuleEntry[], into?: RuleIndex, from?: number): RuleIndex;
708
+ /**
709
+ * The rules worth trying against a node, in cascade order: `order` says which of two comes
710
+ * first, and with none it is the order they were filed in.
616
711
  *
617
- * Each bucket is already in order, so the collected list only needs sorting when more than one
618
- * contributed - which for a node with one class and a name is the common case, and cheap: the
619
- * lists are short by construction, which is the entire point of the index.
712
+ * From each index, only the buckets the node's name, id and classes reach, which is the entire
713
+ * point of the index: the lists are short by construction, so sorting them is cheap.
620
714
  */
621
- export declare function candidateRules(node: StyleTarget, index: RuleIndex): RuleEntry[];
715
+ export declare function candidateRules(node: StyleTarget, indexes: RuleIndex | readonly RuleIndex[], order?: (a: IndexedEntry, b: IndexedEntry) => number): RuleEntry[];
716
+ /** What a sheet's rules are written for: the last compound of each, by its class or its name. */
717
+ export interface Subjects {
718
+ readonly classes: Set<string>;
719
+ readonly types: Set<string>;
720
+ /**
721
+ * The classes of the boxes that rules for anything are written inside: `.dialog > :first-child`
722
+ * is for any element, but only one that has an element with `dialog` over it.
723
+ */
724
+ readonly inside: Set<string>;
725
+ /** A rule for anything anywhere: no class, no name, and no such box to be in. */
726
+ any: boolean;
727
+ }
622
728
  /** Whether an inline style sets a property children inherit. Allocates nothing: it runs per set. */
623
729
  export declare function setsInherited(style: unknown): boolean;
624
730
  /**
@@ -663,7 +769,12 @@ export declare class StyleResolver {
663
769
  * selector. Keyed by the creating sheet and then the hosted one, so a component's nodes share a
664
770
  * single index.
665
771
  */
666
- private merged;
772
+ /** The global sheet and every sheet added to it, filed by key selector. See `rulesFor`. */
773
+ private filed;
774
+ /** How many of the added sheets `filed` holds: one added since is filed at the next read. */
775
+ private filedAdded;
776
+ /** A component's own sheet, indexed once for each place it can take: a host's, or its creator's. */
777
+ private readonly ownIndexes;
667
778
  /**
668
779
  * Whether any sheet merged so far has a rule in a cascade layer. Until one does, rules are
669
780
  * ordered by weight alone and the cascade does not look for layers, which is nearly every app.
@@ -722,6 +833,35 @@ export declare class StyleResolver {
722
833
  * swap of the component's CSS edits the sheet where it is.
723
834
  */
724
835
  addGlobalSheet(sheet: StyleSheet, replacing?: StyleSheet): boolean;
836
+ /**
837
+ * The sheets added one after another with nothing else changed between them, each with the
838
+ * generation it began and ended: a cache made before them still stands for a node none of
839
+ * them could match. Emptied by anything else that moves the generation on.
840
+ */
841
+ private readonly additions;
842
+ /** Whether a sheet could match a node: one of its rules is written for it. */
843
+ couldMatch(sheet: StyleSheet, node: StyleTarget): boolean;
844
+ /** How far each class named by the sheets met so far reaches: see `classReach`. */
845
+ private readonly reach;
846
+ /** The tests of the `class` attribute itself in those sheets, which any class may answer. */
847
+ private readonly classTests;
848
+ private readonly noted;
849
+ /** Read the classes a sheet names, once, as soon as any node is given it. */
850
+ noteSheet(sheet: StyleSheet | null | undefined): void;
851
+ private noteReach;
852
+ /**
853
+ * What classes coming to an element or going from it can restyle: `true` for it and all
854
+ * under it and after it, as any change to it does; the elements under it to restyle, by what
855
+ * rules are for; or null, where no rule names any of them and nothing is styled again.
856
+ */
857
+ reachOf(classes: Iterable<string>): true | Subjects | null;
858
+ /** Whether one of the rules `subjects` stands for could be for a node. */
859
+ isFor(subjects: Subjects, node: StyleTarget): boolean;
860
+ /**
861
+ * Whether a cache is of this generation, or of one before sheets that could not match the
862
+ * node were added, which leaves it as it was: it is then brought up to this one.
863
+ */
864
+ private current;
725
865
  /** Stop matching a sheet `addGlobalSheet` added; false when it is not one. */
726
866
  removeGlobalSheet(sheet: StyleSheet): boolean;
727
867
  setConditions(next: Conditions): void;
@@ -733,11 +873,15 @@ export declare class StyleResolver {
733
873
  * resolves at most once however many descendants ask for its inherited values.
734
874
  */
735
875
  resolve(node: StyleTarget, epoch: number): StyleCache;
736
- /** The rules a node matched, for its cache to keep, while a sheet uses `:has()`. */
737
- private record;
738
876
  /**
739
- * Set by the engine once a sheet uses `:has()`. Until then no cache keeps the rules it matched,
740
- * so an app that never asks pays nothing for it.
877
+ * A cache of a node just styled, with a context of its own. It keeps the rules the node
878
+ * matched, for the node to be compared with, once a sheet has a use for them: see `tracksHas`.
879
+ */
880
+ private cached;
881
+ /**
882
+ * Set by the engine once a sheet uses `:has()`, styles a pressed element or asks about a place
883
+ * in a child list. Until then no cache keeps the rules it matched, so an app that never asks
884
+ * pays nothing for it.
741
885
  */
742
886
  tracksHas: boolean;
743
887
  /**
@@ -746,6 +890,13 @@ export declare class StyleResolver {
746
890
  * resolved, as it does with no record of what it matched, made before any sheet asked.
747
891
  */
748
892
  private keptBeneath;
893
+ /** The rules a node matches now, weakest first. */
894
+ private matchedBy;
895
+ /**
896
+ * The rules `keptBeneath` found the node being resolved to match, where they are other than
897
+ * it matched before: it is styled from them next, rather than matched a second time.
898
+ */
899
+ private justMatched;
749
900
  /** A cache that still stands for a node marked for its subtree or its state alone. */
750
901
  private kept;
751
902
  /**
@@ -779,26 +930,34 @@ export declare class StyleResolver {
779
930
  */
780
931
  private unstyled;
781
932
  /**
782
- * The rules worth trying against a node.
933
+ * The rules worth trying against a node, in cascade order.
783
934
  *
784
- * The merged list is built once per (creating sheet, hosted sheet) pair and indexed by key
785
- * selector; what comes back here is only the buckets this node can reach. For a component's own
786
- * sheet that changes little, but a global utility sheet is hundreds of rules and a screen is a
787
- * thousand nodes, and the difference is between a million match attempts and a few thousand.
788
- */
789
- private rulesFor;
790
- /**
791
- * Weakest first. A host node is matched against two component sheets: the one belonging to the
792
- * component it hosts, whose `:host` rules exist to reach exactly this node, and the one that
793
- * created it. Both carry the bump; the creator comes later and so wins a tie, as the outer
794
- * document does over `:host` on the web. The sort is stable, so within one sheet source order
795
- * survives and a later sheet wins equal weight.
935
+ * Every sheet is filed once, by key selector: the app's global sheet and each sheet added to it
936
+ * in one index, and a component's own in one of its own. What comes back is only the buckets
937
+ * this node can reach. A global utility sheet is hundreds of rules and a screen is a thousand
938
+ * nodes, and the difference is between a million match attempts and a few thousand. A library
939
+ * adds a sheet for each of its components as the component first renders, dozens on one
940
+ * screen, so one more is added to what is filed and nothing is filed again.
941
+ *
942
+ * Sheets are filed in the order a document holds them, which is the order of two rules of the
943
+ * same weight, and where a layer gets its place: the app's global sheet, the host's own, the
944
+ * creating component's, then each added sheet as it came. The component layers get a small
945
+ * specificity bump, so the encapsulation attribute Angular adds on the web does not have to
946
+ * be written.
796
947
  *
797
948
  * A sheet added with `addGlobalSheet` comes last, with no bump: a browser adds a None
798
949
  * component's CSS when the component first renders, after the styles of the components around
799
950
  * it, so it loses to their extra attribute and wins a tie with them.
800
951
  */
801
- private merge;
952
+ private rulesFor;
953
+ /** Weakest first: by layer where any sheet has one, then by weight, then as they were filed. */
954
+ private readonly cascadeOrder;
955
+ /** A component's sheet as the rules of a host or of a creator, which differ only in their place. */
956
+ private ownIndex;
957
+ /** The app's global sheet and every sheet added to it, with any added since the last read. */
958
+ private sharedIndex;
959
+ /** A sheet's rules at their weight here, with its layers given their places. */
960
+ private entries;
802
961
  /**
803
962
  * Gives each of a sheet's layers its place among every sheet's, the first time the sheet is
804
963
  * merged, and each of its layered rules that place. Sheets are merged in the order a document
@@ -856,6 +1015,19 @@ export declare class StyleResolver {
856
1015
  * undefined, which is what a browser does with a value it cannot resolve.
857
1016
  */
858
1017
  private applyDeferred;
1018
+ /** Note what the node being resolved takes an `inherit` from, and that its parent has an heir. */
1019
+ private heir;
1020
+ /** What the parent of the node being resolved came to: an `inherit` takes its values from it. */
1021
+ private parentOf;
1022
+ /** That parent's inline style, which is over what its rules gave it. */
1023
+ private parentInline;
1024
+ /** What the parent's inline style sets, under what its rules marked important, as on the parent. */
1025
+ private parentSet;
1026
+ /**
1027
+ * `inherit`: each prop as the parent has it, handed down or its own, and gone where the parent
1028
+ * has none, which is what a weaker rule's value for it gives way to.
1029
+ */
1030
+ private inherit;
859
1031
  /** One deferred declaration's value, from the tokens in scope and the node's own style. */
860
1032
  private settled;
861
1033
  /** A line's longhands from its tokens, with a width in `em` worked out against the font size. */
@@ -907,6 +1079,15 @@ interface CalcMarker {
907
1079
  readonly expression: CalcExpression;
908
1080
  readonly kind: 'length' | 'angle' | 'time' | 'number';
909
1081
  }
1082
+ /**
1083
+ * A colour at a fraction of its opacity.
1084
+ *
1085
+ * Multiplied rather than replaced, so a token that was already translucent stays relatively so -
1086
+ * `rgba(0, 0, 0, 0.5)` faded to 90% is 45% opaque, which is what a browser computes for the same
1087
+ * mix. A value that is not one of ours is returned untouched: it may be a platform colour, and a
1088
+ * colour nobody can parse is better painted as it stands than dropped.
1089
+ */
1090
+ export declare function faded(value: unknown, fraction: number): unknown;
910
1091
  /**
911
1092
  * Where a component's compiled sheet lives: a static on the component class, written by the
912
1093
  * Metro transformer at build time.