@iconify/json 1.1.408 → 2.0.0-beta.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.
@@ -0,0 +1,49 @@
1
+ import { PathLike } from 'fs';
2
+ import { IconifyInfo, IconifyJSON } from '@iconify/types';
3
+
4
+ /**
5
+ * This file is part of the iconify.design libraries.
6
+ *
7
+ * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
8
+ *
9
+ * @license MIT
10
+ *
11
+ * For the full copyright and license information, please view the license.txt
12
+ * file that is available in this file's directory.
13
+ */
14
+
15
+ /**
16
+ * Collection info map
17
+ */
18
+ declare type IconifyMetaDataCollection = {
19
+ [prefix: string]: IconifyInfo;
20
+ };
21
+ /**
22
+ * Locate JSON file
23
+ *
24
+ * @param {string} name Collection name
25
+ * @returns {string} Path to collection json file
26
+ */
27
+ declare const locate: (name: string) => PathLike;
28
+ /**
29
+ * Loads a collection.
30
+ *
31
+ * @param {PathLike} path The path to locate the `json` collection file.
32
+ * @return {Promise<IconifyJSON>}
33
+ */
34
+ declare const loadCollection: (path: PathLike) => Promise<IconifyJSON>;
35
+ /**
36
+ * Get a collection.
37
+ *
38
+ * @param {string} name The name of the collection
39
+ * @return {Promise<IconifyJSON>}
40
+ */
41
+ declare const lookupCollection: (name: string) => Promise<IconifyJSON>;
42
+ /**
43
+ * Get list of collections info.
44
+ *
45
+ * @return {Promise<IconifyMetaDataCollection>}
46
+ */
47
+ declare const lookupCollections: () => Promise<IconifyMetaDataCollection>;
48
+
49
+ export { IconifyMetaDataCollection, loadCollection, locate, lookupCollection, lookupCollections };
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";var __import_meta_url = typeof document === 'undefined' ? 'file://' + __filename : new URL('index.js', document.baseURI).href;Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts
2
+ var _fs = require('fs');
3
+ var _url = require('url');
4
+ var _pathe = require('pathe');
5
+ var _dirname = typeof __dirname !== "undefined" ? __dirname : _pathe.dirname.call(void 0, _url.fileURLToPath.call(void 0, __import_meta_url));
6
+ var dir = _pathe.join.call(void 0, _dirname, "/..");
7
+ var locate = (name) => _pathe.join.call(void 0, dir, `./json/${name}.json`);
8
+ var loadCollection = async (path) => {
9
+ return JSON.parse(await _fs.promises.readFile(path, "utf8"));
10
+ };
11
+ var lookupCollection = async (name) => {
12
+ return await loadCollection(locate(name));
13
+ };
14
+ var lookupCollections = async () => {
15
+ return JSON.parse(await _fs.promises.readFile(_pathe.join.call(void 0, dir, "./collections.json"), "utf8"));
16
+ };
17
+
18
+
19
+
20
+
21
+
22
+ exports.loadCollection = loadCollection; exports.locate = locate; exports.lookupCollection = lookupCollection; exports.lookupCollections = lookupCollections;
23
+ /**
24
+ * This file is part of the iconify.design libraries.
25
+ *
26
+ * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
27
+ *
28
+ * @license MIT
29
+ *
30
+ * For the full copyright and license information, please view the license.txt
31
+ * file that is available in this file's directory.
32
+ */
package/dist/index.mjs ADDED
@@ -0,0 +1,32 @@
1
+ // src/index.ts
2
+ import { promises as fs } from "fs";
3
+ import { fileURLToPath } from "url";
4
+ import { dirname, join } from "pathe";
5
+ var _dirname = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
6
+ var dir = join(_dirname, "/..");
7
+ var locate = (name) => join(dir, `./json/${name}.json`);
8
+ var loadCollection = async (path) => {
9
+ return JSON.parse(await fs.readFile(path, "utf8"));
10
+ };
11
+ var lookupCollection = async (name) => {
12
+ return await loadCollection(locate(name));
13
+ };
14
+ var lookupCollections = async () => {
15
+ return JSON.parse(await fs.readFile(join(dir, "./collections.json"), "utf8"));
16
+ };
17
+ export {
18
+ loadCollection,
19
+ locate,
20
+ lookupCollection,
21
+ lookupCollections
22
+ };
23
+ /**
24
+ * This file is part of the iconify.design libraries.
25
+ *
26
+ * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
27
+ *
28
+ * @license MIT
29
+ *
30
+ * For the full copyright and license information, please view the license.txt
31
+ * file that is available in this file's directory.
32
+ */
package/package.json CHANGED
@@ -2,12 +2,55 @@
2
2
  "name": "@iconify/json",
3
3
  "description": "Iconify icons collection in JSON format",
4
4
  "license": "MIT",
5
- "version": "1.1.408",
5
+ "version": "2.0.0-beta.0",
6
6
  "homepage": "https://iconify.design/icon-sets/",
7
- "main": "lib/finder.js",
8
7
  "bugs": "https://github.com/iconify/collections-json/issues",
9
8
  "repository": {
10
9
  "type": "git",
11
10
  "url": "git+ssh://git@github.com/iconify/collections-json.git"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "require": "./dist/index.js",
15
+ "import": "./dist/index.mjs"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "json",
21
+ "lib",
22
+ "collections.json",
23
+ "collections.md",
24
+ "composer.md",
25
+ "readme.md"
26
+ ],
27
+ "main": "dist/index.js",
28
+ "module": "dist/index.mjs",
29
+ "types": "dist/index.d.ts",
30
+ "scripts": {
31
+ "build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts",
32
+ "test-esm": "jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --config=jest.esm.config.ts",
33
+ "test-cjs": "yarn build && jest --clearCache && jest --config=jest.cjs.config.ts",
34
+ "test-locate-esm": "jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --config=jest.esm.config.ts src/locate.esm.test.ts -i",
35
+ "test-locate-cjs": "yarn build && jest --clearCache && jest --config=jest.cjs.config.ts src/locate.cjs.test.ts -i",
36
+ "test": "yarn test-esm && yarn test-cjs && yarn test-locate-esm && yarn test-locate-cjs"
37
+ },
38
+ "dependencies": {
39
+ "@iconify/types": "^1.0.9",
40
+ "pathe": "^0.0.2"
41
+ },
42
+ "devDependencies": {
43
+ "@types/jest": "^27.0.1",
44
+ "@types/node": "^16.9.1",
45
+ "@typescript-eslint/eslint-plugin": "^4.31.0",
46
+ "cross-env": "^7.0.3",
47
+ "eslint": "^7.32.0",
48
+ "esno": "^0.9.1",
49
+ "jest": "^27.2.0",
50
+ "jest-each": "^27.2.0",
51
+ "ts-jest": "^27.0.5",
52
+ "ts-node": "^10.2.1",
53
+ "tsup": "^4.14.0",
54
+ "typescript": "^4.4.3"
12
55
  }
13
- }
56
+ }
package/composer.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "name": "iconify/json",
3
- "description": "Iconify icons collection in JSON format",
4
- "type": "library",
5
- "version": "1.1.408",
6
- "license": "MIT",
7
- "homepage": "https://iconify.design/icon-sets/",
8
- "autoload": {
9
- "psr-4": {
10
- "Iconify\\IconsJSON\\": "lib"
11
- }
12
- }
13
- }
package/lib/finder.js DELETED
@@ -1,49 +0,0 @@
1
- /**
2
- * This file is part of the iconify.design libraries.
3
- *
4
- * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
5
- *
6
- * @license MIT
7
- *
8
- * For the full copyright and license information, please view the license.txt
9
- * file that is available in this file's directory.
10
- */
11
-
12
- "use strict";
13
-
14
- const path = require('path');
15
- const fs = require('fs');
16
- const dir = path.dirname(__dirname);
17
-
18
- module.exports = {
19
- /**
20
- * Get root directory of this package
21
- * (not really useful in Node.js because require can do it, but added anyway to match php code)
22
- *
23
- * @returns {string}
24
- */
25
- rootDir: () => dir,
26
-
27
- /**
28
- * Locate JSON file
29
- *
30
- * @param {string} name Collection name
31
- * @returns {string} Path to collection json file
32
- */
33
- locate: name => dir + '/json/' + name + '.json',
34
-
35
- /**
36
- * Get list of collections
37
- *
38
- * @return {object|null}
39
- */
40
- collections: () => {
41
- try {
42
- let data = fs.readFileSync(dir + '/collections.json', 'utf8');
43
- data = JSON.parse(data);
44
- return data;
45
- } catch (err) {
46
- return null;
47
- }
48
- }
49
- };