@ng-native/fabric 0.13.0 → 0.14.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
@@ -487,6 +487,11 @@ export interface StyleSheet {
487
487
  /** The weights a variable font covers, `font-weight: 100 900`, in place of one `weight`. */
488
488
  readonly weightRange?: readonly [number, number];
489
489
  readonly style?: string;
490
+ /**
491
+ * The name inside the face's file, which the build reads where it can. SwiftUI finds a face by
492
+ * this name only, and not by the name it is registered under.
493
+ */
494
+ readonly postScriptName?: string;
490
495
  }[];
491
496
  }
492
497
  export interface StyleCache {
@@ -549,7 +554,7 @@ export interface StyleCache {
549
554
  export declare function fills(child: StyleTarget): boolean;
550
555
  /** What the matcher needs of a node. The engine's node satisfies this structurally. */
551
556
  export interface StyleTarget {
552
- readonly name: string;
557
+ readonly tag: string;
553
558
  readonly parent: StyleTarget | null;
554
559
  /**
555
560
  * Needed only by the selectors that ask about a node's place among its siblings, which is why
@@ -1179,6 +1184,16 @@ export declare class StyleResolver {
1179
1184
  * property, `[style.--gap]`, and read that in the stylesheet.
1180
1185
  */
1181
1186
  export declare function boundDeclaration(prop: string, token: TokenValue | undefined, on?: string): DeferredDeclaration | null;
1187
+ /** Whether `text` is a `line-height` below zero, which a browser drops: `-1.5`, `-1em`, `-2px`. */
1188
+ export declare const isNegativeLineHeight: (prop: string, text: string) => boolean;
1189
+ /**
1190
+ * A bound declaration of a length in `em` or a viewport unit, `[style.width]="'2em'"`, as the
1191
+ * deferred declaration the compiler writes for the same value in a rule: measured where it is
1192
+ * used, against the font size in scope. A viewport unit is measured against the viewport, and
1193
+ * again when it changes. A `line-height` with no unit is the number a rule hands down. Null for
1194
+ * any other value, and for a property that takes no length.
1195
+ */
1196
+ export declare function boundRelativeLength(prop: string, text: string, on?: string): DeferredDeclaration | null;
1182
1197
  /** `hsl()` reads a channels token as hue, saturation and lightness; `rgb()` as sRGB. */
1183
1198
  type ChannelSpace = 'rgb' | 'hsl';
1184
1199
  /**
package/dist/css.js CHANGED
@@ -252,8 +252,8 @@ function matchesValue(value, operator, expected) {
252
252
  case 'substring':
253
253
  return value.includes(expected);
254
254
  case 'includes':
255
- // `~=` matches one whole word of a space-separated list.
256
- return value.split(/\s+/).includes(expected);
255
+ // `~=` matches one whole word of a list split at CSS's spaces, which a no-break space is not.
256
+ return value.split(CSS_SPACE).includes(expected);
257
257
  case 'dash-match':
258
258
  // `|=` matches the value itself or the value followed by a hyphen, as `lang` uses.
259
259
  return value === expected || value.startsWith(`${expected}-`);
@@ -288,7 +288,7 @@ function matchesCompound(node, compound, sheet) {
288
288
  return false;
289
289
  }
290
290
  }
291
- if (compound.type !== undefined && compound.type !== node.name)
291
+ if (compound.type !== undefined && compound.type !== node.tag)
292
292
  return false;
293
293
  if (compound.own !== undefined && !ownedBy(node, compound, sheet))
294
294
  return false;
@@ -511,8 +511,8 @@ function bitsAbove(node) {
511
511
  if (up.classes)
512
512
  for (const className of up.classes)
513
513
  add(bitOf('.', className));
514
- if (up.name !== undefined)
515
- add(bitOf('<', up.name));
514
+ if (up.tag !== undefined)
515
+ add(bitOf('<', up.tag));
516
516
  const id = up.props?.['nativeID'];
517
517
  if (typeof id === 'string')
518
518
  add(bitOf('#', id));
@@ -918,7 +918,7 @@ function countPosition(node, siblings, fromEnd, ofType) {
918
918
  let position = 0;
919
919
  let seen = 0;
920
920
  for (const sibling of siblings) {
921
- if (!isElement(sibling) || (ofType && sibling.name !== node.name))
921
+ if (!isElement(sibling) || (ofType && sibling.tag !== node.tag))
922
922
  continue;
923
923
  seen++;
924
924
  if (sibling === node)
@@ -1115,7 +1115,7 @@ function reach(node, index, found) {
1115
1115
  };
1116
1116
  if (index.universal.length)
1117
1117
  found.push(...index.universal);
1118
- take(`type:${node.name}`);
1118
+ take(`type:${node.tag}`);
1119
1119
  const id = node.props['nativeID'];
1120
1120
  if (typeof id === 'string')
1121
1121
  take(`id:${id}`);
@@ -1460,7 +1460,7 @@ function boxAround(rule) {
1460
1460
  }
1461
1461
  /** Whether a rule among these could be for a node: never no where one is. */
1462
1462
  function writtenFor(of, node) {
1463
- if (of.any || of.types.has(node.name))
1463
+ if (of.any || of.types.has(node.tag))
1464
1464
  return true;
1465
1465
  for (const name of node.classes ?? [])
1466
1466
  if (of.classes.has(name))
@@ -3321,6 +3321,47 @@ export function boundDeclaration(prop, token, on) {
3321
3321
  ...(token && isDerived(token) ? { fallbackToken: token } : {}),
3322
3322
  };
3323
3323
  }
3324
+ /** A CSS number: `1.5`, `+1.5`, `.5`, `1e0`, `-2`. */
3325
+ const CSS_NUMBER = String.raw `[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?`;
3326
+ /** A length in `em` or a viewport unit, the whole value: `2em`, `-0.5em`, `50vw`. */
3327
+ const RELATIVE_LENGTH = new RegExp(String.raw `^\s*(${CSS_NUMBER})(em|vw|vh|vmin|vmax)\s*$`, 'i');
3328
+ /** A number with no unit, as a `line-height` is written: a multiple of the font size. */
3329
+ const UNITLESS = new RegExp(String.raw `^\s*(${CSS_NUMBER})\s*$`, 'i');
3330
+ /** A negative `line-height`, of a number or a length, which CSS has no value for. */
3331
+ const NEGATIVE = new RegExp(String.raw `^\s*-(?:\d|\.\d)`);
3332
+ /** Whether `text` is a `line-height` below zero, which a browser drops: `-1.5`, `-1em`, `-2px`. */
3333
+ export const isNegativeLineHeight = (prop, text) => prop === 'lineHeight' && NEGATIVE.test(text);
3334
+ /**
3335
+ * A bound declaration of a length in `em` or a viewport unit, `[style.width]="'2em'"`, as the
3336
+ * deferred declaration the compiler writes for the same value in a rule: measured where it is
3337
+ * used, against the font size in scope. A viewport unit is measured against the viewport, and
3338
+ * again when it changes. A `line-height` with no unit is the number a rule hands down. Null for
3339
+ * any other value, and for a property that takes no length.
3340
+ */
3341
+ export function boundRelativeLength(prop, text, on) {
3342
+ const kind = boundKind(prop);
3343
+ if (kind !== 'length' && kind !== 'lineHeight')
3344
+ return null;
3345
+ const relative = RELATIVE_LENGTH.exec(text);
3346
+ if (relative) {
3347
+ const unit = relative[2].toLowerCase();
3348
+ return {
3349
+ props: [prop],
3350
+ ...(on === undefined ? {} : { on }),
3351
+ compute: { unit, factor: Number(relative[1]) },
3352
+ };
3353
+ }
3354
+ // A line height with no unit is a number each text under it multiplies its own font size by,
3355
+ // not the points it comes to here: the compiler writes the same for it in a rule.
3356
+ const unitless = kind === 'lineHeight' ? UNITLESS.exec(text) : null;
3357
+ if (!unitless)
3358
+ return null;
3359
+ return {
3360
+ props: [prop],
3361
+ ...(on === undefined ? {} : { on }),
3362
+ compute: { unit: 'em', factor: Number(unitless[1]), multiple: true },
3363
+ };
3364
+ }
3324
3365
  /** The names a `var()` tries in turn: its own, then each `var()` nested as its fallback. */
3325
3366
  function aliasesOf(token) {
3326
3367
  const names = [];