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
package/src/core/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"rootDir": "../..",
|
|
4
|
-
"outDir": "../../lib/commonjs",
|
|
5
|
-
|
|
6
|
-
"target": "ES2022",
|
|
7
|
-
"module": "NodeNext",
|
|
8
|
-
"moduleResolution": "NodeNext",
|
|
9
|
-
|
|
10
|
-
"lib": ["ES2022"],
|
|
11
|
-
"types": ["node"],
|
|
12
|
-
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"skipLibCheck": true,
|
|
16
|
-
|
|
17
|
-
"noEmit": false,
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"declarationMap": false,
|
|
20
|
-
|
|
21
|
-
"sourceMap": false,
|
|
22
|
-
"inlineSources": false,
|
|
23
|
-
|
|
24
|
-
"strict": true,
|
|
25
|
-
"noUncheckedIndexedAccess": true
|
|
26
|
-
},
|
|
27
|
-
"include": [
|
|
28
|
-
"./pipeline/**/*.ts",
|
|
29
|
-
"./font/**/*.ts",
|
|
30
|
-
"./svg/**/*.ts"
|
|
31
|
-
]
|
|
32
|
-
}
|
package/src/core/types.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
export type NanoLogger = {
|
|
2
|
-
start: (msg: string) => void;
|
|
3
|
-
update: (msg: string) => void;
|
|
4
|
-
succeed: (msg: string) => void;
|
|
5
|
-
fail: (msg: string) => void;
|
|
6
|
-
/** Only printed when level is 'verbose'. */
|
|
7
|
-
info: (msg: string) => void;
|
|
8
|
-
warn: (msg: string) => void;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type Point = readonly [number, number];
|
|
12
|
-
|
|
13
|
-
export type Cmd = readonly number[];
|
|
14
|
-
|
|
15
|
-
export type VerbMap = {
|
|
16
|
-
MOVE: number;
|
|
17
|
-
LINE: number;
|
|
18
|
-
QUAD: number;
|
|
19
|
-
CONIC: number;
|
|
20
|
-
CUBIC: number;
|
|
21
|
-
CLOSE: number;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type WrappedPath = {
|
|
25
|
-
p: PathKitPath;
|
|
26
|
-
meta: { moves: Point[] };
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export interface PathKitPath {
|
|
30
|
-
delete?: () => void;
|
|
31
|
-
|
|
32
|
-
moveTo: (x: number, y: number) => void;
|
|
33
|
-
lineTo: (x: number, y: number) => void;
|
|
34
|
-
quadTo: (x1: number, y1: number, x2: number, y2: number) => void;
|
|
35
|
-
cubicTo: (
|
|
36
|
-
x1: number,
|
|
37
|
-
y1: number,
|
|
38
|
-
x2: number,
|
|
39
|
-
y2: number,
|
|
40
|
-
x3: number,
|
|
41
|
-
y3: number
|
|
42
|
-
) => void;
|
|
43
|
-
close: () => void;
|
|
44
|
-
|
|
45
|
-
simplify: () => void;
|
|
46
|
-
toSVGString: () => string;
|
|
47
|
-
toCmds: () => Cmd[];
|
|
48
|
-
|
|
49
|
-
getBounds: () => {
|
|
50
|
-
fLeft: number;
|
|
51
|
-
fTop: number;
|
|
52
|
-
fRight: number;
|
|
53
|
-
fBottom: number;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
getFillType?: () => number;
|
|
57
|
-
setFillType: (t: number) => void;
|
|
58
|
-
|
|
59
|
-
dash?: (on: number, off: number, phase: number) => void;
|
|
60
|
-
stroke: (opts: {
|
|
61
|
-
width: number;
|
|
62
|
-
cap: number;
|
|
63
|
-
join: number;
|
|
64
|
-
miter_limit: number;
|
|
65
|
-
}) => PathKitPath | null;
|
|
66
|
-
|
|
67
|
-
transform: (
|
|
68
|
-
a: number,
|
|
69
|
-
c: number,
|
|
70
|
-
e: number,
|
|
71
|
-
b: number,
|
|
72
|
-
d: number,
|
|
73
|
-
f: number,
|
|
74
|
-
g: number,
|
|
75
|
-
h: number,
|
|
76
|
-
i: number
|
|
77
|
-
) => void;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface PathKitModule {
|
|
81
|
-
MOVE_VERB?: number;
|
|
82
|
-
LINE_VERB?: number;
|
|
83
|
-
QUAD_VERB?: number;
|
|
84
|
-
CONIC_VERB?: number;
|
|
85
|
-
CUBIC_VERB?: number;
|
|
86
|
-
CLOSE_VERB?: number;
|
|
87
|
-
|
|
88
|
-
FillType?: {
|
|
89
|
-
EVENODD?: number;
|
|
90
|
-
EVEN_ODD?: number;
|
|
91
|
-
WINDING?: number;
|
|
92
|
-
NONZERO?: number;
|
|
93
|
-
};
|
|
94
|
-
StrokeCap?: { BUTT?: number; ROUND?: number; SQUARE?: number };
|
|
95
|
-
StrokeJoin?: { MITER?: number; ROUND?: number; BEVEL?: number };
|
|
96
|
-
PathOp?: { UNION?: number; INTERSECT?: number; DIFFERENCE?: number };
|
|
97
|
-
|
|
98
|
-
NewPath: (src?: PathKitPath) => PathKitPath;
|
|
99
|
-
FromSVGString: (svg: string) => PathKitPath | null;
|
|
100
|
-
MakeFromOp: (
|
|
101
|
-
a: PathKitPath,
|
|
102
|
-
b: PathKitPath,
|
|
103
|
-
op: number
|
|
104
|
-
) => PathKitPath | null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export type PyodideModule = {
|
|
108
|
-
mountNodeFS: (mountpoint: string, hostPath: string) => void;
|
|
109
|
-
registerJsModule: (name: string, mod: unknown) => void;
|
|
110
|
-
loadPackage: (
|
|
111
|
-
pkgs: string[],
|
|
112
|
-
options?: {
|
|
113
|
-
messageCallback?: (msg: string) => void;
|
|
114
|
-
errorCallback?: (msg: string) => void;
|
|
115
|
-
}
|
|
116
|
-
) => Promise<void>;
|
|
117
|
-
runPythonAsync: (code: string) => Promise<unknown>;
|
|
118
|
-
runPython: (code: string) => string;
|
|
119
|
-
FS: { writeFile: (path: string, data: string) => void };
|
|
120
|
-
globals: {
|
|
121
|
-
set: (key: string, value: unknown) => void;
|
|
122
|
-
get: (key: string) => unknown;
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export type GlyphLayer = [codepoint: number, color: string];
|
|
127
|
-
export type GlyphEntry = [adv: number, layers: GlyphLayer[]];
|
|
128
|
-
export type IconsMap = Record<string, GlyphEntry>;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* m - metadata,
|
|
132
|
-
* f - font family,
|
|
133
|
-
* u - units per em,
|
|
134
|
-
* z - safe zone,
|
|
135
|
-
* s - start unicode,
|
|
136
|
-
* h - hash,
|
|
137
|
-
* l - linking mode: 's' (static, bundled — default when absent) or 'd' (dynamic, OTA-delivered),
|
|
138
|
-
* i - icons,
|
|
139
|
-
* adv - advance width,
|
|
140
|
-
*/
|
|
141
|
-
export type NanoGlyphMap = {
|
|
142
|
-
m: { f: string; u: number; z: number; s: number; h?: string; l?: 's' | 'd' };
|
|
143
|
-
i: IconsMap;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
/** Accepts JSON-inferred types where arrays aren't tuples. */
|
|
147
|
-
export type NanoGlyphMapInput = {
|
|
148
|
-
m: {
|
|
149
|
-
f: string;
|
|
150
|
-
u: number;
|
|
151
|
-
z: number;
|
|
152
|
-
s: number;
|
|
153
|
-
h?: string;
|
|
154
|
-
l?: 's' | 'd' | (string & {});
|
|
155
|
-
};
|
|
156
|
-
i: Record<string, readonly unknown[]>;
|
|
157
|
-
};
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { memo, useMemo } from 'react';
|
|
2
|
-
import { PixelRatio, UIManager, View, processColor } from 'react-native';
|
|
3
|
-
import type { NanoGlyphMapInput, GlyphEntry } from './core/types';
|
|
4
|
-
import type { IconComponent, IconProps } from './types';
|
|
5
|
-
import { shallowEqualColor } from './utils/shallowEqualColor';
|
|
6
|
-
import {
|
|
7
|
-
DEFAULT_ICON_SIZE,
|
|
8
|
-
resolveGlyphEntry,
|
|
9
|
-
createLayerColorResolver,
|
|
10
|
-
} from './utils/glyphRuntime';
|
|
11
|
-
import NanoIconViewNative from './specs/NanoIconViewNativeComponent';
|
|
12
|
-
import {
|
|
13
|
-
createJSIconSet,
|
|
14
|
-
warnIfLinkingMismatch,
|
|
15
|
-
} from './createNanoIconsSet.shared';
|
|
16
|
-
import { loadDynamicFont, useDynamicFontPending } from './loadDynamicFont';
|
|
17
|
-
|
|
18
|
-
export type { IconComponent, IconProps };
|
|
19
|
-
export { shallowEqualColor };
|
|
20
|
-
|
|
21
|
-
const HAS_NATIVE_IMPL = UIManager.hasViewManagerConfig('NanoIconView');
|
|
22
|
-
|
|
23
|
-
// Shared processColor cache — avoids redundant color parsing for repeated
|
|
24
|
-
// color strings like "black", "rgba(0,0,0,0.3)" across thousands of icons
|
|
25
|
-
const processedColorCache = new Map<string, number>();
|
|
26
|
-
function cachedProcessColor(color: string): number {
|
|
27
|
-
let result = processedColorCache.get(color);
|
|
28
|
-
if (result === undefined) {
|
|
29
|
-
result = (processColor(color) ?? 0xff000000) as number;
|
|
30
|
-
processedColorCache.set(color, result);
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function createIconSet<GM extends NanoGlyphMapInput>(
|
|
36
|
-
glyphMap: GM
|
|
37
|
-
): IconComponent<GM>;
|
|
38
|
-
export function createIconSet<GM extends NanoGlyphMapInput>(
|
|
39
|
-
glyphMap: GM,
|
|
40
|
-
font: unknown
|
|
41
|
-
): IconComponent<GM>;
|
|
42
|
-
export function createIconSet<GM extends NanoGlyphMapInput>(
|
|
43
|
-
glyphMap: GM,
|
|
44
|
-
font?: unknown
|
|
45
|
-
): IconComponent<GM> {
|
|
46
|
-
if (!HAS_NATIVE_IMPL) {
|
|
47
|
-
return createJSIconSet(glyphMap, font);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const fontFamilyBasename = glyphMap.m.f;
|
|
51
|
-
const unitsPerEm = glyphMap.m.u;
|
|
52
|
-
warnIfLinkingMismatch(fontFamilyBasename, glyphMap.m.l, font);
|
|
53
|
-
|
|
54
|
-
// dynamically linked font - register and hide icons until ready
|
|
55
|
-
const managed = glyphMap.m.l === 'd' && font != null;
|
|
56
|
-
if (managed) {
|
|
57
|
-
void loadDynamicFont(fontFamilyBasename, font).catch((err) => {
|
|
58
|
-
if (__DEV__)
|
|
59
|
-
console.warn(
|
|
60
|
-
`[react-native-nano-icons] Failed to load dynamic font "${fontFamilyBasename}".`,
|
|
61
|
-
err
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Pre-compute per-icon static data (codepoints, default colors) once at set creation
|
|
67
|
-
// Avoids layers.map() + processColor per icon mount
|
|
68
|
-
const codepointsCache = new Map<string, readonly number[]>();
|
|
69
|
-
const defaultColorsCache = new Map<string, readonly number[]>();
|
|
70
|
-
|
|
71
|
-
function getCodepoints(
|
|
72
|
-
name: string,
|
|
73
|
-
layers: GlyphEntry[1]
|
|
74
|
-
): readonly number[] {
|
|
75
|
-
let cp = codepointsCache.get(name);
|
|
76
|
-
if (!cp) {
|
|
77
|
-
cp = layers.map(([c]) => c);
|
|
78
|
-
codepointsCache.set(name, cp);
|
|
79
|
-
}
|
|
80
|
-
return cp;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function getDefaultColors(
|
|
84
|
-
name: string,
|
|
85
|
-
layers: GlyphEntry[1]
|
|
86
|
-
): readonly number[] {
|
|
87
|
-
let colors = defaultColorsCache.get(name);
|
|
88
|
-
if (!colors) {
|
|
89
|
-
colors = layers.map(([, srcColor]) =>
|
|
90
|
-
cachedProcessColor(srcColor ?? 'black')
|
|
91
|
-
);
|
|
92
|
-
defaultColorsCache.set(name, colors);
|
|
93
|
-
}
|
|
94
|
-
return colors;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const Icon = memo(
|
|
98
|
-
({
|
|
99
|
-
name,
|
|
100
|
-
size = DEFAULT_ICON_SIZE,
|
|
101
|
-
color,
|
|
102
|
-
style,
|
|
103
|
-
allowFontScaling = true,
|
|
104
|
-
accessible,
|
|
105
|
-
accessibilityLabel,
|
|
106
|
-
accessibilityRole = 'image',
|
|
107
|
-
accessibilityElementsHidden,
|
|
108
|
-
importantForAccessibility,
|
|
109
|
-
testID,
|
|
110
|
-
ref,
|
|
111
|
-
}: IconProps<keyof GM['i']>) => {
|
|
112
|
-
const fontScale = allowFontScaling ? PixelRatio.getFontScale() : 1;
|
|
113
|
-
const [adv, layers] = resolveGlyphEntry(glyphMap, name);
|
|
114
|
-
const scaledSize = size * fontScale;
|
|
115
|
-
const width = (adv / unitsPerEm) * scaledSize;
|
|
116
|
-
|
|
117
|
-
const pending = useDynamicFontPending(managed, fontFamilyBasename);
|
|
118
|
-
|
|
119
|
-
const nameStr = name as string;
|
|
120
|
-
const codepoints = getCodepoints(nameStr, layers);
|
|
121
|
-
|
|
122
|
-
const processedColors = useMemo(() => {
|
|
123
|
-
// Fast path: no custom color — use pre-computed defaults
|
|
124
|
-
if (color === undefined || color === null) {
|
|
125
|
-
return getDefaultColors(nameStr, layers);
|
|
126
|
-
}
|
|
127
|
-
const resolveColor = createLayerColorResolver(color);
|
|
128
|
-
return layers.map(([, srcColor], i) =>
|
|
129
|
-
cachedProcessColor(resolveColor(i, srcColor) as string)
|
|
130
|
-
);
|
|
131
|
-
}, [nameStr, color]);
|
|
132
|
-
|
|
133
|
-
const nativeStyle = useMemo(
|
|
134
|
-
() => [{ width, height: scaledSize }, style],
|
|
135
|
-
[scaledSize, width, style]
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
// Hide-until-ready: while the dynamic font is registering, render a
|
|
139
|
-
// placeholder. The native view mounts only once the font is registered.
|
|
140
|
-
if (pending) {
|
|
141
|
-
return (
|
|
142
|
-
<View
|
|
143
|
-
ref={ref}
|
|
144
|
-
style={nativeStyle}
|
|
145
|
-
accessible={accessible}
|
|
146
|
-
accessibilityRole={accessibilityRole}
|
|
147
|
-
accessibilityLabel={accessibilityLabel ?? (name as string)}
|
|
148
|
-
accessibilityElementsHidden={accessibilityElementsHidden}
|
|
149
|
-
importantForAccessibility={importantForAccessibility}
|
|
150
|
-
testID={testID}
|
|
151
|
-
/>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<NanoIconViewNative
|
|
157
|
-
ref={ref}
|
|
158
|
-
fontFamily={fontFamilyBasename}
|
|
159
|
-
codepoints={codepoints}
|
|
160
|
-
colors={processedColors}
|
|
161
|
-
fontSize={size}
|
|
162
|
-
advanceWidth={adv}
|
|
163
|
-
unitsPerEm={unitsPerEm}
|
|
164
|
-
iconWidth={width}
|
|
165
|
-
iconHeight={scaledSize}
|
|
166
|
-
style={nativeStyle}
|
|
167
|
-
accessible={accessible}
|
|
168
|
-
accessibilityRole={accessibilityRole}
|
|
169
|
-
accessibilityLabel={accessibilityLabel ?? (name as string)}
|
|
170
|
-
accessibilityElementsHidden={accessibilityElementsHidden}
|
|
171
|
-
importantForAccessibility={importantForAccessibility}
|
|
172
|
-
testID={testID}
|
|
173
|
-
/>
|
|
174
|
-
);
|
|
175
|
-
},
|
|
176
|
-
(prev, next) =>
|
|
177
|
-
prev.name === next.name &&
|
|
178
|
-
prev.size === next.size &&
|
|
179
|
-
prev.allowFontScaling === next.allowFontScaling &&
|
|
180
|
-
prev.style === next.style &&
|
|
181
|
-
shallowEqualColor(prev.color, next.color)
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
Icon.displayName = `NanoIcon(${fontFamilyBasename})`;
|
|
185
|
-
|
|
186
|
-
const IconComp = Icon as unknown as IconComponent<GM>;
|
|
187
|
-
IconComp.loadFont = (override) =>
|
|
188
|
-
glyphMap.m.l === 'd'
|
|
189
|
-
? loadDynamicFont(fontFamilyBasename, override ?? font, { force: true })
|
|
190
|
-
: Promise.resolve();
|
|
191
|
-
return IconComp;
|
|
192
|
-
}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { memo, useMemo } from 'react';
|
|
2
|
-
import { PixelRatio, Platform, Text, View, type TextProps } from 'react-native';
|
|
3
|
-
import type { NanoGlyphMapInput } from './core/types';
|
|
4
|
-
import type { IconComponent, IconProps } from './types';
|
|
5
|
-
import { shallowEqualColor } from './utils/shallowEqualColor';
|
|
6
|
-
import {
|
|
7
|
-
DEFAULT_ICON_SIZE,
|
|
8
|
-
resolveGlyphEntry,
|
|
9
|
-
createCharCache,
|
|
10
|
-
createLayerColorResolver,
|
|
11
|
-
} from './utils/glyphRuntime';
|
|
12
|
-
import { loadDynamicFont, useDynamicFontPending } from './loadDynamicFont';
|
|
13
|
-
|
|
14
|
-
export type { IconComponent, IconProps };
|
|
15
|
-
export { shallowEqualColor };
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Warn when the `font` argument and the glyphmap's linking mode are inconsistent.
|
|
19
|
-
*
|
|
20
|
-
* - Dynamic glyphmap without a `font` arg: caller probably forgot to pass it; icons
|
|
21
|
-
* will render as tofu until the host app loads a font under family `fontFamily`.
|
|
22
|
-
* - Static glyphmap with a `font` arg: argument is ignored, font is bundled natively.
|
|
23
|
-
*
|
|
24
|
-
* Fires once per `createIconSet` call (not per render).
|
|
25
|
-
*/
|
|
26
|
-
export function warnIfLinkingMismatch(
|
|
27
|
-
fontFamily: string,
|
|
28
|
-
linking: string | undefined,
|
|
29
|
-
font: unknown
|
|
30
|
-
): void {
|
|
31
|
-
if (!__DEV__) return;
|
|
32
|
-
|
|
33
|
-
const isDynamic = linking === 'd';
|
|
34
|
-
if (isDynamic && font == null) {
|
|
35
|
-
console.warn(
|
|
36
|
-
`[react-native-nano-icons] "${fontFamily}" is built with dynamic linking ` +
|
|
37
|
-
`but no font was passed to createIconSet. Icons will render as tofu ` +
|
|
38
|
-
`until a font is loaded and registered under family "${fontFamily}".`
|
|
39
|
-
);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (!isDynamic && font != null) {
|
|
43
|
-
console.warn(
|
|
44
|
-
`[react-native-nano-icons] "${fontFamily}" is built with static linking; ` +
|
|
45
|
-
`the font argument passed to createIconSet is ignored. ` +
|
|
46
|
-
`Set linking: 'dynamic' in your config to opt into OTA delivery.`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* JS implementation using <View> + <Text> layers.
|
|
53
|
-
* Used on web and as a fallback when native component is unavailable (e.g. Expo Go).
|
|
54
|
-
*/
|
|
55
|
-
export function createJSIconSet<GM extends NanoGlyphMapInput>(
|
|
56
|
-
glyphMap: GM
|
|
57
|
-
): IconComponent<GM>;
|
|
58
|
-
export function createJSIconSet<GM extends NanoGlyphMapInput>(
|
|
59
|
-
glyphMap: GM,
|
|
60
|
-
font: unknown
|
|
61
|
-
): IconComponent<GM>;
|
|
62
|
-
export function createJSIconSet<GM extends NanoGlyphMapInput>(
|
|
63
|
-
glyphMap: GM,
|
|
64
|
-
font?: unknown
|
|
65
|
-
): IconComponent<GM> {
|
|
66
|
-
const fontBasename = glyphMap.m.f;
|
|
67
|
-
warnIfLinkingMismatch(fontBasename, glyphMap.m.l, font);
|
|
68
|
-
|
|
69
|
-
// dynamically linked font - register and hide icons until ready
|
|
70
|
-
const managed = glyphMap.m.l === 'd' && font != null;
|
|
71
|
-
if (managed) {
|
|
72
|
-
void loadDynamicFont(fontBasename, font).catch((err) => {
|
|
73
|
-
if (__DEV__)
|
|
74
|
-
console.warn(
|
|
75
|
-
`[react-native-nano-icons] Failed to load dynamic font "${fontBasename}".`,
|
|
76
|
-
err
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const fontReference = Platform.select({
|
|
82
|
-
windows: `/Assets/${fontBasename}`,
|
|
83
|
-
default: fontBasename,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const styleOverrides: TextProps['style'] = {
|
|
87
|
-
fontFamily: fontReference,
|
|
88
|
-
fontWeight: 'normal',
|
|
89
|
-
fontStyle: 'normal',
|
|
90
|
-
position: 'absolute',
|
|
91
|
-
includeFontPadding: false,
|
|
92
|
-
bottom: 0,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const unitsPerEm = glyphMap.m.u;
|
|
96
|
-
const getChar = createCharCache();
|
|
97
|
-
|
|
98
|
-
const Icon = memo(
|
|
99
|
-
({
|
|
100
|
-
name,
|
|
101
|
-
size = DEFAULT_ICON_SIZE,
|
|
102
|
-
color,
|
|
103
|
-
style,
|
|
104
|
-
allowFontScaling = true,
|
|
105
|
-
accessible,
|
|
106
|
-
accessibilityLabel,
|
|
107
|
-
accessibilityRole = 'image',
|
|
108
|
-
accessibilityElementsHidden,
|
|
109
|
-
importantForAccessibility,
|
|
110
|
-
testID,
|
|
111
|
-
ref,
|
|
112
|
-
}: IconProps<keyof GM['i']>) => {
|
|
113
|
-
const fontScale = allowFontScaling ? PixelRatio.getFontScale() : 1;
|
|
114
|
-
const [adv, layers] = resolveGlyphEntry(glyphMap, name);
|
|
115
|
-
const scaledSize = size * fontScale;
|
|
116
|
-
const width = (adv / unitsPerEm) * scaledSize;
|
|
117
|
-
|
|
118
|
-
const pending = useDynamicFontPending(managed, fontBasename);
|
|
119
|
-
|
|
120
|
-
const resolveColor = createLayerColorResolver(color);
|
|
121
|
-
|
|
122
|
-
const containerStyle = useMemo(
|
|
123
|
-
() => [{ height: scaledSize, width, bottom: 0 as const }, style],
|
|
124
|
-
[scaledSize, width, style]
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const sizeStyle = useMemo(() => ({ fontSize: size }), [size]);
|
|
128
|
-
|
|
129
|
-
return (
|
|
130
|
-
<View
|
|
131
|
-
ref={ref}
|
|
132
|
-
style={containerStyle}
|
|
133
|
-
accessible={accessible}
|
|
134
|
-
accessibilityRole={accessibilityRole}
|
|
135
|
-
accessibilityLabel={accessibilityLabel ?? (name as string)}
|
|
136
|
-
accessibilityElementsHidden={accessibilityElementsHidden}
|
|
137
|
-
importantForAccessibility={importantForAccessibility}
|
|
138
|
-
testID={testID}>
|
|
139
|
-
{pending
|
|
140
|
-
? null
|
|
141
|
-
: layers.map(([codepoint, srcColor], i) => {
|
|
142
|
-
const layerColor = resolveColor(i, srcColor);
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<Text
|
|
146
|
-
key={i}
|
|
147
|
-
selectable={false}
|
|
148
|
-
accessible={false}
|
|
149
|
-
allowFontScaling={allowFontScaling}
|
|
150
|
-
style={[styleOverrides, sizeStyle, { color: layerColor }]}>
|
|
151
|
-
{getChar(codepoint)}
|
|
152
|
-
</Text>
|
|
153
|
-
);
|
|
154
|
-
})}
|
|
155
|
-
</View>
|
|
156
|
-
);
|
|
157
|
-
},
|
|
158
|
-
(prev, next) =>
|
|
159
|
-
prev.name === next.name &&
|
|
160
|
-
prev.size === next.size &&
|
|
161
|
-
prev.allowFontScaling === next.allowFontScaling &&
|
|
162
|
-
prev.style === next.style &&
|
|
163
|
-
shallowEqualColor(prev.color, next.color)
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
Icon.displayName = `NanoIcon(${fontBasename})`;
|
|
167
|
-
|
|
168
|
-
const IconComp = Icon as unknown as IconComponent<GM>;
|
|
169
|
-
IconComp.loadFont = (override) =>
|
|
170
|
-
glyphMap.m.l === 'd'
|
|
171
|
-
? loadDynamicFont(fontBasename, override ?? font, { force: true })
|
|
172
|
-
: Promise.resolve();
|
|
173
|
-
return IconComp;
|
|
174
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { NanoGlyphMapInput } from './core/types';
|
|
2
|
-
import type { IconComponent } from './types';
|
|
3
|
-
import { createJSIconSet } from './createNanoIconsSet.shared';
|
|
4
|
-
|
|
5
|
-
export type { IconComponent, IconProps } from './types';
|
|
6
|
-
export { shallowEqualColor } from './utils/shallowEqualColor';
|
|
7
|
-
|
|
8
|
-
export function createIconSet<GM extends NanoGlyphMapInput>(
|
|
9
|
-
glyphMap: GM
|
|
10
|
-
): IconComponent<GM>;
|
|
11
|
-
export function createIconSet<GM extends NanoGlyphMapInput>(
|
|
12
|
-
glyphMap: GM,
|
|
13
|
-
font: unknown
|
|
14
|
-
): IconComponent<GM>;
|
|
15
|
-
export function createIconSet<GM extends NanoGlyphMapInput>(
|
|
16
|
-
glyphMap: GM,
|
|
17
|
-
font?: unknown
|
|
18
|
-
): IconComponent<GM> {
|
|
19
|
-
return createJSIconSet(glyphMap, font);
|
|
20
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { memo, useMemo, type CSSProperties } from 'react';
|
|
2
|
-
import type { NanoGlyphMapInput } from './core/types';
|
|
3
|
-
import type { IconComponent, IconProps } from './types';
|
|
4
|
-
import { shallowEqualColor } from './utils/shallowEqualColor';
|
|
5
|
-
import {
|
|
6
|
-
DEFAULT_ICON_SIZE,
|
|
7
|
-
resolveGlyphEntry,
|
|
8
|
-
createCharCache,
|
|
9
|
-
createLayerColorResolver,
|
|
10
|
-
} from './utils/glyphRuntime';
|
|
11
|
-
|
|
12
|
-
export type { IconComponent, IconProps };
|
|
13
|
-
export { shallowEqualColor };
|
|
14
|
-
|
|
15
|
-
// Web renderer: uses inline <span> elements so icons flow out of the box (display: inline-block keeps width/height)
|
|
16
|
-
export function createIconSet<GM extends NanoGlyphMapInput>(
|
|
17
|
-
glyphMap: GM
|
|
18
|
-
): IconComponent<GM> {
|
|
19
|
-
const fontBasename = glyphMap.m.f;
|
|
20
|
-
const unitsPerEm = glyphMap.m.u;
|
|
21
|
-
const getChar = createCharCache();
|
|
22
|
-
|
|
23
|
-
const Icon = memo(
|
|
24
|
-
({
|
|
25
|
-
name,
|
|
26
|
-
size = DEFAULT_ICON_SIZE,
|
|
27
|
-
color,
|
|
28
|
-
style,
|
|
29
|
-
accessible,
|
|
30
|
-
accessibilityLabel,
|
|
31
|
-
accessibilityRole = 'image',
|
|
32
|
-
accessibilityElementsHidden,
|
|
33
|
-
testID,
|
|
34
|
-
ref,
|
|
35
|
-
}: IconProps<keyof GM['i']>) => {
|
|
36
|
-
const [adv, layers] = resolveGlyphEntry(glyphMap, name);
|
|
37
|
-
const width = (adv / unitsPerEm) * size;
|
|
38
|
-
|
|
39
|
-
const resolveColor = createLayerColorResolver(color);
|
|
40
|
-
|
|
41
|
-
const containerStyle = useMemo<CSSProperties>(
|
|
42
|
-
() => ({
|
|
43
|
-
display: 'inline-block',
|
|
44
|
-
position: 'relative',
|
|
45
|
-
width,
|
|
46
|
-
height: size,
|
|
47
|
-
lineHeight: 0,
|
|
48
|
-
verticalAlign: 'middle',
|
|
49
|
-
...(style as CSSProperties | undefined),
|
|
50
|
-
}),
|
|
51
|
-
[size, width, style]
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const layerBaseStyle = useMemo<CSSProperties>(
|
|
55
|
-
() => ({
|
|
56
|
-
position: 'absolute',
|
|
57
|
-
left: 0,
|
|
58
|
-
bottom: 0,
|
|
59
|
-
fontFamily: fontBasename,
|
|
60
|
-
fontWeight: 'normal',
|
|
61
|
-
fontStyle: 'normal',
|
|
62
|
-
fontSize: size,
|
|
63
|
-
lineHeight: 1,
|
|
64
|
-
whiteSpace: 'pre',
|
|
65
|
-
}),
|
|
66
|
-
[size]
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const isHidden = accessible === false || accessibilityElementsHidden;
|
|
70
|
-
const role = accessibilityRole === 'image' ? 'img' : accessibilityRole;
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<span
|
|
74
|
-
ref={ref as React.Ref<HTMLSpanElement>}
|
|
75
|
-
style={containerStyle}
|
|
76
|
-
role={isHidden ? undefined : role}
|
|
77
|
-
aria-label={
|
|
78
|
-
isHidden ? undefined : (accessibilityLabel ?? (name as string))
|
|
79
|
-
}
|
|
80
|
-
aria-hidden={isHidden || undefined}
|
|
81
|
-
data-testid={testID}>
|
|
82
|
-
{layers.map(([codepoint, srcColor], i) => {
|
|
83
|
-
const layerColor = resolveColor(i, srcColor);
|
|
84
|
-
return (
|
|
85
|
-
<span
|
|
86
|
-
key={i}
|
|
87
|
-
aria-hidden
|
|
88
|
-
style={{ ...layerBaseStyle, color: layerColor as string }}>
|
|
89
|
-
{getChar(codepoint)}
|
|
90
|
-
</span>
|
|
91
|
-
);
|
|
92
|
-
})}
|
|
93
|
-
</span>
|
|
94
|
-
);
|
|
95
|
-
},
|
|
96
|
-
(prev, next) =>
|
|
97
|
-
prev.name === next.name &&
|
|
98
|
-
prev.size === next.size &&
|
|
99
|
-
prev.style === next.style &&
|
|
100
|
-
shallowEqualColor(prev.color, next.color)
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
Icon.displayName = `NanoIcon(${fontBasename})`;
|
|
104
|
-
|
|
105
|
-
// No-op on web: fonts come from CSS @font-face, nothing to load at runtime.
|
|
106
|
-
const IconComp = Icon as unknown as IconComponent<GM>;
|
|
107
|
-
IconComp.loadFont = () => Promise.resolve();
|
|
108
|
-
return IconComp;
|
|
109
|
-
}
|
package/src/index.node.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
type CreateIconSetFn = (...args: unknown[]) => unknown;
|
|
2
|
-
type ConfigPluginFn = (...args: unknown[]) => unknown;
|
|
3
|
-
|
|
4
|
-
const createNanoIconSet = (...args: unknown[]) => {
|
|
5
|
-
const { createIconSet } = require('./createNanoIconsSet') as {
|
|
6
|
-
createIconSet: CreateIconSetFn;
|
|
7
|
-
};
|
|
8
|
-
return createIconSet(...args);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const plugin = (require('./plugin/src/index') as { default: ConfigPluginFn })
|
|
12
|
-
.default;
|
|
13
|
-
|
|
14
|
-
module.exports = Object.assign(plugin, { createNanoIconSet });
|