react-native-nano-icons 0.2.0 → 1.0.0-beta.1
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 +41 -10
- package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +31 -0
- package/android/src/main/java/com/nanoicons/NanoIconView.kt +50 -15
- package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +78 -12
- package/ios/NanoIconFontResolver.h +5 -0
- package/ios/NanoIconFontResolver.mm +32 -0
- package/ios/NanoIconView.h +0 -4
- package/ios/NanoIconView.mm +62 -57
- package/ios/NanoIconsFontLoader.mm +10 -32
- package/lib/commonjs/cli/build.d.ts +11 -3
- package/lib/commonjs/cli/build.js +86 -25
- package/lib/commonjs/cli/config.d.ts +1 -1
- package/lib/commonjs/cli/config.js +1 -1
- package/lib/commonjs/cli/expoConfig.d.ts +3 -2
- package/lib/commonjs/cli/expoConfig.js +22 -9
- package/lib/commonjs/cli/index.d.ts +5 -5
- package/lib/commonjs/cli/index.js +16 -14
- package/lib/commonjs/cli/link.d.ts +4 -3
- package/lib/commonjs/cli/link.js +127 -45
- package/lib/commonjs/cli/logger.js +9 -7
- package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -3
- package/lib/commonjs/plugin/src/buildFonts.js +5 -15
- package/lib/commonjs/plugin/src/index.d.ts +2 -2
- package/lib/commonjs/plugin/src/index.js +2 -2
- package/lib/commonjs/plugin/src/types.d.ts +10 -1
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +1 -1
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +6 -13
- package/lib/commonjs/scripts/cli.js +46 -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 +21 -7
- package/lib/commonjs/src/core/font/metrics.js +7 -0
- package/lib/commonjs/src/core/font/quadratic.d.ts +1 -0
- package/lib/commonjs/src/core/font/quadratic.js +31 -0
- package/lib/commonjs/src/core/glyph/merge.d.ts +7 -0
- package/lib/commonjs/src/core/glyph/merge.js +57 -0
- package/lib/commonjs/src/core/glyph/parse.d.ts +26 -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 +74 -0
- package/lib/commonjs/src/core/{svg/svg_pathops.js → pathkit/contours.js} +72 -312
- package/lib/commonjs/src/core/pathkit/evenodd.d.ts +12 -0
- package/lib/commonjs/src/core/pathkit/evenodd.js +51 -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/pipeline/config.d.ts +1 -0
- package/lib/commonjs/src/core/pipeline/iconPool.d.ts +3 -0
- package/lib/commonjs/src/core/pipeline/iconPool.js +51 -0
- package/lib/commonjs/src/core/pipeline/index.d.ts +3 -3
- package/lib/commonjs/src/core/pipeline/index.js +6 -5
- package/lib/commonjs/src/core/pipeline/prepare.d.ts +19 -0
- package/lib/commonjs/src/core/pipeline/prepare.js +56 -0
- package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +22 -0
- package/lib/commonjs/src/core/pipeline/prepareIcon.js +78 -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/{run.d.ts → runFontPipeline.d.ts} +7 -4
- package/lib/commonjs/src/core/pipeline/runFontPipeline.js +109 -0
- package/lib/commonjs/src/core/types.d.ts +3 -92
- package/lib/commonjs/src/utils/fingerPrint.d.ts +8 -1
- package/lib/commonjs/src/utils/fingerPrint.js +8 -1
- package/lib/commonjs/src/utils/fontIdentity.d.ts +4 -0
- package/lib/commonjs/src/utils/fontIdentity.js +24 -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 +11 -4
- package/lib/module/createNanoIconsSet.shared.js +12 -7
- package/lib/module/createNanoIconsSet.web.js +7 -5
- 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 +14 -7
- package/lib/module/nativeFontLoader.js +3 -0
- package/lib/module/nativeFontLoader.web.js +3 -0
- package/lib/module/specs/NativeNanoIconsFontLoader.js +1 -2
- package/lib/module/types.js +1 -2
- package/lib/module/utils/fingerPrint.js +3 -3
- package/lib/module/utils/fontIdentity.js +20 -0
- package/lib/module/utils/glyphRuntime.js +1 -2
- 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/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 +27 -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 +75 -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/types.d.ts +3 -92
- package/lib/typescript/src/fontIntegrity.d.ts +24 -0
- package/lib/typescript/src/index.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/NativeNanoIconsFontLoader.d.ts +1 -0
- package/lib/typescript/src/types.d.ts +5 -0
- package/lib/typescript/src/utils/fingerPrint.d.ts +8 -1
- package/lib/typescript/src/utils/fontIdentity.d.ts +5 -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/package.json +13 -11
- 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.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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
#import "NanoIconFontResolver.h"
|
|
1
2
|
#import "NanoIconsFontLoader.h"
|
|
2
|
-
#import "NanoIconView.h"
|
|
3
3
|
#import <CoreText/CoreText.h>
|
|
4
4
|
|
|
5
5
|
@implementation NanoIconsFontLoader
|
|
@@ -43,7 +43,7 @@ RCT_EXPORT_METHOD(registerFont:(NSString *)family
|
|
|
43
43
|
if (!nameMatches) {
|
|
44
44
|
CGFontRelease(cgFont);
|
|
45
45
|
reject(
|
|
46
|
-
@"
|
|
46
|
+
@"E_NANOICONS_FONT_MISMATCH",
|
|
47
47
|
[NSString stringWithFormat:
|
|
48
48
|
@"Font name \"%@\" does not match family \"%@\". "
|
|
49
49
|
@"On iOS the TTF PostScript/full name must equal glyphMap.m.f.",
|
|
@@ -54,51 +54,29 @@ RCT_EXPORT_METHOD(registerFont:(NSString *)family
|
|
|
54
54
|
|
|
55
55
|
CFErrorRef error = NULL;
|
|
56
56
|
bool ok = CTFontManagerRegisterGraphicsFont(cgFont, &error);
|
|
57
|
-
|
|
57
|
+
CGFontRelease(cgFont);
|
|
58
58
|
|
|
59
59
|
if (!ok && error) {
|
|
60
60
|
NSError *err = (__bridge_transfer NSError *)error;
|
|
61
|
-
|
|
62
61
|
if (err.code == kCTFontManagerErrorAlreadyRegistered ||
|
|
63
62
|
err.code == kCTFontManagerErrorDuplicatedName) {
|
|
64
|
-
// OTA reload: process still holds the old font. Swap it out.
|
|
65
|
-
CTFontRef existingCT = CTFontCreateWithName((__bridge CFStringRef)postScriptName, 10.0, NULL);
|
|
66
|
-
if (existingCT) {
|
|
67
|
-
CGFontRef existingCG = CTFontCopyGraphicsFont(existingCT, NULL);
|
|
68
|
-
CFRelease(existingCT);
|
|
69
|
-
if (existingCG) {
|
|
70
|
-
CFErrorRef unregErr = NULL;
|
|
71
|
-
CTFontManagerUnregisterGraphicsFont(existingCG, &unregErr);
|
|
72
|
-
CFRelease(existingCG);
|
|
73
|
-
if (unregErr) CFRelease(unregErr);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
CFErrorRef regErr = NULL;
|
|
78
|
-
bool reok = CTFontManagerRegisterGraphicsFont(cgFont, ®Err);
|
|
79
|
-
CGFontRelease(cgFont);
|
|
80
|
-
|
|
81
|
-
if (!reok && regErr) {
|
|
82
|
-
NSError *reErr = (__bridge_transfer NSError *)regErr;
|
|
83
|
-
reject(@"E_NANOICONS_FONT_REGISTER", reErr.localizedDescription, reErr);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (regErr) CFRelease(regErr);
|
|
87
|
-
|
|
88
|
-
NanoIconInvalidateFontCache(postScriptName);
|
|
89
63
|
resolve(@(YES));
|
|
90
64
|
return;
|
|
91
65
|
}
|
|
92
|
-
|
|
93
|
-
CGFontRelease(cgFont);
|
|
94
66
|
reject(@"E_NANOICONS_FONT_REGISTER", err.localizedDescription, err);
|
|
95
67
|
return;
|
|
96
68
|
}
|
|
97
69
|
|
|
98
|
-
CGFontRelease(cgFont);
|
|
99
70
|
resolve(@(YES));
|
|
100
71
|
}
|
|
101
72
|
|
|
73
|
+
RCT_EXPORT_METHOD(isFontRegistered:(NSString *)family
|
|
74
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
75
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
76
|
+
{
|
|
77
|
+
resolve(@(NanoIconIsFontResolvable(family)));
|
|
78
|
+
}
|
|
79
|
+
|
|
102
80
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
103
81
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
104
82
|
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NanoLogger } from './logger
|
|
1
|
+
import type { NanoLogger } from './logger';
|
|
2
2
|
export type IconSetConfig = {
|
|
3
3
|
/** Path to folder of SVG files (relative to project root). */
|
|
4
4
|
inputDir: string;
|
|
@@ -8,21 +8,29 @@ export type IconSetConfig = {
|
|
|
8
8
|
outputDir?: string;
|
|
9
9
|
/** Units per em (default 1024). */
|
|
10
10
|
upm?: number;
|
|
11
|
-
/** Safe zone inside UPM for glyphs (default 1020). */
|
|
11
|
+
/** Safe zone inside UPM for glyphs (default upm * 1020 / 1024, i.e. 1020 at the default upm). Must not exceed upm. */
|
|
12
12
|
safeZone?: number;
|
|
13
13
|
/** First Unicode codepoint for glyphs (default 0xe900). Hex string or number. */
|
|
14
14
|
startUnicode?: number | string;
|
|
15
15
|
/** Linking type for the font (default 'static'). Static bundles the TTF, dynamic delivers it via OTA*/
|
|
16
16
|
linking?: 'static' | 'dynamic';
|
|
17
|
+
/** Also emit <fontFamily>.woff2 into outputDir for web (default false). Rebuilt with the TTF, never linked natively. */
|
|
18
|
+
web?: boolean;
|
|
17
19
|
};
|
|
18
20
|
export type BuiltFont = {
|
|
19
21
|
fontFamily: string;
|
|
22
|
+
family: string;
|
|
20
23
|
ttfPath: string;
|
|
21
24
|
glyphmapPath: string;
|
|
22
25
|
linking: 'static' | 'dynamic';
|
|
26
|
+
woff2Path?: string;
|
|
23
27
|
};
|
|
28
|
+
export declare class IconSetBuildError extends Error {
|
|
29
|
+
built: BuiltFont[];
|
|
30
|
+
constructor(message: string, built: BuiltFont[]);
|
|
31
|
+
}
|
|
24
32
|
/**
|
|
25
|
-
* Build TTF + glyphmap for all icon sets using a single
|
|
33
|
+
* Build TTF + glyphmap for all icon sets using a single PathKit instance.
|
|
26
34
|
* Output is placed in a "nanoicons" folder next to each input dir (sibling to inputDir).
|
|
27
35
|
* Skips generation for a set if that output folder already contains the expected .ttf and .glyphmap.json.
|
|
28
36
|
*/
|
|
@@ -3,84 +3,145 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IconSetBuildError = void 0;
|
|
6
7
|
exports.buildAllFonts = buildAllFonts;
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const index_1 = require("../src/core/pipeline/index");
|
|
11
|
+
const fingerPrint_1 = require("../src/utils/fingerPrint");
|
|
12
|
+
const packageVersion_1 = require("../src/utils/packageVersion");
|
|
13
|
+
class IconSetBuildError extends Error {
|
|
14
|
+
built;
|
|
15
|
+
constructor(message, built) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.built = built;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.IconSetBuildError = IconSetBuildError;
|
|
21
|
+
const DEFAULT_SAFE_ZONE_RATIO = 1020 / 1024;
|
|
12
22
|
const DEFAULT_UPM = 1024;
|
|
13
23
|
const DEFAULT_START_UNICODE = 0xe900;
|
|
14
|
-
function
|
|
24
|
+
function familyOfCurrentOutput(inputHash, outputDir, fontFamily, linking, web, logger) {
|
|
15
25
|
const ttfPath = path_1.default.join(outputDir, `${fontFamily}.ttf`);
|
|
16
26
|
const glyphmapPath = path_1.default.join(outputDir, `${fontFamily}.glyphmap.json`);
|
|
27
|
+
const woff2Path = path_1.default.join(outputDir, `${fontFamily}.woff2`);
|
|
17
28
|
if (!fs_1.default.existsSync(outputDir) ||
|
|
18
29
|
!fs_1.default.existsSync(ttfPath) ||
|
|
19
|
-
!fs_1.default.existsSync(glyphmapPath)
|
|
20
|
-
|
|
30
|
+
!fs_1.default.existsSync(glyphmapPath) ||
|
|
31
|
+
(web && !fs_1.default.existsSync(woff2Path))) {
|
|
32
|
+
return undefined;
|
|
21
33
|
}
|
|
22
34
|
const glyphmap = JSON.parse(fs_1.default.readFileSync(glyphmapPath, 'utf8'));
|
|
23
35
|
const storedHash = glyphmap?.m?.h;
|
|
36
|
+
const storedFamily = glyphmap?.m?.f;
|
|
24
37
|
const storedLinking = glyphmap?.m?.l === 'd' ? 'dynamic' : 'static';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
const storedWeb = glyphmap?.m?.w === true;
|
|
39
|
+
if (storedHash &&
|
|
40
|
+
storedFamily &&
|
|
41
|
+
storedHash === inputHash &&
|
|
42
|
+
storedLinking === linking &&
|
|
43
|
+
storedWeb === web) {
|
|
44
|
+
const iconCount = Object.keys(glyphmap?.i ?? {}).length;
|
|
45
|
+
logger?.succeed(`${fontFamily}.ttf is up to date [${iconCount} icon${iconCount === 1 ? '' : 's'}]`);
|
|
46
|
+
return storedFamily;
|
|
28
47
|
}
|
|
29
|
-
return
|
|
48
|
+
return undefined;
|
|
30
49
|
}
|
|
31
50
|
/**
|
|
32
|
-
* Build TTF + glyphmap for all icon sets using a single
|
|
51
|
+
* Build TTF + glyphmap for all icon sets using a single PathKit instance.
|
|
33
52
|
* Output is placed in a "nanoicons" folder next to each input dir (sibling to inputDir).
|
|
34
53
|
* Skips generation for a set if that output folder already contains the expected .ttf and .glyphmap.json.
|
|
35
54
|
*/
|
|
36
55
|
async function buildAllFonts(iconSets, projectRoot, options) {
|
|
37
56
|
const logger = options?.logger;
|
|
57
|
+
const version = (0, packageVersion_1.packageVersion)();
|
|
58
|
+
const toolchain = (0, packageVersion_1.fontToolchainVersions)();
|
|
38
59
|
const results = [];
|
|
60
|
+
const failures = [];
|
|
39
61
|
let allSkipped = true;
|
|
40
62
|
for (let i = 0; i < iconSets.length; i++) {
|
|
41
63
|
const set = iconSets[i];
|
|
42
64
|
const inputDir = path_1.default.resolve(projectRoot, set.inputDir);
|
|
43
65
|
const fontFamily = set.fontFamily ?? path_1.default.basename(inputDir);
|
|
44
66
|
const linking = set.linking ?? 'static';
|
|
67
|
+
const web = set.web ?? false;
|
|
45
68
|
if (!fs_1.default.existsSync(inputDir)) {
|
|
46
69
|
throw new Error(`[react-native-nano-icons] Input directory does not exist: ${inputDir} (from "${set.inputDir}")`);
|
|
47
70
|
}
|
|
71
|
+
const upm = set.upm ?? DEFAULT_UPM;
|
|
72
|
+
const safeZone = set.safeZone ?? Math.round(upm * DEFAULT_SAFE_ZONE_RATIO);
|
|
73
|
+
if (safeZone > upm) {
|
|
74
|
+
throw new Error(`[react-native-nano-icons] safeZone (${safeZone}) of "${fontFamily}" must not exceed upm (${upm}).`);
|
|
75
|
+
}
|
|
48
76
|
const outputDir = set.outputDir
|
|
49
77
|
? path_1.default.resolve(projectRoot, set.outputDir)
|
|
50
78
|
: path_1.default.join(path_1.default.dirname(inputDir), 'nanoicons');
|
|
51
79
|
const ttfPath = path_1.default.join(outputDir, `${fontFamily}.ttf`);
|
|
52
80
|
const glyphmapPath = path_1.default.join(outputDir, `${fontFamily}.glyphmap.json`);
|
|
53
|
-
const
|
|
54
|
-
if (shouldSkipGeneration(inputHash, outputDir, fontFamily, linking, logger)) {
|
|
55
|
-
results.push({ fontFamily, ttfPath, glyphmapPath, linking });
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (fs_1.default.existsSync(ttfPath))
|
|
59
|
-
fs_1.default.unlinkSync(ttfPath);
|
|
60
|
-
if (fs_1.default.existsSync(glyphmapPath))
|
|
61
|
-
fs_1.default.unlinkSync(glyphmapPath);
|
|
62
|
-
allSkipped = false;
|
|
63
|
-
const tempDir = path_1.default.join(projectRoot, '.temp_layers', fontFamily);
|
|
81
|
+
const woff2Path = path_1.default.join(outputDir, `${fontFamily}.woff2`);
|
|
64
82
|
const config = {
|
|
65
83
|
fontFamily,
|
|
66
|
-
upm
|
|
67
|
-
safeZone
|
|
84
|
+
upm,
|
|
85
|
+
safeZone,
|
|
68
86
|
startUnicode: set.startUnicode !== undefined
|
|
69
87
|
? typeof set.startUnicode === 'string'
|
|
70
88
|
? parseInt(set.startUnicode, 16)
|
|
71
89
|
: set.startUnicode
|
|
72
90
|
: DEFAULT_START_UNICODE,
|
|
73
91
|
linking,
|
|
92
|
+
web,
|
|
74
93
|
};
|
|
94
|
+
const inputHash = (0, fingerPrint_1.getFingerprintSync)(inputDir, {
|
|
95
|
+
upm: config.upm,
|
|
96
|
+
safeZone: config.safeZone,
|
|
97
|
+
startUnicode: config.startUnicode,
|
|
98
|
+
version,
|
|
99
|
+
toolchain,
|
|
100
|
+
});
|
|
101
|
+
const currentFamily = familyOfCurrentOutput(inputHash, outputDir, fontFamily, linking, web, logger);
|
|
102
|
+
if (currentFamily) {
|
|
103
|
+
results.push({
|
|
104
|
+
fontFamily,
|
|
105
|
+
family: currentFamily,
|
|
106
|
+
ttfPath,
|
|
107
|
+
glyphmapPath,
|
|
108
|
+
linking,
|
|
109
|
+
...(web ? { woff2Path } : {}),
|
|
110
|
+
});
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
allSkipped = false;
|
|
114
|
+
const tempDir = path_1.default.join(projectRoot, '.temp_layers', fontFamily);
|
|
75
115
|
logger?.start(`Building ${fontFamily} (${i + 1}/${iconSets.length})…`);
|
|
76
|
-
|
|
116
|
+
if (!web && fs_1.default.existsSync(woff2Path))
|
|
117
|
+
fs_1.default.unlinkSync(woff2Path);
|
|
118
|
+
let out;
|
|
119
|
+
try {
|
|
120
|
+
out = await (0, index_1.runFontPipeline)(config, { inputDir, outputDir, tempDir }, { logger, inputHash });
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
if (fs_1.default.existsSync(ttfPath))
|
|
124
|
+
fs_1.default.unlinkSync(ttfPath);
|
|
125
|
+
if (fs_1.default.existsSync(glyphmapPath))
|
|
126
|
+
fs_1.default.unlinkSync(glyphmapPath);
|
|
127
|
+
if (fs_1.default.existsSync(woff2Path))
|
|
128
|
+
fs_1.default.unlinkSync(woff2Path);
|
|
129
|
+
logger?.fail(err instanceof Error ? err.message : String(err));
|
|
130
|
+
failures.push(fontFamily);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
77
133
|
results.push({
|
|
78
134
|
fontFamily,
|
|
135
|
+
family: out.family,
|
|
79
136
|
ttfPath: out.ttfPath,
|
|
80
137
|
glyphmapPath: out.glyphmapPath,
|
|
81
138
|
linking,
|
|
139
|
+
...(out.woff2Path ? { woff2Path: out.woff2Path } : {}),
|
|
82
140
|
});
|
|
83
141
|
}
|
|
142
|
+
if (failures.length) {
|
|
143
|
+
throw new IconSetBuildError(`${failures.length} icon set${failures.length === 1 ? '' : 's'} failed to build: ${failures.join(', ')}`, results);
|
|
144
|
+
}
|
|
84
145
|
if (allSkipped && results.length > 0) {
|
|
85
146
|
logger?.succeed('Your icons are flight-tuned with react-native-nano-icons');
|
|
86
147
|
}
|
|
@@ -16,7 +16,7 @@ function loadNanoIconsConfig(configRoot) {
|
|
|
16
16
|
if (!node_fs_1.default.existsSync(configPath)) {
|
|
17
17
|
throw new Error(`🔬❌ [react-native-nano-icons] No .nanoicons.json found at (${configRoot}).\n` +
|
|
18
18
|
`Create one with: { "iconSets": [{ "inputDir": "assets/icons", "fontFamily": "MyIcons" }] } \n` +
|
|
19
|
-
`
|
|
19
|
+
`Run from your app root, or pass --path <app folder or .nanoicons.json>.`);
|
|
20
20
|
}
|
|
21
21
|
const raw = node_fs_1.default.readFileSync(configPath, 'utf8');
|
|
22
22
|
const config = JSON.parse(raw);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { IconSetConfig } from './build
|
|
1
|
+
import type { IconSetConfig } from './build';
|
|
2
2
|
/**
|
|
3
3
|
* Load icon sets configured with linking: 'dynamic' from the Expo app config
|
|
4
4
|
* (app.json, app.config.js, or app.config.ts).
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Loads the config through the app's expo/config (present in all Expo projects),
|
|
7
|
+
* falling back to @expo/config.
|
|
7
8
|
*/
|
|
8
9
|
export declare function loadDynamicSetsFromAppConfig(projectRoot: string): IconSetConfig[];
|
|
@@ -5,18 +5,16 @@ exports.loadDynamicSetsFromAppConfig = loadDynamicSetsFromAppConfig;
|
|
|
5
5
|
* Load icon sets configured with linking: 'dynamic' from the Expo app config
|
|
6
6
|
* (app.json, app.config.js, or app.config.ts).
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Loads the config through the app's expo/config (present in all Expo projects),
|
|
9
|
+
* falling back to @expo/config.
|
|
9
10
|
*/
|
|
10
11
|
function loadDynamicSetsFromAppConfig(projectRoot) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
throw new Error(`[react-native-nano-icons] @expo/config not found — required for --dynamic --app-config.\n` +
|
|
18
|
-
`It should already be present in Expo projects. If missing: yarn add @expo/config`);
|
|
12
|
+
const configModule = resolveExpoConfigModule(projectRoot);
|
|
13
|
+
if (!configModule) {
|
|
14
|
+
throw new Error(`[react-native-nano-icons] Could not find expo/config or @expo/config from ${projectRoot} — required for --dynamic --app-config.\n` +
|
|
15
|
+
`Run the command from your Expo app root, or pass --path <app root>.`);
|
|
19
16
|
}
|
|
17
|
+
const { getConfig } = require(configModule);
|
|
20
18
|
const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });
|
|
21
19
|
const plugins = Array.isArray(exp.plugins) ? exp.plugins : [];
|
|
22
20
|
const entry = plugins.find((p) => Array.isArray(p) && p[0] === 'react-native-nano-icons');
|
|
@@ -32,3 +30,18 @@ function loadDynamicSetsFromAppConfig(projectRoot) {
|
|
|
32
30
|
}
|
|
33
31
|
return dynamicSets;
|
|
34
32
|
}
|
|
33
|
+
function resolveExpoConfigModule(projectRoot) {
|
|
34
|
+
const candidates = [
|
|
35
|
+
['expo/config', [projectRoot]],
|
|
36
|
+
['@expo/config', [projectRoot, __dirname]],
|
|
37
|
+
];
|
|
38
|
+
for (const [request, paths] of candidates) {
|
|
39
|
+
try {
|
|
40
|
+
return require.resolve(request, { paths });
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { buildAllFonts, type IconSetConfig, type BuiltFont } from './build
|
|
2
|
-
export { createOraLogger, createQuietLogger, detectExpoLogLevel, type NanoLogger, type LogLevel, } from './logger
|
|
3
|
-
export { loadNanoIconsConfig, loadDynamicIconSets, type NanoIconsConfig, } from './config
|
|
4
|
-
export { loadDynamicSetsFromAppConfig } from './expoConfig
|
|
5
|
-
export { linkBare } from './link
|
|
1
|
+
export { buildAllFonts, IconSetBuildError, type IconSetConfig, type BuiltFont, } from './build';
|
|
2
|
+
export { createOraLogger, createQuietLogger, detectExpoLogLevel, type NanoLogger, type LogLevel, } from './logger';
|
|
3
|
+
export { loadNanoIconsConfig, loadDynamicIconSets, type NanoIconsConfig, } from './config';
|
|
4
|
+
export { loadDynamicSetsFromAppConfig } from './expoConfig';
|
|
5
|
+
export { linkBare, syncAndroidFontAssets } from './link';
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.linkBare = exports.loadDynamicSetsFromAppConfig = exports.loadDynamicIconSets = exports.loadNanoIconsConfig = exports.detectExpoLogLevel = exports.createQuietLogger = exports.createOraLogger = exports.buildAllFonts = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "buildAllFonts", { enumerable: true, get: function () { return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "
|
|
9
|
-
Object.defineProperty(exports, "
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, "
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
exports.syncAndroidFontAssets = exports.linkBare = exports.loadDynamicSetsFromAppConfig = exports.loadDynamicIconSets = exports.loadNanoIconsConfig = exports.detectExpoLogLevel = exports.createQuietLogger = exports.createOraLogger = exports.IconSetBuildError = exports.buildAllFonts = void 0;
|
|
4
|
+
var build_1 = require("./build");
|
|
5
|
+
Object.defineProperty(exports, "buildAllFonts", { enumerable: true, get: function () { return build_1.buildAllFonts; } });
|
|
6
|
+
Object.defineProperty(exports, "IconSetBuildError", { enumerable: true, get: function () { return build_1.IconSetBuildError; } });
|
|
7
|
+
var logger_1 = require("./logger");
|
|
8
|
+
Object.defineProperty(exports, "createOraLogger", { enumerable: true, get: function () { return logger_1.createOraLogger; } });
|
|
9
|
+
Object.defineProperty(exports, "createQuietLogger", { enumerable: true, get: function () { return logger_1.createQuietLogger; } });
|
|
10
|
+
Object.defineProperty(exports, "detectExpoLogLevel", { enumerable: true, get: function () { return logger_1.detectExpoLogLevel; } });
|
|
11
|
+
var config_1 = require("./config");
|
|
12
|
+
Object.defineProperty(exports, "loadNanoIconsConfig", { enumerable: true, get: function () { return config_1.loadNanoIconsConfig; } });
|
|
13
|
+
Object.defineProperty(exports, "loadDynamicIconSets", { enumerable: true, get: function () { return config_1.loadDynamicIconSets; } });
|
|
14
|
+
var expoConfig_1 = require("./expoConfig");
|
|
15
|
+
Object.defineProperty(exports, "loadDynamicSetsFromAppConfig", { enumerable: true, get: function () { return expoConfig_1.loadDynamicSetsFromAppConfig; } });
|
|
16
|
+
var link_1 = require("./link");
|
|
17
|
+
Object.defineProperty(exports, "linkBare", { enumerable: true, get: function () { return link_1.linkBare; } });
|
|
18
|
+
Object.defineProperty(exports, "syncAndroidFontAssets", { enumerable: true, get: function () { return link_1.syncAndroidFontAssets; } });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { NanoLogger } from './logger
|
|
2
|
-
import type { BuiltFont } from './build
|
|
1
|
+
import type { NanoLogger } from './logger';
|
|
2
|
+
import type { BuiltFont } from './build';
|
|
3
|
+
export declare function syncAndroidFontAssets(fontsDir: string, staticFonts: BuiltFont[], configuredFamilies: string[]): void;
|
|
3
4
|
/**
|
|
4
5
|
* Link built TTFs into native project directories.
|
|
5
6
|
*
|
|
@@ -8,4 +9,4 @@ import type { BuiltFont } from './build.js';
|
|
|
8
9
|
* - Only one platform dir exists → link that platform only
|
|
9
10
|
* - Neither exists (e.g. React Native Web) → skip native linking, report output dir
|
|
10
11
|
*/
|
|
11
|
-
export declare function linkBare(projectRoot: string, builtFonts: BuiltFont[], logger: NanoLogger): Promise<void>;
|
|
12
|
+
export declare function linkBare(projectRoot: string, builtFonts: BuiltFont[], logger: NanoLogger, totalSets?: number): Promise<void>;
|
package/lib/commonjs/cli/link.js
CHANGED
|
@@ -36,56 +36,133 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.syncAndroidFontAssets = syncAndroidFontAssets;
|
|
39
40
|
exports.linkBare = linkBare;
|
|
40
41
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
41
42
|
const node_path_1 = __importDefault(require("node:path"));
|
|
42
43
|
const plist = __importStar(require("plist"));
|
|
44
|
+
const fontIdentity_1 = require("../src/utils/fontIdentity");
|
|
43
45
|
const ANDROID_FONTS_DIR = 'android/app/src/main/assets/fonts';
|
|
44
46
|
const IOS_NANOICONS_FONTS_DIR = 'nanoicons-fonts';
|
|
45
47
|
const IOS_RUN_SCRIPT_PHASE_NAME = 'Copy nanoicons fonts';
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const IOS_APPLICATION_PRODUCT_TYPE = 'com.apple.product-type.application';
|
|
49
|
+
const XCODE_PROJECT_DIR_VARIABLE = /\$[({](?:SRCROOT|PROJECT_DIR)[)}]/g;
|
|
50
|
+
const SURROUNDING_QUOTES = /^["']|["']$/g;
|
|
51
|
+
function getAppTarget(project) {
|
|
52
|
+
const appTarget = project.getTarget(IOS_APPLICATION_PRODUCT_TYPE);
|
|
53
|
+
if (appTarget)
|
|
54
|
+
return appTarget;
|
|
55
|
+
const { uuid, firstTarget } = project.getFirstTarget();
|
|
56
|
+
return { uuid, target: firstTarget };
|
|
57
|
+
}
|
|
58
|
+
function resolveInfoPlistPaths(project, target, iosDir, fallbackPath) {
|
|
59
|
+
const configurationList = project.pbxXCConfigurationList()[target.buildConfigurationList];
|
|
60
|
+
const buildConfigurations = project.pbxXCBuildConfigurationSection();
|
|
61
|
+
const configuredPaths = new Set();
|
|
62
|
+
if (typeof configurationList === 'object') {
|
|
63
|
+
for (const { value } of configurationList.buildConfigurations) {
|
|
64
|
+
const configuration = buildConfigurations[value];
|
|
65
|
+
if (typeof configuration !== 'object')
|
|
66
|
+
continue;
|
|
67
|
+
const setting = configuration.buildSettings['INFOPLIST_FILE'];
|
|
68
|
+
if (typeof setting !== 'string')
|
|
69
|
+
continue;
|
|
70
|
+
configuredPaths.add(node_path_1.default.resolve(iosDir, setting
|
|
71
|
+
.replace(SURROUNDING_QUOTES, '')
|
|
72
|
+
.replace(XCODE_PROJECT_DIR_VARIABLE, iosDir)));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const existingPaths = [...configuredPaths].filter((plistPath) => node_fs_1.default.existsSync(plistPath));
|
|
76
|
+
if (existingPaths.length)
|
|
77
|
+
return existingPaths;
|
|
78
|
+
return node_fs_1.default.existsSync(fallbackPath) ? [fallbackPath] : [];
|
|
79
|
+
}
|
|
80
|
+
function syncUIAppFonts(infoPlistPath, add, remove) {
|
|
81
|
+
const parsed = plist.parse(node_fs_1.default.readFileSync(infoPlistPath, 'utf8'));
|
|
82
|
+
const existing = Array.isArray(parsed['UIAppFonts'])
|
|
83
|
+
? parsed['UIAppFonts']
|
|
84
|
+
: [];
|
|
85
|
+
const fonts = [
|
|
86
|
+
...new Set([...existing.filter((f) => !remove.includes(f)), ...add]),
|
|
87
|
+
];
|
|
88
|
+
if (fonts.length === existing.length &&
|
|
89
|
+
fonts.every((f, i) => f === existing[i])) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const updated = { ...parsed, UIAppFonts: fonts };
|
|
93
|
+
node_fs_1.default.writeFileSync(infoPlistPath, plist.build(updated), 'utf8');
|
|
94
|
+
}
|
|
95
|
+
function syncAndroidFontAssets(fontsDir, staticFonts, configuredFamilies) {
|
|
96
|
+
const keep = new Set(staticFonts.map((b) => `${b.family}.ttf`));
|
|
97
|
+
if (node_fs_1.default.existsSync(fontsDir)) {
|
|
98
|
+
for (const existing of node_fs_1.default.readdirSync(fontsDir)) {
|
|
99
|
+
if (keep.has(existing))
|
|
100
|
+
continue;
|
|
101
|
+
if ((0, fontIdentity_1.isBuildFontFile)(existing) ||
|
|
102
|
+
configuredFamilies.some((family) => (0, fontIdentity_1.isFontFileOf)(family, existing))) {
|
|
103
|
+
node_fs_1.default.unlinkSync(node_path_1.default.join(fontsDir, existing));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (!staticFonts.length)
|
|
108
|
+
return;
|
|
109
|
+
node_fs_1.default.mkdirSync(fontsDir, { recursive: true });
|
|
110
|
+
for (const b of staticFonts) {
|
|
111
|
+
node_fs_1.default.copyFileSync(b.ttfPath, node_path_1.default.join(fontsDir, `${b.family}.ttf`));
|
|
52
112
|
}
|
|
53
113
|
}
|
|
54
|
-
async function
|
|
114
|
+
async function linkAndroid(projectRoot, staticFonts, builtFonts) {
|
|
115
|
+
syncAndroidFontAssets(node_path_1.default.join(projectRoot, ANDROID_FONTS_DIR), staticFonts, builtFonts.map((b) => b.fontFamily));
|
|
116
|
+
}
|
|
117
|
+
async function linkIos(projectRoot, staticFonts, dynamicFonts, logger) {
|
|
55
118
|
const iosDir = node_path_1.default.join(projectRoot, 'ios');
|
|
56
119
|
const xcodeprojDir = node_fs_1.default
|
|
57
120
|
.readdirSync(iosDir, { withFileTypes: true })
|
|
58
121
|
.find((d) => d.name.endsWith('.xcodeproj'));
|
|
59
|
-
if (!xcodeprojDir)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!node_fs_1.default.existsSync(infoPlistPath))
|
|
64
|
-
return;
|
|
65
|
-
const fontNames = [];
|
|
66
|
-
const iosFontsStaging = node_path_1.default.join(iosDir, IOS_NANOICONS_FONTS_DIR);
|
|
67
|
-
node_fs_1.default.mkdirSync(iosFontsStaging, { recursive: true });
|
|
68
|
-
for (const b of builtFonts) {
|
|
69
|
-
const name = node_path_1.default.basename(b.ttfPath);
|
|
70
|
-
fontNames.push(name);
|
|
71
|
-
node_fs_1.default.copyFileSync(b.ttfPath, node_path_1.default.join(iosFontsStaging, name));
|
|
72
|
-
}
|
|
73
|
-
const plistContent = node_fs_1.default.readFileSync(infoPlistPath, 'utf8');
|
|
74
|
-
const obj = plist.parse(plistContent);
|
|
75
|
-
const existing = Array.isArray(obj['UIAppFonts'])
|
|
76
|
-
? obj['UIAppFonts']
|
|
77
|
-
: [];
|
|
78
|
-
const merged = [...new Set([...existing, ...fontNames])];
|
|
79
|
-
const updated = {
|
|
80
|
-
...obj,
|
|
81
|
-
UIAppFonts: merged,
|
|
82
|
-
};
|
|
83
|
-
node_fs_1.default.writeFileSync(infoPlistPath, plist.build(updated), 'utf8');
|
|
122
|
+
if (!xcodeprojDir) {
|
|
123
|
+
logger.warn(`No .xcodeproj found in ${iosDir} — skipping iOS linking.`);
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
84
126
|
const pbxprojPath = node_path_1.default.join(iosDir, xcodeprojDir.name, 'project.pbxproj');
|
|
127
|
+
if (!node_fs_1.default.existsSync(pbxprojPath)) {
|
|
128
|
+
logger.warn(`${node_path_1.default.relative(projectRoot, pbxprojPath)} not found — skipping iOS linking.`);
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
85
131
|
const xcode = require('xcode');
|
|
86
|
-
const project = xcode.project(pbxprojPath);
|
|
87
|
-
|
|
88
|
-
const
|
|
132
|
+
const project = xcode.project(pbxprojPath).parseSync();
|
|
133
|
+
const appName = xcodeprojDir.name.replace(/\.xcodeproj$/, '');
|
|
134
|
+
const { uuid: targetUuid, target } = getAppTarget(project);
|
|
135
|
+
const infoPlistPaths = resolveInfoPlistPaths(project, target, iosDir, node_path_1.default.join(iosDir, appName, 'Info.plist'));
|
|
136
|
+
if (!infoPlistPaths.length) {
|
|
137
|
+
logger.warn(`No Info.plist resolved for target "${target.name}" — set INFOPLIST_FILE in its build settings, ` +
|
|
138
|
+
`or place one at ios/${appName}/Info.plist. Skipping iOS linking.`);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
const fontNames = staticFonts.map((b) => node_path_1.default.basename(b.ttfPath));
|
|
142
|
+
const removedNames = dynamicFonts.map((b) => `${b.fontFamily}.ttf`);
|
|
143
|
+
const iosFontsStaging = node_path_1.default.join(iosDir, IOS_NANOICONS_FONTS_DIR);
|
|
144
|
+
if (node_fs_1.default.existsSync(iosFontsStaging)) {
|
|
145
|
+
for (const existing of node_fs_1.default.readdirSync(iosFontsStaging)) {
|
|
146
|
+
if (existing.endsWith('.ttf') && !fontNames.includes(existing)) {
|
|
147
|
+
node_fs_1.default.unlinkSync(node_path_1.default.join(iosFontsStaging, existing));
|
|
148
|
+
removedNames.push(existing);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (staticFonts.length) {
|
|
153
|
+
node_fs_1.default.mkdirSync(iosFontsStaging, { recursive: true });
|
|
154
|
+
for (const b of staticFonts) {
|
|
155
|
+
node_fs_1.default.copyFileSync(b.ttfPath, node_path_1.default.join(iosFontsStaging, node_path_1.default.basename(b.ttfPath)));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const infoPlistPath of infoPlistPaths) {
|
|
159
|
+
syncUIAppFonts(infoPlistPath, fontNames, removedNames);
|
|
160
|
+
}
|
|
161
|
+
if (!staticFonts.length)
|
|
162
|
+
return true;
|
|
163
|
+
const hasPhase = Object.values(project.hash.project.objects['PBXShellScriptBuildPhase'] ?? {}).some((phase) => typeof phase === 'object' &&
|
|
164
|
+
typeof phase['name'] === 'string' &&
|
|
165
|
+
phase['name'].includes(IOS_RUN_SCRIPT_PHASE_NAME));
|
|
89
166
|
if (!hasPhase) {
|
|
90
167
|
const script = `
|
|
91
168
|
NANOICONS_DIR="\\\${PROJECT_DIR}/${IOS_NANOICONS_FONTS_DIR}"
|
|
@@ -93,9 +170,10 @@ async function linkIos(projectRoot, builtFonts) {
|
|
|
93
170
|
cp "$NANOICONS_DIR"/*.ttf "\\\${BUILT_PRODUCTS_DIR}/\\\${UNLOCALIZED_RESOURCES_FOLDER_PATH}/" 2>/dev/null || true
|
|
94
171
|
fi
|
|
95
172
|
`;
|
|
96
|
-
project.addBuildPhase([], 'PBXShellScriptBuildPhase', IOS_RUN_SCRIPT_PHASE_NAME,
|
|
173
|
+
project.addBuildPhase([], 'PBXShellScriptBuildPhase', IOS_RUN_SCRIPT_PHASE_NAME, targetUuid, { shellPath: '/bin/sh', shellScript: script });
|
|
97
174
|
node_fs_1.default.writeFileSync(pbxprojPath, project.writeSync(), 'utf8');
|
|
98
175
|
}
|
|
176
|
+
return true;
|
|
99
177
|
}
|
|
100
178
|
/**
|
|
101
179
|
* Link built TTFs into native project directories.
|
|
@@ -105,7 +183,7 @@ async function linkIos(projectRoot, builtFonts) {
|
|
|
105
183
|
* - Only one platform dir exists → link that platform only
|
|
106
184
|
* - Neither exists (e.g. React Native Web) → skip native linking, report output dir
|
|
107
185
|
*/
|
|
108
|
-
async function linkBare(projectRoot, builtFonts, logger) {
|
|
186
|
+
async function linkBare(projectRoot, builtFonts, logger, totalSets = builtFonts.length) {
|
|
109
187
|
if (!builtFonts.length)
|
|
110
188
|
return;
|
|
111
189
|
const staticFonts = builtFonts.filter((b) => b.linking === 'static');
|
|
@@ -125,21 +203,25 @@ async function linkBare(projectRoot, builtFonts, logger) {
|
|
|
125
203
|
logger.info(`No native directories found — fonts saved to ${rel}/ (no native dirs, skipping link)`);
|
|
126
204
|
return;
|
|
127
205
|
}
|
|
128
|
-
if (!staticFonts.length) {
|
|
129
|
-
logger.succeed(`All ${dynamicFonts.length} font(s) use dynamic linking — nothing to bundle natively.`);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
206
|
const linkedPlatforms = [];
|
|
133
207
|
if (hasAndroid) {
|
|
134
|
-
await linkAndroid(projectRoot, staticFonts);
|
|
208
|
+
await linkAndroid(projectRoot, staticFonts, builtFonts);
|
|
135
209
|
linkedPlatforms.push('android');
|
|
136
210
|
}
|
|
137
|
-
if (hasIos
|
|
138
|
-
await linkIos(projectRoot, staticFonts)
|
|
211
|
+
if (hasIos &&
|
|
212
|
+
(await linkIos(projectRoot, staticFonts, dynamicFonts, logger))) {
|
|
139
213
|
linkedPlatforms.push('ios');
|
|
140
214
|
}
|
|
215
|
+
if (!staticFonts.length) {
|
|
216
|
+
logger.succeed(`All ${dynamicFonts.length} font(s) use dynamic linking — nothing to bundle natively.`);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
141
219
|
const dynamicSuffix = dynamicFonts.length
|
|
142
220
|
? ` (${dynamicFonts.length} dynamic font${dynamicFonts.length === 1 ? '' : 's'} skipped)`
|
|
143
221
|
: '';
|
|
144
|
-
|
|
222
|
+
if (!linkedPlatforms.length) {
|
|
223
|
+
logger.fail(`No platforms linked${dynamicSuffix}.`);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
logger.succeed(`Linked [${staticFonts.map((b) => b.fontFamily).join(', ')}] (${staticFonts.length}/${totalSets}) → ${linkedPlatforms.join(', ')}${dynamicSuffix}`);
|
|
145
227
|
}
|