完成世界书、骰子、apiconfig页面处理
This commit is contained in:
26
frontend/node_modules/@iconify/utils/lib/icon-set/convert-info.d.ts
generated
vendored
Normal file
26
frontend/node_modules/@iconify/utils/lib/icon-set/convert-info.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { IconifyInfo } from "@iconify/types";
|
||||
/**
|
||||
* Item provided by API or loaded from collections.json, slightly different from IconifyInfo
|
||||
*/
|
||||
interface LegacyIconifyInfo {
|
||||
name: string;
|
||||
total?: number;
|
||||
version?: string;
|
||||
author?: string;
|
||||
url?: string;
|
||||
license?: string;
|
||||
licenseURL?: string;
|
||||
licenseSPDX?: string;
|
||||
samples?: string[];
|
||||
height?: number | number[];
|
||||
displayHeight?: number;
|
||||
samplesHeight?: number;
|
||||
category?: string;
|
||||
palette?: 'Colorless' | 'Colorful';
|
||||
hidden?: boolean;
|
||||
}
|
||||
/**
|
||||
* Convert data to valid CollectionInfo
|
||||
*/
|
||||
declare function convertIconSetInfo(data: unknown, expectedPrefix?: string): IconifyInfo | null;
|
||||
export { LegacyIconifyInfo, convertIconSetInfo };
|
||||
126
frontend/node_modules/@iconify/utils/lib/icon-set/convert-info.js
generated
vendored
Normal file
126
frontend/node_modules/@iconify/utils/lib/icon-set/convert-info.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
const minDisplayHeight = 16;
|
||||
const maxDisplayHeight = 24;
|
||||
/**
|
||||
* Check if displayHeight value is valid, returns 0 on failure
|
||||
*/
|
||||
function validateDisplayHeight(value) {
|
||||
while (value < minDisplayHeight) value *= 2;
|
||||
while (value > maxDisplayHeight) value /= 2;
|
||||
return value === Math.round(value) && value >= minDisplayHeight && value <= maxDisplayHeight ? value : 0;
|
||||
}
|
||||
/**
|
||||
* Convert data to valid CollectionInfo
|
||||
*/
|
||||
function convertIconSetInfo(data, expectedPrefix = "") {
|
||||
if (typeof data !== "object" || data === null) return null;
|
||||
const source = data;
|
||||
const getSourceNestedString = (field, key, defaultValue = "") => {
|
||||
if (typeof source[field] !== "object") return defaultValue;
|
||||
const obj = source[field];
|
||||
return typeof obj[key] === "string" ? obj[key] : defaultValue;
|
||||
};
|
||||
let name;
|
||||
if (typeof source.name === "string") name = source.name;
|
||||
else if (typeof source.title === "string") name = source.title;
|
||||
else return null;
|
||||
if (expectedPrefix !== "" && typeof source.prefix === "string" && source.prefix !== expectedPrefix) return null;
|
||||
const info = { name };
|
||||
switch (typeof source.total) {
|
||||
case "number":
|
||||
info.total = source.total;
|
||||
break;
|
||||
case "string": {
|
||||
const num = parseInt(source.total);
|
||||
if (num > 0) info.total = num;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (typeof source.version === "string") info.version = source.version;
|
||||
info.author = { name: getSourceNestedString("author", "name", typeof source.author === "string" ? source.author : "") };
|
||||
if (typeof source.author === "object") {
|
||||
const sourceAuthor = source.author;
|
||||
if (typeof sourceAuthor.url === "string") info.author.url = sourceAuthor.url;
|
||||
}
|
||||
info.license = { title: getSourceNestedString("license", "title", typeof source.license === "string" ? source.license : "") };
|
||||
if (typeof source.license === "object") {
|
||||
const sourceLicense = source.license;
|
||||
if (typeof sourceLicense.spdx === "string") info.license.spdx = sourceLicense.spdx;
|
||||
if (typeof sourceLicense.url === "string") info.license.url = sourceLicense.url;
|
||||
}
|
||||
if (source.samples instanceof Array) {
|
||||
const samples = [];
|
||||
source.samples.forEach((item) => {
|
||||
if (typeof item === "string" && !samples.includes(item)) samples.push(item);
|
||||
});
|
||||
if (samples.length) info.samples = samples;
|
||||
}
|
||||
if (typeof source.height === "number" || typeof source.height === "string") {
|
||||
const num = parseInt(source.height);
|
||||
if (num > 0) info.height = num;
|
||||
}
|
||||
if (source.height instanceof Array) {
|
||||
source.height.forEach((item) => {
|
||||
const num = parseInt(item);
|
||||
if (num > 0) {
|
||||
if (!(info.height instanceof Array)) info.height = [];
|
||||
info.height.push(num);
|
||||
}
|
||||
});
|
||||
switch (info.height.length) {
|
||||
case 0:
|
||||
delete info.height;
|
||||
break;
|
||||
case 1: info.height = info.height[0];
|
||||
}
|
||||
}
|
||||
if (typeof info.height === "number") {
|
||||
const displayHeight = validateDisplayHeight(info.height);
|
||||
if (displayHeight && displayHeight !== info.height) info.displayHeight = displayHeight;
|
||||
}
|
||||
["samplesHeight", "displayHeight"].forEach((prop) => {
|
||||
const value = source[prop];
|
||||
if (typeof value === "number" || typeof value === "string") {
|
||||
const displayHeight = validateDisplayHeight(parseInt(value));
|
||||
if (displayHeight) info.displayHeight = displayHeight;
|
||||
}
|
||||
});
|
||||
if (typeof source.category === "string") info.category = source.category;
|
||||
if (source.tags instanceof Array) info.tags = source.tags;
|
||||
switch (typeof source.palette) {
|
||||
case "boolean":
|
||||
info.palette = source.palette;
|
||||
break;
|
||||
case "string":
|
||||
switch (source.palette.toLowerCase()) {
|
||||
case "colorless":
|
||||
case "false":
|
||||
info.palette = false;
|
||||
break;
|
||||
case "colorful":
|
||||
case "true": info.palette = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (source.hidden === true) info.hidden = true;
|
||||
Object.keys(source).forEach((key) => {
|
||||
const value = source[key];
|
||||
if (typeof value !== "string") return;
|
||||
switch (key) {
|
||||
case "url":
|
||||
case "uri":
|
||||
info.author.url = value;
|
||||
break;
|
||||
case "licenseURL":
|
||||
case "licenseURI":
|
||||
info.license.url = value;
|
||||
break;
|
||||
case "licenseID":
|
||||
case "licenseSPDX":
|
||||
info.license.spdx = value;
|
||||
break;
|
||||
}
|
||||
});
|
||||
return info;
|
||||
}
|
||||
|
||||
export { convertIconSetInfo };
|
||||
8
frontend/node_modules/@iconify/utils/lib/icon-set/expand.d.ts
generated
vendored
Normal file
8
frontend/node_modules/@iconify/utils/lib/icon-set/expand.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { IconifyJSON } from "@iconify/types";
|
||||
/**
|
||||
* Expand minified icon set
|
||||
*
|
||||
* Opposite of minifyIconSet() from ./minify.ts
|
||||
*/
|
||||
declare function expandIconSet(data: IconifyJSON): void;
|
||||
export { expandIconSet };
|
||||
10
frontend/node_modules/@iconify/utils/lib/icon-set/get-icon.d.ts
generated
vendored
Normal file
10
frontend/node_modules/@iconify/utils/lib/icon-set/get-icon.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { ExtendedIconifyIcon, IconifyJSON } from "@iconify/types";
|
||||
/**
|
||||
* Get icon data, using prepared aliases tree
|
||||
*/
|
||||
declare function internalGetIconData(data: IconifyJSON, name: string, tree: string[]): ExtendedIconifyIcon;
|
||||
/**
|
||||
* Get data for icon
|
||||
*/
|
||||
declare function getIconData(data: IconifyJSON, name: string): ExtendedIconifyIcon | null;
|
||||
export { getIconData, internalGetIconData };
|
||||
38
frontend/node_modules/@iconify/utils/lib/icon-set/get-icons.js
generated
vendored
Normal file
38
frontend/node_modules/@iconify/utils/lib/icon-set/get-icons.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { defaultIconDimensions } from "../icon/defaults.js";
|
||||
import { getIconsTree } from "./tree.js";
|
||||
|
||||
/**
|
||||
* Optional properties that must be copied when copying icon set
|
||||
*/
|
||||
const propsToCopy = Object.keys(defaultIconDimensions).concat(["provider"]);
|
||||
/**
|
||||
* Extract icons from icon set
|
||||
*/
|
||||
function getIcons(data, names, not_found) {
|
||||
const icons = Object.create(null);
|
||||
const aliases = Object.create(null);
|
||||
const result = {
|
||||
prefix: data.prefix,
|
||||
icons
|
||||
};
|
||||
const sourceIcons = data.icons;
|
||||
const sourceAliases = data.aliases || Object.create(null);
|
||||
if (data.lastModified) result.lastModified = data.lastModified;
|
||||
const tree = getIconsTree(data, names);
|
||||
let empty = true;
|
||||
for (const name in tree) if (!tree[name]) {
|
||||
if (not_found && names.indexOf(name) !== -1) (result.not_found || (result.not_found = [])).push(name);
|
||||
} else if (sourceIcons[name]) {
|
||||
icons[name] = { ...sourceIcons[name] };
|
||||
empty = false;
|
||||
} else {
|
||||
aliases[name] = { ...sourceAliases[name] };
|
||||
result.aliases = aliases;
|
||||
}
|
||||
propsToCopy.forEach((attr) => {
|
||||
if (attr in data) result[attr] = data[attr];
|
||||
});
|
||||
return empty && not_found !== true ? null : result;
|
||||
}
|
||||
|
||||
export { getIcons, propsToCopy };
|
||||
43
frontend/node_modules/@iconify/utils/lib/icon-set/minify.d.ts
generated
vendored
Normal file
43
frontend/node_modules/@iconify/utils/lib/icon-set/minify.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import { IconifyJSON } from "@iconify/types";
|
||||
/**
|
||||
* Minify icon set
|
||||
*
|
||||
* Function finds common values for few numeric properties, such as 'width' and 'height' (see defaultIconDimensions keys for list of properties),
|
||||
* removes entries from icons and sets default entry in root of icon set object.
|
||||
*
|
||||
* For example, this:
|
||||
* {
|
||||
* icons: {
|
||||
* foo: {
|
||||
* body: '<g />',
|
||||
* width: 24
|
||||
* },
|
||||
* bar: {
|
||||
* body: '<g />',
|
||||
* width: 24
|
||||
* },
|
||||
* baz: {
|
||||
* body: '<g />',
|
||||
* width: 16
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* is changed to this:
|
||||
* {
|
||||
* icons: {
|
||||
* foo: {
|
||||
* body: '<g />'
|
||||
* },
|
||||
* bar: {
|
||||
* body: '<g />'
|
||||
* },
|
||||
* baz: {
|
||||
* body: '<g />',
|
||||
* width: 16
|
||||
* }
|
||||
* },
|
||||
* width: 24
|
||||
* }
|
||||
*/
|
||||
declare function minifyIconSet(data: IconifyJSON): void;
|
||||
export { minifyIconSet };
|
||||
19
frontend/node_modules/@iconify/utils/lib/icon-set/parse.d.ts
generated
vendored
Normal file
19
frontend/node_modules/@iconify/utils/lib/icon-set/parse.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { ExtendedIconifyIcon, IconifyJSON } from "@iconify/types";
|
||||
/**
|
||||
* Callback to call for each icon.
|
||||
*
|
||||
* If data === null, icon is missing.
|
||||
*/
|
||||
type SplitIconSetCallback = (name: string, data: ExtendedIconifyIcon | null) => unknown;
|
||||
type SplitIconSetAsyncCallback = (name: string, data: ExtendedIconifyIcon | null) => Promise<unknown>;
|
||||
/**
|
||||
* Extract icons from an icon set
|
||||
*
|
||||
* Returns list of icons that were found in icon set
|
||||
*/
|
||||
declare function parseIconSet(data: IconifyJSON, callback: SplitIconSetCallback): string[];
|
||||
/**
|
||||
* Async version of parseIconSet()
|
||||
*/
|
||||
declare function parseIconSetAsync(data: IconifyJSON, callback: SplitIconSetAsyncCallback): Promise<string[]>;
|
||||
export { SplitIconSetAsyncCallback, SplitIconSetCallback, parseIconSet, parseIconSetAsync };
|
||||
48
frontend/node_modules/@iconify/utils/lib/icon-set/parse.js
generated
vendored
Normal file
48
frontend/node_modules/@iconify/utils/lib/icon-set/parse.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import { getIconsTree } from "./tree.js";
|
||||
import { internalGetIconData } from "./get-icon.js";
|
||||
|
||||
/**
|
||||
* Extract icons from an icon set
|
||||
*
|
||||
* Returns list of icons that were found in icon set
|
||||
*/
|
||||
function parseIconSet(data, callback) {
|
||||
const names = [];
|
||||
if (typeof data !== "object" || typeof data.icons !== "object") return names;
|
||||
if (data.not_found instanceof Array) data.not_found.forEach((name) => {
|
||||
callback(name, null);
|
||||
names.push(name);
|
||||
});
|
||||
const tree = getIconsTree(data);
|
||||
for (const name in tree) {
|
||||
const item = tree[name];
|
||||
if (item) {
|
||||
callback(name, internalGetIconData(data, name, item));
|
||||
names.push(name);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
/**
|
||||
* Async version of parseIconSet()
|
||||
*/
|
||||
async function parseIconSetAsync(data, callback) {
|
||||
const names = [];
|
||||
if (typeof data !== "object" || typeof data.icons !== "object") return names;
|
||||
if (data.not_found instanceof Array) for (let i = 0; i < data.not_found.length; i++) {
|
||||
const name = data.not_found[i];
|
||||
await callback(name, null);
|
||||
names.push(name);
|
||||
}
|
||||
const tree = getIconsTree(data);
|
||||
for (const name in tree) {
|
||||
const item = tree[name];
|
||||
if (item) {
|
||||
await callback(name, internalGetIconData(data, name, item));
|
||||
names.push(name);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
export { parseIconSet, parseIconSetAsync };
|
||||
Reference in New Issue
Block a user