react-native-nano-icons 1.0.1 → 1.1.0-beta.2

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 (138) hide show
  1. package/README.md +139 -21
  2. package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +15 -0
  3. package/android/src/main/java/com/nanoicons/NanoIconView.kt +27 -4
  4. package/android/src/main/java/com/nanoicons/NanoIconViewManager.kt +7 -0
  5. package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +3 -0
  6. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconProps.cpp +6 -1
  7. package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconProps.h +4 -2
  8. package/ios/NanoIconView.mm +34 -44
  9. package/ios/NanoIconsFontLoader.mm +5 -0
  10. package/lib/commonjs/cli/build.d.ts +26 -0
  11. package/lib/commonjs/cli/build.js +174 -64
  12. package/lib/commonjs/cli/buildSymbols.d.ts +30 -1
  13. package/lib/commonjs/cli/buildSymbols.js +120 -42
  14. package/lib/commonjs/cli/expoConfig.d.ts +11 -0
  15. package/lib/commonjs/cli/expoConfig.js +28 -9
  16. package/lib/commonjs/cli/fingerprint.d.ts +15 -0
  17. package/lib/commonjs/cli/fingerprint.js +42 -0
  18. package/lib/commonjs/cli/index.d.ts +2 -2
  19. package/lib/commonjs/cli/index.js +3 -1
  20. package/lib/commonjs/cli/link.d.ts +4 -0
  21. package/lib/commonjs/cli/link.js +38 -1
  22. package/lib/commonjs/cli/sameOutputs.d.ts +5 -0
  23. package/lib/commonjs/cli/sameOutputs.js +45 -0
  24. package/lib/commonjs/index.node.js +1 -1
  25. package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -2
  26. package/lib/commonjs/plugin/src/buildFonts.js +11 -3
  27. package/lib/commonjs/plugin/src/buildSymbols.d.ts +2 -2
  28. package/lib/commonjs/plugin/src/buildSymbols.js +10 -3
  29. package/lib/commonjs/plugin/src/frozen.d.ts +3 -0
  30. package/lib/commonjs/plugin/src/frozen.js +18 -0
  31. package/lib/commonjs/plugin/src/index.js +3 -3
  32. package/lib/commonjs/plugin/src/types.d.ts +22 -1
  33. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.d.ts +1 -1
  34. package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.js +2 -2
  35. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +3 -3
  36. package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +8 -8
  37. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.d.ts +1 -1
  38. package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.js +2 -2
  39. package/lib/commonjs/scripts/cli.js +31 -2
  40. package/lib/commonjs/src/core/flatten/dom.js +40 -5
  41. package/lib/commonjs/src/core/flatten/element.js +2 -1
  42. package/lib/commonjs/src/core/flatten/stages/collapse.js +12 -0
  43. package/lib/commonjs/src/core/font/compile.d.ts +0 -1
  44. package/lib/commonjs/src/core/font/compile.js +2 -8
  45. package/lib/commonjs/src/core/glyph/merge.d.ts +2 -1
  46. package/lib/commonjs/src/core/glyph/merge.js +27 -36
  47. package/lib/commonjs/src/core/glyph/parse.d.ts +1 -2
  48. package/lib/commonjs/src/core/glyph/parse.js +31 -18
  49. package/lib/commonjs/src/core/glyph/placement.d.ts +1 -0
  50. package/lib/commonjs/src/core/glyph/placement.js +9 -3
  51. package/lib/commonjs/src/core/pathkit/types.d.ts +1 -0
  52. package/lib/commonjs/src/core/pathkit/winding.d.ts +14 -3
  53. package/lib/commonjs/src/core/pathkit/winding.js +434 -7
  54. package/lib/commonjs/src/core/pipeline/config.d.ts +1 -0
  55. package/lib/commonjs/src/core/pipeline/prepare.d.ts +1 -1
  56. package/lib/commonjs/src/core/pipeline/prepare.js +4 -16
  57. package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +1 -0
  58. package/lib/commonjs/src/core/pipeline/prepareIcon.js +3 -1
  59. package/lib/commonjs/src/core/pipeline/prepareSymbol.d.ts +2 -0
  60. package/lib/commonjs/src/core/pipeline/prepareSymbol.js +15 -3
  61. package/lib/commonjs/src/core/pipeline/preparedSvgCache.js +2 -2
  62. package/lib/commonjs/src/core/pipeline/runFontPipeline.js +20 -12
  63. package/lib/commonjs/src/core/pipeline/runSymbolPipeline.d.ts +2 -0
  64. package/lib/commonjs/src/core/pipeline/runSymbolPipeline.js +2 -0
  65. package/lib/commonjs/src/core/symbols/contents.d.ts +1 -1
  66. package/lib/commonjs/src/core/symbols/contents.js +6 -2
  67. package/lib/commonjs/src/core/symbols/knockout.js +4 -3
  68. package/lib/commonjs/src/core/symbols/layers.d.ts +1 -0
  69. package/lib/commonjs/src/core/symbols/layers.js +133 -92
  70. package/lib/commonjs/src/core/symbols/template.d.ts +8 -3
  71. package/lib/commonjs/src/core/symbols/template.js +23 -8
  72. package/lib/commonjs/src/core/symbols/vectorDrawable.d.ts +8 -0
  73. package/lib/commonjs/src/core/symbols/vectorDrawable.js +28 -2
  74. package/lib/commonjs/src/utils/fingerPrint.d.ts +3 -0
  75. package/lib/commonjs/src/utils/fingerPrint.js +5 -1
  76. package/lib/commonjs/src/utils/fontIdentity.d.ts +1 -1
  77. package/lib/commonjs/src/utils/fontIdentity.js +2 -2
  78. package/lib/module/createNanoIconsSet.js +0 -1
  79. package/lib/module/createNanoIconsSet.native.js +22 -18
  80. package/lib/module/createNanoIconsSet.shared.js +32 -18
  81. package/lib/module/createNanoIconsSet.web.js +103 -61
  82. package/lib/module/devServerFont.js +1 -1
  83. package/lib/module/devServerFont.web.js +3 -5
  84. package/lib/module/fontIntegrity.js +20 -38
  85. package/lib/module/fontIntegrity.web.js +48 -0
  86. package/lib/module/fontIntegrityStore.js +65 -0
  87. package/lib/module/index.js +1 -1
  88. package/lib/module/index.node.js +1 -1
  89. package/lib/module/index.web.js +4 -0
  90. package/lib/module/loadDynamicFont.js +3 -15
  91. package/lib/module/specs/NanoIconViewNativeComponent.ts +2 -1
  92. package/lib/module/utils/fingerPrint.js +4 -3
  93. package/lib/module/utils/fontIdentity.js +2 -2
  94. package/lib/module/utils/fontScale.js +10 -2
  95. package/lib/module/utils/glyphRuntime.js +13 -0
  96. package/lib/module/utils/iconAccessibility.js +26 -0
  97. package/lib/module/utils/iconPropsEqual.js +27 -0
  98. package/lib/module/utils/webCss.js +26 -0
  99. package/lib/module/utils/webStyle.js +86 -0
  100. package/lib/module/webFont.js +33 -0
  101. package/lib/typescript/src/const/codegenPrimitives.d.ts +1 -0
  102. package/lib/typescript/src/core/glyph/merge.d.ts +2 -1
  103. package/lib/typescript/src/core/glyph/parse.d.ts +1 -2
  104. package/lib/typescript/src/core/glyph/placement.d.ts +1 -0
  105. package/lib/typescript/src/core/pathkit/types.d.ts +1 -0
  106. package/lib/typescript/src/core/pathkit/winding.d.ts +14 -3
  107. package/lib/typescript/src/core/symbols/contents.d.ts +1 -1
  108. package/lib/typescript/src/core/symbols/layers.d.ts +1 -0
  109. package/lib/typescript/src/core/symbols/template.d.ts +8 -3
  110. package/lib/typescript/src/core/symbols/vectorDrawable.d.ts +8 -0
  111. package/lib/typescript/src/createNanoIconsSet.d.ts +0 -1
  112. package/lib/typescript/src/createNanoIconsSet.native.d.ts +0 -2
  113. package/lib/typescript/src/createNanoIconsSet.shared.d.ts +1 -3
  114. package/lib/typescript/src/createNanoIconsSet.web.d.ts +1 -2
  115. package/lib/typescript/src/fontIntegrity.d.ts +2 -14
  116. package/lib/typescript/src/fontIntegrity.web.d.ts +7 -0
  117. package/lib/typescript/src/fontIntegrityStore.d.ts +19 -0
  118. package/lib/typescript/src/index.d.ts +2 -1
  119. package/lib/typescript/src/index.web.d.ts +5 -0
  120. package/lib/typescript/src/loadDynamicFont.d.ts +0 -1
  121. package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts +2 -1
  122. package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts +1 -0
  123. package/lib/typescript/src/types.d.ts +37 -9
  124. package/lib/typescript/src/utils/fingerPrint.d.ts +3 -0
  125. package/lib/typescript/src/utils/fontIdentity.d.ts +1 -1
  126. package/lib/typescript/src/utils/glyphRuntime.d.ts +8 -0
  127. package/lib/typescript/src/utils/iconAccessibility.d.ts +4 -0
  128. package/lib/typescript/src/utils/iconPropsEqual.d.ts +4 -0
  129. package/lib/typescript/src/utils/webCss.d.ts +9 -0
  130. package/lib/typescript/src/utils/webStyle.d.ts +3 -0
  131. package/lib/typescript/src/webFont.d.ts +6 -0
  132. package/package.json +19 -3
  133. package/src/const/codegenPrimitives.ts +3 -3
  134. package/src/specs/NanoIconViewNativeComponent.ts +2 -1
  135. package/src/specs/NativeNanoIconsFontLoader.ts +1 -0
  136. package/lib/commonjs/src/core/pathkit/evenodd.d.ts +0 -12
  137. package/lib/commonjs/src/core/pathkit/evenodd.js +0 -37
  138. package/lib/typescript/src/core/pathkit/evenodd.d.ts +0 -13
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ import * as React from 'react';
4
+ import { configuredFontFamily } from "./utils/fontIdentity.js";
5
+ import { warnRuntime } from "./utils/runtimeLog.js";
6
+ const issues = new Map();
7
+ const listeners = new Set();
8
+ export function causeDetail(cause) {
9
+ return cause === undefined ? [] : [cause];
10
+ }
11
+ export function recordIssue(family, linking, message, cause, notifyLater = false) {
12
+ const issue = {
13
+ fontFamily: configuredFontFamily(family),
14
+ family,
15
+ linking,
16
+ message,
17
+ ...(cause === undefined ? {} : {
18
+ cause
19
+ })
20
+ };
21
+ issues.set(family, issue);
22
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
23
+ warnRuntime(message, ...causeDetail(cause));
24
+ }
25
+ if (!notifyLater) {
26
+ for (const listener of listeners) listener(issue, 'found');
27
+ return;
28
+ }
29
+ const subscribed = [...listeners];
30
+ void Promise.resolve().then(() => {
31
+ for (const listener of subscribed) {
32
+ if (listeners.has(listener)) listener(issue, 'found');
33
+ }
34
+ });
35
+ }
36
+ export function resolveFontIssue(family) {
37
+ const issue = issues.get(family);
38
+ if (!issue) return;
39
+ issues.delete(family);
40
+ for (const listener of listeners) listener(issue, 'resolved');
41
+ }
42
+ export function addFontIntegrityListener(listener) {
43
+ listeners.add(listener);
44
+ for (const issue of issues.values()) listener(issue, 'found');
45
+ return () => {
46
+ listeners.delete(listener);
47
+ };
48
+ }
49
+ export function getFontIntegrityIssues() {
50
+ return [...issues.values()];
51
+ }
52
+ function subscribe(onChange) {
53
+ const listener = () => onChange();
54
+ listeners.add(listener);
55
+ return () => {
56
+ listeners.delete(listener);
57
+ };
58
+ }
59
+ export function useFontIntegrityIssue(family) {
60
+ return React.useSyncExternalStore(subscribe, () => issues.get(family), () => undefined);
61
+ }
62
+ export function __resetFontIssuesForTests() {
63
+ issues.clear();
64
+ listeners.clear();
65
+ }
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
 
3
3
  export { createIconSet as createNanoIconSet } from './createNanoIconsSet';
4
- export { addFontIntegrityListener, getFontIntegrityIssues } from "./fontIntegrity.js";
4
+ export { addFontIntegrityListener, getFontIntegrityIssues, useFontIntegrityIssue } from './fontIntegrity';
@@ -3,7 +3,7 @@
3
3
  const createNanoIconSet = (...args) => {
4
4
  const {
5
5
  createIconSet
6
- } = require('./createNanoIconsSet');
6
+ } = require('../module/createNanoIconsSet.web.js');
7
7
  return createIconSet(...args);
8
8
  };
9
9
  const plugin = require('./plugin/src/index').default;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { createIconSet as createNanoIconSet } from "./createNanoIconsSet.web.js";
4
+ export { addFontIntegrityListener, getFontIntegrityIssues, useFontIntegrityIssue } from "./fontIntegrity.web.js";
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  import { useSyncExternalStore } from 'react';
4
- import { Image, Platform } from 'react-native';
5
- import { FONT_SOURCE_CODE, resolveFontIssue } from "./fontIntegrity.js";
4
+ import { Image } from 'react-native';
5
+ import { FONT_SOURCE_CODE, resolveFontIssue } from './fontIntegrity';
6
6
  import NanoIconsFontLoader from './nativeFontLoader';
7
7
  import { runtimeError } from "./utils/runtimeLog.js";
8
8
 
@@ -46,18 +46,6 @@ export function resolveFontUri(font) {
46
46
  throw fontSourceError('Unsupported font source. Pass require("Foo.ttf"), { uri }, or a path string.');
47
47
  }
48
48
  async function register(family, uri) {
49
- if (Platform.OS === 'web') {
50
- // Browser FontFace API. Typed loosely so this compiles under both the RN-only
51
- // lib config and a DOM-aware app config without depending on the DOM lib.
52
- const g = globalThis;
53
- if (!g.FontFace || !g.document?.fonts) {
54
- throw runtimeError('FontFace API unavailable; cannot load dynamic font on this platform.');
55
- }
56
- const face = new g.FontFace(family, `url(${uri})`);
57
- await face.load();
58
- g.document.fonts.add(face);
59
- return;
60
- }
61
49
  if (!NanoIconsFontLoader) {
62
50
  throw runtimeError('Native font loader is unavailable (Expo Go or module not built). ' + 'Load the font yourself, or use a development/production build.');
63
51
  }
@@ -113,7 +101,7 @@ export function useDynamicFontPending(managed, family) {
113
101
  const status = useDynamicFontStatus(family);
114
102
  return managed && status === 'loading';
115
103
  }
116
- export function useDynamicFontStatus(family) {
104
+ function useDynamicFontStatus(family) {
117
105
  return useSyncExternalStore(cb => {
118
106
  listeners.add(cb);
119
107
  return () => listeners.delete(cb);
@@ -1,6 +1,6 @@
1
1
  import { codegenNativeComponent } from 'react-native';
2
2
  import type { ColorValue, ViewProps } from 'react-native';
3
- import type { Float, Int32 } from '../const/codegenPrimitives';
3
+ import type { Float, Int32, WithDefault } from '../const/codegenPrimitives';
4
4
 
5
5
  export interface NativeProps extends ViewProps {
6
6
  fontFamily: string;
@@ -12,6 +12,7 @@ export interface NativeProps extends ViewProps {
12
12
  fontScale: Float;
13
13
  advanceWidth: Int32;
14
14
  unitsPerEm: Int32;
15
+ squareGlyphScale?: WithDefault<Float, 0>;
15
16
  }
16
17
 
17
18
  export default codegenNativeComponent<NativeProps>('NanoIconView', {
@@ -3,14 +3,15 @@
3
3
  const crypto = require('crypto');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
+ const CRLF = /\r\n/g;
6
7
  export function getFingerprintSync(dir, inputs) {
7
8
  return fingerprintSvgDirSync(dir, inputs).hash;
8
9
  }
9
10
  export function fingerprintSvgDirSync(dir, inputs) {
10
- return hashSvgDir(dir, [inputs.upm, inputs.safeZone, inputs.startUnicode, inputs.version, inputs.toolchain]);
11
+ return hashSvgDir(dir, [inputs.upm, inputs.safeZone, inputs.curveTolerance, inputs.startUnicode, inputs.version, inputs.toolchain]);
11
12
  }
12
13
  export function fingerprintSymbolDirSync(dir, inputs) {
13
- return hashSvgDir(dir, ['symbol', inputs.prefix, inputs.version, inputs.toolchain]);
14
+ return hashSvgDir(dir, ['symbol', inputs.prefix, inputs.fit ?? 'content', inputs.scale ?? 1, inputs.version, inputs.toolchain]);
14
15
  }
15
16
  function hashSvgDir(dir, settings) {
16
17
  const files = fs.readdirSync(dir).filter(f => f.endsWith('.svg')).sort();
@@ -18,7 +19,7 @@ function hashSvgDir(dir, settings) {
18
19
  const svgHashByFile = new Map();
19
20
  for (const file of files) {
20
21
  const filePath = path.join(dir, file);
21
- const content = fs.readFileSync(filePath);
22
+ const content = fs.readFileSync(filePath, 'utf8').replace(CRLF, '\n');
22
23
  // Hash both path and content
23
24
  hash.update(file);
24
25
  hash.update(content);
@@ -5,8 +5,8 @@ const BUILD_HASH = `[0-9a-f]{${BUILD_HASH_LENGTH}}`;
5
5
  const BUILD_SUFFIX = new RegExp(`-${BUILD_HASH}$`);
6
6
  const BUILD_FONT_FILE = new RegExp(`-${BUILD_HASH}\\.ttf$`);
7
7
  const REGEX_SPECIALS = /[.*+?^${}()|[\]\\]/g;
8
- export function buildFontFamily(fontFamily, inputHash) {
9
- return `${fontFamily}-${inputHash.slice(0, BUILD_HASH_LENGTH)}`;
8
+ export function buildFontFamily(fontFamily, contentHash) {
9
+ return `${fontFamily}-${contentHash.slice(0, BUILD_HASH_LENGTH)}`;
10
10
  }
11
11
  export function configuredFontFamily(family) {
12
12
  return family.replace(BUILD_SUFFIX, '');
@@ -9,7 +9,15 @@ function subscribe(onChange) {
9
9
  function getFontScale() {
10
10
  return PixelRatio.getFontScale();
11
11
  }
12
+ function subscribeNever() {
13
+ return () => {};
14
+ }
15
+ function noScale() {
16
+ return 1;
17
+ }
18
+
19
+ // Icons with font scaling disabled don't subscribe, so they don't add a
20
+ // Dimensions listener or re-render on window changes.
12
21
  export function useFontScale(enabled) {
13
- const fontScale = useSyncExternalStore(subscribe, getFontScale);
14
- return enabled ? fontScale : 1;
22
+ return useSyncExternalStore(enabled ? subscribe : subscribeNever, enabled ? getFontScale : noScale);
15
23
  }
@@ -11,6 +11,19 @@ export function resolveGlyphEntry(glyphMap, name) {
11
11
  return glyphMap.i[name] ?? [glyphMap.m.u, [[63, 'black']]];
12
12
  }
13
13
 
14
+ /**
15
+ * Size of a glyph in a square box, as fractions of the box side: the glyph's
16
+ * longer side fits the safe zone.
17
+ */
18
+ export function squareGlyphBox(advanceWidth, unitsPerEm, safeZone) {
19
+ const contentWidth = advanceWidth - (unitsPerEm - safeZone);
20
+ const scale = contentWidth > safeZone ? safeZone / contentWidth : 1;
21
+ return {
22
+ scale,
23
+ width: advanceWidth / unitsPerEm * scale
24
+ };
25
+ }
26
+
14
27
  /** A memoized codepoint -> string converter, scoped per icon set. */
15
28
  export function createCharCache() {
16
29
  const cache = new Map();
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ export function iconAccessibilityProps({
4
+ accessible,
5
+ accessibilityLabel,
6
+ accessibilityRole,
7
+ accessibilityElementsHidden,
8
+ importantForAccessibility
9
+ }) {
10
+ if (accessibilityLabel || accessible === true || accessibilityElementsHidden === false || importantForAccessibility === 'yes' || accessibilityRole !== undefined && accessibilityRole !== 'none') {
11
+ return {
12
+ accessible,
13
+ accessibilityLabel,
14
+ accessibilityRole: accessibilityRole ?? 'image',
15
+ accessibilityElementsHidden,
16
+ importantForAccessibility
17
+ };
18
+ }
19
+ return {
20
+ accessible: accessible ?? false,
21
+ accessibilityLabel,
22
+ accessibilityRole,
23
+ accessibilityElementsHidden: accessibilityElementsHidden ?? true,
24
+ importantForAccessibility: importantForAccessibility ?? 'no-hide-descendants'
25
+ };
26
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ import { shallowEqualColor } from "./shallowEqualColor.js";
4
+ const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
5
+ export function shallowEqualStyle(a, b) {
6
+ if (a === b) return true;
7
+ if (Array.isArray(a) || Array.isArray(b)) {
8
+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, i) => shallowEqualStyle(item, b[i]));
9
+ }
10
+ if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {
11
+ return false;
12
+ }
13
+ const aStyle = a;
14
+ const bStyle = b;
15
+ const keys = Object.keys(aStyle);
16
+ return keys.length === Object.keys(bStyle).length && keys.every(key => hasOwn(bStyle, key) && Object.is(aStyle[key], bStyle[key]));
17
+ }
18
+ export function areIconPropsEqual(prev, next) {
19
+ const keys = Object.keys(prev);
20
+ if (keys.length !== Object.keys(next).length) return false;
21
+ return keys.every(key => {
22
+ if (!hasOwn(next, key)) return false;
23
+ if (key === 'style') return shallowEqualStyle(prev.style, next.style);
24
+ if (key === 'color') return shallowEqualColor(prev.color, next.color);
25
+ return Object.is(prev[key], next[key]);
26
+ });
27
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ export const ICON_CLASS = 'nano-icon';
4
+ export const STYLE_HREF = 'react-native-nano-icons';
5
+ export const STYLE_PRECEDENCE = 'react-native-nano-icons';
6
+ export const BASE_CSS = `:where(.${ICON_CLASS}){display:inline-block;position:relative;` + 'width:calc(var(--nano-icon-ratio,1)*1em);height:1em;line-height:0;vertical-align:middle}' + `.${ICON_CLASS}>span{position:absolute;left:0;bottom:0;color:inherit;` + 'font-family:inherit;font-size:inherit;font-weight:normal;font-style:normal;' + 'line-height:1;white-space:pre}';
7
+ export const BASE_HREF = `${STYLE_HREF}:${shortHash(BASE_CSS)}`;
8
+ const TEXT_COLORS = new Set(['black', '#000', '#000f', '#000000', '#000000ff', 'rgb(0,0,0)', 'rgba(0,0,0,1)', 'currentcolor']);
9
+ const followsTextColorByLayers = new WeakMap();
10
+ export function followsTextColor(layers) {
11
+ let follows = followsTextColorByLayers.get(layers);
12
+ if (follows === undefined) {
13
+ follows = layers.every(([, srcColor]) => TEXT_COLORS.has(srcColor.replace(/\s+/g, '').toLowerCase()));
14
+ followsTextColorByLayers.set(layers, follows);
15
+ }
16
+ return follows;
17
+ }
18
+
19
+ // @keep: 32-bit FNV-1a hash in base 36, a short and stable id for the hoisted <style> href.
20
+ export function shortHash(value) {
21
+ let hash = 0x811c9dc5;
22
+ for (let i = 0; i < value.length; i++) {
23
+ hash = Math.imul(hash ^ value.charCodeAt(i), 0x01000193);
24
+ }
25
+ return (hash >>> 0).toString(36);
26
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ const SIDE_AXIS = {
4
+ Top: 'Vertical',
5
+ Bottom: 'Vertical',
6
+ Left: 'Horizontal',
7
+ Right: 'Horizontal'
8
+ };
9
+ const SIDES = Object.keys(SIDE_AXIS);
10
+ const LOGICAL_RENAMES = {
11
+ marginStart: 'marginInlineStart',
12
+ marginEnd: 'marginInlineEnd',
13
+ paddingStart: 'paddingInlineStart',
14
+ paddingEnd: 'paddingInlineEnd',
15
+ start: 'insetInlineStart',
16
+ end: 'insetInlineEnd'
17
+ };
18
+ function flattenInto(style, out) {
19
+ if (Array.isArray(style)) {
20
+ for (const entry of style) flattenInto(entry, out);
21
+ } else if (style != null && typeof style === 'object') {
22
+ Object.assign(out, style);
23
+ }
24
+ }
25
+ function expandBox(style, prop) {
26
+ const horizontal = `${prop}Horizontal`;
27
+ const vertical = `${prop}Vertical`;
28
+ const hasAxis = style[horizontal] !== undefined || style[vertical] !== undefined;
29
+ const hasSide = SIDES.some(side => style[`${prop}${side}`] !== undefined);
30
+ if (!hasAxis && !(hasSide && style[prop] !== undefined)) return;
31
+ for (const side of SIDES) {
32
+ const value = style[`${prop}${side}`] ?? style[`${prop}${SIDE_AXIS[side]}`] ?? style[prop];
33
+ if (value !== undefined) style[`${prop}${side}`] = value;
34
+ }
35
+ delete style[prop];
36
+ delete style[horizontal];
37
+ delete style[vertical];
38
+ }
39
+ function transformFunction(entry) {
40
+ const [type, value] = Object.entries(entry)[0] ?? [];
41
+ if (type === undefined) return '';
42
+ if (Array.isArray(value)) {
43
+ const name = type === 'matrix' && value.length === 16 ? 'matrix3d' : type;
44
+ return `${name}(${value.join(',')})`;
45
+ }
46
+ if (typeof value === 'number' && !type.startsWith('scale')) {
47
+ return `${type}(${value}px)`;
48
+ }
49
+ return `${type}(${String(value)})`;
50
+ }
51
+ function lengthList(value) {
52
+ return value.map(v => typeof v === 'number' ? `${v}px` : String(v)).join(' ');
53
+ }
54
+ export function resolveWebStyle(style) {
55
+ if (style == null || style === false) return undefined;
56
+ const flat = {};
57
+ flattenInto(style, flat);
58
+ expandBox(flat, 'margin');
59
+ expandBox(flat, 'padding');
60
+ for (const [from, to] of Object.entries(LOGICAL_RENAMES)) {
61
+ if (flat[from] === undefined) continue;
62
+ flat[to] ??= flat[from];
63
+ delete flat[from];
64
+ }
65
+ if (Array.isArray(flat.transform)) {
66
+ flat.transform = flat.transform.map(transformFunction).join(' ');
67
+ }
68
+ if (Array.isArray(flat.transformOrigin)) {
69
+ flat.transformOrigin = lengthList(flat.transformOrigin);
70
+ }
71
+ if (typeof flat.lineHeight === 'number') {
72
+ flat.lineHeight = `${flat.lineHeight}px`;
73
+ }
74
+ if (flat.borderStyle === undefined) {
75
+ if (flat.borderWidth != null) {
76
+ flat.borderStyle = 'solid';
77
+ } else {
78
+ for (const side of SIDES) {
79
+ if (flat[`border${side}Width`] != null) {
80
+ flat[`border${side}Style`] = 'solid';
81
+ }
82
+ }
83
+ }
84
+ }
85
+ return flat;
86
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ import { runtimeError, warnRuntime } from "./utils/runtimeLog.js";
4
+ const registered = new Map();
5
+ export function webFontUrl(font) {
6
+ if (typeof font === 'string') return font;
7
+ if (font != null && typeof font === 'object' && typeof font.uri === 'string') {
8
+ return font.uri;
9
+ }
10
+ return undefined;
11
+ }
12
+ export function isWebFontRegistered(family) {
13
+ return registered.has(family);
14
+ }
15
+ export async function registerWebFont(family, url) {
16
+ if (registered.get(family) === url) return;
17
+ const g = globalThis;
18
+ if (!g.FontFace || !g.document?.fonts) {
19
+ throw runtimeError('FontFace API unavailable; cannot load the icon font.');
20
+ }
21
+ const face = new g.FontFace(family, `url(${JSON.stringify(url)})`, {
22
+ display: 'block'
23
+ });
24
+ await face.load();
25
+ g.document.fonts.add(face);
26
+ registered.set(family, url);
27
+ }
28
+ export function __resetWebFontsForTests() {
29
+ registered.clear();
30
+ }
31
+ export function warnFontNotLoaded(fontBasename) {
32
+ warnRuntime(`Icon font "${fontBasename}" is not loaded on web: pass its url, e.g. require("${fontBasename}.woff2") or { uri }.`);
33
+ }
@@ -1,3 +1,4 @@
1
1
  export type Int32 = number;
2
2
  export type Float = number;
3
+ export type WithDefault<Type, _Value extends Type> = Type | null | undefined;
3
4
  //# sourceMappingURL=codegenPrimitives.d.ts.map
@@ -1,8 +1,9 @@
1
+ import type { PathKitModule } from '../pathkit/types';
1
2
  import type { NanoLogger } from '../types';
2
3
  import type { ParsedPath } from './parse';
3
4
  /**
4
5
  * Merge consecutive same-color paths into single compound paths.
5
6
  * Preserves z-order: only merges runs of adjacent paths with identical fill color.
6
7
  */
7
- export declare function mergeSameColorPaths(paths: ParsedPath[], logger?: NanoLogger): ParsedPath[];
8
+ export declare function mergeSameColorPaths(paths: ParsedPath[], pathkit: PathKitModule, logger?: NanoLogger, tolerance?: number): ParsedPath[];
8
9
  //# sourceMappingURL=merge.d.ts.map
@@ -2,14 +2,13 @@ import { type Element } from '@xmldom/xmldom';
2
2
  export type ParsedPath = {
3
3
  d: string;
4
4
  fill: string | null;
5
- fillRule?: 'evenodd';
6
- noMerge?: boolean;
7
5
  knockout?: boolean;
8
6
  };
9
7
  export type ParsedFlatSvg = {
10
8
  viewBox: [number, number, number, number];
11
9
  paths: ParsedPath[];
12
10
  };
11
+ export declare function attribute(el: Element, name: string): string | null;
13
12
  export declare function calculateOpColor(fill: string | null, opacity: number, el: Element): `rgba(${number},${number},${number},${number})`;
14
13
  /**
15
14
  * If a flattened path lost its initial moveto (e.g. an empty `Mx y z`
@@ -25,5 +25,6 @@ export declare function transformPathForFont(PathKit: PathKitModule, d: string,
25
25
  xOff: number;
26
26
  yOff: number;
27
27
  upm: number;
28
+ touchTolerance: number;
28
29
  }): string;
29
30
  //# sourceMappingURL=placement.d.ts.map
@@ -10,6 +10,7 @@ export type VerbMap = {
10
10
  };
11
11
  export interface PathKitPath {
12
12
  delete?: () => void;
13
+ copy: () => PathKitPath;
13
14
  moveTo: (x: number, y: number) => void;
14
15
  lineTo: (x: number, y: number) => void;
15
16
  quadTo: (x1: number, y1: number, x2: number, y2: number) => void;
@@ -1,5 +1,16 @@
1
- import type { PathKitModule, PathKitPath } from './types';
1
+ import type { Cmd, PathKitModule, PathKitPath, VerbMap } from './types';
2
2
  export declare function orientedPathData(PathKit: PathKitModule, path: PathKitPath): string;
3
- export declare function canonicalWinding(PathKit: PathKitModule, d: string): string;
4
- export declare function reversedWinding(PathKit: PathKitModule, d: string): string;
3
+ export declare function touchTolerance(viewBox: readonly [number, number, number, number]): number;
4
+ export type WindingAnalysis = {
5
+ contours: Cmd[][];
6
+ outerSigns: (-1 | 0 | 1)[];
7
+ };
8
+ export declare function analyzeWinding(PathKit: PathKitModule, d: string, tolerance?: number): WindingAnalysis | null;
9
+ export declare function reversedContour(contour: readonly Cmd[], V: VerbMap): Cmd[];
10
+ export declare function pathDataWithWinding(PathKit: PathKitModule, d: string, analysis: WindingAnalysis, sign: -1 | 1): string;
11
+ export declare function rasterSafePathData(PathKit: PathKitModule, path: PathKitPath, tolerance: number): string | null;
12
+ export declare function canonicalWinding(PathKit: PathKitModule, d: string, tolerance?: number): string;
13
+ export declare function reversedWinding(PathKit: PathKitModule, d: string, tolerance?: number): string;
14
+ export type PathOpKind = 'union' | 'intersect' | 'difference';
15
+ export declare function pathOpData(PathKit: PathKitModule, a: string, b: string, kind: PathOpKind): string | null;
5
16
  //# sourceMappingURL=winding.d.ts.map
@@ -1,3 +1,3 @@
1
- export declare function symbolsetContentsJson(svgFilename: string): string;
1
+ export declare function symbolsetContentsJson(svgFilename: string, multicolor?: boolean): string;
2
2
  export declare function catalogRootContentsJson(): string;
3
3
  //# sourceMappingURL=contents.d.ts.map
@@ -28,6 +28,7 @@ export type ResolvedSymbolLayers = {
28
28
  export declare function isKnockoutFill(fill: string | null): boolean;
29
29
  export declare function resolveSymbolLayers(PathKit: PathKitModule, layers: SymbolLayerInput[], options?: {
30
30
  onKnockoutLayer?: (index: number) => void;
31
+ touchTolerance?: number;
31
32
  }): ResolvedSymbolLayers;
32
33
  /**
33
34
  * Tight bounding box [x, y, w, h] of path `d` strings in source coords, or null.
@@ -5,17 +5,22 @@ export type SymbolTemplateLayer = {
5
5
  fill: string | null;
6
6
  };
7
7
  export declare function layerHexColor(fill: string | null): string;
8
- export declare function layerClass(layerIndex: number): string;
8
+ /** A `currentColor` layer follows the tint in multicolor too, like the monochrome rendering. */
9
+ export declare function isTintFill(fill: string | null): boolean;
10
+ /** More than one distinct fill: the symbol is meant to be seen in colour. */
11
+ export declare function isMulticolor(layers: SymbolTemplateLayer[]): boolean;
12
+ export declare function layerClass(layerIndex: number, fill?: string | null): string;
9
13
  /**
10
14
  * Build the template SVG for one symbol. Layers are back→front; every layer
11
- * gets `monochrome-N multicolor-N:custom` classes, with the layer fills
12
- * declared in a `<style>` block.
15
+ * gets `monochrome-N multicolor-N:custom` classes (`multicolor-N:tintColor` for a
16
+ * `currentColor` layer), with the layer fills declared in a `<style>` block.
13
17
  */
14
18
  export declare function buildSymbolTemplate(opts: {
15
19
  layers: SymbolTemplateLayer[];
16
20
  viewBox: [number, number, number, number];
17
21
  /** Tight content box `[x, y, w, h]`; used instead of the viewBox when given. */
18
22
  contentBounds?: [number, number, number, number];
23
+ scale?: number;
19
24
  /** Shown in the template's Notes group. */
20
25
  descriptiveName?: string;
21
26
  logger?: NanoLogger;
@@ -8,5 +8,13 @@ export declare function buildVectorDrawableXml(opts: {
8
8
  viewBox: [number, number, number, number];
9
9
  /** Tight content box `[x, y, w, h]`; used instead of the viewBox when given. */
10
10
  contentBounds?: [number, number, number, number];
11
+ scale?: number;
12
+ inkBounds?: [number, number, number, number];
11
13
  }): string;
14
+ /**
15
+ * A resources file that keeps the given drawables through resource shrinking
16
+ * (`shrinkResources` in release builds): react-native-screens' native tab bar
17
+ * resolves them by name at runtime (`getIdentifier`), which the shrinker cannot see.
18
+ */
19
+ export declare function buildDrawableKeepXml(resourceNames: string[]): string;
12
20
  //# sourceMappingURL=vectorDrawable.d.ts.map
@@ -1,7 +1,6 @@
1
1
  import type { NanoGlyphMapInput } from './core/types';
2
2
  import type { IconComponent } from './types';
3
3
  export type { IconComponent, IconProps } from './types';
4
- export { shallowEqualColor } from './utils/shallowEqualColor';
5
4
  export declare function createIconSet<GM extends NanoGlyphMapInput>(glyphMap: GM): IconComponent<GM>;
6
5
  export declare function createIconSet<GM extends NanoGlyphMapInput>(glyphMap: GM, font: unknown): IconComponent<GM>;
7
6
  //# sourceMappingURL=createNanoIconsSet.d.ts.map
@@ -1,8 +1,6 @@
1
1
  import type { NanoGlyphMapInput } from './core/types';
2
2
  import type { IconComponent, IconProps } from './types';
3
- import { shallowEqualColor } from './utils/shallowEqualColor';
4
3
  export type { IconComponent, IconProps };
5
- export { shallowEqualColor };
6
4
  export declare function createIconSet<GM extends NanoGlyphMapInput>(glyphMap: GM): IconComponent<GM>;
7
5
  export declare function createIconSet<GM extends NanoGlyphMapInput>(glyphMap: GM, font: unknown): IconComponent<GM>;
8
6
  //# sourceMappingURL=createNanoIconsSet.native.d.ts.map
@@ -1,8 +1,6 @@
1
1
  import type { NanoGlyphMapInput } from './core/types';
2
2
  import type { IconComponent, IconProps } from './types';
3
- import { shallowEqualColor } from './utils/shallowEqualColor';
4
3
  export type { IconComponent, IconProps };
5
- export { shallowEqualColor };
6
4
  /**
7
5
  * Warn when the `font` argument and the glyphmap's linking mode are inconsistent.
8
6
  *
@@ -15,7 +13,7 @@ export { shallowEqualColor };
15
13
  export declare function warnIfLinkingMismatch(fontFamily: string, linking: string | undefined, font: unknown): void;
16
14
  /**
17
15
  * JS implementation using <View> + <Text> layers.
18
- * Used on web and as a fallback when native component is unavailable (e.g. Expo Go).
16
+ * Used as a fallback when native component is unavailable (e.g. Expo Go).
19
17
  */
20
18
  export declare function createJSIconSet<GM extends NanoGlyphMapInput>(glyphMap: GM): IconComponent<GM>;
21
19
  export declare function createJSIconSet<GM extends NanoGlyphMapInput>(glyphMap: GM, font: unknown): IconComponent<GM>;
@@ -1,7 +1,6 @@
1
1
  import type { NanoGlyphMapInput } from './core/types';
2
2
  import type { IconComponent, IconProps } from './types';
3
- import { shallowEqualColor } from './utils/shallowEqualColor';
4
3
  export type { IconComponent, IconProps };
5
- export { shallowEqualColor };
6
4
  export declare function createIconSet<GM extends NanoGlyphMapInput>(glyphMap: GM): IconComponent<GM>;
5
+ export declare function createIconSet<GM extends NanoGlyphMapInput>(glyphMap: GM, font: unknown): IconComponent<GM>;
7
6
  //# sourceMappingURL=createNanoIconsSet.web.d.ts.map
@@ -1,24 +1,12 @@
1
- export type FontIntegrityIssue = {
2
- fontFamily: string;
3
- family: string;
4
- linking: 'static' | 'dynamic';
5
- message: string;
6
- /** The error behind a dynamic font failure, when there is one. */
7
- cause?: unknown;
8
- };
9
- export type FontIntegrityStatus = 'found' | 'resolved';
10
- type Listener = (issue: FontIntegrityIssue, status: FontIntegrityStatus) => void;
1
+ export { addFontIntegrityListener, getFontIntegrityIssues, resolveFontIssue, useFontIntegrityIssue, type FontIntegrityIssue, type FontIntegrityStatus, } from './fontIntegrityStore';
11
2
  export declare function isFontRegistered(family: string): Promise<boolean>;
12
3
  export declare function checkFontIntegrity(family: string, linking: 'static' | 'dynamic'): Promise<void>;
4
+ export declare function checkStaticFontNow(family: string): boolean;
13
5
  export declare const FONT_MISMATCH_CODE = "E_NANOICONS_FONT_MISMATCH";
14
6
  export declare function isFontMismatch(err: unknown): boolean;
15
7
  export declare const FONT_SOURCE_CODE = "E_NANOICONS_FONT_SOURCE";
16
8
  export declare function reportFontMismatch(family: string, linking: 'static' | 'dynamic'): void;
17
9
  export declare function reportMissingDynamicFont(family: string): Promise<void>;
18
10
  export declare function reportDynamicFontLoadFailure(family: string, cause: unknown): Promise<void>;
19
- export declare function resolveFontIssue(family: string): void;
20
- export declare function addFontIntegrityListener(listener: Listener): () => void;
21
- export declare function getFontIntegrityIssues(): FontIntegrityIssue[];
22
11
  export declare function __resetFontIntegrityForTests(): void;
23
- export {};
24
12
  //# sourceMappingURL=fontIntegrity.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { type FontIntegrityIssue } from './fontIntegrityStore';
2
+ export { addFontIntegrityListener, getFontIntegrityIssues, resolveFontIssue, useFontIntegrityIssue, type FontIntegrityIssue, type FontIntegrityStatus, } from './fontIntegrityStore';
3
+ type Linking = FontIntegrityIssue['linking'];
4
+ export declare function reportFontLoadFailure(family: string, linking: Linking, cause: unknown): void;
5
+ export declare function watchFontLoadFailures(family: string, linking: Linking): void;
6
+ export declare function __resetFontIntegrityForTests(): void;
7
+ //# sourceMappingURL=fontIntegrity.web.d.ts.map