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