@iconify/tools 5.0.0-beta.1 → 5.0.0-beta.3
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/download/github/index.d.ts +2 -0
- package/lib/download/github/index.js +3 -3
- package/lib/download/gitlab/index.d.ts +2 -0
- package/lib/download/gitlab/index.js +3 -3
- package/lib/download/helpers/unzip.d.ts +3 -2
- package/lib/download/helpers/unzip.js +2 -1
- package/lib/import/figma/types/api.d.ts +12 -1
- package/lib/import/figma/types/api.js +1 -0
- package/lib/import/figma/types/nodes.d.ts +1 -1
- package/lib/import/figma/types/nodes.js +1 -0
- package/lib/import/figma/types/options.d.ts +1 -1
- package/lib/import/figma/types/options.js +1 -0
- package/lib/import/figma/types/result.d.ts +1 -1
- package/lib/import/figma/types/result.js +1 -0
- package/lib/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2,8 +2,10 @@ import { ExportTargetOptions } from "../../export/helpers/prepare.js";
|
|
|
2
2
|
import { DocumentNotModified } from "../types/modified.js";
|
|
3
3
|
import { DownloadSourceMixin } from "../types/sources.js";
|
|
4
4
|
import { GitHubAPIOptions } from "./types.js";
|
|
5
|
+
import { UnzipFilterCallback } from "../helpers/unzip.js";
|
|
5
6
|
interface IfModifiedSinceOption {
|
|
6
7
|
ifModifiedSince: string | DownloadGitHubRepoResult;
|
|
8
|
+
filter?: UnzipFilterCallback;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Options for downloadGitHubRepo()
|
|
@@ -30,7 +30,7 @@ async function downloadGitHubRepo(options) {
|
|
|
30
30
|
let exists = false;
|
|
31
31
|
try {
|
|
32
32
|
exists = (await promises.stat(archiveTarget)).isFile();
|
|
33
|
-
} catch
|
|
33
|
+
} catch {}
|
|
34
34
|
if (!exists) await downloadFile({
|
|
35
35
|
uri: `https://api.github.com/repos/${options.user}/${options.repo}/zipball/${hash}`,
|
|
36
36
|
headers: {
|
|
@@ -50,9 +50,9 @@ async function downloadGitHubRepo(options) {
|
|
|
50
50
|
force: true,
|
|
51
51
|
recursive: true
|
|
52
52
|
});
|
|
53
|
-
} catch
|
|
53
|
+
} catch {}
|
|
54
54
|
}
|
|
55
|
-
await unzip(archiveTarget, rootDir);
|
|
55
|
+
await unzip(archiveTarget, rootDir, options.filter);
|
|
56
56
|
const matchingDirs = await findMatchingDirs(rootDir, hash);
|
|
57
57
|
if (matchingDirs.length !== 1) throw new Error(`Error unpacking ${hash}.zip`);
|
|
58
58
|
return {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ExportTargetOptions } from "../../export/helpers/prepare.js";
|
|
2
2
|
import { DocumentNotModified } from "../types/modified.js";
|
|
3
3
|
import { DownloadSourceMixin } from "../types/sources.js";
|
|
4
|
+
import { UnzipFilterCallback } from "../helpers/unzip.js";
|
|
4
5
|
import { GitLabAPIOptions } from "./types.js";
|
|
5
6
|
interface IfModifiedSinceOption {
|
|
6
7
|
ifModifiedSince: string | DownloadGitLabRepoResult;
|
|
8
|
+
filter?: UnzipFilterCallback;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Options for downloadGitLabRepo()
|
|
@@ -31,7 +31,7 @@ async function downloadGitLabRepo(options) {
|
|
|
31
31
|
let exists = false;
|
|
32
32
|
try {
|
|
33
33
|
exists = (await promises.stat(archiveTarget)).isFile();
|
|
34
|
-
} catch
|
|
34
|
+
} catch {}
|
|
35
35
|
if (!exists) await downloadFile({
|
|
36
36
|
uri: `${options.uri || defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`,
|
|
37
37
|
headers: { Authorization: "token " + options.token }
|
|
@@ -48,9 +48,9 @@ async function downloadGitLabRepo(options) {
|
|
|
48
48
|
force: true,
|
|
49
49
|
recursive: true
|
|
50
50
|
});
|
|
51
|
-
} catch
|
|
51
|
+
} catch {}
|
|
52
52
|
}
|
|
53
|
-
await unzip(archiveTarget, rootDir);
|
|
53
|
+
await unzip(archiveTarget, rootDir, options.filter);
|
|
54
54
|
const matchingDirs = await findMatchingDirs(rootDir, hash);
|
|
55
55
|
if (matchingDirs.length !== 1) throw new Error(`Error unpacking ${hash}.zip`);
|
|
56
56
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
type UnzipFilterCallback = (file: string) => boolean;
|
|
1
2
|
/**
|
|
2
3
|
* Unzip archive
|
|
3
4
|
*/
|
|
4
|
-
declare function unzip(source: string, path: string): Promise<void>;
|
|
5
|
-
export { unzip };
|
|
5
|
+
declare function unzip(source: string, path: string, filter?: UnzipFilterCallback): Promise<void>;
|
|
6
|
+
export { UnzipFilterCallback, unzip };
|
|
@@ -5,13 +5,14 @@ import { unzip as unzip$1 } from "fflate";
|
|
|
5
5
|
/**
|
|
6
6
|
* Unzip archive
|
|
7
7
|
*/
|
|
8
|
-
async function unzip(source, path) {
|
|
8
|
+
async function unzip(source, path, filter) {
|
|
9
9
|
const dir = normalize(path);
|
|
10
10
|
const data = await readFile(source);
|
|
11
11
|
async function writeFiles(data$1) {
|
|
12
12
|
const createdDirs = /* @__PURE__ */ new Set();
|
|
13
13
|
for (const name in data$1) {
|
|
14
14
|
const filePath = normalize(join(dir, name));
|
|
15
|
+
if (filter && !filter(filePath)) continue;
|
|
15
16
|
if (filePath.startsWith("/") || filePath.includes("..") || filePath.includes(":")) throw new Error("Invalid file path in zip: " + filePath);
|
|
16
17
|
if (filePath.includes("/._")) continue;
|
|
17
18
|
const isDir = filePath.endsWith("/");
|
|
@@ -38,4 +38,15 @@ interface FigmaDocument {
|
|
|
38
38
|
role: string;
|
|
39
39
|
editorType: 'figma' | 'figjam';
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
interface FigmaAPIError {
|
|
42
|
+
status: number;
|
|
43
|
+
err: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Result for retrieved icons
|
|
47
|
+
*/
|
|
48
|
+
interface FigmaAPIImagesResponse {
|
|
49
|
+
err?: string | null;
|
|
50
|
+
images: Record<string, string | null>;
|
|
51
|
+
}
|
|
52
|
+
export { FigmaAPIError, FigmaAPIImagesResponse, FigmaDocument, FigmaDocumentNode, FigmaNode, IconFigmaNode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -32,4 +32,4 @@ type FigmaImportParentNodeFilter = (node: FigmaParentNodeData[], document: Figma
|
|
|
32
32
|
*/
|
|
33
33
|
type FigmaIconNodeWithKeyword = Partial<FigmaIconNode> & Pick<FigmaIconNode, 'keyword'>;
|
|
34
34
|
type FigmaImportNodeFilter = (node: FigmaImportNodeData, nodes: FigmaNodesImportResult, document: FigmaDocument) => string | FigmaIconNodeWithKeyword | null | undefined;
|
|
35
|
-
export { FigmaImportNodeFilter, FigmaImportParentNodeFilter };
|
|
35
|
+
export { FigmaImportIconNodeType, FigmaImportNodeData, FigmaImportNodeFilter, FigmaImportParentNodeFilter, FigmaImportParentNodeType, FigmaParentNodeData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -47,4 +47,4 @@ interface FigmaImportOptions extends FigmaFilesQueryOptions, FigmaImagesQueryOpt
|
|
|
47
47
|
beforeImportingIcon?: FigmaImportedIconCallback;
|
|
48
48
|
afterImportingIcon?: FigmaImportedIconCallback;
|
|
49
49
|
}
|
|
50
|
-
export { FigmaFilesQueryOptions, FigmaGetIconNodesOptions, FigmaIfModifiedSinceOption, FigmaImagesQueryOptions, FigmaImportOptions };
|
|
50
|
+
export { FigmaFilesQueryOptions, FigmaGetIconNodesOptions, FigmaIfModifiedSinceOption, FigmaImagesQueryOptions, FigmaImportOptions, FigmaImportSVGOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -33,4 +33,4 @@ interface FigmaImportResult extends FigmaNodesCount {
|
|
|
33
33
|
iconSet: IconSet;
|
|
34
34
|
missing: FigmaIconNode[];
|
|
35
35
|
}
|
|
36
|
-
export { FigmaIconNode, FigmaImportResult, FigmaNodesImportResult };
|
|
36
|
+
export { FigmaIconNode, FigmaImportResult, FigmaNodesCount, FigmaNodesImportResult };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/lib/index.d.ts
CHANGED
|
@@ -14,11 +14,11 @@ import { getGitRepoHash } from "./download/git/hash.js";
|
|
|
14
14
|
import { downloadGitRepo } from "./download/git/index.js";
|
|
15
15
|
import { resetGitRepoContents } from "./download/git/reset.js";
|
|
16
16
|
import { getGitHubRepoHash } from "./download/github/hash.js";
|
|
17
|
+
import { unzip } from "./download/helpers/unzip.js";
|
|
17
18
|
import { downloadGitHubRepo } from "./download/github/index.js";
|
|
18
19
|
import { getGitLabRepoHash } from "./download/gitlab/hash.js";
|
|
19
20
|
import { downloadGitLabRepo } from "./download/gitlab/index.js";
|
|
20
21
|
import { untar } from "./download/helpers/untar.js";
|
|
21
|
-
import { unzip } from "./download/helpers/unzip.js";
|
|
22
22
|
import { downloadNPMPackage } from "./download/npm/index.js";
|
|
23
23
|
import { downloadPackage } from "./download/index.js";
|
|
24
24
|
import { getNPMVersion, getPackageVersion } from "./download/npm/version.js";
|
package/package.json
CHANGED