react-native-nano-icons 0.2.1 → 1.0.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.
- package/LICENSES.md +40 -0
- package/README.md +165 -12
- package/android/build.gradle +8 -1
- package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +31 -0
- package/android/src/main/java/com/nanoicons/NanoIconView.kt +103 -19
- package/android/src/main/java/com/nanoicons/NanoIconViewManager.kt +42 -18
- package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +72 -11
- package/android/src/main/jni/CMakeLists.txt +38 -0
- package/android/src/main/jni/RNNanoIconsSpec.h +19 -0
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewComponentDescriptor.h +11 -0
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.cpp +46 -0
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.h +41 -0
- package/ios/NanoIconFontResolver.h +5 -0
- package/ios/NanoIconFontResolver.mm +32 -0
- package/ios/NanoIconInlineBaseline.h +4 -0
- package/ios/NanoIconInlineBaseline.mm +190 -0
- package/ios/NanoIconView.h +1 -4
- package/ios/NanoIconView.mm +178 -162
- package/ios/NanoIconsFontLoader.mm +10 -32
- package/lib/commonjs/cli/build.d.ts +16 -3
- package/lib/commonjs/cli/build.js +108 -25
- package/lib/commonjs/cli/buildSymbols.d.ts +26 -0
- package/lib/commonjs/cli/buildSymbols.js +134 -0
- package/lib/commonjs/cli/config.d.ts +4 -2
- package/lib/commonjs/cli/config.js +4 -4
- package/lib/commonjs/cli/expoConfig.d.ts +6 -2
- package/lib/commonjs/cli/expoConfig.js +37 -13
- package/lib/commonjs/cli/index.d.ts +7 -5
- package/lib/commonjs/cli/index.js +27 -14
- package/lib/commonjs/cli/link.d.ts +19 -3
- package/lib/commonjs/cli/link.js +311 -45
- package/lib/commonjs/cli/logger.js +9 -7
- package/lib/commonjs/metro/fontRebuildWatcher.d.ts +62 -0
- package/lib/commonjs/metro/fontRebuildWatcher.js +174 -0
- package/lib/commonjs/metro/index.d.ts +35 -0
- package/lib/commonjs/metro/index.js +92 -0
- package/lib/commonjs/metro/symbolRebuildWatcher.d.ts +19 -0
- package/lib/commonjs/metro/symbolRebuildWatcher.js +76 -0
- package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -3
- package/lib/commonjs/plugin/src/buildFonts.js +5 -15
- package/lib/commonjs/plugin/src/buildSymbols.d.ts +3 -0
- package/lib/commonjs/plugin/src/buildSymbols.js +18 -0
- package/lib/commonjs/plugin/src/index.d.ts +2 -2
- package/lib/commonjs/plugin/src/index.js +10 -4
- package/lib/commonjs/plugin/src/types.d.ts +44 -3
- package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.d.ts +8 -0
- package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.js +29 -0
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +1 -1
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +6 -13
- package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.d.ts +8 -0
- package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.js +37 -0
- package/lib/commonjs/scripts/cli.js +64 -23
- package/lib/commonjs/src/core/flatten/arcs.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/arcs.js +136 -0
- package/lib/commonjs/src/core/flatten/document.d.ts +35 -0
- package/lib/commonjs/src/core/flatten/document.js +164 -0
- package/lib/commonjs/src/core/flatten/dom.d.ts +24 -0
- package/lib/commonjs/src/core/flatten/dom.js +221 -0
- package/lib/commonjs/src/core/flatten/element.d.ts +12 -0
- package/lib/commonjs/src/core/flatten/element.js +97 -0
- package/lib/commonjs/src/core/flatten/geometry.d.ts +21 -0
- package/lib/commonjs/src/core/flatten/geometry.js +85 -0
- package/lib/commonjs/src/core/flatten/index.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/index.js +11 -0
- package/lib/commonjs/src/core/flatten/inherit.d.ts +13 -0
- package/lib/commonjs/src/core/flatten/inherit.js +249 -0
- package/lib/commonjs/src/core/flatten/path.d.ts +19 -0
- package/lib/commonjs/src/core/flatten/path.js +439 -0
- package/lib/commonjs/src/core/flatten/pathops.d.ts +14 -0
- package/lib/commonjs/src/core/flatten/pathops.js +236 -0
- package/lib/commonjs/src/core/flatten/shape.d.ts +29 -0
- package/lib/commonjs/src/core/flatten/shape.js +415 -0
- package/lib/commonjs/src/core/flatten/stages/clip-path.d.ts +4 -0
- package/lib/commonjs/src/core/flatten/stages/clip-path.js +20 -0
- package/lib/commonjs/src/core/flatten/stages/collapse.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/collapse.js +86 -0
- package/lib/commonjs/src/core/flatten/stages/defs.d.ts +4 -0
- package/lib/commonjs/src/core/flatten/stages/defs.js +49 -0
- package/lib/commonjs/src/core/flatten/stages/discard.d.ts +4 -0
- package/lib/commonjs/src/core/flatten/stages/discard.js +50 -0
- package/lib/commonjs/src/core/flatten/stages/fill-rule.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/fill-rule.js +7 -0
- package/lib/commonjs/src/core/flatten/stages/nested-svg.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/nested-svg.js +131 -0
- package/lib/commonjs/src/core/flatten/stages/opacity.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/opacity.js +7 -0
- package/lib/commonjs/src/core/flatten/stages/shapes.d.ts +7 -0
- package/lib/commonjs/src/core/flatten/stages/shapes.js +37 -0
- package/lib/commonjs/src/core/flatten/stages/stroke.d.ts +3 -0
- package/lib/commonjs/src/core/flatten/stages/stroke.js +34 -0
- package/lib/commonjs/src/core/flatten/stages/styles.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/styles.js +29 -0
- package/lib/commonjs/src/core/flatten/stages/use.d.ts +4 -0
- package/lib/commonjs/src/core/flatten/stages/use.js +80 -0
- package/lib/commonjs/src/core/flatten/stages/validate.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages/validate.js +39 -0
- package/lib/commonjs/src/core/flatten/stages.d.ts +2 -0
- package/lib/commonjs/src/core/flatten/stages.js +40 -0
- package/lib/commonjs/src/core/flatten/transform.d.ts +35 -0
- package/lib/commonjs/src/core/flatten/transform.js +221 -0
- package/lib/commonjs/src/core/font/compile.d.ts +2 -1
- package/lib/commonjs/src/core/font/compile.js +19 -7
- package/lib/commonjs/src/core/font/metrics.js +7 -0
- package/lib/commonjs/src/core/font/quadratic.d.ts +2 -0
- package/lib/commonjs/src/core/font/quadratic.js +33 -0
- package/lib/commonjs/src/core/glyph/merge.d.ts +7 -0
- package/lib/commonjs/src/core/glyph/merge.js +59 -0
- package/lib/commonjs/src/core/glyph/parse.d.ts +27 -0
- package/lib/commonjs/src/core/{svg/svg_dom.js → glyph/parse.js} +21 -77
- package/lib/commonjs/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +1 -13
- package/lib/commonjs/src/core/{svg/layers.js → glyph/placement.js} +0 -17
- package/lib/commonjs/src/core/glyph/validate.d.ts +8 -0
- package/lib/commonjs/src/core/glyph/validate.js +33 -0
- package/lib/commonjs/src/core/pathkit/contours.d.ts +75 -0
- package/lib/commonjs/src/core/{svg/svg_pathops.js → pathkit/contours.js} +79 -301
- package/lib/commonjs/src/core/pathkit/evenodd.d.ts +12 -0
- package/lib/commonjs/src/core/pathkit/evenodd.js +37 -0
- package/lib/commonjs/src/core/pathkit/load.d.ts +2 -0
- package/lib/commonjs/src/core/pathkit/load.js +26 -0
- package/lib/commonjs/src/core/pathkit/types.d.ts +69 -0
- package/lib/commonjs/src/core/pathkit/types.js +2 -0
- package/lib/commonjs/src/core/pathkit/winding.d.ts +4 -0
- package/lib/commonjs/src/core/pathkit/winding.js +59 -0
- package/lib/commonjs/src/core/pipeline/config.d.ts +2 -0
- package/lib/commonjs/src/core/pipeline/config.js +6 -0
- package/lib/commonjs/src/core/pipeline/iconPool.d.ts +14 -0
- package/lib/commonjs/src/core/pipeline/iconPool.js +109 -0
- package/lib/commonjs/src/core/pipeline/index.d.ts +5 -3
- package/lib/commonjs/src/core/pipeline/index.js +8 -5
- package/lib/commonjs/src/core/pipeline/prepare.d.ts +20 -0
- package/lib/commonjs/src/core/pipeline/prepare.js +74 -0
- package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +25 -0
- package/lib/commonjs/src/core/pipeline/prepareIcon.js +81 -0
- package/lib/commonjs/src/core/pipeline/prepareSvg.d.ts +6 -0
- package/lib/commonjs/src/core/pipeline/prepareSvg.js +11 -0
- package/lib/commonjs/src/core/pipeline/prepareSymbol.d.ts +26 -0
- package/lib/commonjs/src/core/pipeline/prepareSymbol.js +79 -0
- package/lib/commonjs/src/core/pipeline/prepareWorker.d.ts +1 -0
- package/lib/commonjs/src/core/pipeline/prepareWorker.js +12 -0
- package/lib/commonjs/src/core/pipeline/preparedSvgCache.d.ts +6 -0
- package/lib/commonjs/src/core/pipeline/preparedSvgCache.js +44 -0
- package/lib/commonjs/src/core/pipeline/runFontPipeline.d.ts +22 -0
- package/lib/commonjs/src/core/pipeline/runFontPipeline.js +111 -0
- package/lib/commonjs/src/core/pipeline/runSymbolPipeline.d.ts +54 -0
- package/lib/commonjs/src/core/pipeline/runSymbolPipeline.js +161 -0
- package/lib/commonjs/src/core/symbols/contents.d.ts +2 -0
- package/lib/commonjs/src/core/symbols/contents.js +15 -0
- package/lib/commonjs/src/core/symbols/knockout.d.ts +3 -0
- package/lib/commonjs/src/core/symbols/knockout.js +51 -0
- package/lib/commonjs/src/core/symbols/layers.d.ts +36 -0
- package/lib/commonjs/src/core/symbols/layers.js +182 -0
- package/lib/commonjs/src/core/symbols/template.d.ts +22 -0
- package/lib/commonjs/src/core/symbols/template.js +140 -0
- package/lib/commonjs/src/core/symbols/vectorDrawable.d.ts +11 -0
- package/lib/commonjs/src/core/symbols/vectorDrawable.js +66 -0
- package/lib/commonjs/src/core/types.d.ts +3 -92
- package/lib/commonjs/src/utils/fingerPrint.d.ts +19 -1
- package/lib/commonjs/src/utils/fingerPrint.js +29 -3
- package/lib/commonjs/src/utils/fontIdentity.d.ts +4 -0
- package/lib/commonjs/src/utils/fontIdentity.js +24 -0
- package/lib/commonjs/src/utils/naming.d.ts +10 -0
- package/lib/commonjs/src/utils/naming.js +49 -0
- package/lib/commonjs/src/utils/packageVersion.d.ts +2 -0
- package/lib/commonjs/src/utils/packageVersion.js +37 -0
- package/lib/commonjs/src/utils/parse.d.ts +0 -1
- package/lib/commonjs/src/utils/parse.js +0 -8
- package/lib/commonjs/src/utils/svgPatterns.d.ts +38 -0
- package/lib/commonjs/src/utils/svgPatterns.js +46 -0
- package/lib/module/const/codegenPrimitives.js +1 -2
- package/lib/module/const/colors.js +1 -2
- package/lib/module/createNanoIconsSet.js +1 -2
- package/lib/module/createNanoIconsSet.native.js +38 -28
- package/lib/module/createNanoIconsSet.shared.js +15 -9
- package/lib/module/createNanoIconsSet.web.js +22 -8
- package/lib/module/devServerFont.js +30 -0
- package/lib/module/devServerFont.web.js +25 -0
- package/lib/module/fontIntegrity.js +99 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.node.js +1 -2
- package/lib/module/loadDynamicFont.js +20 -10
- package/lib/module/nativeFontLoader.js +3 -0
- package/lib/module/nativeFontLoader.web.js +3 -0
- package/lib/module/specs/NanoIconViewNativeComponent.ts +9 -6
- package/lib/module/specs/NativeNanoIconsFontLoader.js +1 -2
- package/lib/module/symbols/index.android.js +42 -0
- package/lib/module/symbols/index.ios.js +35 -0
- package/lib/module/symbols/index.js +35 -0
- package/lib/module/symbols/index.native.js +12 -0
- package/lib/module/symbols/types.js +1 -0
- package/lib/module/types.js +1 -2
- package/lib/module/utils/fingerPrint.js +20 -5
- package/lib/module/utils/fontIdentity.js +20 -0
- package/lib/module/utils/glyphRuntime.js +36 -3
- package/lib/module/utils/naming.js +46 -0
- package/lib/module/utils/packageVersion.js +29 -0
- package/lib/module/utils/parse.js +1 -9
- package/lib/module/utils/runtimeLog.js +12 -0
- package/lib/module/utils/shallowEqualColor.js +1 -2
- package/lib/module/utils/svgPatterns.js +49 -0
- package/lib/module/utils/validateLayerColor.js +24 -0
- package/lib/typescript/src/core/flatten/arcs.d.ts +3 -0
- package/lib/typescript/src/core/flatten/document.d.ts +36 -0
- package/lib/typescript/src/core/flatten/dom.d.ts +25 -0
- package/lib/typescript/src/core/flatten/element.d.ts +13 -0
- package/lib/typescript/src/core/flatten/geometry.d.ts +22 -0
- package/lib/typescript/src/core/flatten/index.d.ts +3 -0
- package/lib/typescript/src/core/flatten/inherit.d.ts +14 -0
- package/lib/typescript/src/core/flatten/path.d.ts +20 -0
- package/lib/typescript/src/core/flatten/pathops.d.ts +15 -0
- package/lib/typescript/src/core/flatten/shape.d.ts +30 -0
- package/lib/typescript/src/core/flatten/stages/clip-path.d.ts +5 -0
- package/lib/typescript/src/core/flatten/stages/collapse.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/defs.d.ts +5 -0
- package/lib/typescript/src/core/flatten/stages/discard.d.ts +5 -0
- package/lib/typescript/src/core/flatten/stages/fill-rule.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/nested-svg.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/opacity.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/shapes.d.ts +8 -0
- package/lib/typescript/src/core/flatten/stages/stroke.d.ts +4 -0
- package/lib/typescript/src/core/flatten/stages/styles.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages/use.d.ts +5 -0
- package/lib/typescript/src/core/flatten/stages/validate.d.ts +3 -0
- package/lib/typescript/src/core/flatten/stages.d.ts +3 -0
- package/lib/typescript/src/core/flatten/transform.d.ts +36 -0
- package/lib/typescript/src/core/glyph/merge.d.ts +8 -0
- package/lib/typescript/src/core/glyph/parse.d.ts +28 -0
- package/lib/typescript/src/core/{svg/layers.d.ts → glyph/placement.d.ts} +2 -14
- package/lib/typescript/src/core/glyph/validate.d.ts +9 -0
- package/lib/typescript/src/core/pathkit/contours.d.ts +76 -0
- package/lib/typescript/src/core/pathkit/evenodd.d.ts +13 -0
- package/lib/typescript/src/core/pathkit/load.d.ts +3 -0
- package/lib/typescript/src/core/pathkit/types.d.ts +70 -0
- package/lib/typescript/src/core/pathkit/winding.d.ts +5 -0
- package/lib/typescript/src/core/symbols/contents.d.ts +3 -0
- package/lib/typescript/src/core/symbols/knockout.d.ts +4 -0
- package/lib/typescript/src/core/symbols/layers.d.ts +37 -0
- package/lib/typescript/src/core/symbols/template.d.ts +23 -0
- package/lib/typescript/src/core/symbols/vectorDrawable.d.ts +12 -0
- package/lib/typescript/src/core/types.d.ts +3 -92
- package/lib/typescript/src/devServerFont.d.ts +4 -0
- package/lib/typescript/src/devServerFont.web.d.ts +4 -0
- package/lib/typescript/src/fontIntegrity.d.ts +24 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/loadDynamicFont.d.ts +1 -0
- package/lib/typescript/src/nativeFontLoader.d.ts +2 -0
- package/lib/typescript/src/nativeFontLoader.web.d.ts +3 -0
- package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts +6 -5
- package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts +1 -0
- package/lib/typescript/src/symbols/index.android.d.ts +33 -0
- package/lib/typescript/src/symbols/index.d.ts +31 -0
- package/lib/typescript/src/symbols/index.ios.d.ts +31 -0
- package/lib/typescript/src/symbols/index.native.d.ts +8 -0
- package/lib/typescript/src/symbols/types.d.ts +24 -0
- package/lib/typescript/src/types.d.ts +7 -0
- package/lib/typescript/src/utils/fingerPrint.d.ts +19 -1
- package/lib/typescript/src/utils/fontIdentity.d.ts +5 -0
- package/lib/typescript/src/utils/glyphRuntime.d.ts +3 -1
- package/lib/typescript/src/utils/naming.d.ts +11 -0
- package/lib/typescript/src/utils/packageVersion.d.ts +3 -0
- package/lib/typescript/src/utils/parse.d.ts +0 -1
- package/lib/typescript/src/utils/runtimeLog.d.ts +5 -0
- package/lib/typescript/src/utils/svgPatterns.d.ts +39 -0
- package/lib/typescript/src/utils/validateLayerColor.d.ts +3 -0
- package/metro.js +1 -0
- package/package.json +37 -11
- package/react-native-nano-icons.podspec +4 -1
- package/react-native.config.js +10 -0
- package/src/specs/NanoIconViewNativeComponent.ts +9 -6
- package/src/specs/NativeNanoIconsFontLoader.ts +1 -0
- package/lib/commonjs/src/core/pipeline/managers.d.ts +0 -11
- package/lib/commonjs/src/core/pipeline/managers.js +0 -104
- package/lib/commonjs/src/core/pipeline/run.d.ts +0 -14
- package/lib/commonjs/src/core/pipeline/run.js +0 -189
- package/lib/commonjs/src/core/svg/svg_dom.d.ts +0 -51
- package/lib/commonjs/src/core/svg/svg_pathops.d.ts +0 -32
- package/lib/module/const/codegenPrimitives.js.map +0 -1
- package/lib/module/const/colors.js.map +0 -1
- package/lib/module/core/font/compile.js +0 -81
- package/lib/module/core/font/compile.js.map +0 -1
- package/lib/module/core/font/metrics.js +0 -37
- package/lib/module/core/font/metrics.js.map +0 -1
- package/lib/module/core/pipeline/config.js +0 -20
- package/lib/module/core/pipeline/config.js.map +0 -1
- package/lib/module/core/pipeline/index.js +0 -5
- package/lib/module/core/pipeline/index.js.map +0 -1
- package/lib/module/core/pipeline/managers.js +0 -94
- package/lib/module/core/pipeline/managers.js.map +0 -1
- package/lib/module/core/pipeline/run.js +0 -204
- package/lib/module/core/pipeline/run.js.map +0 -1
- package/lib/module/core/shims/pathops.py +0 -181
- package/lib/module/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
- package/lib/module/core/svg/layers.js +0 -85
- package/lib/module/core/svg/layers.js.map +0 -1
- package/lib/module/core/svg/svg_dom.js +0 -170
- package/lib/module/core/svg/svg_dom.js.map +0 -1
- package/lib/module/core/svg/svg_pathops.js +0 -750
- package/lib/module/core/svg/svg_pathops.js.map +0 -1
- package/lib/module/core/tsconfig.json +0 -32
- package/lib/module/core/types.js +0 -2
- package/lib/module/core/types.js.map +0 -1
- package/lib/module/createNanoIconsSet.js.map +0 -1
- package/lib/module/createNanoIconsSet.native.js.map +0 -1
- package/lib/module/createNanoIconsSet.shared.js.map +0 -1
- package/lib/module/createNanoIconsSet.web.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/index.node.js.map +0 -1
- package/lib/module/loadDynamicFont.js.map +0 -1
- package/lib/module/specs/NativeNanoIconsFontLoader.js.map +0 -1
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/fingerPrint.js.map +0 -1
- package/lib/module/utils/glyphRuntime.js.map +0 -1
- package/lib/module/utils/parse.js.map +0 -1
- package/lib/module/utils/shallowEqualColor.js.map +0 -1
- package/lib/typescript/__tests__/build.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/build.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/clippath.e2e.test.d.ts +0 -3
- package/lib/typescript/__tests__/clippath.e2e.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/fingerprint.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/fingerprint.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts +0 -2
- package/lib/typescript/__tests__/glyphRuntime.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/link.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/link.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts +0 -2
- package/lib/typescript/__tests__/loadDynamicFont.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/pipeline.e2e.test.d.ts +0 -3
- package/lib/typescript/__tests__/pipeline.e2e.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/placement.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/placement.unit.test.d.ts.map +0 -1
- package/lib/typescript/__tests__/svg_dom.unit.test.d.ts +0 -3
- package/lib/typescript/__tests__/svg_dom.unit.test.d.ts.map +0 -1
- package/lib/typescript/cli/build.d.ts +0 -32
- package/lib/typescript/cli/build.d.ts.map +0 -1
- package/lib/typescript/cli/link.d.ts +0 -12
- package/lib/typescript/cli/link.d.ts.map +0 -1
- package/lib/typescript/cli/logger.d.ts +0 -28
- package/lib/typescript/cli/logger.d.ts.map +0 -1
- package/lib/typescript/src/const/codegenPrimitives.d.ts.map +0 -1
- package/lib/typescript/src/const/colors.d.ts.map +0 -1
- package/lib/typescript/src/core/font/compile.d.ts +0 -21
- package/lib/typescript/src/core/font/compile.d.ts.map +0 -1
- package/lib/typescript/src/core/font/metrics.d.ts +0 -2
- package/lib/typescript/src/core/font/metrics.d.ts.map +0 -1
- package/lib/typescript/src/core/pipeline/config.d.ts +0 -16
- package/lib/typescript/src/core/pipeline/config.d.ts.map +0 -1
- package/lib/typescript/src/core/pipeline/index.d.ts +0 -4
- package/lib/typescript/src/core/pipeline/index.d.ts.map +0 -1
- package/lib/typescript/src/core/pipeline/managers.d.ts +0 -12
- package/lib/typescript/src/core/pipeline/managers.d.ts.map +0 -1
- package/lib/typescript/src/core/pipeline/run.d.ts +0 -15
- package/lib/typescript/src/core/pipeline/run.d.ts.map +0 -1
- package/lib/typescript/src/core/svg/layers.d.ts.map +0 -1
- package/lib/typescript/src/core/svg/svg_dom.d.ts +0 -52
- package/lib/typescript/src/core/svg/svg_dom.d.ts.map +0 -1
- package/lib/typescript/src/core/svg/svg_pathops.d.ts +0 -33
- package/lib/typescript/src/core/svg/svg_pathops.d.ts.map +0 -1
- package/lib/typescript/src/core/types.d.ts.map +0 -1
- package/lib/typescript/src/createNanoIconsSet.d.ts.map +0 -1
- package/lib/typescript/src/createNanoIconsSet.native.d.ts.map +0 -1
- package/lib/typescript/src/createNanoIconsSet.shared.d.ts.map +0 -1
- package/lib/typescript/src/createNanoIconsSet.web.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/index.node.d.ts.map +0 -1
- package/lib/typescript/src/loadDynamicFont.d.ts.map +0 -1
- package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts.map +0 -1
- package/lib/typescript/src/types.d.ts.map +0 -1
- package/lib/typescript/src/utils/fingerPrint.d.ts.map +0 -1
- package/lib/typescript/src/utils/glyphRuntime.d.ts.map +0 -1
- package/lib/typescript/src/utils/parse.d.ts.map +0 -1
- package/lib/typescript/src/utils/shallowEqualColor.d.ts.map +0 -1
- package/plugin/src/buildFonts.ts +0 -42
- package/plugin/src/index.ts +0 -21
- package/plugin/src/types.ts +0 -42
- package/plugin/src/withNanoIconsFontLinking.ts +0 -136
- package/plugin/tsconfig.json +0 -9
- package/scripts/cli.ts +0 -63
- package/scripts/tsconfig.json +0 -25
- package/src/const/colors.ts +0 -150
- package/src/core/font/compile.ts +0 -99
- package/src/core/font/metrics.ts +0 -44
- package/src/core/pipeline/config.ts +0 -25
- package/src/core/pipeline/index.ts +0 -3
- package/src/core/pipeline/managers.ts +0 -132
- package/src/core/pipeline/run.ts +0 -274
- package/src/core/shims/pathops.py +0 -181
- package/src/core/shims/picosvg-0.22.3-py3-none-any.whl +0 -0
- package/src/core/svg/layers.ts +0 -110
- package/src/core/svg/svg_dom.ts +0 -194
- package/src/core/svg/svg_pathops.ts +0 -1040
- package/src/core/tsconfig.json +0 -32
- package/src/core/types.ts +0 -157
- package/src/createNanoIconsSet.native.tsx +0 -192
- package/src/createNanoIconsSet.shared.tsx +0 -174
- package/src/createNanoIconsSet.tsx +0 -20
- package/src/createNanoIconsSet.web.tsx +0 -109
- package/src/index.node.ts +0 -14
- package/src/index.ts +0 -6
- package/src/loadDynamicFont.ts +0 -162
- package/src/types.ts +0 -31
- package/src/utils/fingerPrint.ts +0 -20
- package/src/utils/glyphRuntime.ts +0 -46
- package/src/utils/parse.ts +0 -67
- package/src/utils/shallowEqualColor.ts +0 -17
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Shared regexes + helpers for sanitizing asset/symbol names into valid
|
|
3
|
+
// Android resource ids and TypeScript manifest identifiers.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.toDrawableResourceName = toDrawableResourceName;
|
|
6
|
+
exports.toOriginalDrawableResourceName = toOriginalDrawableResourceName;
|
|
7
|
+
exports.manifestBaseName = manifestBaseName;
|
|
8
|
+
exports.manifestExportName = manifestExportName;
|
|
9
|
+
/** Chars illegal in an Android drawable resource name → `_`. */
|
|
10
|
+
const NON_RESOURCE_CHARS = /[^a-z0-9_]+/g;
|
|
11
|
+
/** Leading/trailing underscores to trim. */
|
|
12
|
+
const EDGE_UNDERSCORES = /^_+|_+$/g;
|
|
13
|
+
/** Resource names must start with a lowercase letter. */
|
|
14
|
+
const STARTS_WITH_LOWER = /^[a-z]/;
|
|
15
|
+
/** Word separators in a set name (split → PascalCase parts). */
|
|
16
|
+
const NAME_SEPARATORS = /[^a-zA-Z0-9]+/;
|
|
17
|
+
/** Manifest identifiers must start with a letter. */
|
|
18
|
+
const STARTS_WITH_LETTER = /^[a-zA-Z]/;
|
|
19
|
+
/** Prefix used when a sanitized name would be empty or start with a non-letter. */
|
|
20
|
+
const RESOURCE_FALLBACK_PREFIX = 'nano_';
|
|
21
|
+
/**
|
|
22
|
+
* Resource names must match `[a-z][a-z0-9_]*` — no dots/uppercase.
|
|
23
|
+
* `nano.home` → `nano_home`, `nano.person-walking` → `nano_person_walking`.
|
|
24
|
+
*/
|
|
25
|
+
function toDrawableResourceName(assetName) {
|
|
26
|
+
let name = assetName.toLowerCase().replace(NON_RESOURCE_CHARS, '_');
|
|
27
|
+
name = name.replace(EDGE_UNDERSCORES, '');
|
|
28
|
+
if (name === '' || !STARTS_WITH_LOWER.test(name)) {
|
|
29
|
+
name = `${RESOURCE_FALLBACK_PREFIX}${name}`;
|
|
30
|
+
}
|
|
31
|
+
return name;
|
|
32
|
+
}
|
|
33
|
+
const ORIGINAL_DRAWABLE_SUFFIX = '_original';
|
|
34
|
+
function toOriginalDrawableResourceName(resourceName) {
|
|
35
|
+
return `${resourceName}${ORIGINAL_DRAWABLE_SUFFIX}`;
|
|
36
|
+
}
|
|
37
|
+
/** "my-tab icons" → "MyTabIcons" — PascalCase base for manifest identifiers. */
|
|
38
|
+
function manifestBaseName(setName) {
|
|
39
|
+
const pascal = setName
|
|
40
|
+
.split(NAME_SEPARATORS)
|
|
41
|
+
.filter(Boolean)
|
|
42
|
+
.map((part) => part[0].toUpperCase() + part.slice(1))
|
|
43
|
+
.join('');
|
|
44
|
+
return STARTS_WITH_LETTER.test(pascal) ? pascal : `Set${pascal}`;
|
|
45
|
+
}
|
|
46
|
+
/** Manifest export name, e.g. `MyTabIconsSymbols` / `MyTabIconsDrawables`. */
|
|
47
|
+
function manifestExportName(setName, suffix = 'Symbols') {
|
|
48
|
+
return `${manifestBaseName(setName)}${suffix}`;
|
|
49
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageVersion = packageVersion;
|
|
4
|
+
exports.fontToolchainVersions = fontToolchainVersions;
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const PACKAGE_NAME = 'react-native-nano-icons';
|
|
8
|
+
const FONT_TOOLCHAIN = [
|
|
9
|
+
'@xmldom/xmldom',
|
|
10
|
+
'cubic2quad',
|
|
11
|
+
'fonteditor-core',
|
|
12
|
+
'pathkit-wasm',
|
|
13
|
+
'svg2ttf',
|
|
14
|
+
];
|
|
15
|
+
function packageVersion() {
|
|
16
|
+
return installedVersion(PACKAGE_NAME, __dirname);
|
|
17
|
+
}
|
|
18
|
+
function fontToolchainVersions() {
|
|
19
|
+
return FONT_TOOLCHAIN.map((name) => `${name}@${installedVersion(name, path.dirname(require.resolve(name)))}`);
|
|
20
|
+
}
|
|
21
|
+
function installedVersion(name, fromDir) {
|
|
22
|
+
let dir = fromDir;
|
|
23
|
+
for (;;) {
|
|
24
|
+
const manifest = path.join(dir, 'package.json');
|
|
25
|
+
if (fs.existsSync(manifest)) {
|
|
26
|
+
const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
|
|
27
|
+
if (pkg.name === name && typeof pkg.version === 'string') {
|
|
28
|
+
return pkg.version;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const parent = path.dirname(dir);
|
|
32
|
+
if (parent === dir) {
|
|
33
|
+
throw new Error(`Could not locate the ${name} package.json`);
|
|
34
|
+
}
|
|
35
|
+
dir = parent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCodepointFromFilename = parseCodepointFromFilename;
|
|
4
3
|
exports.parseColor = parseColor;
|
|
5
4
|
const colors_1 = require("../const/colors");
|
|
6
|
-
// e.g. u0041.svg -> 65
|
|
7
|
-
function parseCodepointFromFilename(filename) {
|
|
8
|
-
const m = /^u([0-9a-fA-F]+)\.svg$/.exec(filename);
|
|
9
|
-
if (!m)
|
|
10
|
-
throw new Error(`Unexpected glyph filename: ${filename}`);
|
|
11
|
-
return parseInt(m[1], 16);
|
|
12
|
-
}
|
|
13
5
|
// e.g. #ff0000 -> [255, 0, 0, 1], rgba(255, 0, 0, 0.5) -> [255, 0, 0, 0.5], rgb(255, 0, 0) -> [255, 0, 0, 1], blue -> [0, 0, 255, 1] etc.
|
|
14
6
|
function parseColor(color) {
|
|
15
7
|
const c = color.trim();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Path already starts with a moveto. */
|
|
2
|
+
export declare const SVG_MOVE_PREFIX: RegExp;
|
|
3
|
+
/** Trailing close-path command (+ optional whitespace). */
|
|
4
|
+
export declare const SVG_TRAILING_CLOSE: RegExp;
|
|
5
|
+
/** A signed int/float token. */
|
|
6
|
+
export declare const SVG_NUMBER: RegExp;
|
|
7
|
+
/** Whitespace separator (e.g. viewBox parts). */
|
|
8
|
+
export declare const WHITESPACE: RegExp;
|
|
9
|
+
/** `<mask …>` element (unsupported). */
|
|
10
|
+
export declare const XML_MASK: RegExp;
|
|
11
|
+
/** `<filter …>` element (unsupported). */
|
|
12
|
+
export declare const XML_FILTER: RegExp;
|
|
13
|
+
/** `<image …>` element (unsupported). */
|
|
14
|
+
export declare const XML_IMAGE: RegExp;
|
|
15
|
+
/** An `xmlns=` attribute. */
|
|
16
|
+
export declare const XML_XMLNS: RegExp;
|
|
17
|
+
/** Opening `<svg` tag. */
|
|
18
|
+
export declare const SVG_OPEN_TAG: RegExp;
|
|
19
|
+
export declare const PX_ATTRIBUTE_VALUE: RegExp;
|
|
20
|
+
export declare const PX_STYLE_VALUE: RegExp;
|
|
21
|
+
/** viewBox: comma or whitespace separated. */
|
|
22
|
+
export declare const VIEWBOX_SEPARATOR: RegExp;
|
|
23
|
+
/** transform() arguments: comma and/or whitespace separated. */
|
|
24
|
+
export declare const TRANSFORM_ARG_SEPARATOR: RegExp;
|
|
25
|
+
/** stroke-dasharray: single comma or space separated. */
|
|
26
|
+
export declare const DASHARRAY_SEPARATOR: RegExp;
|
|
27
|
+
/** One transform function call, e.g. `rotate(30)`; captures name and args. */
|
|
28
|
+
export declare const TRANSFORM_FUNCTION: RegExp;
|
|
29
|
+
/** `url(#id)` reference; captures the id. */
|
|
30
|
+
export declare const URL_ID_REFERENCE: RegExp;
|
|
31
|
+
/** A well-formed XML attribute name. */
|
|
32
|
+
export declare const XML_ATTRIBUTE_NAME: RegExp;
|
|
33
|
+
export declare const XML_AMP: RegExp;
|
|
34
|
+
export declare const XML_LT: RegExp;
|
|
35
|
+
export declare const XML_GT: RegExp;
|
|
36
|
+
export declare const XML_QUOT: RegExp;
|
|
37
|
+
/** svg2ttf error `glyph "u<hex>"` → captures the hex codepoint. */
|
|
38
|
+
export declare const GLYPH_CODEPOINT: RegExp;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Regexes for parsing/validating SVG path data and XML markup.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.GLYPH_CODEPOINT = exports.XML_QUOT = exports.XML_GT = exports.XML_LT = exports.XML_AMP = exports.XML_ATTRIBUTE_NAME = exports.URL_ID_REFERENCE = exports.TRANSFORM_FUNCTION = exports.DASHARRAY_SEPARATOR = exports.TRANSFORM_ARG_SEPARATOR = exports.VIEWBOX_SEPARATOR = exports.PX_STYLE_VALUE = exports.PX_ATTRIBUTE_VALUE = exports.SVG_OPEN_TAG = exports.XML_XMLNS = exports.XML_IMAGE = exports.XML_FILTER = exports.XML_MASK = exports.WHITESPACE = exports.SVG_NUMBER = exports.SVG_TRAILING_CLOSE = exports.SVG_MOVE_PREFIX = void 0;
|
|
5
|
+
// --- SVG path data ---
|
|
6
|
+
/** Path already starts with a moveto. */
|
|
7
|
+
exports.SVG_MOVE_PREFIX = /^[Mm]/;
|
|
8
|
+
/** Trailing close-path command (+ optional whitespace). */
|
|
9
|
+
exports.SVG_TRAILING_CLOSE = /[Zz]\s*$/;
|
|
10
|
+
/** A signed int/float token. */
|
|
11
|
+
exports.SVG_NUMBER = /-?\d+(?:\.\d+)?/g;
|
|
12
|
+
/** Whitespace separator (e.g. viewBox parts). */
|
|
13
|
+
exports.WHITESPACE = /\s+/;
|
|
14
|
+
// --- SVG/XML validation ---
|
|
15
|
+
/** `<mask …>` element (unsupported). */
|
|
16
|
+
exports.XML_MASK = /<mask[\s>]/i;
|
|
17
|
+
/** `<filter …>` element (unsupported). */
|
|
18
|
+
exports.XML_FILTER = /<filter[\s>]/i;
|
|
19
|
+
/** `<image …>` element (unsupported). */
|
|
20
|
+
exports.XML_IMAGE = /<image[\s>]/i;
|
|
21
|
+
/** An `xmlns=` attribute. */
|
|
22
|
+
exports.XML_XMLNS = /xmlns\s*=/;
|
|
23
|
+
/** Opening `<svg` tag. */
|
|
24
|
+
exports.SVG_OPEN_TAG = /<svg\b/;
|
|
25
|
+
exports.PX_ATTRIBUTE_VALUE = /=(["'])(\s*-?(?:\d+\.?\d*|\.\d+))px\s*\1/g;
|
|
26
|
+
exports.PX_STYLE_VALUE = /(:\s*-?(?:\d+\.?\d*|\.\d+))px(?=\s*(?:;|["']|$))/g;
|
|
27
|
+
// --- SVG attribute value separators ---
|
|
28
|
+
/** viewBox: comma or whitespace separated. */
|
|
29
|
+
exports.VIEWBOX_SEPARATOR = /,|\s+/;
|
|
30
|
+
/** transform() arguments: comma and/or whitespace separated. */
|
|
31
|
+
exports.TRANSFORM_ARG_SEPARATOR = /\s*[,\s]\s*/;
|
|
32
|
+
/** stroke-dasharray: single comma or space separated. */
|
|
33
|
+
exports.DASHARRAY_SEPARATOR = /[, ]/;
|
|
34
|
+
/** One transform function call, e.g. `rotate(30)`; captures name and args. */
|
|
35
|
+
exports.TRANSFORM_FUNCTION = /(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/gi;
|
|
36
|
+
/** `url(#id)` reference; captures the id. */
|
|
37
|
+
exports.URL_ID_REFERENCE = /^url[(]#([\w-]+)[)]$/;
|
|
38
|
+
/** A well-formed XML attribute name. */
|
|
39
|
+
exports.XML_ATTRIBUTE_NAME = /^[A-Za-z_][\w.-]*$/;
|
|
40
|
+
// --- XML escaping / font emit ---
|
|
41
|
+
exports.XML_AMP = /&/g;
|
|
42
|
+
exports.XML_LT = /</g;
|
|
43
|
+
exports.XML_GT = />/g;
|
|
44
|
+
exports.XML_QUOT = /"/g;
|
|
45
|
+
/** svg2ttf error `glyph "u<hex>"` → captures the hex codepoint. */
|
|
46
|
+
exports.GLYPH_CODEPOINT = /glyph\s+"u([0-9a-fA-F]+)"/;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//# sourceMappingURL=codegenPrimitives.js.map
|
|
1
|
+
"use strict";
|
|
@@ -4,5 +4,4 @@ import { createJSIconSet } from "./createNanoIconsSet.shared.js";
|
|
|
4
4
|
export { shallowEqualColor } from "./utils/shallowEqualColor.js";
|
|
5
5
|
export function createIconSet(glyphMap, font) {
|
|
6
6
|
return createJSIconSet(glyphMap, font);
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=createNanoIconsSet.js.map
|
|
7
|
+
}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { memo, useMemo } from 'react';
|
|
4
|
-
import { PixelRatio, UIManager, View
|
|
4
|
+
import { PixelRatio, UIManager, View } from 'react-native';
|
|
5
5
|
import { shallowEqualColor } from "./utils/shallowEqualColor.js";
|
|
6
|
-
import {
|
|
6
|
+
import { validateLayerColor } from "./utils/validateLayerColor.js";
|
|
7
|
+
import { DEFAULT_ICON_SIZE, resolveGlyphEntry, createLayerColorResolver, tintableLayers } from "./utils/glyphRuntime.js";
|
|
7
8
|
import NanoIconViewNative from './specs/NanoIconViewNativeComponent';
|
|
8
9
|
import { createJSIconSet, warnIfLinkingMismatch } from "./createNanoIconsSet.shared.js";
|
|
9
10
|
import { loadDynamicFont, useDynamicFontPending } from "./loadDynamicFont.js";
|
|
11
|
+
import { checkFontIntegrity, isFontMismatch, reportDynamicFontLoadFailure, reportFontMismatch } from "./fontIntegrity.js";
|
|
10
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
13
|
export { shallowEqualColor };
|
|
12
14
|
const HAS_NATIVE_IMPL = UIManager.hasViewManagerConfig('NanoIconView');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function cachedProcessColor(color) {
|
|
18
|
-
let result = processedColorCache.get(color);
|
|
19
|
-
if (result === undefined) {
|
|
20
|
-
result = processColor(color) ?? 0xff000000;
|
|
21
|
-
processedColorCache.set(color, result);
|
|
15
|
+
async function loadFontFromDevServer(family) {
|
|
16
|
+
if (__DEV__) {
|
|
17
|
+
const dev = require('./devServerFont');
|
|
18
|
+
return dev.loadFontFromDevServer(family);
|
|
22
19
|
}
|
|
23
|
-
return
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
async function ensureStaticFont(family) {
|
|
23
|
+
await loadFontFromDevServer(family);
|
|
24
|
+
await checkFontIntegrity(family, 'static');
|
|
24
25
|
}
|
|
25
26
|
export function createIconSet(glyphMap, font) {
|
|
26
27
|
if (!HAS_NATIVE_IMPL) {
|
|
@@ -32,14 +33,23 @@ export function createIconSet(glyphMap, font) {
|
|
|
32
33
|
|
|
33
34
|
// dynamically linked font - register and hide icons until ready
|
|
34
35
|
const managed = glyphMap.m.l === 'd' && font != null;
|
|
36
|
+
const linking = glyphMap.m.l === 'd' ? 'dynamic' : 'static';
|
|
35
37
|
if (managed) {
|
|
36
|
-
void loadDynamicFont(fontFamilyBasename, font).
|
|
37
|
-
if (
|
|
38
|
+
void loadDynamicFont(fontFamilyBasename, font).then(() => checkFontIntegrity(fontFamilyBasename, linking), async err => {
|
|
39
|
+
if (await loadFontFromDevServer(fontFamilyBasename)) return;
|
|
40
|
+
if (isFontMismatch(err)) {
|
|
41
|
+
reportFontMismatch(fontFamilyBasename, linking);
|
|
42
|
+
} else {
|
|
43
|
+
void reportDynamicFontLoadFailure(fontFamilyBasename, err);
|
|
44
|
+
}
|
|
38
45
|
});
|
|
46
|
+
} else if (linking === 'static') {
|
|
47
|
+
void ensureStaticFont(fontFamilyBasename);
|
|
39
48
|
}
|
|
40
49
|
|
|
41
50
|
// Pre-compute per-icon static data (codepoints, default colors) once at set creation
|
|
42
|
-
// Avoids layers.map()
|
|
51
|
+
// Avoids layers.map() per icon mount, and keeps the array identity stable so
|
|
52
|
+
// React Native's prop diff skips re-running processColorArray on re-render.
|
|
43
53
|
const codepointsCache = new Map();
|
|
44
54
|
const defaultColorsCache = new Map();
|
|
45
55
|
function getCodepoints(name, layers) {
|
|
@@ -53,7 +63,7 @@ export function createIconSet(glyphMap, font) {
|
|
|
53
63
|
function getDefaultColors(name, layers) {
|
|
54
64
|
let colors = defaultColorsCache.get(name);
|
|
55
65
|
if (!colors) {
|
|
56
|
-
colors = layers.map(([, srcColor]) =>
|
|
66
|
+
colors = layers.map(([, srcColor], i) => validateLayerColor(srcColor, name, i));
|
|
57
67
|
defaultColorsCache.set(name, colors);
|
|
58
68
|
}
|
|
59
69
|
return colors;
|
|
@@ -62,6 +72,7 @@ export function createIconSet(glyphMap, font) {
|
|
|
62
72
|
name,
|
|
63
73
|
size = DEFAULT_ICON_SIZE,
|
|
64
74
|
color,
|
|
75
|
+
tintMode,
|
|
65
76
|
style,
|
|
66
77
|
allowFontScaling = true,
|
|
67
78
|
accessible,
|
|
@@ -79,14 +90,14 @@ export function createIconSet(glyphMap, font) {
|
|
|
79
90
|
const pending = useDynamicFontPending(managed, fontFamilyBasename);
|
|
80
91
|
const nameStr = name;
|
|
81
92
|
const codepoints = getCodepoints(nameStr, layers);
|
|
82
|
-
const
|
|
93
|
+
const layerColors = useMemo(() => {
|
|
83
94
|
// Fast path: no custom color — use pre-computed defaults
|
|
84
95
|
if (color === undefined || color === null) {
|
|
85
96
|
return getDefaultColors(nameStr, layers);
|
|
86
97
|
}
|
|
87
|
-
const resolveColor = createLayerColorResolver(color);
|
|
88
|
-
return layers.map(([, srcColor], i) =>
|
|
89
|
-
}, [nameStr, color]);
|
|
98
|
+
const resolveColor = createLayerColorResolver(color, tintMode, layers);
|
|
99
|
+
return layers.map(([, srcColor], i) => validateLayerColor(resolveColor(i, srcColor), nameStr, i));
|
|
100
|
+
}, [nameStr, color, tintMode]);
|
|
90
101
|
const nativeStyle = useMemo(() => [{
|
|
91
102
|
width,
|
|
92
103
|
height: scaledSize
|
|
@@ -110,13 +121,13 @@ export function createIconSet(glyphMap, font) {
|
|
|
110
121
|
ref: ref,
|
|
111
122
|
fontFamily: fontFamilyBasename,
|
|
112
123
|
codepoints: codepoints,
|
|
113
|
-
colors:
|
|
114
|
-
|
|
124
|
+
colors: layerColors,
|
|
125
|
+
tintLayers: tintableLayers(layers, tintMode),
|
|
126
|
+
size: size,
|
|
127
|
+
allowFontScaling: allowFontScaling,
|
|
115
128
|
advanceWidth: adv,
|
|
116
129
|
unitsPerEm: unitsPerEm,
|
|
117
|
-
|
|
118
|
-
iconHeight: scaledSize,
|
|
119
|
-
style: nativeStyle,
|
|
130
|
+
style: style,
|
|
120
131
|
accessible: accessible,
|
|
121
132
|
accessibilityRole: accessibilityRole,
|
|
122
133
|
accessibilityLabel: accessibilityLabel ?? name,
|
|
@@ -124,12 +135,11 @@ export function createIconSet(glyphMap, font) {
|
|
|
124
135
|
importantForAccessibility: importantForAccessibility,
|
|
125
136
|
testID: testID
|
|
126
137
|
});
|
|
127
|
-
}, (prev, next) => prev.name === next.name && prev.size === next.size && prev.allowFontScaling === next.allowFontScaling && prev.style === next.style && shallowEqualColor(prev.color, next.color));
|
|
138
|
+
}, (prev, next) => prev.name === next.name && prev.size === next.size && prev.allowFontScaling === next.allowFontScaling && prev.style === next.style && prev.tintMode === next.tintMode && shallowEqualColor(prev.color, next.color));
|
|
128
139
|
Icon.displayName = `NanoIcon(${fontFamilyBasename})`;
|
|
129
140
|
const IconComp = Icon;
|
|
130
141
|
IconComp.loadFont = override => glyphMap.m.l === 'd' ? loadDynamicFont(fontFamilyBasename, override ?? font, {
|
|
131
142
|
force: true
|
|
132
143
|
}) : Promise.resolve();
|
|
133
144
|
return IconComp;
|
|
134
|
-
}
|
|
135
|
-
//# sourceMappingURL=createNanoIconsSet.native.js.map
|
|
145
|
+
}
|
|
@@ -5,6 +5,9 @@ import { PixelRatio, Platform, Text, View } from 'react-native';
|
|
|
5
5
|
import { shallowEqualColor } from "./utils/shallowEqualColor.js";
|
|
6
6
|
import { DEFAULT_ICON_SIZE, resolveGlyphEntry, createCharCache, createLayerColorResolver } from "./utils/glyphRuntime.js";
|
|
7
7
|
import { loadDynamicFont, useDynamicFontPending } from "./loadDynamicFont.js";
|
|
8
|
+
import { warnRuntime } from "./utils/runtimeLog.js";
|
|
9
|
+
import { isFontMismatch, reportDynamicFontLoadFailure, reportFontMismatch, reportMissingDynamicFont } from "./fontIntegrity.js";
|
|
10
|
+
import { configuredFontFamily } from "./utils/fontIdentity.js";
|
|
8
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
12
|
export { shallowEqualColor };
|
|
10
13
|
|
|
@@ -18,14 +21,13 @@ export { shallowEqualColor };
|
|
|
18
21
|
* Fires once per `createIconSet` call (not per render).
|
|
19
22
|
*/
|
|
20
23
|
export function warnIfLinkingMismatch(fontFamily, linking, font) {
|
|
21
|
-
if (!__DEV__) return;
|
|
22
24
|
const isDynamic = linking === 'd';
|
|
23
25
|
if (isDynamic && font == null) {
|
|
24
|
-
|
|
26
|
+
void reportMissingDynamicFont(fontFamily);
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
27
|
-
if (!isDynamic && font != null) {
|
|
28
|
-
|
|
29
|
+
if (__DEV__ && !isDynamic && font != null) {
|
|
30
|
+
warnRuntime(`Icon font "${configuredFontFamily(fontFamily)}" is built with static linking, so the font passed to createNanoIconSet is ignored. ` + `Set linking: 'dynamic' in your config to deliver it at runtime.`);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -42,7 +44,11 @@ export function createJSIconSet(glyphMap, font) {
|
|
|
42
44
|
const managed = glyphMap.m.l === 'd' && font != null;
|
|
43
45
|
if (managed) {
|
|
44
46
|
void loadDynamicFont(fontBasename, font).catch(err => {
|
|
45
|
-
if (
|
|
47
|
+
if (isFontMismatch(err)) {
|
|
48
|
+
reportFontMismatch(fontBasename, 'dynamic');
|
|
49
|
+
} else {
|
|
50
|
+
void reportDynamicFontLoadFailure(fontBasename, err);
|
|
51
|
+
}
|
|
46
52
|
});
|
|
47
53
|
}
|
|
48
54
|
const fontReference = Platform.select({
|
|
@@ -63,6 +69,7 @@ export function createJSIconSet(glyphMap, font) {
|
|
|
63
69
|
name,
|
|
64
70
|
size = DEFAULT_ICON_SIZE,
|
|
65
71
|
color,
|
|
72
|
+
tintMode,
|
|
66
73
|
style,
|
|
67
74
|
allowFontScaling = true,
|
|
68
75
|
accessible,
|
|
@@ -78,7 +85,7 @@ export function createJSIconSet(glyphMap, font) {
|
|
|
78
85
|
const scaledSize = size * fontScale;
|
|
79
86
|
const width = adv / unitsPerEm * scaledSize;
|
|
80
87
|
const pending = useDynamicFontPending(managed, fontBasename);
|
|
81
|
-
const resolveColor = createLayerColorResolver(color);
|
|
88
|
+
const resolveColor = createLayerColorResolver(color, tintMode, layers);
|
|
82
89
|
const containerStyle = useMemo(() => [{
|
|
83
90
|
height: scaledSize,
|
|
84
91
|
width,
|
|
@@ -109,12 +116,11 @@ export function createJSIconSet(glyphMap, font) {
|
|
|
109
116
|
}, i);
|
|
110
117
|
})
|
|
111
118
|
});
|
|
112
|
-
}, (prev, next) => prev.name === next.name && prev.size === next.size && prev.allowFontScaling === next.allowFontScaling && prev.style === next.style && shallowEqualColor(prev.color, next.color));
|
|
119
|
+
}, (prev, next) => prev.name === next.name && prev.size === next.size && prev.allowFontScaling === next.allowFontScaling && prev.style === next.style && prev.tintMode === next.tintMode && shallowEqualColor(prev.color, next.color));
|
|
113
120
|
Icon.displayName = `NanoIcon(${fontBasename})`;
|
|
114
121
|
const IconComp = Icon;
|
|
115
122
|
IconComp.loadFont = override => glyphMap.m.l === 'd' ? loadDynamicFont(fontBasename, override ?? font, {
|
|
116
123
|
force: true
|
|
117
124
|
}) : Promise.resolve();
|
|
118
125
|
return IconComp;
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=createNanoIconsSet.shared.js.map
|
|
126
|
+
}
|
|
@@ -3,29 +3,43 @@
|
|
|
3
3
|
import { memo, useMemo } from 'react';
|
|
4
4
|
import { shallowEqualColor } from "./utils/shallowEqualColor.js";
|
|
5
5
|
import { DEFAULT_ICON_SIZE, resolveGlyphEntry, createCharCache, createLayerColorResolver } from "./utils/glyphRuntime.js";
|
|
6
|
+
import { configuredFontFamily } from "./utils/fontIdentity.js";
|
|
7
|
+
import { useDynamicFontStatus } from "./loadDynamicFont.js";
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
export { shallowEqualColor };
|
|
10
|
+
async function loadFontFromDevServer(family) {
|
|
11
|
+
if (__DEV__) {
|
|
12
|
+
const dev = require('./devServerFont');
|
|
13
|
+
return dev.loadFontFromDevServer(family);
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
8
17
|
|
|
9
18
|
// Web renderer: uses inline <span> elements so icons flow out of the box (display: inline-block keeps width/height)
|
|
10
19
|
export function createIconSet(glyphMap) {
|
|
11
|
-
const
|
|
20
|
+
const family = glyphMap.m.f;
|
|
21
|
+
const fontBasename = configuredFontFamily(family);
|
|
12
22
|
const unitsPerEm = glyphMap.m.u;
|
|
13
23
|
const getChar = createCharCache();
|
|
24
|
+
void loadFontFromDevServer(family);
|
|
14
25
|
const Icon = /*#__PURE__*/memo(({
|
|
15
26
|
name,
|
|
16
27
|
size = DEFAULT_ICON_SIZE,
|
|
17
28
|
color,
|
|
29
|
+
tintMode,
|
|
18
30
|
style,
|
|
19
31
|
accessible,
|
|
20
32
|
accessibilityLabel,
|
|
21
33
|
accessibilityRole = 'image',
|
|
22
34
|
accessibilityElementsHidden,
|
|
23
35
|
testID,
|
|
36
|
+
className,
|
|
24
37
|
ref
|
|
25
38
|
}) => {
|
|
26
39
|
const [adv, layers] = resolveGlyphEntry(glyphMap, name);
|
|
27
40
|
const width = adv / unitsPerEm * size;
|
|
28
|
-
const
|
|
41
|
+
const fontFamily = useDynamicFontStatus(family) === 'ready' ? family : fontBasename;
|
|
42
|
+
const resolveColor = createLayerColorResolver(color, tintMode, layers);
|
|
29
43
|
const containerStyle = useMemo(() => ({
|
|
30
44
|
display: 'inline-block',
|
|
31
45
|
position: 'relative',
|
|
@@ -39,17 +53,18 @@ export function createIconSet(glyphMap) {
|
|
|
39
53
|
position: 'absolute',
|
|
40
54
|
left: 0,
|
|
41
55
|
bottom: 0,
|
|
42
|
-
fontFamily
|
|
56
|
+
fontFamily,
|
|
43
57
|
fontWeight: 'normal',
|
|
44
58
|
fontStyle: 'normal',
|
|
45
59
|
fontSize: size,
|
|
46
60
|
lineHeight: 1,
|
|
47
61
|
whiteSpace: 'pre'
|
|
48
|
-
}), [size]);
|
|
62
|
+
}), [size, fontFamily]);
|
|
49
63
|
const isHidden = accessible === false || accessibilityElementsHidden;
|
|
50
64
|
const role = accessibilityRole === 'image' ? 'img' : accessibilityRole;
|
|
51
65
|
return /*#__PURE__*/_jsx("span", {
|
|
52
66
|
ref: ref,
|
|
67
|
+
className: className,
|
|
53
68
|
style: containerStyle,
|
|
54
69
|
role: isHidden ? undefined : role,
|
|
55
70
|
"aria-label": isHidden ? undefined : accessibilityLabel ?? name,
|
|
@@ -67,12 +82,11 @@ export function createIconSet(glyphMap) {
|
|
|
67
82
|
}, i);
|
|
68
83
|
})
|
|
69
84
|
});
|
|
70
|
-
}, (prev, next) => prev.name === next.name && prev.size === next.size && prev.style === next.style && shallowEqualColor(prev.color, next.color));
|
|
85
|
+
}, (prev, next) => prev.name === next.name && prev.size === next.size && prev.style === next.style && prev.className === next.className && prev.tintMode === next.tintMode && shallowEqualColor(prev.color, next.color));
|
|
71
86
|
Icon.displayName = `NanoIcon(${fontBasename})`;
|
|
72
87
|
|
|
73
|
-
// No-op on web:
|
|
88
|
+
// No-op on web: the host app links the font under the configured family name, nothing to load at runtime.
|
|
74
89
|
const IconComp = Icon;
|
|
75
90
|
IconComp.loadFont = () => Promise.resolve();
|
|
76
91
|
return IconComp;
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=createNanoIconsSet.web.js.map
|
|
92
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
4
|
+
import { isFontRegistered } from "./fontIntegrity.js";
|
|
5
|
+
import { loadDynamicFont } from "./loadDynamicFont.js";
|
|
6
|
+
import NanoIconsFontLoader from './nativeFontLoader';
|
|
7
|
+
export const DEV_SERVER_FONT_ROUTE = '/__nanoicons/';
|
|
8
|
+
export function devServerFontUri(family) {
|
|
9
|
+
const scriptURL = TurboModuleRegistry.get('SourceCode')?.getConstants().scriptURL;
|
|
10
|
+
const origin = scriptURL?.match(/^https?:\/\/[^/]+/)?.[0];
|
|
11
|
+
return origin ? `${origin}${DEV_SERVER_FONT_ROUTE}${encodeURIComponent(family)}.ttf` : undefined;
|
|
12
|
+
}
|
|
13
|
+
export async function loadFontFromDevServer(family) {
|
|
14
|
+
if (!NanoIconsFontLoader) return false;
|
|
15
|
+
if (await isFontRegistered(family)) return true;
|
|
16
|
+
const uri = devServerFontUri(family);
|
|
17
|
+
if (!uri) return false;
|
|
18
|
+
try {
|
|
19
|
+
const head = await fetch(uri, {
|
|
20
|
+
method: 'HEAD'
|
|
21
|
+
});
|
|
22
|
+
if (!head.ok) return false;
|
|
23
|
+
await loadDynamicFont(family, {
|
|
24
|
+
uri
|
|
25
|
+
});
|
|
26
|
+
return true;
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getFontStatus, loadDynamicFont } from "./loadDynamicFont.js";
|
|
4
|
+
export const DEV_SERVER_FONT_ROUTE = '/__nanoicons/';
|
|
5
|
+
export function devServerFontUri(family) {
|
|
6
|
+
const origin = globalThis.location?.origin;
|
|
7
|
+
return origin ? `${origin}${DEV_SERVER_FONT_ROUTE}${encodeURIComponent(family)}.ttf` : undefined;
|
|
8
|
+
}
|
|
9
|
+
export async function loadFontFromDevServer(family) {
|
|
10
|
+
if (getFontStatus(family) === 'ready') return true;
|
|
11
|
+
const uri = devServerFontUri(family);
|
|
12
|
+
if (!uri) return false;
|
|
13
|
+
try {
|
|
14
|
+
const head = await fetch(uri, {
|
|
15
|
+
method: 'HEAD'
|
|
16
|
+
});
|
|
17
|
+
if (!head.ok) return false;
|
|
18
|
+
await loadDynamicFont(family, {
|
|
19
|
+
uri
|
|
20
|
+
});
|
|
21
|
+
return true;
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|