react-native-nano-icons 0.2.1 → 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 +72 -11
- 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
|
@@ -7,98 +7,6 @@ export type NanoLogger = {
|
|
|
7
7
|
info: (msg: string) => void;
|
|
8
8
|
warn: (msg: string) => void;
|
|
9
9
|
};
|
|
10
|
-
export type Point = readonly [number, number];
|
|
11
|
-
export type Cmd = readonly number[];
|
|
12
|
-
export type VerbMap = {
|
|
13
|
-
MOVE: number;
|
|
14
|
-
LINE: number;
|
|
15
|
-
QUAD: number;
|
|
16
|
-
CONIC: number;
|
|
17
|
-
CUBIC: number;
|
|
18
|
-
CLOSE: number;
|
|
19
|
-
};
|
|
20
|
-
export type WrappedPath = {
|
|
21
|
-
p: PathKitPath;
|
|
22
|
-
meta: {
|
|
23
|
-
moves: Point[];
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export interface PathKitPath {
|
|
27
|
-
delete?: () => void;
|
|
28
|
-
moveTo: (x: number, y: number) => void;
|
|
29
|
-
lineTo: (x: number, y: number) => void;
|
|
30
|
-
quadTo: (x1: number, y1: number, x2: number, y2: number) => void;
|
|
31
|
-
cubicTo: (x1: number, y1: number, x2: number, y2: number, x3: number, y3: number) => void;
|
|
32
|
-
close: () => void;
|
|
33
|
-
simplify: () => void;
|
|
34
|
-
toSVGString: () => string;
|
|
35
|
-
toCmds: () => Cmd[];
|
|
36
|
-
getBounds: () => {
|
|
37
|
-
fLeft: number;
|
|
38
|
-
fTop: number;
|
|
39
|
-
fRight: number;
|
|
40
|
-
fBottom: number;
|
|
41
|
-
};
|
|
42
|
-
getFillType?: () => number;
|
|
43
|
-
setFillType: (t: number) => void;
|
|
44
|
-
dash?: (on: number, off: number, phase: number) => void;
|
|
45
|
-
stroke: (opts: {
|
|
46
|
-
width: number;
|
|
47
|
-
cap: number;
|
|
48
|
-
join: number;
|
|
49
|
-
miter_limit: number;
|
|
50
|
-
}) => PathKitPath | null;
|
|
51
|
-
transform: (a: number, c: number, e: number, b: number, d: number, f: number, g: number, h: number, i: number) => void;
|
|
52
|
-
}
|
|
53
|
-
export interface PathKitModule {
|
|
54
|
-
MOVE_VERB?: number;
|
|
55
|
-
LINE_VERB?: number;
|
|
56
|
-
QUAD_VERB?: number;
|
|
57
|
-
CONIC_VERB?: number;
|
|
58
|
-
CUBIC_VERB?: number;
|
|
59
|
-
CLOSE_VERB?: number;
|
|
60
|
-
FillType?: {
|
|
61
|
-
EVENODD?: number;
|
|
62
|
-
EVEN_ODD?: number;
|
|
63
|
-
WINDING?: number;
|
|
64
|
-
NONZERO?: number;
|
|
65
|
-
};
|
|
66
|
-
StrokeCap?: {
|
|
67
|
-
BUTT?: number;
|
|
68
|
-
ROUND?: number;
|
|
69
|
-
SQUARE?: number;
|
|
70
|
-
};
|
|
71
|
-
StrokeJoin?: {
|
|
72
|
-
MITER?: number;
|
|
73
|
-
ROUND?: number;
|
|
74
|
-
BEVEL?: number;
|
|
75
|
-
};
|
|
76
|
-
PathOp?: {
|
|
77
|
-
UNION?: number;
|
|
78
|
-
INTERSECT?: number;
|
|
79
|
-
DIFFERENCE?: number;
|
|
80
|
-
};
|
|
81
|
-
NewPath: (src?: PathKitPath) => PathKitPath;
|
|
82
|
-
FromSVGString: (svg: string) => PathKitPath | null;
|
|
83
|
-
MakeFromOp: (a: PathKitPath, b: PathKitPath, op: number) => PathKitPath | null;
|
|
84
|
-
}
|
|
85
|
-
export type PyodideModule = {
|
|
86
|
-
mountNodeFS: (mountpoint: string, hostPath: string) => void;
|
|
87
|
-
registerJsModule: (name: string, mod: unknown) => void;
|
|
88
|
-
loadPackage: (pkgs: string[], options?: {
|
|
89
|
-
messageCallback?: (msg: string) => void;
|
|
90
|
-
errorCallback?: (msg: string) => void;
|
|
91
|
-
}) => Promise<void>;
|
|
92
|
-
runPythonAsync: (code: string) => Promise<unknown>;
|
|
93
|
-
runPython: (code: string) => string;
|
|
94
|
-
FS: {
|
|
95
|
-
writeFile: (path: string, data: string) => void;
|
|
96
|
-
};
|
|
97
|
-
globals: {
|
|
98
|
-
set: (key: string, value: unknown) => void;
|
|
99
|
-
get: (key: string) => unknown;
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
10
|
export type GlyphLayer = [codepoint: number, color: string];
|
|
103
11
|
export type GlyphEntry = [adv: number, layers: GlyphLayer[]];
|
|
104
12
|
export type IconsMap = Record<string, GlyphEntry>;
|
|
@@ -110,6 +18,7 @@ export type IconsMap = Record<string, GlyphEntry>;
|
|
|
110
18
|
* s - start unicode,
|
|
111
19
|
* h - hash,
|
|
112
20
|
* l - linking mode: 's' (static, bundled — default when absent) or 'd' (dynamic, OTA-delivered),
|
|
21
|
+
* w - web output: true when a .woff2 was built alongside the .ttf (absent otherwise),
|
|
113
22
|
* i - icons,
|
|
114
23
|
* adv - advance width,
|
|
115
24
|
*/
|
|
@@ -121,6 +30,7 @@ export type NanoGlyphMap = {
|
|
|
121
30
|
s: number;
|
|
122
31
|
h?: string;
|
|
123
32
|
l?: 's' | 'd';
|
|
33
|
+
w?: true;
|
|
124
34
|
};
|
|
125
35
|
i: IconsMap;
|
|
126
36
|
};
|
|
@@ -133,6 +43,7 @@ export type NanoGlyphMapInput = {
|
|
|
133
43
|
s: number;
|
|
134
44
|
h?: string;
|
|
135
45
|
l?: 's' | 'd' | (string & {});
|
|
46
|
+
w?: boolean;
|
|
136
47
|
};
|
|
137
48
|
i: Record<string, readonly unknown[]>;
|
|
138
49
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type FontIntegrityIssue = {
|
|
2
|
+
fontFamily: string;
|
|
3
|
+
family: string;
|
|
4
|
+
linking: 'static' | 'dynamic';
|
|
5
|
+
message: string;
|
|
6
|
+
/** The error behind a dynamic font failure, when there is one. */
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type FontIntegrityStatus = 'found' | 'resolved';
|
|
10
|
+
type Listener = (issue: FontIntegrityIssue, status: FontIntegrityStatus) => void;
|
|
11
|
+
export declare function isFontRegistered(family: string): Promise<boolean>;
|
|
12
|
+
export declare function checkFontIntegrity(family: string, linking: 'static' | 'dynamic'): Promise<void>;
|
|
13
|
+
export declare const FONT_MISMATCH_CODE = "E_NANOICONS_FONT_MISMATCH";
|
|
14
|
+
export declare function isFontMismatch(err: unknown): boolean;
|
|
15
|
+
export declare const FONT_SOURCE_CODE = "E_NANOICONS_FONT_SOURCE";
|
|
16
|
+
export declare function reportFontMismatch(family: string, linking: 'static' | 'dynamic'): void;
|
|
17
|
+
export declare function reportMissingDynamicFont(family: string): Promise<void>;
|
|
18
|
+
export declare function reportDynamicFontLoadFailure(family: string, cause: unknown): Promise<void>;
|
|
19
|
+
export declare function resolveFontIssue(family: string): void;
|
|
20
|
+
export declare function addFontIntegrityListener(listener: Listener): () => void;
|
|
21
|
+
export declare function getFontIntegrityIssues(): FontIntegrityIssue[];
|
|
22
|
+
export declare function __resetFontIntegrityForTests(): void;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=fontIntegrity.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { createIconSet as createNanoIconSet, type IconComponent, type IconProps, } from './createNanoIconsSet';
|
|
2
|
+
export { addFontIntegrityListener, getFontIntegrityIssues, type FontIntegrityIssue, type FontIntegrityStatus, } from './fontIntegrity';
|
|
2
3
|
export type { ColorValue } from 'react-native';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,6 +2,7 @@ import type { TurboModule } from 'react-native';
|
|
|
2
2
|
export interface Spec extends TurboModule {
|
|
3
3
|
/** Pass glyphMap.m.f as `family`. On iOS it must also match the TTF's embedded PostScript/full name. */
|
|
4
4
|
registerFont(family: string, uri: string): Promise<boolean>;
|
|
5
|
+
isFontRegistered(family: string): Promise<boolean>;
|
|
5
6
|
}
|
|
6
7
|
declare const _default: Spec | null | undefined;
|
|
7
8
|
export default _default;
|
|
@@ -15,6 +15,11 @@ export type IconProps<Name> = {
|
|
|
15
15
|
importantForAccessibility?: 'auto' | 'yes' | 'no' | 'no-hide-descendants';
|
|
16
16
|
ref?: Ref<ViewRef>;
|
|
17
17
|
testID?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Forwarded to the container element on web.
|
|
20
|
+
* @platform Web only - no-op on native.
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
18
23
|
};
|
|
19
24
|
export type IconComponent<GM extends NanoGlyphMapInput> = React.FC<IconProps<keyof GM['i']>> & {
|
|
20
25
|
loadFont: (font?: number | string | {
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type FingerprintInputs = {
|
|
2
|
+
upm: number;
|
|
3
|
+
safeZone: number;
|
|
4
|
+
startUnicode: number;
|
|
5
|
+
version: string;
|
|
6
|
+
toolchain: readonly string[];
|
|
7
|
+
};
|
|
8
|
+
export declare function getFingerprintSync(dir: string, inputs: FingerprintInputs): string;
|
|
2
9
|
//# sourceMappingURL=fingerPrint.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function buildFontFamily(fontFamily: string, inputHash: string): string;
|
|
2
|
+
export declare function configuredFontFamily(family: string): string;
|
|
3
|
+
export declare function isFontFileOf(fontFamily: string, fileName: string): boolean;
|
|
4
|
+
export declare function isBuildFontFile(fileName: string): boolean;
|
|
5
|
+
//# sourceMappingURL=fontIdentity.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const LOG_PREFIX = "\uD83D\uDD2C react-native-nano-icons";
|
|
2
|
+
export declare function warnRuntime(message: string, ...rest: unknown[]): void;
|
|
3
|
+
export declare function errorRuntime(message: string): void;
|
|
4
|
+
export declare function runtimeError(message: string): Error;
|
|
5
|
+
//# sourceMappingURL=runtimeLog.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Path already starts with a moveto. */
|
|
2
|
+
export declare const SVG_MOVE_PREFIX: RegExp;
|
|
3
|
+
/** Trailing close-path command (+ optional whitespace). */
|
|
4
|
+
export declare const SVG_TRAILING_CLOSE: RegExp;
|
|
5
|
+
/** A signed int/float token. */
|
|
6
|
+
export declare const SVG_NUMBER: RegExp;
|
|
7
|
+
/** Whitespace separator (e.g. viewBox parts). */
|
|
8
|
+
export declare const WHITESPACE: RegExp;
|
|
9
|
+
/** `<mask …>` element (unsupported). */
|
|
10
|
+
export declare const XML_MASK: RegExp;
|
|
11
|
+
/** `<filter …>` element (unsupported). */
|
|
12
|
+
export declare const XML_FILTER: RegExp;
|
|
13
|
+
/** `<image …>` element (unsupported). */
|
|
14
|
+
export declare const XML_IMAGE: RegExp;
|
|
15
|
+
/** An `xmlns=` attribute. */
|
|
16
|
+
export declare const XML_XMLNS: RegExp;
|
|
17
|
+
/** Opening `<svg` tag. */
|
|
18
|
+
export declare const SVG_OPEN_TAG: RegExp;
|
|
19
|
+
export declare const PX_ATTRIBUTE_VALUE: RegExp;
|
|
20
|
+
export declare const PX_STYLE_VALUE: RegExp;
|
|
21
|
+
/** viewBox: comma or whitespace separated. */
|
|
22
|
+
export declare const VIEWBOX_SEPARATOR: RegExp;
|
|
23
|
+
/** transform() arguments: comma and/or whitespace separated. */
|
|
24
|
+
export declare const TRANSFORM_ARG_SEPARATOR: RegExp;
|
|
25
|
+
/** stroke-dasharray: single comma or space separated. */
|
|
26
|
+
export declare const DASHARRAY_SEPARATOR: RegExp;
|
|
27
|
+
/** One transform function call, e.g. `rotate(30)`; captures name and args. */
|
|
28
|
+
export declare const TRANSFORM_FUNCTION: RegExp;
|
|
29
|
+
/** `url(#id)` reference; captures the id. */
|
|
30
|
+
export declare const URL_ID_REFERENCE: RegExp;
|
|
31
|
+
/** A well-formed XML attribute name. */
|
|
32
|
+
export declare const XML_ATTRIBUTE_NAME: RegExp;
|
|
33
|
+
export declare const XML_AMP: RegExp;
|
|
34
|
+
export declare const XML_LT: RegExp;
|
|
35
|
+
export declare const XML_GT: RegExp;
|
|
36
|
+
export declare const XML_QUOT: RegExp;
|
|
37
|
+
/** svg2ttf error `glyph "u<hex>"` → captures the hex codepoint. */
|
|
38
|
+
export declare const GLYPH_CODEPOINT: RegExp;
|
|
39
|
+
//# sourceMappingURL=svgPatterns.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nano-icons",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "High-performance icon rendering for React Native & Expo.",
|
|
5
|
-
"react-native": "
|
|
5
|
+
"react-native": "./lib/module/index.js",
|
|
6
6
|
"source": "src/index.ts",
|
|
7
7
|
"bin": "lib/commonjs/scripts/cli.js",
|
|
8
8
|
"main": "./lib/commonjs/index.node.js",
|
|
9
9
|
"types": "./lib/typescript/src/index.d.ts",
|
|
10
10
|
"files": [
|
|
11
11
|
"app.plugin.js",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"src",
|
|
12
|
+
"LICENSES.md",
|
|
13
|
+
"src/specs",
|
|
14
|
+
"src/const/codegenPrimitives.ts",
|
|
15
15
|
"lib",
|
|
16
|
-
"plugin",
|
|
17
|
-
"scripts",
|
|
18
16
|
"ios",
|
|
19
17
|
"android",
|
|
20
18
|
"react-native-nano-icons.podspec"
|
|
21
19
|
],
|
|
22
20
|
"scripts": {
|
|
23
|
-
"build": "yarn build:node-entry && bob build && yarn build:core && yarn build:cli && yarn build:plugin && yarn build:scripts",
|
|
21
|
+
"build": "yarn build:node-entry && bob build && yarn build:core && yarn build:cli && yarn build:plugin && yarn build:scripts && del-cli 'lib/typescript/**/*.d.ts.map'",
|
|
24
22
|
"build:node-entry": "tsc -p tsconfig.node.json",
|
|
25
23
|
"build:core": "tsc -p src/core/tsconfig.json",
|
|
26
24
|
"build:cli": "tsc -p cli/tsconfig.json",
|
|
@@ -39,11 +37,11 @@
|
|
|
39
37
|
"@expo/config-plugins": ">=9.0.0",
|
|
40
38
|
"@xmldom/xmldom": "^0.9.10",
|
|
41
39
|
"chalk": "^5.6.2",
|
|
40
|
+
"cubic2quad": "^1.2.1",
|
|
42
41
|
"fonteditor-core": "^2.6.3",
|
|
43
42
|
"ora": "^9.3.0",
|
|
44
43
|
"pathkit-wasm": "^1.0.0",
|
|
45
44
|
"plist": "^3.0.5",
|
|
46
|
-
"pyodide": "^0.29.3",
|
|
47
45
|
"svg2ttf": "^6.0.3",
|
|
48
46
|
"xcode": "^3.0.1"
|
|
49
47
|
},
|
|
@@ -71,6 +69,7 @@
|
|
|
71
69
|
"@types/plist": "^3.0.5",
|
|
72
70
|
"@types/react": "~19.1.0",
|
|
73
71
|
"@types/svg2ttf": "^5.0.3",
|
|
72
|
+
"@types/xcode": "^3.0.0",
|
|
74
73
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
75
74
|
"del-cli": "^6.0.0",
|
|
76
75
|
"expo-module-scripts": "^5.0.8",
|
|
@@ -83,7 +82,8 @@
|
|
|
83
82
|
},
|
|
84
83
|
"exports": {
|
|
85
84
|
".": {
|
|
86
|
-
"source": "./src/index.
|
|
85
|
+
"source": "./src/index.ts",
|
|
86
|
+
"react-native": "./lib/module/index.js",
|
|
87
87
|
"require": {
|
|
88
88
|
"types": "./lib/typescript/src/index.d.ts",
|
|
89
89
|
"default": "./lib/commonjs/index.node.js"
|
|
@@ -139,11 +139,13 @@
|
|
|
139
139
|
"react-native-builder-bob": {
|
|
140
140
|
"source": "src",
|
|
141
141
|
"output": "lib",
|
|
142
|
+
"exclude": "**/{__tests__,__fixtures__,__mocks__,core}/**",
|
|
142
143
|
"targets": [
|
|
143
144
|
[
|
|
144
145
|
"module",
|
|
145
146
|
{
|
|
146
|
-
"esm": true
|
|
147
|
+
"esm": true,
|
|
148
|
+
"sourceMaps": false
|
|
147
149
|
}
|
|
148
150
|
],
|
|
149
151
|
[
|
|
@@ -4,6 +4,7 @@ import { TurboModuleRegistry } from 'react-native';
|
|
|
4
4
|
export interface Spec extends TurboModule {
|
|
5
5
|
/** Pass glyphMap.m.f as `family`. On iOS it must also match the TTF's embedded PostScript/full name. */
|
|
6
6
|
registerFont(family: string, uri: string): Promise<boolean>;
|
|
7
|
+
isFontRegistered(family: string): Promise<boolean>;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
// `get` (not `getEnforcing`) so the absence of the native module (web, Expo Go,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { PathKitModule, PyodideModule } from '../types.js';
|
|
2
|
-
export declare class PathKitManager {
|
|
3
|
-
private static instance;
|
|
4
|
-
static getInstance(): Promise<PathKitModule>;
|
|
5
|
-
}
|
|
6
|
-
export declare class PyodideManager {
|
|
7
|
-
private static instance;
|
|
8
|
-
static getInstance(): Promise<PyodideModule>;
|
|
9
|
-
static picoFromFile(hostFilePath: string, content?: string): Promise<string>;
|
|
10
|
-
}
|
|
11
|
-
export declare function picoFromFile(hostFilePath: string, content?: string): Promise<string>;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PyodideManager = exports.PathKitManager = void 0;
|
|
7
|
-
exports.picoFromFile = picoFromFile;
|
|
8
|
-
const pyodide_1 = require("pyodide");
|
|
9
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
11
|
-
const svg_pathops_js_1 = require("../svg/svg_pathops.js");
|
|
12
|
-
/** Package root (where package.json lives). */
|
|
13
|
-
function getPackageRoot() {
|
|
14
|
-
// Compiled to lib/commonjs/src/core/pipeline/ — 5 dirs up is package root.
|
|
15
|
-
// Running from source (Jest/ts-node) in src/core/pipeline/ — 3 dirs up is package root.
|
|
16
|
-
return __dirname.includes(`${node_path_1.default.sep}lib${node_path_1.default.sep}`)
|
|
17
|
-
? node_path_1.default.resolve(__dirname, '../../../../..')
|
|
18
|
-
: node_path_1.default.resolve(__dirname, '../../..');
|
|
19
|
-
}
|
|
20
|
-
class PathKitManager {
|
|
21
|
-
static instance = null;
|
|
22
|
-
static async getInstance() {
|
|
23
|
-
if (this.instance)
|
|
24
|
-
return this.instance;
|
|
25
|
-
const PathKitInit = require('pathkit-wasm/bin/pathkit.js');
|
|
26
|
-
const pathkitJsPath = require.resolve('pathkit-wasm/bin/pathkit.js');
|
|
27
|
-
const pathkitBinDir = node_path_1.default.dirname(pathkitJsPath);
|
|
28
|
-
const pathkitWasmPath = node_path_1.default.join(pathkitBinDir, 'pathkit.wasm');
|
|
29
|
-
const wasmBinary = await promises_1.default.readFile(pathkitWasmPath);
|
|
30
|
-
const pkInit = PathKitInit({
|
|
31
|
-
wasmBinary,
|
|
32
|
-
locateFile: (file) => node_path_1.default.join(pathkitBinDir, file),
|
|
33
|
-
});
|
|
34
|
-
const PathKit = await (typeof pkInit?.ready === 'function'
|
|
35
|
-
? pkInit.ready()
|
|
36
|
-
: pkInit);
|
|
37
|
-
this.instance = PathKit;
|
|
38
|
-
return PathKit;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.PathKitManager = PathKitManager;
|
|
42
|
-
class PyodideManager {
|
|
43
|
-
static instance = null;
|
|
44
|
-
static async getInstance() {
|
|
45
|
-
if (this.instance)
|
|
46
|
-
return this.instance;
|
|
47
|
-
const pyodideAsmPath = require.resolve('pyodide/pyodide.asm.js');
|
|
48
|
-
const pyodideDir = node_path_1.default.dirname(pyodideAsmPath) + node_path_1.default.sep;
|
|
49
|
-
const py = (await (0, pyodide_1.loadPyodide)({
|
|
50
|
-
indexURL: pyodideDir,
|
|
51
|
-
}));
|
|
52
|
-
py.mountNodeFS('/app', process.cwd());
|
|
53
|
-
const PathKit = await PathKitManager.getInstance();
|
|
54
|
-
py.registerJsModule('_pathops_js', (0, svg_pathops_js_1.buildPathopsBackend)(PathKit));
|
|
55
|
-
const pathopsPyPath = node_path_1.default.join(getPackageRoot(), 'src', 'core', 'shims', 'pathops.py');
|
|
56
|
-
const pathopsPy = await promises_1.default.readFile(pathopsPyPath, 'utf8');
|
|
57
|
-
py.FS.writeFile('/pathops.py', pathopsPy);
|
|
58
|
-
await py.loadPackage(['micropip', 'lxml'], { messageCallback: () => { } });
|
|
59
|
-
// Resolve local picosvg wheel path for offline-first installation.
|
|
60
|
-
const picosvgWhlDir = node_path_1.default.join(getPackageRoot(), 'src', 'core', 'shims');
|
|
61
|
-
const picosvgWhl = (await promises_1.default.readdir(picosvgWhlDir)).find((f) => f.startsWith('picosvg-') && f.endsWith('.whl'));
|
|
62
|
-
const localWhlUrl = picosvgWhl
|
|
63
|
-
? `file://${node_path_1.default.join(picosvgWhlDir, picosvgWhl)}`
|
|
64
|
-
: null;
|
|
65
|
-
py.globals.set('_picosvg_local_whl', localWhlUrl);
|
|
66
|
-
await py.runPythonAsync(`
|
|
67
|
-
import sys
|
|
68
|
-
if "/" not in sys.path:
|
|
69
|
-
sys.path.insert(0, "/")
|
|
70
|
-
|
|
71
|
-
import micropip
|
|
72
|
-
|
|
73
|
-
_whl = _picosvg_local_whl
|
|
74
|
-
if _whl:
|
|
75
|
-
try:
|
|
76
|
-
await micropip.install(_whl, deps=False)
|
|
77
|
-
except Exception:
|
|
78
|
-
await micropip.install("picosvg", deps=False)
|
|
79
|
-
else:
|
|
80
|
-
await micropip.install("picosvg", deps=False)
|
|
81
|
-
|
|
82
|
-
import pathops
|
|
83
|
-
import picosvg
|
|
84
|
-
`);
|
|
85
|
-
this.instance = py;
|
|
86
|
-
return py;
|
|
87
|
-
}
|
|
88
|
-
static async picoFromFile(hostFilePath, content) {
|
|
89
|
-
const py = await this.getInstance();
|
|
90
|
-
const svgContent = content ?? (await promises_1.default.readFile(hostFilePath, 'utf-8'));
|
|
91
|
-
py.globals.set('_svg_content', svgContent);
|
|
92
|
-
const out = py.runPython(`
|
|
93
|
-
from picosvg.svg import SVG
|
|
94
|
-
svg = SVG.fromstring(_svg_content)
|
|
95
|
-
pico = svg.topicosvg()
|
|
96
|
-
pico.tostring(pretty_print=True)
|
|
97
|
-
`);
|
|
98
|
-
return out;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.PyodideManager = PyodideManager;
|
|
102
|
-
async function picoFromFile(hostFilePath, content) {
|
|
103
|
-
return PyodideManager.picoFromFile(hostFilePath, content);
|
|
104
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.runPipeline = runPipeline;
|
|
7
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const compile_js_1 = require("../font/compile.js");
|
|
10
|
-
const managers_js_1 = require("./managers.js");
|
|
11
|
-
const config_js_1 = require("./config.js");
|
|
12
|
-
const svg_dom_js_1 = require("../svg/svg_dom.js");
|
|
13
|
-
const layers_js_1 = require("../svg/layers.js");
|
|
14
|
-
const svg_pathops_js_1 = require("../svg/svg_pathops.js");
|
|
15
|
-
/**
|
|
16
|
-
* Concatenate multiple SVG path `d` strings into a single compound path.
|
|
17
|
-
* This preserves the exact geometry of each path (no boolean operations)
|
|
18
|
-
* while combining them into one glyph. Under nonzero winding, this renders
|
|
19
|
-
* identically to drawing each path separately with the same color.
|
|
20
|
-
*/
|
|
21
|
-
function concatPathDs(ds) {
|
|
22
|
-
if (ds.length === 0)
|
|
23
|
-
return null;
|
|
24
|
-
if (ds.length === 1)
|
|
25
|
-
return ds[0];
|
|
26
|
-
return ds.join(' ');
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Merge consecutive same-color paths into single compound paths via boolean UNION.
|
|
30
|
-
* Preserves z-order: only merges runs of adjacent paths with identical fill color.
|
|
31
|
-
*/
|
|
32
|
-
function mergeSameColorPaths(paths, logger) {
|
|
33
|
-
if (paths.length <= 1)
|
|
34
|
-
return paths;
|
|
35
|
-
const result = [];
|
|
36
|
-
let i = 0;
|
|
37
|
-
while (i < paths.length) {
|
|
38
|
-
const fill = paths[i].fill;
|
|
39
|
-
// Find consecutive run of same fill that are all mergeable.
|
|
40
|
-
// Paths converted from evenodd have compound hole structure and must not
|
|
41
|
-
// be merged — their CW hole contours would cancel CCW contours from
|
|
42
|
-
// adjacent paths, producing incorrect fill.
|
|
43
|
-
let j = i + 1;
|
|
44
|
-
if (!paths[i].noMerge) {
|
|
45
|
-
while (j < paths.length &&
|
|
46
|
-
paths[j].fill === fill &&
|
|
47
|
-
!paths[j].noMerge) {
|
|
48
|
-
j++;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (j - i === 1) {
|
|
52
|
-
result.push(paths[i]);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const group = paths.slice(i, j);
|
|
56
|
-
const merged = concatPathDs(group.map((p) => p.d));
|
|
57
|
-
if (merged) {
|
|
58
|
-
logger?.info(` ⊕ Merged ${group.length} same-color paths (fill=${fill})`);
|
|
59
|
-
result.push({ d: merged, fill });
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
result.push(...group);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
i = j;
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
// Pipeline
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
/**
|
|
73
|
-
* Run the font pipeline with given config and paths.
|
|
74
|
-
* Uses the singleton Pyodide/PathKit instance (initialized on first call).
|
|
75
|
-
*/
|
|
76
|
-
async function runPipeline(config, paths, options) {
|
|
77
|
-
const startTime = Date.now();
|
|
78
|
-
const logger = options?.logger;
|
|
79
|
-
logger?.update(`Building "${config.fontFamily}"…`);
|
|
80
|
-
(0, config_js_1.ensureDir)(paths.outputDir);
|
|
81
|
-
const files = (await promises_1.default.readdir(paths.inputDir)).filter((f) => f.toLowerCase().endsWith('.svg'));
|
|
82
|
-
const glyphMap = {
|
|
83
|
-
m: {
|
|
84
|
-
f: config.fontFamily,
|
|
85
|
-
u: config.upm,
|
|
86
|
-
z: config.safeZone,
|
|
87
|
-
s: config.startUnicode,
|
|
88
|
-
...(config.linking === 'dynamic' ? { l: 'd' } : {}),
|
|
89
|
-
},
|
|
90
|
-
i: {},
|
|
91
|
-
};
|
|
92
|
-
let currentUnicode = config.startUnicode;
|
|
93
|
-
const codepointToIcon = new Map();
|
|
94
|
-
const allGlyphs = [];
|
|
95
|
-
const PathKit = await managers_js_1.PathKitManager.getInstance();
|
|
96
|
-
for (const file of files) {
|
|
97
|
-
const iconName = node_path_1.default.parse(file).name;
|
|
98
|
-
const filePath = node_path_1.default.join(paths.inputDir, file);
|
|
99
|
-
logger?.info(`Processing ${file}`);
|
|
100
|
-
const rawContent = await promises_1.default.readFile(filePath, 'utf-8');
|
|
101
|
-
const validation = (0, svg_dom_js_1.validateSvg)(rawContent);
|
|
102
|
-
if (validation.valid === false) {
|
|
103
|
-
logger?.warn(`Skipping "${config.fontFamily}:${file}": ${validation.reason}`);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const preprocessed = (0, svg_dom_js_1.preprocessSvg)(rawContent);
|
|
107
|
-
// Preserve original evenodd `d` strings BEFORE picosvg processes them.
|
|
108
|
-
// Picosvg's simplify (via our PathKit shim) can drop contours from
|
|
109
|
-
// multi-subpath evenodd paths — we restore the originals after.
|
|
110
|
-
const originalEvenoddDs = (0, svg_dom_js_1.extractOriginalEvenoddDs)(preprocessed);
|
|
111
|
-
const flattenedSvg = await (0, managers_js_1.picoFromFile)(filePath, preprocessed);
|
|
112
|
-
const parsed = (0, svg_dom_js_1.parseFlattenedSvg)(flattenedSvg, {
|
|
113
|
-
onSanitize: (original) => {
|
|
114
|
-
logger?.info(` ⚠ Sanitized path in "${file}": path was missing initial moveto (prepended M from endpoint)`);
|
|
115
|
-
logger?.info(` Original: ${original.slice(0, 80)}…`);
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
// Restore original evenodd path data (undamaged by picosvg's simplify),
|
|
119
|
-
// then convert to nonzero winding with our containment-based algorithm.
|
|
120
|
-
// Mark as noMerge — compound paths with holes must stay separate so their
|
|
121
|
-
// CW hole contours don't cancel adjacent paths' CCW contours.
|
|
122
|
-
if (originalEvenoddDs.length > 0) {
|
|
123
|
-
(0, svg_dom_js_1.restoreOriginalEvenoddDs)(parsed.paths, originalEvenoddDs);
|
|
124
|
-
}
|
|
125
|
-
for (const p of parsed.paths) {
|
|
126
|
-
if (p.fillRule === 'evenodd') {
|
|
127
|
-
logger?.info(` ↻ Converting evenodd path to nonzero winding in "${file}"`);
|
|
128
|
-
p.d = (0, svg_pathops_js_1.convertEvenoddToWinding)(PathKit, p.d);
|
|
129
|
-
delete p.fillRule;
|
|
130
|
-
p.noMerge = true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// Merge consecutive same-color paths into single compound glyphs
|
|
134
|
-
const mergedPaths = mergeSameColorPaths(parsed.paths, logger);
|
|
135
|
-
const { vx, vy, scale, xOff, yOff, adv } = (0, layers_js_1.computePlacement)({
|
|
136
|
-
upm: config.upm,
|
|
137
|
-
safeZone: config.safeZone,
|
|
138
|
-
viewBox: parsed.viewBox,
|
|
139
|
-
});
|
|
140
|
-
const layers = [];
|
|
141
|
-
for (const p of mergedPaths) {
|
|
142
|
-
if ((0, svg_dom_js_1.shouldSkipPath)(p.d, p.fill))
|
|
143
|
-
continue;
|
|
144
|
-
const cp = currentUnicode++;
|
|
145
|
-
codepointToIcon.set(cp, iconName);
|
|
146
|
-
const fontD = (0, layers_js_1.transformPathForFont)(PathKit, p.d, {
|
|
147
|
-
vx,
|
|
148
|
-
vy,
|
|
149
|
-
scale,
|
|
150
|
-
xOff,
|
|
151
|
-
yOff,
|
|
152
|
-
upm: config.upm,
|
|
153
|
-
});
|
|
154
|
-
allGlyphs.push({
|
|
155
|
-
codepoint: cp,
|
|
156
|
-
advanceWidth: adv,
|
|
157
|
-
d: fontD,
|
|
158
|
-
});
|
|
159
|
-
layers.push([cp, p.fill || 'black']);
|
|
160
|
-
}
|
|
161
|
-
if (layers.length > 0) {
|
|
162
|
-
glyphMap.i[iconName] = [adv, layers];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const glyphmapPath = node_path_1.default.join(paths.outputDir, `${config.fontFamily}.glyphmap.json`);
|
|
166
|
-
if (options?.inputHash) {
|
|
167
|
-
glyphMap.m.h = options.inputHash;
|
|
168
|
-
}
|
|
169
|
-
await promises_1.default.writeFile(glyphmapPath, JSON.stringify(glyphMap), 'utf8');
|
|
170
|
-
logger?.info(`Compiling TTF…`);
|
|
171
|
-
const ttfPath = node_path_1.default.join(paths.outputDir, `${config.fontFamily}.ttf`);
|
|
172
|
-
try {
|
|
173
|
-
await (0, compile_js_1.compileTtfFromGlyphs)({
|
|
174
|
-
glyphs: allGlyphs,
|
|
175
|
-
outTtfPath: ttfPath,
|
|
176
|
-
fontName: config.fontFamily,
|
|
177
|
-
upm: config.upm,
|
|
178
|
-
ascent: config.upm,
|
|
179
|
-
descent: 0,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
catch (err) {
|
|
183
|
-
(0, compile_js_1.parseCompileTtfFromGlyphsError)(err, codepointToIcon);
|
|
184
|
-
}
|
|
185
|
-
const iconCount = Object.keys(glyphMap.i).length;
|
|
186
|
-
const elapsed = Date.now() - startTime;
|
|
187
|
-
logger?.succeed(`Built ${config.fontFamily}.ttf [${iconCount} icon${iconCount === 1 ? '' : 's'} in ${elapsed}ms]`);
|
|
188
|
-
return { ttfPath, glyphmapPath };
|
|
189
|
-
}
|