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,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import NanoIconsFontLoader from './nativeFontLoader';
|
|
4
|
+
import { configuredFontFamily } from "./utils/fontIdentity.js";
|
|
5
|
+
import { errorRuntime, LOG_PREFIX, warnRuntime } from "./utils/runtimeLog.js";
|
|
6
|
+
const checked = new Set();
|
|
7
|
+
const issues = new Map();
|
|
8
|
+
const listeners = new Set();
|
|
9
|
+
let staleBinaryReported = false;
|
|
10
|
+
function hasNativeCheck() {
|
|
11
|
+
return typeof NanoIconsFontLoader?.isFontRegistered === 'function';
|
|
12
|
+
}
|
|
13
|
+
export function isFontRegistered(family) {
|
|
14
|
+
if (!NanoIconsFontLoader || !hasNativeCheck()) return Promise.resolve(false);
|
|
15
|
+
return NanoIconsFontLoader.isFontRegistered(family);
|
|
16
|
+
}
|
|
17
|
+
export async function checkFontIntegrity(family, linking) {
|
|
18
|
+
if (!NanoIconsFontLoader || checked.has(family)) return;
|
|
19
|
+
checked.add(family);
|
|
20
|
+
if (!hasNativeCheck()) {
|
|
21
|
+
if (!staleBinaryReported) {
|
|
22
|
+
staleBinaryReported = true;
|
|
23
|
+
errorRuntime('The app binary was built with an older version of react-native-nano-icons. Rebuild the app.');
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (await isFontRegistered(family)) return;
|
|
28
|
+
recordIssue(family, linking, `Icon font "${configuredFontFamily(family)}" is missing or out of date, so its icons will render blank. ` + 'Regenerate the icon fonts with the react-native-nano-icons CLI.');
|
|
29
|
+
}
|
|
30
|
+
export const FONT_MISMATCH_CODE = 'E_NANOICONS_FONT_MISMATCH';
|
|
31
|
+
export function isFontMismatch(err) {
|
|
32
|
+
return err?.code === FONT_MISMATCH_CODE;
|
|
33
|
+
}
|
|
34
|
+
export const FONT_SOURCE_CODE = 'E_NANOICONS_FONT_SOURCE';
|
|
35
|
+
function isFontSourceError(err) {
|
|
36
|
+
return err?.code === FONT_SOURCE_CODE;
|
|
37
|
+
}
|
|
38
|
+
export function reportFontMismatch(family, linking) {
|
|
39
|
+
recordIssue(family, linking, `Icon font "${configuredFontFamily(family)}" does not match its glyphmap, so its icons will render blank. ` + 'Regenerate the icon fonts with the react-native-nano-icons CLI and deliver the .ttf together with its .glyphmap.json.');
|
|
40
|
+
}
|
|
41
|
+
export function reportMissingDynamicFont(family) {
|
|
42
|
+
return reportDynamicFontIssue(family, `Icon font "${configuredFontFamily(family)}" is built with dynamic linking but no font was passed to createNanoIconSet, ` + 'so its icons will render blank until a font is registered under the family name in glyphMap.m.f.');
|
|
43
|
+
}
|
|
44
|
+
export function reportDynamicFontLoadFailure(family, cause) {
|
|
45
|
+
const name = configuredFontFamily(family);
|
|
46
|
+
const message = isFontSourceError(cause) ? `Icon font "${name}" has no usable font source, so its icons will render blank. ` + `Pass require("${name}.ttf") or { uri } to createNanoIconSet.` : `Icon font "${name}" could not be loaded: ${describeCause(cause)} Its icons will render blank. ` + 'Make sure the .ttf is delivered with your update.';
|
|
47
|
+
return reportDynamicFontIssue(family, message, cause);
|
|
48
|
+
}
|
|
49
|
+
function describeCause(cause) {
|
|
50
|
+
const text = (cause instanceof Error ? cause.message : String(cause)).replace(`${LOG_PREFIX} ✖ `, '');
|
|
51
|
+
return /[.!?]$/.test(text) ? text : `${text}.`;
|
|
52
|
+
}
|
|
53
|
+
async function reportDynamicFontIssue(family, message, cause) {
|
|
54
|
+
if (await isFontRegistered(family)) return;
|
|
55
|
+
if (NanoIconsFontLoader) {
|
|
56
|
+
recordIssue(family, 'dynamic', message, cause);
|
|
57
|
+
} else if (__DEV__) {
|
|
58
|
+
warnRuntime(message, ...causeDetail(cause));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function causeDetail(cause) {
|
|
62
|
+
return cause === undefined ? [] : [cause];
|
|
63
|
+
}
|
|
64
|
+
function recordIssue(family, linking, message, cause) {
|
|
65
|
+
const issue = {
|
|
66
|
+
fontFamily: configuredFontFamily(family),
|
|
67
|
+
family,
|
|
68
|
+
linking,
|
|
69
|
+
message,
|
|
70
|
+
...(cause === undefined ? {} : {
|
|
71
|
+
cause
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
issues.set(family, issue);
|
|
75
|
+
if (__DEV__) warnRuntime(message, ...causeDetail(cause));
|
|
76
|
+
for (const listener of listeners) listener(issue, 'found');
|
|
77
|
+
}
|
|
78
|
+
export function resolveFontIssue(family) {
|
|
79
|
+
const issue = issues.get(family);
|
|
80
|
+
if (!issue) return;
|
|
81
|
+
issues.delete(family);
|
|
82
|
+
for (const listener of listeners) listener(issue, 'resolved');
|
|
83
|
+
}
|
|
84
|
+
export function addFontIntegrityListener(listener) {
|
|
85
|
+
listeners.add(listener);
|
|
86
|
+
for (const issue of issues.values()) listener(issue, 'found');
|
|
87
|
+
return () => {
|
|
88
|
+
listeners.delete(listener);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function getFontIntegrityIssues() {
|
|
92
|
+
return [...issues.values()];
|
|
93
|
+
}
|
|
94
|
+
export function __resetFontIntegrityForTests() {
|
|
95
|
+
staleBinaryReported = false;
|
|
96
|
+
checked.clear();
|
|
97
|
+
issues.clear();
|
|
98
|
+
listeners.clear();
|
|
99
|
+
}
|
package/lib/module/index.js
CHANGED
package/lib/module/index.node.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { useSyncExternalStore } from 'react';
|
|
4
4
|
import { Image, Platform } from 'react-native';
|
|
5
|
-
import
|
|
5
|
+
import { FONT_SOURCE_CODE, resolveFontIssue } from "./fontIntegrity.js";
|
|
6
|
+
import NanoIconsFontLoader from './nativeFontLoader';
|
|
7
|
+
import { runtimeError } from "./utils/runtimeLog.js";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Runtime registration of dynamically-linked (`l:"d"`) fonts.
|
|
@@ -24,11 +26,16 @@ export function getFontStatus(family) {
|
|
|
24
26
|
|
|
25
27
|
/** A font source: a require()'d module, an { uri }, or a path/uri string. */
|
|
26
28
|
|
|
29
|
+
function fontSourceError(message) {
|
|
30
|
+
return Object.assign(runtimeError(message), {
|
|
31
|
+
code: FONT_SOURCE_CODE
|
|
32
|
+
});
|
|
33
|
+
}
|
|
27
34
|
export function resolveFontUri(font) {
|
|
28
35
|
if (typeof font === 'number') {
|
|
29
36
|
const source = Image.resolveAssetSource(font);
|
|
30
37
|
if (!source?.uri) {
|
|
31
|
-
throw
|
|
38
|
+
throw fontSourceError('Could not resolve the font asset to a uri.');
|
|
32
39
|
}
|
|
33
40
|
return source.uri;
|
|
34
41
|
}
|
|
@@ -36,7 +43,7 @@ export function resolveFontUri(font) {
|
|
|
36
43
|
if (font != null && typeof font === 'object' && typeof font.uri === 'string') {
|
|
37
44
|
return font.uri;
|
|
38
45
|
}
|
|
39
|
-
throw
|
|
46
|
+
throw fontSourceError('Unsupported font source. Pass require("Foo.ttf"), { uri }, or a path string.');
|
|
40
47
|
}
|
|
41
48
|
async function register(family, uri) {
|
|
42
49
|
if (Platform.OS === 'web') {
|
|
@@ -44,7 +51,7 @@ async function register(family, uri) {
|
|
|
44
51
|
// lib config and a DOM-aware app config without depending on the DOM lib.
|
|
45
52
|
const g = globalThis;
|
|
46
53
|
if (!g.FontFace || !g.document?.fonts) {
|
|
47
|
-
throw
|
|
54
|
+
throw runtimeError('FontFace API unavailable; cannot load dynamic font on this platform.');
|
|
48
55
|
}
|
|
49
56
|
const face = new g.FontFace(family, `url(${uri})`);
|
|
50
57
|
await face.load();
|
|
@@ -52,7 +59,7 @@ async function register(family, uri) {
|
|
|
52
59
|
return;
|
|
53
60
|
}
|
|
54
61
|
if (!NanoIconsFontLoader) {
|
|
55
|
-
throw
|
|
62
|
+
throw runtimeError('Native font loader is unavailable (Expo Go or module not built). ' + 'Load the font yourself, or use a development/production build.');
|
|
56
63
|
}
|
|
57
64
|
await NanoIconsFontLoader.registerFont(family, uri);
|
|
58
65
|
}
|
|
@@ -76,6 +83,7 @@ export function loadDynamicFont(family, font, opts) {
|
|
|
76
83
|
try {
|
|
77
84
|
await register(family, resolveFontUri(font));
|
|
78
85
|
setStatus(family, 'ready');
|
|
86
|
+
resolveFontIssue(family);
|
|
79
87
|
} catch (err) {
|
|
80
88
|
setStatus(family, 'error');
|
|
81
89
|
throw err;
|
|
@@ -102,11 +110,14 @@ export function loadDynamicFont(family, font, opts) {
|
|
|
102
110
|
* errored, or not managed by us).
|
|
103
111
|
*/
|
|
104
112
|
export function useDynamicFontPending(managed, family) {
|
|
105
|
-
const status =
|
|
113
|
+
const status = useDynamicFontStatus(family);
|
|
114
|
+
return managed && status === 'loading';
|
|
115
|
+
}
|
|
116
|
+
export function useDynamicFontStatus(family) {
|
|
117
|
+
return useSyncExternalStore(cb => {
|
|
106
118
|
listeners.add(cb);
|
|
107
119
|
return () => listeners.delete(cb);
|
|
108
|
-
}, () =>
|
|
109
|
-
return managed && status === 'loading';
|
|
120
|
+
}, () => statusByFamily.get(family), () => undefined);
|
|
110
121
|
}
|
|
111
122
|
|
|
112
123
|
/** Test-only: reset module state between tests. */
|
|
@@ -114,5 +125,4 @@ export function __resetDynamicFontsForTests() {
|
|
|
114
125
|
statusByFamily.clear();
|
|
115
126
|
inFlight.clear();
|
|
116
127
|
listeners.clear();
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=loadDynamicFont.js.map
|
|
128
|
+
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { codegenNativeComponent } from 'react-native';
|
|
2
|
-
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { ColorValue, ViewProps } from 'react-native';
|
|
3
3
|
import type { Float, Int32 } from '../const/codegenPrimitives';
|
|
4
4
|
|
|
5
5
|
export interface NativeProps extends ViewProps {
|
|
6
6
|
fontFamily: string;
|
|
7
7
|
codepoints: ReadonlyArray<Int32>;
|
|
8
|
-
colors: ReadonlyArray<
|
|
9
|
-
|
|
8
|
+
colors: ReadonlyArray<ColorValue>;
|
|
9
|
+
color?: ColorValue;
|
|
10
|
+
tintLayers: ReadonlyArray<Int32>;
|
|
11
|
+
size: Float;
|
|
12
|
+
allowFontScaling: boolean;
|
|
10
13
|
advanceWidth: Int32;
|
|
11
14
|
unitsPerEm: Int32;
|
|
12
|
-
iconWidth: Float;
|
|
13
|
-
iconHeight: Float;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export default codegenNativeComponent<NativeProps>('NanoIconView'
|
|
17
|
+
export default codegenNativeComponent<NativeProps>('NanoIconView', {
|
|
18
|
+
interfaceOnly: true,
|
|
19
|
+
});
|
|
@@ -3,5 +3,4 @@
|
|
|
3
3
|
import { TurboModuleRegistry } from 'react-native';
|
|
4
4
|
// `get` (not `getEnforcing`) so the absence of the native module (web, Expo Go,
|
|
5
5
|
// module not built) returns null and the caller can degrade gracefully.
|
|
6
|
-
export default TurboModuleRegistry.get('NanoIconsFontLoader');
|
|
7
|
-
//# sourceMappingURL=NativeNanoIconsFontLoader.js.map
|
|
6
|
+
export default TurboModuleRegistry.get('NanoIconsFontLoader');
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { toDrawableResourceName, toOriginalDrawableResourceName } from "../utils/naming.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Augmentable registry of forged icon names. The build emits a `.d.ts` per symbol
|
|
7
|
+
* set that augments this interface, so `nativeNanoSymbol()` accepts that set's SVG
|
|
8
|
+
* filenames (and autocompletes them) with no explicit generic.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Accepted icon names — the augmented union, or any string until a set is generated. */
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a forged icon (by its SVG filename) to a native tab-bar descriptor.
|
|
15
|
+
*
|
|
16
|
+
* iOS — the asset is referenced by its asset-catalog name via the `sfSymbol`
|
|
17
|
+
* path. Every forged symbol carries both rendering modes; `renderingMode`
|
|
18
|
+
* picks one: `monochrome` (bar tint, default) or `original` (the SVG's own
|
|
19
|
+
* colors — Apple's "multicolor" symbol rendering).
|
|
20
|
+
*
|
|
21
|
+
* Android — the drawable resource name is derived from `${prefix}.${name}` with
|
|
22
|
+
* the same pure transform the build uses. Each icon ships two drawables;
|
|
23
|
+
* `renderingMode` picks the solid silhouette the bar tints (`monochrome`) or
|
|
24
|
+
* the untinted drawable that keeps its own colors (`original`, `_original`
|
|
25
|
+
* suffix), forwarded as react-navigation's `tinted`.
|
|
26
|
+
*
|
|
27
|
+
* tabBarIcon: () => nativeNanoSymbol('home')
|
|
28
|
+
* // tints only when unfocused, keeps the icon's own colors while focused
|
|
29
|
+
* tabBarIcon: ({ focused }) =>
|
|
30
|
+
* nativeNanoSymbol('home', focused ? 'original' : 'monochrome')
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export function nativeNanoSymbol(name, renderingMode = 'monochrome', prefix = 'nano') {
|
|
34
|
+
const resourceName = toDrawableResourceName(`${prefix}.${name}`);
|
|
35
|
+
return {
|
|
36
|
+
type: 'image',
|
|
37
|
+
source: {
|
|
38
|
+
uri: renderingMode === 'original' ? toOriginalDrawableResourceName(resourceName) : resourceName
|
|
39
|
+
},
|
|
40
|
+
tinted: renderingMode === 'monochrome'
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Augmentable registry of forged icon names. The build emits a `.d.ts` per symbol
|
|
5
|
+
* set that augments this interface, so `nativeNanoSymbol()` accepts that set's SVG
|
|
6
|
+
* filenames (and autocompletes them) with no explicit generic.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Accepted icon names — the augmented union, or any string until a set is generated. */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolve a forged icon (by its SVG filename) to a native tab-bar descriptor.
|
|
13
|
+
*
|
|
14
|
+
* iOS — the asset is referenced by its asset-catalog name via the `sfSymbol`
|
|
15
|
+
* path. Every forged symbol carries both rendering modes; `renderingMode`
|
|
16
|
+
* picks one: `monochrome` (bar tint, default) or `original` (the SVG's own
|
|
17
|
+
* colors — Apple's "multicolor" symbol rendering).
|
|
18
|
+
*
|
|
19
|
+
* Android — the drawable resource name is derived from `${prefix}.${name}` with
|
|
20
|
+
* the same pure transform the build uses. `renderingMode` controls whether the
|
|
21
|
+
* bar recolors the drawable (`monochrome`) or keeps its own colors (`original`).
|
|
22
|
+
*
|
|
23
|
+
* tabBarIcon: () => nativeNanoSymbol('home')
|
|
24
|
+
* // tints only when unfocused, keeps the icon's own colors while focused
|
|
25
|
+
* tabBarIcon: ({ focused }) =>
|
|
26
|
+
* nativeNanoSymbol('home', focused ? 'original' : 'monochrome')
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export function nativeNanoSymbol(name, renderingMode = 'monochrome', prefix = 'nano') {
|
|
30
|
+
return {
|
|
31
|
+
type: 'sfSymbol',
|
|
32
|
+
name: `${prefix}.${name}`,
|
|
33
|
+
renderingMode
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Augmentable registry of forged icon names. The build emits a `.d.ts` per symbol
|
|
5
|
+
* set that augments this interface, so `nativeNanoSymbol()` accepts that set's SVG
|
|
6
|
+
* filenames (and autocompletes them) with no explicit generic.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Accepted icon names — the augmented union, or any string until a set is generated. */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolve a forged icon (by its SVG filename) to a native tab-bar descriptor.
|
|
13
|
+
*
|
|
14
|
+
* iOS — the asset is referenced by its asset-catalog name via the `sfSymbol`
|
|
15
|
+
* path. Every forged symbol carries both rendering modes; `renderingMode`
|
|
16
|
+
* picks one: `monochrome` (bar tint, default) or `original` (the SVG's own
|
|
17
|
+
* colors — Apple's "multicolor" symbol rendering).
|
|
18
|
+
*
|
|
19
|
+
* Android — the drawable resource name is derived from `${prefix}.${name}` with
|
|
20
|
+
* the same pure transform the build uses. `renderingMode` controls whether the
|
|
21
|
+
* bar recolors the drawable (`monochrome`) or keeps its own colors (`original`).
|
|
22
|
+
*
|
|
23
|
+
* tabBarIcon: () => nativeNanoSymbol('home')
|
|
24
|
+
* // tints only when unfocused, keeps the icon's own colors while focused
|
|
25
|
+
* tabBarIcon: ({ focused }) =>
|
|
26
|
+
* nativeNanoSymbol('home', focused ? 'original' : 'monochrome')
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export function nativeNanoSymbol(name, renderingMode = 'monochrome', prefix = 'nano') {
|
|
30
|
+
return {
|
|
31
|
+
type: 'sfSymbol',
|
|
32
|
+
name: `${prefix}.${name}`,
|
|
33
|
+
renderingMode
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import { nativeNanoSymbol as androidNanoSymbol } from "./index.android.js";
|
|
5
|
+
import { nativeNanoSymbol as iosNanoSymbol } from "./index.ios.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Runtime platform split for React Native. Metro resolves package `exports`
|
|
9
|
+
* targets verbatim — it never expands `.ios`/`.android` for them — so the
|
|
10
|
+
* filename-based split the source uses cannot survive the `exports` map.
|
|
11
|
+
*/
|
|
12
|
+
export const nativeNanoSymbol = Platform.OS === 'android' ? androidNanoSymbol : iosNanoSymbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/lib/module/types.js
CHANGED
|
@@ -3,15 +3,30 @@
|
|
|
3
3
|
const crypto = require('crypto');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const path = require('path');
|
|
6
|
-
export function getFingerprintSync(dir) {
|
|
6
|
+
export function getFingerprintSync(dir, inputs) {
|
|
7
|
+
return fingerprintSvgDirSync(dir, inputs).hash;
|
|
8
|
+
}
|
|
9
|
+
export function fingerprintSvgDirSync(dir, inputs) {
|
|
10
|
+
return hashSvgDir(dir, [inputs.upm, inputs.safeZone, inputs.startUnicode, inputs.version, inputs.toolchain]);
|
|
11
|
+
}
|
|
12
|
+
export function fingerprintSymbolDirSync(dir, inputs) {
|
|
13
|
+
return hashSvgDir(dir, ['symbol', inputs.prefix, inputs.version, inputs.toolchain]);
|
|
14
|
+
}
|
|
15
|
+
function hashSvgDir(dir, settings) {
|
|
7
16
|
const files = fs.readdirSync(dir).filter(f => f.endsWith('.svg')).sort();
|
|
8
17
|
const hash = crypto.createHash('sha256');
|
|
18
|
+
const svgHashByFile = new Map();
|
|
9
19
|
for (const file of files) {
|
|
10
20
|
const filePath = path.join(dir, file);
|
|
21
|
+
const content = fs.readFileSync(filePath);
|
|
11
22
|
// Hash both path and content
|
|
12
23
|
hash.update(file);
|
|
13
|
-
hash.update(
|
|
24
|
+
hash.update(content);
|
|
25
|
+
svgHashByFile.set(file, crypto.createHash('sha256').update(content).digest('hex'));
|
|
14
26
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
hash.update(JSON.stringify(settings));
|
|
28
|
+
return {
|
|
29
|
+
hash: hash.digest('hex'),
|
|
30
|
+
svgHashByFile
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const BUILD_HASH_LENGTH = 8;
|
|
4
|
+
const BUILD_HASH = `[0-9a-f]{${BUILD_HASH_LENGTH}}`;
|
|
5
|
+
const BUILD_SUFFIX = new RegExp(`-${BUILD_HASH}$`);
|
|
6
|
+
const BUILD_FONT_FILE = new RegExp(`-${BUILD_HASH}\\.ttf$`);
|
|
7
|
+
const REGEX_SPECIALS = /[.*+?^${}()|[\]\\]/g;
|
|
8
|
+
export function buildFontFamily(fontFamily, inputHash) {
|
|
9
|
+
return `${fontFamily}-${inputHash.slice(0, BUILD_HASH_LENGTH)}`;
|
|
10
|
+
}
|
|
11
|
+
export function configuredFontFamily(family) {
|
|
12
|
+
return family.replace(BUILD_SUFFIX, '');
|
|
13
|
+
}
|
|
14
|
+
export function isFontFileOf(fontFamily, fileName) {
|
|
15
|
+
const escaped = fontFamily.replace(REGEX_SPECIALS, '\\$&');
|
|
16
|
+
return new RegExp(`^${escaped}(-${BUILD_HASH})?\\.ttf$`).test(fileName);
|
|
17
|
+
}
|
|
18
|
+
export function isBuildFontFile(fileName) {
|
|
19
|
+
return BUILD_FONT_FILE.test(fileName);
|
|
20
|
+
}
|
|
@@ -29,9 +29,42 @@ export function createCharCache() {
|
|
|
29
29
|
* color wins, else the last supplied palette color spills onto remaining
|
|
30
30
|
* layers, else the glyph's own source color, else black.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
export function createLayerColorResolver(color, tintMode = 'all', layers = []) {
|
|
33
34
|
const colorArray = Array.isArray(color) ? color : [color];
|
|
34
35
|
const lastPaletteColor = colorArray[colorArray.length - 1];
|
|
35
|
-
|
|
36
|
+
const paletteIndexByLayer = tintMode === 'currentColor' ? currentColorPositions(layers) : undefined;
|
|
37
|
+
return (index, srcColor) => {
|
|
38
|
+
const paletteIndex = paletteIndexByLayer ? paletteIndexByLayer[index] ?? -1 : index;
|
|
39
|
+
const paletteColor = paletteIndex < 0 ? undefined : colorArray[paletteIndex] ?? lastPaletteColor;
|
|
40
|
+
return paletteColor ?? srcColor ?? 'black';
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function tintableLayers(layers, tintMode = 'all') {
|
|
44
|
+
if (tintMode === 'all') return allLayerIndices(layers);
|
|
45
|
+
const positions = currentColorPositions(layers);
|
|
46
|
+
const indices = [];
|
|
47
|
+
for (let i = 0; i < positions.length; i++) {
|
|
48
|
+
if (positions[i] >= 0) indices.push(i);
|
|
49
|
+
}
|
|
50
|
+
return indices;
|
|
51
|
+
}
|
|
52
|
+
const allIndicesByLayers = new WeakMap();
|
|
53
|
+
function allLayerIndices(layers) {
|
|
54
|
+
let indices = allIndicesByLayers.get(layers);
|
|
55
|
+
if (!indices) {
|
|
56
|
+
indices = layers.map((_, i) => i);
|
|
57
|
+
allIndicesByLayers.set(layers, indices);
|
|
58
|
+
}
|
|
59
|
+
return indices;
|
|
36
60
|
}
|
|
37
|
-
|
|
61
|
+
const positionsByLayers = new WeakMap();
|
|
62
|
+
function currentColorPositions(layers) {
|
|
63
|
+
let positions = positionsByLayers.get(layers);
|
|
64
|
+
if (!positions) {
|
|
65
|
+
let next = 0;
|
|
66
|
+
positions = layers.map(([, srcColor]) => srcColor === 'currentColor' ? next++ : -1);
|
|
67
|
+
positionsByLayers.set(layers, positions);
|
|
68
|
+
}
|
|
69
|
+
return positions;
|
|
70
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Shared regexes + helpers for sanitizing asset/symbol names into valid
|
|
4
|
+
// Android resource ids and TypeScript manifest identifiers.
|
|
5
|
+
|
|
6
|
+
/** Chars illegal in an Android drawable resource name → `_`. */
|
|
7
|
+
const NON_RESOURCE_CHARS = /[^a-z0-9_]+/g;
|
|
8
|
+
/** Leading/trailing underscores to trim. */
|
|
9
|
+
const EDGE_UNDERSCORES = /^_+|_+$/g;
|
|
10
|
+
/** Resource names must start with a lowercase letter. */
|
|
11
|
+
const STARTS_WITH_LOWER = /^[a-z]/;
|
|
12
|
+
/** Word separators in a set name (split → PascalCase parts). */
|
|
13
|
+
const NAME_SEPARATORS = /[^a-zA-Z0-9]+/;
|
|
14
|
+
/** Manifest identifiers must start with a letter. */
|
|
15
|
+
const STARTS_WITH_LETTER = /^[a-zA-Z]/;
|
|
16
|
+
|
|
17
|
+
/** Prefix used when a sanitized name would be empty or start with a non-letter. */
|
|
18
|
+
const RESOURCE_FALLBACK_PREFIX = 'nano_';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Resource names must match `[a-z][a-z0-9_]*` — no dots/uppercase.
|
|
22
|
+
* `nano.home` → `nano_home`, `nano.person-walking` → `nano_person_walking`.
|
|
23
|
+
*/
|
|
24
|
+
export function toDrawableResourceName(assetName) {
|
|
25
|
+
let name = assetName.toLowerCase().replace(NON_RESOURCE_CHARS, '_');
|
|
26
|
+
name = name.replace(EDGE_UNDERSCORES, '');
|
|
27
|
+
if (name === '' || !STARTS_WITH_LOWER.test(name)) {
|
|
28
|
+
name = `${RESOURCE_FALLBACK_PREFIX}${name}`;
|
|
29
|
+
}
|
|
30
|
+
return name;
|
|
31
|
+
}
|
|
32
|
+
const ORIGINAL_DRAWABLE_SUFFIX = '_original';
|
|
33
|
+
export function toOriginalDrawableResourceName(resourceName) {
|
|
34
|
+
return `${resourceName}${ORIGINAL_DRAWABLE_SUFFIX}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** "my-tab icons" → "MyTabIcons" — PascalCase base for manifest identifiers. */
|
|
38
|
+
export function manifestBaseName(setName) {
|
|
39
|
+
const pascal = setName.split(NAME_SEPARATORS).filter(Boolean).map(part => part[0].toUpperCase() + part.slice(1)).join('');
|
|
40
|
+
return STARTS_WITH_LETTER.test(pascal) ? pascal : `Set${pascal}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Manifest export name, e.g. `MyTabIconsSymbols` / `MyTabIconsDrawables`. */
|
|
44
|
+
export function manifestExportName(setName, suffix = 'Symbols') {
|
|
45
|
+
return `${manifestBaseName(setName)}${suffix}`;
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const PACKAGE_NAME = 'react-native-nano-icons';
|
|
6
|
+
const FONT_TOOLCHAIN = ['@xmldom/xmldom', 'cubic2quad', 'fonteditor-core', 'pathkit-wasm', 'svg2ttf'];
|
|
7
|
+
export function packageVersion() {
|
|
8
|
+
return installedVersion(PACKAGE_NAME, __dirname);
|
|
9
|
+
}
|
|
10
|
+
export function fontToolchainVersions() {
|
|
11
|
+
return FONT_TOOLCHAIN.map(name => `${name}@${installedVersion(name, path.dirname(require.resolve(name)))}`);
|
|
12
|
+
}
|
|
13
|
+
function installedVersion(name, fromDir) {
|
|
14
|
+
let dir = fromDir;
|
|
15
|
+
for (;;) {
|
|
16
|
+
const manifest = path.join(dir, 'package.json');
|
|
17
|
+
if (fs.existsSync(manifest)) {
|
|
18
|
+
const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
|
|
19
|
+
if (pkg.name === name && typeof pkg.version === 'string') {
|
|
20
|
+
return pkg.version;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const parent = path.dirname(dir);
|
|
24
|
+
if (parent === dir) {
|
|
25
|
+
throw new Error(`Could not locate the ${name} package.json`);
|
|
26
|
+
}
|
|
27
|
+
dir = parent;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { CSS_NAMED_COLORS } from "../const/colors.js";
|
|
4
4
|
|
|
5
|
-
// e.g. u0041.svg -> 65
|
|
6
|
-
export function parseCodepointFromFilename(filename) {
|
|
7
|
-
const m = /^u([0-9a-fA-F]+)\.svg$/.exec(filename);
|
|
8
|
-
if (!m) throw new Error(`Unexpected glyph filename: ${filename}`);
|
|
9
|
-
return parseInt(m[1], 16);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
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.
|
|
13
6
|
export function parseColor(color) {
|
|
14
7
|
const c = color.trim();
|
|
@@ -49,5 +42,4 @@ export function parseColor(color) {
|
|
|
49
42
|
|
|
50
43
|
// unknown — SVG default is opaque black
|
|
51
44
|
return [0, 0, 0, 1];
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=parse.js.map
|
|
45
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const LOG_PREFIX = '🔬 react-native-nano-icons';
|
|
4
|
+
export function warnRuntime(message, ...rest) {
|
|
5
|
+
console.warn(`${LOG_PREFIX} ⚠ ${message}`, ...rest);
|
|
6
|
+
}
|
|
7
|
+
export function errorRuntime(message) {
|
|
8
|
+
console.error(`${LOG_PREFIX} ✖ ${message}`);
|
|
9
|
+
}
|
|
10
|
+
export function runtimeError(message) {
|
|
11
|
+
return new Error(`${LOG_PREFIX} ✖ ${message}`);
|
|
12
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Regexes for parsing/validating SVG path data and XML markup.
|
|
4
|
+
|
|
5
|
+
// --- SVG path data ---
|
|
6
|
+
/** Path already starts with a moveto. */
|
|
7
|
+
export const SVG_MOVE_PREFIX = /^[Mm]/;
|
|
8
|
+
/** Trailing close-path command (+ optional whitespace). */
|
|
9
|
+
export const SVG_TRAILING_CLOSE = /[Zz]\s*$/;
|
|
10
|
+
/** A signed int/float token. */
|
|
11
|
+
export const SVG_NUMBER = /-?\d+(?:\.\d+)?/g;
|
|
12
|
+
/** Whitespace separator (e.g. viewBox parts). */
|
|
13
|
+
export const WHITESPACE = /\s+/;
|
|
14
|
+
|
|
15
|
+
// --- SVG/XML validation ---
|
|
16
|
+
/** `<mask …>` element (unsupported). */
|
|
17
|
+
export const XML_MASK = /<mask[\s>]/i;
|
|
18
|
+
/** `<filter …>` element (unsupported). */
|
|
19
|
+
export const XML_FILTER = /<filter[\s>]/i;
|
|
20
|
+
/** `<image …>` element (unsupported). */
|
|
21
|
+
export const XML_IMAGE = /<image[\s>]/i;
|
|
22
|
+
/** An `xmlns=` attribute. */
|
|
23
|
+
export const XML_XMLNS = /xmlns\s*=/;
|
|
24
|
+
/** Opening `<svg` tag. */
|
|
25
|
+
export const SVG_OPEN_TAG = /<svg\b/;
|
|
26
|
+
export const PX_ATTRIBUTE_VALUE = /=(["'])(\s*-?(?:\d+\.?\d*|\.\d+))px\s*\1/g;
|
|
27
|
+
export const PX_STYLE_VALUE = /(:\s*-?(?:\d+\.?\d*|\.\d+))px(?=\s*(?:;|["']|$))/g;
|
|
28
|
+
|
|
29
|
+
// --- SVG attribute value separators ---
|
|
30
|
+
/** viewBox: comma or whitespace separated. */
|
|
31
|
+
export const VIEWBOX_SEPARATOR = /,|\s+/;
|
|
32
|
+
/** transform() arguments: comma and/or whitespace separated. */
|
|
33
|
+
export const TRANSFORM_ARG_SEPARATOR = /\s*[,\s]\s*/;
|
|
34
|
+
/** stroke-dasharray: single comma or space separated. */
|
|
35
|
+
export const DASHARRAY_SEPARATOR = /[, ]/;
|
|
36
|
+
/** One transform function call, e.g. `rotate(30)`; captures name and args. */
|
|
37
|
+
export const TRANSFORM_FUNCTION = /(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/gi;
|
|
38
|
+
/** `url(#id)` reference; captures the id. */
|
|
39
|
+
export const URL_ID_REFERENCE = /^url[(]#([\w-]+)[)]$/;
|
|
40
|
+
/** A well-formed XML attribute name. */
|
|
41
|
+
export const XML_ATTRIBUTE_NAME = /^[A-Za-z_][\w.-]*$/;
|
|
42
|
+
|
|
43
|
+
// --- XML escaping / font emit ---
|
|
44
|
+
export const XML_AMP = /&/g;
|
|
45
|
+
export const XML_LT = /</g;
|
|
46
|
+
export const XML_GT = />/g;
|
|
47
|
+
export const XML_QUOT = /"/g;
|
|
48
|
+
/** svg2ttf error `glyph "u<hex>"` → captures the hex codepoint. */
|
|
49
|
+
export const GLYPH_CODEPOINT = /glyph\s+"u([0-9a-fA-F]+)"/;
|