@iconify/tools 2.0.14 → 2.0.15
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/lib/colors/attribs.cjs +30 -0
- package/lib/colors/attribs.d.ts +13 -10
- package/lib/colors/attribs.mjs +7 -13
- package/lib/colors/parse.cjs +269 -0
- package/lib/colors/parse.d.ts +15 -11
- package/lib/colors/parse.mjs +27 -31
- package/lib/colors/validate.cjs +52 -0
- package/lib/colors/validate.d.ts +11 -4
- package/lib/colors/validate.mjs +19 -6
- package/lib/css/parse.cjs +26 -0
- package/lib/css/parse.d.ts +3 -1
- package/lib/css/parse.mjs +8 -6
- package/lib/css/parser/error.cjs +25 -0
- package/lib/css/parser/error.d.ts +4 -2
- package/lib/css/parser/error.mjs +2 -4
- package/lib/css/parser/export.cjs +48 -0
- package/lib/css/parser/export.d.ts +5 -2
- package/lib/css/parser/export.mjs +4 -6
- package/lib/css/parser/strings.cjs +77 -0
- package/lib/css/parser/strings.d.ts +6 -3
- package/lib/css/parser/strings.mjs +4 -6
- package/lib/css/parser/text.cjs +135 -0
- package/lib/css/parser/text.d.ts +8 -5
- package/lib/css/parser/text.mjs +3 -8
- package/lib/css/parser/tokens.cjs +184 -0
- package/lib/css/parser/tokens.d.ts +6 -3
- package/lib/css/parser/tokens.mjs +7 -13
- package/lib/css/parser/tree.cjs +42 -0
- package/lib/css/parser/tree.d.ts +5 -2
- package/lib/css/parser/tree.mjs +2 -4
- package/lib/css/parser/types.cjs +2 -0
- package/lib/css/parser/types.d.ts +13 -11
- package/lib/css/parser/types.mjs +1 -0
- package/lib/download/api/cache.cjs +86 -0
- package/lib/download/api/cache.d.ts +8 -5
- package/lib/download/api/cache.mjs +14 -19
- package/lib/download/api/download.cjs +28 -0
- package/lib/download/api/download.d.ts +5 -2
- package/lib/download/api/download.mjs +8 -9
- package/lib/download/api/index.cjs +51 -0
- package/lib/download/api/index.d.ts +5 -2
- package/lib/download/api/index.mjs +8 -6
- package/lib/download/api/types.cjs +2 -0
- package/lib/download/api/types.d.ts +4 -2
- package/lib/download/api/types.mjs +1 -0
- package/lib/download/git/branch.cjs +22 -0
- package/lib/download/git/branch.d.ts +5 -2
- package/lib/download/git/branch.mjs +5 -5
- package/lib/download/git/hash.cjs +15 -0
- package/lib/download/git/hash.d.ts +5 -2
- package/lib/download/git/hash.mjs +5 -5
- package/lib/download/git/index.cjs +76 -0
- package/lib/download/git/index.d.ts +10 -8
- package/lib/download/git/index.mjs +41 -26
- package/lib/download/git/reset.cjs +41 -0
- package/lib/download/git/reset.d.ts +3 -1
- package/lib/download/git/reset.mjs +29 -5
- package/lib/download/github/hash.cjs +32 -0
- package/lib/download/github/hash.d.ts +5 -2
- package/lib/download/github/hash.mjs +10 -7
- package/lib/download/github/index.cjs +98 -0
- package/lib/download/github/index.d.ts +11 -9
- package/lib/download/github/index.mjs +23 -17
- package/lib/download/github/types.cjs +2 -0
- package/lib/download/github/types.d.ts +3 -1
- package/lib/download/github/types.mjs +1 -0
- package/lib/download/gitlab/hash.cjs +32 -0
- package/lib/download/gitlab/hash.d.ts +5 -2
- package/lib/download/gitlab/hash.mjs +10 -6
- package/lib/download/gitlab/index.cjs +98 -0
- package/lib/download/gitlab/index.d.ts +11 -9
- package/lib/download/gitlab/index.mjs +24 -18
- package/lib/download/gitlab/types.cjs +7 -0
- package/lib/download/gitlab/types.d.ts +4 -2
- package/lib/download/gitlab/types.mjs +3 -5
- package/lib/download/helpers/untar.cjs +14 -0
- package/lib/download/helpers/untar.d.ts +3 -1
- package/lib/download/helpers/untar.mjs +4 -5
- package/lib/download/helpers/unzip.cjs +19 -0
- package/lib/download/helpers/unzip.d.ts +3 -1
- package/lib/download/helpers/unzip.mjs +6 -7
- package/lib/download/index.cjs +64 -0
- package/lib/download/index.d.ts +18 -13
- package/lib/download/index.mjs +46 -19
- package/lib/download/npm/index.cjs +82 -0
- package/lib/download/npm/index.d.ts +10 -8
- package/lib/download/npm/index.mjs +16 -13
- package/lib/download/npm/types.cjs +2 -0
- package/lib/download/npm/types.d.ts +3 -1
- package/lib/download/npm/types.mjs +1 -0
- package/lib/download/npm/version.cjs +23 -0
- package/lib/download/npm/version.d.ts +7 -4
- package/lib/download/npm/version.mjs +8 -10
- package/lib/download/types/modified.cjs +2 -0
- package/lib/download/types/modified.d.ts +3 -1
- package/lib/download/types/modified.mjs +1 -0
- package/lib/download/types/sources.cjs +2 -0
- package/lib/download/types/sources.d.ts +4 -2
- package/lib/download/types/sources.mjs +1 -0
- package/lib/export/directory.cjs +45 -0
- package/lib/export/directory.d.ts +11 -4
- package/lib/export/directory.mjs +8 -8
- package/lib/export/helpers/custom-files.cjs +28 -0
- package/lib/export/helpers/custom-files.d.ts +4 -2
- package/lib/export/helpers/custom-files.mjs +8 -9
- package/lib/export/helpers/prepare.cjs +36 -0
- package/lib/export/helpers/prepare.d.ts +5 -3
- package/lib/export/helpers/prepare.mjs +7 -9
- package/lib/export/helpers/types-version.cjs +22 -0
- package/lib/export/helpers/types-version.d.ts +3 -1
- package/lib/export/helpers/types-version.mjs +15 -37
- package/lib/export/icon-package.cjs +59 -0
- package/lib/export/icon-package.d.ts +12 -5
- package/lib/export/icon-package.mjs +15 -16
- package/lib/export/json-package.cjs +133 -0
- package/lib/export/json-package.d.ts +12 -5
- package/lib/export/json-package.mjs +20 -21
- package/lib/icon-set/index.cjs +589 -0
- package/lib/icon-set/index.d.ts +9 -6
- package/lib/icon-set/index.mjs +40 -53
- package/lib/icon-set/match.cjs +58 -0
- package/lib/icon-set/match.d.ts +10 -3
- package/lib/icon-set/match.mjs +5 -6
- package/lib/icon-set/merge.cjs +83 -0
- package/lib/icon-set/merge.d.ts +9 -2
- package/lib/icon-set/merge.mjs +15 -10
- package/lib/icon-set/props.cjs +28 -0
- package/lib/icon-set/props.d.ts +8 -4
- package/lib/icon-set/props.mjs +7 -10
- package/lib/icon-set/types.cjs +2 -0
- package/lib/icon-set/types.d.ts +19 -17
- package/lib/icon-set/types.mjs +1 -0
- package/lib/import/directory.cjs +76 -0
- package/lib/import/directory.d.ts +11 -5
- package/lib/import/directory.mjs +36 -11
- package/lib/import/figma/index.cjs +105 -0
- package/lib/import/figma/index.d.ts +15 -5
- package/lib/import/figma/index.mjs +40 -13
- package/lib/import/figma/nodes.cjs +86 -0
- package/lib/import/figma/nodes.d.ts +13 -4
- package/lib/import/figma/nodes.mjs +3 -11
- package/lib/import/figma/query.cjs +218 -0
- package/lib/import/figma/query.d.ts +18 -9
- package/lib/import/figma/query.mjs +9 -12
- package/lib/import/figma/types/api.cjs +2 -0
- package/lib/import/figma/types/api.d.ts +8 -7
- package/lib/import/figma/types/api.mjs +1 -0
- package/lib/import/figma/types/nodes.cjs +2 -0
- package/lib/import/figma/types/nodes.d.ts +16 -9
- package/lib/import/figma/types/nodes.mjs +1 -0
- package/lib/import/figma/types/options.cjs +2 -0
- package/lib/import/figma/types/options.d.ts +17 -10
- package/lib/import/figma/types/options.mjs +1 -0
- package/lib/import/figma/types/result.cjs +2 -0
- package/lib/import/figma/types/result.d.ts +12 -5
- package/lib/import/figma/types/result.mjs +1 -0
- package/lib/index.cjs +137 -0
- package/lib/index.d.ts +65 -44
- package/lib/index.mjs +83 -94
- package/lib/misc/bump-version.cjs +17 -0
- package/lib/misc/bump-version.d.ts +3 -1
- package/lib/misc/bump-version.mjs +2 -4
- package/lib/misc/compare-dirs.cjs +75 -0
- package/lib/misc/compare-dirs.d.ts +4 -2
- package/lib/misc/compare-dirs.mjs +12 -12
- package/lib/misc/exec.cjs +25 -0
- package/lib/misc/exec.d.ts +6 -4
- package/lib/misc/exec.mjs +4 -5
- package/lib/misc/keyword.cjs +19 -0
- package/lib/misc/keyword.d.ts +3 -1
- package/lib/misc/keyword.mjs +2 -4
- package/lib/misc/scan.cjs +51 -0
- package/lib/misc/scan.d.ts +7 -6
- package/lib/misc/scan.mjs +6 -7
- package/lib/misc/write-json.cjs +11 -0
- package/lib/misc/write-json.d.ts +3 -1
- package/lib/misc/write-json.mjs +5 -6
- package/lib/optimise/flags.cjs +252 -0
- package/lib/optimise/flags.d.ts +7 -2
- package/lib/optimise/flags.mjs +18 -19
- package/lib/optimise/global-style.cjs +154 -0
- package/lib/optimise/global-style.d.ts +7 -2
- package/lib/optimise/global-style.mjs +18 -15
- package/lib/optimise/scale.cjs +26 -0
- package/lib/optimise/scale.d.ts +7 -2
- package/lib/optimise/scale.mjs +5 -5
- package/lib/optimise/svgo.cjs +83 -0
- package/lib/optimise/svgo.d.ts +10 -6
- package/lib/optimise/svgo.mjs +6 -9
- package/lib/svg/analyse/error.cjs +18 -0
- package/lib/svg/analyse/error.d.ts +5 -2
- package/lib/svg/analyse/error.mjs +2 -4
- package/lib/svg/analyse/types.cjs +2 -0
- package/lib/svg/analyse/types.d.ts +11 -11
- package/lib/svg/analyse/types.mjs +1 -0
- package/lib/svg/analyse.cjs +291 -0
- package/lib/svg/analyse.d.ts +8 -3
- package/lib/svg/analyse.mjs +15 -30
- package/lib/svg/cleanup/attribs.cjs +41 -0
- package/lib/svg/cleanup/attribs.d.ts +7 -2
- package/lib/svg/cleanup/attribs.mjs +6 -12
- package/lib/svg/cleanup/bad-tags.cjs +51 -0
- package/lib/svg/cleanup/bad-tags.d.ts +7 -2
- package/lib/svg/cleanup/bad-tags.mjs +10 -25
- package/lib/svg/cleanup/inline-style.cjs +64 -0
- package/lib/svg/cleanup/inline-style.d.ts +7 -2
- package/lib/svg/cleanup/inline-style.mjs +14 -19
- package/lib/svg/cleanup/root-svg.cjs +81 -0
- package/lib/svg/cleanup/root-svg.d.ts +7 -2
- package/lib/svg/cleanup/root-svg.mjs +7 -18
- package/lib/svg/cleanup/svgo-style.cjs +38 -0
- package/lib/svg/cleanup/svgo-style.d.ts +7 -2
- package/lib/svg/cleanup/svgo-style.mjs +16 -11
- package/lib/svg/cleanup.cjs +32 -0
- package/lib/svg/cleanup.d.ts +7 -2
- package/lib/svg/cleanup.mjs +21 -9
- package/lib/svg/data/attributes.cjs +355 -0
- package/lib/svg/data/attributes.d.ts +27 -25
- package/lib/svg/data/attributes.mjs +90 -115
- package/lib/svg/data/tags.cjs +137 -0
- package/lib/svg/data/tags.d.ts +25 -23
- package/lib/svg/data/tags.mjs +25 -49
- package/lib/svg/index.cjs +130 -0
- package/lib/svg/index.d.ts +16 -5
- package/lib/svg/index.mjs +48 -14
- package/lib/svg/parse-style.cjs +134 -0
- package/lib/svg/parse-style.d.ts +12 -8
- package/lib/svg/parse-style.mjs +11 -9
- package/lib/svg/parse.cjs +42 -0
- package/lib/svg/parse.d.ts +11 -7
- package/lib/svg/parse.mjs +2 -4
- package/package.json +99 -94
- package/lib/colors/attribs.js +0 -26
- package/lib/colors/parse.js +0 -341
- package/lib/colors/validate.js +0 -48
- package/lib/css/parse.js +0 -23
- package/lib/css/parser/error.js +0 -27
- package/lib/css/parser/export.js +0 -69
- package/lib/css/parser/strings.js +0 -93
- package/lib/css/parser/text.js +0 -171
- package/lib/css/parser/tokens.js +0 -200
- package/lib/css/parser/tree.js +0 -44
- package/lib/css/parser/types.js +0 -2
- package/lib/download/api/cache.js +0 -108
- package/lib/download/api/download.js +0 -27
- package/lib/download/api/index.js +0 -52
- package/lib/download/api/types.js +0 -2
- package/lib/download/git/branch.js +0 -22
- package/lib/download/git/hash.js +0 -14
- package/lib/download/git/index.js +0 -75
- package/lib/download/git/reset.js +0 -16
- package/lib/download/github/hash.js +0 -28
- package/lib/download/github/index.js +0 -116
- package/lib/download/github/types.js +0 -2
- package/lib/download/gitlab/hash.js +0 -27
- package/lib/download/gitlab/index.js +0 -115
- package/lib/download/gitlab/types.js +0 -7
- package/lib/download/helpers/untar.js +0 -14
- package/lib/download/helpers/unzip.js +0 -18
- package/lib/download/index.js +0 -27
- package/lib/download/npm/index.js +0 -91
- package/lib/download/npm/types.js +0 -2
- package/lib/download/npm/version.js +0 -27
- package/lib/download/types/modified.js +0 -2
- package/lib/download/types/sources.js +0 -2
- package/lib/export/directory.js +0 -52
- package/lib/export/helpers/custom-files.js +0 -32
- package/lib/export/helpers/prepare.js +0 -49
- package/lib/export/helpers/types-version.js +0 -12
- package/lib/export/icon-package.js +0 -77
- package/lib/export/json-package.js +0 -156
- package/lib/icon-set/index.js +0 -749
- package/lib/icon-set/match.js +0 -66
- package/lib/icon-set/merge.js +0 -90
- package/lib/icon-set/props.js +0 -34
- package/lib/icon-set/types.js +0 -2
- package/lib/import/directory.js +0 -59
- package/lib/import/figma/index.js +0 -90
- package/lib/import/figma/nodes.js +0 -106
- package/lib/import/figma/query.js +0 -244
- package/lib/import/figma/types/api.js +0 -12
- package/lib/import/figma/types/nodes.js +0 -2
- package/lib/import/figma/types/options.js +0 -2
- package/lib/import/figma/types/result.js +0 -2
- package/lib/index.js +0 -103
- package/lib/misc/bump-version.js +0 -19
- package/lib/misc/compare-dirs.js +0 -84
- package/lib/misc/exec.js +0 -26
- package/lib/misc/keyword.js +0 -31
- package/lib/misc/scan.js +0 -55
- package/lib/misc/write-json.js +0 -11
- package/lib/optimise/flags.js +0 -312
- package/lib/optimise/global-style.js +0 -185
- package/lib/optimise/scale.js +0 -42
- package/lib/optimise/svgo.js +0 -99
- package/lib/svg/analyse/error.js +0 -22
- package/lib/svg/analyse/types.js +0 -2
- package/lib/svg/analyse.js +0 -352
- package/lib/svg/cleanup/attribs.js +0 -51
- package/lib/svg/cleanup/bad-tags.js +0 -65
- package/lib/svg/cleanup/inline-style.js +0 -77
- package/lib/svg/cleanup/root-svg.js +0 -107
- package/lib/svg/cleanup/svgo-style.js +0 -35
- package/lib/svg/cleanup.js +0 -24
- package/lib/svg/data/attributes.js +0 -403
- package/lib/svg/data/tags.js +0 -188
- package/lib/svg/index.js +0 -134
- package/lib/svg/parse-style.js +0 -151
- package/lib/svg/parse.js +0 -49
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { ExportOptionsWithCustomFiles } from './helpers/custom-files';
|
|
1
|
+
import { IconSet } from '../icon-set/index.js';
|
|
2
|
+
import { ExportTargetOptions } from './helpers/prepare.js';
|
|
3
|
+
import { ExportOptionsWithCustomFiles } from './helpers/custom-files.js';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations';
|
|
6
|
+
import '../icon-set/types.js';
|
|
7
|
+
import '../svg/index.js';
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* Options
|
|
6
11
|
*/
|
|
7
|
-
|
|
12
|
+
interface ExportIconPackageOptions extends ExportTargetOptions, ExportOptionsWithCustomFiles {
|
|
8
13
|
package?: Record<string, unknown>;
|
|
9
14
|
module?: boolean;
|
|
10
15
|
typesContent?: string;
|
|
@@ -14,4 +19,6 @@ export interface ExportIconPackageOptions extends ExportTargetOptions, ExportOpt
|
|
|
14
19
|
*
|
|
15
20
|
* Used for exporting `@iconify-icons/{prefix}` packages
|
|
16
21
|
*/
|
|
17
|
-
|
|
22
|
+
declare function exportIconPackage(iconSet: IconSet, options: ExportIconPackageOptions): Promise<string[]>;
|
|
23
|
+
|
|
24
|
+
export { ExportIconPackageOptions, exportIconPackage };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { prepareDirectoryForExport } from './helpers/prepare.mjs';
|
|
3
|
+
import { writeJSONFile } from '../misc/write-json.mjs';
|
|
4
|
+
import { getTypesVersion } from './helpers/types-version.mjs';
|
|
5
|
+
import { exportCustomFiles } from './helpers/custom-files.mjs';
|
|
6
|
+
import 'pathe';
|
|
7
|
+
import 'local-pkg';
|
|
8
|
+
|
|
9
|
+
const defaultTypesContent = `import type { IconifyIcon } from '@iconify/types';
|
|
10
10
|
declare const data: IconifyIcon;
|
|
11
11
|
export default data;
|
|
12
12
|
`;
|
|
13
13
|
async function exportIconPackage(iconSet, options) {
|
|
14
|
-
const files = new Set();
|
|
14
|
+
const files = /* @__PURE__ */ new Set();
|
|
15
15
|
const esm = options.module !== false;
|
|
16
16
|
const dir = await prepareDirectoryForExport(options);
|
|
17
17
|
const typesContent = options.typesContent || defaultTypesContent;
|
|
@@ -21,7 +21,7 @@ async function exportIconPackage(iconSet, options) {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
const typesFilename = name2 + ".d.ts";
|
|
24
|
-
await
|
|
24
|
+
await promises.writeFile(`${dir}/${typesFilename}`, typesContent, "utf8");
|
|
25
25
|
files.add(typesFilename);
|
|
26
26
|
let content = `const data = ` + JSON.stringify(data, null, " ") + ";\n";
|
|
27
27
|
if (!esm) {
|
|
@@ -30,7 +30,7 @@ async function exportIconPackage(iconSet, options) {
|
|
|
30
30
|
content += "export default data;\n";
|
|
31
31
|
}
|
|
32
32
|
const contentFilename = name2 + ".js";
|
|
33
|
-
await
|
|
33
|
+
await promises.writeFile(`${dir}/${contentFilename}`, content, "utf8");
|
|
34
34
|
files.add(contentFilename);
|
|
35
35
|
});
|
|
36
36
|
await exportCustomFiles(dir, options, files);
|
|
@@ -44,13 +44,12 @@ async function exportIconPackage(iconSet, options) {
|
|
|
44
44
|
iconSetInfo: info,
|
|
45
45
|
...customPackageProps,
|
|
46
46
|
dependencies: dependencies || {
|
|
47
|
-
"@iconify/types": "^" + getTypesVersion()
|
|
47
|
+
"@iconify/types": "^" + await getTypesVersion()
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
await writeJSONFile(dir + "/package.json", packageJSON);
|
|
51
51
|
files.add("package.json");
|
|
52
52
|
return Array.from(files);
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
54
|
+
|
|
55
|
+
export { exportIconPackage };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const icon = require('@iconify/utils/lib/icon');
|
|
7
|
+
const export_helpers_prepare = require('./helpers/prepare.cjs');
|
|
8
|
+
const misc_writeJson = require('../misc/write-json.cjs');
|
|
9
|
+
const export_helpers_typesVersion = require('./helpers/types-version.cjs');
|
|
10
|
+
const export_helpers_customFiles = require('./helpers/custom-files.cjs');
|
|
11
|
+
require('pathe');
|
|
12
|
+
require('local-pkg');
|
|
13
|
+
|
|
14
|
+
const exportTypes = {
|
|
15
|
+
icons: "IconifyJSON",
|
|
16
|
+
info: "IconifyInfo",
|
|
17
|
+
metadata: "IconifyMetaData",
|
|
18
|
+
chars: "IconifyChars"
|
|
19
|
+
};
|
|
20
|
+
const iconsKeys = ["aliases"].concat(Object.keys(icon.iconDefaults));
|
|
21
|
+
const metadataKeys = [
|
|
22
|
+
"categories",
|
|
23
|
+
"themes",
|
|
24
|
+
"prefixes",
|
|
25
|
+
"suffixes"
|
|
26
|
+
];
|
|
27
|
+
async function exportJSONPackage(iconSet, options) {
|
|
28
|
+
const files = /* @__PURE__ */ new Set();
|
|
29
|
+
const dir = await export_helpers_prepare.prepareDirectoryForExport(options);
|
|
30
|
+
const exportedJSON = iconSet.export(true);
|
|
31
|
+
const icons = {
|
|
32
|
+
prefix: exportedJSON.prefix,
|
|
33
|
+
icons: exportedJSON.icons
|
|
34
|
+
};
|
|
35
|
+
iconsKeys.forEach((attr) => {
|
|
36
|
+
if (exportedJSON[attr] !== void 0) {
|
|
37
|
+
icons[attr] = exportedJSON[attr];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const metadata = {};
|
|
41
|
+
let hasMetadata = false;
|
|
42
|
+
metadataKeys.forEach((attr) => {
|
|
43
|
+
if (exportedJSON[attr]) {
|
|
44
|
+
metadata[attr] = exportedJSON[attr];
|
|
45
|
+
hasMetadata = true;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const info = exportedJSON.info ? {
|
|
49
|
+
prefix: iconSet.prefix,
|
|
50
|
+
...exportedJSON.info
|
|
51
|
+
} : void 0;
|
|
52
|
+
const contents = {
|
|
53
|
+
icons,
|
|
54
|
+
info,
|
|
55
|
+
metadata: hasMetadata ? metadata : void 0,
|
|
56
|
+
chars: exportedJSON.chars
|
|
57
|
+
};
|
|
58
|
+
const { name, description, version, dependencies, ...customPackageProps } = options.package || {};
|
|
59
|
+
const packageJSONIconSet = {};
|
|
60
|
+
const packageJSONExports = {
|
|
61
|
+
"./*": "./*",
|
|
62
|
+
".": {
|
|
63
|
+
require: "./index.js",
|
|
64
|
+
import: "./index.mjs"
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const packageJSON = {
|
|
68
|
+
name: name || `@iconify-json/${iconSet.prefix}`,
|
|
69
|
+
description: description || `${info ? info.name : iconSet.prefix} icon set in Iconify JSON format`,
|
|
70
|
+
version,
|
|
71
|
+
iconSetVersion: info?.version,
|
|
72
|
+
main: "index.js",
|
|
73
|
+
module: "index.mjs",
|
|
74
|
+
types: "index.d.ts",
|
|
75
|
+
...customPackageProps,
|
|
76
|
+
exports: packageJSONExports,
|
|
77
|
+
iconSet: packageJSONIconSet,
|
|
78
|
+
dependencies: dependencies || {
|
|
79
|
+
"@iconify/types": "^" + await export_helpers_typesVersion.getTypesVersion()
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const dtsContent = [];
|
|
83
|
+
const cjsImports = [];
|
|
84
|
+
const cjsExports = [];
|
|
85
|
+
const mjsImports = [];
|
|
86
|
+
const mjsConsts = [];
|
|
87
|
+
const mjsExports = [];
|
|
88
|
+
for (const key in contents) {
|
|
89
|
+
const attr = key;
|
|
90
|
+
const data = contents[attr];
|
|
91
|
+
const type = exportTypes[attr];
|
|
92
|
+
const jsonFilename = attr + ".json";
|
|
93
|
+
const relativeFile = `./${jsonFilename}`;
|
|
94
|
+
dtsContent.push(`export declare const ${attr}: ${type};`);
|
|
95
|
+
cjsExports.push(`exports.${attr} = ${attr};`);
|
|
96
|
+
mjsExports.push(attr);
|
|
97
|
+
if (data !== void 0) {
|
|
98
|
+
await misc_writeJson.writeJSONFile(`${dir}/${jsonFilename}`, data);
|
|
99
|
+
cjsImports.push(`const ${attr} = require('${relativeFile}');`);
|
|
100
|
+
mjsImports.push(`import ${attr} from '${relativeFile}';`);
|
|
101
|
+
packageJSONIconSet[attr] = attr + ".json";
|
|
102
|
+
packageJSONExports[relativeFile] = relativeFile;
|
|
103
|
+
} else {
|
|
104
|
+
await misc_writeJson.writeJSONFile(`${dir}/${jsonFilename}`, {});
|
|
105
|
+
cjsImports.push(`const ${attr} = {};`);
|
|
106
|
+
mjsConsts.push(`const ${attr} = {};`);
|
|
107
|
+
}
|
|
108
|
+
files.add(jsonFilename);
|
|
109
|
+
}
|
|
110
|
+
const cjsContent = cjsImports.concat([""], cjsExports);
|
|
111
|
+
await fs.promises.writeFile(dir + "/index.js", cjsContent.join("\n") + "\n", "utf8");
|
|
112
|
+
files.add("index.js");
|
|
113
|
+
const mjsContent = mjsImports.concat([""], mjsConsts, [
|
|
114
|
+
`export { ${mjsExports.join(", ")} };`
|
|
115
|
+
]);
|
|
116
|
+
await fs.promises.writeFile(dir + "/index.mjs", mjsContent.join("\n") + "\n", "utf8");
|
|
117
|
+
files.add("index.mjs");
|
|
118
|
+
const usedTypes = Object.values(exportTypes);
|
|
119
|
+
const typesData = [
|
|
120
|
+
`import type { ${usedTypes.join(", ")} } from '@iconify/types';`,
|
|
121
|
+
"",
|
|
122
|
+
`export { ${usedTypes.join(", ")} };`,
|
|
123
|
+
""
|
|
124
|
+
].concat(dtsContent);
|
|
125
|
+
await fs.promises.writeFile(dir + "/index.d.ts", typesData.join("\n") + "\n", "utf8");
|
|
126
|
+
files.add("index.d.ts");
|
|
127
|
+
await export_helpers_customFiles.exportCustomFiles(dir, options, files);
|
|
128
|
+
await misc_writeJson.writeJSONFile(dir + "/package.json", packageJSON);
|
|
129
|
+
files.add("package.json");
|
|
130
|
+
return Array.from(files);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
exports.exportJSONPackage = exportJSONPackage;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { ExportOptionsWithCustomFiles } from './helpers/custom-files';
|
|
1
|
+
import { IconSet } from '../icon-set/index.js';
|
|
2
|
+
import { ExportTargetOptions } from './helpers/prepare.js';
|
|
3
|
+
import { ExportOptionsWithCustomFiles } from './helpers/custom-files.js';
|
|
4
|
+
import '@iconify/types';
|
|
5
|
+
import '@iconify/utils/lib/customisations';
|
|
6
|
+
import '../icon-set/types.js';
|
|
7
|
+
import '../svg/index.js';
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* Options
|
|
6
11
|
*/
|
|
7
|
-
|
|
12
|
+
interface ExportJSONPackageOptions extends ExportTargetOptions, ExportOptionsWithCustomFiles {
|
|
8
13
|
package?: Record<string, unknown>;
|
|
9
14
|
}
|
|
10
15
|
/**
|
|
@@ -12,4 +17,6 @@ export interface ExportJSONPackageOptions extends ExportTargetOptions, ExportOpt
|
|
|
12
17
|
*
|
|
13
18
|
* Used for exporting `@iconify-json/{prefix}` packages
|
|
14
19
|
*/
|
|
15
|
-
|
|
20
|
+
declare function exportJSONPackage(iconSet: IconSet, options: ExportJSONPackageOptions): Promise<string[]>;
|
|
21
|
+
|
|
22
|
+
export { ExportJSONPackageOptions, exportJSONPackage };
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { iconDefaults } from '@iconify/utils/lib/icon';
|
|
3
|
+
import { prepareDirectoryForExport } from './helpers/prepare.mjs';
|
|
4
|
+
import { writeJSONFile } from '../misc/write-json.mjs';
|
|
5
|
+
import { getTypesVersion } from './helpers/types-version.mjs';
|
|
6
|
+
import { exportCustomFiles } from './helpers/custom-files.mjs';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import 'local-pkg';
|
|
9
|
+
|
|
10
|
+
const exportTypes = {
|
|
11
11
|
icons: "IconifyJSON",
|
|
12
12
|
info: "IconifyInfo",
|
|
13
13
|
metadata: "IconifyMetaData",
|
|
14
14
|
chars: "IconifyChars"
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const iconsKeys = ["aliases"].concat(Object.keys(iconDefaults));
|
|
17
|
+
const metadataKeys = [
|
|
18
18
|
"categories",
|
|
19
19
|
"themes",
|
|
20
20
|
"prefixes",
|
|
21
21
|
"suffixes"
|
|
22
22
|
];
|
|
23
23
|
async function exportJSONPackage(iconSet, options) {
|
|
24
|
-
const files = new Set();
|
|
24
|
+
const files = /* @__PURE__ */ new Set();
|
|
25
25
|
const dir = await prepareDirectoryForExport(options);
|
|
26
26
|
const exportedJSON = iconSet.export(true);
|
|
27
27
|
const icons = {
|
|
@@ -64,7 +64,7 @@ async function exportJSONPackage(iconSet, options) {
|
|
|
64
64
|
name: name || `@iconify-json/${iconSet.prefix}`,
|
|
65
65
|
description: description || `${info ? info.name : iconSet.prefix} icon set in Iconify JSON format`,
|
|
66
66
|
version,
|
|
67
|
-
iconSetVersion: info
|
|
67
|
+
iconSetVersion: info?.version,
|
|
68
68
|
main: "index.js",
|
|
69
69
|
module: "index.mjs",
|
|
70
70
|
types: "index.d.ts",
|
|
@@ -72,7 +72,7 @@ async function exportJSONPackage(iconSet, options) {
|
|
|
72
72
|
exports: packageJSONExports,
|
|
73
73
|
iconSet: packageJSONIconSet,
|
|
74
74
|
dependencies: dependencies || {
|
|
75
|
-
"@iconify/types": "^" + getTypesVersion()
|
|
75
|
+
"@iconify/types": "^" + await getTypesVersion()
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
const dtsContent = [];
|
|
@@ -104,12 +104,12 @@ async function exportJSONPackage(iconSet, options) {
|
|
|
104
104
|
files.add(jsonFilename);
|
|
105
105
|
}
|
|
106
106
|
const cjsContent = cjsImports.concat([""], cjsExports);
|
|
107
|
-
await
|
|
107
|
+
await promises.writeFile(dir + "/index.js", cjsContent.join("\n") + "\n", "utf8");
|
|
108
108
|
files.add("index.js");
|
|
109
109
|
const mjsContent = mjsImports.concat([""], mjsConsts, [
|
|
110
110
|
`export { ${mjsExports.join(", ")} };`
|
|
111
111
|
]);
|
|
112
|
-
await
|
|
112
|
+
await promises.writeFile(dir + "/index.mjs", mjsContent.join("\n") + "\n", "utf8");
|
|
113
113
|
files.add("index.mjs");
|
|
114
114
|
const usedTypes = Object.values(exportTypes);
|
|
115
115
|
const typesData = [
|
|
@@ -118,13 +118,12 @@ async function exportJSONPackage(iconSet, options) {
|
|
|
118
118
|
`export { ${usedTypes.join(", ")} };`,
|
|
119
119
|
""
|
|
120
120
|
].concat(dtsContent);
|
|
121
|
-
await
|
|
121
|
+
await promises.writeFile(dir + "/index.d.ts", typesData.join("\n") + "\n", "utf8");
|
|
122
122
|
files.add("index.d.ts");
|
|
123
123
|
await exportCustomFiles(dir, options, files);
|
|
124
124
|
await writeJSONFile(dir + "/package.json", packageJSON);
|
|
125
125
|
files.add("package.json");
|
|
126
126
|
return Array.from(files);
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
128
|
+
|
|
129
|
+
export { exportJSONPackage };
|