react-native-nano-icons 1.0.0 → 1.1.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/README.md +137 -21
- package/android/src/main/java/com/nanoicons/NanoIconFonts.kt +15 -0
- package/android/src/main/java/com/nanoicons/NanoIconView.kt +27 -4
- package/android/src/main/java/com/nanoicons/NanoIconViewManager.kt +9 -2
- package/android/src/main/java/com/nanoicons/NanoIconsFontLoaderModule.kt +3 -0
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconProps.cpp +122 -0
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconProps.h +60 -0
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.cpp +0 -39
- package/common/cpp/react/renderer/components/RNNanoIconsSpec/NanoIconViewShadowNode.h +2 -16
- package/ios/NanoIconView.mm +17 -5
- package/ios/NanoIconsFontLoader.mm +5 -0
- package/lib/commonjs/cli/build.d.ts +26 -0
- package/lib/commonjs/cli/build.js +174 -64
- package/lib/commonjs/cli/buildSymbols.d.ts +17 -0
- package/lib/commonjs/cli/buildSymbols.js +103 -42
- package/lib/commonjs/cli/expoConfig.d.ts +10 -0
- package/lib/commonjs/cli/expoConfig.js +22 -7
- package/lib/commonjs/cli/fingerprint.d.ts +15 -0
- package/lib/commonjs/cli/fingerprint.js +36 -0
- package/lib/commonjs/cli/index.d.ts +2 -2
- package/lib/commonjs/cli/index.js +3 -1
- package/lib/commonjs/cli/link.d.ts +4 -0
- package/lib/commonjs/cli/link.js +25 -0
- package/lib/commonjs/cli/sameOutputs.d.ts +5 -0
- package/lib/commonjs/cli/sameOutputs.js +45 -0
- package/lib/commonjs/index.node.js +1 -1
- package/lib/commonjs/plugin/src/buildFonts.d.ts +3 -2
- package/lib/commonjs/plugin/src/buildFonts.js +11 -3
- package/lib/commonjs/plugin/src/buildSymbols.d.ts +2 -2
- package/lib/commonjs/plugin/src/buildSymbols.js +10 -3
- package/lib/commonjs/plugin/src/frozen.d.ts +3 -0
- package/lib/commonjs/plugin/src/frozen.js +18 -0
- package/lib/commonjs/plugin/src/index.js +3 -3
- package/lib/commonjs/plugin/src/types.d.ts +10 -0
- package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.d.ts +1 -1
- package/lib/commonjs/plugin/src/withNanoIconsDrawableLinking.js +2 -2
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.d.ts +3 -3
- package/lib/commonjs/plugin/src/withNanoIconsFontLinking.js +8 -8
- package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.d.ts +1 -1
- package/lib/commonjs/plugin/src/withNanoIconsSymbolLinking.js +2 -2
- package/lib/commonjs/scripts/cli.js +31 -2
- package/lib/commonjs/src/core/flatten/dom.js +40 -5
- package/lib/commonjs/src/core/flatten/element.js +2 -1
- package/lib/commonjs/src/core/flatten/stages/collapse.js +12 -0
- package/lib/commonjs/src/core/font/compile.d.ts +0 -1
- package/lib/commonjs/src/core/font/compile.js +2 -8
- package/lib/commonjs/src/core/glyph/merge.d.ts +2 -1
- package/lib/commonjs/src/core/glyph/merge.js +27 -36
- package/lib/commonjs/src/core/glyph/parse.d.ts +1 -2
- package/lib/commonjs/src/core/glyph/parse.js +31 -18
- package/lib/commonjs/src/core/pathkit/winding.d.ts +7 -1
- package/lib/commonjs/src/core/pathkit/winding.js +172 -0
- package/lib/commonjs/src/core/pipeline/config.d.ts +1 -0
- package/lib/commonjs/src/core/pipeline/prepare.d.ts +1 -1
- package/lib/commonjs/src/core/pipeline/prepare.js +3 -16
- package/lib/commonjs/src/core/pipeline/prepareIcon.d.ts +1 -0
- package/lib/commonjs/src/core/pipeline/prepareIcon.js +1 -1
- package/lib/commonjs/src/core/pipeline/preparedSvgCache.js +1 -1
- package/lib/commonjs/src/core/pipeline/runFontPipeline.js +20 -12
- package/lib/commonjs/src/core/symbols/knockout.js +4 -3
- package/lib/commonjs/src/utils/fingerPrint.d.ts +1 -0
- package/lib/commonjs/src/utils/fingerPrint.js +3 -1
- package/lib/commonjs/src/utils/fontIdentity.d.ts +1 -1
- package/lib/commonjs/src/utils/fontIdentity.js +2 -2
- package/lib/module/createNanoIconsSet.js +0 -1
- package/lib/module/createNanoIconsSet.native.js +26 -21
- package/lib/module/createNanoIconsSet.shared.js +32 -18
- package/lib/module/createNanoIconsSet.web.js +103 -61
- package/lib/module/devServerFont.js +1 -1
- package/lib/module/devServerFont.web.js +3 -5
- package/lib/module/fontIntegrity.js +20 -38
- package/lib/module/fontIntegrity.web.js +48 -0
- package/lib/module/fontIntegrityStore.js +65 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.node.js +1 -1
- package/lib/module/index.web.js +4 -0
- package/lib/module/loadDynamicFont.js +3 -15
- package/lib/module/specs/NanoIconViewNativeComponent.ts +3 -2
- package/lib/module/utils/fingerPrint.js +3 -2
- package/lib/module/utils/fontIdentity.js +2 -2
- package/lib/module/utils/fontScale.js +23 -0
- package/lib/module/utils/glyphRuntime.js +13 -0
- package/lib/module/utils/iconAccessibility.js +26 -0
- package/lib/module/utils/iconPropsEqual.js +27 -0
- package/lib/module/utils/webCss.js +26 -0
- package/lib/module/utils/webStyle.js +86 -0
- package/lib/module/webFont.js +33 -0
- package/lib/typescript/src/const/codegenPrimitives.d.ts +1 -0
- package/lib/typescript/src/core/glyph/merge.d.ts +2 -1
- package/lib/typescript/src/core/glyph/parse.d.ts +1 -2
- package/lib/typescript/src/core/pathkit/winding.d.ts +7 -1
- package/lib/typescript/src/createNanoIconsSet.d.ts +0 -1
- package/lib/typescript/src/createNanoIconsSet.native.d.ts +0 -2
- package/lib/typescript/src/createNanoIconsSet.shared.d.ts +1 -3
- package/lib/typescript/src/createNanoIconsSet.web.d.ts +1 -2
- package/lib/typescript/src/fontIntegrity.d.ts +2 -14
- package/lib/typescript/src/fontIntegrity.web.d.ts +7 -0
- package/lib/typescript/src/fontIntegrityStore.d.ts +19 -0
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.web.d.ts +5 -0
- package/lib/typescript/src/loadDynamicFont.d.ts +0 -1
- package/lib/typescript/src/specs/NanoIconViewNativeComponent.d.ts +3 -2
- package/lib/typescript/src/specs/NativeNanoIconsFontLoader.d.ts +1 -0
- package/lib/typescript/src/types.d.ts +37 -9
- package/lib/typescript/src/utils/fingerPrint.d.ts +1 -0
- package/lib/typescript/src/utils/fontIdentity.d.ts +1 -1
- package/lib/typescript/src/utils/fontScale.d.ts +2 -0
- package/lib/typescript/src/utils/glyphRuntime.d.ts +8 -0
- package/lib/typescript/src/utils/iconAccessibility.d.ts +4 -0
- package/lib/typescript/src/utils/iconPropsEqual.d.ts +4 -0
- package/lib/typescript/src/utils/webCss.d.ts +9 -0
- package/lib/typescript/src/utils/webStyle.d.ts +3 -0
- package/lib/typescript/src/webFont.d.ts +6 -0
- package/package.json +19 -3
- package/src/const/codegenPrimitives.ts +3 -3
- package/src/specs/NanoIconViewNativeComponent.ts +3 -2
- package/src/specs/NativeNanoIconsFontLoader.ts +1 -0
- package/lib/commonjs/src/core/pathkit/evenodd.d.ts +0 -12
- package/lib/commonjs/src/core/pathkit/evenodd.js +0 -37
- package/lib/typescript/src/core/pathkit/evenodd.d.ts +0 -13
|
@@ -4,10 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SymbolSetBuildError = void 0;
|
|
7
|
+
exports.fingerprintSymbolSets = fingerprintSymbolSets;
|
|
8
|
+
exports.checkAllSymbols = checkAllSymbols;
|
|
7
9
|
exports.buildAllSymbols = buildAllSymbols;
|
|
8
10
|
const path_1 = __importDefault(require("path"));
|
|
9
11
|
const fs_1 = __importDefault(require("fs"));
|
|
10
12
|
const runSymbolPipeline_1 = require("../src/core/pipeline/runSymbolPipeline");
|
|
13
|
+
const sameOutputs_1 = require("./sameOutputs");
|
|
11
14
|
const fingerPrint_1 = require("../src/utils/fingerPrint");
|
|
12
15
|
const naming_1 = require("../src/utils/naming");
|
|
13
16
|
const packageVersion_1 = require("../src/utils/packageVersion");
|
|
@@ -20,26 +23,32 @@ class SymbolSetBuildError extends Error {
|
|
|
20
23
|
}
|
|
21
24
|
exports.SymbolSetBuildError = SymbolSetBuildError;
|
|
22
25
|
const DEFAULT_PREFIX = 'nano';
|
|
23
|
-
|
|
26
|
+
const STALE_REASON = {
|
|
27
|
+
missing: (file) => `${file} is missing`,
|
|
28
|
+
invalidJson: (file) => `${file} is not valid JSON`,
|
|
29
|
+
inputsChanged: 'its SVGs, prefix or installed versions changed',
|
|
30
|
+
};
|
|
31
|
+
function currentSymbolOutput(inputHash, outputDir, name, logger) {
|
|
24
32
|
const symbolmapPath = path_1.default.join(outputDir, `${name}.symbolmap.json`);
|
|
25
33
|
const dtsPath = path_1.default.join(outputDir, `${name}.symbols.d.ts`);
|
|
26
34
|
const symbolsDir = path_1.default.join(outputDir, `${name}.symbols`);
|
|
27
35
|
const drawablesDir = path_1.default.join(outputDir, `${name}.drawables`);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
!fs_1.default.existsSync(drawablesDir)) {
|
|
32
|
-
return null;
|
|
36
|
+
const missing = [symbolmapPath, dtsPath, symbolsDir, drawablesDir].find((file) => !fs_1.default.existsSync(file));
|
|
37
|
+
if (missing) {
|
|
38
|
+
return { staleBecause: STALE_REASON.missing(path_1.default.basename(missing)) };
|
|
33
39
|
}
|
|
34
40
|
let symbolmap;
|
|
35
41
|
try {
|
|
36
42
|
symbolmap = JSON.parse(fs_1.default.readFileSync(symbolmapPath, 'utf8'));
|
|
37
43
|
}
|
|
38
44
|
catch {
|
|
39
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
staleBecause: STALE_REASON.invalidJson(path_1.default.basename(symbolmapPath)),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!symbolmap?.m?.h || symbolmap.m.h !== inputHash) {
|
|
50
|
+
return { staleBecause: STALE_REASON.inputsChanged };
|
|
40
51
|
}
|
|
41
|
-
if (!symbolmap?.m?.h || symbolmap.m.h !== inputHash)
|
|
42
|
-
return null;
|
|
43
52
|
const symbols = symbolmap.s ?? {};
|
|
44
53
|
const drawables = symbolmap.d ?? {};
|
|
45
54
|
const assetDirs = Object.values(symbols).map((assetName) => path_1.default.join(symbolsDir, `${assetName}.symbolset`));
|
|
@@ -47,54 +56,106 @@ function shouldSkipGeneration(inputHash, outputDir, name, logger) {
|
|
|
47
56
|
path_1.default.join(drawablesDir, `${resourceName}.xml`),
|
|
48
57
|
path_1.default.join(drawablesDir, `${(0, naming_1.toOriginalDrawableResourceName)(resourceName)}.xml`),
|
|
49
58
|
]);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
const missingAsset = [...assetDirs, ...drawableFiles].find((file) => !fs_1.default.existsSync(file));
|
|
60
|
+
if (missingAsset) {
|
|
61
|
+
return {
|
|
62
|
+
staleBecause: STALE_REASON.missing(path_1.default.basename(missingAsset)),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
54
65
|
logger?.info(`${name}: SVG fingerprint unchanged, skipping build.`);
|
|
55
66
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
built: {
|
|
68
|
+
name,
|
|
69
|
+
prefix: symbolmap.m.p,
|
|
70
|
+
symbolsDir,
|
|
71
|
+
assetDirs,
|
|
72
|
+
drawablesDir,
|
|
73
|
+
drawableFiles,
|
|
74
|
+
dtsPath,
|
|
75
|
+
symbolmapPath,
|
|
76
|
+
symbols,
|
|
77
|
+
drawables,
|
|
78
|
+
},
|
|
66
79
|
};
|
|
67
80
|
}
|
|
81
|
+
function resolveSymbolSet(set, projectRoot, versions) {
|
|
82
|
+
const inputDir = path_1.default.resolve(projectRoot, set.inputDir);
|
|
83
|
+
const name = set.name ?? path_1.default.basename(inputDir);
|
|
84
|
+
const prefix = set.prefix ?? DEFAULT_PREFIX;
|
|
85
|
+
if (!fs_1.default.existsSync(inputDir)) {
|
|
86
|
+
throw new Error(`[react-native-nano-icons] Input directory does not exist: ${inputDir} (from "${set.inputDir}")`);
|
|
87
|
+
}
|
|
88
|
+
const outputDir = set.outputDir
|
|
89
|
+
? path_1.default.resolve(projectRoot, set.outputDir)
|
|
90
|
+
: path_1.default.join(path_1.default.dirname(inputDir), 'nanoicons');
|
|
91
|
+
const { hash: inputHash, svgHashByFile } = (0, fingerPrint_1.fingerprintSymbolDirSync)(inputDir, { prefix, ...versions });
|
|
92
|
+
return { inputDir, name, prefix, outputDir, inputHash, svgHashByFile };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The input fingerprint of each symbol set: the value a build stores in its symbolmap as `m.h`.
|
|
96
|
+
*/
|
|
97
|
+
function fingerprintSymbolSets(symbolSets, projectRoot) {
|
|
98
|
+
const versions = {
|
|
99
|
+
version: (0, packageVersion_1.packageVersion)(),
|
|
100
|
+
toolchain: (0, packageVersion_1.fontToolchainVersions)(),
|
|
101
|
+
};
|
|
102
|
+
return symbolSets.map((set) => {
|
|
103
|
+
const { name, inputHash } = resolveSymbolSet(set, projectRoot, versions);
|
|
104
|
+
return { name, hash: inputHash };
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Report the symbol sets whose generated files are out of date, without writing anything to the project.
|
|
109
|
+
* A set is out of date when a build would change its generated files. When only its input fingerprint changed,
|
|
110
|
+
* the set is built into a temp dir and compared with them. With `existingOnly`, sets without a symbolmap are skipped.
|
|
111
|
+
*/
|
|
112
|
+
async function checkAllSymbols(symbolSets, projectRoot, options) {
|
|
113
|
+
const versions = {
|
|
114
|
+
version: (0, packageVersion_1.packageVersion)(),
|
|
115
|
+
toolchain: (0, packageVersion_1.fontToolchainVersions)(),
|
|
116
|
+
};
|
|
117
|
+
const stale = [];
|
|
118
|
+
for (const set of symbolSets) {
|
|
119
|
+
const { inputDir, name, prefix, outputDir, inputHash, svgHashByFile } = resolveSymbolSet(set, projectRoot, versions);
|
|
120
|
+
if (options?.existingOnly &&
|
|
121
|
+
!fs_1.default.existsSync(path_1.default.join(outputDir, `${name}.symbolmap.json`))) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const state = currentSymbolOutput(inputHash, outputDir, name);
|
|
125
|
+
if ('staleBecause' in state &&
|
|
126
|
+
state.staleBecause === STALE_REASON.inputsChanged &&
|
|
127
|
+
(await (0, sameOutputs_1.buildsSameOutputs)(outputDir, `${name}.symbolmap.json`, (dir) => (0, runSymbolPipeline_1.runSymbolPipeline)({ name, prefix }, { inputDir, outputDir: dir }, { inputHash, svgHashByFile })))) {
|
|
128
|
+
options?.logger?.succeed(`${name} symbols are up to date: their inputs changed, but they build the same`);
|
|
129
|
+
}
|
|
130
|
+
else if ('staleBecause' in state) {
|
|
131
|
+
options?.logger?.fail(`${name} symbols are out of date: ${state.staleBecause}`);
|
|
132
|
+
stale.push({ name, reason: state.staleBecause });
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
options?.logger?.succeed(`${name} symbols are up to date`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return stale;
|
|
139
|
+
}
|
|
68
140
|
// Build all symbol sets. Output goes in a "nanoicons" folder next to each
|
|
69
141
|
// inputDir, matching the font pipeline's convention.
|
|
70
142
|
async function buildAllSymbols(symbolSets, projectRoot, options) {
|
|
71
143
|
const logger = options?.logger;
|
|
72
|
-
const
|
|
73
|
-
|
|
144
|
+
const versions = {
|
|
145
|
+
version: (0, packageVersion_1.packageVersion)(),
|
|
146
|
+
toolchain: (0, packageVersion_1.fontToolchainVersions)(),
|
|
147
|
+
};
|
|
74
148
|
const results = [];
|
|
75
149
|
const failures = [];
|
|
76
150
|
for (let i = 0; i < symbolSets.length; i++) {
|
|
77
151
|
const set = symbolSets[i];
|
|
78
|
-
const inputDir =
|
|
79
|
-
const name = set.name ?? path_1.default.basename(inputDir);
|
|
80
|
-
const prefix = set.prefix ?? DEFAULT_PREFIX;
|
|
81
|
-
if (!fs_1.default.existsSync(inputDir)) {
|
|
82
|
-
throw new Error(`[react-native-nano-icons] Input directory does not exist: ${inputDir} (from "${set.inputDir}")`);
|
|
83
|
-
}
|
|
84
|
-
const outputDir = set.outputDir
|
|
85
|
-
? path_1.default.resolve(projectRoot, set.outputDir)
|
|
86
|
-
: path_1.default.join(path_1.default.dirname(inputDir), 'nanoicons');
|
|
152
|
+
const { inputDir, name, prefix, outputDir, inputHash, svgHashByFile } = resolveSymbolSet(set, projectRoot, versions);
|
|
87
153
|
if ('multicolor' in set) {
|
|
88
154
|
logger?.warn(`${name}: "multicolor" is no longer needed — every symbol now carries both rendering modes; remove it from the config.`);
|
|
89
155
|
}
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
toolchain,
|
|
94
|
-
});
|
|
95
|
-
const skipped = shouldSkipGeneration(inputHash, outputDir, name, logger);
|
|
96
|
-
if (skipped) {
|
|
97
|
-
results.push(skipped);
|
|
156
|
+
const current = currentSymbolOutput(inputHash, outputDir, name, logger);
|
|
157
|
+
if ('built' in current) {
|
|
158
|
+
results.push(current.built);
|
|
98
159
|
continue;
|
|
99
160
|
}
|
|
100
161
|
logger?.start(`Building ${name} (${i + 1}/${symbolSets.length})…`);
|
|
@@ -8,5 +8,15 @@ import type { SymbolSetConfig } from './buildSymbols';
|
|
|
8
8
|
* falling back to @expo/config.
|
|
9
9
|
*/
|
|
10
10
|
export declare function loadDynamicSetsFromAppConfig(projectRoot: string): IconSetConfig[];
|
|
11
|
+
type NanoIconsPluginOptions = {
|
|
12
|
+
iconSets?: IconSetConfig[];
|
|
13
|
+
symbolSets?: SymbolSetConfig[];
|
|
14
|
+
};
|
|
11
15
|
export declare function loadIconSetsFromAppConfig(projectRoot: string): IconSetConfig[];
|
|
12
16
|
export declare function loadSymbolSetsFromAppConfig(projectRoot: string): SymbolSetConfig[];
|
|
17
|
+
/**
|
|
18
|
+
* The plugin options in the Expo app config, `{}` when the plugin is listed without options,
|
|
19
|
+
* or `undefined` when it is not listed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function findPluginOptions(projectRoot: string): NanoIconsPluginOptions | undefined;
|
|
22
|
+
export {};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadDynamicSetsFromAppConfig = loadDynamicSetsFromAppConfig;
|
|
4
4
|
exports.loadIconSetsFromAppConfig = loadIconSetsFromAppConfig;
|
|
5
5
|
exports.loadSymbolSetsFromAppConfig = loadSymbolSetsFromAppConfig;
|
|
6
|
+
exports.findPluginOptions = findPluginOptions;
|
|
6
7
|
/**
|
|
7
8
|
* Load icon sets configured with linking: 'dynamic' from the Expo app config
|
|
8
9
|
* (app.json, app.config.js, or app.config.ts).
|
|
@@ -18,6 +19,11 @@ function loadDynamicSetsFromAppConfig(projectRoot) {
|
|
|
18
19
|
}
|
|
19
20
|
return dynamicSets;
|
|
20
21
|
}
|
|
22
|
+
const PLUGIN_NAMES = [
|
|
23
|
+
'react-native-nano-icons',
|
|
24
|
+
'react-native-nano-icons/app.plugin',
|
|
25
|
+
'react-native-nano-icons/app.plugin.js',
|
|
26
|
+
];
|
|
21
27
|
function loadIconSetsFromAppConfig(projectRoot) {
|
|
22
28
|
return loadPluginOptions(projectRoot).iconSets ?? [];
|
|
23
29
|
}
|
|
@@ -25,6 +31,18 @@ function loadSymbolSetsFromAppConfig(projectRoot) {
|
|
|
25
31
|
return loadPluginOptions(projectRoot).symbolSets ?? [];
|
|
26
32
|
}
|
|
27
33
|
function loadPluginOptions(projectRoot) {
|
|
34
|
+
const options = findPluginOptions(projectRoot);
|
|
35
|
+
if (!options) {
|
|
36
|
+
throw new Error(`[react-native-nano-icons] Plugin "react-native-nano-icons" not found in app config.\n` +
|
|
37
|
+
`Add it to your app.json or app.config.js/ts under the "plugins" key.`);
|
|
38
|
+
}
|
|
39
|
+
return options;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The plugin options in the Expo app config, `{}` when the plugin is listed without options,
|
|
43
|
+
* or `undefined` when it is not listed.
|
|
44
|
+
*/
|
|
45
|
+
function findPluginOptions(projectRoot) {
|
|
28
46
|
const configModule = resolveExpoConfigModule(projectRoot);
|
|
29
47
|
if (!configModule) {
|
|
30
48
|
throw new Error(`[react-native-nano-icons] Could not find expo/config or @expo/config from ${projectRoot} — required for --dynamic-app-config.\n` +
|
|
@@ -33,13 +51,10 @@ function loadPluginOptions(projectRoot) {
|
|
|
33
51
|
const { getConfig } = require(configModule);
|
|
34
52
|
const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });
|
|
35
53
|
const plugins = Array.isArray(exp.plugins) ? exp.plugins : [];
|
|
36
|
-
const entry = plugins.find((p) => Array.isArray(p)
|
|
37
|
-
if (!entry)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
const [, options] = entry;
|
|
42
|
-
return options;
|
|
54
|
+
const entry = plugins.find((p) => PLUGIN_NAMES.includes(Array.isArray(p) ? p[0] : p));
|
|
55
|
+
if (!entry)
|
|
56
|
+
return undefined;
|
|
57
|
+
return (Array.isArray(entry) ? entry[1] : undefined) ?? {};
|
|
43
58
|
}
|
|
44
59
|
function resolveExpoConfigModule(projectRoot) {
|
|
45
60
|
const candidates = [
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** An `@expo/fingerprint` hash source of type `contents`. */
|
|
2
|
+
export type FingerprintSource = {
|
|
3
|
+
type: 'contents';
|
|
4
|
+
id: string;
|
|
5
|
+
contents: string;
|
|
6
|
+
reasons: string[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* `extraSources` for `fingerprint.config.js`, read from the plugin options in the Expo app config.
|
|
10
|
+
* Icon sets with `linking: 'static'` and symbol sets are built into the native app, so each adds its
|
|
11
|
+
* input fingerprint: its SVGs, its options, and the installed library and font toolchain versions.
|
|
12
|
+
* Dynamic icon sets are left out, because an update delivers them.
|
|
13
|
+
* Returns no sources when the plugin is not configured, and warns and returns none when the sets can't be read.
|
|
14
|
+
*/
|
|
15
|
+
export declare function nanoIconsFingerprintSources(projectRoot: string): FingerprintSource[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nanoIconsFingerprintSources = nanoIconsFingerprintSources;
|
|
4
|
+
const build_1 = require("./build");
|
|
5
|
+
const buildSymbols_1 = require("./buildSymbols");
|
|
6
|
+
const expoConfig_1 = require("./expoConfig");
|
|
7
|
+
const REASONS = ['react-native-nano-icons'];
|
|
8
|
+
/**
|
|
9
|
+
* `extraSources` for `fingerprint.config.js`, read from the plugin options in the Expo app config.
|
|
10
|
+
* Icon sets with `linking: 'static'` and symbol sets are built into the native app, so each adds its
|
|
11
|
+
* input fingerprint: its SVGs, its options, and the installed library and font toolchain versions.
|
|
12
|
+
* Dynamic icon sets are left out, because an update delivers them.
|
|
13
|
+
* Returns no sources when the plugin is not configured, and warns and returns none when the sets can't be read.
|
|
14
|
+
*/
|
|
15
|
+
function nanoIconsFingerprintSources(projectRoot) {
|
|
16
|
+
try {
|
|
17
|
+
const options = (0, expoConfig_1.findPluginOptions)(projectRoot);
|
|
18
|
+
const iconSets = (0, build_1.fingerprintIconSets)((options?.iconSets ?? []).filter((set) => set.linking !== 'dynamic'), projectRoot).map(({ fontFamily, hash }) => ({
|
|
19
|
+
type: 'contents',
|
|
20
|
+
id: `react-native-nano-icons:iconSet:${fontFamily}`,
|
|
21
|
+
contents: hash,
|
|
22
|
+
reasons: REASONS,
|
|
23
|
+
}));
|
|
24
|
+
const symbolSets = (0, buildSymbols_1.fingerprintSymbolSets)(options?.symbolSets ?? [], projectRoot).map(({ name, hash }) => ({
|
|
25
|
+
type: 'contents',
|
|
26
|
+
id: `react-native-nano-icons:symbolSet:${name}`,
|
|
27
|
+
contents: hash,
|
|
28
|
+
reasons: REASONS,
|
|
29
|
+
}));
|
|
30
|
+
return [...iconSets, ...symbolSets];
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
console.warn(`[react-native-nano-icons] No fingerprint sources added: ${err instanceof Error ? err.message : String(err)}`);
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { buildAllFonts, IconSetBuildError, type IconSetConfig, type BuiltFont, } from './build';
|
|
2
|
-
export { buildAllSymbols, SymbolSetBuildError, type SymbolSetConfig, type BuiltSymbolSet, } from './buildSymbols';
|
|
1
|
+
export { buildAllFonts, checkAllFonts, IconSetBuildError, type IconSetConfig, type BuiltFont, type StaleSet, } from './build';
|
|
2
|
+
export { buildAllSymbols, checkAllSymbols, SymbolSetBuildError, type SymbolSetConfig, type BuiltSymbolSet, } from './buildSymbols';
|
|
3
3
|
export { SvgWorkerPool, type PreparedSvgCache, } from '../src/core/pipeline/index';
|
|
4
4
|
export { createOraLogger, createQuietLogger, detectExpoLogLevel, type NanoLogger, type LogLevel, } from './logger';
|
|
5
5
|
export { loadNanoIconsConfig, loadDynamicIconSets, type NanoIconsConfig, } from './config';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyDrawablesIntoResDir = exports.linkBareAndroidDrawables = exports.copySymbolsetsIntoCatalog = exports.linkBareSymbols = exports.syncAndroidFontAssets = exports.linkBare = exports.loadSymbolSetsFromAppConfig = exports.loadIconSetsFromAppConfig = exports.loadDynamicSetsFromAppConfig = exports.loadDynamicIconSets = exports.loadNanoIconsConfig = exports.detectExpoLogLevel = exports.createQuietLogger = exports.createOraLogger = exports.SvgWorkerPool = exports.SymbolSetBuildError = exports.buildAllSymbols = exports.IconSetBuildError = exports.buildAllFonts = void 0;
|
|
3
|
+
exports.copyDrawablesIntoResDir = exports.linkBareAndroidDrawables = exports.copySymbolsetsIntoCatalog = exports.linkBareSymbols = exports.syncAndroidFontAssets = exports.linkBare = exports.loadSymbolSetsFromAppConfig = exports.loadIconSetsFromAppConfig = exports.loadDynamicSetsFromAppConfig = exports.loadDynamicIconSets = exports.loadNanoIconsConfig = exports.detectExpoLogLevel = exports.createQuietLogger = exports.createOraLogger = exports.SvgWorkerPool = exports.SymbolSetBuildError = exports.checkAllSymbols = exports.buildAllSymbols = exports.IconSetBuildError = exports.checkAllFonts = exports.buildAllFonts = void 0;
|
|
4
4
|
var build_1 = require("./build");
|
|
5
5
|
Object.defineProperty(exports, "buildAllFonts", { enumerable: true, get: function () { return build_1.buildAllFonts; } });
|
|
6
|
+
Object.defineProperty(exports, "checkAllFonts", { enumerable: true, get: function () { return build_1.checkAllFonts; } });
|
|
6
7
|
Object.defineProperty(exports, "IconSetBuildError", { enumerable: true, get: function () { return build_1.IconSetBuildError; } });
|
|
7
8
|
var buildSymbols_1 = require("./buildSymbols");
|
|
8
9
|
Object.defineProperty(exports, "buildAllSymbols", { enumerable: true, get: function () { return buildSymbols_1.buildAllSymbols; } });
|
|
10
|
+
Object.defineProperty(exports, "checkAllSymbols", { enumerable: true, get: function () { return buildSymbols_1.checkAllSymbols; } });
|
|
9
11
|
Object.defineProperty(exports, "SymbolSetBuildError", { enumerable: true, get: function () { return buildSymbols_1.SymbolSetBuildError; } });
|
|
10
12
|
var index_1 = require("../src/core/pipeline/index");
|
|
11
13
|
Object.defineProperty(exports, "SvgWorkerPool", { enumerable: true, get: function () { return index_1.SvgWorkerPool; } });
|
|
@@ -2,6 +2,10 @@ import type { NanoLogger } from './logger';
|
|
|
2
2
|
import type { BuiltFont } from './build';
|
|
3
3
|
import type { BuiltSymbolSet } from './buildSymbols';
|
|
4
4
|
export declare function syncAndroidFontAssets(fontsDir: string, staticFonts: BuiltFont[], configuredFamilies: string[]): void;
|
|
5
|
+
/**
|
|
6
|
+
* Why the copy of a static font linked into the app's android/ or ios/ project differs from the generated TTF, if it does.
|
|
7
|
+
*/
|
|
8
|
+
export declare function staleLinkedFont(projectRoot: string, family: string, ttfPath: string): string | undefined;
|
|
5
9
|
export declare function copySymbolsetsIntoCatalog(catalogDir: string, builtSymbolSets: BuiltSymbolSet[]): void;
|
|
6
10
|
/**
|
|
7
11
|
* Link custom SF Symbols into the iOS app. Primary path writes into the app's
|
package/lib/commonjs/cli/link.js
CHANGED
|
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.syncAndroidFontAssets = syncAndroidFontAssets;
|
|
40
|
+
exports.staleLinkedFont = staleLinkedFont;
|
|
40
41
|
exports.copySymbolsetsIntoCatalog = copySymbolsetsIntoCatalog;
|
|
41
42
|
exports.linkBareSymbols = linkBareSymbols;
|
|
42
43
|
exports.copyDrawablesIntoResDir = copyDrawablesIntoResDir;
|
|
@@ -118,6 +119,30 @@ function syncAndroidFontAssets(fontsDir, staticFonts, configuredFamilies) {
|
|
|
118
119
|
node_fs_1.default.copyFileSync(b.ttfPath, node_path_1.default.join(fontsDir, `${b.family}.ttf`));
|
|
119
120
|
}
|
|
120
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Why the copy of a static font linked into the app's android/ or ios/ project differs from the generated TTF, if it does.
|
|
124
|
+
*/
|
|
125
|
+
function staleLinkedFont(projectRoot, family, ttfPath) {
|
|
126
|
+
const copies = [
|
|
127
|
+
...(node_fs_1.default.existsSync(node_path_1.default.join(projectRoot, 'android'))
|
|
128
|
+
? [node_path_1.default.join(projectRoot, ANDROID_FONTS_DIR, `${family}.ttf`)]
|
|
129
|
+
: []),
|
|
130
|
+
...(findIosApp(projectRoot)
|
|
131
|
+
? [
|
|
132
|
+
node_path_1.default.join(projectRoot, 'ios', IOS_NANOICONS_FONTS_DIR, node_path_1.default.basename(ttfPath)),
|
|
133
|
+
]
|
|
134
|
+
: []),
|
|
135
|
+
];
|
|
136
|
+
const ttf = node_fs_1.default.readFileSync(ttfPath);
|
|
137
|
+
for (const copy of copies) {
|
|
138
|
+
const relative = node_path_1.default.relative(projectRoot, copy);
|
|
139
|
+
if (!node_fs_1.default.existsSync(copy))
|
|
140
|
+
return `${relative} is missing`;
|
|
141
|
+
if (!node_fs_1.default.readFileSync(copy).equals(ttf))
|
|
142
|
+
return `${relative} is out of date`;
|
|
143
|
+
}
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
121
146
|
async function linkAndroid(projectRoot, staticFonts, builtFonts) {
|
|
122
147
|
syncAndroidFontAssets(node_path_1.default.join(projectRoot, ANDROID_FONTS_DIR), staticFonts, builtFonts.map((b) => b.fontFamily));
|
|
123
148
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether `build`, run into a temp dir, writes the same files as those in `outputDir`.
|
|
3
|
+
* In `mapFile` the stored input fingerprint `m.h` is ignored.
|
|
4
|
+
*/
|
|
5
|
+
export declare function buildsSameOutputs(outputDir: string, mapFile: string, build: (tempDir: string) => Promise<unknown>): Promise<boolean>;
|
|
@@ -0,0 +1,45 @@
|
|
|
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.buildsSameOutputs = buildsSameOutputs;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
/**
|
|
11
|
+
* Whether `build`, run into a temp dir, writes the same files as those in `outputDir`.
|
|
12
|
+
* In `mapFile` the stored input fingerprint `m.h` is ignored.
|
|
13
|
+
*/
|
|
14
|
+
async function buildsSameOutputs(outputDir, mapFile, build) {
|
|
15
|
+
const tempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'nano-check-'));
|
|
16
|
+
try {
|
|
17
|
+
await build(tempDir);
|
|
18
|
+
return fs_1.default
|
|
19
|
+
.readdirSync(tempDir)
|
|
20
|
+
.every((entry) => sameEntry(path_1.default.join(tempDir, entry), path_1.default.join(outputDir, entry), mapFile));
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
fs_1.default.rmSync(tempDir, { recursive: true, force: true });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function sameEntry(built, existing, mapFile) {
|
|
27
|
+
if (!fs_1.default.existsSync(existing))
|
|
28
|
+
return false;
|
|
29
|
+
if (fs_1.default.statSync(built).isDirectory()) {
|
|
30
|
+
if (!fs_1.default.statSync(existing).isDirectory())
|
|
31
|
+
return false;
|
|
32
|
+
const entries = fs_1.default.readdirSync(built).sort();
|
|
33
|
+
return (entries.join('\n') === fs_1.default.readdirSync(existing).sort().join('\n') &&
|
|
34
|
+
entries.every((entry) => sameEntry(path_1.default.join(built, entry), path_1.default.join(existing, entry), mapFile)));
|
|
35
|
+
}
|
|
36
|
+
if (path_1.default.basename(built) === mapFile) {
|
|
37
|
+
return withoutInputHash(built) === withoutInputHash(existing);
|
|
38
|
+
}
|
|
39
|
+
return fs_1.default.readFileSync(built).equals(fs_1.default.readFileSync(existing));
|
|
40
|
+
}
|
|
41
|
+
function withoutInputHash(file) {
|
|
42
|
+
const map = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
|
|
43
|
+
delete map?.m?.h;
|
|
44
|
+
return JSON.stringify(map);
|
|
45
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const createNanoIconSet = (...args) => {
|
|
3
|
-
const { createIconSet } = require('
|
|
3
|
+
const { createIconSet } = require('../module/createNanoIconsSet.web.js');
|
|
4
4
|
return createIconSet(...args);
|
|
5
5
|
};
|
|
6
6
|
const plugin = require('./plugin/src/index')
|
|
@@ -2,7 +2,8 @@ import type { IconSetConfig, BuiltFont } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Build TTF + glyphmap for all icon sets.
|
|
4
4
|
* Reports every broken icon, then fails the prebuild so no set is silently left unlinked.
|
|
5
|
+
* When frozen, fails the prebuild instead when a set is out of date, and builds nothing.
|
|
5
6
|
* EXPO_DEBUG adds the per-file processing details.
|
|
6
7
|
*/
|
|
7
|
-
export declare function buildAllFonts(iconSets: IconSetConfig[], projectRoot: string): Promise<BuiltFont[]>;
|
|
8
|
-
export declare function getOrBuildFonts(projectRoot: string, iconSets: IconSetConfig[]): Promise<BuiltFont[]>;
|
|
8
|
+
export declare function buildAllFonts(iconSets: IconSetConfig[], projectRoot: string, frozen?: boolean): Promise<BuiltFont[]>;
|
|
9
|
+
export declare function getOrBuildFonts(projectRoot: string, iconSets: IconSetConfig[], frozen?: boolean): Promise<BuiltFont[]>;
|
|
@@ -3,20 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildAllFonts = buildAllFonts;
|
|
4
4
|
exports.getOrBuildFonts = getOrBuildFonts;
|
|
5
5
|
const index_1 = require("../../cli/index");
|
|
6
|
+
const frozen_1 = require("./frozen");
|
|
6
7
|
/**
|
|
7
8
|
* Build TTF + glyphmap for all icon sets.
|
|
8
9
|
* Reports every broken icon, then fails the prebuild so no set is silently left unlinked.
|
|
10
|
+
* When frozen, fails the prebuild instead when a set is out of date, and builds nothing.
|
|
9
11
|
* EXPO_DEBUG adds the per-file processing details.
|
|
10
12
|
*/
|
|
11
|
-
async function buildAllFonts(iconSets, projectRoot) {
|
|
13
|
+
async function buildAllFonts(iconSets, projectRoot, frozen) {
|
|
12
14
|
const logger = await (0, index_1.createQuietLogger)((0, index_1.detectExpoLogLevel)());
|
|
15
|
+
const scope = (0, frozen_1.frozenScope)(frozen);
|
|
16
|
+
if (scope !== 'none') {
|
|
17
|
+
(0, frozen_1.failFrozenPrebuild)(await (0, index_1.checkAllFonts)(iconSets, projectRoot, {
|
|
18
|
+
existingOnly: scope === 'existing',
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
13
21
|
return (0, index_1.buildAllFonts)(iconSets, projectRoot, { logger });
|
|
14
22
|
}
|
|
15
23
|
// Single build run per process; reused across ios/android mods.
|
|
16
24
|
let _buildPromise = null;
|
|
17
|
-
function getOrBuildFonts(projectRoot, iconSets) {
|
|
25
|
+
function getOrBuildFonts(projectRoot, iconSets, frozen) {
|
|
18
26
|
if (!_buildPromise) {
|
|
19
|
-
_buildPromise = buildAllFonts(iconSets, projectRoot);
|
|
27
|
+
_buildPromise = buildAllFonts(iconSets, projectRoot, frozen);
|
|
20
28
|
}
|
|
21
29
|
return _buildPromise;
|
|
22
30
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SymbolSetConfig, BuiltSymbolSet } from './types';
|
|
2
|
-
export declare function buildAllSymbols(symbolSets: SymbolSetConfig[], projectRoot: string): Promise<BuiltSymbolSet[]>;
|
|
3
|
-
export declare function getOrBuildSymbols(projectRoot: string, symbolSets: SymbolSetConfig[]): Promise<BuiltSymbolSet[]>;
|
|
2
|
+
export declare function buildAllSymbols(symbolSets: SymbolSetConfig[], projectRoot: string, frozen?: boolean): Promise<BuiltSymbolSet[]>;
|
|
3
|
+
export declare function getOrBuildSymbols(projectRoot: string, symbolSets: SymbolSetConfig[], frozen?: boolean): Promise<BuiltSymbolSet[]>;
|
|
@@ -3,16 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildAllSymbols = buildAllSymbols;
|
|
4
4
|
exports.getOrBuildSymbols = getOrBuildSymbols;
|
|
5
5
|
const index_1 = require("../../cli/index");
|
|
6
|
+
const frozen_1 = require("./frozen");
|
|
6
7
|
// Build all symbol sets.
|
|
7
|
-
async function buildAllSymbols(symbolSets, projectRoot) {
|
|
8
|
+
async function buildAllSymbols(symbolSets, projectRoot, frozen) {
|
|
8
9
|
const logger = await (0, index_1.createQuietLogger)((0, index_1.detectExpoLogLevel)());
|
|
10
|
+
const scope = (0, frozen_1.frozenScope)(frozen);
|
|
11
|
+
if (scope !== 'none') {
|
|
12
|
+
(0, frozen_1.failFrozenPrebuild)(await (0, index_1.checkAllSymbols)(symbolSets, projectRoot, {
|
|
13
|
+
existingOnly: scope === 'existing',
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
9
16
|
return (0, index_1.buildAllSymbols)(symbolSets, projectRoot, { logger });
|
|
10
17
|
}
|
|
11
18
|
// Single build run per process; reused across mods.
|
|
12
19
|
let _buildPromise = null;
|
|
13
|
-
function getOrBuildSymbols(projectRoot, symbolSets) {
|
|
20
|
+
function getOrBuildSymbols(projectRoot, symbolSets, frozen) {
|
|
14
21
|
if (!_buildPromise) {
|
|
15
|
-
_buildPromise = buildAllSymbols(symbolSets, projectRoot);
|
|
22
|
+
_buildPromise = buildAllSymbols(symbolSets, projectRoot, frozen);
|
|
16
23
|
}
|
|
17
24
|
return _buildPromise;
|
|
18
25
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.frozenScope = frozenScope;
|
|
4
|
+
exports.failFrozenPrebuild = failFrozenPrebuild;
|
|
5
|
+
function frozenScope(frozen) {
|
|
6
|
+
if (frozen !== undefined)
|
|
7
|
+
return frozen ? 'all' : 'none';
|
|
8
|
+
const ci = process.env.CI?.toLowerCase();
|
|
9
|
+
return ci && ci !== 'false' && ci !== '0' ? 'existing' : 'none';
|
|
10
|
+
}
|
|
11
|
+
function failFrozenPrebuild(stale) {
|
|
12
|
+
if (!stale.length)
|
|
13
|
+
return;
|
|
14
|
+
const sets = stale
|
|
15
|
+
.map(({ name, reason }) => `${name} (${reason})`)
|
|
16
|
+
.join(', ');
|
|
17
|
+
throw new Error(`[react-native-nano-icons] frozen is on, but ${stale.length === 1 ? '1 set is' : `${stale.length} sets are`} out of date: ${sets}. Rebuild them without frozen, e.g. with a local prebuild, and commit the generated files.`);
|
|
18
|
+
}
|
|
@@ -5,11 +5,11 @@ const withNanoIconsSymbolLinking_1 = require("./withNanoIconsSymbolLinking");
|
|
|
5
5
|
const withNanoIconsDrawableLinking_1 = require("./withNanoIconsDrawableLinking");
|
|
6
6
|
const withNanoIcons = (config, options) => {
|
|
7
7
|
if (options?.iconSets?.length) {
|
|
8
|
-
config = (0, withNanoIconsFontLinking_1.withNanoIconsFontLinking)(config, options.iconSets);
|
|
8
|
+
config = (0, withNanoIconsFontLinking_1.withNanoIconsFontLinking)(config, options.iconSets, options.frozen);
|
|
9
9
|
}
|
|
10
10
|
if (options?.symbolSets?.length) {
|
|
11
|
-
config = (0, withNanoIconsSymbolLinking_1.withNanoIconsSymbolLinking)(config, options.symbolSets);
|
|
12
|
-
config = (0, withNanoIconsDrawableLinking_1.withNanoIconsDrawableLinking)(config, options.symbolSets);
|
|
11
|
+
config = (0, withNanoIconsSymbolLinking_1.withNanoIconsSymbolLinking)(config, options.symbolSets, options.frozen);
|
|
12
|
+
config = (0, withNanoIconsDrawableLinking_1.withNanoIconsDrawableLinking)(config, options.symbolSets, options.frozen);
|
|
13
13
|
}
|
|
14
14
|
return config;
|
|
15
15
|
};
|
|
@@ -12,6 +12,8 @@ export interface IconSetConfig {
|
|
|
12
12
|
upm?: number;
|
|
13
13
|
/** Safe zone inside UPM for glyphs (default upm * 1020 / 1024, i.e. 1020 at the default upm). Must not exceed upm. */
|
|
14
14
|
safeZone?: number;
|
|
15
|
+
/** Max distance between the font's quadratic curves and the SVG curves, as a fraction of the em (default 1/512). Must be positive. */
|
|
16
|
+
curveTolerance?: number;
|
|
15
17
|
/** First Unicode codepoint for glyphs (default 0xe900). Hex string or number. */
|
|
16
18
|
startUnicode?: number | string;
|
|
17
19
|
/**
|
|
@@ -67,6 +69,14 @@ export interface BuiltSymbolSet {
|
|
|
67
69
|
export interface NanoIconsPluginOptions {
|
|
68
70
|
iconSets?: IconSetConfig[];
|
|
69
71
|
symbolSets?: SymbolSetConfig[];
|
|
72
|
+
/**
|
|
73
|
+
* Fail prebuild when a set's generated files are out of date, instead of regenerating them.
|
|
74
|
+
*
|
|
75
|
+
* - unset: on in CI (`CI` is set and not `false` or `0`) for the sets whose generated files exist; the others are built.
|
|
76
|
+
* - `true`: on for every set, also outside CI.
|
|
77
|
+
* - `false`: off.
|
|
78
|
+
*/
|
|
79
|
+
frozen?: boolean;
|
|
70
80
|
}
|
|
71
81
|
/**
|
|
72
82
|
* Result of building one icon set.
|
|
@@ -5,4 +5,4 @@ import type { SymbolSetConfig } from './types';
|
|
|
5
5
|
* compiles them automatically and they resolve by name — the native-tab-bar
|
|
6
6
|
* counterpart to the iOS asset catalog, so no gradle changes are needed.
|
|
7
7
|
*/
|
|
8
|
-
export declare function withNanoIconsDrawableLinking(config: Parameters<typeof withDangerousMod>[0], symbolSets: SymbolSetConfig[]): ReturnType<typeof withDangerousMod>;
|
|
8
|
+
export declare function withNanoIconsDrawableLinking(config: Parameters<typeof withDangerousMod>[0], symbolSets: SymbolSetConfig[], frozen?: boolean): ReturnType<typeof withDangerousMod>;
|
|
@@ -14,11 +14,11 @@ const ANDROID_DRAWABLES_DIR = 'app/src/main/res/drawable';
|
|
|
14
14
|
* compiles them automatically and they resolve by name — the native-tab-bar
|
|
15
15
|
* counterpart to the iOS asset catalog, so no gradle changes are needed.
|
|
16
16
|
*/
|
|
17
|
-
function withNanoIconsDrawableLinking(config, symbolSets) {
|
|
17
|
+
function withNanoIconsDrawableLinking(config, symbolSets, frozen) {
|
|
18
18
|
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
19
19
|
'android',
|
|
20
20
|
async (config) => {
|
|
21
|
-
const built = await (0, buildSymbols_1.getOrBuildSymbols)(config.modRequest.projectRoot, symbolSets);
|
|
21
|
+
const built = await (0, buildSymbols_1.getOrBuildSymbols)(config.modRequest.projectRoot, symbolSets, frozen);
|
|
22
22
|
if (!built?.length)
|
|
23
23
|
return config;
|
|
24
24
|
const drawableDir = path_1.default.join(config.modRequest.platformProjectRoot, ANDROID_DRAWABLES_DIR);
|