react-native-nano-icons 0.0.0 → 0.1.0
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/LICENSE +21 -0
- package/README.md +174 -0
- package/app.plugin.js +1 -0
- package/lib/commonjs/cli/build.d.ts +28 -0
- package/lib/commonjs/cli/build.js +83 -0
- package/lib/commonjs/cli/config.d.ts +9 -0
- package/lib/commonjs/cli/config.js +25 -0
- package/lib/commonjs/cli/index.d.ts +4 -0
- package/lib/commonjs/cli/index.js +13 -0
- package/lib/commonjs/cli/link.d.ts +11 -0
- package/lib/commonjs/cli/link.js +135 -0
- package/lib/commonjs/cli/logger.d.ts +27 -0
- package/lib/commonjs/cli/logger.js +83 -0
- package/lib/commonjs/index.node.js +8 -0
- package/lib/commonjs/plugin/src/buildFonts.d.ts +7 -0
- package/lib/commonjs/plugin/src/buildFonts.js +23 -0
- package/lib/commonjs/plugin/src/index.d.ts +5 -0
- package/lib/commonjs/plugin/src/index.js +43 -0
- package/lib/commonjs/plugin/src/types.d.ts +31 -0
- package/lib/commonjs/plugin/src/types.js +2 -0
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +14 -0
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +92 -0
- package/lib/commonjs/scripts/cli.js +28 -0
- package/lib/commonjs/src/const/colors.d.ts +1 -0
- package/lib/commonjs/src/const/colors.js +153 -0
- package/lib/commonjs/src/core/font/compile.d.ts +9 -0
- package/lib/commonjs/src/core/font/compile.js +68 -0
- package/lib/commonjs/src/core/font/metrics.d.ts +1 -0
- package/lib/commonjs/src/core/font/metrics.js +33 -0
- package/lib/commonjs/src/core/pipeline/config.d.ts +14 -0
- package/lib/commonjs/src/core/pipeline/config.js +17 -0
- package/lib/commonjs/src/core/pipeline/index.d.ts +3 -0
- package/lib/commonjs/src/core/pipeline/index.js +7 -0
- package/lib/commonjs/src/core/pipeline/managers.d.ts +11 -0
- package/lib/commonjs/src/core/pipeline/managers.js +89 -0
- package/lib/commonjs/src/core/pipeline/run.d.ts +14 -0
- package/lib/commonjs/src/core/pipeline/run.js +99 -0
- package/lib/commonjs/src/core/svg/layers.d.ts +24 -0
- package/lib/commonjs/src/core/svg/layers.js +42 -0
- package/lib/commonjs/src/core/svg/svg_dom.d.ts +22 -0
- package/lib/commonjs/src/core/svg/svg_dom.js +84 -0
- package/lib/commonjs/src/core/svg/svg_pathops.d.ts +21 -0
- package/lib/commonjs/src/core/svg/svg_pathops.js +611 -0
- package/lib/commonjs/src/core/types.d.ts +120 -0
- package/lib/commonjs/src/core/types.js +2 -0
- package/lib/commonjs/src/utils/fingerPrint.d.ts +1 -0
- package/lib/commonjs/src/utils/fingerPrint.js +20 -0
- package/lib/commonjs/src/utils/parse.d.ts +2 -0
- package/lib/commonjs/src/utils/parse.js +64 -0
- package/lib/module/const/colors.js +153 -0
- package/lib/module/const/colors.js.map +1 -0
- package/lib/module/core/font/compile.js +70 -0
- package/lib/module/core/font/compile.js.map +1 -0
- package/lib/module/core/font/metrics.js +37 -0
- package/lib/module/core/font/metrics.js.map +1 -0
- package/lib/module/core/pipeline/config.js +20 -0
- package/lib/module/core/pipeline/config.js.map +1 -0
- package/lib/module/core/pipeline/index.js +5 -0
- package/lib/module/core/pipeline/index.js.map +1 -0
- package/lib/module/core/pipeline/managers.js +80 -0
- package/lib/module/core/pipeline/managers.js.map +1 -0
- package/lib/module/core/pipeline/run.js +114 -0
- package/lib/module/core/pipeline/run.js.map +1 -0
- package/lib/module/core/shims/pathops.py +181 -0
- package/lib/module/core/svg/layers.js +51 -0
- package/lib/module/core/svg/layers.js.map +1 -0
- package/lib/module/core/svg/svg_dom.js +83 -0
- package/lib/module/core/svg/svg_dom.js.map +1 -0
- package/lib/module/core/svg/svg_pathops.js +566 -0
- package/lib/module/core/svg/svg_pathops.js.map +1 -0
- package/lib/module/core/tsconfig.json +32 -0
- package/lib/module/core/types.js +2 -0
- package/lib/module/core/types.js.map +1 -0
- package/lib/module/createNanoIconsSet.js +84 -0
- package/lib/module/createNanoIconsSet.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.node.js +13 -0
- package/lib/module/index.node.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/utils/fingerPrint.js +17 -0
- package/lib/module/utils/fingerPrint.js.map +1 -0
- package/lib/module/utils/parse.js +53 -0
- package/lib/module/utils/parse.js.map +1 -0
- package/lib/typescript/__tests__/build.unit.test.d.ts +3 -0
- package/lib/typescript/__tests__/build.unit.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/clippath.e2e.test.d.ts +3 -0
- package/lib/typescript/__tests__/clippath.e2e.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/fingerprint.unit.test.d.ts +3 -0
- package/lib/typescript/__tests__/fingerprint.unit.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/pipeline.e2e.test.d.ts +3 -0
- package/lib/typescript/__tests__/pipeline.e2e.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/placement.unit.test.d.ts +3 -0
- package/lib/typescript/__tests__/placement.unit.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/svg_dom.unit.test.d.ts +3 -0
- package/lib/typescript/__tests__/svg_dom.unit.test.d.ts.map +1 -0
- package/lib/typescript/cli/build.d.ts +29 -0
- package/lib/typescript/cli/build.d.ts.map +1 -0
- package/lib/typescript/cli/logger.d.ts +28 -0
- package/lib/typescript/cli/logger.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/const/colors.d.ts +2 -0
- package/lib/typescript/src/const/colors.d.ts.map +1 -0
- package/lib/typescript/src/core/font/compile.d.ts +10 -0
- package/lib/typescript/src/core/font/compile.d.ts.map +1 -0
- package/lib/typescript/src/core/font/metrics.d.ts +2 -0
- package/lib/typescript/src/core/font/metrics.d.ts.map +1 -0
- package/lib/typescript/src/core/pipeline/config.d.ts +15 -0
- package/lib/typescript/src/core/pipeline/config.d.ts.map +1 -0
- package/lib/typescript/src/core/pipeline/index.d.ts +4 -0
- package/lib/typescript/src/core/pipeline/index.d.ts.map +1 -0
- package/lib/typescript/src/core/pipeline/managers.d.ts +12 -0
- package/lib/typescript/src/core/pipeline/managers.d.ts.map +1 -0
- package/lib/typescript/src/core/pipeline/run.d.ts +15 -0
- package/lib/typescript/src/core/pipeline/run.d.ts.map +1 -0
- package/lib/typescript/src/core/svg/layers.d.ts +25 -0
- package/lib/typescript/src/core/svg/layers.d.ts.map +1 -0
- package/lib/typescript/src/core/svg/svg_dom.d.ts +23 -0
- package/lib/typescript/src/core/svg/svg_dom.d.ts.map +1 -0
- package/lib/typescript/src/core/svg/svg_pathops.d.ts +22 -0
- package/lib/typescript/src/core/svg/svg_pathops.d.ts.map +1 -0
- package/lib/typescript/src/core/types.d.ts +121 -0
- package/lib/typescript/src/core/types.d.ts.map +1 -0
- package/lib/typescript/src/createNanoIconsSet.d.ts +19 -0
- package/lib/typescript/src/createNanoIconsSet.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/index.node.d.ts +2 -0
- package/lib/typescript/src/index.node.d.ts.map +1 -0
- package/lib/typescript/src/utils/fingerPrint.d.ts +2 -0
- package/lib/typescript/src/utils/fingerPrint.d.ts.map +1 -0
- package/lib/typescript/src/utils/parse.d.ts +3 -0
- package/lib/typescript/src/utils/parse.d.ts.map +1 -0
- package/package.json +160 -1
- package/plugin/src/buildFonts.ts +29 -0
- package/plugin/src/index.ts +68 -0
- package/plugin/src/types.ts +33 -0
- package/plugin/src/withNanoIconsFontLinking.ts +119 -0
- package/plugin/tsconfig.json +9 -0
- package/scripts/cli.ts +34 -0
- package/scripts/tsconfig.json +25 -0
- package/src/const/colors.ts +150 -0
- package/src/core/font/compile.ts +96 -0
- package/src/core/font/metrics.ts +44 -0
- package/src/core/pipeline/config.ts +24 -0
- package/src/core/pipeline/index.ts +3 -0
- package/src/core/pipeline/managers.ts +114 -0
- package/src/core/pipeline/run.ts +151 -0
- package/src/core/shims/pathops.py +181 -0
- package/src/core/svg/layers.ts +66 -0
- package/src/core/svg/svg_dom.ts +99 -0
- package/src/core/svg/svg_pathops.ts +796 -0
- package/src/core/tsconfig.json +32 -0
- package/src/core/types.ts +138 -0
- package/src/createNanoIconsSet.tsx +131 -0
- package/src/index.node.ts +14 -0
- package/src/index.ts +7 -0
- package/src/utils/fingerPrint.ts +20 -0
- package/src/utils/parse.ts +67 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export type NanoLogger = {
|
|
2
|
+
start: (msg: string) => void;
|
|
3
|
+
update: (msg: string) => void;
|
|
4
|
+
succeed: (msg: string) => void;
|
|
5
|
+
fail: (msg: string) => void;
|
|
6
|
+
/** Only printed when level is 'verbose'. */
|
|
7
|
+
info: (msg: string) => void;
|
|
8
|
+
warn: (msg: string) => void;
|
|
9
|
+
};
|
|
10
|
+
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
|
+
export type GlyphLayer = {
|
|
103
|
+
codepoint: number;
|
|
104
|
+
color: string;
|
|
105
|
+
};
|
|
106
|
+
export type GlyphEntry = {
|
|
107
|
+
adv: number;
|
|
108
|
+
layers: GlyphLayer[];
|
|
109
|
+
};
|
|
110
|
+
export type IconsMap = Record<string, GlyphEntry>;
|
|
111
|
+
export type NanoGlyphMap = {
|
|
112
|
+
meta: {
|
|
113
|
+
fontFamily: string;
|
|
114
|
+
upm: number;
|
|
115
|
+
safeZone: number;
|
|
116
|
+
startUnicode: number;
|
|
117
|
+
hash?: string;
|
|
118
|
+
};
|
|
119
|
+
icons: IconsMap;
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,MAA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CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;KACvC,KACE,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,EAAE,EAAE;QAAE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;IACxD,OAAO,EAAE;QACP,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QAC3C,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;KAC/B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9D,MAAM,MAAM,UAAU,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC;AAC/D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAClD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,KAAK,EAAE,QAAQ,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ComponentRef, type Ref } from 'react';
|
|
2
|
+
import { View, type ColorValue, type TextProps } from 'react-native';
|
|
3
|
+
import type { NanoGlyphMap } from './core/types';
|
|
4
|
+
type ViewRef = ComponentRef<typeof View>;
|
|
5
|
+
export type IconProps<Name> = TextProps & {
|
|
6
|
+
name: Name;
|
|
7
|
+
size?: number;
|
|
8
|
+
colorPalette?: ColorValue[];
|
|
9
|
+
innerRef?: Ref<ViewRef>;
|
|
10
|
+
};
|
|
11
|
+
export type IconComponent<GM extends NanoGlyphMap> = React.FC<TextProps & {
|
|
12
|
+
name: keyof GM['icons'];
|
|
13
|
+
size?: number;
|
|
14
|
+
colorPalette?: ColorValue[];
|
|
15
|
+
innerRef?: Ref<ViewRef>;
|
|
16
|
+
} & React.RefAttributes<ViewRef>>;
|
|
17
|
+
export declare function createIconSet<GM extends NanoGlyphMap>(glyphMap: GM): IconComponent<GM>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=createNanoIconsSet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNanoIconsSet.d.ts","sourceRoot":"","sources":["../../../src/createNanoIconsSet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAGL,IAAI,EAEJ,KAAK,UAAU,EACf,KAAK,SAAS,EAEf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAc,YAAY,EAAE,MAAM,cAAc,CAAC;AAI7D,KAAK,OAAO,GAAG,YAAY,CAAC,OAAO,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,SAAS,CAAC,IAAI,IAAI,SAAS,GAAG;IACxC,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,EAAE,SAAS,YAAY,IAAI,KAAK,CAAC,EAAE,CAC3D,SAAS,GAAG;IACV,IAAI,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CACzB,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CACjC,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,SAAS,YAAY,EACnD,QAAQ,EAAE,EAAE,GACX,aAAa,CAAC,EAAE,CAAC,CAgGnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,IAAI,iBAAiB,EAClC,KAAK,aAAa,EAClB,KAAK,SAAS,GACf,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../../src/index.node.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerPrint.d.ts","sourceRoot":"","sources":["../../../../src/utils/fingerPrint.ts"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAetD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../src/utils/parse.ts"],"names":[],"mappings":"AAGA,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAInE;AAGD,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,GACZ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAsD9C"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,163 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nano-icons",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Use any svg as font. High-performance, build-time icon font generation for React Native & Expo.",
|
|
5
|
+
"react-native": "src/index.ts",
|
|
6
|
+
"source": "src/index.ts",
|
|
7
|
+
"bin": "lib/commonjs/scripts/cli.js",
|
|
8
|
+
"main": "./lib/commonjs/index.node.js",
|
|
9
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"app.plugin.js",
|
|
12
|
+
"src/core/shims",
|
|
13
|
+
"bin",
|
|
14
|
+
"src",
|
|
15
|
+
"lib",
|
|
16
|
+
"plugin",
|
|
17
|
+
"scripts"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "yarn build:node-entry && bob build && yarn build:core && yarn build:cli && yarn build:plugin && yarn build:scripts",
|
|
21
|
+
"build:node-entry": "tsc -p tsconfig.node.json",
|
|
22
|
+
"build:core": "tsc -p src/core/tsconfig.json",
|
|
23
|
+
"build:cli": "tsc -p cli/tsconfig.json",
|
|
24
|
+
"build:plugin": "tsc -p plugin/tsconfig.json",
|
|
25
|
+
"build:scripts": "tsc -p scripts/tsconfig.json",
|
|
26
|
+
"clean": "del-cli lib",
|
|
27
|
+
"prepare": "yarn build",
|
|
28
|
+
"typecheck": "tsc",
|
|
29
|
+
"ts-check": "tsc --noEmit",
|
|
30
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
31
|
+
"lint-js": "eslint 'src/**/*.{js,ts,tsx}' && prettier --check 'src/**/*.{js,jsx,ts,tsx}'",
|
|
32
|
+
"format-js": "prettier --write --list-different 'src/**/*.{js,jsx,ts,tsx}'",
|
|
33
|
+
"test": "jest",
|
|
34
|
+
"postinstall": "patch-package"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@expo/config-plugins": ">=9.0.0",
|
|
38
|
+
"chalk": "^5.6.2",
|
|
39
|
+
"fonteditor-core": "^2.6.3",
|
|
40
|
+
"jsdom": "^28.1.0",
|
|
41
|
+
"ora": "^9.3.0",
|
|
42
|
+
"pathkit-wasm": "^1.0.0",
|
|
43
|
+
"plist": "^3.0.5",
|
|
44
|
+
"pyodide": "^0.29.3",
|
|
45
|
+
"svg2ttf": "^6.0.3",
|
|
46
|
+
"svgicons2svgfont": "^15.0.1",
|
|
47
|
+
"xcode": "^3.0.1"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"expo": "*",
|
|
51
|
+
"react": "*",
|
|
52
|
+
"react-native": "*"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@expo/config-plugins": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"expo": {
|
|
59
|
+
"optional": true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@react-native/babel-preset": "0.83.0",
|
|
64
|
+
"@types/jest": "^29.5.14",
|
|
65
|
+
"@types/node": "^25.2.3",
|
|
66
|
+
"@types/plist": "^3.0.5",
|
|
67
|
+
"@types/react": "~19.1.0",
|
|
68
|
+
"@types/svg2ttf": "^5.0.3",
|
|
69
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
70
|
+
"del-cli": "^6.0.0",
|
|
71
|
+
"expo-module-scripts": "^5.0.8",
|
|
72
|
+
"jest": "^29.7.0",
|
|
73
|
+
"patch-package": "^8.0.0",
|
|
74
|
+
"react": "19.1.0",
|
|
75
|
+
"react-native": "^0.84.0",
|
|
76
|
+
"react-native-builder-bob": "^0.40.18",
|
|
77
|
+
"typescript": "^5.9.3"
|
|
78
|
+
},
|
|
79
|
+
"exports": {
|
|
80
|
+
".": {
|
|
81
|
+
"source": "./src/index.tsx",
|
|
82
|
+
"require": {
|
|
83
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
84
|
+
"default": "./lib/commonjs/index.node.js"
|
|
85
|
+
},
|
|
86
|
+
"import": {
|
|
87
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
88
|
+
"default": "./lib/module/index.js"
|
|
89
|
+
},
|
|
90
|
+
"default": "./lib/commonjs/index.node.js"
|
|
91
|
+
},
|
|
92
|
+
"./cli": {
|
|
93
|
+
"source": "./cli/index.ts",
|
|
94
|
+
"types": "./lib/commonjs/cli/index.d.ts",
|
|
95
|
+
"require": {
|
|
96
|
+
"default": "./lib/commonjs/cli/index.js"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"./pipeline": {
|
|
100
|
+
"source": "./src/core/pipeline/index.ts",
|
|
101
|
+
"require": {
|
|
102
|
+
"types": "./lib/commonjs/src/core/pipeline/index.d.ts",
|
|
103
|
+
"default": "./lib/commonjs/src/core/pipeline/index.js"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"./app.plugin": "./app.plugin.js",
|
|
107
|
+
"./app.plugin.js": "./app.plugin.js",
|
|
108
|
+
"./package.json": "./package.json"
|
|
109
|
+
},
|
|
110
|
+
"keywords": [
|
|
111
|
+
"react-native",
|
|
112
|
+
"expo",
|
|
113
|
+
"react-native-nano-icons",
|
|
114
|
+
"ExpoNanoIcons",
|
|
115
|
+
"RNNanoIcons",
|
|
116
|
+
"ReactNativeNanoIcons",
|
|
117
|
+
"svg-to-ttf",
|
|
118
|
+
"svg2font",
|
|
119
|
+
"svg-to-font",
|
|
120
|
+
"svg-to-ttf",
|
|
121
|
+
"svg-to-glyph"
|
|
122
|
+
],
|
|
123
|
+
"repository": "https://github.com/software-mansion-labs/react-native-nano-icons",
|
|
124
|
+
"bugs": {
|
|
125
|
+
"url": "https://github.com/software-mansion-labs/react-native-nano-icons/issues"
|
|
126
|
+
},
|
|
127
|
+
"author": "Stanisław Białecki <stanislaw.bialecki@swmansion.com> (https://github.com/stachbial)",
|
|
128
|
+
"license": "MIT",
|
|
129
|
+
"homepage": "https://github.com/software-mansion-labs/react-native-nano-icons#readme",
|
|
130
|
+
"publishConfig": {
|
|
131
|
+
"registry": "https://registry.npmjs.org/"
|
|
132
|
+
},
|
|
133
|
+
"packageManager": "yarn@4.11.0",
|
|
134
|
+
"react-native-builder-bob": {
|
|
135
|
+
"source": "src",
|
|
136
|
+
"output": "lib",
|
|
137
|
+
"targets": [
|
|
138
|
+
[
|
|
139
|
+
"module",
|
|
140
|
+
{
|
|
141
|
+
"esm": true
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
"typescript",
|
|
146
|
+
{
|
|
147
|
+
"project": "tsconfig.build.json"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
"create-react-native-library": {
|
|
153
|
+
"type": "library",
|
|
154
|
+
"languages": "js",
|
|
155
|
+
"tools": [
|
|
156
|
+
"eslint",
|
|
157
|
+
"jest",
|
|
158
|
+
"lefthook",
|
|
159
|
+
"release-it"
|
|
160
|
+
],
|
|
161
|
+
"version": "0.57.2"
|
|
162
|
+
}
|
|
4
163
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildAllFonts as coreBuildAllFonts,
|
|
3
|
+
createQuietLogger,
|
|
4
|
+
detectExpoLogLevel,
|
|
5
|
+
} from '../../cli/index.js';
|
|
6
|
+
import type { IconSetConfig, BuiltFont } from './types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Build TTF + glyphmap for all icon sets.
|
|
10
|
+
* Shows an ora spinner per font set; catches errors and displays a friendly message
|
|
11
|
+
* unless EXPO_DEBUG is set, in which case the full error is re-thrown.
|
|
12
|
+
*/
|
|
13
|
+
export async function buildAllFonts(
|
|
14
|
+
iconSets: IconSetConfig[],
|
|
15
|
+
projectRoot: string
|
|
16
|
+
): Promise<BuiltFont[]> {
|
|
17
|
+
const level = detectExpoLogLevel();
|
|
18
|
+
const logger = await createQuietLogger(level);
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
return await coreBuildAllFonts(iconSets, projectRoot, { logger });
|
|
22
|
+
} catch (err: unknown) {
|
|
23
|
+
if (level === 'verbose') {
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
logger.fail('Error optimizing icons. Run with EXPO_DEBUG=1 for more logs.');
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ConfigPlugin,
|
|
3
|
+
ExportedConfigWithProps,
|
|
4
|
+
} from '@expo/config-plugins';
|
|
5
|
+
import { withDangerousMod } from '@expo/config-plugins';
|
|
6
|
+
import { buildAllFonts } from './buildFonts.js';
|
|
7
|
+
import { withNanoIconsFontLinking } from './withNanoIconsFontLinking.js';
|
|
8
|
+
import type {
|
|
9
|
+
NanoIconsPluginOptions,
|
|
10
|
+
IconSetConfig,
|
|
11
|
+
BuiltFont,
|
|
12
|
+
} from './types.js';
|
|
13
|
+
|
|
14
|
+
const BUILT_FONTS_KEY = '_nanoIconsBuilt';
|
|
15
|
+
|
|
16
|
+
// Single Pyodide/PathKit run for the whole prebuild; reused across ios/android mods.
|
|
17
|
+
let _builtFontsCache: BuiltFont[] | null = null;
|
|
18
|
+
|
|
19
|
+
function getOrBuildFonts(
|
|
20
|
+
projectRoot: string,
|
|
21
|
+
iconSets: IconSetConfig[]
|
|
22
|
+
): Promise<BuiltFont[]> {
|
|
23
|
+
if (_builtFontsCache) return Promise.resolve(_builtFontsCache);
|
|
24
|
+
return buildAllFonts(iconSets, projectRoot).then((built: BuiltFont[]) => {
|
|
25
|
+
_builtFontsCache = built;
|
|
26
|
+
return built;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const withNanoIcons: ConfigPlugin<NanoIconsPluginOptions> = (
|
|
31
|
+
config,
|
|
32
|
+
options
|
|
33
|
+
) => {
|
|
34
|
+
if (!options?.iconSets?.length) return config;
|
|
35
|
+
|
|
36
|
+
// Build fonts (once per process, cached) and attach to config for linking mods.
|
|
37
|
+
config = withDangerousMod(config, [
|
|
38
|
+
'ios',
|
|
39
|
+
async (config: ExportedConfigWithProps<unknown>) => {
|
|
40
|
+
const projectRoot = config.modRequest.projectRoot;
|
|
41
|
+
const built = await getOrBuildFonts(projectRoot, options.iconSets);
|
|
42
|
+
(config as unknown as Record<string, unknown>)[BUILT_FONTS_KEY] = built;
|
|
43
|
+
return config;
|
|
44
|
+
},
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
config = withDangerousMod(config, [
|
|
48
|
+
'android',
|
|
49
|
+
async (config: ExportedConfigWithProps<unknown>) => {
|
|
50
|
+
const projectRoot = config.modRequest.projectRoot;
|
|
51
|
+
const built = await getOrBuildFonts(projectRoot, options.iconSets);
|
|
52
|
+
(config as unknown as Record<string, unknown>)[BUILT_FONTS_KEY] = built;
|
|
53
|
+
return config;
|
|
54
|
+
},
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
// Link built TTFs into native projects (reads _nanoIconsBuilt from config).
|
|
58
|
+
config = withNanoIconsFontLinking(config);
|
|
59
|
+
|
|
60
|
+
return config;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default withNanoIcons;
|
|
64
|
+
export type {
|
|
65
|
+
NanoIconsPluginOptions,
|
|
66
|
+
IconSetConfig,
|
|
67
|
+
BuiltFont,
|
|
68
|
+
} from './types.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config for one icon set: input SVGs → one TTF + glyphmap.
|
|
3
|
+
*/
|
|
4
|
+
export interface IconSetConfig {
|
|
5
|
+
/** Path to folder of SVG files (relative to project root). */
|
|
6
|
+
inputDir: string;
|
|
7
|
+
/** Font family name (used for TTF and glyphmap filenames). */
|
|
8
|
+
fontFamily: string;
|
|
9
|
+
/** Path where .ttf and .glyphmap.json will be saved. Defaults to a sibling nanoicons folder relative to inputDir. */
|
|
10
|
+
outputDir?: string;
|
|
11
|
+
/** Units per em (default 1024). */
|
|
12
|
+
upm?: number;
|
|
13
|
+
/** Safe zone inside UPM for glyphs (default 1020). */
|
|
14
|
+
safeZone?: number;
|
|
15
|
+
/** First Unicode codepoint for glyphs (default 0xe900). Hex string or number. */
|
|
16
|
+
startUnicode?: number | string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* plugins: [ [ "react-native-nano-icons", { iconSets: [...] } ] ]
|
|
21
|
+
*/
|
|
22
|
+
export interface NanoIconsPluginOptions {
|
|
23
|
+
iconSets: IconSetConfig[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Result of building one icon set.
|
|
28
|
+
*/
|
|
29
|
+
export interface BuiltFont {
|
|
30
|
+
fontFamily: string;
|
|
31
|
+
ttfPath: string;
|
|
32
|
+
glyphmapPath: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IOSConfig,
|
|
3
|
+
withInfoPlist,
|
|
4
|
+
withXcodeProject,
|
|
5
|
+
withDangerousMod,
|
|
6
|
+
} from '@expo/config-plugins';
|
|
7
|
+
import fs from 'fs/promises';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import type { BuiltFont } from './types.js';
|
|
10
|
+
type InfoPlist = Record<string, unknown>;
|
|
11
|
+
|
|
12
|
+
const ANDROID_ASSETS_FONTS_DIR = 'app/src/main/assets/fonts';
|
|
13
|
+
|
|
14
|
+
const BUILT_FONTS_KEY = '_nanoIconsBuilt' as const;
|
|
15
|
+
|
|
16
|
+
function getBuiltFonts(config: {
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}): BuiltFont[] | undefined {
|
|
19
|
+
return config[BUILT_FONTS_KEY] as BuiltFont[] | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Add TTFs to the iOS project (Resources group + UIAppFonts in Info.plist).
|
|
24
|
+
* Reads cached built font paths from config._nanoIconsBuilt (set by the build mod) to prevent redundant builds for iOS and Android.
|
|
25
|
+
*/
|
|
26
|
+
export function withNanoIconsIos(
|
|
27
|
+
config: Parameters<typeof withXcodeProject>[0]
|
|
28
|
+
): ReturnType<typeof withXcodeProject> {
|
|
29
|
+
config = withXcodeProject(config, async (config) => {
|
|
30
|
+
const built = getBuiltFonts(
|
|
31
|
+
config as unknown as { [key: string]: unknown }
|
|
32
|
+
);
|
|
33
|
+
if (!built?.length) return config;
|
|
34
|
+
const ttfPaths = built.map((b) => b.ttfPath);
|
|
35
|
+
const project = config.modResults;
|
|
36
|
+
const platformProjectRoot = config.modRequest.platformProjectRoot;
|
|
37
|
+
IOSConfig.XcodeUtils.ensureGroupRecursively(project, 'Resources');
|
|
38
|
+
for (const fontPath of ttfPaths) {
|
|
39
|
+
const relativePath = path.relative(platformProjectRoot, fontPath);
|
|
40
|
+
IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
41
|
+
filepath: relativePath,
|
|
42
|
+
groupName: 'Resources',
|
|
43
|
+
project,
|
|
44
|
+
isBuildFile: true,
|
|
45
|
+
verbose: true,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return config;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
config = withInfoPlist(
|
|
52
|
+
config as Parameters<typeof withInfoPlist>[0],
|
|
53
|
+
async (config) => {
|
|
54
|
+
const built = getBuiltFonts(
|
|
55
|
+
config as unknown as { [key: string]: unknown }
|
|
56
|
+
);
|
|
57
|
+
if (!built?.length) return config;
|
|
58
|
+
const ttfPaths = built.map((b) => b.ttfPath);
|
|
59
|
+
const existingFonts = getUIAppFonts(config.modResults);
|
|
60
|
+
const fontList = ttfPaths.map((f) => path.basename(f));
|
|
61
|
+
const allFonts = [...existingFonts, ...fontList];
|
|
62
|
+
config.modResults.UIAppFonts = Array.from(new Set(allFonts));
|
|
63
|
+
return config;
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return config;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function getUIAppFonts(infoPlist: InfoPlist): string[] {
|
|
71
|
+
const fonts = infoPlist['UIAppFonts'];
|
|
72
|
+
if (
|
|
73
|
+
fonts != null &&
|
|
74
|
+
Array.isArray(fonts) &&
|
|
75
|
+
fonts.every((font) => typeof font === 'string')
|
|
76
|
+
) {
|
|
77
|
+
return fonts as string[];
|
|
78
|
+
}
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Copy TTFs to Android assets/fonts. Reads paths from config._nanoIconsBuilt.
|
|
84
|
+
*/
|
|
85
|
+
export function withNanoIconsAndroid(
|
|
86
|
+
config: Parameters<typeof withDangerousMod>[0]
|
|
87
|
+
): ReturnType<typeof withDangerousMod> {
|
|
88
|
+
return withDangerousMod(config, [
|
|
89
|
+
'android',
|
|
90
|
+
async (config) => {
|
|
91
|
+
const built = getBuiltFonts(
|
|
92
|
+
config as unknown as { [key: string]: unknown }
|
|
93
|
+
);
|
|
94
|
+
if (!built?.length) return config;
|
|
95
|
+
const fontsDir = path.join(
|
|
96
|
+
config.modRequest.platformProjectRoot,
|
|
97
|
+
ANDROID_ASSETS_FONTS_DIR
|
|
98
|
+
);
|
|
99
|
+
await fs.mkdir(fontsDir, { recursive: true });
|
|
100
|
+
for (const b of built) {
|
|
101
|
+
const filename = path.basename(b.ttfPath);
|
|
102
|
+
const dest = path.join(fontsDir, filename);
|
|
103
|
+
await fs.copyFile(b.ttfPath, dest);
|
|
104
|
+
}
|
|
105
|
+
return config;
|
|
106
|
+
},
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Apply iOS and Android font linking. Built font list is read from config (set by build mod).
|
|
112
|
+
*/
|
|
113
|
+
export function withNanoIconsFontLinking(
|
|
114
|
+
config: Parameters<typeof withNanoIconsIos>[0]
|
|
115
|
+
): ReturnType<typeof withNanoIconsAndroid> {
|
|
116
|
+
config = withNanoIconsIos(config);
|
|
117
|
+
config = withNanoIconsAndroid(config);
|
|
118
|
+
return config;
|
|
119
|
+
}
|
package/scripts/cli.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Bare React Native workflow: build icon fonts and link them into the native project.
|
|
4
|
+
*
|
|
5
|
+
* Run from your app root: npx react-native-nano-icons [--verbose]
|
|
6
|
+
*
|
|
7
|
+
* Reads .nanoicons.json (same shape as Expo plugin options) so Expo and bare apps
|
|
8
|
+
* share one config format.
|
|
9
|
+
*
|
|
10
|
+
* Flags:
|
|
11
|
+
* --verbose Show per-SVG processing details and pipeline timing
|
|
12
|
+
*/
|
|
13
|
+
import {
|
|
14
|
+
createOraLogger,
|
|
15
|
+
loadNanoIconsConfig,
|
|
16
|
+
buildAllFonts,
|
|
17
|
+
linkBare,
|
|
18
|
+
} from '../cli/index.js';
|
|
19
|
+
|
|
20
|
+
async function main(): Promise<void> {
|
|
21
|
+
const verbose = process.argv.includes('--verbose');
|
|
22
|
+
const level = verbose ? 'verbose' : 'normal';
|
|
23
|
+
|
|
24
|
+
const logger = await createOraLogger(level);
|
|
25
|
+
const config = loadNanoIconsConfig(process.cwd());
|
|
26
|
+
const built = await buildAllFonts(config.iconSets, process.cwd(), { logger });
|
|
27
|
+
await linkBare(process.cwd(), built, logger);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main().catch((err: unknown) => {
|
|
31
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
32
|
+
console.error(message);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "..",
|
|
4
|
+
"outDir": "../lib/commonjs",
|
|
5
|
+
|
|
6
|
+
"target": "ES2022",
|
|
7
|
+
"module": "NodeNext",
|
|
8
|
+
"moduleResolution": "NodeNext",
|
|
9
|
+
|
|
10
|
+
"lib": ["ES2022"],
|
|
11
|
+
"types": ["node"],
|
|
12
|
+
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
|
|
17
|
+
"noEmit": false,
|
|
18
|
+
"declaration": false,
|
|
19
|
+
|
|
20
|
+
"sourceMap": false,
|
|
21
|
+
"inlineSources": false
|
|
22
|
+
},
|
|
23
|
+
"include": ["./**/*.ts"],
|
|
24
|
+
"exclude": ["**/*.test.ts", "**/__tests__/**"]
|
|
25
|
+
}
|