diff --git a/.gitattributes b/.gitattributes index e8c09ad00a4d802e22f0e9e2246b52f1bb1ecb25..280c374d5b6aacfa735c88051cb2b7bf25ef7590 100644 --- a/.gitattributes +++ b/.gitattributes @@ -103,3 +103,5 @@ tools/ui/node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node fil tools/ui/node_modules/@rollup/rollup-linux-x64-musl/rollup.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text tools/ui/node_modules/@tailwindcss/oxide-linux-x64-gnu/tailwindcss-oxide.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text tools/ui/node_modules/@tailwindcss/oxide-linux-x64-musl/tailwindcss-oxide.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text +tools/ui/node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text +tools/ui/node_modules/lightningcss-linux-x64-musl/lightningcss.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text diff --git a/tools/ui/node_modules/khroma/dist/index.js b/tools/ui/node_modules/khroma/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c9da5b3be8731a98c7c2581671b3ad37eb588350 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/index.js @@ -0,0 +1,2 @@ +/* EXPORT */ +export * from './methods/index.js'; diff --git a/tools/ui/node_modules/khroma/dist/methods/adjust.d.ts b/tools/ui/node_modules/khroma/dist/methods/adjust.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d43c3e78ba386f69abd71df9c956737a466d865 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/adjust.d.ts @@ -0,0 +1,3 @@ +import type { CHANNELS, Channels } from '../types'; +declare const adjust: (color: string | Channels, channels: Partial) => string; +export default adjust; diff --git a/tools/ui/node_modules/khroma/dist/methods/adjust.js b/tools/ui/node_modules/khroma/dist/methods/adjust.js new file mode 100644 index 0000000000000000000000000000000000000000..dbcfb7905555d94e56db7c67a7387c2f884b4710 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/adjust.js @@ -0,0 +1,16 @@ +/* IMPORT */ +import Color from '../color/index.js'; +import change from './change.js'; +/* MAIN */ +const adjust = (color, channels) => { + const ch = Color.parse(color); + const changes = {}; + for (const c in channels) { + if (!channels[c]) + continue; + changes[c] = ch[c] + channels[c]; + } + return change(color, changes); +}; +/* EXPORT */ +export default adjust; diff --git a/tools/ui/node_modules/khroma/dist/methods/adjust_channel.d.ts b/tools/ui/node_modules/khroma/dist/methods/adjust_channel.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a13a7bada9400f27b7099eba78bfee019950c73 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/adjust_channel.d.ts @@ -0,0 +1,3 @@ +import type { CHANNEL, Channels } from '../types'; +declare const adjustChannel: (color: string | Channels, channel: CHANNEL, amount: number) => string; +export default adjustChannel; diff --git a/tools/ui/node_modules/khroma/dist/methods/adjust_channel.js b/tools/ui/node_modules/khroma/dist/methods/adjust_channel.js new file mode 100644 index 0000000000000000000000000000000000000000..1def4f1142a7c61b3f399143335086866a4b9b97 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/adjust_channel.js @@ -0,0 +1,14 @@ +/* IMPORT */ +import _ from '../utils/index.js'; +import Color from '../color/index.js'; +/* MAIN */ +const adjustChannel = (color, channel, amount) => { + const channels = Color.parse(color); + const amountCurrent = channels[channel]; + const amountNext = _.channel.clamp[channel](amountCurrent + amount); + if (amountCurrent !== amountNext) + channels[channel] = amountNext; + return Color.stringify(channels); +}; +/* EXPORT */ +export default adjustChannel; diff --git a/tools/ui/node_modules/khroma/dist/methods/alpha.d.ts b/tools/ui/node_modules/khroma/dist/methods/alpha.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..74b2fe2fe76efa2a89e3dbb7860cf62a6e230c5b --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/alpha.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const alpha: (color: string | Channels) => number; +export default alpha; diff --git a/tools/ui/node_modules/khroma/dist/methods/alpha.js b/tools/ui/node_modules/khroma/dist/methods/alpha.js new file mode 100644 index 0000000000000000000000000000000000000000..4b4643f7c1500a0a6b0c6c1ec41b5cdb865ac0f9 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/alpha.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import channel from './channel.js'; +/* MAIN */ +const alpha = (color) => { + return channel(color, 'a'); +}; +/* EXPORT */ +export default alpha; diff --git a/tools/ui/node_modules/khroma/dist/methods/blue.d.ts b/tools/ui/node_modules/khroma/dist/methods/blue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..23a9fcea87c96a9902b62432b285f90756a11116 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/blue.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const blue: (color: string | Channels) => number; +export default blue; diff --git a/tools/ui/node_modules/khroma/dist/methods/blue.js b/tools/ui/node_modules/khroma/dist/methods/blue.js new file mode 100644 index 0000000000000000000000000000000000000000..4c0287f34d47970f177e2102952751ff52211a00 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/blue.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import channel from './channel.js'; +/* MAIN */ +const blue = (color) => { + return channel(color, 'b'); +}; +/* EXPORT */ +export default blue; diff --git a/tools/ui/node_modules/khroma/dist/methods/change.d.ts b/tools/ui/node_modules/khroma/dist/methods/change.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..40ec122fc3212b036533167e8c17d22d432b92d1 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/change.d.ts @@ -0,0 +1,3 @@ +import type { CHANNELS, Channels } from '../types'; +declare const change: (color: string | Channels, channels: Partial) => string; +export default change; diff --git a/tools/ui/node_modules/khroma/dist/methods/change.js b/tools/ui/node_modules/khroma/dist/methods/change.js new file mode 100644 index 0000000000000000000000000000000000000000..2ae84b20a7977ea971f63ec6c0f9a66d5c790e08 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/change.js @@ -0,0 +1,13 @@ +/* IMPORT */ +import _ from '../utils/index.js'; +import Color from '../color/index.js'; +/* MAIN */ +const change = (color, channels) => { + const ch = Color.parse(color); + for (const c in channels) { + ch[c] = _.channel.clamp[c](channels[c]); + } + return Color.stringify(ch); +}; +/* EXPORT */ +export default change; diff --git a/tools/ui/node_modules/khroma/dist/methods/channel.d.ts b/tools/ui/node_modules/khroma/dist/methods/channel.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..97e67998cfb351048e2bc639458d11409e4555e4 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/channel.d.ts @@ -0,0 +1,3 @@ +import type { CHANNEL, Channels } from '../types'; +declare const channel: (color: string | Channels, channel: CHANNEL) => number; +export default channel; diff --git a/tools/ui/node_modules/khroma/dist/methods/channel.js b/tools/ui/node_modules/khroma/dist/methods/channel.js new file mode 100644 index 0000000000000000000000000000000000000000..2173667fba19f7a8cb052ecdf8b3ca6dd8b05c28 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/channel.js @@ -0,0 +1,9 @@ +/* IMPORT */ +import _ from '../utils/index.js'; +import Color from '../color/index.js'; +/* MAIN */ +const channel = (color, channel) => { + return _.lang.round(Color.parse(color)[channel]); +}; +/* EXPORT */ +export default channel; diff --git a/tools/ui/node_modules/khroma/dist/methods/complement.d.ts b/tools/ui/node_modules/khroma/dist/methods/complement.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b797c40c66c43e08c185ef537a296b16ea52cc19 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/complement.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const complement: (color: string | Channels) => string; +export default complement; diff --git a/tools/ui/node_modules/khroma/dist/methods/complement.js b/tools/ui/node_modules/khroma/dist/methods/complement.js new file mode 100644 index 0000000000000000000000000000000000000000..8ba61a222cbe4cad8f1de698ec3590f5aef398aa --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/complement.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import adjustChannel from './adjust_channel.js'; +/* MAIN */ +const complement = (color) => { + return adjustChannel(color, 'h', 180); +}; +/* EXPORT */ +export default complement; diff --git a/tools/ui/node_modules/khroma/dist/methods/contrast.d.ts b/tools/ui/node_modules/khroma/dist/methods/contrast.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b6ccd47d34728eb94c7485532276a5e5786e2961 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/contrast.d.ts @@ -0,0 +1,2 @@ +declare const contrast: (color1: string, color2: string) => number; +export default contrast; diff --git a/tools/ui/node_modules/khroma/dist/methods/contrast.js b/tools/ui/node_modules/khroma/dist/methods/contrast.js new file mode 100644 index 0000000000000000000000000000000000000000..357a13d510a213b2503a67b39d378ff3ac7a3cbd --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/contrast.js @@ -0,0 +1,14 @@ +/* IMPORT */ +import _ from '../utils/index.js'; +import luminance from './luminance.js'; +/* MAIN */ +const contrast = (color1, color2) => { + const luminance1 = luminance(color1); + const luminance2 = luminance(color2); + const max = Math.max(luminance1, luminance2); + const min = Math.min(luminance1, luminance2); + const ratio = (max + Number.EPSILON) / (min + Number.EPSILON); + return _.lang.round(_.lang.clamp(ratio, 1, 10)); +}; +/* EXPORT */ +export default contrast; diff --git a/tools/ui/node_modules/khroma/dist/methods/darken.d.ts b/tools/ui/node_modules/khroma/dist/methods/darken.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..eb589448c3224ef955fb6cc1c2b85aeeb76bdeb0 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/darken.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const darken: (color: string | Channels, amount: number) => string; +export default darken; diff --git a/tools/ui/node_modules/khroma/dist/methods/darken.js b/tools/ui/node_modules/khroma/dist/methods/darken.js new file mode 100644 index 0000000000000000000000000000000000000000..b456313034b1e81de6dc87562f39391ced45090f --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/darken.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import adjustChannel from './adjust_channel.js'; +/* MAIN */ +const darken = (color, amount) => { + return adjustChannel(color, 'l', -amount); +}; +/* EXPORT */ +export default darken; diff --git a/tools/ui/node_modules/khroma/dist/methods/desaturate.d.ts b/tools/ui/node_modules/khroma/dist/methods/desaturate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..74160b2c2440d566aedd86ff0626926d088c1eb4 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/desaturate.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const desaturate: (color: string | Channels, amount: number) => string; +export default desaturate; diff --git a/tools/ui/node_modules/khroma/dist/methods/desaturate.js b/tools/ui/node_modules/khroma/dist/methods/desaturate.js new file mode 100644 index 0000000000000000000000000000000000000000..04159ccf3dc42c3ba332c087bad05a1e9496029a --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/desaturate.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import adjustChannel from './adjust_channel.js'; +/* MAIN */ +const desaturate = (color, amount) => { + return adjustChannel(color, 's', -amount); +}; +/* EXPORT */ +export default desaturate; diff --git a/tools/ui/node_modules/khroma/dist/methods/grayscale.d.ts b/tools/ui/node_modules/khroma/dist/methods/grayscale.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a66db7c4b8e06a941c58a104822c69e90680f93a --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/grayscale.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const grayscale: (color: string | Channels) => string; +export default grayscale; diff --git a/tools/ui/node_modules/khroma/dist/methods/grayscale.js b/tools/ui/node_modules/khroma/dist/methods/grayscale.js new file mode 100644 index 0000000000000000000000000000000000000000..8af4c576d57c00edbd8ce89c69c94412c0fd1175 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/grayscale.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import change from './change.js'; +/* MAIN */ +const grayscale = (color) => { + return change(color, { s: 0 }); +}; +/* EXPORT */ +export default grayscale; diff --git a/tools/ui/node_modules/khroma/dist/methods/green.d.ts b/tools/ui/node_modules/khroma/dist/methods/green.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6103225f18b9dba58bff410d1995346523c38bcb --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/green.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const green: (color: string | Channels) => number; +export default green; diff --git a/tools/ui/node_modules/khroma/dist/methods/green.js b/tools/ui/node_modules/khroma/dist/methods/green.js new file mode 100644 index 0000000000000000000000000000000000000000..47a88ad54331be40d25ede56e5c1916582c32ccf --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/green.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import channel from './channel.js'; +/* MAIN */ +const green = (color) => { + return channel(color, 'g'); +}; +/* EXPORT */ +export default green; diff --git a/tools/ui/node_modules/khroma/dist/methods/hsla.d.ts b/tools/ui/node_modules/khroma/dist/methods/hsla.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..73951c432d430a8e2b6a583deeec4f9bb34e74b2 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/hsla.d.ts @@ -0,0 +1,2 @@ +declare const hsla: (h: number, s: number, l: number, a?: number) => string; +export default hsla; diff --git a/tools/ui/node_modules/khroma/dist/methods/hsla.js b/tools/ui/node_modules/khroma/dist/methods/hsla.js new file mode 100644 index 0000000000000000000000000000000000000000..f8d4a26beeec01b470af360393d017325d1e51ac --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/hsla.js @@ -0,0 +1,16 @@ +/* IMPORT */ +import _ from '../utils/index.js'; +import ChannelsReusable from '../channels/reusable.js'; +import Color from '../color/index.js'; +/* MAIN */ +const hsla = (h, s, l, a = 1) => { + const channels = ChannelsReusable.set({ + h: _.channel.clamp.h(h), + s: _.channel.clamp.s(s), + l: _.channel.clamp.l(l), + a: _.channel.clamp.a(a) + }); + return Color.stringify(channels); +}; +/* EXPORT */ +export default hsla; diff --git a/tools/ui/node_modules/khroma/dist/methods/hue.d.ts b/tools/ui/node_modules/khroma/dist/methods/hue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f5f5351da299a91c5bc50f72a963c64ec3488779 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/hue.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const hue: (color: string | Channels) => number; +export default hue; diff --git a/tools/ui/node_modules/khroma/dist/methods/hue.js b/tools/ui/node_modules/khroma/dist/methods/hue.js new file mode 100644 index 0000000000000000000000000000000000000000..e11a6f70c290f73812c225114815bd7df46022c9 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/hue.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import channel from './channel.js'; +/* MAIN */ +const hue = (color) => { + return channel(color, 'h'); +}; +/* EXPORT */ +export default hue; diff --git a/tools/ui/node_modules/khroma/dist/methods/index.d.ts b/tools/ui/node_modules/khroma/dist/methods/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0047415774501faa85eca72d7699c710eddbf54 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/index.d.ts @@ -0,0 +1,40 @@ +import hex from './rgba'; +import rgb from './rgba'; +import rgba from './rgba'; +import hsl from './hsla'; +import hsla from './hsla'; +import toKeyword from './to_keyword'; +import toHex from './to_hex'; +import toRgba from './to_rgba'; +import toHsla from './to_hsla'; +import channel from './channel'; +import red from './red'; +import green from './green'; +import blue from './blue'; +import hue from './hue'; +import saturation from './saturation'; +import lightness from './lightness'; +import alpha from './alpha'; +import opacity from './alpha'; +import contrast from './contrast'; +import luminance from './luminance'; +import isDark from './is_dark'; +import isLight from './is_light'; +import isTransparent from './is_transparent'; +import isValid from './is_valid'; +import saturate from './saturate'; +import desaturate from './desaturate'; +import lighten from './lighten'; +import darken from './darken'; +import opacify from './opacify'; +import fadeIn from './opacify'; +import transparentize from './transparentize'; +import fadeOut from './transparentize'; +import complement from './complement'; +import grayscale from './grayscale'; +import adjust from './adjust'; +import change from './change'; +import invert from './invert'; +import mix from './mix'; +import scale from './scale'; +export { hex, rgb, rgba, hsl, hsla, toKeyword, toHex, toRgba, toHsla, channel, red, green, blue, hue, saturation, lightness, alpha, opacity, contrast, luminance, isDark, isLight, isTransparent, isValid, saturate, desaturate, lighten, darken, opacify, fadeIn, transparentize, fadeOut, complement, grayscale, adjust, change, invert, mix, scale }; diff --git a/tools/ui/node_modules/khroma/dist/methods/index.js b/tools/ui/node_modules/khroma/dist/methods/index.js new file mode 100644 index 0000000000000000000000000000000000000000..0f0a7e2e53703fdeeab1fda9ddb429361afb24e1 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/index.js @@ -0,0 +1,54 @@ +/* IMPORT */ +import hex from './rgba.js'; // Alias +import rgb from './rgba.js'; // Alias +import rgba from './rgba.js'; +import hsl from './hsla.js'; // Alias +import hsla from './hsla.js'; +import toKeyword from './to_keyword.js'; +import toHex from './to_hex.js'; +import toRgba from './to_rgba.js'; +import toHsla from './to_hsla.js'; +import channel from './channel.js'; +import red from './red.js'; +import green from './green.js'; +import blue from './blue.js'; +import hue from './hue.js'; +import saturation from './saturation.js'; +import lightness from './lightness.js'; +import alpha from './alpha.js'; +import opacity from './alpha.js'; // Alias +import contrast from './contrast.js'; +import luminance from './luminance.js'; +import isDark from './is_dark.js'; +import isLight from './is_light.js'; +import isTransparent from './is_transparent.js'; +import isValid from './is_valid.js'; +import saturate from './saturate.js'; +import desaturate from './desaturate.js'; +import lighten from './lighten.js'; +import darken from './darken.js'; +import opacify from './opacify.js'; +import fadeIn from './opacify.js'; // Alias +import transparentize from './transparentize.js'; +import fadeOut from './transparentize.js'; // Alias +import complement from './complement.js'; +import grayscale from './grayscale.js'; +import adjust from './adjust.js'; +import change from './change.js'; +import invert from './invert.js'; +import mix from './mix.js'; +import scale from './scale.js'; +/* EXPORT */ +export { +/* CREATE */ +hex, rgb, rgba, hsl, hsla, +/* CONVERT */ +toKeyword, toHex, toRgba, toHsla, +/* GET - CHANNEL */ +channel, red, green, blue, hue, saturation, lightness, alpha, opacity, +/* GET - MORE */ +contrast, luminance, isDark, isLight, isTransparent, isValid, +/* EDIT - CHANNEL */ +saturate, desaturate, lighten, darken, opacify, fadeIn, transparentize, fadeOut, complement, grayscale, +/* EDIT - MORE */ +adjust, change, invert, mix, scale }; diff --git a/tools/ui/node_modules/khroma/dist/methods/invert.d.ts b/tools/ui/node_modules/khroma/dist/methods/invert.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a696b8619c2c0cf9b8612933a75f4a9d734b40df --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/invert.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const invert: (color: string | Channels, weight?: number) => string; +export default invert; diff --git a/tools/ui/node_modules/khroma/dist/methods/invert.js b/tools/ui/node_modules/khroma/dist/methods/invert.js new file mode 100644 index 0000000000000000000000000000000000000000..ec17b8e4e0198d1a7713b60474599ea71c8e3aaf --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/invert.js @@ -0,0 +1,13 @@ +/* IMPORT */ +import Color from '../color/index.js'; +import mix from './mix.js'; +/* MAIN */ +const invert = (color, weight = 100) => { + const inverse = Color.parse(color); + inverse.r = 255 - inverse.r; + inverse.g = 255 - inverse.g; + inverse.b = 255 - inverse.b; + return mix(inverse, color, weight); +}; +/* EXPORT */ +export default invert; diff --git a/tools/ui/node_modules/khroma/dist/methods/is_dark.d.ts b/tools/ui/node_modules/khroma/dist/methods/is_dark.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..06d8424505719d2a92db17f104c7d4a6fb16418c --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/is_dark.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const isDark: (color: string | Channels) => boolean; +export default isDark; diff --git a/tools/ui/node_modules/khroma/dist/methods/is_dark.js b/tools/ui/node_modules/khroma/dist/methods/is_dark.js new file mode 100644 index 0000000000000000000000000000000000000000..ded114518a4bc9a589385e24d941e4be77670acd --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/is_dark.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import isLight from './is_light.js'; +/* MAIN */ +const isDark = (color) => { + return !isLight(color); +}; +/* EXPORT */ +export default isDark; diff --git a/tools/ui/node_modules/khroma/dist/methods/is_light.d.ts b/tools/ui/node_modules/khroma/dist/methods/is_light.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5804151e2007a042599668eaf616778d1e1fd872 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/is_light.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const isLight: (color: string | Channels) => boolean; +export default isLight; diff --git a/tools/ui/node_modules/khroma/dist/methods/is_light.js b/tools/ui/node_modules/khroma/dist/methods/is_light.js new file mode 100644 index 0000000000000000000000000000000000000000..3300045c544f46031d86547e48c174a91be002e2 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/is_light.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import luminance from './luminance.js'; +/* MAIN */ +const isLight = (color) => { + return luminance(color) >= .5; +}; +/* EXPORT */ +export default isLight; diff --git a/tools/ui/node_modules/khroma/dist/methods/is_transparent.d.ts b/tools/ui/node_modules/khroma/dist/methods/is_transparent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1b6a99d332f2af5220d7c88e76a658c5a56acda --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/is_transparent.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const isTransparent: (color: string | Channels) => boolean; +export default isTransparent; diff --git a/tools/ui/node_modules/khroma/dist/methods/is_transparent.js b/tools/ui/node_modules/khroma/dist/methods/is_transparent.js new file mode 100644 index 0000000000000000000000000000000000000000..44103f0c6b608c105f55a460e1feea51cd503155 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/is_transparent.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import alpha from './alpha.js'; +/* MAIN */ +const isTransparent = (color) => { + return !alpha(color); +}; +/* EXPORT */ +export default isTransparent; diff --git a/tools/ui/node_modules/khroma/dist/methods/is_valid.d.ts b/tools/ui/node_modules/khroma/dist/methods/is_valid.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..41c8feee9022141edd91112888c136477dd03a5b --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/is_valid.d.ts @@ -0,0 +1,2 @@ +declare const isValid: (color: string) => boolean; +export default isValid; diff --git a/tools/ui/node_modules/khroma/dist/methods/is_valid.js b/tools/ui/node_modules/khroma/dist/methods/is_valid.js new file mode 100644 index 0000000000000000000000000000000000000000..822bf0b0475263649a71dff075912fe9592fcb40 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/is_valid.js @@ -0,0 +1,14 @@ +/* IMPORT */ +import Color from '../color/index.js'; +/* MAIN */ +const isValid = (color) => { + try { + Color.parse(color); + return true; + } + catch { + return false; + } +}; +/* EXPORT */ +export default isValid; diff --git a/tools/ui/node_modules/khroma/dist/methods/lighten.d.ts b/tools/ui/node_modules/khroma/dist/methods/lighten.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df9dce51a30b157c9a3305595278329937d38c60 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/lighten.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const lighten: (color: string | Channels, amount: number) => string; +export default lighten; diff --git a/tools/ui/node_modules/khroma/dist/methods/lighten.js b/tools/ui/node_modules/khroma/dist/methods/lighten.js new file mode 100644 index 0000000000000000000000000000000000000000..70a9b637e46576e21fbea05fab50e95fcd7f18c1 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/lighten.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import adjustChannel from './adjust_channel.js'; +/* MAIN */ +const lighten = (color, amount) => { + return adjustChannel(color, 'l', amount); +}; +/* EXPORT */ +export default lighten; diff --git a/tools/ui/node_modules/khroma/dist/methods/lightness.d.ts b/tools/ui/node_modules/khroma/dist/methods/lightness.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..41f10656e41926e6c665e6dcbe6f17b52d864ead --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/lightness.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const lightness: (color: string | Channels) => number; +export default lightness; diff --git a/tools/ui/node_modules/khroma/dist/methods/lightness.js b/tools/ui/node_modules/khroma/dist/methods/lightness.js new file mode 100644 index 0000000000000000000000000000000000000000..2b646982d786337526b629d171e932c705581bbf --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/lightness.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import channel from './channel.js'; +/* MAIN */ +const lightness = (color) => { + return channel(color, 'l'); +}; +/* EXPORT */ +export default lightness; diff --git a/tools/ui/node_modules/khroma/dist/methods/luminance.d.ts b/tools/ui/node_modules/khroma/dist/methods/luminance.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..efec2f500e64f1a20296f2bcb4c76f6d02ed4008 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/luminance.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const luminance: (color: string | Channels) => number; +export default luminance; diff --git a/tools/ui/node_modules/khroma/dist/methods/luminance.js b/tools/ui/node_modules/khroma/dist/methods/luminance.js new file mode 100644 index 0000000000000000000000000000000000000000..9071f05193c10f51a5dcf1cd80ce7fccb3bae058 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/luminance.js @@ -0,0 +1,12 @@ +/* IMPORT */ +import _ from '../utils/index.js'; +import Color from '../color/index.js'; +/* MAIN */ +//SOURCE: https://planetcalc.com/7779 +const luminance = (color) => { + const { r, g, b } = Color.parse(color); + const luminance = .2126 * _.channel.toLinear(r) + .7152 * _.channel.toLinear(g) + .0722 * _.channel.toLinear(b); + return _.lang.round(luminance); +}; +/* EXPORT */ +export default luminance; diff --git a/tools/ui/node_modules/khroma/dist/methods/mix.d.ts b/tools/ui/node_modules/khroma/dist/methods/mix.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..392e3084e062b8705dd43474bce28a8d459a5877 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/mix.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const mix: (color1: string | Channels, color2: string | Channels, weight?: number) => string; +export default mix; diff --git a/tools/ui/node_modules/khroma/dist/methods/mix.js b/tools/ui/node_modules/khroma/dist/methods/mix.js new file mode 100644 index 0000000000000000000000000000000000000000..3e74fffec7f670a503e0bfd374311d56b41ad7d9 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/mix.js @@ -0,0 +1,22 @@ +/* IMPORT */ +import Color from '../color/index.js'; +import rgba from './rgba.js'; +/* MAIN */ +//SOURCE: https://github.com/sass/dart-sass/blob/7457d2e9e7e623d9844ffd037a070cf32d39c348/lib/src/functions/color.dart#L718-L756 +const mix = (color1, color2, weight = 50) => { + const { r: r1, g: g1, b: b1, a: a1 } = Color.parse(color1); + const { r: r2, g: g2, b: b2, a: a2 } = Color.parse(color2); + const weightScale = weight / 100; + const weightNormalized = (weightScale * 2) - 1; + const alphaDelta = a1 - a2; + const weight1combined = ((weightNormalized * alphaDelta) === -1) ? weightNormalized : (weightNormalized + alphaDelta) / (1 + weightNormalized * alphaDelta); + const weight1 = (weight1combined + 1) / 2; + const weight2 = 1 - weight1; + const r = (r1 * weight1) + (r2 * weight2); + const g = (g1 * weight1) + (g2 * weight2); + const b = (b1 * weight1) + (b2 * weight2); + const a = (a1 * weightScale) + (a2 * (1 - weightScale)); + return rgba(r, g, b, a); +}; +/* EXPORT */ +export default mix; diff --git a/tools/ui/node_modules/khroma/dist/methods/opacify.d.ts b/tools/ui/node_modules/khroma/dist/methods/opacify.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5828b61d7bd339d81159d947867be6a1b3ecef26 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/opacify.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const opacify: (color: string | Channels, amount: number) => string; +export default opacify; diff --git a/tools/ui/node_modules/khroma/dist/methods/opacify.js b/tools/ui/node_modules/khroma/dist/methods/opacify.js new file mode 100644 index 0000000000000000000000000000000000000000..bb5027ccb7425e42c3b2c8b67a549fc2fdd99016 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/opacify.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import adjustChannel from './adjust_channel.js'; +/* MAIN */ +const opacify = (color, amount) => { + return adjustChannel(color, 'a', amount); +}; +/* EXPORT */ +export default opacify; diff --git a/tools/ui/node_modules/khroma/dist/methods/red.d.ts b/tools/ui/node_modules/khroma/dist/methods/red.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ecaaca7850402756ea57ecd77e358fc82304163 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/red.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const red: (color: string | Channels) => number; +export default red; diff --git a/tools/ui/node_modules/khroma/dist/methods/red.js b/tools/ui/node_modules/khroma/dist/methods/red.js new file mode 100644 index 0000000000000000000000000000000000000000..f0dc94114bffce0beb9c07b1d9e1585474c3ce18 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/red.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import channel from './channel.js'; +/* MAIN */ +const red = (color) => { + return channel(color, 'r'); +}; +/* EXPORT */ +export default red; diff --git a/tools/ui/node_modules/khroma/dist/methods/rgba.d.ts b/tools/ui/node_modules/khroma/dist/methods/rgba.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf0555a4b5e45eae8e7474da8cf83bb0639364d1 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/rgba.d.ts @@ -0,0 +1,7 @@ +import type { Channels } from '../types'; +type IRgba = { + (color: string | Channels, opacity: number): string; + (r: number, g: number, b: number, a?: number): string; +}; +declare const rgba: IRgba; +export default rgba; diff --git a/tools/ui/node_modules/khroma/dist/methods/rgba.js b/tools/ui/node_modules/khroma/dist/methods/rgba.js new file mode 100644 index 0000000000000000000000000000000000000000..c1ab785f2d0c3d0d13d1605753129d1756a5b7a7 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/rgba.js @@ -0,0 +1,19 @@ +/* IMPORT */ +import _ from '../utils/index.js'; +import ChannelsReusable from '../channels/reusable.js'; +import Color from '../color/index.js'; +import change from './change.js'; +/* MAIN */ +const rgba = (r, g, b = 0, a = 1) => { + if (typeof r !== 'number') + return change(r, { a: g }); + const channels = ChannelsReusable.set({ + r: _.channel.clamp.r(r), + g: _.channel.clamp.g(g), + b: _.channel.clamp.b(b), + a: _.channel.clamp.a(a) + }); + return Color.stringify(channels); +}; +/* EXPORT */ +export default rgba; diff --git a/tools/ui/node_modules/khroma/dist/methods/saturate.d.ts b/tools/ui/node_modules/khroma/dist/methods/saturate.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c6097b0f6c64b472c7c0f3b6bec4ac3eccdabff --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/saturate.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const saturate: (color: string | Channels, amount: number) => string; +export default saturate; diff --git a/tools/ui/node_modules/khroma/dist/methods/saturate.js b/tools/ui/node_modules/khroma/dist/methods/saturate.js new file mode 100644 index 0000000000000000000000000000000000000000..faec9e9712ae03063eca20d81a8b761bc991aa77 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/saturate.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import adjustChannel from './adjust_channel.js'; +/* MAIN */ +const saturate = (color, amount) => { + return adjustChannel(color, 's', amount); +}; +/* EXPORT */ +export default saturate; diff --git a/tools/ui/node_modules/khroma/dist/methods/saturation.d.ts b/tools/ui/node_modules/khroma/dist/methods/saturation.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f4263b13db608279a1ca464d3b3ebb85459fdffe --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/saturation.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const saturation: (color: string | Channels) => number; +export default saturation; diff --git a/tools/ui/node_modules/khroma/dist/methods/saturation.js b/tools/ui/node_modules/khroma/dist/methods/saturation.js new file mode 100644 index 0000000000000000000000000000000000000000..b20e79e930d5249acac508c5b458bbe1714f8ec4 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/saturation.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import channel from './channel.js'; +/* MAIN */ +const saturation = (color) => { + return channel(color, 's'); +}; +/* EXPORT */ +export default saturation; diff --git a/tools/ui/node_modules/khroma/dist/methods/scale.d.ts b/tools/ui/node_modules/khroma/dist/methods/scale.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..685f96b4abd225f26bce555f386380943691cc6a --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/scale.d.ts @@ -0,0 +1,3 @@ +import type { CHANNELS, Channels } from '../types'; +declare const scale: (color: string | Channels, channels: Partial) => string; +export default scale; diff --git a/tools/ui/node_modules/khroma/dist/methods/scale.js b/tools/ui/node_modules/khroma/dist/methods/scale.js new file mode 100644 index 0000000000000000000000000000000000000000..bcc8a8b99df5fc8cc58f2298334aa08063631806 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/scale.js @@ -0,0 +1,16 @@ +/* IMPORT */ +import _ from '../utils/index.js'; +import Color from '../color/index.js'; +import adjust from './adjust.js'; +/* MAIN */ +const scale = (color, channels) => { + const ch = Color.parse(color); + const adjustments = {}; + const delta = (amount, weight, max) => weight > 0 ? (max - amount) * weight / 100 : amount * weight / 100; + for (const c in channels) { + adjustments[c] = delta(ch[c], channels[c], _.channel.max[c]); + } + return adjust(color, adjustments); +}; +/* EXPORT */ +export default scale; diff --git a/tools/ui/node_modules/khroma/dist/methods/to_hex.d.ts b/tools/ui/node_modules/khroma/dist/methods/to_hex.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8407d3059f7df8c5b25ccab09126b06ebb2ced5b --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/to_hex.d.ts @@ -0,0 +1,2 @@ +declare const toHex: (color: string) => string; +export default toHex; diff --git a/tools/ui/node_modules/khroma/dist/methods/to_hex.js b/tools/ui/node_modules/khroma/dist/methods/to_hex.js new file mode 100644 index 0000000000000000000000000000000000000000..8a4a2bbc27355329f0933ba5dca6dcde77e3091a --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/to_hex.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import Color from '../color/index.js'; +/* MAIN */ +const toHex = (color) => { + return Color.format.hex.stringify(Color.parse(color)); +}; +/* EXPORT */ +export default toHex; diff --git a/tools/ui/node_modules/khroma/dist/methods/to_hsla.d.ts b/tools/ui/node_modules/khroma/dist/methods/to_hsla.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c441b57fd568f6f05609fb88a858880cc84fcd7 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/to_hsla.d.ts @@ -0,0 +1,2 @@ +declare const toHsla: (color: string) => string; +export default toHsla; diff --git a/tools/ui/node_modules/khroma/dist/methods/to_hsla.js b/tools/ui/node_modules/khroma/dist/methods/to_hsla.js new file mode 100644 index 0000000000000000000000000000000000000000..95cae906ae4dc879c280565d176c1eb8d96d3a38 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/to_hsla.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import Color from '../color/index.js'; +/* MAIN */ +const toHsla = (color) => { + return Color.format.hsla.stringify(Color.parse(color)); +}; +/* EXPORT */ +export default toHsla; diff --git a/tools/ui/node_modules/khroma/dist/methods/to_keyword.d.ts b/tools/ui/node_modules/khroma/dist/methods/to_keyword.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0ef06a9925d29c1a4317bf535bef38ac914dc735 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/to_keyword.d.ts @@ -0,0 +1,2 @@ +declare const toKeyword: (color: string) => string | undefined; +export default toKeyword; diff --git a/tools/ui/node_modules/khroma/dist/methods/to_keyword.js b/tools/ui/node_modules/khroma/dist/methods/to_keyword.js new file mode 100644 index 0000000000000000000000000000000000000000..325a73324c15084e082fe8403f8e93356d4465b4 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/to_keyword.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import Color from '../color/index.js'; +/* MAIN */ +const toKeyword = (color) => { + return Color.format.keyword.stringify(Color.parse(color)); +}; +/* EXPORT */ +export default toKeyword; diff --git a/tools/ui/node_modules/khroma/dist/methods/to_rgba.d.ts b/tools/ui/node_modules/khroma/dist/methods/to_rgba.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..26c6b96f53869509f2b630d96856f530ced7244d --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/to_rgba.d.ts @@ -0,0 +1,2 @@ +declare const toRgba: (color: string) => string; +export default toRgba; diff --git a/tools/ui/node_modules/khroma/dist/methods/to_rgba.js b/tools/ui/node_modules/khroma/dist/methods/to_rgba.js new file mode 100644 index 0000000000000000000000000000000000000000..1c48dc79902772e1207addc37e7c6759a07ceffe --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/to_rgba.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import Color from '../color/index.js'; +/* MAIN */ +const toRgba = (color) => { + return Color.format.rgba.stringify(Color.parse(color)); +}; +/* EXPORT */ +export default toRgba; diff --git a/tools/ui/node_modules/khroma/dist/methods/transparentize.d.ts b/tools/ui/node_modules/khroma/dist/methods/transparentize.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d3692a333df97ae44f044f7bcc13fa239433b3f --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/transparentize.d.ts @@ -0,0 +1,3 @@ +import type { Channels } from '../types'; +declare const transparentize: (color: string | Channels, amount: number) => string; +export default transparentize; diff --git a/tools/ui/node_modules/khroma/dist/methods/transparentize.js b/tools/ui/node_modules/khroma/dist/methods/transparentize.js new file mode 100644 index 0000000000000000000000000000000000000000..026a1e48b0f72308e624769be973930570edb759 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/methods/transparentize.js @@ -0,0 +1,8 @@ +/* IMPORT */ +import adjustChannel from './adjust_channel.js'; +/* MAIN */ +const transparentize = (color, amount) => { + return adjustChannel(color, 'a', -amount); +}; +/* EXPORT */ +export default transparentize; diff --git a/tools/ui/node_modules/khroma/dist/types.d.ts b/tools/ui/node_modules/khroma/dist/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a7f533cefbaff8a83a8eef89448c8e374fa14001 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/types.d.ts @@ -0,0 +1,20 @@ +import type Channels from './channels'; +type ALPHA = { + a: number; +}; +type RGB = { + r: number; + g: number; + b: number; +}; +type RGBA = RGB & ALPHA; +type HSL = { + h: number; + s: number; + l: number; +}; +type HSLA = HSL & ALPHA; +type CHANNEL = 'r' | 'g' | 'b' | 'h' | 's' | 'l' | 'a'; +type CHANNELS = Record; +export type { Channels }; +export type { ALPHA, RGB, RGBA, HSL, HSLA, CHANNEL, CHANNELS }; diff --git a/tools/ui/node_modules/khroma/dist/types.js b/tools/ui/node_modules/khroma/dist/types.js new file mode 100644 index 0000000000000000000000000000000000000000..8f0c45df0611e5841636170273074274b9fc02a6 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/types.js @@ -0,0 +1,2 @@ +/* IMPORT */ +export {}; diff --git a/tools/ui/node_modules/khroma/dist/utils/channel.d.ts b/tools/ui/node_modules/khroma/dist/utils/channel.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6133a577d2bd0ad0facdb774903e7e0c286790ff --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/utils/channel.d.ts @@ -0,0 +1,34 @@ +import type { RGB, HSL } from '../types'; +declare const Channel: { + min: { + r: number; + g: number; + b: number; + s: number; + l: number; + a: number; + }; + max: { + r: number; + g: number; + b: number; + h: number; + s: number; + l: number; + a: number; + }; + clamp: { + r: (r: number) => number; + g: (g: number) => number; + b: (b: number) => number; + h: (h: number) => number; + s: (s: number) => number; + l: (l: number) => number; + a: (a: number) => number; + }; + toLinear: (c: number) => number; + hue2rgb: (p: number, q: number, t: number) => number; + hsl2rgb: ({ h, s, l }: HSL, channel: keyof RGB) => number; + rgb2hsl: ({ r, g, b }: RGB, channel: keyof HSL) => number; +}; +export default Channel; diff --git a/tools/ui/node_modules/khroma/dist/utils/channel.js b/tools/ui/node_modules/khroma/dist/utils/channel.js new file mode 100644 index 0000000000000000000000000000000000000000..0e6dbc1378434b8c1ed1c6230aed13b14431be2d --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/utils/channel.js @@ -0,0 +1,89 @@ +/* IMPORT */ +/* MAIN */ +const Channel = { + /* CLAMP */ + min: { + r: 0, + g: 0, + b: 0, + s: 0, + l: 0, + a: 0 + }, + max: { + r: 255, + g: 255, + b: 255, + h: 360, + s: 100, + l: 100, + a: 1 + }, + clamp: { + r: (r) => r >= 255 ? 255 : (r < 0 ? 0 : r), + g: (g) => g >= 255 ? 255 : (g < 0 ? 0 : g), + b: (b) => b >= 255 ? 255 : (b < 0 ? 0 : b), + h: (h) => h % 360, + s: (s) => s >= 100 ? 100 : (s < 0 ? 0 : s), + l: (l) => l >= 100 ? 100 : (l < 0 ? 0 : l), + a: (a) => a >= 1 ? 1 : (a < 0 ? 0 : a) + }, + /* CONVERSION */ + //SOURCE: https://planetcalc.com/7779 + toLinear: (c) => { + const n = c / 255; + return c > .03928 ? Math.pow(((n + .055) / 1.055), 2.4) : n / 12.92; + }, + //SOURCE: https://gist.github.com/mjackson/5311256 + hue2rgb: (p, q, t) => { + if (t < 0) + t += 1; + if (t > 1) + t -= 1; + if (t < 1 / 6) + return p + (q - p) * 6 * t; + if (t < 1 / 2) + return q; + if (t < 2 / 3) + return p + (q - p) * (2 / 3 - t) * 6; + return p; + }, + hsl2rgb: ({ h, s, l }, channel) => { + if (!s) + return l * 2.55; // Achromatic + h /= 360; + s /= 100; + l /= 100; + const q = (l < .5) ? l * (1 + s) : (l + s) - (l * s); + const p = 2 * l - q; + switch (channel) { + case 'r': return Channel.hue2rgb(p, q, h + 1 / 3) * 255; + case 'g': return Channel.hue2rgb(p, q, h) * 255; + case 'b': return Channel.hue2rgb(p, q, h - 1 / 3) * 255; + } + }, + rgb2hsl: ({ r, g, b }, channel) => { + r /= 255; + g /= 255; + b /= 255; + const max = Math.max(r, g, b); + const min = Math.min(r, g, b); + const l = (max + min) / 2; + if (channel === 'l') + return l * 100; + if (max === min) + return 0; // Achromatic + const d = max - min; + const s = (l > .5) ? d / (2 - max - min) : d / (max + min); + if (channel === 's') + return s * 100; + switch (max) { + case r: return ((g - b) / d + (g < b ? 6 : 0)) * 60; + case g: return ((b - r) / d + 2) * 60; + case b: return ((r - g) / d + 4) * 60; + default: return -1; //TSC: TypeScript is stupid and complains if there isn't this useless default statement + } + } +}; +/* EXPORT */ +export default Channel; diff --git a/tools/ui/node_modules/khroma/dist/utils/index.d.ts b/tools/ui/node_modules/khroma/dist/utils/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..84f9ce7bbffb702611877747336d7203b5abd2f2 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/utils/index.d.ts @@ -0,0 +1,42 @@ +declare const Utils: { + channel: { + min: { + r: number; + g: number; + b: number; + s: number; + l: number; + a: number; + }; + max: { + r: number; + g: number; + b: number; + h: number; + s: number; + l: number; + a: number; + }; + clamp: { + r: (r: number) => number; + g: (g: number) => number; + b: (b: number) => number; + h: (h: number) => number; + s: (s: number) => number; + l: (l: number) => number; + a: (a: number) => number; + }; + toLinear: (c: number) => number; + hue2rgb: (p: number, q: number, t: number) => number; + hsl2rgb: ({ h, s, l }: import("../types").HSL, channel: keyof import("../types").RGB) => number; + rgb2hsl: ({ r, g, b }: import("../types").RGB, channel: keyof import("../types").HSL) => number; + }; + lang: { + clamp: (number: number, lower: number, upper: number) => number; + round: (number: number) => number; + }; + unit: { + dec2hex: (dec: number) => string; + }; +}; +export default Utils; diff --git a/tools/ui/node_modules/khroma/dist/utils/index.js b/tools/ui/node_modules/khroma/dist/utils/index.js new file mode 100644 index 0000000000000000000000000000000000000000..11f2b87704262fbd11e330c3faa92f352f58bdd3 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/utils/index.js @@ -0,0 +1,12 @@ +/* IMPORT */ +import channel from './channel.js'; +import lang from './lang.js'; +import unit from './unit.js'; +/* MAIN */ +const Utils = { + channel, + lang, + unit +}; +/* EXPORT */ +export default Utils; diff --git a/tools/ui/node_modules/khroma/dist/utils/lang.d.ts b/tools/ui/node_modules/khroma/dist/utils/lang.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9fead2928c68aa86e6efc79b32a235574aa88c01 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/utils/lang.d.ts @@ -0,0 +1,5 @@ +declare const Lang: { + clamp: (number: number, lower: number, upper: number) => number; + round: (number: number) => number; +}; +export default Lang; diff --git a/tools/ui/node_modules/khroma/dist/utils/lang.js b/tools/ui/node_modules/khroma/dist/utils/lang.js new file mode 100644 index 0000000000000000000000000000000000000000..73bd5af9234ba2f77ec5fcdabeb1dddec2d1f9e1 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/utils/lang.js @@ -0,0 +1,14 @@ +/* MAIN */ +const Lang = { + /* API */ + clamp: (number, lower, upper) => { + if (lower > upper) + return Math.min(lower, Math.max(upper, number)); + return Math.min(upper, Math.max(lower, number)); + }, + round: (number) => { + return Math.round(number * 10000000000) / 10000000000; + } +}; +/* EXPORT */ +export default Lang; diff --git a/tools/ui/node_modules/khroma/dist/utils/unit.d.ts b/tools/ui/node_modules/khroma/dist/utils/unit.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb119d299206b6225ace74fd3f4428f603842a75 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/utils/unit.d.ts @@ -0,0 +1,4 @@ +declare const Unit: { + dec2hex: (dec: number) => string; +}; +export default Unit; diff --git a/tools/ui/node_modules/khroma/dist/utils/unit.js b/tools/ui/node_modules/khroma/dist/utils/unit.js new file mode 100644 index 0000000000000000000000000000000000000000..fdc426aa2550ad16997fe254a624779ee4fc6699 --- /dev/null +++ b/tools/ui/node_modules/khroma/dist/utils/unit.js @@ -0,0 +1,10 @@ +/* MAIN */ +const Unit = { + /* API */ + dec2hex: (dec) => { + const hex = Math.round(dec).toString(16); + return hex.length > 1 ? hex : `0${hex}`; + } +}; +/* EXPORT */ +export default Unit; diff --git a/tools/ui/node_modules/khroma/license b/tools/ui/node_modules/khroma/license new file mode 100644 index 0000000000000000000000000000000000000000..433a5ecd4cb7c687f6a6ec968da740d490b1f776 --- /dev/null +++ b/tools/ui/node_modules/khroma/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019-present Fabio Spampinato, Andrew Maney + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/tools/ui/node_modules/khroma/package.json b/tools/ui/node_modules/khroma/package.json new file mode 100644 index 0000000000000000000000000000000000000000..6151686952b6aefe188205ebcd4fd452f7f36211 --- /dev/null +++ b/tools/ui/node_modules/khroma/package.json @@ -0,0 +1,37 @@ +{ + "name": "khroma", + "repository": "github:fabiospampinato/khroma", + "description": "A collection of functions for manipulating CSS colors, inspired by SASS.", + "version": "2.1.0", + "type": "module", + "sideEffects": false, + "main": "dist/index.js", + "exports": "./dist/index.js", + "types": "./dist/index.d.ts", + "scripts": { + "benchmark": "tsex benchmark", + "benchmark:watch": "tsex benchmark --watch", + "clean": "tsex clean", + "compile": "tsex compile", + "compile:watch": "tsex compile --watch", + "test": "tsex test", + "test:watch": "tsex test --watch", + "prepublishOnly": "tsex prepare" + }, + "keywords": [ + "sass", + "color", + "manipulation", + "manipulate", + "css", + "hex", + "rgb", + "hsl" + ], + "devDependencies": { + "benchloop": "^2.1.1", + "fava": "^0.2.1", + "tsex": "^3.0.1", + "typescript": "^5.1.6" + } +} diff --git a/tools/ui/node_modules/khroma/readme.md b/tools/ui/node_modules/khroma/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..a00f3235c4a56fdc24e5d3fbf5956c27c53639f9 --- /dev/null +++ b/tools/ui/node_modules/khroma/readme.md @@ -0,0 +1,536 @@ +# [Khrôma](https://en.wiktionary.org/wiki/%CF%87%CF%81%E1%BF%B6%CE%BC%CE%B1) + +A collection of functions for manipulating CSS colors, inspired by SASS. + +## Features + +- **Small**: the entire library weighs ~5kb (min + gzip) and has no dependencies. +- **Fast**: in our benchmark suite functions are executed at ~0.0025ms per call on a mid-2014 MBP. +- **Flexible**: All valid CSS colors are supported. +- **SASS-like**: if you're familiar with SASS you should feel right at home. + +## Install + +```sh +npm install --save khroma +``` + +## Usage + +```ts +import {red, isDark, darken, change} from 'khroma'; + +red ( '#ffffff' ); // => 255 +isDark ( 'white' ); // => false +darken ( 'hsl(0, 5%, 100%)', 50 ); // => 'hsl(0, 5%, 50%)' +change ( 'rgb(255, 255, 255)', { a: 0.5 } ); // => 'rgba(255, 255, 255, 0.5)' +``` + +## Functions + +These are all the provided functions, for each of them below you can find a short description, its interface and examples. + +| Create | Convert | Get channel | Get more | Edit channel | Edit more | +| ------------- | ----------------------- | ------------------------- | ------------------------------- | --------------------------------- | -------------------- | +| [hex](#hex) | [toKeyword](#tokeyword) | [channel](#channel) | [contrast](#contrast) | [saturate](#saturate) | [adjust](#adjust) | +| [rgb](#rgb) | [toHex](#tohex) | [red](#red) | [luminance](#luminance) | [desaturate](#desaturate) | [change](#change) | +| [rgba](#rgba) | [toRgba](#torgba) | [green](#green) | [isDark](#isdark) | [lighten](#lighten) | [invert](#invert) | +| [hsl](#hsl) | [toHsla](#tohsla) | [blue](#blue) | [isLight](#islight) | [darken](#darken) | [mix](#mix) | +| [hsla](#hsla) | | [hue](#hue) | [isTransparent](#istransparent) | [opacify](#opacify) | [scale](#scale) | +| | | [saturation](#saturation) | [isValid](#isvalid) | [fadeIn](#fadein) | | +| | | [lightness](#lightness) | | [transparentize](#transparentize) | | +| | | [alpha](#alpha) | | [fadeOut](#fadeout) | | +| | | [opacity](#opacity) | | [rgba](#rgba-alt) (alt) | | +| | | | | [complement](#complement) | | +| | | | | [grayscale](#grayscale) | | + +### Create + +These functions create a new color given the provided channels. + +#### `hex` + +Alias for [`rgba`](#rgba). + +#### `rgb` + +Alias for [`rgba`](#rgba). + +#### `rgba` + +Creates a new color given its rgba channels, the alpha channel is optional. + +```ts +function rgba ( r: string, g: number, b: number, a: number = 1 ): string; +``` + +```ts +rgba ( 255, 204, 0 ); // => '#ffcc00' +rgba ( 255, 204, 0, 0.5 ); // => 'rgba(255, 204, 0, 0.5)' +``` + +#### `hsl` + +Alias for [`hsla`](#hsla). + +#### `hsla` + +Creates a new color given its hsla channels, the alpha channel is optional. + +```ts +function hsla ( h: number, s: number, l: number, a: number = 1 ): string; +``` + +```ts +hsla ( 0, 50, 100 ); // => 'hsl(0, 50%, 100%)' +hsla ( 10, 50, 100, 0.5 ); // => 'hsla(10, 50%, 100%, 0.5)' +``` + +### Convert + +These functions convert supported colors to a specific format. + +#### `toKeyword` + +Convert a color to the keyword format, when possible. + +```ts +function toKeyword ( color: string ): string | undefined; +``` + +```ts +toKeyword ( '#ff0000' ); // => 'red' +toKeyword ( '#ffcc00' ); // => undefined +``` + +#### `toHex` + +Convert a color to the HEX format. + +```ts +function toHex ( color: string ): string; +``` + +```ts +toHex ( 'red' ); // => '#ff0000' +toHex ( '#ff0000' ); // => '#ff0000' +``` + +#### `toRgba` + +Convert a color to the RGBA format. + +```ts +function toRgba ( color: string ): string; +``` + +```ts +toRgba ( 'red' ); // => 'rgb(255, 0, 0)' +toRgba ( '#ff0000' ); // => 'rgb(255, 0, 0)' +toRgba ( '#00000088' ); // => 'rgba(0, 0, 0, 0.5333333333)' +``` + +#### `toHsla` + +Convert a color to the HSLA format. + +```ts +function toHsla ( color: string ): string; +``` + +```ts +toHsla ( 'red' ); // => 'hsl(0, 100%, 50%)' +toHsla ( '#ff0000' ); // => 'hsl(0, 100%, 50%)' +toHsla ( 'rgb(255, 0, 0)' ); // => 'hsl(0, 100%, 50%)' +``` + +### Get channel + +These functions get a single channel from the provided color. + +#### `channel` + +Gets any single channel of the color. + +```ts +function channel ( color: string, channel: 'r' | 'g' | 'b' | 'h' | 's' | 'l' | 'a' ): number; +``` + +```ts +channel ( '#ffcc00', 'r' ); // => 255 +channel ( '#ffcc00', 'h' ); // => 48 +channel ( '#ffcc00', 'a' ); // => 1 +``` + +#### `red` + +Gets the red channel of the color. + +```ts +function red ( color: string ): number; +``` + +```ts +red ( '#ffcc00' ); // => 255 +``` + +#### `green` + +Gets the green channel of the color. + +```ts +function green ( color: string ): number; +``` + +```ts +green ( '#ffcc00' ); // => 204 +``` + +#### `blue` + +Gets the blue channel of the color. + +```ts +function blue ( color: string ): number; +``` + +```ts +blue ( '#ffcc00' ); // => 0 +``` + +#### `hue` + +Gets the hue channel of the color. + +```ts +function hue ( color: string ): number; +``` + +```ts +hue ( 'hsl(0, 50%, 100%)' ); // => 0 +``` + +#### `saturation` + +Gets the saturation channel of the color. + +```ts +function saturation ( color: string ): number; +``` + +```ts +saturation ( 'hsl(0, 50%, 100%)' ); // => 50 +``` + +#### `lightness` + +Gets the lightness channel of the color. + +```ts +function lightness ( color: string ): number; +``` + +```ts +lightness ( 'hsl(0, 50%, 100%)' ); // => 100 +``` + +#### `alpha` + +Gets the alpha channel of the color. + +```ts +function alpha ( color: string ): number; +``` + +```ts +alpha ( '#ffcc00' ); // => 1 +alpha ( 'rgba(255, 205, 0, 0.5)' ); // => 0.5 +``` + +#### `opacity` + +Alias for [`alpha`](#alpha). + +### Get more + +These functions get some other information from the provided color. + +#### `contrast` + +Gets the contrast in luminance between two colors. + +Contrast values go between 1 and 10. 1 means same color, >= 4 means decent contrast, >= 7 means great contrast, 10 means great contrast. + +```ts +function contrast ( color1: string, color2: string ): number; +``` + +```ts +contrast ( '#000000', '#000000' ); // => 1 +contrast ( '#000000', '#ffffff' ); // => 10 +contrast ( '#888888', '#ffffff' ); // => 4.0617165366 +``` + +#### `luminance` + +Gets the [relative luminance](https://en.wikipedia.org/wiki/Relative_luminance) of the color. + +```ts +function luminance ( color: string ): number; +``` + +```ts +luminance ( 'black' ); // => 0 +luminance ( 'white' ); // => 1 +luminance ( '#ffcc00' ); // => 0.6444573127 +``` + +#### `isDark` + +Checks if the provided color is a dark color. + +```ts +function isDark ( color: string ): number; +``` + +```ts +isDark ( 'black' ); // => true +isDark ( 'white' ); // => false +isDark ( '#ffcc00' ); // => false +``` + +#### `isLight` + +Checks if the provided color is a light color. + +```ts +function isLight ( color: string ): number; +``` + +```ts +isLight ( 'black' ); // => false +isLight ( 'white' ); // => true +isLight ( '#ffcc00' ); // => true +``` + +#### `isTransparent` + +Checks if the provided color is a transparent color. + +```ts +function isTransparent ( color: string ): boolean; +``` + +```ts +isTransparent ( 'transparent' ); // => true +isTransparent ( '#ffcc0000' ); // => true +isTransparent ( '#ffcc00' ); // => false +``` + +#### `isValid` + +Checks if the provided color is a valid color. + +```ts +function isLight ( color: string ): boolean; +``` + +```ts +isValid ( 'black' ); // => true +isValid ( '#ffcc00' ); // => true +isValid ( '#wtf' ); // => false +``` + +### Edit channel + +These functions change a single channel of the provided color. + +#### `saturate` + +Increases the saturation channel of the color. + +```ts +function saturate ( color: string, amount: number ): string; +``` + +```ts +saturate ( 'hsl(0, 50%, 50%)', 25 ); // => 'hsl(0, 75%, 50%)' +``` + +#### `desaturate` + +Decreases the saturation channel of the color. + +```ts +function desaturate ( color: string, amount: number ): string; +``` + +```ts +desaturate ( 'hsl(0, 50%, 50%)', 25 ); // => 'hsl(0, 25%, 50%)' +``` + +#### `lighten` + +Increases the lightness channel of the color. + +```ts +function lighten ( color: string, amount: number ): string; +``` + +```ts +lighten ( 'hsl(0, 50%, 50%)', 25 ); // => 'hsl(0, 50%, 75%)' +``` + +#### `darken` + +Decreases the lightness channel of the color. + +```ts +function darken ( color: string, amount: number ): string; +``` + +```ts +darken ( 'hsl(0, 50%, 50%)', 25 ); // => 'hsl(0, 50%, 25%)' +``` + +#### `opacify` + +Increases the opacity channel of the color. + +```ts +function opacify ( color: string, amount: number ): string; +``` + +```ts +opacify ( 'rgba(255, 204, 0, 0.5)', 0.25 ); // => 'rgba(255, 204, 0, 0.75)' +``` + +#### `fadeIn` + +Alias for [`opacify`](#opacify). + +#### `transparentize` + +Decreases the opacity channel of the color. + +```ts +function transparentize ( color: string, amount: number ): string; +``` + +```ts +transparentize ( 'rgba(255, 204, 0, 0.5)', 0.25 ); // => 'rgba(255, 204, 0, 0.25)' +``` + +#### `fadeOut` + +Alias for [`transparentize`](#transparentize). + +#### `rgba` (alt) + +Sets a new value for the opacity channel. + +```ts +function rgba ( color: string, amount: number ): string; +``` + +```ts +rgba ( 'rgba(255, 204, 0, 0.5)', 0.1 ); // => 'rgba(255, 204, 0, 0.1)' +``` + +#### `complement` + +Gets the complement of the color, rotating its hue channel by 180 degrees. + +```ts +function complement ( color: string ): string; +``` + +```ts +complement ( '#ffcc00' ); // => 'hsl(228, 100%, 50%)' +``` + +#### `grayscale` + +Gets the grayscale version of the color, setting its saturation to 0. + +```ts +function grayscale ( color: string ): string; +``` + +```ts +grayscale ( '#ffcc00' ); // => 'hsl(48, 0%, 50%)' +``` + +### Edit more + +These functions can/will change more than a single channel at once of the provided color. + +#### `adjust` + +Increases or decreases the value of any channel of the color. + +```ts +function adjust ( color: string, channels: Record<'r' | 'g' | 'b' | 'h' | 's' | 'l' | 'a', number> ): string; +``` + +```ts +adjust ( '#ffcc00', { r: -10, g: 200 } ); // => '#f5ff00' +adjust ( '#ffcc00', { a: -0.5 } ); // => 'rgba(255, 204, 0, 0.5)' +adjust ( '#ffcc00', { h: 50, l: -30 } ); // => 'hsl(98, 100%, 20%)' +``` + +#### `change` + +Sets a new value for any channel of the color. + +```ts +function change ( color: string, channels: Record<'r' | 'g' | 'b' | 'h' | 's' | 'l' | 'a', number> ): string; +``` + +```ts +change ( '#ffcc00', { r: 10, g: 200 } ); // => '#0ac800' +change ( '#ffcc00', { a: 0.5 } ); // => 'rgba(255, 204, 0, 0.5)' +change ( '#ffcc00', { h: 50, l: 30 } ); // => 'hsl(50, 100%, 30%)' +``` + +#### `invert` + +Gets the inverse of the color. + +```ts +function invert ( color: string, weight: number = 100 ): string; +``` + +```ts +invert ( '#ffcc00' ); // => '#0033ff' +invert ( '#ffcc00', 50 ); // => '#808080' +``` + +#### `mix` + +Mixes two colors together. + +```ts +function mix ( color1: string, color2: string, weight: number = 50 ): string; +``` + +```ts +mix ( 'red', 'blue' ); // => '#800080' +mix ( 'red', 'blue', 15 ); // => '#2600d9' +``` + +#### `scale` + +Scales any channel of the color. + +```ts +function scale ( color: string, channels: Record<'r' | 'g' | 'b' | 'h' | 's' | 'l' | 'a', number> ): string; +``` + +```ts +scale ( '#ffcc00', { r: -50, b: 10 } ); // => '#80cc1a' +``` + +## License + +MIT © Fabio Spampinato, Andrew Maney diff --git a/tools/ui/node_modules/khroma/src/channels/index.ts b/tools/ui/node_modules/khroma/src/channels/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..7453d941db7aeb4811b8f75a48498cea65c87dbc --- /dev/null +++ b/tools/ui/node_modules/khroma/src/channels/index.ts @@ -0,0 +1,169 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import Type from '~/channels/type'; +import {TYPE} from '~/constants'; +import type {RGBA, HSLA, CHANNELS} from '~/types'; + +/* MAIN */ + +class Channels { + + /* VARIABLES */ + + color?: string; + changed: boolean; + data: CHANNELS; //TSC: It should really be "Partial", but TS gets excessively noisy + type: Type; + + /* CONSTRUCTOR */ + + constructor ( data: RGBA | HSLA | CHANNELS, color?: string ) { + + this.color = color; + this.changed = false; + this.data = data as CHANNELS; //TSC + this.type = new Type (); + + } + + /* API */ + + set ( data: RGBA | HSLA | CHANNELS, color?: string ): this { + + this.color = color; + this.changed = false; + this.data = data as CHANNELS; //TSC + this.type.type = TYPE.ALL; + + return this; + + } + + /* HELPERS */ + + _ensureHSL (): void { + + const data = this.data; + const {h, s, l} = data; + + if ( h === undefined ) data.h = _.channel.rgb2hsl ( data, 'h' ); + if ( s === undefined ) data.s = _.channel.rgb2hsl ( data, 's' ); + if ( l === undefined ) data.l = _.channel.rgb2hsl ( data, 'l' ); + + } + + _ensureRGB (): void { + + const data = this.data; + const {r, g, b} = data; + + if ( r === undefined ) data.r = _.channel.hsl2rgb ( data, 'r' ); + if ( g === undefined ) data.g = _.channel.hsl2rgb ( data, 'g' ); + if ( b === undefined ) data.b = _.channel.hsl2rgb ( data, 'b' ); + + } + + /* GETTERS */ + + get r (): number { + const data = this.data; + const r = data.r; + if ( !this.type.is ( TYPE.HSL ) && r !== undefined ) return r; + this._ensureHSL (); + return _.channel.hsl2rgb ( data, 'r' ); + } + + get g (): number { + const data = this.data; + const g = data.g; + if ( !this.type.is ( TYPE.HSL ) && g !== undefined ) return g; + this._ensureHSL (); + return _.channel.hsl2rgb ( data, 'g' ); + } + + get b (): number { + const data = this.data; + const b = data.b; + if ( !this.type.is ( TYPE.HSL ) && b !== undefined ) return b; + this._ensureHSL (); + return _.channel.hsl2rgb ( data, 'b' ); + } + + get h (): number { + const data = this.data; + const h = data.h; + if ( !this.type.is ( TYPE.RGB ) && h !== undefined ) return h; + this._ensureRGB (); + return _.channel.rgb2hsl ( data, 'h' ); + } + + get s (): number { + const data = this.data; + const s = data.s; + if ( !this.type.is ( TYPE.RGB ) && s !== undefined ) return s; + this._ensureRGB (); + return _.channel.rgb2hsl ( data, 's' ); + } + + get l (): number { + const data = this.data; + const l = data.l; + if ( !this.type.is ( TYPE.RGB ) && l !== undefined ) return l; + this._ensureRGB (); + return _.channel.rgb2hsl ( data, 'l' ); + } + + get a (): number { + return this.data.a; + } + + /* SETTERS */ + + set r ( r: number ) { + this.type.set ( TYPE.RGB ); + this.changed = true; + this.data.r = r; + } + + set g ( g: number ) { + this.type.set ( TYPE.RGB ); + this.changed = true; + this.data.g = g; + } + + set b ( b: number ) { + this.type.set ( TYPE.RGB ); + this.changed = true; + this.data.b = b; + } + + set h ( h: number ) { + this.type.set ( TYPE.HSL ); + this.changed = true; + this.data.h = h; + } + + set s ( s: number ) { + this.type.set ( TYPE.HSL ); + this.changed = true; + this.data.s = s; + } + + set l ( l: number ) { + this.type.set ( TYPE.HSL ); + this.changed = true; + this.data.l = l; + } + + set a ( a: number ) { + this.changed = true; + this.data.a = a; + } + +} + +/* EXPORT */ + +export default Channels; diff --git a/tools/ui/node_modules/khroma/src/channels/reusable.ts b/tools/ui/node_modules/khroma/src/channels/reusable.ts new file mode 100644 index 0000000000000000000000000000000000000000..78d812af23f85ff491888ddead247fe0927e3075 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/channels/reusable.ts @@ -0,0 +1,12 @@ + +/* IMPORT */ + +import Channels from '~/channels'; + +/* MAIN */ + +const channels = new Channels ( { r: 0, g: 0, b: 0, a: 0 }, 'transparent' ); + +/* EXPORT */ + +export default channels; diff --git a/tools/ui/node_modules/khroma/src/channels/type.ts b/tools/ui/node_modules/khroma/src/channels/type.ts new file mode 100644 index 0000000000000000000000000000000000000000..e7258b63b249bd87a7f3cf3b06ed289b84e0ecf9 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/channels/type.ts @@ -0,0 +1,46 @@ + +/* IMPORT */ + +import {TYPE} from '~/constants'; + +/* MAIN */ + +class Type { + + /* VARIABLES */ + + type: number = TYPE.ALL; + + /* API */ + + get (): number { + + return this.type; + + } + + set ( type: number ): void { + + if ( this.type && this.type !== type ) throw new Error ( 'Cannot change both RGB and HSL channels at the same time' ); + + this.type = type; + + } + + reset (): void { + + this.type = TYPE.ALL; + + } + + is ( type: number ): boolean { + + return this.type === type; + + } + +} + +/* EXPORT */ + +export default Type; diff --git a/tools/ui/node_modules/khroma/src/color/hex.ts b/tools/ui/node_modules/khroma/src/color/hex.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6ee1421e9f8b4623d1f884a2b5755e8466c7b91 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/color/hex.ts @@ -0,0 +1,66 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import ChannelsReusable from '~/channels/reusable'; +import {DEC2HEX} from '~/constants'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const Hex = { + + /* VARIABLES */ + + re: /^#((?:[a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i, + + /* API */ + + parse: ( color: string ): Channels | void => { + + if ( color.charCodeAt ( 0 ) !== 35 ) return; // '#' + + const match = color.match ( Hex.re ); + + if ( !match ) return; + + const hex = match[1]; + const dec = parseInt ( hex, 16 ); + const length = hex.length; + const hasAlpha = length % 4 === 0; + const isFullLength = length > 4; + const multiplier = isFullLength ? 1 : 17; + const bits = isFullLength ? 8 : 4; + const bitsOffset = hasAlpha ? 0 : -1; + const mask = isFullLength ? 255 : 15; + + return ChannelsReusable.set ({ + r: ( ( dec >> ( bits * ( bitsOffset + 3 ) ) ) & mask ) * multiplier, + g: ( ( dec >> ( bits * ( bitsOffset + 2 ) ) ) & mask ) * multiplier, + b: ( ( dec >> ( bits * ( bitsOffset + 1 ) ) ) & mask ) * multiplier, + a: hasAlpha ? ( dec & mask ) * multiplier / 255 : 1 + }, color ); + + }, + + stringify: ( channels: Channels ): string => { + + const {r, g, b, a} = channels; + + if ( a < 1 ) { // #RRGGBBAA + + return `#${DEC2HEX[Math.round ( r )]}${DEC2HEX[Math.round ( g )]}${DEC2HEX[Math.round ( b )]}${DEC2HEX[Math.round ( a * 255 )]}`; + + } else { // #RRGGBB + + return `#${DEC2HEX[Math.round ( r )]}${DEC2HEX[Math.round ( g )]}${DEC2HEX[Math.round ( b )]}`; + + } + + } + +}; + +/* EXPORT */ + +export default Hex; diff --git a/tools/ui/node_modules/khroma/src/color/hsl.ts b/tools/ui/node_modules/khroma/src/color/hsl.ts new file mode 100644 index 0000000000000000000000000000000000000000..8d86d1876117794fc6df4120027898c38151fef2 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/color/hsl.ts @@ -0,0 +1,82 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import ChannelsReusable from '~/channels/reusable'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const HSL = { + + /* VARIABLES */ + + re: /^hsla?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(?:deg|grad|rad|turn)?)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(%)?))?\s*?\)$/i, + hueRe: /^(.+?)(deg|grad|rad|turn)$/i, + + /* HELPERS */ + + _hue2deg: ( hue: string ): number => { + + const match = hue.match ( HSL.hueRe ); + + if ( match ) { + + const [, number, unit] = match; + + switch ( unit ) { + case 'grad': return _.channel.clamp.h ( parseFloat ( number ) * .9 ); + case 'rad': return _.channel.clamp.h ( parseFloat ( number ) * 180 / Math.PI ); + case 'turn': return _.channel.clamp.h ( parseFloat ( number ) * 360 ); + } + + } + + return _.channel.clamp.h ( parseFloat ( hue ) ); + + }, + + /* API */ + + parse: ( color: string ): Channels | void => { + + const charCode = color.charCodeAt ( 0 ); + + if ( charCode !== 104 && charCode !== 72 ) return; // 'h'/'H' + + const match = color.match ( HSL.re ); + + if ( !match ) return; + + const [, h, s, l, a, isAlphaPercentage] = match; + + return ChannelsReusable.set ({ + h: HSL._hue2deg ( h ), + s: _.channel.clamp.s ( parseFloat ( s ) ), + l: _.channel.clamp.l ( parseFloat ( l ) ), + a: a ? _.channel.clamp.a ( isAlphaPercentage ? parseFloat ( a ) / 100 : parseFloat ( a ) ) : 1 + }, color ); + + }, + + stringify: ( channels: Channels ): string => { + + const {h, s, l, a} = channels; + + if ( a < 1 ) { // HSLA + + return `hsla(${_.lang.round ( h )}, ${_.lang.round ( s )}%, ${_.lang.round ( l )}%, ${a})`; + + } else { // HSL + + return `hsl(${_.lang.round ( h )}, ${_.lang.round ( s )}%, ${_.lang.round ( l )}%)`; + + } + + } + +}; + +/* EXPORT */ + +export default HSL; diff --git a/tools/ui/node_modules/khroma/src/color/index.ts b/tools/ui/node_modules/khroma/src/color/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..b800de52304ca79f40051a08e472b8a890f34768 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/color/index.ts @@ -0,0 +1,67 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import Hex from '~/color/hex'; +import HSL from '~/color/hsl'; +import Keyword from '~/color/keyword'; +import RGB from '~/color/rgb'; +import {TYPE} from '~/constants'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const Color = { + + /* VARIABLES */ + + format: { + keyword: Keyword, + hex: Hex, + rgb: RGB, + rgba: RGB, + hsl: HSL, + hsla: HSL + }, + + /* API */ + + parse: ( color: string | Channels ): Channels => { + + if ( typeof color !== 'string' ) return color; + + const channels = Hex.parse ( color ) || RGB.parse ( color ) || HSL.parse ( color ) || Keyword.parse ( color ); // Color providers ordered with performance in mind + + if ( channels ) return channels; + + throw new Error ( `Unsupported color format: "${color}"` ); + + }, + + stringify: ( channels: Channels ): string => { + + // SASS returns a keyword if possible, but we avoid doing that as it's slower and doesn't really add any value + + if ( !channels.changed && channels.color ) return channels.color; + + if ( channels.type.is ( TYPE.HSL ) || channels.data.r === undefined ) { + + return HSL.stringify ( channels ); + + } else if ( channels.a < 1 || !Number.isInteger ( channels.r ) || !Number.isInteger ( channels.g ) || !Number.isInteger ( channels.b ) ) { + + return RGB.stringify ( channels ); + + } else { + + return Hex.stringify ( channels ); + + } + + } + +}; + +/* EXPORT */ + +export default Color; diff --git a/tools/ui/node_modules/khroma/src/color/keyword.ts b/tools/ui/node_modules/khroma/src/color/keyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..a856054b46c8cac935db6e090003d8c790ed0b27 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/color/keyword.ts @@ -0,0 +1,195 @@ + +/* IMPORT */ + +import Hex from '~/color/hex'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const Keyword = { + + /* VARIABLES */ + + colors: { + aliceblue: '#f0f8ff', + antiquewhite: '#faebd7', + aqua: '#00ffff', + aquamarine: '#7fffd4', + azure: '#f0ffff', + beige: '#f5f5dc', + bisque: '#ffe4c4', + black: '#000000', + blanchedalmond: '#ffebcd', + blue: '#0000ff', + blueviolet: '#8a2be2', + brown: '#a52a2a', + burlywood: '#deb887', + cadetblue: '#5f9ea0', + chartreuse: '#7fff00', + chocolate: '#d2691e', + coral: '#ff7f50', + cornflowerblue: '#6495ed', + cornsilk: '#fff8dc', + crimson: '#dc143c', + cyanaqua: '#00ffff', + darkblue: '#00008b', + darkcyan: '#008b8b', + darkgoldenrod: '#b8860b', + darkgray: '#a9a9a9', + darkgreen: '#006400', + darkgrey: '#a9a9a9', + darkkhaki: '#bdb76b', + darkmagenta: '#8b008b', + darkolivegreen: '#556b2f', + darkorange: '#ff8c00', + darkorchid: '#9932cc', + darkred: '#8b0000', + darksalmon: '#e9967a', + darkseagreen: '#8fbc8f', + darkslateblue: '#483d8b', + darkslategray: '#2f4f4f', + darkslategrey: '#2f4f4f', + darkturquoise: '#00ced1', + darkviolet: '#9400d3', + deeppink: '#ff1493', + deepskyblue: '#00bfff', + dimgray: '#696969', + dimgrey: '#696969', + dodgerblue: '#1e90ff', + firebrick: '#b22222', + floralwhite: '#fffaf0', + forestgreen: '#228b22', + fuchsia: '#ff00ff', + gainsboro: '#dcdcdc', + ghostwhite: '#f8f8ff', + gold: '#ffd700', + goldenrod: '#daa520', + gray: '#808080', + green: '#008000', + greenyellow: '#adff2f', + grey: '#808080', + honeydew: '#f0fff0', + hotpink: '#ff69b4', + indianred: '#cd5c5c', + indigo: '#4b0082', + ivory: '#fffff0', + khaki: '#f0e68c', + lavender: '#e6e6fa', + lavenderblush: '#fff0f5', + lawngreen: '#7cfc00', + lemonchiffon: '#fffacd', + lightblue: '#add8e6', + lightcoral: '#f08080', + lightcyan: '#e0ffff', + lightgoldenrodyellow: '#fafad2', + lightgray: '#d3d3d3', + lightgreen: '#90ee90', + lightgrey: '#d3d3d3', + lightpink: '#ffb6c1', + lightsalmon: '#ffa07a', + lightseagreen: '#20b2aa', + lightskyblue: '#87cefa', + lightslategray: '#778899', + lightslategrey: '#778899', + lightsteelblue: '#b0c4de', + lightyellow: '#ffffe0', + lime: '#00ff00', + limegreen: '#32cd32', + linen: '#faf0e6', + magenta: '#ff00ff', + maroon: '#800000', + mediumaquamarine: '#66cdaa', + mediumblue: '#0000cd', + mediumorchid: '#ba55d3', + mediumpurple: '#9370db', + mediumseagreen: '#3cb371', + mediumslateblue: '#7b68ee', + mediumspringgreen: '#00fa9a', + mediumturquoise: '#48d1cc', + mediumvioletred: '#c71585', + midnightblue: '#191970', + mintcream: '#f5fffa', + mistyrose: '#ffe4e1', + moccasin: '#ffe4b5', + navajowhite: '#ffdead', + navy: '#000080', + oldlace: '#fdf5e6', + olive: '#808000', + olivedrab: '#6b8e23', + orange: '#ffa500', + orangered: '#ff4500', + orchid: '#da70d6', + palegoldenrod: '#eee8aa', + palegreen: '#98fb98', + paleturquoise: '#afeeee', + palevioletred: '#db7093', + papayawhip: '#ffefd5', + peachpuff: '#ffdab9', + peru: '#cd853f', + pink: '#ffc0cb', + plum: '#dda0dd', + powderblue: '#b0e0e6', + purple: '#800080', + rebeccapurple: '#663399', + red: '#ff0000', + rosybrown: '#bc8f8f', + royalblue: '#4169e1', + saddlebrown: '#8b4513', + salmon: '#fa8072', + sandybrown: '#f4a460', + seagreen: '#2e8b57', + seashell: '#fff5ee', + sienna: '#a0522d', + silver: '#c0c0c0', + skyblue: '#87ceeb', + slateblue: '#6a5acd', + slategray: '#708090', + slategrey: '#708090', + snow: '#fffafa', + springgreen: '#00ff7f', + tan: '#d2b48c', + teal: '#008080', + thistle: '#d8bfd8', + transparent: '#00000000', + turquoise: '#40e0d0', + violet: '#ee82ee', + wheat: '#f5deb3', + white: '#ffffff', + whitesmoke: '#f5f5f5', + yellow: '#ffff00', + yellowgreen: '#9acd32' + }, + + /* API */ + + parse: ( color: string ): Channels | void => { + + color = color.toLowerCase (); + + const hex = Keyword.colors[color]; + + if ( !hex ) return; + + return Hex.parse ( hex ); + + }, + + stringify: ( channels: Channels ): string | undefined => { + + const hex = Hex.stringify ( channels ); + + for ( const name in Keyword.colors ) { + + if ( Keyword.colors[name] === hex ) return name; + + } + + return; + + } + +}; + +/* EXPORT */ + +export default Keyword; diff --git a/tools/ui/node_modules/khroma/src/color/rgb.ts b/tools/ui/node_modules/khroma/src/color/rgb.ts new file mode 100644 index 0000000000000000000000000000000000000000..d634a867f62eda8cda2c2d7bcc8d34c399713aeb --- /dev/null +++ b/tools/ui/node_modules/khroma/src/color/rgb.ts @@ -0,0 +1,59 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import ChannelsReusable from '~/channels/reusable'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const RGB = { + + /* VARIABLES */ + + re: /^rgba?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?)))?\s*?\)$/i, + + /* API */ + + parse: ( color: string ): Channels | void => { + + const charCode = color.charCodeAt ( 0 ); + + if ( charCode !== 114 && charCode !== 82 ) return; // 'r'/'R' + + const match = color.match ( RGB.re ); + + if ( !match ) return; + + const [, r, isRedPercentage, g, isGreenPercentage, b, isBluePercentage, a, isAlphaPercentage] = match; + + return ChannelsReusable.set ({ + r: _.channel.clamp.r ( isRedPercentage ? parseFloat ( r ) * 2.55 : parseFloat ( r ) ), + g: _.channel.clamp.g ( isGreenPercentage ? parseFloat ( g ) * 2.55 : parseFloat ( g ) ), + b: _.channel.clamp.b ( isBluePercentage ? parseFloat ( b ) * 2.55 : parseFloat ( b ) ), + a: a ? _.channel.clamp.a ( isAlphaPercentage ? parseFloat ( a ) / 100 : parseFloat ( a ) ) : 1 + }, color ); + + }, + + stringify: ( channels: Channels ): string => { + + const {r, g, b, a} = channels; + + if ( a < 1 ) { // RGBA + + return `rgba(${_.lang.round ( r )}, ${_.lang.round ( g )}, ${_.lang.round ( b )}, ${_.lang.round ( a )})`; + + } else { // RGB + + return `rgb(${_.lang.round ( r )}, ${_.lang.round ( g )}, ${_.lang.round ( b )})`; + + } + + } + +}; + +/* EXPORT */ + +export default RGB; diff --git a/tools/ui/node_modules/khroma/src/constants.ts b/tools/ui/node_modules/khroma/src/constants.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b60be5c8805d4126e95609decbde894fa77e05e --- /dev/null +++ b/tools/ui/node_modules/khroma/src/constants.ts @@ -0,0 +1,20 @@ + +/* IMPORT */ + +import _ from '~/utils'; + +/* MAIN */ + +const DEC2HEX: Record = {}; + +for ( let i = 0; i <= 255; i++ ) DEC2HEX[i] = _.unit.dec2hex ( i ); // Populating dynamically, striking a balance between code size and performance + +const TYPE = { + ALL: 0, + RGB: 1, + HSL: 2 +}; + +/* EXPORT */ + +export {DEC2HEX, TYPE}; diff --git a/tools/ui/node_modules/khroma/src/index.ts b/tools/ui/node_modules/khroma/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..8750f9b83821aed5bc01e0bd58a0a9c6c01173c6 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/index.ts @@ -0,0 +1,4 @@ + +/* EXPORT */ + +export * from '~/methods'; diff --git a/tools/ui/node_modules/khroma/src/methods/adjust.ts b/tools/ui/node_modules/khroma/src/methods/adjust.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ae8eb47748d5028e9289dc12267a7148d50f973 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/adjust.ts @@ -0,0 +1,29 @@ + +/* IMPORT */ + +import Color from '~/color'; +import change from '~/methods/change'; +import type {CHANNELS, Channels} from '~/types'; + +/* MAIN */ + +const adjust = ( color: string | Channels, channels: Partial ): string => { + + const ch = Color.parse ( color ); + const changes: Partial = {}; + + for ( const c in channels ) { + + if ( !channels[c] ) continue; + + changes[c] = ch[c] + channels[c]; + + } + + return change ( color, changes ); + +}; + +/* EXPORT */ + +export default adjust; diff --git a/tools/ui/node_modules/khroma/src/methods/adjust_channel.ts b/tools/ui/node_modules/khroma/src/methods/adjust_channel.ts new file mode 100644 index 0000000000000000000000000000000000000000..d567a1472b5d951392869d50c9b444559b348b51 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/adjust_channel.ts @@ -0,0 +1,24 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import Color from '~/color'; +import type {CHANNEL, Channels} from '~/types'; + +/* MAIN */ + +const adjustChannel = ( color: string | Channels, channel: CHANNEL, amount: number ): string => { + + const channels = Color.parse ( color ); + const amountCurrent = channels[channel]; + const amountNext = _.channel.clamp[channel]( amountCurrent + amount ); + + if ( amountCurrent !== amountNext ) channels[channel] = amountNext; + + return Color.stringify ( channels ); + +}; + +/* EXPORT */ + +export default adjustChannel; diff --git a/tools/ui/node_modules/khroma/src/methods/alpha.ts b/tools/ui/node_modules/khroma/src/methods/alpha.ts new file mode 100644 index 0000000000000000000000000000000000000000..40f6182b15b2f4a5dac4416547437cf023cc43e5 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/alpha.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import channel from '~/methods/channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const alpha = ( color: string | Channels ): number => { + + return channel ( color, 'a' ); + +}; + +/* EXPORT */ + +export default alpha; diff --git a/tools/ui/node_modules/khroma/src/methods/blue.ts b/tools/ui/node_modules/khroma/src/methods/blue.ts new file mode 100644 index 0000000000000000000000000000000000000000..e212cb39f993b6b4f0ce2aaabcd50ed809636daf --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/blue.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import channel from '~/methods/channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const blue = ( color: string | Channels ): number => { + + return channel ( color, 'b' ); + +}; + +/* EXPORT */ + +export default blue; diff --git a/tools/ui/node_modules/khroma/src/methods/change.ts b/tools/ui/node_modules/khroma/src/methods/change.ts new file mode 100644 index 0000000000000000000000000000000000000000..78af793c1e2f9cf25fdca7837784915a631d12a1 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/change.ts @@ -0,0 +1,26 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import Color from '~/color'; +import type {CHANNELS, Channels} from '~/types'; + +/* MAIN */ + +const change = ( color: string | Channels, channels: Partial ): string => { + + const ch = Color.parse ( color ); + + for ( const c in channels ) { + + ch[c] = _.channel.clamp[c]( channels[c] ); + + } + + return Color.stringify ( ch ); + +}; + +/* EXPORT */ + +export default change; diff --git a/tools/ui/node_modules/khroma/src/methods/channel.ts b/tools/ui/node_modules/khroma/src/methods/channel.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ef8468d0b4ef0246495f115053c511ab5e6ab99 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/channel.ts @@ -0,0 +1,18 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import Color from '~/color'; +import type {CHANNEL, Channels} from '~/types'; + +/* MAIN */ + +const channel = ( color: string | Channels, channel: CHANNEL ): number => { + + return _.lang.round ( Color.parse ( color )[channel] ); + +}; + +/* EXPORT */ + +export default channel; diff --git a/tools/ui/node_modules/khroma/src/methods/complement.ts b/tools/ui/node_modules/khroma/src/methods/complement.ts new file mode 100644 index 0000000000000000000000000000000000000000..6a4590b832f433436776b318a85993d1ba5c773a --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/complement.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import adjustChannel from '~/methods/adjust_channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const complement = ( color: string | Channels ): string => { + + return adjustChannel ( color, 'h', 180 ); + +}; + +/* EXPORT */ + +export default complement; diff --git a/tools/ui/node_modules/khroma/src/methods/contrast.ts b/tools/ui/node_modules/khroma/src/methods/contrast.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f7490d72080d8f1163a06da56c447b6a7df495b --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/contrast.ts @@ -0,0 +1,23 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import luminance from '~/methods/luminance'; + +/* MAIN */ + +const contrast = ( color1: string, color2: string ): number => { + + const luminance1 = luminance ( color1 ); + const luminance2 = luminance ( color2 ); + const max = Math.max ( luminance1, luminance2 ); + const min = Math.min ( luminance1, luminance2 ); + const ratio = ( max + Number.EPSILON ) / ( min + Number.EPSILON ); + + return _.lang.round ( _.lang.clamp ( ratio, 1, 10 ) ); + +}; + +/* EXPORT */ + +export default contrast; diff --git a/tools/ui/node_modules/khroma/src/methods/darken.ts b/tools/ui/node_modules/khroma/src/methods/darken.ts new file mode 100644 index 0000000000000000000000000000000000000000..4a765cc6592b9e8c59ee6bd436ce2227d0dff661 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/darken.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import adjustChannel from '~/methods/adjust_channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const darken = ( color: string | Channels, amount: number ): string => { + + return adjustChannel ( color, 'l', -amount ); + +}; + +/* EXPORT */ + +export default darken; diff --git a/tools/ui/node_modules/khroma/src/methods/desaturate.ts b/tools/ui/node_modules/khroma/src/methods/desaturate.ts new file mode 100644 index 0000000000000000000000000000000000000000..b8cb0e424ca184930f01cd39b9826857e7324510 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/desaturate.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import adjustChannel from '~/methods/adjust_channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const desaturate = ( color: string | Channels, amount: number ): string => { + + return adjustChannel ( color, 's', -amount ); + +}; + +/* EXPORT */ + +export default desaturate; diff --git a/tools/ui/node_modules/khroma/src/methods/grayscale.ts b/tools/ui/node_modules/khroma/src/methods/grayscale.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c7ab86e21748aeedca873ae22eb2f4ed15819f9 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/grayscale.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import change from '~/methods/change'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const grayscale = ( color: string | Channels ): string => { + + return change ( color, { s: 0 } ); + +}; + +/* EXPORT */ + +export default grayscale; diff --git a/tools/ui/node_modules/khroma/src/methods/green.ts b/tools/ui/node_modules/khroma/src/methods/green.ts new file mode 100644 index 0000000000000000000000000000000000000000..c700617d6b93c68b99842c9d7c85c057ca96278d --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/green.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import channel from '~/methods/channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const green = ( color: string | Channels ): number => { + + return channel ( color, 'g' ); + +}; + +/* EXPORT */ + +export default green; diff --git a/tools/ui/node_modules/khroma/src/methods/hsla.ts b/tools/ui/node_modules/khroma/src/methods/hsla.ts new file mode 100644 index 0000000000000000000000000000000000000000..c92739ec3018ddd81c97d35735255160dd8d6f9c --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/hsla.ts @@ -0,0 +1,25 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import ChannelsReusable from '~/channels/reusable'; +import Color from '~/color'; + +/* MAIN */ + +const hsla = ( h: number, s: number, l: number, a: number = 1 ): string => { + + const channels = ChannelsReusable.set ({ + h: _.channel.clamp.h ( h ), + s: _.channel.clamp.s ( s ), + l: _.channel.clamp.l ( l ), + a: _.channel.clamp.a ( a ) + }); + + return Color.stringify ( channels ); + +}; + +/* EXPORT */ + +export default hsla; diff --git a/tools/ui/node_modules/khroma/src/methods/hue.ts b/tools/ui/node_modules/khroma/src/methods/hue.ts new file mode 100644 index 0000000000000000000000000000000000000000..83274ee527aa920e284134058b7199d006fb2f13 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/hue.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import channel from '~/methods/channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const hue = ( color: string | Channels ): number => { + + return channel ( color, 'h' ); + +}; + +/* EXPORT */ + +export default hue; diff --git a/tools/ui/node_modules/khroma/src/methods/index.ts b/tools/ui/node_modules/khroma/src/methods/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a8fa3d8d22f8ce0cc2b7a09f4bd9f49e161c02e --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/index.ts @@ -0,0 +1,92 @@ + +/* IMPORT */ + +import hex from '~/methods/rgba'; // Alias +import rgb from '~/methods/rgba'; // Alias +import rgba from '~/methods/rgba'; +import hsl from '~/methods/hsla'; // Alias +import hsla from '~/methods/hsla'; +import toKeyword from '~/methods/to_keyword'; +import toHex from '~/methods/to_hex'; +import toRgba from '~/methods/to_rgba'; +import toHsla from '~/methods/to_hsla'; +import channel from '~/methods/channel'; +import red from '~/methods/red'; +import green from '~/methods/green'; +import blue from '~/methods/blue'; +import hue from '~/methods/hue'; +import saturation from '~/methods/saturation'; +import lightness from '~/methods/lightness'; +import alpha from '~/methods/alpha'; +import opacity from '~/methods/alpha'; // Alias +import contrast from '~/methods/contrast'; +import luminance from '~/methods/luminance'; +import isDark from '~/methods/is_dark'; +import isLight from '~/methods/is_light'; +import isTransparent from '~/methods/is_transparent'; +import isValid from '~/methods/is_valid'; +import saturate from '~/methods/saturate'; +import desaturate from '~/methods/desaturate'; +import lighten from '~/methods/lighten'; +import darken from '~/methods/darken'; +import opacify from '~/methods/opacify'; +import fadeIn from '~/methods/opacify'; // Alias +import transparentize from '~/methods/transparentize'; +import fadeOut from '~/methods/transparentize'; // Alias +import complement from '~/methods/complement'; +import grayscale from '~/methods/grayscale'; +import adjust from '~/methods/adjust'; +import change from '~/methods/change'; +import invert from '~/methods/invert'; +import mix from '~/methods/mix'; +import scale from '~/methods/scale'; + +/* EXPORT */ + +export { + /* CREATE */ + hex, + rgb, + rgba, + hsl, + hsla, + /* CONVERT */ + toKeyword, + toHex, + toRgba, + toHsla, + /* GET - CHANNEL */ + channel, + red, + green, + blue, + hue, + saturation, + lightness, + alpha, + opacity, + /* GET - MORE */ + contrast, + luminance, + isDark, + isLight, + isTransparent, + isValid, + /* EDIT - CHANNEL */ + saturate, + desaturate, + lighten, + darken, + opacify, + fadeIn, + transparentize, + fadeOut, + complement, + grayscale, + /* EDIT - MORE */ + adjust, + change, + invert, + mix, + scale +}; diff --git a/tools/ui/node_modules/khroma/src/methods/invert.ts b/tools/ui/node_modules/khroma/src/methods/invert.ts new file mode 100644 index 0000000000000000000000000000000000000000..0af1cf74e0875358971e92ce8b1a2cb77e8493b0 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/invert.ts @@ -0,0 +1,24 @@ + +/* IMPORT */ + +import Color from '~/color'; +import mix from '~/methods/mix'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const invert = ( color: string | Channels, weight: number = 100 ): string => { + + const inverse = Color.parse ( color ); + + inverse.r = 255 - inverse.r; + inverse.g = 255 - inverse.g; + inverse.b = 255 - inverse.b; + + return mix ( inverse, color, weight ); + +}; + +/* EXPORT */ + +export default invert; diff --git a/tools/ui/node_modules/khroma/src/methods/is_dark.ts b/tools/ui/node_modules/khroma/src/methods/is_dark.ts new file mode 100644 index 0000000000000000000000000000000000000000..0ffb16aee53893f4fcff9ef63195d3fd26466812 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/is_dark.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import isLight from '~/methods/is_light'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const isDark = ( color: string | Channels ): boolean => { + + return !isLight ( color ); + +}; + +/* EXPORT */ + +export default isDark; diff --git a/tools/ui/node_modules/khroma/src/methods/is_light.ts b/tools/ui/node_modules/khroma/src/methods/is_light.ts new file mode 100644 index 0000000000000000000000000000000000000000..c4092ec44f5484d22a1a3914c7a85d5d73c7aacf --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/is_light.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import luminance from '~/methods/luminance'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const isLight = ( color: string | Channels ): boolean => { + + return luminance ( color ) >= .5; + +}; + +/* EXPORT */ + +export default isLight; diff --git a/tools/ui/node_modules/khroma/src/methods/is_transparent.ts b/tools/ui/node_modules/khroma/src/methods/is_transparent.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a1db45f176737f8d9d3863fa44ac6600b618c3b --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/is_transparent.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import alpha from '~/methods/alpha'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const isTransparent = ( color: string | Channels ): boolean => { + + return !alpha ( color ); + +}; + +/* EXPORT */ + +export default isTransparent; diff --git a/tools/ui/node_modules/khroma/src/methods/is_valid.ts b/tools/ui/node_modules/khroma/src/methods/is_valid.ts new file mode 100644 index 0000000000000000000000000000000000000000..76e8fcb0f98cccd3ee0aed5e072744c67115527a --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/is_valid.ts @@ -0,0 +1,26 @@ + +/* IMPORT */ + +import Color from '~/color'; + +/* MAIN */ + +const isValid = ( color: string ): boolean => { + + try { + + Color.parse ( color ); + + return true; + + } catch { + + return false; + + } + +}; + +/* EXPORT */ + +export default isValid; diff --git a/tools/ui/node_modules/khroma/src/methods/lighten.ts b/tools/ui/node_modules/khroma/src/methods/lighten.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b11600f51dcb47471780d6c4304f0dc2ecfa9b2 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/lighten.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import adjustChannel from '~/methods/adjust_channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const lighten = ( color: string | Channels, amount: number ): string => { + + return adjustChannel ( color, 'l', amount ); + +}; + +/* EXPORT */ + +export default lighten; diff --git a/tools/ui/node_modules/khroma/src/methods/lightness.ts b/tools/ui/node_modules/khroma/src/methods/lightness.ts new file mode 100644 index 0000000000000000000000000000000000000000..82df39080d8a4f8e862159842f8165032a8f54a3 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/lightness.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import channel from '~/methods/channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const lightness = ( color: string | Channels ): number => { + + return channel ( color, 'l' ); + +}; + +/* EXPORT */ + +export default lightness; diff --git a/tools/ui/node_modules/khroma/src/methods/luminance.ts b/tools/ui/node_modules/khroma/src/methods/luminance.ts new file mode 100644 index 0000000000000000000000000000000000000000..58806def65190ec37d92de00b79cae30d43841c9 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/luminance.ts @@ -0,0 +1,23 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import Color from '~/color'; +import type {Channels} from '~/types'; + +/* MAIN */ + +//SOURCE: https://planetcalc.com/7779 + +const luminance = ( color: string | Channels ): number => { + + const {r, g, b} = Color.parse ( color ); + const luminance = .2126 * _.channel.toLinear ( r ) + .7152 * _.channel.toLinear ( g ) + .0722 * _.channel.toLinear ( b ); + + return _.lang.round ( luminance ); + +}; + +/* EXPORT */ + +export default luminance; diff --git a/tools/ui/node_modules/khroma/src/methods/mix.ts b/tools/ui/node_modules/khroma/src/methods/mix.ts new file mode 100644 index 0000000000000000000000000000000000000000..737d87a6ab81d869cb9ebc1eaf0eba5fcf889c4f --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/mix.ts @@ -0,0 +1,33 @@ + +/* IMPORT */ + +import Color from '~/color'; +import rgba from '~/methods/rgba'; +import type {Channels} from '~/types'; + +/* MAIN */ + +//SOURCE: https://github.com/sass/dart-sass/blob/7457d2e9e7e623d9844ffd037a070cf32d39c348/lib/src/functions/color.dart#L718-L756 + +const mix = ( color1: string | Channels, color2: string | Channels, weight: number = 50 ): string => { + + const {r: r1, g: g1, b: b1, a: a1} = Color.parse ( color1 ); + const {r: r2, g: g2, b: b2, a: a2} = Color.parse ( color2 ); + const weightScale = weight / 100; + const weightNormalized = ( weightScale * 2 ) - 1; + const alphaDelta = a1 - a2; + const weight1combined = ( ( weightNormalized * alphaDelta ) === -1 ) ? weightNormalized : ( weightNormalized + alphaDelta ) / ( 1 + weightNormalized * alphaDelta ); + const weight1 = ( weight1combined + 1 ) / 2; + const weight2 = 1 - weight1; + const r = ( r1 * weight1 ) + ( r2 * weight2 ); + const g = ( g1 * weight1 ) + ( g2 * weight2 ); + const b = ( b1 * weight1 ) + ( b2 * weight2 ); + const a = ( a1 * weightScale ) + ( a2 * ( 1 - weightScale ) ); + + return rgba ( r, g, b, a ); + +}; + +/* EXPORT */ + +export default mix; diff --git a/tools/ui/node_modules/khroma/src/methods/opacify.ts b/tools/ui/node_modules/khroma/src/methods/opacify.ts new file mode 100644 index 0000000000000000000000000000000000000000..53fbed50cfaadc4f6bf0aed40d65b13a7fef8cd9 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/opacify.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import adjustChannel from '~/methods/adjust_channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const opacify = ( color: string | Channels, amount: number ): string => { + + return adjustChannel ( color, 'a', amount ); + +}; + +/* EXPORT */ + +export default opacify; diff --git a/tools/ui/node_modules/khroma/src/methods/red.ts b/tools/ui/node_modules/khroma/src/methods/red.ts new file mode 100644 index 0000000000000000000000000000000000000000..d5a638748666533e3fda388c60a966d3bd225c05 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/red.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import channel from '~/methods/channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const red = ( color: string | Channels ): number => { + + return channel ( color, 'r' ); + +}; + +/* EXPORT */ + +export default red; diff --git a/tools/ui/node_modules/khroma/src/methods/rgba.ts b/tools/ui/node_modules/khroma/src/methods/rgba.ts new file mode 100644 index 0000000000000000000000000000000000000000..7fef73bc05fbe70aa7489c639a3cb98a4324a159 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/rgba.ts @@ -0,0 +1,36 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import ChannelsReusable from '~/channels/reusable'; +import Color from '~/color'; +import change from '~/methods/change'; +import type {Channels} from '~/types'; + +/* TYPES */ + +type IRgba = { + ( color: string | Channels, opacity: number ): string, + ( r: number, g: number, b: number, a?: number ): string +}; + +/* MAIN */ + +const rgba: IRgba = ( r: string | Channels | number, g: number, b: number = 0, a: number = 1 ): string => { //TSC: `b` shouldn't have a default value + + if ( typeof r !== 'number' ) return change ( r, { a: g } ); + + const channels = ChannelsReusable.set ({ + r: _.channel.clamp.r ( r ), + g: _.channel.clamp.g ( g ), + b: _.channel.clamp.b ( b ), + a: _.channel.clamp.a ( a ) + }); + + return Color.stringify ( channels ); + +}; + +/* EXPORT */ + +export default rgba; diff --git a/tools/ui/node_modules/khroma/src/methods/saturate.ts b/tools/ui/node_modules/khroma/src/methods/saturate.ts new file mode 100644 index 0000000000000000000000000000000000000000..1400f1fe479aeab94c2c5e9b4e22bac653bd7b9d --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/saturate.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import adjustChannel from '~/methods/adjust_channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const saturate = ( color: string | Channels, amount: number ): string => { + + return adjustChannel ( color, 's', amount ); + +}; + +/* EXPORT */ + +export default saturate; diff --git a/tools/ui/node_modules/khroma/src/methods/saturation.ts b/tools/ui/node_modules/khroma/src/methods/saturation.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ca77b1bccf7acdd6089306db0deb2d75e8754c3 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/saturation.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import channel from '~/methods/channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const saturation = ( color: string | Channels ): number => { + + return channel ( color, 's' ); + +}; + +/* EXPORT */ + +export default saturation; diff --git a/tools/ui/node_modules/khroma/src/methods/scale.ts b/tools/ui/node_modules/khroma/src/methods/scale.ts new file mode 100644 index 0000000000000000000000000000000000000000..21a873c1721059421e0773727bd4a60297496a8d --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/scale.ts @@ -0,0 +1,29 @@ + +/* IMPORT */ + +import _ from '~/utils'; +import Color from '~/color'; +import adjust from '~/methods/adjust'; +import type {CHANNELS, Channels} from '~/types'; + +/* MAIN */ + +const scale = ( color: string | Channels, channels: Partial ): string => { + + const ch = Color.parse ( color ); + const adjustments: Partial = {}; + const delta = ( amount: number, weight: number, max: number ) => weight > 0 ? ( max - amount ) * weight / 100 : amount * weight / 100; + + for ( const c in channels ) { + + adjustments[c] = delta ( ch[c], channels[c], _.channel.max[c] ); + + } + + return adjust ( color, adjustments ); + +}; + +/* EXPORT */ + +export default scale; diff --git a/tools/ui/node_modules/khroma/src/methods/to_hex.ts b/tools/ui/node_modules/khroma/src/methods/to_hex.ts new file mode 100644 index 0000000000000000000000000000000000000000..df29125dd09608386fb5ae75387f6b947ea2a409 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/to_hex.ts @@ -0,0 +1,16 @@ + +/* IMPORT */ + +import Color from '~/color'; + +/* MAIN */ + +const toHex = ( color: string ): string => { + + return Color.format.hex.stringify ( Color.parse ( color ) ); + +}; + +/* EXPORT */ + +export default toHex; diff --git a/tools/ui/node_modules/khroma/src/methods/to_hsla.ts b/tools/ui/node_modules/khroma/src/methods/to_hsla.ts new file mode 100644 index 0000000000000000000000000000000000000000..f50c58df52505023f432acb52ee1c34d4f0304cc --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/to_hsla.ts @@ -0,0 +1,16 @@ + +/* IMPORT */ + +import Color from '~/color'; + +/* MAIN */ + +const toHsla = ( color: string ): string => { + + return Color.format.hsla.stringify ( Color.parse ( color ) ); + +}; + +/* EXPORT */ + +export default toHsla; diff --git a/tools/ui/node_modules/khroma/src/methods/to_keyword.ts b/tools/ui/node_modules/khroma/src/methods/to_keyword.ts new file mode 100644 index 0000000000000000000000000000000000000000..d94f3cb0cdf79a420bcbb2bdead04016f064351f --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/to_keyword.ts @@ -0,0 +1,16 @@ + +/* IMPORT */ + +import Color from '~/color'; + +/* MAIN */ + +const toKeyword = ( color: string ): string | undefined => { + + return Color.format.keyword.stringify ( Color.parse ( color ) ); + +}; + +/* EXPORT */ + +export default toKeyword; diff --git a/tools/ui/node_modules/khroma/src/methods/to_rgba.ts b/tools/ui/node_modules/khroma/src/methods/to_rgba.ts new file mode 100644 index 0000000000000000000000000000000000000000..55c330ef9a173ff548fc55af9fe912b94b40f8cf --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/to_rgba.ts @@ -0,0 +1,16 @@ + +/* IMPORT */ + +import Color from '~/color'; + +/* MAIN */ + +const toRgba = ( color: string ): string => { + + return Color.format.rgba.stringify ( Color.parse ( color ) ); + +}; + +/* EXPORT */ + +export default toRgba; diff --git a/tools/ui/node_modules/khroma/src/methods/transparentize.ts b/tools/ui/node_modules/khroma/src/methods/transparentize.ts new file mode 100644 index 0000000000000000000000000000000000000000..f0b0153e381c1b32621d496b9f3b9f2375a06d45 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/methods/transparentize.ts @@ -0,0 +1,17 @@ + +/* IMPORT */ + +import adjustChannel from '~/methods/adjust_channel'; +import type {Channels} from '~/types'; + +/* MAIN */ + +const transparentize = ( color: string | Channels, amount: number ): string => { + + return adjustChannel ( color, 'a', -amount ); + +}; + +/* EXPORT */ + +export default transparentize; diff --git a/tools/ui/node_modules/khroma/src/types.ts b/tools/ui/node_modules/khroma/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..141b19a6c0e3e5cda7fa7083e9901140aeaabd86 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/types.ts @@ -0,0 +1,35 @@ + +/* IMPORT */ + +import type Channels from './channels'; + +/* MAIN */ + +type ALPHA = { + a: number // Alpha (0~1) +}; + +type RGB = { + r: number, // Red (0~255) + g: number, // Green (0~255) + b: number // Blue (0~255) +}; + +type RGBA = RGB & ALPHA; + +type HSL = { + h: number, // Hue (0~360) + s: number, // Saturation (0~100) + l: number // Lightness (0~100) +}; + +type HSLA = HSL & ALPHA; + +type CHANNEL = 'r' | 'g' | 'b' | 'h' | 's' | 'l' | 'a'; + +type CHANNELS = Record; + +/* EXPORT */ + +export type {Channels}; +export type {ALPHA, RGB, RGBA, HSL, HSLA, CHANNEL, CHANNELS}; diff --git a/tools/ui/node_modules/khroma/src/utils/channel.ts b/tools/ui/node_modules/khroma/src/utils/channel.ts new file mode 100644 index 0000000000000000000000000000000000000000..111a732af92baabcb2b03e57ea186ec7707615f3 --- /dev/null +++ b/tools/ui/node_modules/khroma/src/utils/channel.ts @@ -0,0 +1,122 @@ + +/* IMPORT */ + +import type {RGB, HSL} from '~/types'; + +/* MAIN */ + +const Channel = { + + /* CLAMP */ + + min: { + r: 0, + g: 0, + b: 0, + s: 0, + l: 0, + a: 0 + }, + + max: { + r: 255, + g: 255, + b: 255, + h: 360, + s: 100, + l: 100, + a: 1 + }, + + clamp: { + r: ( r: number ) => r >= 255 ? 255 : ( r < 0 ? 0 : r ), + g: ( g: number ) => g >= 255 ? 255 : ( g < 0 ? 0 : g ), + b: ( b: number ) => b >= 255 ? 255 : ( b < 0 ? 0 : b ), + h: ( h: number ) => h % 360, + s: ( s: number ) => s >= 100 ? 100 : ( s < 0 ? 0 : s ), + l: ( l: number ) => l >= 100 ? 100 : ( l < 0 ? 0 : l ), + a: ( a: number ) => a >= 1 ? 1 : ( a < 0 ? 0 : a ) + }, + + /* CONVERSION */ + + //SOURCE: https://planetcalc.com/7779 + + toLinear: ( c: number ): number => { + + const n = c / 255; + + return c > .03928 ? Math.pow ( ( ( n + .055 ) / 1.055 ), 2.4 ) : n / 12.92; + + }, + + //SOURCE: https://gist.github.com/mjackson/5311256 + + hue2rgb: ( p: number, q: number, t: number ): number => { + + if ( t < 0 ) t += 1; + + if ( t > 1 ) t -= 1; + + if ( t < 1/6 ) return p + ( q - p ) * 6 * t; + + if ( t < 1/2 ) return q; + + if ( t < 2/3 ) return p + ( q - p ) * ( 2/3 - t ) * 6; + + return p; + + }, + + hsl2rgb: ( { h, s, l }: HSL, channel: keyof RGB ): number => { + + if ( !s ) return l * 2.55; // Achromatic + + h /= 360; + s /= 100; + l /= 100; + + const q = ( l < .5 ) ? l * ( 1 + s ) : ( l + s ) - ( l * s ); + const p = 2 * l - q; + + switch ( channel ) { + case 'r': return Channel.hue2rgb ( p, q, h + 1/3 ) * 255; + case 'g': return Channel.hue2rgb ( p, q, h ) * 255; + case 'b': return Channel.hue2rgb ( p, q, h - 1/3 ) * 255; + } + + }, + + rgb2hsl: ( { r, g, b }: RGB, channel: keyof HSL ): number => { + + r /= 255; + g /= 255; + b /= 255; + + const max = Math.max ( r, g, b ); + const min = Math.min ( r, g, b ); + const l = ( max + min ) / 2; + + if ( channel === 'l' ) return l * 100; + + if ( max === min ) return 0; // Achromatic + + const d = max - min; + const s = ( l > .5 ) ? d / ( 2 - max - min ) : d / ( max + min ); + + if ( channel === 's' ) return s * 100; + + switch ( max ) { + case r: return ( ( g - b ) / d + ( g < b ? 6 : 0 ) ) * 60; + case g: return ( ( b - r ) / d + 2 ) * 60; + case b: return ( ( r - g ) / d + 4 ) * 60; + default: return -1; //TSC: TypeScript is stupid and complains if there isn't this useless default statement + } + + } + +}; + +/* EXPORT */ + +export default Channel; diff --git a/tools/ui/node_modules/khroma/src/utils/index.ts b/tools/ui/node_modules/khroma/src/utils/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..66491d064625c3aba8a31fa001a5b1097a73735c --- /dev/null +++ b/tools/ui/node_modules/khroma/src/utils/index.ts @@ -0,0 +1,18 @@ + +/* IMPORT */ + +import channel from '~/utils/channel'; +import lang from '~/utils/lang'; +import unit from '~/utils/unit'; + +/* MAIN */ + +const Utils = { + channel, + lang, + unit +}; + +/* EXPORT */ + +export default Utils; diff --git a/tools/ui/node_modules/khroma/src/utils/lang.ts b/tools/ui/node_modules/khroma/src/utils/lang.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d7a241599bcef773177f62d1490f658bf323e6b --- /dev/null +++ b/tools/ui/node_modules/khroma/src/utils/lang.ts @@ -0,0 +1,26 @@ + +/* MAIN */ + +const Lang = { + + /* API */ + + clamp: ( number: number, lower: number, upper: number ): number => { + + if ( lower > upper ) return Math.min ( lower, Math.max ( upper, number ) ); + + return Math.min ( upper, Math.max ( lower, number ) ); + + }, + + round: ( number: number ): number => { // 10 digits rounding + + return Math.round ( number * 10000000000 ) / 10000000000; + + } + +}; + +/* EXPORT */ + +export default Lang; diff --git a/tools/ui/node_modules/khroma/src/utils/unit.ts b/tools/ui/node_modules/khroma/src/utils/unit.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d039fb329cd0d1b4b90abbd27c8e29920442abc --- /dev/null +++ b/tools/ui/node_modules/khroma/src/utils/unit.ts @@ -0,0 +1,20 @@ + +/* MAIN */ + +const Unit = { + + /* API */ + + dec2hex: ( dec: number ): string => { + + const hex = Math.round ( dec ).toString ( 16 ); + + return hex.length > 1 ? hex : `0${hex}`; + + } + +}; + +/* EXPORT */ + +export default Unit; diff --git a/tools/ui/node_modules/khroma/tasks/benchmark.js b/tools/ui/node_modules/khroma/tasks/benchmark.js new file mode 100644 index 0000000000000000000000000000000000000000..3e16f12bf5f3d2efd30d1f805194b9222d6477af --- /dev/null +++ b/tools/ui/node_modules/khroma/tasks/benchmark.js @@ -0,0 +1,421 @@ + +/* IMPORT */ + +import benchmark from 'benchloop'; +import Color from '../dist/color/index.js'; +import {hex, rgb, rgba, hsl, hsla, channel, red, green, blue, alpha, hue, saturation, lightness, darken, lighten, opacify, transparentize, saturate, desaturate, grayscale, invert, complement, scale, adjust, change, mix, contrast, luminance, isDark, isLight, isTransparent, toKeyword, toHex, toRgba, toHsla} from '../dist/index.js'; + +/* MAIN */ + +benchmark.config ({ + iterations: 10_000 +}); + +benchmark.group ( 'parse', () => { + + benchmark ({ + name: 'keyword', + fn: () => { + Color.parse ( 'blue' ); + } + }); + + benchmark.group ( 'hex', () => { + + benchmark ({ + name: 'rgb', + fn: () => { + Color.parse ( '#fc0' ); + } + }); + + benchmark ({ + name: 'rgba', + fn: () => { + Color.parse ( '#fc08' ); + } + }); + + benchmark ({ + name: 'rrggbb', + fn: () => { + Color.parse ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'rrggbbaa', + fn: () => { + Color.parse ( '#ffcc0088' ); + } + }); + + }); + + benchmark.group ( 'rgb', () => { + + benchmark ({ + name: 'rgb', + fn: () => { + Color.parse ( 'rgb(255, 204, 0)' ); + } + }); + + benchmark ({ + name: 'rgba', + fn: () => { + Color.parse ( 'rgb(255, 204, 0, .5)' ); + } + }); + + benchmark ({ + name: 'rgba:percentage', + fn: () => { + Color.parse ( 'rgb(100%, 80%, 0%, .5)' ); + } + }); + + benchmark ({ + name: 'rgba:scientific', + fn: () => { + Color.parse ( 'rgba(1e2, .5e1, .5e0, +.25e2%)' ); + } + }); + + }); + + benchmark.group ( 'hsl', () => { + + benchmark ({ + name: 'hsl', + fn: () => { + Color.parse ( 'hsl(150, 50%, 50%)' ); + } + }); + + benchmark ({ + name: 'hsla', + fn: () => { + Color.parse ( 'hsla(150, 50%, 50%, .5)' ); + } + }); + + benchmark ({ + name: 'hsla:deg', + fn: () => { + Color.parse ( 'hsla(0deg, 50%, 50%, .5)' ); + } + }); + + benchmark ({ + name: 'hsla:scientific', + fn: () => { + Color.parse ( 'hsla(1e2, 2e1%, .5e2%, +.25e2%)' ); + } + }); + + benchmark ({ + name: 'hsla:grad', + fn: () => { + Color.parse ( 'hsla(0grad, 50%, 50%, .5)' ); + } + }); + + benchmark ({ + name: 'hsla:rad', + fn: () => { + Color.parse ( 'hsla(3.14rad, 50%, 50%, .5)' ); + } + }); + + + benchmark ({ + name: 'hsla:turn', + fn: () => { + Color.parse ( 'hsla(1turn, 50%, 50%, .5)' ); + } + }); + + }); + +}); + +benchmark.group ( 'stringify', () => { + + const channels = Color.parse ( '#ff00ff' ); + + benchmark ({ + name: 'keyword', + fn: () => { + toKeyword ( channels ); + } + }); + + benchmark ({ + name: 'hex', + fn: () => { + toHex ( channels ); + } + }); + + benchmark ({ + name: 'rgba', + fn: () => { + toRgba ( channels ); + } + }); + + benchmark ({ + name: 'hsla', + fn: () => { + toHsla ( channels ); + } + }); + +}); + +benchmark.group ( 'create', () => { + + benchmark ({ + name: 'hex', + fn: () => { + hex ( 255, 204, 0 ); + } + }); + + benchmark ({ + name: 'rgb', + fn: () => { + rgb ( 255, 204, 0 ); + } + }); + + benchmark ({ + name: 'rgba', + fn: () => { + rgba ( 255, 204, 0, 136 ); + } + }); + + benchmark ({ + name: 'hsl', + fn: () => { + hsl ( 150, 50, 50 ); + } + }); + + benchmark ({ + name: 'hsla', + fn: () => { + hsla ( 150, 50, 50, .5 ); + } + }); + +}); + +benchmark.group ( 'get.channel', () => { + + benchmark ({ + name: 'channel', + fn: () => { + channel ( '#ffcc00', 'r' ); + } + }); + + benchmark ({ + name: 'red', + fn: () => { + red ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'green', + fn: () => { + green ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'blue', + fn: () => { + blue ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'hue', + fn: () => { + hue ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'saturation', + fn: () => { + saturation ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'lightness', + fn: () => { + lightness ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'alpha', + fn: () => { + alpha ( '#ffcc00' ); + } + }); + +}); + +benchmark.group ( 'get.more', () => { + + benchmark ({ + name: 'contrast', + fn: () => { + contrast ( '#000000', '#ffffff' ); + } + }); + + benchmark ({ + name: 'luminance', + fn: () => { + luminance ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'isDark', + fn: () => { + isDark ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'isLight', + fn: () => { + isLight ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'isTransparent', + fn: () => { + isTransparent ( '#ffcc00' ); + } + }); + +}); + +benchmark.group ( 'edit.channel', () => { + + benchmark ({ + name: 'saturate', + fn: () => { + saturate ( '#ffcc00', 50 ); + } + }); + + benchmark ({ + name: 'desaturate', + fn: () => { + desaturate ( '#ffcc00', 50 ); + } + }); + + benchmark ({ + name: 'lighten', + fn: () => { + lighten ( '#ffcc00', 50 ); + } + }); + + benchmark ({ + name: 'darken', + fn: () => { + darken ( '#ffcc00', 50 ); + } + }); + + benchmark ({ + name: 'opacify', + fn: () => { + opacify ( '#ffcc00', .5 ); + } + }); + + benchmark ({ + name: 'transparentize', + fn: () => { + transparentize ( '#ffcc00', .5 ); + } + }); + + benchmark ({ + name: 'rgba', + fn: () => { + rgba ( '#ffcc00', .5 ); + } + }); + + benchmark ({ + name: 'complement', + fn: () => { + complement ( '#ffcc00' ); + } + }); + + benchmark ({ + name: 'grayscale', + fn: () => { + grayscale ( '#ffcc00' ); + } + }); + +}); + +benchmark.group ( 'edit.more', () => { + + benchmark ({ + name: 'adjust', + fn: () => { + adjust ( '#ffcc00', { a: -.5 } ); + } + }); + + benchmark ({ + name: 'change', + fn: () => { + change ( '#ffcc00', { a: .5 } ); + } + }); + + benchmark ({ + name: 'invert', + fn: () => { + invert ( '#ffcc00', 50 ); + } + }); + + benchmark ({ + name: 'mix', + fn: () => { + mix ( '#ffcc00', '#000000', 50 ); + } + }); + + benchmark ({ + name: 'scale', + fn: () => { + scale ( '#ffcc00', { r: 50, g: 50, b: 50 } ); + } + }); + +}); + +benchmark.summary (); diff --git a/tools/ui/node_modules/khroma/test/color/hex.js b/tools/ui/node_modules/khroma/test/color/hex.js new file mode 100644 index 0000000000000000000000000000000000000000..c9d1e33864ced3ec6d14e89f1ad7986ca76daa47 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/color/hex.js @@ -0,0 +1,66 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import Color from '../../dist/color/index.js'; + +/* MAIN */ + +describe ( 'Hex', it => { + + it ( 'parses hex colors', t => { + + const tests = [ + /* RGB */ + ['#000', '#000000'], + ['#fff', '#ffffff'], + ['#a2b', '#aa22bb'], + ['#a2B', '#aa22bb'], + /* RGBA */ + ['#0000', '#00000000'], + ['#fffF', '#ffffff'], + ['#fff8', '#ffffff88'], + ['#a2bf', '#aa22bb'], + ['#a2Bf', '#aa22bb'], + /* RRGGBB */ + ['#000000', '#000000'], + ['#FFFFFF', '#ffffff'], + ['#ffffff', '#ffffff'], + ['#ae12b4', '#ae12b4'], + ['#Ae12B4', '#ae12b4'], + /* RRGGBBAA */ + ['#000000ff', '#000000'], + ['#00000000', '#00000000'], + ['#ffffffa8', '#ffffffa8'], + ['#ffffffA8', '#ffffffa8'] + ]; + + tests.forEach ( ([ input, output ]) => { + t.is ( Color.format.hex.stringify ( Color.parse ( input ) ), output ); + }); + + }); + + it ( 'throws with unsupported colors', t => { + + const colors = [ + '#', + '#0', + '#00', + '#ggg', + '#zzz', + 'fff', + '#0 0 0', + '# 000', + '#aabbc', + '#aabbccd', + '#aabbccdde' + ]; + + colors.forEach ( color => { + t.throws ( () => Color.parse ( color ), /unsupported/i ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/color/hsl.js b/tools/ui/node_modules/khroma/test/color/hsl.js new file mode 100644 index 0000000000000000000000000000000000000000..5120540ea8a55458981b3c0ef4464bbc49cfa599 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/color/hsl.js @@ -0,0 +1,106 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import Color from '../../dist/color/index.js'; + +/* MAIN */ + +describe ( 'HSL', it => { + + it ( 'parses HSL colors', t => { + + const tests = [ + /* NO UNIT HUE */ + ['hsl(0, 0%, 0%)', 'hsl(0, 0%, 0%)'], + ['hsl(0, 100%, 0%)', 'hsl(0, 100%, 0%)'], + ['hsl(0, 0%, 100%)', 'hsl(0, 0%, 100%)'], + ['hsl(0, 100%, 100%)', 'hsl(0, 100%, 100%)'], + ['hsl(180, 50%, 50%)', 'hsl(180, 50%, 50%)'], + ['hsl(180, 40.4%, 70.4%)', 'hsl(180, 40.4%, 70.4%)'], + /* S & L CLAMPING - H WRAPPING */ + ['hsl(-180, 40.4%, 70.4%)', 'hsl(-180, 40.4%, 70.4%)'], + ['hsl(180, -40.4%, -70.4%)', 'hsl(180, 0%, 0%)'], + ['hsl(180, 400.4%, 700.4%)', 'hsl(180, 100%, 100%)'], + ['hsl(540, 100%, 50%)', 'hsl(180, 100%, 50%)'], + /* DEGREES */ + ['hsl(-180deg, 50%, 50%)', 'hsl(-180, 50%, 50%)'], + ['hsl(0deg, 50%, 50%)', 'hsl(0, 50%, 50%)'], + ['hsl(180deg, 50%, 50%)', 'hsl(180, 50%, 50%)'], + ['hsl(360deg, 50%, 50%)', 'hsl(0, 50%, 50%)'], + ['hsl(540deg, 50%, 50%)', 'hsl(180, 50%, 50%)'], + /* GRADIANS */ + ['hsl(0grad, 50%, 50%)', 'hsl(0, 50%, 50%)'], + ['hsl(200grad, 50%, 50%)', 'hsl(180, 50%, 50%)'], + ['hsl(400grad, 50%, 50%)', 'hsl(0, 50%, 50%)'], + /* RADIANS */ + ['hsl(0rad, 50%, 50%)', 'hsl(0, 50%, 50%)'], + ['hsl(3.14159265359rad, 50%, 50%)', 'hsl(180, 50%, 50%)'], + /* TURNS */ + ['hsl(0turn, 50%, 50%)', 'hsl(0, 50%, 50%)'], + ['hsl(0.5turn, 50%, 50%)', 'hsl(180, 50%, 50%)'], + ['hsl(1turn, 50%, 50%)', 'hsl(0, 50%, 50%)'], + /* SCIENTIFIC NOTATION */ + ['hsl(1.8e2, 4.04e1%, .704e2%)', 'hsl(180, 40.4%, 70.4%)'], + ['hsl(1.8e2deg, 4.04e1%, .704e2%)', 'hsl(180, 40.4%, 70.4%)'], + ['hsl(1800e-1deg, 404e-1%, 7040e-2%)', 'hsl(180, 40.4%, 70.4%)'], + /* WITH COMMAS AND WEIRD SPACES */ + ['hsl( 0 , 0% , 0% )', 'hsl(0, 0%, 0%)'], + ['hsl(0,0%,0%)', 'hsl(0, 0%, 0%)'], + /* WITHOUT COMMAS */ + ['hsl(0 0% 0%)', 'hsl(0, 0%, 0%)'], + ['hsl( 0 0% 0% )', 'hsl(0, 0%, 0%)'], + ['hsl(180deg 50% 50%)', 'hsl(180, 50%, 50%)'], + ['hsl(180 40.4% 70.4%)', 'hsl(180, 40.4%, 70.4%)'], + /* WEIRD CASING */ + ['HSL(0 0% 0%)', 'hsl(0, 0%, 0%)'], + ['hSl(0 0% 0%)', 'hsl(0, 0%, 0%)'] + ]; + + tests.forEach ( ([ input, output ]) => { + t.is ( Color.format.hsl.stringify ( Color.parse ( input ) ), output ); + }); + + }); + + it ( 'throws with unsupported colors', t => { + + const colors = [ + 'hsl', + 'hsl()', + 'hsl(0, 0)', + 'hsl(0, 1, dog)', + 'hsl(0de, 0, 0)', + 'hsl(0gra, 0, 0)', + 'hsl(1, 2, 3, 4, 5)', + 'hsl(1/2/3)', + 'hsl(1,, 20, 255)', + 'hsl(1%,, 20%, 255%)', + 'hsl(1%, 255%)', + 'hsl(1%, 10%%, 255%)', + 'hsl(1%, %10%, 255%)', + 'hsl(1)', + 'hsl(1, 20, 255', + 'hsl 1, 20, 255', + 'hsl 1, 20, 255)', + 'hsl(1, a, 255)', + 'hsl (1, 2, 255)', + 'hsl(1,2,3..5)', + 'hsl(1, 2, 3.4.5)', + 'hslQ(1, 2, 255)', + 'h s l(1, 2, 255)', + 'hsl(0, 0, 0)', + 'hsl(0, 100, 0)', + 'hsl(0, 0, 100)', + 'hsl(0, 100, 100)', + 'hsl(180, 50, 50)', + 'hsl(180, 40.4, 70.4)' + ]; + + colors.forEach ( color => { + t.throws ( () => Color.parse ( color ), /unsupported/i ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/color/hsla.js b/tools/ui/node_modules/khroma/test/color/hsla.js new file mode 100644 index 0000000000000000000000000000000000000000..9ed94a7bce0fec52285d39ebc921583d1cfa4930 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/color/hsla.js @@ -0,0 +1,85 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import Color from '../../dist/color/index.js'; + +/* MAIN */ + +describe ( 'HSLA', it => { + + it ( 'parses HSLA colors', t => { + + const tests = [ + /* NO UNIT HUE */ + ['hsla(0, 0%, 0%, 0)', 'hsla(0, 0%, 0%, 0)'], + ['hsla(0, 0%, 0%)', 'hsl(0, 0%, 0%)'], + ['hsla(0, 0%, 0%, 10)', 'hsl(0, 0%, 0%)'], + ['hsla(0, 0%, 0%, -10)', 'hsla(0, 0%, 0%, 0)'], + ['hsla(0, 0%, 0%, 0.5)', 'hsla(0, 0%, 0%, 0.5)'], + ['hsla(0, 0%, 0%, .5)', 'hsla(0, 0%, 0%, 0.5)'], + ['hsla(0, 0%, 0%, 0.5 )', 'hsla(0, 0%, 0%, 0.5)'], + /* PERCENTAGE 0~100 */ + ['hsla(0, 0%, 0%, 0%)', 'hsla(0, 0%, 0%, 0)'], + ['hsla(0, 0%, 0%, 100%)', 'hsl(0, 0%, 0%)'], + ['hsla(0, 0%, 0%, 110%)', 'hsl(0, 0%, 0%)'], + ['hsla(0, 0%, 0%, -110%)', 'hsla(0, 0%, 0%, 0)'], + ['hsla(0, 0%, 0%, 50%)', 'hsla(0, 0%, 0%, 0.5)'], + ['hsla(0, 0%, 0%, 50.5%)', 'hsla(0, 0%, 0%, 0.505)'], + /* WITH COMMAS AND WEIRD SPACES */ + ['hsla( 1 , 20% , 50%, 0.5 )', 'hsla(1, 20%, 50%, 0.5)'], + ['hsla(1,20%,50%,50%)', 'hsla(1, 20%, 50%, 0.5)'], + ['hsla( 1,20%,50%,0.5 )', 'hsla(1, 20%, 50%, 0.5)'], + /* WITH SLASH */ + ['hsla(0 0% 0% / 0.4)', 'hsla(0, 0%, 0%, 0.4)'], + ['hsla(0 0% 0%/0.4)', 'hsla(0, 0%, 0%, 0.4)'], + ['hsla(0 0% 0% / 40%)', 'hsla(0, 0%, 0%, 0.4)'], + ['hsla(0, 0%, 0% / 40%)', 'hsla(0, 0%, 0%, 0.4)'], + ['hsla(0,0%,0%/40%)', 'hsla(0, 0%, 0%, 0.4)'], + /* SCIENTIFIC NOTATION */ + ['hsla(1e2, 2e1%, .5e2%, +.25e2%)', 'hsla(100, 20%, 50%, 0.25)'], + ['hsla(1e2, 2e1%, .5e2%, +.25e1%)', 'hsla(100, 20%, 50%, 0.025)'], + ['hsla(1e2, 2e1%, .5e2%, +.25e0%)', 'hsla(100, 20%, 50%, 0.0025)'], + ['hsla(1e2, 2e1%, .5e2%, .25e0)', 'hsla(100, 20%, 50%, 0.25)'], + ['hsla(1e2, 2e1%, .5e2%, .25e1)', 'hsl(100, 20%, 50%)'], + ['hsla(1e2, 2e1%, .5e2%, 25e-2)', 'hsla(100, 20%, 50%, 0.25)'], + /* MIXED UNITS */ + ['hsla(1, 20%, .5e2%, +.25e2%)', 'hsla(1, 20%, 50%, 0.25)'], + /* WEIRD CASING */ + ['HSLA(1, 20%, 50%, 0.5)', 'hsla(1, 20%, 50%, 0.5)'], + ['hSlA(1, 20%, 50%, 0.5)', 'hsla(1, 20%, 50%, 0.5)'] + ]; + + tests.forEach ( ([ input, output ]) => { + t.is ( Color.format.hsla.stringify ( Color.parse ( input ) ), output ); + }); + + }); + + it ( 'throws with unsupported colors', t => { + + const colors = [ + 'hsla()', + 'hsla(51 170 51 0.4)', + 'hsla(1, 2, 3, 4, 5)', + 'hsla(0, 0, 0, 0..5)', + 'hsla(0, 0, 0, 0.5.)', + 'hsla(0, 0, 0, 0%%)', + 'hsla(51 170 51 // 0.4)', + 'hsla(1ee2, .5e1, .5e0, +.25e2%)', + 'hsla(1f2, .5e1, .5e0, +.25e2%)', + 'hsla(0, 0, 0, 0)', + 'hsla(0, 100, 0, 0)', + 'hsla(0, 0, 100, 0)', + 'hsla(0, 100, 100, 0)', + 'hsla(180, 50, 50, 0)', + 'hsla(180, 40.4, 70.4, 0)' + ]; + + colors.forEach ( color => { + t.throws ( () => Color.parse ( color ), /unsupported/i ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/color/keyword.js b/tools/ui/node_modules/khroma/test/color/keyword.js new file mode 100644 index 0000000000000000000000000000000000000000..1c960471826b5faff5a78f51d52f00c317874889 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/color/keyword.js @@ -0,0 +1,38 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import Color from '../../dist/color/index.js'; + +/* MAIN */ + +describe ( 'Keyword', it => { + + it ( 'parses keywords colors', t => { + + const tests = [ + ['black', '#000000'], + ['BLACK', '#000000'], + ['tranSpaRent', '#00000000'] + ]; + + tests.forEach ( ([ input, output ]) => { + t.is ( Color.format.hex.stringify ( Color.parse ( input ) ), output ); + }); + + }); + + it ( 'throws with unsupported colors', t => { + + const colors = [ + 'foo', + 'bar' + ]; + + colors.forEach ( color => { + t.throws ( () => Color.parse ( color ), /unsupported/i ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/color/rgb.js b/tools/ui/node_modules/khroma/test/color/rgb.js new file mode 100644 index 0000000000000000000000000000000000000000..d17618ef2c06571f546adce3d7852ff39a890cb5 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/color/rgb.js @@ -0,0 +1,73 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import Color from '../../dist/color/index.js'; + +/* MAIN */ + +describe ( 'RGB', it => { + + it ( 'parses RGB colors', t => { + + const tests = [ + /* DECIAML 0~255 */ + ['rgb(1, 20, 255)', 'rgb(1, 20, 255)'], + ['rgb(1.99, 20.5, 255)', 'rgb(1.99, 20.5, 255)'], + ['rgb(300, 255, -100)', 'rgb(255, 255, 0)'], + /* PERCENTAGE 0~100 */ + ['rgb(10%, 20%, 30%)', 'rgb(25.5, 51, 76.5)'], + ['rgb(10.5%, 20.7%, 30%)', 'rgb(26.775, 52.785, 76.5)'], + ['rgb(100% 200% -30%)', 'rgb(255, 255, 0)'], + /* WITH COMMAS AND WEIRD SPACES */ + ['rgb( 1 , 20 , 255 )', 'rgb(1, 20, 255)'], + ['rgb(1,20,255)', 'rgb(1, 20, 255)'], + ['rgb( 1,20,255 )', 'rgb(1, 20, 255)'], + /* WITHOUT COMMAS */ + ['rgb(10% 20% 30%)', 'rgb(25.5, 51, 76.5)'], + ['rgb(1 20 255)', 'rgb(1, 20, 255)'], + ['rgb( 1 20 255 )', 'rgb(1, 20, 255)'], + /* MIXED UNITS */ + ['rgb(10% 20 30%)', 'rgb(25.5, 20, 76.5)'], + ['rgb(1 25.5 25.5)', 'rgb(1, 25.5, 25.5)'], + /* WEIRD CASING */ + ['RGB(1, 20, 255)', 'rgb(1, 20, 255)'], + ['rGb(1, 20, 255)', 'rgb(1, 20, 255)'] + ]; + + tests.forEach ( ([ input, output ]) => { + t.is ( Color.format.rgb.stringify ( Color.parse ( input ) ), output ); + }); + + }); + + it ( 'throws with unsupported colors', t => { + + const colors = [ + 'rgb()', + 'rgb(1, 2, 3, 4, 5)', + 'rgb(1/2/3)', + 'rgb(1,, 20, 255)', + 'rgb(1%,, 20%, 255%)', + 'rgb(1%, 255%)', + 'rgb(1%, 10%%, 255%)', + 'rgb(1%, %10%, 255%)', + 'rgb(1)', + 'rgb(1, 20, 255', + 'rgb 1, 20, 255', + 'rgb 1, 20, 255)', + 'rgb(1, a, 255)', + 'rgb (1, 2, 255)', + 'rgb(1,2,3..5)', + 'rgb(1, 2, 3.4.5)', + 'rgbQ(1, 2, 255)', + 'r g b(1, 2, 255)' + ]; + + colors.forEach ( color => { + t.throws ( () => Color.parse ( color ), /unsupported/i ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/color/rgba.js b/tools/ui/node_modules/khroma/test/color/rgba.js new file mode 100644 index 0000000000000000000000000000000000000000..7c255b2cee86d2d624089117de940ae82f17a38b --- /dev/null +++ b/tools/ui/node_modules/khroma/test/color/rgba.js @@ -0,0 +1,78 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import Color from '../../dist/color/index.js'; + +/* MAIN */ + +describe ( 'RGBA', it => { + + it ( 'parses RGBA colors', t => { + + const tests = [ + /* FRACTION 0~1 */ + ['rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 0)'], + ['rgba(0, 0, 0)', 'rgb(0, 0, 0)'], + ['rgba(0, 0, 0, 10)', 'rgb(0, 0, 0)'], + ['rgba(0, 0, 0, -10)', 'rgba(0, 0, 0, 0)'], + ['rgba(0, 0, 0, 0.5)', 'rgba(0, 0, 0, 0.5)'], + ['rgba(0, 0, 0, .5)', 'rgba(0, 0, 0, 0.5)'], + ['rgba(0, 0, 0, 0.5 )', 'rgba(0, 0, 0, 0.5)'], + /* PERCENTAGE 0~100 */ + ['rgba(0, 0, 0, 0%)', 'rgba(0, 0, 0, 0)'], + ['rgba(0, 0, 0, 100%)', 'rgb(0, 0, 0)'], + ['rgba(0, 0, 0, 110%)', 'rgb(0, 0, 0)'], + ['rgba(0, 0, 0, -110%)', 'rgba(0, 0, 0, 0)'], + ['rgba(0, 0, 0, 50%)', 'rgba(0, 0, 0, 0.5)'], + ['rgba(0, 0, 0, 50.5%)', 'rgba(0, 0, 0, 0.505)'], + /* WITH COMMAS AND WEIRD SPACES */ + ['rgba( 1 , 20 , 255, 0.5 )', 'rgba(1, 20, 255, 0.5)'], + ['rgba(1,20,255,50%)', 'rgba(1, 20, 255, 0.5)'], + ['rgba( 1,20,255,0.5 )', 'rgba(1, 20, 255, 0.5)'], + /* WITH SLASH */ + ['rgba(51 170 51 / 0.4)', 'rgba(51, 170, 51, 0.4)'], + ['rgba(51 170 51/0.4)', 'rgba(51, 170, 51, 0.4)'], + ['rgba(51 170 51 / 40%)', 'rgba(51, 170, 51, 0.4)'], + ['rgba(51, 170, 51 / 40%)', 'rgba(51, 170, 51, 0.4)'], + ['rgba(51,170,51/40%)', 'rgba(51, 170, 51, 0.4)'], + /* SCIENTIFIC NOTATION */ + ['rgba(1e2, .5e1, .5e0, +.25e2%)', 'rgba(100, 5, 0.5, 0.25)'], + ['rgba(1e2, .5e1, .5e0, +.25e1%)', 'rgba(100, 5, 0.5, 0.025)'], + ['rgba(1e2, .5e1, .5e0, +.25e0%)', 'rgba(100, 5, 0.5, 0.0025)'], + ['rgba(1e2, .5e1, .5e0, .25e0)', 'rgba(100, 5, 0.5, 0.25)'], + ['rgba(1e2, .5e1, .5e0, .25e1)', 'rgb(100, 5, 0.5)'], + /* MIXED UNITS */ + ['rgba(1, 10%, .5e0, +.25e2%)', 'rgba(1, 25.5, 0.5, 0.25)'], + /* WEIRD CASING */ + ['RGBA(1, 20, 255, 0.5)', 'rgba(1, 20, 255, 0.5)'], + ['rgbA(1, 20, 255, 0.5)', 'rgba(1, 20, 255, 0.5)'] + ]; + + tests.forEach ( ([ input, output ]) => { + t.is ( Color.format.rgba.stringify ( Color.parse ( input ) ), output ); + }); + + }); + + it ( 'throws with unsupported colors', t => { + + const colors = [ + 'rgba()', + 'rgba(51 170 51 0.4)', + 'rgba(1, 2, 3, 4, 5)', + 'rgba(0, 0, 0, 0..5)', + 'rgba(0, 0, 0, 0.5.)', + 'rgba(0, 0, 0, 0%%)', + 'rgba(51 170 51 // 0.4)', + 'rgba(1ee2, .5e1, .5e0, +.25e2%)', + 'rgba(1f2, .5e1, .5e0, +.25e2%)' + ]; + + colors.forEach ( color => { + t.throws ( () => Color.parse ( color ), /unsupported/i ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/adjust.js b/tools/ui/node_modules/khroma/test/methods/adjust.js new file mode 100644 index 0000000000000000000000000000000000000000..023e0c734ebd00deab2481e7582ca1be123b3517 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/adjust.js @@ -0,0 +1,89 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {adjust} from '../../dist/index.js'; +import Color from '../../dist/color/index.js'; + +/* MAIN */ + +describe ( 'adjust', it => { + + it ( 'increases or decreases the value of any RGB channel of the color', t => { + + const tests = [ + [['rgb(0, 0, 0)', { r: 100 }], 'rgb(100, 0, 0)'], + [['rgb(0, 0, 0)', { g: 100 }], 'rgb(0, 100, 0)'], + [['rgb(0, 0, 0)', { b: 100 }], 'rgb(0, 0, 100)'], + [['rgb(0, 0, 0)', { r: 100, g: 100 }], 'rgb(100, 100, 0)'], + [['rgb(0, 0, 0)', { r: 100, g: 100, b: 100 }], 'rgb(100, 100, 100)'], + [['rgb(255, 255, 255)', { r: -100 }], 'rgb(155, 255, 255)'], + [['rgb(255, 255, 255)', { g: -100 }], 'rgb(255, 155, 255)'], + [['rgb(255, 255, 255)', { b: -100 }], 'rgb(255, 255, 155)'], + [['rgb(200, 0, 0)', { r: 100 }], 'rgb(255, 0, 0)'], + [['rgb(100, 0, 0)', { r: -200 }], 'rgb(0, 0, 0)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( Color.format.rgb.stringify ( Color.parse ( adjust ( ...args ) ) ), output ); + }); + + }); + + it ( 'increases or decreases the value of any HSL channel of the color', t => { + + const tests = [ + [['hsl(0, 50%, 50%)', { h: 100 }], 'hsl(100, 50%, 50%)'], + [['hsl(0, 50%, 50%)', { s: 25 }], 'hsl(0, 75%, 50%)'], + [['hsl(0, 50%, 50%)', { l: 25 }], 'hsl(0, 50%, 75%)'], + [['hsl(0, 50%, 50%)', { h: 100, s: 25 }], 'hsl(100, 75%, 50%)'], + [['hsl(0, 50%, 50%)', { h: 100, s: 25, l: 25 }], 'hsl(100, 75%, 75%)'], + [['hsl(100, 50%, 50%)', { h: -100 }], 'hsl(0, 50%, 50%)'], + [['hsl(0, 50%, 50%)', { s: -25 }], 'hsl(0, 25%, 50%)'], + [['hsl(0, 50%, 50%)', { l: -25 }], 'hsl(0, 50%, 25%)'], + [['hsl(300, 50%, 50%)', { h: 100 }], 'hsl(40, 50%, 50%)'], + [['hsl(0, 50%, 50%)', { h: -100 }], 'hsl(-100, 50%, 50%)'], + [['hsl(0, 100%, 50%)', { s: 25 }], 'hsl(0, 100%, 50%)'], + [['hsl(0, 0%, 50%)', { s: -25 }], 'hsl(0, 0%, 50%)'], + [['hsla(0, 0%, 50%, .5)', { s: -25 }], 'hsla(0, 0%, 50%, 0.5)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( Color.format.hsl.stringify ( Color.parse ( adjust ( ...args ) ) ), output ); + }); + + }); + + it ( 'increases or decreases the value of the alpha channel of the color', t => { + + const tests = [ + [['rgba(0, 0, 0, 0)', { a: 0.5 }], 'rgba(0, 0, 0, 0.5)'], + [['hsla(0, 0%, 0%, 0)', { a: 0.5 }], 'hsla(0, 0%, 0%, 0.5)'], + [['rgba(0, 0, 0, 0)', { a: 1 }], '#000000'], + [['rgba(0, 0, 0, 1)', { a: -0.5 }], 'rgba(0, 0, 0, 0.5)'], + [['rgba(0, 0, 0, 1)', { a: -1 }], 'rgba(0, 0, 0, 0)'], + [['rgba(0, 0, 0, 0.5)', { a: 1 }], '#000000'], + [['rgba(0, 0, 0, 0.5)', { a: -1 }], 'rgba(0, 0, 0, 0)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( adjust ( ...args ), output ); + }); + + }); + + it ( 'throws when setting RGB and HSL channels at the same time', t => { + + const tests = [ + ['#000', { r: 10, h: 10 }], + ['#000', { g: 10, l: 10 }], + ['#000', { b: 10, s: 10 }] + ]; + + tests.forEach ( args => { + t.throws ( () => adjust ( ...args ), /cannot.*at the same time/i ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/alpha.js b/tools/ui/node_modules/khroma/test/methods/alpha.js new file mode 100644 index 0000000000000000000000000000000000000000..6ddd438602f29c560dbaa92cfba84b966447b9bd --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/alpha.js @@ -0,0 +1,26 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {alpha} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'alpha', it => { + + it ( 'gets the alpha channel of the color', t => { + + const tests = [ + ['rgba(10, 20, 30)', 1], + ['rgba(10, 20, 30, 0.1)', 0.1], + ['#10203040', 0.2509803922], + ['hsla(10, 20%, 30%, 0.5)', 0.5] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( alpha ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/blue.js b/tools/ui/node_modules/khroma/test/methods/blue.js new file mode 100644 index 0000000000000000000000000000000000000000..1d526feaa5a029606aac33b504e4c6ac20ec7af1 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/blue.js @@ -0,0 +1,25 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {blue} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'blue', it => { + + it ( 'gets the blue channel of the color', t => { + + const tests = [ + ['rgb(10, 20, 30)', 30], + ['#102030', 48], + ['hsl(10, 20%, 30%)', 61.2] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( blue ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/change.js b/tools/ui/node_modules/khroma/test/methods/change.js new file mode 100644 index 0000000000000000000000000000000000000000..ce7db7bb26a1fef8487b939e257a36d8840182ca --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/change.js @@ -0,0 +1,82 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {change} from '../../dist/index.js'; +import Color from '../../dist/color/index.js'; + +/* MAIN */ + +describe ( 'change', it => { + + it ( 'sets a new value for any RGBA channel of the color', t => { + + const tests = [ + [['rgb(100, 100, 100)', { r: 0 }], 'rgb(0, 100, 100)'], + [['rgb(100, 100, 100)', { r: 255 }], 'rgb(255, 100, 100)'], + [['rgb(100, 100, 100)', { r: 100 }], 'rgb(100, 100, 100)'], + [['rgb(100, 100, 100)', { g: 0 }], 'rgb(100, 0, 100)'], + [['rgb(100, 100, 100)', { b: 0 }], 'rgb(100, 100, 0)'], + [['rgb(100, 100, 100)', { r: 50, g: 150 }], 'rgb(50, 150, 100)'], + [['rgb(100, 100, 100)', { r: 50, g: 150, b: 200 }], 'rgb(50, 150, 200)'], + [['rgb(100, 100, 100)', { r: 50, g: 150, b: 200, a: 0.5 }], 'rgba(50, 150, 200, 0.5)'], + [['rgb(100, 100, 100)', { r: 0, g: 0, b: 0, a: 0 }], 'rgba(0, 0, 0, 0)'], + [['rgba(100, 100, 100, .5)', { g: 0 }], 'rgba(100, 0, 100, 0.5)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( Color.format.rgb.stringify ( Color.parse ( change ( ...args ) ) ), output ); + }); + + }); + + it ( 'sets a new value for any HSLA channel of the color', t => { + + const tests = [ + [['hsl(50, 50%, 50%)', { h: 100 }], 'hsl(100, 50%, 50%)'], + [['hsl(50, 50%, 50%)', { h: 400 }], 'hsl(40, 50%, 50%)'], + [['hsl(50, 50%, 50%)', { h: 0 }], 'hsl(0, 50%, 50%)'], + [['hsl(50, 50%, 50%)', { s: 25 }], 'hsl(50, 25%, 50%)'], + [['hsl(50, 50%, 50%)', { l: 25 }], 'hsl(50, 50%, 25%)'], + [['hsl(50, 50%, 50%)', { h: 100, s: 75 }], 'hsl(100, 75%, 50%)'], + [['hsl(50, 50%, 50%)', { h: 100, s: 75, l: 25 }], 'hsl(100, 75%, 25%)'], + [['hsl(50, 50%, 50%)', { h: 100, s: 75, l: 25, a: 0.5 }], 'hsla(100, 75%, 25%, 0.5)'], + [['hsl(50, 50%, 50%)', { h: 0, s: 0, l: 0, a: 0 }], 'hsla(0, 0%, 0%, 0)'], + [['hsla(50, 50%, 50%, 0.5)', { h: 360, s: 100, l: 100, a: 1 }], 'hsl(0, 100%, 100%)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( Color.format.hsl.stringify ( Color.parse ( change ( ...args ) ) ), output ); + }); + + }); + + it ( 'sets a new value for the alpha channel of the color', t => { + + const tests = [ + [['rgba(0, 0, 0, 0)', { a: 0.5 }], 'rgba(0, 0, 0, 0.5)'], + [['hsla(0, 0%, 0%, 0.25)', { a: 0.5 }], 'hsla(0, 0%, 0%, 0.5)'], + [['rgba(0, 0, 0, 1)', { a: 1 }], '#000000'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( change ( ...args ), output ); + }); + + }); + + it ( 'throws when setting RGB and HSL channels at the same time', t => { + + const tests = [ + ['#000', { r: 0, h: 0 }], + ['#000', { g: 0, l: 0 }], + ['#000', { b: 0, s: 0 }] + ]; + + tests.forEach ( args => { + t.throws ( () => change ( ...args ), /cannot.*at the same time/i ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/complement.js b/tools/ui/node_modules/khroma/test/methods/complement.js new file mode 100644 index 0000000000000000000000000000000000000000..9e31894ee46b0adcf6a911ab571006427853c25d --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/complement.js @@ -0,0 +1,25 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {complement} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'complement', it => { + + it ( 'gets the complement of the color', t => { + + const tests = [ + ['#6b717f', 'hsl(42, 8.547008547%, 45.8823529412%)'], + ['#d2e1dd', 'hsl(344, 20%, 85.2941176471%)'], + ['#036', 'hsl(30, 100%, 20%)'] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( complement ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/contrast.js b/tools/ui/node_modules/khroma/test/methods/contrast.js new file mode 100644 index 0000000000000000000000000000000000000000..72dcda15030e4305dc45e5d2820f21eff7bce5c2 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/contrast.js @@ -0,0 +1,28 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {contrast} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'contrast', it => { + + it ( 'gets the contrast ratio between two colors', t => { + + const tests = [ + ['#000000', '#000000', 1], + ['#ffffff', '#ffffff', 1], + ['#000000', '#ffffff', 10], + ['#ffffff', '#000000', 10], + ['#888888', '#ffffff', 4.0617165366], + ['#ffffff', '#888888', 4.0617165366] + ]; + + tests.forEach ( ([ color1, color2, output ]) => { + t.is ( contrast ( color1, color2 ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/darken.js b/tools/ui/node_modules/khroma/test/methods/darken.js new file mode 100644 index 0000000000000000000000000000000000000000..add9edb9da1fd4d27e1548786fb91dac90b1ad79 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/darken.js @@ -0,0 +1,27 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {darken} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'darken', it => { + + it ( 'decreases the lightness channel of the color', t => { + + const tests = [ + [['hsl(0, 0%, 100%)', 0], 'hsl(0, 0%, 100%)'], + [['hsl(0, 0%, 100%)', 50], 'hsl(0, 0%, 50%)'], + [['hsl(0, 0%, 100%)', 75], 'hsl(0, 0%, 25%)'], + [['hsl(0, 0%, 100%)', 100], 'hsl(0, 0%, 0%)'], + [['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 0%)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( darken ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/desaturate.js b/tools/ui/node_modules/khroma/test/methods/desaturate.js new file mode 100644 index 0000000000000000000000000000000000000000..3b993930c17615dd1034c4337f6b72edfd5598a0 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/desaturate.js @@ -0,0 +1,28 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {desaturate} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'desaturate', it => { + + it ( 'decreases the saturation channel of the color', t => { + + const tests = [ + [['hsl(0, 100%, 50%)', 0], 'hsl(0, 100%, 50%)'], + [['hsl(0, 100%, 50%)', 50], 'hsl(0, 50%, 50%)'], + [['hsl(0, 100%, 50%)', 75], 'hsl(0, 25%, 50%)'], + [['hsl(0, 100%, 50%)', 100], 'hsl(0, 0%, 50%)'], + [['hsl(0, 50%, 50%)', 100], 'hsl(0, 0%, 50%)'], + [['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 50%)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( desaturate ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/grayscale.js b/tools/ui/node_modules/khroma/test/methods/grayscale.js new file mode 100644 index 0000000000000000000000000000000000000000..40304248df83c5a3009a0e596cae2d8aa69a1b94 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/grayscale.js @@ -0,0 +1,25 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {grayscale} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'grayscale', it => { + + it ( 'gets the grayscale version of the color', t => { + + const tests = [ + ['#6b717f', 'hsl(222, 0%, 45.8823529412%)'], + ['#d2e1dd', 'hsl(164, 0%, 85.2941176471%)'], + ['#036', 'hsl(210, 0%, 20%)'] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( grayscale ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/green.js b/tools/ui/node_modules/khroma/test/methods/green.js new file mode 100644 index 0000000000000000000000000000000000000000..10cf752cf0b63a7df1ac1456db60282af2cac86b --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/green.js @@ -0,0 +1,25 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {green} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'green', it => { + + it ( 'gets the green channel of the color', t => { + + const tests = [ + ['rgb(10, 20, 30)', 20], + ['#102030', 32], + ['hsl(10, 20%, 30%)', 66.3] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( green ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/hex.js b/tools/ui/node_modules/khroma/test/methods/hex.js new file mode 100644 index 0000000000000000000000000000000000000000..988c2130a1af5f05a09da80131e72bc0b99cc1ed --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/hex.js @@ -0,0 +1,41 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {hex} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'hex', it => { + + it ( 'creates a new color given its rgba channels', t => { + + const tests = [ + [[0, 0, 0, 0], 'rgba(0, 0, 0, 0)'], + [[255, 255, 255, 0.5], 'rgba(255, 255, 255, 0.5)'], + [[0, 0, 0, 1], '#000000'], + [[128, 128, 128, 1], '#808080'], + [[-1, -1, -1, -1], 'rgba(0, 0, 0, 0)'], + [[1000, 1000, 1000, 1000], '#ffffff'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( hex ( ...args ), output ); + }); + + }); + + it ( 'allows ommiting the alpha channel', t => { + + const tests = [ + [[0, 0, 0], '#000000'], + [[255, 255, 255], '#ffffff'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( hex ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/hsla.js b/tools/ui/node_modules/khroma/test/methods/hsla.js new file mode 100644 index 0000000000000000000000000000000000000000..e7b395daa6d0dcf5ff17fc9c6e55950509834a85 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/hsla.js @@ -0,0 +1,41 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {hsla} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'hsla', it => { + + it ( 'creates a new color given its hsla channels.', t => { + + const tests = [ + [[0, 0, 0, 0], 'hsla(0, 0%, 0%, 0)'], + [[0, 0, 0, 0.5], 'hsla(0, 0%, 0%, 0.5)'], + [[0, 0, 0, 1], 'hsl(0, 0%, 0%)'], + [[180, 50, 50, 1], 'hsl(180, 50%, 50%)'], + [[-1, -1, -1, -1], 'hsla(-1, 0%, 0%, 0)'], + [[1000, 1000, 1000, 1000], 'hsl(280, 100%, 100%)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( hsla ( ...args ), output ); + }); + + }); + + it ( 'allows ommiting the alpha channel', t => { + + const tests = [ + [[0, 0, 0], 'hsl(0, 0%, 0%)'], + [[180, 50, 50], 'hsl(180, 50%, 50%)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( hsla ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/hue.js b/tools/ui/node_modules/khroma/test/methods/hue.js new file mode 100644 index 0000000000000000000000000000000000000000..80718d00941eb53ab7e82963e34c3b7a042fbd34 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/hue.js @@ -0,0 +1,25 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {hue} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'hue', it => { + + it ( 'gets the hue channel of the color', t => { + + const tests = [ + ['hsl(10, 20%, 30%)', 10], + ['rgb(10, 20, 30)', 210], + ['#102030', 210] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( hue ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/invert.js b/tools/ui/node_modules/khroma/test/methods/invert.js new file mode 100644 index 0000000000000000000000000000000000000000..17714b5ed242e41de45493db5548fc34e21ae90f --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/invert.js @@ -0,0 +1,25 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {invert} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'invert', it => { + + it ( 'gets the inverse of the color', t => { + + const tests = [ + [['#b37399'], '#4c8c66'], + [['black'], '#ffffff'], + [['#550e0c', 20 ], 'rgb(102, 59.4, 58.2)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( invert ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/is_dark.js b/tools/ui/node_modules/khroma/test/methods/is_dark.js new file mode 100644 index 0000000000000000000000000000000000000000..cea101e9b5ab95d6171f22c491945262ffe23e7b --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/is_dark.js @@ -0,0 +1,28 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {isDark} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'isDark', it => { + + it ( 'checks if the provided color is a dark color', t => { + + const tests = [ + ['#000000', true], + ['#8a8a8a', true], + ['#bbbbbb', true], + ['#ffcc00', false], + ['#e0e0e0', false], + ['#ffffff', false] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( isDark ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/is_light.js b/tools/ui/node_modules/khroma/test/methods/is_light.js new file mode 100644 index 0000000000000000000000000000000000000000..34c7266f8d5d041fc7cc1cc63a2d1dfb89f2db70 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/is_light.js @@ -0,0 +1,28 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {isLight} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'isLight', it => { + + it ( 'checks if the provided color is a light color', t => { + + const tests = [ + ['#000000', false], + ['#8a8a8a', false], + ['#bbbbbb', false], + ['#ffcc00', true], + ['#e0e0e0', true], + ['#ffffff', true] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( isLight ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/is_transparent.js b/tools/ui/node_modules/khroma/test/methods/is_transparent.js new file mode 100644 index 0000000000000000000000000000000000000000..8272ebe0d17cc211e3c63dd66ce888ca46c7ae02 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/is_transparent.js @@ -0,0 +1,33 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {isTransparent} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'isTransparent', it => { + + it ( 'checks if the provided color is a transparent color', t => { + + const tests = [ + ['transparent', true], + ['#00000000', true], + ['#ffffff00', true], + ['black', false], + ['#00000001', false], + ['#ffffffff', false], + ['#8a8a8a', false], + ['#bbbbbb', false], + ['#ffcc00', false], + ['#e0e0e0', false], + ['#ffffff', false] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( isTransparent ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/is_valid.js b/tools/ui/node_modules/khroma/test/methods/is_valid.js new file mode 100644 index 0000000000000000000000000000000000000000..8f01a2718f50b32505055f95542914d874a794a4 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/is_valid.js @@ -0,0 +1,28 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {isValid} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'isValid', it => { + + it ( 'checks if the provided color is a valid color', t => { + + const tests = [ + ['black', true], + ['rgb(10, 20, 30)', true], + ['#102030', true], + ['hsl(10, 20%, 30%)', true], + ['#ggg', false], + ['foo', false] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( isValid ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/lighten.js b/tools/ui/node_modules/khroma/test/methods/lighten.js new file mode 100644 index 0000000000000000000000000000000000000000..5d89ff16181a33bc9c423a0fd2fdd71c47acd9e1 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/lighten.js @@ -0,0 +1,28 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {lighten} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'lighten', it => { + + it ( 'increases the lightness channel of the color', t => { + + const tests = [ + [['hsl(0, 0%, 0%)', 0], 'hsl(0, 0%, 0%)'], + [['hsl(0, 0%, 0%)', 50], 'hsl(0, 0%, 50%)'], + [['hsl(0, 0%, 0%)', 75], 'hsl(0, 0%, 75%)'], + [['hsl(0, 0%, 0%)', 100], 'hsl(0, 0%, 100%)'], + [['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 100%)'], + [['hsl(0, 0%, 100%)', 100], 'hsl(0, 0%, 100%)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( lighten ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/lightness.js b/tools/ui/node_modules/khroma/test/methods/lightness.js new file mode 100644 index 0000000000000000000000000000000000000000..8aef58531ccfba9de8aafdcf9937a59c503db2eb --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/lightness.js @@ -0,0 +1,26 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {lightness} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'lightness', it => { + + it ( 'gets the lightness channel of the color', t => { + + const tests = [ + ['hsl(10, 20%, 30%)', 30], + ['rgb(10, 20, 30)', 7.8431372549], + ['rgb(0, 0, 0)', 0], + ['#102030', 12.5490196078] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( lightness ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/luminance.js b/tools/ui/node_modules/khroma/test/methods/luminance.js new file mode 100644 index 0000000000000000000000000000000000000000..1f9d919332bd9dda4ba53a5dbdce42d2f4ec9817 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/luminance.js @@ -0,0 +1,28 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {luminance} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'luminance', it => { + + it ( 'gets the relative luminance of the color', t => { + + const tests = [ + ['#000000', 0], + ['#8a8a8a', .2541520943], + ['#bbbbbb', .4969329951], + ['#ffcc00', .6444573127], + ['#e0e0e0', .7454042095], + ['#ffffff', 1] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( luminance ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/mix.js b/tools/ui/node_modules/khroma/test/methods/mix.js new file mode 100644 index 0000000000000000000000000000000000000000..1f687e19686c01d2bf82ff00d5a241b2e64bcd19 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/mix.js @@ -0,0 +1,26 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {mix} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'mix', it => { + + it ( 'mixes two colors together', t => { + + const tests = [ + [['#036', '#d2e1dd'], 'rgb(105, 138, 161.5)'], + [['#036', '#d2e1dd', 75 ], 'rgb(52.5, 94.5, 131.75)'], + [['#036', '#d2e1dd', 25 ], 'rgb(157.5, 181.5, 191.25)'], + [['rgba(242, 236, 228, 0.5)', '#6b717f'], 'rgba(140.75, 143.75, 152.25, 0.75)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( mix ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/opacify.js b/tools/ui/node_modules/khroma/test/methods/opacify.js new file mode 100644 index 0000000000000000000000000000000000000000..104b2643375661f0bd36ad74e7c24c8646ec83c0 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/opacify.js @@ -0,0 +1,25 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {opacify} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'opacify', it => { + + it ( 'increases the opacity channel of the color', t => { + + const tests = [ + [['#000000', 1], '#000000'], + [['rgba(0, 0, 0, 0.5)', 0.5], '#000000'], + [['rgba(0, 0, 0, 0.5)', 0.1], 'rgba(0, 0, 0, 0.6)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( opacify ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/red.js b/tools/ui/node_modules/khroma/test/methods/red.js new file mode 100644 index 0000000000000000000000000000000000000000..e165c23060976943235b56de62bdd8bd04045c64 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/red.js @@ -0,0 +1,25 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {red} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'red', it => { + + it ( 'gets the red channel of the color', t => { + + const tests = [ + ['rgb(10, 20, 30)', 10], + ['#102030', 16], + ['hsl(10, 20%, 30%)', 91.8] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( red ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/rgba.js b/tools/ui/node_modules/khroma/test/methods/rgba.js new file mode 100644 index 0000000000000000000000000000000000000000..86e6d6876d9d7641ef611d3ecb0f1526e7366e13 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/rgba.js @@ -0,0 +1,58 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {rgba} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'rgba', it => { + + it ( 'creates a new color given its rgba channels', t => { + + const tests = [ + [[0, 0, 0, 0], 'rgba(0, 0, 0, 0)'], + [[255, 255, 255, 0.5], 'rgba(255, 255, 255, 0.5)'], + [[0, 0, 0, 1], '#000000'], + [[128, 128, 128, 1], '#808080'], + [[-1, -1, -1, -1], 'rgba(0, 0, 0, 0)'], + [[1000, 1000, 1000, 1000], '#ffffff'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( rgba ( ...args ), output ); + }); + + }); + + it ( 'sets the opacity', t => { + + const tests = [ + [['#000000', .5], 'rgba(0, 0, 0, 0.5)'], + [['#00000066', .5], 'rgba(0, 0, 0, 0.5)'], + [['#ffffff', .5], 'rgba(255, 255, 255, 0.5)'], + [['#ffffff66', .5], 'rgba(255, 255, 255, 0.5)'], + [['#ffcc00', .5], 'rgba(255, 204, 0, 0.5)'], + [['#ffcc0066', .5], 'rgba(255, 204, 0, 0.5)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( rgba ( ...args ), output ); + }); + + }); + + it ( 'allows ommiting the alpha channel', t => { + + const tests = [ + [[0, 0, 0], '#000000'], + [[255, 255, 255], '#ffffff'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( rgba ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/saturate.js b/tools/ui/node_modules/khroma/test/methods/saturate.js new file mode 100644 index 0000000000000000000000000000000000000000..a9a84fefd7f7d33bac49a8029ec5db006ae1b286 --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/saturate.js @@ -0,0 +1,28 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {saturate} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'saturate', it => { + + it ( 'increases the saturation channel of the color', t => { + + const tests = [ + [['hsl(0, 0%, 50%)', 0], 'hsl(0, 0%, 50%)'], + [['hsl(0, 0%, 50%)', 50], 'hsl(0, 50%, 50%)'], + [['hsl(0, 0%, 50%)', 75], 'hsl(0, 75%, 50%)'], + [['hsl(0, 0%, 50%)', 100], 'hsl(0, 100%, 50%)'], + [['hsl(0, 50%, 50%)', 100], 'hsl(0, 100%, 50%)'], + [['hsl(0, 100%, 50%)', 100], 'hsl(0, 100%, 50%)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( saturate ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/saturation.js b/tools/ui/node_modules/khroma/test/methods/saturation.js new file mode 100644 index 0000000000000000000000000000000000000000..d63338fa140da069ea43d408d32138a69ac69efb --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/saturation.js @@ -0,0 +1,27 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {saturation} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'saturation', it => { + + it ( 'gets the saturation channel of the color', t => { + + const tests = [ + ['hsl(10, 20%, 30%)', 20], + ['rgb(10, 20, 30)', 50], + ['rgb(0, 0, 0)', 0], + ['#102030', 50], + ['#ff0000', 100] + ]; + + tests.forEach ( ([ color, output ]) => { + t.is ( saturation ( color ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/scale.js b/tools/ui/node_modules/khroma/test/methods/scale.js new file mode 100644 index 0000000000000000000000000000000000000000..222bfdf58d9575a4110f0c17377ae995935b1c5f --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/scale.js @@ -0,0 +1,95 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {scale} from '../../dist/index.js'; +import Color from '../../dist/color/index.js'; + +/* MAIN */ + +describe ( 'scale', it => { + + it ( 'scales any RGBA channels of the color', t => { + + const tests = [ + [['rgb(0, 0, 0)', { r: 100 }], 'rgb(255, 0, 0)'], + [['rgb(0, 0, 0)', { r: 50 }], 'rgb(127.5, 0, 0)'], + [['rgb(0, 0, 0)', { r: 0 }], 'rgb(0, 0, 0)'], + [['rgb(255, 0, 0)', { r: -100 }], 'rgb(0, 0, 0)'], + [['rgb(255, 0, 0)', { r: -50 }], 'rgb(127.5, 0, 0)'], + [['rgb(255, 0, 0)', { r: -0 }], 'rgb(255, 0, 0)'], + [['rgb(0, 0, 0)', { g: 100 }], 'rgb(0, 255, 0)'], + [['rgb(0, 0, 0)', { g: 50 }], 'rgb(0, 127.5, 0)'], + [['rgb(0, 0, 0)', { g: 0 }], 'rgb(0, 0, 0)'], + [['rgb(0, 0, 0)', { b: 100 }], 'rgb(0, 0, 255)'], + [['rgb(0, 0, 0)', { b: 50 }], 'rgb(0, 0, 127.5)'], + [['rgb(0, 0, 0)', { b: 0 }], 'rgb(0, 0, 0)'], + [['rgb(0, 0, 0)', { r: 50, g: 50, b: 50 }], 'rgb(127.5, 127.5, 127.5)'], + [['rgba(0, 0, 0, .5)', { b: 0 }], 'rgba(0, 0, 0, 0.5)'] + ]; + + tests.forEach ( ([ args, ouptut ]) => { + t.is ( Color.format.rgb.stringify ( Color.parse ( scale ( ...args ) ) ), ouptut ); + }); + + }); + + it ( 'scales any HSLA channels of the color', t => { + + const tests = [ + [['hsl(0, 50%, 50%)', { h: 100 }], 'hsl(0, 50%, 50%)'], // Wraps becuase 360deg = 0deg + [['hsl(0, 50%, 50%)', { h: 50 }], 'hsl(180, 50%, 50%)'], + [['hsl(0, 50%, 50%)', { h: 0 }], 'hsl(0, 50%, 50%)'], + [['hsl(180, 50%, 50%)', { h: -100 }], 'hsl(0, 50%, 50%)'], + [['hsl(180, 50%, 50%)', { h: -50 }], 'hsl(90, 50%, 50%)'], + [['hsl(0, 50%, 50%)', { s: 100 }], 'hsl(0, 100%, 50%)'], + [['hsl(0, 50%, 50%)', { s: 50 }], 'hsl(0, 75%, 50%)'], + [['hsl(0, 50%, 50%)', { s: 0 }], 'hsl(0, 50%, 50%)'], + [['hsl(0, 50%, 50%)', { s: -100 }], 'hsl(0, 0%, 50%)'], + [['hsl(0, 50%, 50%)', { s: -50 }], 'hsl(0, 25%, 50%)'], + [['hsl(0, 50%, 50%)', { l: 100 }], 'hsl(0, 50%, 100%)'], + [['hsl(0, 50%, 50%)', { l: 50 }], 'hsl(0, 50%, 75%)'], + [['hsl(0, 50%, 50%)', { l: 0 }], 'hsl(0, 50%, 50%)'], + [['hsla(0, 50%, 50%, .5)', { l: 0 }], 'hsla(0, 50%, 50%, 0.5)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( Color.format.hsl.stringify ( Color.parse ( scale ( ...args ) ) ), output ); + }); + + }); + + it ( 'scales the alpha channel', t => { + + const tests = [ + [['rgba(0, 0, 0, 0)', { a: 0 }], 'rgba(0, 0, 0, 0)'], + [['rgba(0, 0, 0, 0)', { a: 50 }], 'rgba(0, 0, 0, 0.5)'], + [['rgba(0, 0, 0, 0)', { a: 100 }], '#000000'], + [['hsla(0, 0%, 0%, 0)', { a: 50 }], 'hsla(0, 0%, 0%, 0.5)'], + [['rgba(0, 0, 0, 1)', { a: -50 }], 'rgba(0, 0, 0, 0.5)'], + [['rgba(0, 0, 0, 1)', { a: -100 }], 'rgba(0, 0, 0, 0)'], + [['rgba(0, 0, 0, 0.5)', { a: 100 }], '#000000'], + [['rgba(0, 0, 0, 0.5)', { a: -100 }], 'rgba(0, 0, 0, 0)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( scale ( ...args ), output ); + }); + + }); + + it ( 'throws when setting RGB and HSL channels at the same time', t => { + + const tests = [ + ['#000', { r: 10, h: 10 }], + ['#000', { g: 10, l: 10 }], + ['#000', { b: 10, s: 10 }] + ]; + + tests.forEach ( args => { + t.throws ( () => scale ( ...args ), /cannot.*at the same time/i ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/test/methods/transparentize.js b/tools/ui/node_modules/khroma/test/methods/transparentize.js new file mode 100644 index 0000000000000000000000000000000000000000..1210c64ecf77fb11f94d10d036c9ec9b78fc7c8c --- /dev/null +++ b/tools/ui/node_modules/khroma/test/methods/transparentize.js @@ -0,0 +1,26 @@ + +/* IMPORT */ + +import {describe} from 'fava'; +import {transparentize} from '../../dist/index.js'; + +/* MAIN */ + +describe ( 'transparentize', it => { + + it ( 'decreases the opacity channel of the color', t => { + + const tests = [ + [['#000000', 1], 'rgba(0, 0, 0, 0)'], + [['rgba(0, 0, 0, 0.5)', 0.5], 'rgba(0, 0, 0, 0)'], + [['rgba(0, 0, 0, 0.5)', 1], 'rgba(0, 0, 0, 0)'], + [['rgba(0, 0, 0, 0.5)', 0.1], 'rgba(0, 0, 0, 0.4)'] + ]; + + tests.forEach ( ([ args, output ]) => { + t.is ( transparentize ( ...args ), output ); + }); + + }); + +}); diff --git a/tools/ui/node_modules/khroma/tsconfig.json b/tools/ui/node_modules/khroma/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..4235d7eeae51c10bf7fa165d64539c286e434e1b --- /dev/null +++ b/tools/ui/node_modules/khroma/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "tsex/tsconfig.json", + "compilerOptions": { + "noImplicitAny": false + } +} diff --git a/tools/ui/node_modules/kleur/colors.d.ts b/tools/ui/node_modules/kleur/colors.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cab25c66c55ffedd1846930aa032c1aef92f9972 --- /dev/null +++ b/tools/ui/node_modules/kleur/colors.d.ts @@ -0,0 +1,38 @@ +declare function print(input: string | boolean | number): string; +declare function print(input: undefined | void): undefined; +declare function print(input: null): null; +type Colorize = typeof print; + +export declare const $: { enabled: boolean }; + +// Colors +export declare const black: Colorize; +export declare const red: Colorize; +export declare const green: Colorize; +export declare const yellow: Colorize; +export declare const blue: Colorize; +export declare const magenta: Colorize; +export declare const cyan: Colorize; +export declare const white: Colorize; +export declare const gray: Colorize; +export declare const grey: Colorize; + +// Backgrounds +export declare const bgBlack: Colorize; +export declare const bgRed: Colorize; +export declare const bgGreen: Colorize; +export declare const bgYellow: Colorize; +export declare const bgBlue: Colorize; +export declare const bgMagenta: Colorize; +export declare const bgCyan: Colorize; +export declare const bgWhite: Colorize; + +// Modifiers +export declare const reset: Colorize; +export declare const bold: Colorize; +export declare const dim: Colorize; +export declare const italic: Colorize; +export declare const underline: Colorize; +export declare const inverse: Colorize; +export declare const hidden: Colorize; +export declare const strikethrough: Colorize; diff --git a/tools/ui/node_modules/kleur/colors.js b/tools/ui/node_modules/kleur/colors.js new file mode 100644 index 0000000000000000000000000000000000000000..89fb012dd49e17d7247735a73c49164205b3f8fd --- /dev/null +++ b/tools/ui/node_modules/kleur/colors.js @@ -0,0 +1,53 @@ +let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true; +if (typeof process !== 'undefined') { + ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {}); + isTTY = process.stdout && process.stdout.isTTY; +} + +const $ = exports.$ = { + enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && ( + FORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY + ) +} + +function init(x, y) { + let rgx = new RegExp(`\\x1b\\[${y}m`, 'g'); + let open = `\x1b[${x}m`, close = `\x1b[${y}m`; + + return function (txt) { + if (!$.enabled || txt == null) return txt; + return open + (!!~(''+txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close; + }; +} + +// modifiers +exports.reset = init(0, 0); +exports.bold = init(1, 22); +exports.dim = init(2, 22); +exports.italic = init(3, 23); +exports.underline = init(4, 24); +exports.inverse = init(7, 27); +exports.hidden = init(8, 28); +exports.strikethrough = init(9, 29); + +// colors +exports.black = init(30, 39); +exports.red = init(31, 39); +exports.green = init(32, 39); +exports.yellow = init(33, 39); +exports.blue = init(34, 39); +exports.magenta = init(35, 39); +exports.cyan = init(36, 39); +exports.white = init(37, 39); +exports.gray = init(90, 39); +exports.grey = init(90, 39); + +// background colors +exports.bgBlack = init(40, 49); +exports.bgRed = init(41, 49); +exports.bgGreen = init(42, 49); +exports.bgYellow = init(43, 49); +exports.bgBlue = init(44, 49); +exports.bgMagenta = init(45, 49); +exports.bgCyan = init(46, 49); +exports.bgWhite = init(47, 49); diff --git a/tools/ui/node_modules/kleur/colors.mjs b/tools/ui/node_modules/kleur/colors.mjs new file mode 100644 index 0000000000000000000000000000000000000000..e9feb83edb65807d360a3a300675a0ac012d915f --- /dev/null +++ b/tools/ui/node_modules/kleur/colors.mjs @@ -0,0 +1,53 @@ +let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true; +if (typeof process !== 'undefined') { + ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {}); + isTTY = process.stdout && process.stdout.isTTY; +} + +export const $ = { + enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && ( + FORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY + ) +} + +function init(x, y) { + let rgx = new RegExp(`\\x1b\\[${y}m`, 'g'); + let open = `\x1b[${x}m`, close = `\x1b[${y}m`; + + return function (txt) { + if (!$.enabled || txt == null) return txt; + return open + (!!~(''+txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close; + }; +} + +// modifiers +export const reset = init(0, 0); +export const bold = init(1, 22); +export const dim = init(2, 22); +export const italic = init(3, 23); +export const underline = init(4, 24); +export const inverse = init(7, 27); +export const hidden = init(8, 28); +export const strikethrough = init(9, 29); + +// colors +export const black = init(30, 39); +export const red = init(31, 39); +export const green = init(32, 39); +export const yellow = init(33, 39); +export const blue = init(34, 39); +export const magenta = init(35, 39); +export const cyan = init(36, 39); +export const white = init(37, 39); +export const gray = init(90, 39); +export const grey = init(90, 39); + +// background colors +export const bgBlack = init(40, 49); +export const bgRed = init(41, 49); +export const bgGreen = init(42, 49); +export const bgYellow = init(43, 49); +export const bgBlue = init(44, 49); +export const bgMagenta = init(45, 49); +export const bgCyan = init(46, 49); +export const bgWhite = init(47, 49); diff --git a/tools/ui/node_modules/kleur/index.d.ts b/tools/ui/node_modules/kleur/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fdc26ca985a5ec68d19a592fd572116bb6ee103b --- /dev/null +++ b/tools/ui/node_modules/kleur/index.d.ts @@ -0,0 +1,45 @@ +// Originally by: Rogier Schouten +// Adapted by: Madhav Varshney +declare namespace kleur { + interface Color { + (x: string | number): string; + (): Kleur; + } + + interface Kleur { + // Colors + black: Color; + red: Color; + green: Color; + yellow: Color; + blue: Color; + magenta: Color; + cyan: Color; + white: Color; + gray: Color; + grey: Color; + + // Backgrounds + bgBlack: Color; + bgRed: Color; + bgGreen: Color; + bgYellow: Color; + bgBlue: Color; + bgMagenta: Color; + bgCyan: Color; + bgWhite: Color; + + // Modifiers + reset: Color; + bold: Color; + dim: Color; + italic: Color; + underline: Color; + inverse: Color; + hidden: Color; + strikethrough: Color; + } +} + +declare let kleur: kleur.Kleur & { enabled: boolean }; +export = kleur; diff --git a/tools/ui/node_modules/kleur/index.js b/tools/ui/node_modules/kleur/index.js new file mode 100644 index 0000000000000000000000000000000000000000..5800b9816c2b0606b1f8a2a7e502f53d162e40ea --- /dev/null +++ b/tools/ui/node_modules/kleur/index.js @@ -0,0 +1,110 @@ +'use strict'; + +let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true; +if (typeof process !== 'undefined') { + ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {}); + isTTY = process.stdout && process.stdout.isTTY; +} + +const $ = { + enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && ( + FORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY + ), + + // modifiers + reset: init(0, 0), + bold: init(1, 22), + dim: init(2, 22), + italic: init(3, 23), + underline: init(4, 24), + inverse: init(7, 27), + hidden: init(8, 28), + strikethrough: init(9, 29), + + // colors + black: init(30, 39), + red: init(31, 39), + green: init(32, 39), + yellow: init(33, 39), + blue: init(34, 39), + magenta: init(35, 39), + cyan: init(36, 39), + white: init(37, 39), + gray: init(90, 39), + grey: init(90, 39), + + // background colors + bgBlack: init(40, 49), + bgRed: init(41, 49), + bgGreen: init(42, 49), + bgYellow: init(43, 49), + bgBlue: init(44, 49), + bgMagenta: init(45, 49), + bgCyan: init(46, 49), + bgWhite: init(47, 49) +}; + +function run(arr, str) { + let i=0, tmp, beg='', end=''; + for (; i < arr.length; i++) { + tmp = arr[i]; + beg += tmp.open; + end += tmp.close; + if (!!~str.indexOf(tmp.close)) { + str = str.replace(tmp.rgx, tmp.close + tmp.open); + } + } + return beg + str + end; +} + +function chain(has, keys) { + let ctx = { has, keys }; + + ctx.reset = $.reset.bind(ctx); + ctx.bold = $.bold.bind(ctx); + ctx.dim = $.dim.bind(ctx); + ctx.italic = $.italic.bind(ctx); + ctx.underline = $.underline.bind(ctx); + ctx.inverse = $.inverse.bind(ctx); + ctx.hidden = $.hidden.bind(ctx); + ctx.strikethrough = $.strikethrough.bind(ctx); + + ctx.black = $.black.bind(ctx); + ctx.red = $.red.bind(ctx); + ctx.green = $.green.bind(ctx); + ctx.yellow = $.yellow.bind(ctx); + ctx.blue = $.blue.bind(ctx); + ctx.magenta = $.magenta.bind(ctx); + ctx.cyan = $.cyan.bind(ctx); + ctx.white = $.white.bind(ctx); + ctx.gray = $.gray.bind(ctx); + ctx.grey = $.grey.bind(ctx); + + ctx.bgBlack = $.bgBlack.bind(ctx); + ctx.bgRed = $.bgRed.bind(ctx); + ctx.bgGreen = $.bgGreen.bind(ctx); + ctx.bgYellow = $.bgYellow.bind(ctx); + ctx.bgBlue = $.bgBlue.bind(ctx); + ctx.bgMagenta = $.bgMagenta.bind(ctx); + ctx.bgCyan = $.bgCyan.bind(ctx); + ctx.bgWhite = $.bgWhite.bind(ctx); + + return ctx; +} + +function init(open, close) { + let blk = { + open: `\x1b[${open}m`, + close: `\x1b[${close}m`, + rgx: new RegExp(`\\x1b\\[${close}m`, 'g') + }; + return function (txt) { + if (this !== void 0 && this.has !== void 0) { + !!~this.has.indexOf(open) || (this.has.push(open),this.keys.push(blk)); + return txt === void 0 ? this : $.enabled ? run(this.keys, txt+'') : txt+''; + } + return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+''; + }; +} + +module.exports = $; diff --git a/tools/ui/node_modules/kleur/index.mjs b/tools/ui/node_modules/kleur/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..96dadad20d3d7ad2257548b51b4bffb6e6e89293 --- /dev/null +++ b/tools/ui/node_modules/kleur/index.mjs @@ -0,0 +1,110 @@ +'use strict'; + +let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true; +if (typeof process !== 'undefined') { + ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {}); + isTTY = process.stdout && process.stdout.isTTY; +} + +const $ = { + enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && ( + FORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY + ), + + // modifiers + reset: init(0, 0), + bold: init(1, 22), + dim: init(2, 22), + italic: init(3, 23), + underline: init(4, 24), + inverse: init(7, 27), + hidden: init(8, 28), + strikethrough: init(9, 29), + + // colors + black: init(30, 39), + red: init(31, 39), + green: init(32, 39), + yellow: init(33, 39), + blue: init(34, 39), + magenta: init(35, 39), + cyan: init(36, 39), + white: init(37, 39), + gray: init(90, 39), + grey: init(90, 39), + + // background colors + bgBlack: init(40, 49), + bgRed: init(41, 49), + bgGreen: init(42, 49), + bgYellow: init(43, 49), + bgBlue: init(44, 49), + bgMagenta: init(45, 49), + bgCyan: init(46, 49), + bgWhite: init(47, 49) +}; + +function run(arr, str) { + let i=0, tmp, beg='', end=''; + for (; i < arr.length; i++) { + tmp = arr[i]; + beg += tmp.open; + end += tmp.close; + if (!!~str.indexOf(tmp.close)) { + str = str.replace(tmp.rgx, tmp.close + tmp.open); + } + } + return beg + str + end; +} + +function chain(has, keys) { + let ctx = { has, keys }; + + ctx.reset = $.reset.bind(ctx); + ctx.bold = $.bold.bind(ctx); + ctx.dim = $.dim.bind(ctx); + ctx.italic = $.italic.bind(ctx); + ctx.underline = $.underline.bind(ctx); + ctx.inverse = $.inverse.bind(ctx); + ctx.hidden = $.hidden.bind(ctx); + ctx.strikethrough = $.strikethrough.bind(ctx); + + ctx.black = $.black.bind(ctx); + ctx.red = $.red.bind(ctx); + ctx.green = $.green.bind(ctx); + ctx.yellow = $.yellow.bind(ctx); + ctx.blue = $.blue.bind(ctx); + ctx.magenta = $.magenta.bind(ctx); + ctx.cyan = $.cyan.bind(ctx); + ctx.white = $.white.bind(ctx); + ctx.gray = $.gray.bind(ctx); + ctx.grey = $.grey.bind(ctx); + + ctx.bgBlack = $.bgBlack.bind(ctx); + ctx.bgRed = $.bgRed.bind(ctx); + ctx.bgGreen = $.bgGreen.bind(ctx); + ctx.bgYellow = $.bgYellow.bind(ctx); + ctx.bgBlue = $.bgBlue.bind(ctx); + ctx.bgMagenta = $.bgMagenta.bind(ctx); + ctx.bgCyan = $.bgCyan.bind(ctx); + ctx.bgWhite = $.bgWhite.bind(ctx); + + return ctx; +} + +function init(open, close) { + let blk = { + open: `\x1b[${open}m`, + close: `\x1b[${close}m`, + rgx: new RegExp(`\\x1b\\[${close}m`, 'g') + }; + return function (txt) { + if (this !== void 0 && this.has !== void 0) { + !!~this.has.indexOf(open) || (this.has.push(open),this.keys.push(blk)); + return txt === void 0 ? this : $.enabled ? run(this.keys, txt+'') : txt+''; + } + return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+''; + }; +} + +export default $; diff --git a/tools/ui/node_modules/kleur/license b/tools/ui/node_modules/kleur/license new file mode 100644 index 0000000000000000000000000000000000000000..a3f96f828458d4ccf4ca8e9b0949300f1916e114 --- /dev/null +++ b/tools/ui/node_modules/kleur/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Luke Edwards (lukeed.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tools/ui/node_modules/kleur/package.json b/tools/ui/node_modules/kleur/package.json new file mode 100644 index 0000000000000000000000000000000000000000..5007c0574ddaa3388e5f109f7e4cdb237f325804 --- /dev/null +++ b/tools/ui/node_modules/kleur/package.json @@ -0,0 +1,51 @@ +{ + "name": "kleur", + "version": "4.1.5", + "repository": "lukeed/kleur", + "description": "The fastest Node.js library for formatting terminal text with ANSI colors~!", + "module": "index.mjs", + "types": "index.d.ts", + "main": "index.js", + "license": "MIT", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.mjs", + "require": "./index.js" + }, + "./colors": { + "types": "./colors.d.ts", + "import": "./colors.mjs", + "require": "./colors.js" + } + }, + "files": [ + "*.d.ts", + "colors.*", + "index.*" + ], + "author": { + "name": "Luke Edwards", + "email": "luke.edwards05@gmail.com", + "url": "https://lukeed.com" + }, + "scripts": { + "build": "node build", + "test": "uvu -r esm -i utils -i xyz" + }, + "engines": { + "node": ">=6" + }, + "keywords": [ + "ansi", + "cli", + "color", + "colors", + "console", + "terminal" + ], + "devDependencies": { + "esm": "3.2.25", + "uvu": "0.3.3" + } +} diff --git a/tools/ui/node_modules/kleur/readme.md b/tools/ui/node_modules/kleur/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..de7f5aa0acc27febacbab13f2f0078188ddc06c8 --- /dev/null +++ b/tools/ui/node_modules/kleur/readme.md @@ -0,0 +1,232 @@ +
+ kleur +
+ + + +
The fastest Node.js library for formatting terminal text with ANSI colors~!
+ +## Features + +* No dependencies +* Super [lightweight](#load-time) & [performant](#performance) +* Supports [nested](#nested-methods) & [chained](#chained-methods) colors +* No `String.prototype` modifications +* Conditional [color support](#conditional-support) +* [Fully treeshakable](#individual-colors) +* Familiar [API](#api) + +--- + +As of `v3.0` the Chalk-style syntax (magical getter) is no longer used.
Please visit [History](#history) for migration paths supporting that syntax. + +--- + + +## Install + +``` +$ npm install --save kleur +``` + + +## Usage + +```js +import kleur from 'kleur'; + +// basic usage +kleur.red('red text'); + +// chained methods +kleur.blue().bold().underline('howdy partner'); + +// nested methods +kleur.bold(`${ white().bgRed('[ERROR]') } ${ kleur.red().italic('Something happened')}`); +``` + +### Chained Methods + +```js +const { bold, green } = require('kleur'); + +console.log(bold().red('this is a bold red message')); +console.log(bold().italic('this is a bold italicized message')); +console.log(bold().yellow().bgRed().italic('this is a bold yellow italicized message')); +console.log(green().bold().underline('this is a bold green underlined message')); +``` + + + +### Nested Methods + +```js +const { yellow, red, cyan } = require('kleur'); + +console.log(yellow(`foo ${red().bold('red')} bar ${cyan('cyan')} baz`)); +console.log(yellow('foo ' + red().bold('red') + ' bar ' + cyan('cyan') + ' baz')); +``` + + + + +### Conditional Support + +Toggle color support as needed; `kleur` includes simple auto-detection which may not cover all cases. + +> **Note:** Both `kleur` and `kleur/colors` share the same detection logic. + +```js +import kleur from 'kleur'; + +// manually disable +kleur.enabled = false; + +// or use another library to detect support +kleur.enabled = require('color-support').level > 0; + +console.log(kleur.red('I will only be colored red if the terminal supports colors')); +``` + +> **Important:**
Colors will be disabled automatically in non [TTY contexts](https://nodejs.org/api/process.html#process_a_note_on_process_i_o). For example, spawning another process or piping output into another process will disable colorization automatically. To force colors in your piped output, you may do so with the `FORCE_COLOR=1` environment variable: + +```sh +$ node app.js #=> COLORS +$ node app.js > log.txt #=> NO COLORS +$ FORCE_COLOR=1 node app.js > log.txt #=> COLORS +$ FORCE_COLOR=0 node app.js > log.txt #=> NO COLORS +``` + +## API + +Any `kleur` method returns a `String` when invoked with input; otherwise chaining is expected. + +> It's up to the developer to pass the output to destinations like `console.log`, `process.stdout.write`, etc. + +The methods below are grouped by type for legibility purposes only. They each can be [chained](#chained-methods) or [nested](#nested-methods) with one another. + +***Colors:*** +> black — red — green — yellow — blue — magenta — cyan — white — gray — grey + +***Backgrounds:*** +> bgBlack — bgRed — bgGreen — bgYellow — bgBlue — bgMagenta — bgCyan — bgWhite + +***Modifiers:*** +> reset — bold — dim — italic* — underline — inverse — hidden — strikethrough* + +* Not widely supported + + +## Individual Colors + +When you only need a few colors, it doesn't make sense to import _all_ of `kleur` because, as small as it is, `kleur` is not treeshakeable, and so most of its code will be doing nothing. In order to fix this, you can import from the `kleur/colors` submodule which _fully_ supports tree-shaking. + +The caveat with this approach is that color functions **are not** chainable~!
Each function receives and colorizes its input. You may combine colors, backgrounds, and modifiers by nesting function calls within other functions. + +```js +// or: import * as kleur from 'kleur/colors'; +import { red, underline, bgWhite } from 'kleur/colors'; + +red('red text'); +//~> kleur.red('red text'); + +underline(red('red underlined text')); +//~> kleur.underline().red('red underlined text'); + +bgWhite(underline(red('red underlined text w/ white background'))); +//~> kleur.bgWhite().underline().red('red underlined text w/ white background'); +``` + +> **Note:** All the same [colors, backgrounds, and modifiers](#api) are available. + +***Conditional Support*** + +The `kleur/colors` submodule also allows you to toggle color support, as needed.
+It includes the same initial assumptions as `kleur`, in an attempt to have colors enabled by default. + +Unlike `kleur`, this setting exists as `kleur.$.enabled` instead of `kleur.enabled`: + +```js +import * as kleur from 'kleur/colors'; +// or: import { $, red } from 'kleur/colors'; + +// manually disabled +kleur.$.enabled = false; + +// or use another library to detect support +kleur.$.enabled = require('color-support').level > 0; + +console.log(red('I will only be colored red if the terminal supports colors')); +``` + + +## Benchmarks + +> Using Node v10.13.0 + +### Load time + +``` +chalk :: 5.303ms +kleur :: 0.488ms +kleur/colors :: 0.369ms +ansi-colors :: 1.504ms +``` + +### Performance + +``` +# All Colors + ansi-colors x 177,625 ops/sec ±1.47% (92 runs sampled) + chalk x 611,907 ops/sec ±0.20% (92 runs sampled) + kleur x 742,509 ops/sec ±1.47% (93 runs sampled) + kleur/colors x 881,742 ops/sec ±0.19% (98 runs sampled) + +# Stacked colors + ansi-colors x 23,331 ops/sec ±1.81% (94 runs sampled) + chalk x 337,178 ops/sec ±0.20% (98 runs sampled) + kleur x 78,299 ops/sec ±1.01% (97 runs sampled) + kleur/colors x 104,431 ops/sec ±0.22% (97 runs sampled) + +# Nested colors + ansi-colors x 67,181 ops/sec ±1.15% (92 runs sampled) + chalk x 116,361 ops/sec ±0.63% (94 runs sampled) + kleur x 139,514 ops/sec ±0.76% (95 runs sampled) + kleur/colors x 145,716 ops/sec ±0.97% (97 runs sampled) +``` + + +## History + +This project originally forked [`ansi-colors`](https://github.com/doowb/ansi-colors). + +Beginning with `kleur@3.0`, the Chalk-style syntax (magical getter) has been replaced with function calls per key: + +```js +// Old: +c.red.bold.underline('old'); + +// New: +c.red().bold().underline('new'); +``` +> As I work more with Rust, the newer syntax feels so much better & more natural! + +If you prefer the old syntax, you may migrate to `ansi-colors` or newer `chalk` releases.
Versions below `kleur@3.0` have been officially deprecated. + + +## License + +MIT © [Luke Edwards](https://lukeed.com) diff --git a/tools/ui/node_modules/known-css-properties/.nvmrc b/tools/ui/node_modules/known-css-properties/.nvmrc new file mode 100644 index 0000000000000000000000000000000000000000..9a2a0e219c9b280eea2627cdcaa1bb40bc8351b3 --- /dev/null +++ b/tools/ui/node_modules/known-css-properties/.nvmrc @@ -0,0 +1 @@ +v20 diff --git a/tools/ui/node_modules/known-css-properties/LICENSE b/tools/ui/node_modules/known-css-properties/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0f8792dd8e3b639160f467c288a45858bddf8107 --- /dev/null +++ b/tools/ui/node_modules/known-css-properties/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Mavrix Technologies + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tools/ui/node_modules/known-css-properties/README.md b/tools/ui/node_modules/known-css-properties/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c1987824edf4c99c2e64faf96455f061cf8341bb --- /dev/null +++ b/tools/ui/node_modules/known-css-properties/README.md @@ -0,0 +1,48 @@ +

logo

+ +# Known CSS properties + +List of standard and browser specific CSS properties. + +[![License](https://img.shields.io/github/license/known-css/known-css-properties.svg)](https://github.com/known-css/known-css-properties/blob/master/LICENSE) +[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovateapp.com/) +[![Npm downloads](https://img.shields.io/npm/dm/known-css-properties.svg)](https://www.npmjs.com/package/known-css-properties) + +## Sources + +1. Standard properties (only 'REC', 'CR', 'LC', 'WD', 'FPWD', 'ED' statuses): http://www.w3.org/Style/CSS/all-properties.en.json +2. Browser supported properties from `window.getComputedStyle` / `document.body.style` + +## Browser versions + +### Desktop + +| Name | Versions | +|---|--:| +| Chrome | 14 - 137 | +| Firefox | 6 - 139 | +| Edge | 13 - 18 | +| Safari | 1.1, 2, 6, 6.2, 7 - 9, 9.1, 10.0, 11.0, 11.1, 12.0, 12.1, 13.0, 13.1, 14, 14.1, 15.1, 15.4, 16.0, 16.5, 16.6, 17.0, 17.1, 17.3, 17.6, 18.1, 18.5 | +| Internet Explorer | 8 - 11 | +| Opera | 12.10, 12.14, 12.15, 12.16, 36 - 40, 45, 56, 58 | + +### Mobile +| Name | Versions | +|---|--:| +| iOS Safari | 6 - 8, 8.3, 9.0, 9.3, 10.0, 10.2, 10.3, 11.0, 11.2, 11.3, 11.4, 12.0 , 12.1, 13.1, 14, 14.1, 15.1, 15.4, 15.6, 16.0, 16.4, 17.0, 17.3, 17.4, 17.5, 17.6, 18.3, 18.5 | +| Chrome for Android | 30, 35, 37, 44, 46, 51, 55 - 62, 64, 66 - 76, 78 - 79, 81, 83, 91, 94, 96, 100, 101, 110, 113 - 114, 117, 124 - 126, 129, 135, 137 | +| Firefox for Android | 47, 52 - 54, 57, 58, 62 - 64, 66, 68, 81, 85, 91, 99, 101, 106, 110, 115, 118, 120, 123, 125, 126, 131, 137, 139 | +| IE mobile | 11 | +| Opera Mobile | 42.7, 43, 47.1, 73.2 | +| Samsung Internet | 4.0, 6.4, 7.4, 8.2, 9.0, 14.2, 19.0, 22.0, 23.0, 25 - 28 | +| UC Browser for Android | 11.2, 12.9, 12.10, 13.1, 13.4 | + +## JavaScript API + +```js +const properties = require('known-css-properties').all; +``` + +## Thanks + +We use [SauceLabs](https://saucelabs.com) live testing solution for gathering most of the data. diff --git a/tools/ui/node_modules/known-css-properties/data/all.json b/tools/ui/node_modules/known-css-properties/data/all.json new file mode 100644 index 0000000000000000000000000000000000000000..1a7c8fb349e160a31c563d7199652d4563149b6e --- /dev/null +++ b/tools/ui/node_modules/known-css-properties/data/all.json @@ -0,0 +1,1328 @@ +{ + "properties": [ + "-epub-caption-side", + "-epub-hyphens", + "-epub-text-combine", + "-epub-text-emphasis", + "-epub-text-emphasis-color", + "-epub-text-emphasis-style", + "-epub-text-orientation", + "-epub-text-transform", + "-epub-word-break", + "-epub-writing-mode", + "-internal-text-autosizing-status", + "accelerator", + "accent-color", + "-wap-accesskey", + "additive-symbols", + "align-content", + "-webkit-align-content", + "align-items", + "-webkit-align-items", + "align-self", + "-webkit-align-self", + "alignment-baseline", + "all", + "alt", + "-webkit-alt", + "anchor-name", + "anchor-scope", + "animation", + "animation-composition", + "animation-delay", + "-moz-animation-delay", + "-ms-animation-delay", + "-webkit-animation-delay", + "animation-direction", + "-moz-animation-direction", + "-ms-animation-direction", + "-webkit-animation-direction", + "animation-duration", + "-moz-animation-duration", + "-ms-animation-duration", + "-webkit-animation-duration", + "animation-fill-mode", + "-moz-animation-fill-mode", + "-ms-animation-fill-mode", + "-webkit-animation-fill-mode", + "animation-iteration-count", + "-moz-animation-iteration-count", + "-ms-animation-iteration-count", + "-webkit-animation-iteration-count", + "-moz-animation", + "-ms-animation", + "animation-name", + "-moz-animation-name", + "-ms-animation-name", + "-webkit-animation-name", + "animation-play-state", + "-moz-animation-play-state", + "-ms-animation-play-state", + "-webkit-animation-play-state", + "animation-range", + "animation-range-end", + "animation-range-start", + "animation-timeline", + "animation-timing-function", + "-moz-animation-timing-function", + "-ms-animation-timing-function", + "-webkit-animation-timing-function", + "animation-trigger", + "animation-trigger-behavior", + "animation-trigger-exit-range", + "animation-trigger-exit-range-end", + "animation-trigger-exit-range-start", + "animation-trigger-range", + "animation-trigger-range-end", + "animation-trigger-range-start", + "animation-trigger-timeline", + "-webkit-animation-trigger", + "-webkit-animation", + "app-region", + "-webkit-app-region", + "appearance", + "-khtml-appearance", + "-moz-appearance", + "-webkit-appearance", + "ascent-override", + "aspect-ratio", + "-webkit-aspect-ratio", + "audio-level", + "azimuth", + "backdrop-filter", + "-webkit-backdrop-filter", + "backface-visibility", + "-moz-backface-visibility", + "-ms-backface-visibility", + "-webkit-backface-visibility", + "background", + "background-attachment", + "-webkit-background-attachment", + "background-blend-mode", + "background-clip", + "-moz-background-clip", + "-webkit-background-clip", + "background-color", + "-webkit-background-color", + "-webkit-background-composite", + "background-image", + "-webkit-background-image", + "-moz-background-inline-policy", + "background-origin", + "-moz-background-origin", + "-webkit-background-origin", + "background-position", + "-webkit-background-position", + "background-position-x", + "-webkit-background-position-x", + "background-position-y", + "-webkit-background-position-y", + "background-repeat", + "-webkit-background-repeat", + "background-repeat-x", + "background-repeat-y", + "background-size", + "-moz-background-size", + "-webkit-background-size", + "-webkit-background", + "base-palette", + "baseline-shift", + "baseline-source", + "behavior", + "-khtml-binding", + "-moz-binding", + "block-ellipsis", + "-ms-block-progression", + "block-size", + "block-step", + "block-step-align", + "block-step-insert", + "block-step-round", + "block-step-size", + "bookmark-label", + "bookmark-level", + "bookmark-state", + "border", + "-webkit-border-after-color", + "-webkit-border-after-style", + "-webkit-border-after", + "-webkit-border-after-width", + "-webkit-border-before-color", + "-webkit-border-before-style", + "-webkit-border-before", + "-webkit-border-before-width", + "border-block", + "border-block-color", + "border-block-end", + "border-block-end-color", + "border-block-end-style", + "border-block-end-width", + "border-block-start", + "border-block-start-color", + "border-block-start-style", + "border-block-start-width", + "border-block-style", + "border-block-width", + "border-bottom", + "border-bottom-color", + "-moz-border-bottom-colors", + "border-bottom-left-radius", + "-webkit-border-bottom-left-radius", + "border-bottom-right-radius", + "-webkit-border-bottom-right-radius", + "border-bottom-style", + "border-bottom-width", + "border-boundary", + "border-collapse", + "border-color", + "-moz-border-end-color", + "-webkit-border-end-color", + "border-end-end-radius", + "-moz-border-end", + "border-end-start-radius", + "-moz-border-end-style", + "-webkit-border-end-style", + "-webkit-border-end", + "-moz-border-end-width", + "-webkit-border-end-width", + "-webkit-border-fit", + "-khtml-border-horizontal-spacing", + "-webkit-border-horizontal-spacing", + "border-image", + "-moz-border-image", + "-o-border-image", + "border-image-outset", + "-webkit-border-image-outset", + "border-image-repeat", + "-webkit-border-image-repeat", + "border-image-slice", + "-webkit-border-image-slice", + "border-image-source", + "-webkit-border-image-source", + "-webkit-border-image", + "border-image-width", + "-webkit-border-image-width", + "border-inline", + "border-inline-color", + "border-inline-end", + "border-inline-end-color", + "border-inline-end-style", + "border-inline-end-width", + "border-inline-start", + "border-inline-start-color", + "border-inline-start-style", + "border-inline-start-width", + "border-inline-style", + "border-inline-width", + "border-left", + "border-left-color", + "-moz-border-left-colors", + "border-left-style", + "border-left-width", + "border-radius", + "-moz-border-radius-bottomleft", + "-moz-border-radius-bottomright", + "-moz-border-radius", + "-moz-border-radius-topleft", + "-moz-border-radius-topright", + "-webkit-border-radius", + "border-right", + "border-right-color", + "-moz-border-right-colors", + "border-right-style", + "border-right-width", + "border-spacing", + "-moz-border-start-color", + "-webkit-border-start-color", + "border-start-end-radius", + "-moz-border-start", + "border-start-start-radius", + "-moz-border-start-style", + "-webkit-border-start-style", + "-webkit-border-start", + "-moz-border-start-width", + "-webkit-border-start-width", + "border-style", + "border-top", + "border-top-color", + "-moz-border-top-colors", + "border-top-left-radius", + "-webkit-border-top-left-radius", + "border-top-right-radius", + "-webkit-border-top-right-radius", + "border-top-style", + "border-top-width", + "-khtml-border-vertical-spacing", + "-webkit-border-vertical-spacing", + "border-width", + "bottom", + "-khtml-box-align", + "-moz-box-align", + "-webkit-box-align", + "box-decoration-break", + "-webkit-box-decoration-break", + "-khtml-box-direction", + "-moz-box-direction", + "-webkit-box-direction", + "-khtml-box-flex-group", + "-khtml-box-flex-group-transition", + "-webkit-box-flex-group", + "-khtml-box-flex", + "-moz-box-flex", + "-webkit-box-flex", + "-khtml-box-lines", + "-webkit-box-lines", + "-khtml-box-ordinal-group", + "-moz-box-ordinal-group", + "-webkit-box-ordinal-group", + "-khtml-box-orient", + "-moz-box-orient", + "-webkit-box-orient", + "-khtml-box-pack", + "-moz-box-pack", + "-webkit-box-pack", + "-webkit-box-reflect", + "box-shadow", + "-moz-box-shadow", + "-webkit-box-shadow", + "box-sizing", + "-moz-box-sizing", + "-webkit-box-sizing", + "box-snap", + "break-after", + "break-before", + "break-inside", + "buffered-rendering", + "caption-side", + "caret", + "caret-animation", + "caret-color", + "caret-shape", + "chains", + "clear", + "clip", + "clip-path", + "-webkit-clip-path", + "clip-rule", + "color", + "color-adjust", + "-webkit-color-correction", + "-apple-color-filter", + "color-interpolation", + "color-interpolation-filters", + "color-profile", + "color-rendering", + "color-scheme", + "-webkit-column-axis", + "-webkit-column-break-after", + "-webkit-column-break-before", + "-webkit-column-break-inside", + "column-count", + "-moz-column-count", + "-webkit-column-count", + "column-fill", + "-moz-column-fill", + "-webkit-column-fill", + "column-gap", + "-moz-column-gap", + "-webkit-column-gap", + "column-height", + "column-progression", + "-webkit-column-progression", + "column-rule", + "column-rule-break", + "column-rule-color", + "-moz-column-rule-color", + "-webkit-column-rule-color", + "-moz-column-rule", + "column-rule-outset", + "column-rule-style", + "-moz-column-rule-style", + "-webkit-column-rule-style", + "-webkit-column-rule", + "column-rule-width", + "-moz-column-rule-width", + "-webkit-column-rule-width", + "column-span", + "-moz-column-span", + "-webkit-column-span", + "column-width", + "-moz-column-width", + "-webkit-column-width", + "column-wrap", + "columns", + "-moz-columns", + "-webkit-columns", + "-webkit-composition-fill-color", + "-webkit-composition-frame-color", + "contain", + "contain-intrinsic-block-size", + "contain-intrinsic-height", + "contain-intrinsic-inline-size", + "contain-intrinsic-size", + "contain-intrinsic-width", + "container", + "container-name", + "container-type", + "content", + "content-visibility", + "-ms-content-zoom-chaining", + "-ms-content-zoom-limit-max", + "-ms-content-zoom-limit-min", + "-ms-content-zoom-limit", + "-ms-content-zoom-snap", + "-ms-content-zoom-snap-points", + "-ms-content-zoom-snap-type", + "-ms-content-zooming", + "continue", + "counter-increment", + "counter-reset", + "counter-set", + "cue", + "cue-after", + "cue-before", + "cursor", + "-webkit-cursor-visibility", + "cx", + "cy", + "d", + "-apple-dashboard-region", + "-khtml-dashboard-region", + "-webkit-dashboard-region", + "descent-override", + "direction", + "display", + "display-align", + "dominant-baseline", + "dynamic-range-limit", + "elevation", + "empty-cells", + "enable-background", + "epub-caption-side", + "epub-hyphens", + "epub-text-combine", + "epub-text-emphasis", + "epub-text-emphasis-color", + "epub-text-emphasis-style", + "epub-text-orientation", + "epub-text-transform", + "epub-word-break", + "epub-writing-mode", + "fallback", + "field-sizing", + "fill", + "fill-break", + "fill-color", + "fill-image", + "fill-opacity", + "fill-origin", + "fill-position", + "fill-repeat", + "fill-rule", + "fill-size", + "filter", + "-ms-filter", + "-webkit-filter", + "flex", + "-ms-flex-align", + "-webkit-flex-align", + "flex-basis", + "-webkit-flex-basis", + "flex-direction", + "-ms-flex-direction", + "-webkit-flex-direction", + "flex-flow", + "-ms-flex-flow", + "-webkit-flex-flow", + "flex-grow", + "-webkit-flex-grow", + "-ms-flex-item-align", + "-webkit-flex-item-align", + "-ms-flex-line-pack", + "-webkit-flex-line-pack", + "-ms-flex", + "-ms-flex-negative", + "-ms-flex-order", + "-webkit-flex-order", + "-ms-flex-pack", + "-webkit-flex-pack", + "-ms-flex-positive", + "-ms-flex-preferred-size", + "flex-shrink", + "-webkit-flex-shrink", + "-webkit-flex", + "flex-wrap", + "-ms-flex-wrap", + "-webkit-flex-wrap", + "float", + "float-defer", + "-moz-float-edge", + "float-offset", + "float-reference", + "flood-color", + "flood-opacity", + "flow", + "flow-from", + "-ms-flow-from", + "-webkit-flow-from", + "flow-into", + "-ms-flow-into", + "-webkit-flow-into", + "-khtml-flow-mode", + "-konq-flow-mode", + "font", + "font-display", + "font-family", + "font-feature-settings", + "-moz-font-feature-settings", + "-ms-font-feature-settings", + "-webkit-font-feature-settings", + "font-kerning", + "-webkit-font-kerning", + "font-language-override", + "-moz-font-language-override", + "font-optical-sizing", + "font-palette", + "font-size", + "font-size-adjust", + "-khtml-font-size-delta", + "-webkit-font-size-delta", + "-webkit-font-smoothing", + "font-stretch", + "font-style", + "font-synthesis", + "font-synthesis-position", + "font-synthesis-small-caps", + "font-synthesis-style", + "font-synthesis-weight", + "font-variant", + "font-variant-alternates", + "font-variant-caps", + "font-variant-east-asian", + "font-variant-emoji", + "font-variant-ligatures", + "-webkit-font-variant-ligatures", + "font-variant-numeric", + "font-variant-position", + "font-variation-settings", + "font-weight", + "font-width", + "footnote-display", + "footnote-policy", + "-moz-force-broken-image-icon", + "forced-color-adjust", + "gap", + "glyph-orientation-horizontal", + "glyph-orientation-vertical", + "grid", + "-webkit-grid-after", + "grid-area", + "grid-auto-columns", + "-webkit-grid-auto-columns", + "grid-auto-flow", + "-webkit-grid-auto-flow", + "grid-auto-rows", + "-webkit-grid-auto-rows", + "-webkit-grid-before", + "grid-column", + "-ms-grid-column-align", + "grid-column-end", + "grid-column-gap", + "-ms-grid-column", + "-ms-grid-column-span", + "grid-column-start", + "-webkit-grid-column", + "-ms-grid-columns", + "-webkit-grid-columns", + "-webkit-grid-end", + "grid-gap", + "grid-row", + "-ms-grid-row-align", + "grid-row-end", + "grid-row-gap", + "-ms-grid-row", + "-ms-grid-row-span", + "grid-row-start", + "-webkit-grid-row", + "-ms-grid-rows", + "-webkit-grid-rows", + "-webkit-grid-start", + "grid-template", + "grid-template-areas", + "grid-template-columns", + "grid-template-rows", + "hanging-punctuation", + "height", + "-ms-high-contrast-adjust", + "-webkit-highlight", + "-khtml-horizontal-border-spacing", + "hyphenate-character", + "-webkit-hyphenate-character", + "-webkit-hyphenate-limit-after", + "-webkit-hyphenate-limit-before", + "hyphenate-limit-chars", + "-ms-hyphenate-limit-chars", + "hyphenate-limit-last", + "hyphenate-limit-lines", + "-ms-hyphenate-limit-lines", + "-webkit-hyphenate-limit-lines", + "hyphenate-limit-zone", + "-ms-hyphenate-limit-zone", + "hyphens", + "-moz-hyphens", + "-ms-hyphens", + "-webkit-hyphens", + "image-orientation", + "-moz-image-region", + "image-rendering", + "image-resolution", + "-ms-ime-align", + "ime-mode", + "inherits", + "initial-letter", + "initial-letter-align", + "-webkit-initial-letter", + "initial-letter-wrap", + "initial-value", + "inline-size", + "inline-sizing", + "input-format", + "-wap-input-format", + "-wap-input-required", + "input-security", + "inset", + "inset-area", + "inset-block", + "inset-block-end", + "inset-block-start", + "inset-inline", + "inset-inline-end", + "inset-inline-start", + "interactivity", + "interpolate-size", + "-ms-interpolation-mode", + "isolation", + "item-cross", + "item-direction", + "item-flow", + "item-pack", + "item-slack", + "item-track", + "item-wrap", + "-konq-js-clip", + "justify-content", + "-webkit-justify-content", + "justify-items", + "-webkit-justify-items", + "justify-self", + "-webkit-justify-self", + "kerning", + "layout-flow", + "layout-grid", + "layout-grid-char", + "layout-grid-line", + "layout-grid-mode", + "layout-grid-type", + "left", + "letter-spacing", + "lighting-color", + "-webkit-line-align", + "-webkit-line-box-contain", + "line-break", + "-khtml-line-break", + "-webkit-line-break", + "line-clamp", + "-apple-line-clamp", + "-khtml-line-clamp", + "-webkit-line-clamp", + "line-fit-edge", + "line-gap-override", + "line-grid", + "-webkit-line-grid-snap", + "-webkit-line-grid", + "line-height", + "line-height-step", + "line-increment", + "line-padding", + "line-snap", + "-webkit-line-snap", + "-o-link", + "-o-link-source", + "list-style", + "list-style-image", + "list-style-position", + "list-style-type", + "-webkit-locale", + "-webkit-logical-height", + "-webkit-logical-width", + "margin", + "-webkit-margin-after-collapse", + "-webkit-margin-after", + "-webkit-margin-before-collapse", + "-webkit-margin-before", + "margin-block", + "margin-block-end", + "margin-block-start", + "margin-bottom", + "-khtml-margin-bottom-collapse", + "-webkit-margin-bottom-collapse", + "margin-break", + "-khtml-margin-collapse", + "-webkit-margin-collapse", + "-moz-margin-end", + "-webkit-margin-end", + "margin-inline", + "margin-inline-end", + "margin-inline-start", + "margin-left", + "margin-right", + "-khtml-margin-start", + "-moz-margin-start", + "-webkit-margin-start", + "margin-top", + "-khtml-margin-top-collapse", + "-webkit-margin-top-collapse", + "margin-trim", + "marker", + "marker-end", + "marker-knockout-left", + "marker-knockout-right", + "marker-mid", + "marker-offset", + "marker-pattern", + "marker-segment", + "marker-side", + "marker-start", + "marks", + "-wap-marquee-dir", + "-khtml-marquee-direction", + "-webkit-marquee-direction", + "-khtml-marquee-increment", + "-webkit-marquee-increment", + "-khtml-marquee", + "-wap-marquee-loop", + "-khtml-marquee-repetition", + "-webkit-marquee-repetition", + "-khtml-marquee-speed", + "-wap-marquee-speed", + "-webkit-marquee-speed", + "-khtml-marquee-style", + "-wap-marquee-style", + "-webkit-marquee-style", + "-webkit-marquee", + "mask", + "-webkit-mask-attachment", + "mask-border", + "mask-border-mode", + "mask-border-outset", + "mask-border-repeat", + "mask-border-slice", + "mask-border-source", + "mask-border-width", + "-webkit-mask-box-image-outset", + "-webkit-mask-box-image-repeat", + "-webkit-mask-box-image-slice", + "-webkit-mask-box-image-source", + "-webkit-mask-box-image", + "-webkit-mask-box-image-width", + "mask-clip", + "-webkit-mask-clip", + "mask-composite", + "-webkit-mask-composite", + "mask-image", + "-webkit-mask-image", + "mask-mode", + "mask-origin", + "-webkit-mask-origin", + "mask-position", + "-webkit-mask-position", + "mask-position-x", + "-webkit-mask-position-x", + "mask-position-y", + "-webkit-mask-position-y", + "mask-repeat", + "-webkit-mask-repeat", + "-webkit-mask-repeat-x", + "-webkit-mask-repeat-y", + "mask-size", + "-webkit-mask-size", + "mask-source-type", + "-webkit-mask-source-type", + "mask-type", + "-webkit-mask", + "-khtml-match-nearest-mail-blockquote-color", + "-webkit-match-nearest-mail-blockquote-color", + "math-depth", + "math-shift", + "math-style", + "max-block-size", + "max-height", + "max-inline-size", + "max-lines", + "-webkit-max-logical-height", + "-webkit-max-logical-width", + "max-width", + "max-zoom", + "min-block-size", + "min-height", + "min-inline-size", + "min-intrinsic-sizing", + "-webkit-min-logical-height", + "-webkit-min-logical-width", + "min-width", + "min-zoom", + "mix-blend-mode", + "motion", + "motion-offset", + "motion-path", + "motion-rotation", + "nav-down", + "nav-index", + "nav-left", + "nav-right", + "nav-up", + "navigation", + "-khtml-nbsp-mode", + "-webkit-nbsp-mode", + "negative", + "object-fit", + "-o-object-fit", + "object-position", + "-o-object-position", + "object-view-box", + "offset", + "offset-anchor", + "offset-block-end", + "offset-block-start", + "offset-distance", + "offset-inline-end", + "offset-inline-start", + "offset-path", + "offset-position", + "offset-rotate", + "offset-rotation", + "opacity", + "-khtml-opacity", + "-moz-opacity", + "-webkit-opacity", + "order", + "-webkit-order", + "-moz-orient", + "orientation", + "orphans", + "-moz-osx-font-smoothing", + "outline", + "outline-color", + "-moz-outline-color", + "-moz-outline", + "outline-offset", + "-moz-outline-offset", + "-moz-outline-radius-bottomleft", + "-moz-outline-radius-bottomright", + "-moz-outline-radius", + "-moz-outline-radius-topleft", + "-moz-outline-radius-topright", + "outline-style", + "-moz-outline-style", + "outline-width", + "-moz-outline-width", + "overflow", + "overflow-anchor", + "overflow-block", + "overflow-clip-margin", + "overflow-clip-margin-block", + "overflow-clip-margin-block-end", + "overflow-clip-margin-block-start", + "overflow-clip-margin-bottom", + "overflow-clip-margin-inline", + "overflow-clip-margin-inline-end", + "overflow-clip-margin-inline-start", + "overflow-clip-margin-left", + "overflow-clip-margin-right", + "overflow-clip-margin-top", + "overflow-inline", + "-webkit-overflow-scrolling", + "-ms-overflow-style", + "overflow-wrap", + "overflow-x", + "overflow-y", + "overlay", + "override-colors", + "overscroll-behavior", + "overscroll-behavior-block", + "overscroll-behavior-inline", + "overscroll-behavior-x", + "overscroll-behavior-y", + "pad", + "padding", + "-webkit-padding-after", + "-webkit-padding-before", + "padding-block", + "padding-block-end", + "padding-block-start", + "padding-bottom", + "-moz-padding-end", + "-webkit-padding-end", + "padding-inline", + "padding-inline-end", + "padding-inline-start", + "padding-left", + "padding-right", + "-khtml-padding-start", + "-moz-padding-start", + "-webkit-padding-start", + "padding-top", + "page", + "page-break-after", + "page-break-before", + "page-break-inside", + "page-orientation", + "paint-order", + "pause", + "pause-after", + "pause-before", + "-apple-pay-button-style", + "-apple-pay-button-type", + "pen-action", + "perspective", + "-moz-perspective", + "-ms-perspective", + "perspective-origin", + "-moz-perspective-origin", + "-ms-perspective-origin", + "-webkit-perspective-origin", + "perspective-origin-x", + "-webkit-perspective-origin-x", + "perspective-origin-y", + "-webkit-perspective-origin-y", + "-webkit-perspective", + "pitch", + "pitch-range", + "place-content", + "place-items", + "place-self", + "play-during", + "pointer-events", + "position", + "position-anchor", + "position-area", + "position-try", + "position-try-fallbacks", + "position-try-options", + "position-try-order", + "position-visibility", + "prefix", + "print-color-adjust", + "-webkit-print-color-adjust", + "property-name", + "quotes", + "r", + "range", + "reading-flow", + "reading-order", + "-webkit-region-break-after", + "-webkit-region-break-before", + "-webkit-region-break-inside", + "region-fragment", + "-webkit-region-fragment", + "-webkit-region-overflow", + "resize", + "rest", + "rest-after", + "rest-before", + "richness", + "right", + "rotate", + "row-gap", + "row-rule", + "row-rule-break", + "row-rule-color", + "row-rule-outset", + "row-rule-style", + "row-rule-width", + "-khtml-rtl-ordering", + "-webkit-rtl-ordering", + "ruby-align", + "ruby-merge", + "ruby-overhang", + "ruby-position", + "-webkit-ruby-position", + "rule", + "rule-break", + "rule-color", + "rule-outset", + "rule-paint-order", + "rule-style", + "rule-width", + "running", + "rx", + "ry", + "scale", + "scroll-behavior", + "-ms-scroll-chaining", + "scroll-initial-target", + "-ms-scroll-limit", + "-ms-scroll-limit-x-max", + "-ms-scroll-limit-x-min", + "-ms-scroll-limit-y-max", + "-ms-scroll-limit-y-min", + "scroll-margin", + "scroll-margin-block", + "scroll-margin-block-end", + "scroll-margin-block-start", + "scroll-margin-bottom", + "scroll-margin-inline", + "scroll-margin-inline-end", + "scroll-margin-inline-start", + "scroll-margin-left", + "scroll-margin-right", + "scroll-margin-top", + "scroll-marker-group", + "scroll-padding", + "scroll-padding-block", + "scroll-padding-block-end", + "scroll-padding-block-start", + "scroll-padding-bottom", + "scroll-padding-inline", + "scroll-padding-inline-end", + "scroll-padding-inline-start", + "scroll-padding-left", + "scroll-padding-right", + "scroll-padding-top", + "-ms-scroll-rails", + "scroll-snap-align", + "scroll-snap-coordinate", + "-webkit-scroll-snap-coordinate", + "scroll-snap-destination", + "-webkit-scroll-snap-destination", + "scroll-snap-margin", + "scroll-snap-margin-bottom", + "scroll-snap-margin-left", + "scroll-snap-margin-right", + "scroll-snap-margin-top", + "scroll-snap-points-x", + "-ms-scroll-snap-points-x", + "-webkit-scroll-snap-points-x", + "scroll-snap-points-y", + "-ms-scroll-snap-points-y", + "-webkit-scroll-snap-points-y", + "scroll-snap-stop", + "scroll-snap-type", + "-ms-scroll-snap-type", + "-webkit-scroll-snap-type", + "scroll-snap-type-x", + "scroll-snap-type-y", + "-ms-scroll-snap-x", + "-ms-scroll-snap-y", + "scroll-start-target", + "scroll-target-group", + "scroll-timeline", + "scroll-timeline-axis", + "scroll-timeline-name", + "-ms-scroll-translation", + "scrollbar-arrow-color", + "scrollbar-base-color", + "scrollbar-color", + "scrollbar-dark-shadow-color", + "scrollbar-darkshadow-color", + "scrollbar-face-color", + "scrollbar-gutter", + "scrollbar-highlight-color", + "scrollbar-shadow-color", + "scrollbar-track-color", + "scrollbar-width", + "scrollbar3d-light-color", + "scrollbar3dlight-color", + "shape-image-threshold", + "-webkit-shape-image-threshold", + "shape-inside", + "-webkit-shape-inside", + "shape-margin", + "-webkit-shape-margin", + "shape-outside", + "-webkit-shape-outside", + "-webkit-shape-padding", + "shape-rendering", + "size", + "size-adjust", + "slider-orientation", + "snap-height", + "solid-color", + "solid-opacity", + "spatial-navigation-action", + "spatial-navigation-contain", + "spatial-navigation-function", + "speak", + "speak-as", + "speak-header", + "speak-numeral", + "speak-punctuation", + "speech-rate", + "src", + "-moz-stack-sizing", + "stop-color", + "stop-opacity", + "stress", + "string-set", + "stroke", + "stroke-align", + "stroke-alignment", + "stroke-break", + "stroke-color", + "stroke-dash-corner", + "stroke-dash-justify", + "stroke-dashadjust", + "stroke-dasharray", + "stroke-dashcorner", + "stroke-dashoffset", + "stroke-image", + "stroke-linecap", + "stroke-linejoin", + "stroke-miterlimit", + "stroke-opacity", + "stroke-origin", + "stroke-position", + "stroke-repeat", + "stroke-size", + "stroke-width", + "suffix", + "supported-color-schemes", + "-webkit-svg-shadow", + "symbols", + "syntax", + "system", + "tab-size", + "-moz-tab-size", + "-o-tab-size", + "-o-table-baseline", + "table-layout", + "-webkit-tap-highlight-color", + "text-align", + "text-align-all", + "text-align-last", + "-moz-text-align-last", + "text-anchor", + "text-autospace", + "-moz-text-blink", + "text-box", + "text-box-edge", + "text-box-trim", + "-ms-text-combine-horizontal", + "text-combine-upright", + "-webkit-text-combine", + "text-decoration", + "text-decoration-blink", + "text-decoration-color", + "-moz-text-decoration-color", + "-webkit-text-decoration-color", + "text-decoration-line", + "-moz-text-decoration-line", + "text-decoration-line-through", + "-webkit-text-decoration-line", + "text-decoration-none", + "text-decoration-overline", + "text-decoration-skip", + "text-decoration-skip-box", + "text-decoration-skip-ink", + "text-decoration-skip-inset", + "text-decoration-skip-self", + "text-decoration-skip-spaces", + "-webkit-text-decoration-skip", + "text-decoration-style", + "-moz-text-decoration-style", + "-webkit-text-decoration-style", + "text-decoration-thickness", + "text-decoration-trim", + "text-decoration-underline", + "-webkit-text-decoration", + "-khtml-text-decorations-in-effect", + "-webkit-text-decorations-in-effect", + "text-emphasis", + "text-emphasis-color", + "-webkit-text-emphasis-color", + "text-emphasis-position", + "-webkit-text-emphasis-position", + "text-emphasis-skip", + "text-emphasis-style", + "-webkit-text-emphasis-style", + "-webkit-text-emphasis", + "-webkit-text-fill-color", + "text-group-align", + "text-indent", + "text-justify", + "text-justify-trim", + "text-kashida", + "text-kashida-space", + "text-line-through", + "text-line-through-color", + "text-line-through-mode", + "text-line-through-style", + "text-line-through-width", + "text-orientation", + "-webkit-text-orientation", + "text-overflow", + "text-overline", + "text-overline-color", + "text-overline-mode", + "text-overline-style", + "text-overline-width", + "text-rendering", + "-webkit-text-security", + "text-shadow", + "text-size-adjust", + "-apple-text-size-adjust", + "-khtml-text-size-adjust", + "-moz-text-size-adjust", + "-ms-text-size-adjust", + "-webkit-text-size-adjust", + "text-spacing", + "text-spacing-trim", + "-webkit-text-stroke-color", + "-webkit-text-stroke", + "-webkit-text-stroke-width", + "text-transform", + "text-underline", + "text-underline-color", + "text-underline-mode", + "text-underline-offset", + "text-underline-position", + "-webkit-text-underline-position", + "text-underline-style", + "text-underline-width", + "text-wrap", + "text-wrap-mode", + "text-wrap-style", + "-webkit-text-zoom", + "timeline-scope", + "top", + "touch-action", + "touch-action-delay", + "-ms-touch-action", + "-webkit-touch-callout", + "-ms-touch-select", + "-apple-trailing-word", + "transform", + "transform-box", + "-moz-transform", + "-ms-transform", + "-o-transform", + "transform-origin", + "-moz-transform-origin", + "-ms-transform-origin", + "-o-transform-origin", + "-webkit-transform-origin", + "transform-origin-x", + "-webkit-transform-origin-x", + "transform-origin-y", + "-webkit-transform-origin-y", + "transform-origin-z", + "-webkit-transform-origin-z", + "transform-style", + "-moz-transform-style", + "-ms-transform-style", + "-webkit-transform-style", + "-webkit-transform", + "transition", + "transition-behavior", + "transition-delay", + "-moz-transition-delay", + "-ms-transition-delay", + "-o-transition-delay", + "-webkit-transition-delay", + "transition-duration", + "-moz-transition-duration", + "-ms-transition-duration", + "-o-transition-duration", + "-webkit-transition-duration", + "-moz-transition", + "-ms-transition", + "-o-transition", + "transition-property", + "-moz-transition-property", + "-ms-transition-property", + "-o-transition-property", + "-webkit-transition-property", + "transition-timing-function", + "-moz-transition-timing-function", + "-ms-transition-timing-function", + "-o-transition-timing-function", + "-webkit-transition-timing-function", + "-webkit-transition", + "translate", + "types", + "uc-alt-skin", + "uc-skin", + "unicode-bidi", + "unicode-range", + "-khtml-user-drag", + "-webkit-user-drag", + "-moz-user-focus", + "-moz-user-input", + "-khtml-user-modify", + "-moz-user-modify", + "-webkit-user-modify", + "user-select", + "-khtml-user-select", + "-moz-user-select", + "-ms-user-select", + "-webkit-user-select", + "user-zoom", + "vector-effect", + "vertical-align", + "-khtml-vertical-border-spacing", + "view-timeline", + "view-timeline-axis", + "view-timeline-inset", + "view-timeline-name", + "view-transition-class", + "view-transition-group", + "view-transition-name", + "viewport-fill", + "viewport-fill-opacity", + "viewport-fit", + "visibility", + "voice-balance", + "voice-duration", + "voice-family", + "voice-pitch", + "voice-range", + "voice-rate", + "voice-stress", + "voice-volume", + "volume", + "white-space", + "white-space-collapse", + "white-space-trim", + "-webkit-widget-region", + "widows", + "width", + "will-change", + "-moz-window-dragging", + "-moz-window-shadow", + "word-break", + "word-space-transform", + "word-spacing", + "word-wrap", + "wrap-after", + "wrap-before", + "wrap-flow", + "-ms-wrap-flow", + "-webkit-wrap-flow", + "wrap-inside", + "-ms-wrap-margin", + "-webkit-wrap-margin", + "-webkit-wrap-padding", + "-webkit-wrap-shape-inside", + "-webkit-wrap-shape-outside", + "wrap-through", + "-ms-wrap-through", + "-webkit-wrap-through", + "-webkit-wrap", + "writing-mode", + "-webkit-writing-mode", + "x", + "y", + "z-index", + "zoom" + ] +} \ No newline at end of file diff --git a/tools/ui/node_modules/known-css-properties/index.d.ts b/tools/ui/node_modules/known-css-properties/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f31ec7bfc29dfca6e18ab529c1545271bbc8c81e --- /dev/null +++ b/tools/ui/node_modules/known-css-properties/index.d.ts @@ -0,0 +1,3 @@ +declare module "known-css-properties" { + export const all: string[]; +} diff --git a/tools/ui/node_modules/known-css-properties/index.js b/tools/ui/node_modules/known-css-properties/index.js new file mode 100644 index 0000000000000000000000000000000000000000..be1480afcbc5d34a75bdb0524f43dbbef2f595ab --- /dev/null +++ b/tools/ui/node_modules/known-css-properties/index.js @@ -0,0 +1 @@ +module.exports.all = require('./data/all.json').properties; diff --git a/tools/ui/node_modules/known-css-properties/package.json b/tools/ui/node_modules/known-css-properties/package.json new file mode 100644 index 0000000000000000000000000000000000000000..8b47cd9789d4e81a45fede55a70ef965b0a5ab27 --- /dev/null +++ b/tools/ui/node_modules/known-css-properties/package.json @@ -0,0 +1,55 @@ +{ + "name": "known-css-properties", + "version": "0.37.0", + "description": "List of known CSS properties", + "repository": "known-css/known-css-properties", + "main": "index.js", + "scripts": { + "bump": "npm version patch && npm publish && git push && git push --tags", + "download-w3c-data": "node scripts/download-w3c-data.mjs", + "generate": "node scripts/generate.mjs", + "lint": "eslint index.js scripts/*.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "css", + "properties", + "w3c", + "chrome", + "firefox", + "explorer", + "edge", + "safari", + "opera", + "samsung-internet", + "uc-browser" + ], + "contributors": [ + { + "name": "Krzysztof Bebenek", + "email": "kbebenek@kbebenek.me", + "url": "http://kbebenek.me" + }, + { + "name": "Viorel Cojocaru", + "email": "vio@beanon.com", + "url": "http://beanon.com" + } + ], + "author": { + "name": "Viorel Cojocaru", + "email": "vio@beanon.com", + "url": "http://beanon.com" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/known-css/known-css-properties/issues" + }, + "homepage": "https://github.com/known-css/known-css-properties#readme", + "devDependencies": { + "eslint": "8.57.0", + "globby": "14.0.1", + "lodash.sortby": "4.7.0", + "lodash.uniq": "4.5.0" + } +} diff --git a/tools/ui/node_modules/kolorist/LICENSE b/tools/ui/node_modules/kolorist/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..52c0230c86e4e4a17fbb6c06bdac7a1eeb4b4912 --- /dev/null +++ b/tools/ui/node_modules/kolorist/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020-present Marvin Hagemeister + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/tools/ui/node_modules/kolorist/README.md b/tools/ui/node_modules/kolorist/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4755ee0f306d5e8212bafe23ac078b4b85a1d627 --- /dev/null +++ b/tools/ui/node_modules/kolorist/README.md @@ -0,0 +1,53 @@ +# kolorist + +Tiny library to put colors into stdin/stdout :tada: + +![Screenshot of terminal colors](.github/demo.png) + +## Usage + +```bash +npm install --save-dev kolorist +``` + +```js +import { red, cyan } from 'kolorist'; + +console.log(red(`Error: something failed in ${cyan('my-file.js')}.`)); +``` + +You can also disable or enable colors globally via the following environment variables: + +- disable: + - `NODE_DISABLE_COLORS` + - `NO_COLOR` + - `TERM=dumb` + - `FORCE_COLOR=0` + +- enable: + - `FORCE_COLOR=1` + - `FORCE_COLOR=2` + - `FORCE_COLOR=3` + +On top of that you can disable colors right from node: + +```js +import { options, red } from 'kolorist'; + +options.enabled = false; +console.log(red('foo')); +// Logs a string without colors +``` + +You can also strip colors from a string: + +```js +import { red, stripColors } from 'kolorist'; + +console.log(stripColors(red('foo'))); +// Logs 'foo' +``` + +### License + +`MIT`, see [the license file](./LICENSE). diff --git a/tools/ui/node_modules/kolorist/dist/cjs/index.js b/tools/ui/node_modules/kolorist/dist/cjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9d32b372315bc5fd34dde18ad1c8624fb1a52d1b --- /dev/null +++ b/tools/ui/node_modules/kolorist/dist/cjs/index.js @@ -0,0 +1,176 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.link = exports.trueColorBg = exports.trueColor = exports.ansi256Bg = exports.ansi256 = exports.bgLightGray = exports.bgLightCyan = exports.bgLightMagenta = exports.bgLightBlue = exports.bgLightYellow = exports.bgLightGreen = exports.bgLightRed = exports.bgGray = exports.bgWhite = exports.bgCyan = exports.bgMagenta = exports.bgBlue = exports.bgYellow = exports.bgGreen = exports.bgRed = exports.bgBlack = exports.lightCyan = exports.lightMagenta = exports.lightBlue = exports.lightYellow = exports.lightGreen = exports.lightRed = exports.lightGray = exports.gray = exports.white = exports.cyan = exports.magenta = exports.blue = exports.yellow = exports.green = exports.red = exports.black = exports.strikethrough = exports.hidden = exports.inverse = exports.underline = exports.italic = exports.dim = exports.bold = exports.reset = exports.stripColors = exports.options = void 0; +let enabled = true; +// Support both browser and node environments +const globalVar = typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : {}; +/** + * Detect how much colors the current terminal supports + */ +let supportLevel = 0 /* none */; +if (globalVar.process && globalVar.process.env && globalVar.process.stdout) { + const { FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, COLORTERM } = globalVar.process.env; + if (NODE_DISABLE_COLORS || NO_COLOR || FORCE_COLOR === '0') { + enabled = false; + } + else if (FORCE_COLOR === '1' || + FORCE_COLOR === '2' || + FORCE_COLOR === '3') { + enabled = true; + } + else if (TERM === 'dumb') { + enabled = false; + } + else if ('CI' in globalVar.process.env && + [ + 'TRAVIS', + 'CIRCLECI', + 'APPVEYOR', + 'GITLAB_CI', + 'GITHUB_ACTIONS', + 'BUILDKITE', + 'DRONE', + ].some(vendor => vendor in globalVar.process.env)) { + enabled = true; + } + else { + enabled = process.stdout.isTTY; + } + if (enabled) { + // Windows supports 24bit True Colors since Windows 10 revision #14931, + // see https://devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/ + if (process.platform === 'win32') { + supportLevel = 3 /* trueColor */; + } + else { + if (COLORTERM && (COLORTERM === 'truecolor' || COLORTERM === '24bit')) { + supportLevel = 3 /* trueColor */; + } + else if (TERM && (TERM.endsWith('-256color') || TERM.endsWith('256'))) { + supportLevel = 2 /* ansi256 */; + } + else { + supportLevel = 1 /* ansi */; + } + } + } +} +exports.options = { + enabled, + supportLevel, +}; +function kolorist(start, end, level = 1 /* ansi */) { + const open = `\x1b[${start}m`; + const close = `\x1b[${end}m`; + const regex = new RegExp(`\\x1b\\[${end}m`, 'g'); + return (str) => { + return exports.options.enabled && exports.options.supportLevel >= level + ? open + ('' + str).replace(regex, open) + close + : '' + str; + }; +} +// Lower colors into 256 color space +// Taken from https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js +// which is MIT licensed and copyright by Heather Arthur and Josh Junon +function rgbToAnsi256(r, g, b) { + // We use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r >> 4 === g >> 4 && g >> 4 === b >> 4) { + if (r < 8) { + return 16; + } + if (r > 248) { + return 231; + } + return Math.round(((r - 8) / 247) * 24) + 232; + } + const ansi = 16 + + 36 * Math.round((r / 255) * 5) + + 6 * Math.round((g / 255) * 5) + + Math.round((b / 255) * 5); + return ansi; +} +function stripColors(str) { + return ('' + str) + .replace(/\x1b\[[0-9;]+m/g, '') + .replace(/\x1b\]8;;.*?\x07(.*?)\x1b\]8;;\x07/g, (_, group) => group); +} +exports.stripColors = stripColors; +// modifiers +exports.reset = kolorist(0, 0); +exports.bold = kolorist(1, 22); +exports.dim = kolorist(2, 22); +exports.italic = kolorist(3, 23); +exports.underline = kolorist(4, 24); +exports.inverse = kolorist(7, 27); +exports.hidden = kolorist(8, 28); +exports.strikethrough = kolorist(9, 29); +// colors +exports.black = kolorist(30, 39); +exports.red = kolorist(31, 39); +exports.green = kolorist(32, 39); +exports.yellow = kolorist(33, 39); +exports.blue = kolorist(34, 39); +exports.magenta = kolorist(35, 39); +exports.cyan = kolorist(36, 39); +exports.white = kolorist(97, 39); +exports.gray = kolorist(90, 39); +exports.lightGray = kolorist(37, 39); +exports.lightRed = kolorist(91, 39); +exports.lightGreen = kolorist(92, 39); +exports.lightYellow = kolorist(93, 39); +exports.lightBlue = kolorist(94, 39); +exports.lightMagenta = kolorist(95, 39); +exports.lightCyan = kolorist(96, 39); +// background colors +exports.bgBlack = kolorist(40, 49); +exports.bgRed = kolorist(41, 49); +exports.bgGreen = kolorist(42, 49); +exports.bgYellow = kolorist(43, 49); +exports.bgBlue = kolorist(44, 49); +exports.bgMagenta = kolorist(45, 49); +exports.bgCyan = kolorist(46, 49); +exports.bgWhite = kolorist(107, 49); +exports.bgGray = kolorist(100, 49); +exports.bgLightRed = kolorist(101, 49); +exports.bgLightGreen = kolorist(102, 49); +exports.bgLightYellow = kolorist(103, 49); +exports.bgLightBlue = kolorist(104, 49); +exports.bgLightMagenta = kolorist(105, 49); +exports.bgLightCyan = kolorist(106, 49); +exports.bgLightGray = kolorist(47, 49); +// 256 support +const ansi256 = (n) => kolorist('38;5;' + n, 0, 2 /* ansi256 */); +exports.ansi256 = ansi256; +const ansi256Bg = (n) => kolorist('48;5;' + n, 0, 2 /* ansi256 */); +exports.ansi256Bg = ansi256Bg; +// TrueColor 24bit support +const trueColor = (r, g, b) => { + return exports.options.supportLevel === 2 /* ansi256 */ + ? exports.ansi256(rgbToAnsi256(r, g, b)) + : kolorist(`38;2;${r};${g};${b}`, 0, 3 /* trueColor */); +}; +exports.trueColor = trueColor; +const trueColorBg = (r, g, b) => { + return exports.options.supportLevel === 2 /* ansi256 */ + ? exports.ansi256Bg(rgbToAnsi256(r, g, b)) + : kolorist(`48;2;${r};${g};${b}`, 0, 3 /* trueColor */); +}; +exports.trueColorBg = trueColorBg; +// Links +const OSC = '\u001B]'; +const BEL = '\u0007'; +const SEP = ';'; +function link(text, url) { + return exports.options.enabled + ? OSC + '8' + SEP + SEP + url + BEL + text + OSC + '8' + SEP + SEP + BEL + : `${text} (\u200B${url}\u200B)`; +} +exports.link = link; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/tools/ui/node_modules/kolorist/dist/cjs/index.js.map b/tools/ui/node_modules/kolorist/dist/cjs/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..8456faba9b8ba1b80a24fb7becd9d299d00c8060 --- /dev/null +++ b/tools/ui/node_modules/kolorist/dist/cjs/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,IAAI,OAAO,GAAG,IAAI,CAAC;AAEnB,6CAA6C;AAC7C,MAAM,SAAS,GACd,OAAO,IAAI,KAAK,WAAW;IAC1B,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;QAC/B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;YAC/B,CAAC,CAAC,MAAM;YACR,CAAC,CAAE,EAAU,CAAC;AAShB;;GAEG;AACH,IAAI,YAAY,eAAkC,CAAC;AAEnD,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE;IAC3E,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,GACpE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;IACvB,IAAI,mBAAmB,IAAI,QAAQ,IAAI,WAAW,KAAK,GAAG,EAAE;QAC3D,OAAO,GAAG,KAAK,CAAC;KAChB;SAAM,IACN,WAAW,KAAK,GAAG;QACnB,WAAW,KAAK,GAAG;QACnB,WAAW,KAAK,GAAG,EAClB;QACD,OAAO,GAAG,IAAI,CAAC;KACf;SAAM,IAAI,IAAI,KAAK,MAAM,EAAE;QAC3B,OAAO,GAAG,KAAK,CAAC;KAChB;SAAM,IACN,IAAI,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG;QAC7B;YACC,QAAQ;YACR,UAAU;YACV,UAAU;YACV,WAAW;YACX,gBAAgB;YAChB,WAAW;YACX,OAAO;SACP,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EAChD;QACD,OAAO,GAAG,IAAI,CAAC;KACf;SAAM;QACN,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;KAC/B;IAED,IAAI,OAAO,EAAE;QACZ,uEAAuE;QACvE,sFAAsF;QACtF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YACjC,YAAY,oBAAyB,CAAC;SACtC;aAAM;YACN,IAAI,SAAS,IAAI,CAAC,SAAS,KAAK,WAAW,IAAI,SAAS,KAAK,OAAO,CAAC,EAAE;gBACtE,YAAY,oBAAyB,CAAC;aACtC;iBAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;gBACxE,YAAY,kBAAuB,CAAC;aACpC;iBAAM;gBACN,YAAY,eAAoB,CAAC;aACjC;SACD;KACD;CACD;AAEU,QAAA,OAAO,GAAG;IACpB,OAAO;IACP,YAAY;CACZ,CAAC;AAEF,SAAS,QAAQ,CAChB,KAAsB,EACtB,GAAoB,EACpB,oBAAuC;IAEvC,MAAM,IAAI,GAAG,QAAQ,KAAK,GAAG,CAAC;IAC9B,MAAM,KAAK,GAAG,QAAQ,GAAG,GAAG,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,WAAW,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;IAEjD,OAAO,CAAC,GAAoB,EAAE,EAAE;QAC/B,OAAO,eAAO,CAAC,OAAO,IAAI,eAAO,CAAC,YAAY,IAAI,KAAK;YACtD,CAAC,CAAC,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK;YAChD,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC;IACb,CAAC,CAAC;AACH,CAAC;AAED,oCAAoC;AACpC,gHAAgH;AAChH,uEAAuE;AACvE,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACpD,oEAAoE;IACpE,+DAA+D;IAC/D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QAC3C,IAAI,CAAC,GAAG,CAAC,EAAE;YACV,OAAO,EAAE,CAAC;SACV;QAED,IAAI,CAAC,GAAG,GAAG,EAAE;YACZ,OAAO,GAAG,CAAC;SACX;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC;KAC9C;IAED,MAAM,IAAI,GACT,EAAE;QACF,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAE3B,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAgB,WAAW,CAAC,GAAoB;IAC/C,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC;SACf,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;SAC9B,OAAO,CAAC,qCAAqC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAJD,kCAIC;AAED,YAAY;AACC,QAAA,KAAK,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvB,QAAA,IAAI,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvB,QAAA,GAAG,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACtB,QAAA,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzB,QAAA,SAAS,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5B,QAAA,OAAO,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1B,QAAA,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzB,QAAA,aAAa,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE7C,SAAS;AACI,QAAA,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzB,QAAA,GAAG,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACvB,QAAA,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzB,QAAA,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,QAAA,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACxB,QAAA,OAAO,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3B,QAAA,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACxB,QAAA,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzB,QAAA,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAExB,QAAA,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC7B,QAAA,QAAQ,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC5B,QAAA,UAAU,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9B,QAAA,WAAW,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/B,QAAA,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC7B,QAAA,YAAY,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAChC,QAAA,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1C,oBAAoB;AACP,QAAA,OAAO,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3B,QAAA,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3B,QAAA,QAAQ,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC5B,QAAA,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,QAAA,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC7B,QAAA,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,QAAA,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC5B,QAAA,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAE3B,QAAA,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC/B,QAAA,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACjC,QAAA,aAAa,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAClC,QAAA,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAChC,QAAA,cAAc,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACnC,QAAA,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAChC,QAAA,WAAW,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE5C,cAAc;AACP,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CACpC,QAAQ,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,kBAAuB,CAAC;AADnC,QAAA,OAAO,WAC4B;AACzC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CACtC,QAAQ,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,kBAAuB,CAAC;AADnC,QAAA,SAAS,aAC0B;AAEhD,0BAA0B;AACnB,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;IAC5D,OAAO,eAAO,CAAC,YAAY,oBAAyB;QACnD,CAAC,CAAC,eAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,oBAAyB,CAAC;AAC/D,CAAC,CAAC;AAJW,QAAA,SAAS,aAIpB;AACK,MAAM,WAAW,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;IAC9D,OAAO,eAAO,CAAC,YAAY,oBAAyB;QACnD,CAAC,CAAC,iBAAS,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,oBAAyB,CAAC;AAC/D,CAAC,CAAC;AAJW,QAAA,WAAW,eAItB;AAEF,QAAQ;AACR,MAAM,GAAG,GAAG,SAAS,CAAC;AACtB,MAAM,GAAG,GAAG,QAAQ,CAAC;AACrB,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,SAAgB,IAAI,CAAC,IAAY,EAAE,GAAW;IAC7C,OAAO,eAAO,CAAC,OAAO;QACrB,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG;QACxE,CAAC,CAAC,GAAG,IAAI,WAAW,GAAG,SAAS,CAAC;AACnC,CAAC;AAJD,oBAIC"} \ No newline at end of file diff --git a/tools/ui/node_modules/kolorist/dist/esm/index.js b/tools/ui/node_modules/kolorist/dist/esm/index.js new file mode 100644 index 0000000000000000000000000000000000000000..520e85599c690feee02b620df1a10905871d49ad --- /dev/null +++ b/tools/ui/node_modules/kolorist/dist/esm/index.js @@ -0,0 +1,167 @@ +let enabled = true; +// Support both browser and node environments +const globalVar = typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : {}; +/** + * Detect how much colors the current terminal supports + */ +let supportLevel = 0 /* none */; +if (globalVar.process && globalVar.process.env && globalVar.process.stdout) { + const { FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, COLORTERM } = globalVar.process.env; + if (NODE_DISABLE_COLORS || NO_COLOR || FORCE_COLOR === '0') { + enabled = false; + } + else if (FORCE_COLOR === '1' || + FORCE_COLOR === '2' || + FORCE_COLOR === '3') { + enabled = true; + } + else if (TERM === 'dumb') { + enabled = false; + } + else if ('CI' in globalVar.process.env && + [ + 'TRAVIS', + 'CIRCLECI', + 'APPVEYOR', + 'GITLAB_CI', + 'GITHUB_ACTIONS', + 'BUILDKITE', + 'DRONE', + ].some(vendor => vendor in globalVar.process.env)) { + enabled = true; + } + else { + enabled = process.stdout.isTTY; + } + if (enabled) { + // Windows supports 24bit True Colors since Windows 10 revision #14931, + // see https://devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/ + if (process.platform === 'win32') { + supportLevel = 3 /* trueColor */; + } + else { + if (COLORTERM && (COLORTERM === 'truecolor' || COLORTERM === '24bit')) { + supportLevel = 3 /* trueColor */; + } + else if (TERM && (TERM.endsWith('-256color') || TERM.endsWith('256'))) { + supportLevel = 2 /* ansi256 */; + } + else { + supportLevel = 1 /* ansi */; + } + } + } +} +export let options = { + enabled, + supportLevel, +}; +function kolorist(start, end, level = 1 /* ansi */) { + const open = `\x1b[${start}m`; + const close = `\x1b[${end}m`; + const regex = new RegExp(`\\x1b\\[${end}m`, 'g'); + return (str) => { + return options.enabled && options.supportLevel >= level + ? open + ('' + str).replace(regex, open) + close + : '' + str; + }; +} +// Lower colors into 256 color space +// Taken from https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js +// which is MIT licensed and copyright by Heather Arthur and Josh Junon +function rgbToAnsi256(r, g, b) { + // We use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r >> 4 === g >> 4 && g >> 4 === b >> 4) { + if (r < 8) { + return 16; + } + if (r > 248) { + return 231; + } + return Math.round(((r - 8) / 247) * 24) + 232; + } + const ansi = 16 + + 36 * Math.round((r / 255) * 5) + + 6 * Math.round((g / 255) * 5) + + Math.round((b / 255) * 5); + return ansi; +} +export function stripColors(str) { + return ('' + str) + .replace(/\x1b\[[0-9;]+m/g, '') + .replace(/\x1b\]8;;.*?\x07(.*?)\x1b\]8;;\x07/g, (_, group) => group); +} +// modifiers +export const reset = kolorist(0, 0); +export const bold = kolorist(1, 22); +export const dim = kolorist(2, 22); +export const italic = kolorist(3, 23); +export const underline = kolorist(4, 24); +export const inverse = kolorist(7, 27); +export const hidden = kolorist(8, 28); +export const strikethrough = kolorist(9, 29); +// colors +export const black = kolorist(30, 39); +export const red = kolorist(31, 39); +export const green = kolorist(32, 39); +export const yellow = kolorist(33, 39); +export const blue = kolorist(34, 39); +export const magenta = kolorist(35, 39); +export const cyan = kolorist(36, 39); +export const white = kolorist(97, 39); +export const gray = kolorist(90, 39); +export const lightGray = kolorist(37, 39); +export const lightRed = kolorist(91, 39); +export const lightGreen = kolorist(92, 39); +export const lightYellow = kolorist(93, 39); +export const lightBlue = kolorist(94, 39); +export const lightMagenta = kolorist(95, 39); +export const lightCyan = kolorist(96, 39); +// background colors +export const bgBlack = kolorist(40, 49); +export const bgRed = kolorist(41, 49); +export const bgGreen = kolorist(42, 49); +export const bgYellow = kolorist(43, 49); +export const bgBlue = kolorist(44, 49); +export const bgMagenta = kolorist(45, 49); +export const bgCyan = kolorist(46, 49); +export const bgWhite = kolorist(107, 49); +export const bgGray = kolorist(100, 49); +export const bgLightRed = kolorist(101, 49); +export const bgLightGreen = kolorist(102, 49); +export const bgLightYellow = kolorist(103, 49); +export const bgLightBlue = kolorist(104, 49); +export const bgLightMagenta = kolorist(105, 49); +export const bgLightCyan = kolorist(106, 49); +export const bgLightGray = kolorist(47, 49); +// 256 support +export const ansi256 = (n) => kolorist('38;5;' + n, 0, 2 /* ansi256 */); +export const ansi256Bg = (n) => kolorist('48;5;' + n, 0, 2 /* ansi256 */); +// TrueColor 24bit support +export const trueColor = (r, g, b) => { + return options.supportLevel === 2 /* ansi256 */ + ? ansi256(rgbToAnsi256(r, g, b)) + : kolorist(`38;2;${r};${g};${b}`, 0, 3 /* trueColor */); +}; +export const trueColorBg = (r, g, b) => { + return options.supportLevel === 2 /* ansi256 */ + ? ansi256Bg(rgbToAnsi256(r, g, b)) + : kolorist(`48;2;${r};${g};${b}`, 0, 3 /* trueColor */); +}; +// Links +const OSC = '\u001B]'; +const BEL = '\u0007'; +const SEP = ';'; +export function link(text, url) { + return options.enabled + ? OSC + '8' + SEP + SEP + url + BEL + text + OSC + '8' + SEP + SEP + BEL + : `${text} (\u200B${url}\u200B)`; +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/tools/ui/node_modules/kolorist/dist/esm/index.js.map b/tools/ui/node_modules/kolorist/dist/esm/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..478ec8f77fa54a2595df7361c55176d15c4f09ef --- /dev/null +++ b/tools/ui/node_modules/kolorist/dist/esm/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,IAAI,OAAO,GAAG,IAAI,CAAC;AAEnB,6CAA6C;AAC7C,MAAM,SAAS,GACd,OAAO,IAAI,KAAK,WAAW;IAC1B,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;QAC/B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;YAC/B,CAAC,CAAC,MAAM;YACR,CAAC,CAAE,EAAU,CAAC;AAShB;;GAEG;AACH,IAAI,YAAY,eAAkC,CAAC;AAEnD,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE;IAC3E,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,GACpE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;IACvB,IAAI,mBAAmB,IAAI,QAAQ,IAAI,WAAW,KAAK,GAAG,EAAE;QAC3D,OAAO,GAAG,KAAK,CAAC;KAChB;SAAM,IACN,WAAW,KAAK,GAAG;QACnB,WAAW,KAAK,GAAG;QACnB,WAAW,KAAK,GAAG,EAClB;QACD,OAAO,GAAG,IAAI,CAAC;KACf;SAAM,IAAI,IAAI,KAAK,MAAM,EAAE;QAC3B,OAAO,GAAG,KAAK,CAAC;KAChB;SAAM,IACN,IAAI,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG;QAC7B;YACC,QAAQ;YACR,UAAU;YACV,UAAU;YACV,WAAW;YACX,gBAAgB;YAChB,WAAW;YACX,OAAO;SACP,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EAChD;QACD,OAAO,GAAG,IAAI,CAAC;KACf;SAAM;QACN,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;KAC/B;IAED,IAAI,OAAO,EAAE;QACZ,uEAAuE;QACvE,sFAAsF;QACtF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YACjC,YAAY,oBAAyB,CAAC;SACtC;aAAM;YACN,IAAI,SAAS,IAAI,CAAC,SAAS,KAAK,WAAW,IAAI,SAAS,KAAK,OAAO,CAAC,EAAE;gBACtE,YAAY,oBAAyB,CAAC;aACtC;iBAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;gBACxE,YAAY,kBAAuB,CAAC;aACpC;iBAAM;gBACN,YAAY,eAAoB,CAAC;aACjC;SACD;KACD;CACD;AAED,MAAM,CAAC,IAAI,OAAO,GAAG;IACpB,OAAO;IACP,YAAY;CACZ,CAAC;AAEF,SAAS,QAAQ,CAChB,KAAsB,EACtB,GAAoB,EACpB,oBAAuC;IAEvC,MAAM,IAAI,GAAG,QAAQ,KAAK,GAAG,CAAC;IAC9B,MAAM,KAAK,GAAG,QAAQ,GAAG,GAAG,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,WAAW,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;IAEjD,OAAO,CAAC,GAAoB,EAAE,EAAE;QAC/B,OAAO,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,YAAY,IAAI,KAAK;YACtD,CAAC,CAAC,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK;YAChD,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC;IACb,CAAC,CAAC;AACH,CAAC;AAED,oCAAoC;AACpC,gHAAgH;AAChH,uEAAuE;AACvE,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACpD,oEAAoE;IACpE,+DAA+D;IAC/D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QAC3C,IAAI,CAAC,GAAG,CAAC,EAAE;YACV,OAAO,EAAE,CAAC;SACV;QAED,IAAI,CAAC,GAAG,GAAG,EAAE;YACZ,OAAO,GAAG,CAAC;SACX;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC;KAC9C;IAED,MAAM,IAAI,GACT,EAAE;QACF,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAE3B,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAoB;IAC/C,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC;SACf,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;SAC9B,OAAO,CAAC,qCAAqC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAED,YAAY;AACZ,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE7C,SAAS;AACT,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,GAAG,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1C,oBAAoB;AACpB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE5C,cAAc;AACd,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CACpC,QAAQ,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,kBAAuB,CAAC;AAChD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CACtC,QAAQ,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,kBAAuB,CAAC;AAEhD,0BAA0B;AAC1B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;IAC5D,OAAO,OAAO,CAAC,YAAY,oBAAyB;QACnD,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,oBAAyB,CAAC;AAC/D,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;IAC9D,OAAO,OAAO,CAAC,YAAY,oBAAyB;QACnD,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,oBAAyB,CAAC;AAC/D,CAAC,CAAC;AAEF,QAAQ;AACR,MAAM,GAAG,GAAG,SAAS,CAAC;AACtB,MAAM,GAAG,GAAG,QAAQ,CAAC;AACrB,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,GAAW;IAC7C,OAAO,OAAO,CAAC,OAAO;QACrB,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG;QACxE,CAAC,CAAC,GAAG,IAAI,WAAW,GAAG,SAAS,CAAC;AACnC,CAAC"} \ No newline at end of file diff --git a/tools/ui/node_modules/kolorist/dist/esm/index.mjs b/tools/ui/node_modules/kolorist/dist/esm/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..520e85599c690feee02b620df1a10905871d49ad --- /dev/null +++ b/tools/ui/node_modules/kolorist/dist/esm/index.mjs @@ -0,0 +1,167 @@ +let enabled = true; +// Support both browser and node environments +const globalVar = typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : {}; +/** + * Detect how much colors the current terminal supports + */ +let supportLevel = 0 /* none */; +if (globalVar.process && globalVar.process.env && globalVar.process.stdout) { + const { FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, COLORTERM } = globalVar.process.env; + if (NODE_DISABLE_COLORS || NO_COLOR || FORCE_COLOR === '0') { + enabled = false; + } + else if (FORCE_COLOR === '1' || + FORCE_COLOR === '2' || + FORCE_COLOR === '3') { + enabled = true; + } + else if (TERM === 'dumb') { + enabled = false; + } + else if ('CI' in globalVar.process.env && + [ + 'TRAVIS', + 'CIRCLECI', + 'APPVEYOR', + 'GITLAB_CI', + 'GITHUB_ACTIONS', + 'BUILDKITE', + 'DRONE', + ].some(vendor => vendor in globalVar.process.env)) { + enabled = true; + } + else { + enabled = process.stdout.isTTY; + } + if (enabled) { + // Windows supports 24bit True Colors since Windows 10 revision #14931, + // see https://devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/ + if (process.platform === 'win32') { + supportLevel = 3 /* trueColor */; + } + else { + if (COLORTERM && (COLORTERM === 'truecolor' || COLORTERM === '24bit')) { + supportLevel = 3 /* trueColor */; + } + else if (TERM && (TERM.endsWith('-256color') || TERM.endsWith('256'))) { + supportLevel = 2 /* ansi256 */; + } + else { + supportLevel = 1 /* ansi */; + } + } + } +} +export let options = { + enabled, + supportLevel, +}; +function kolorist(start, end, level = 1 /* ansi */) { + const open = `\x1b[${start}m`; + const close = `\x1b[${end}m`; + const regex = new RegExp(`\\x1b\\[${end}m`, 'g'); + return (str) => { + return options.enabled && options.supportLevel >= level + ? open + ('' + str).replace(regex, open) + close + : '' + str; + }; +} +// Lower colors into 256 color space +// Taken from https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js +// which is MIT licensed and copyright by Heather Arthur and Josh Junon +function rgbToAnsi256(r, g, b) { + // We use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r >> 4 === g >> 4 && g >> 4 === b >> 4) { + if (r < 8) { + return 16; + } + if (r > 248) { + return 231; + } + return Math.round(((r - 8) / 247) * 24) + 232; + } + const ansi = 16 + + 36 * Math.round((r / 255) * 5) + + 6 * Math.round((g / 255) * 5) + + Math.round((b / 255) * 5); + return ansi; +} +export function stripColors(str) { + return ('' + str) + .replace(/\x1b\[[0-9;]+m/g, '') + .replace(/\x1b\]8;;.*?\x07(.*?)\x1b\]8;;\x07/g, (_, group) => group); +} +// modifiers +export const reset = kolorist(0, 0); +export const bold = kolorist(1, 22); +export const dim = kolorist(2, 22); +export const italic = kolorist(3, 23); +export const underline = kolorist(4, 24); +export const inverse = kolorist(7, 27); +export const hidden = kolorist(8, 28); +export const strikethrough = kolorist(9, 29); +// colors +export const black = kolorist(30, 39); +export const red = kolorist(31, 39); +export const green = kolorist(32, 39); +export const yellow = kolorist(33, 39); +export const blue = kolorist(34, 39); +export const magenta = kolorist(35, 39); +export const cyan = kolorist(36, 39); +export const white = kolorist(97, 39); +export const gray = kolorist(90, 39); +export const lightGray = kolorist(37, 39); +export const lightRed = kolorist(91, 39); +export const lightGreen = kolorist(92, 39); +export const lightYellow = kolorist(93, 39); +export const lightBlue = kolorist(94, 39); +export const lightMagenta = kolorist(95, 39); +export const lightCyan = kolorist(96, 39); +// background colors +export const bgBlack = kolorist(40, 49); +export const bgRed = kolorist(41, 49); +export const bgGreen = kolorist(42, 49); +export const bgYellow = kolorist(43, 49); +export const bgBlue = kolorist(44, 49); +export const bgMagenta = kolorist(45, 49); +export const bgCyan = kolorist(46, 49); +export const bgWhite = kolorist(107, 49); +export const bgGray = kolorist(100, 49); +export const bgLightRed = kolorist(101, 49); +export const bgLightGreen = kolorist(102, 49); +export const bgLightYellow = kolorist(103, 49); +export const bgLightBlue = kolorist(104, 49); +export const bgLightMagenta = kolorist(105, 49); +export const bgLightCyan = kolorist(106, 49); +export const bgLightGray = kolorist(47, 49); +// 256 support +export const ansi256 = (n) => kolorist('38;5;' + n, 0, 2 /* ansi256 */); +export const ansi256Bg = (n) => kolorist('48;5;' + n, 0, 2 /* ansi256 */); +// TrueColor 24bit support +export const trueColor = (r, g, b) => { + return options.supportLevel === 2 /* ansi256 */ + ? ansi256(rgbToAnsi256(r, g, b)) + : kolorist(`38;2;${r};${g};${b}`, 0, 3 /* trueColor */); +}; +export const trueColorBg = (r, g, b) => { + return options.supportLevel === 2 /* ansi256 */ + ? ansi256Bg(rgbToAnsi256(r, g, b)) + : kolorist(`48;2;${r};${g};${b}`, 0, 3 /* trueColor */); +}; +// Links +const OSC = '\u001B]'; +const BEL = '\u0007'; +const SEP = ';'; +export function link(text, url) { + return options.enabled + ? OSC + '8' + SEP + SEP + url + BEL + text + OSC + '8' + SEP + SEP + BEL + : `${text} (\u200B${url}\u200B)`; +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/tools/ui/node_modules/kolorist/dist/module/index.js b/tools/ui/node_modules/kolorist/dist/module/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a477cb71e7ab07681fd2c03577a4e72040eff63d --- /dev/null +++ b/tools/ui/node_modules/kolorist/dist/module/index.js @@ -0,0 +1,172 @@ +var enabled = true; +// Support both browser and node environments +var globalVar = typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : {}; +/** + * Detect how much colors the current terminal supports + */ +var supportLevel = 0 /* none */; +if (globalVar.process && globalVar.process.env && globalVar.process.stdout) { + var _a = globalVar.process.env, FORCE_COLOR = _a.FORCE_COLOR, NODE_DISABLE_COLORS = _a.NODE_DISABLE_COLORS, NO_COLOR = _a.NO_COLOR, TERM = _a.TERM, COLORTERM = _a.COLORTERM; + if (NODE_DISABLE_COLORS || NO_COLOR || FORCE_COLOR === '0') { + enabled = false; + } + else if (FORCE_COLOR === '1' || + FORCE_COLOR === '2' || + FORCE_COLOR === '3') { + enabled = true; + } + else if (TERM === 'dumb') { + enabled = false; + } + else if ('CI' in globalVar.process.env && + [ + 'TRAVIS', + 'CIRCLECI', + 'APPVEYOR', + 'GITLAB_CI', + 'GITHUB_ACTIONS', + 'BUILDKITE', + 'DRONE', + ].some(function (vendor) { return vendor in globalVar.process.env; })) { + enabled = true; + } + else { + enabled = process.stdout.isTTY; + } + if (enabled) { + // Windows supports 24bit True Colors since Windows 10 revision #14931, + // see https://devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/ + if (process.platform === 'win32') { + supportLevel = 3 /* trueColor */; + } + else { + if (COLORTERM && (COLORTERM === 'truecolor' || COLORTERM === '24bit')) { + supportLevel = 3 /* trueColor */; + } + else if (TERM && (TERM.endsWith('-256color') || TERM.endsWith('256'))) { + supportLevel = 2 /* ansi256 */; + } + else { + supportLevel = 1 /* ansi */; + } + } + } +} +export var options = { + enabled: enabled, + supportLevel: supportLevel, +}; +function kolorist(start, end, level) { + if (level === void 0) { level = 1 /* ansi */; } + var open = "\u001B[" + start + "m"; + var close = "\u001B[" + end + "m"; + var regex = new RegExp("\\x1b\\[" + end + "m", 'g'); + return function (str) { + return options.enabled && options.supportLevel >= level + ? open + ('' + str).replace(regex, open) + close + : '' + str; + }; +} +// Lower colors into 256 color space +// Taken from https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js +// which is MIT licensed and copyright by Heather Arthur and Josh Junon +function rgbToAnsi256(r, g, b) { + // We use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r >> 4 === g >> 4 && g >> 4 === b >> 4) { + if (r < 8) { + return 16; + } + if (r > 248) { + return 231; + } + return Math.round(((r - 8) / 247) * 24) + 232; + } + var ansi = 16 + + 36 * Math.round((r / 255) * 5) + + 6 * Math.round((g / 255) * 5) + + Math.round((b / 255) * 5); + return ansi; +} +export function stripColors(str) { + return ('' + str) + .replace(/\x1b\[[0-9;]+m/g, '') + .replace(/\x1b\]8;;.*?\x07(.*?)\x1b\]8;;\x07/g, function (_, group) { return group; }); +} +// modifiers +export var reset = kolorist(0, 0); +export var bold = kolorist(1, 22); +export var dim = kolorist(2, 22); +export var italic = kolorist(3, 23); +export var underline = kolorist(4, 24); +export var inverse = kolorist(7, 27); +export var hidden = kolorist(8, 28); +export var strikethrough = kolorist(9, 29); +// colors +export var black = kolorist(30, 39); +export var red = kolorist(31, 39); +export var green = kolorist(32, 39); +export var yellow = kolorist(33, 39); +export var blue = kolorist(34, 39); +export var magenta = kolorist(35, 39); +export var cyan = kolorist(36, 39); +export var white = kolorist(97, 39); +export var gray = kolorist(90, 39); +export var lightGray = kolorist(37, 39); +export var lightRed = kolorist(91, 39); +export var lightGreen = kolorist(92, 39); +export var lightYellow = kolorist(93, 39); +export var lightBlue = kolorist(94, 39); +export var lightMagenta = kolorist(95, 39); +export var lightCyan = kolorist(96, 39); +// background colors +export var bgBlack = kolorist(40, 49); +export var bgRed = kolorist(41, 49); +export var bgGreen = kolorist(42, 49); +export var bgYellow = kolorist(43, 49); +export var bgBlue = kolorist(44, 49); +export var bgMagenta = kolorist(45, 49); +export var bgCyan = kolorist(46, 49); +export var bgWhite = kolorist(107, 49); +export var bgGray = kolorist(100, 49); +export var bgLightRed = kolorist(101, 49); +export var bgLightGreen = kolorist(102, 49); +export var bgLightYellow = kolorist(103, 49); +export var bgLightBlue = kolorist(104, 49); +export var bgLightMagenta = kolorist(105, 49); +export var bgLightCyan = kolorist(106, 49); +export var bgLightGray = kolorist(47, 49); +// 256 support +export var ansi256 = function (n) { + return kolorist('38;5;' + n, 0, 2 /* ansi256 */); +}; +export var ansi256Bg = function (n) { + return kolorist('48;5;' + n, 0, 2 /* ansi256 */); +}; +// TrueColor 24bit support +export var trueColor = function (r, g, b) { + return options.supportLevel === 2 /* ansi256 */ + ? ansi256(rgbToAnsi256(r, g, b)) + : kolorist("38;2;" + r + ";" + g + ";" + b, 0, 3 /* trueColor */); +}; +export var trueColorBg = function (r, g, b) { + return options.supportLevel === 2 /* ansi256 */ + ? ansi256Bg(rgbToAnsi256(r, g, b)) + : kolorist("48;2;" + r + ";" + g + ";" + b, 0, 3 /* trueColor */); +}; +// Links +var OSC = '\u001B]'; +var BEL = '\u0007'; +var SEP = ';'; +export function link(text, url) { + return options.enabled + ? OSC + '8' + SEP + SEP + url + BEL + text + OSC + '8' + SEP + SEP + BEL + : text + " (\u200B" + url + "\u200B)"; +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/tools/ui/node_modules/kolorist/dist/module/index.js.map b/tools/ui/node_modules/kolorist/dist/module/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..02d7103720ca86f405fa108f7abbdb04424ce64a --- /dev/null +++ b/tools/ui/node_modules/kolorist/dist/module/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,IAAI,OAAO,GAAG,IAAI,CAAC;AAEnB,6CAA6C;AAC7C,IAAM,SAAS,GACd,OAAO,IAAI,KAAK,WAAW;IAC1B,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;QAC/B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;YAC/B,CAAC,CAAC,MAAM;YACR,CAAC,CAAE,EAAU,CAAC;AAShB;;GAEG;AACH,IAAI,YAAY,eAAkC,CAAC;AAEnD,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE;IACrE,IAAA,KACL,SAAS,CAAC,OAAO,CAAC,GAAG,EADd,WAAW,iBAAA,EAAE,mBAAmB,yBAAA,EAAE,QAAQ,cAAA,EAAE,IAAI,UAAA,EAAE,SAAS,eAC7C,CAAC;IACvB,IAAI,mBAAmB,IAAI,QAAQ,IAAI,WAAW,KAAK,GAAG,EAAE;QAC3D,OAAO,GAAG,KAAK,CAAC;KAChB;SAAM,IACN,WAAW,KAAK,GAAG;QACnB,WAAW,KAAK,GAAG;QACnB,WAAW,KAAK,GAAG,EAClB;QACD,OAAO,GAAG,IAAI,CAAC;KACf;SAAM,IAAI,IAAI,KAAK,MAAM,EAAE;QAC3B,OAAO,GAAG,KAAK,CAAC;KAChB;SAAM,IACN,IAAI,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG;QAC7B;YACC,QAAQ;YACR,UAAU;YACV,UAAU;YACV,WAAW;YACX,gBAAgB;YAChB,WAAW;YACX,OAAO;SACP,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,EAA/B,CAA+B,CAAC,EAChD;QACD,OAAO,GAAG,IAAI,CAAC;KACf;SAAM;QACN,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;KAC/B;IAED,IAAI,OAAO,EAAE;QACZ,uEAAuE;QACvE,sFAAsF;QACtF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YACjC,YAAY,oBAAyB,CAAC;SACtC;aAAM;YACN,IAAI,SAAS,IAAI,CAAC,SAAS,KAAK,WAAW,IAAI,SAAS,KAAK,OAAO,CAAC,EAAE;gBACtE,YAAY,oBAAyB,CAAC;aACtC;iBAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;gBACxE,YAAY,kBAAuB,CAAC;aACpC;iBAAM;gBACN,YAAY,eAAoB,CAAC;aACjC;SACD;KACD;CACD;AAED,MAAM,CAAC,IAAI,OAAO,GAAG;IACpB,OAAO,SAAA;IACP,YAAY,cAAA;CACZ,CAAC;AAEF,SAAS,QAAQ,CAChB,KAAsB,EACtB,GAAoB,EACpB,KAAuC;IAAvC,sBAAA,EAAA,oBAAuC;IAEvC,IAAM,IAAI,GAAG,YAAQ,KAAK,MAAG,CAAC;IAC9B,IAAM,KAAK,GAAG,YAAQ,GAAG,MAAG,CAAC;IAC7B,IAAM,KAAK,GAAG,IAAI,MAAM,CAAC,aAAW,GAAG,MAAG,EAAE,GAAG,CAAC,CAAC;IAEjD,OAAO,UAAC,GAAoB;QAC3B,OAAO,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,YAAY,IAAI,KAAK;YACtD,CAAC,CAAC,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,KAAK;YAChD,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC;IACb,CAAC,CAAC;AACH,CAAC;AAED,oCAAoC;AACpC,gHAAgH;AAChH,uEAAuE;AACvE,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACpD,oEAAoE;IACpE,+DAA+D;IAC/D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QAC3C,IAAI,CAAC,GAAG,CAAC,EAAE;YACV,OAAO,EAAE,CAAC;SACV;QAED,IAAI,CAAC,GAAG,GAAG,EAAE;YACZ,OAAO,GAAG,CAAC;SACX;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC;KAC9C;IAED,IAAM,IAAI,GACT,EAAE;QACF,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAE3B,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAoB;IAC/C,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC;SACf,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;SAC9B,OAAO,CAAC,qCAAqC,EAAE,UAAC,CAAC,EAAE,KAAK,IAAK,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;AACvE,CAAC;AAED,YAAY;AACZ,MAAM,CAAC,IAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,CAAC,IAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC,IAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACnC,MAAM,CAAC,IAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,IAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzC,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvC,MAAM,CAAC,IAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,IAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE7C,SAAS;AACT,MAAM,CAAC,IAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,IAAM,GAAG,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC,IAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,IAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACvC,MAAM,CAAC,IAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACrC,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACxC,MAAM,CAAC,IAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACrC,MAAM,CAAC,IAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,IAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAErC,MAAM,CAAC,IAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1C,MAAM,CAAC,IAAM,QAAQ,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzC,MAAM,CAAC,IAAM,UAAU,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3C,MAAM,CAAC,IAAM,WAAW,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC5C,MAAM,CAAC,IAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1C,MAAM,CAAC,IAAM,YAAY,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC7C,MAAM,CAAC,IAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1C,oBAAoB;AACpB,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACxC,MAAM,CAAC,IAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACtC,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACxC,MAAM,CAAC,IAAM,QAAQ,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACzC,MAAM,CAAC,IAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACvC,MAAM,CAAC,IAAM,SAAS,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1C,MAAM,CAAC,IAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACvC,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACzC,MAAM,CAAC,IAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAExC,MAAM,CAAC,IAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC5C,MAAM,CAAC,IAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9C,MAAM,CAAC,IAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC/C,MAAM,CAAC,IAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC7C,MAAM,CAAC,IAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAChD,MAAM,CAAC,IAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC7C,MAAM,CAAC,IAAM,WAAW,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE5C,cAAc;AACd,MAAM,CAAC,IAAM,OAAO,GAAG,UAAC,CAAS;IAChC,OAAA,QAAQ,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,kBAAuB;AAA9C,CAA8C,CAAC;AAChD,MAAM,CAAC,IAAM,SAAS,GAAG,UAAC,CAAS;IAClC,OAAA,QAAQ,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,kBAAuB;AAA9C,CAA8C,CAAC;AAEhD,0BAA0B;AAC1B,MAAM,CAAC,IAAM,SAAS,GAAG,UAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACxD,OAAO,OAAO,CAAC,YAAY,oBAAyB;QACnD,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC,QAAQ,CAAC,UAAQ,CAAC,SAAI,CAAC,SAAI,CAAG,EAAE,CAAC,oBAAyB,CAAC;AAC/D,CAAC,CAAC;AACF,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IAC1D,OAAO,OAAO,CAAC,YAAY,oBAAyB;QACnD,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC,CAAC,QAAQ,CAAC,UAAQ,CAAC,SAAI,CAAC,SAAI,CAAG,EAAE,CAAC,oBAAyB,CAAC;AAC/D,CAAC,CAAC;AAEF,QAAQ;AACR,IAAM,GAAG,GAAG,SAAS,CAAC;AACtB,IAAM,GAAG,GAAG,QAAQ,CAAC;AACrB,IAAM,GAAG,GAAG,GAAG,CAAC;AAEhB,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,GAAW;IAC7C,OAAO,OAAO,CAAC,OAAO;QACrB,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG;QACxE,CAAC,CAAI,IAAI,gBAAW,GAAG,YAAS,CAAC;AACnC,CAAC"} \ No newline at end of file diff --git a/tools/ui/node_modules/kolorist/dist/types/index.d.ts b/tools/ui/node_modules/kolorist/dist/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..70c1bc831f7a372bac31131f85086c13eec9c338 --- /dev/null +++ b/tools/ui/node_modules/kolorist/dist/types/index.d.ts @@ -0,0 +1,56 @@ +export declare const enum SupportLevel { + none = 0, + ansi = 1, + ansi256 = 2, + trueColor = 3 +} +export declare let options: { + enabled: boolean; + supportLevel: SupportLevel; +}; +export declare function stripColors(str: string | number): string; +export declare const reset: (str: string | number) => string; +export declare const bold: (str: string | number) => string; +export declare const dim: (str: string | number) => string; +export declare const italic: (str: string | number) => string; +export declare const underline: (str: string | number) => string; +export declare const inverse: (str: string | number) => string; +export declare const hidden: (str: string | number) => string; +export declare const strikethrough: (str: string | number) => string; +export declare const black: (str: string | number) => string; +export declare const red: (str: string | number) => string; +export declare const green: (str: string | number) => string; +export declare const yellow: (str: string | number) => string; +export declare const blue: (str: string | number) => string; +export declare const magenta: (str: string | number) => string; +export declare const cyan: (str: string | number) => string; +export declare const white: (str: string | number) => string; +export declare const gray: (str: string | number) => string; +export declare const lightGray: (str: string | number) => string; +export declare const lightRed: (str: string | number) => string; +export declare const lightGreen: (str: string | number) => string; +export declare const lightYellow: (str: string | number) => string; +export declare const lightBlue: (str: string | number) => string; +export declare const lightMagenta: (str: string | number) => string; +export declare const lightCyan: (str: string | number) => string; +export declare const bgBlack: (str: string | number) => string; +export declare const bgRed: (str: string | number) => string; +export declare const bgGreen: (str: string | number) => string; +export declare const bgYellow: (str: string | number) => string; +export declare const bgBlue: (str: string | number) => string; +export declare const bgMagenta: (str: string | number) => string; +export declare const bgCyan: (str: string | number) => string; +export declare const bgWhite: (str: string | number) => string; +export declare const bgGray: (str: string | number) => string; +export declare const bgLightRed: (str: string | number) => string; +export declare const bgLightGreen: (str: string | number) => string; +export declare const bgLightYellow: (str: string | number) => string; +export declare const bgLightBlue: (str: string | number) => string; +export declare const bgLightMagenta: (str: string | number) => string; +export declare const bgLightCyan: (str: string | number) => string; +export declare const bgLightGray: (str: string | number) => string; +export declare const ansi256: (n: number) => (str: string | number) => string; +export declare const ansi256Bg: (n: number) => (str: string | number) => string; +export declare const trueColor: (r: number, g: number, b: number) => (str: string | number) => string; +export declare const trueColorBg: (r: number, g: number, b: number) => (str: string | number) => string; +export declare function link(text: string, url: string): string; diff --git a/tools/ui/node_modules/kolorist/package.json b/tools/ui/node_modules/kolorist/package.json new file mode 100644 index 0000000000000000000000000000000000000000..39d9d22e314877611b16780e3af05807eee7bcfb --- /dev/null +++ b/tools/ui/node_modules/kolorist/package.json @@ -0,0 +1,48 @@ +{ + "name": "kolorist", + "version": "1.8.0", + "description": "A tiny utility to colorize stdin/stdout", + "main": "dist/cjs/index.js", + "module": "dist/module/index.js", + "types": "dist/types/index.d.ts", + "scripts": { + "test": "mocha -r @esbuild-kit/cjs-loader --extension ts,js src/*.test.ts", + "build": "rimraf dist/ && tsc && tsc -p tsconfig.module.json && tsc -p tsconfig.esm.json && node tools/post-build.js", + "prepublishOnly": "npm run build" + }, + "author": "Marvin Hagemeister ", + "repository": { + "type": "git", + "url": "https://github.com/marvinhagemeister/kolorist.git" + }, + "license": "MIT", + "devDependencies": { + "@changesets/cli": "^2.26.0", + "@esbuild-kit/cjs-loader": "^2.4.1", + "@types/mocha": "^8.2.1", + "@types/node": "^14.14.35", + "mocha": "^8.3.2", + "node-pty": "^0.10.0", + "prettier": "^2.2.1", + "rimraf": "^3.0.2", + "typescript": "^4.2.3" + }, + "exports": { + ".": { + "types": "./dist/types/index.d.ts", + "browser": "./dist/module/index.js", + "import": "./dist/esm/index.mjs", + "require": "./dist/cjs/index.js" + }, + "./package.json": "./package.json", + "./*": "./*" + }, + "files": [ + "dist/" + ], + "prettier": { + "useTabs": true, + "arrowParens": "avoid", + "singleQuote": true + } +} diff --git a/tools/ui/node_modules/layout-base/.babelrc b/tools/ui/node_modules/layout-base/.babelrc new file mode 100644 index 0000000000000000000000000000000000000000..002b4aa0d58ec481a2688d3c0b66e9069e5d6adb --- /dev/null +++ b/tools/ui/node_modules/layout-base/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["env"] +} diff --git a/tools/ui/node_modules/layout-base/LICENSE b/tools/ui/node_modules/layout-base/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..6553af2e92cf87902b380f873971628c883788ed --- /dev/null +++ b/tools/ui/node_modules/layout-base/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 iVis@Bilkent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tools/ui/node_modules/layout-base/README.md b/tools/ui/node_modules/layout-base/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b08d3fb7edf6ea4cc5ab3ad8f5e76b904e706406 --- /dev/null +++ b/tools/ui/node_modules/layout-base/README.md @@ -0,0 +1,20 @@ +layout-base +================================================================================ + +## Description + +This repository implements a basic layout model and some utilities for Cytoscape.js layout extensions. + +## Usage instructions + +Add `layout-base` as a dependecy to your layout extension. + +`require()` in the extension to reach functionality: + + * `var Integer = require(layout-base).Integer`, + * `var Layout = require(layout-base).Layout`, + * `...` + + For a usage example, see [cose-base](https://github.com/iVis-at-Bilkent/cose-base) or [avsdf-base](https://github.com/iVis-at-Bilkent/avsdf-base). + + ![](https://github.com/iVis-at-Bilkent/layout-base/blob/master/layout-schema.png) diff --git a/tools/ui/node_modules/layout-base/bower.json b/tools/ui/node_modules/layout-base/bower.json new file mode 100644 index 0000000000000000000000000000000000000000..24f74de75d826c71c901136533823f9fbb020d55 --- /dev/null +++ b/tools/ui/node_modules/layout-base/bower.json @@ -0,0 +1,20 @@ +{ + "name": "layout-base", + "description": "Basic layout model and some utilities for Cytoscape.js layout extensions", + "main": "layout-base.js", + "repository": { + "type": "git", + "url": "https://github.com/iVis-at-Bilkent/layout-base.git" + }, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "keywords": [ + "layout" + ], + "license": "MIT" +} diff --git a/tools/ui/node_modules/layout-base/index.js b/tools/ui/node_modules/layout-base/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b4b24f4b566d02a91d3b6e8febd27b6b312c4a49 --- /dev/null +++ b/tools/ui/node_modules/layout-base/index.js @@ -0,0 +1,36 @@ +'use strict'; + +let layoutBase = function(){ + return; +}; + +layoutBase.FDLayout = require('./src/fd/FDLayout'); +layoutBase.FDLayoutConstants = require('./src/fd/FDLayoutConstants'); +layoutBase.FDLayoutEdge = require('./src/fd/FDLayoutEdge'); +layoutBase.FDLayoutNode = require('./src/fd/FDLayoutNode'); +layoutBase.DimensionD = require('./src/util/DimensionD'); +layoutBase.HashMap = require('./src/util/HashMap'); +layoutBase.HashSet = require('./src/util/HashSet'); +layoutBase.IGeometry = require('./src/util/IGeometry'); +layoutBase.IMath = require('./src/util/IMath'); +layoutBase.Integer = require('./src/util/Integer'); +layoutBase.Point = require('./src/util/Point'); +layoutBase.PointD = require('./src/util/PointD'); +layoutBase.RandomSeed = require('./src/util/RandomSeed'); +layoutBase.RectangleD = require('./src/util/RectangleD'); +layoutBase.Transform = require('./src/util/Transform'); +layoutBase.UniqueIDGeneretor = require('./src/util/UniqueIDGeneretor'); +layoutBase.Quicksort = require('./src/util/Quicksort'); +layoutBase.LinkedList = require('./src/util/LinkedList'); +layoutBase.LGraphObject = require('./src/LGraphObject'); +layoutBase.LGraph = require('./src/LGraph'); +layoutBase.LEdge = require('./src/LEdge'); +layoutBase.LGraphManager = require('./src/LGraphManager'); +layoutBase.LNode = require('./src/LNode'); +layoutBase.Layout = require('./src/Layout'); +layoutBase.LayoutConstants = require('./src/LayoutConstants'); +layoutBase.NeedlemanWunsch = require('./src/util/alignment/NeedlemanWunsch'); + +module.exports = layoutBase; + + diff --git a/tools/ui/node_modules/layout-base/layout-base.js b/tools/ui/node_modules/layout-base/layout-base.js new file mode 100644 index 0000000000000000000000000000000000000000..20e3d637686e98802f77c9597e030cae3426666f --- /dev/null +++ b/tools/ui/node_modules/layout-base/layout-base.js @@ -0,0 +1,4334 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["layoutBase"] = factory(); + else + root["layoutBase"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 26); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function LayoutConstants() {} + +/** + * Layout Quality: 0:draft, 1:default, 2:proof + */ +LayoutConstants.QUALITY = 1; + +/** + * Default parameters + */ +LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false; +LayoutConstants.DEFAULT_INCREMENTAL = false; +LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true; +LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false; +LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50; +LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false; + +// ----------------------------------------------------------------------------- +// Section: General other constants +// ----------------------------------------------------------------------------- +/* + * Margins of a graph to be applied on bouding rectangle of its contents. We + * assume margins on all four sides to be uniform. + */ +LayoutConstants.DEFAULT_GRAPH_MARGIN = 15; + +/* + * Whether to consider labels in node dimensions or not + */ +LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false; + +/* + * Default dimension of a non-compound node. + */ +LayoutConstants.SIMPLE_NODE_SIZE = 40; + +/* + * Default dimension of a non-compound node. + */ +LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2; + +/* + * Empty compound node size. When a compound node is empty, its both + * dimensions should be of this value. + */ +LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40; + +/* + * Minimum length that an edge should take during layout + */ +LayoutConstants.MIN_EDGE_LENGTH = 1; + +/* + * World boundaries that layout operates on + */ +LayoutConstants.WORLD_BOUNDARY = 1000000; + +/* + * World boundaries that random positioning can be performed with + */ +LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1000; + +/* + * Coordinates of the world center + */ +LayoutConstants.WORLD_CENTER_X = 1200; +LayoutConstants.WORLD_CENTER_Y = 900; + +module.exports = LayoutConstants; + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LGraphObject = __webpack_require__(2); +var IGeometry = __webpack_require__(8); +var IMath = __webpack_require__(9); + +function LEdge(source, target, vEdge) { + LGraphObject.call(this, vEdge); + + this.isOverlapingSourceAndTarget = false; + this.vGraphObject = vEdge; + this.bendpoints = []; + this.source = source; + this.target = target; +} + +LEdge.prototype = Object.create(LGraphObject.prototype); + +for (var prop in LGraphObject) { + LEdge[prop] = LGraphObject[prop]; +} + +LEdge.prototype.getSource = function () { + return this.source; +}; + +LEdge.prototype.getTarget = function () { + return this.target; +}; + +LEdge.prototype.isInterGraph = function () { + return this.isInterGraph; +}; + +LEdge.prototype.getLength = function () { + return this.length; +}; + +LEdge.prototype.isOverlapingSourceAndTarget = function () { + return this.isOverlapingSourceAndTarget; +}; + +LEdge.prototype.getBendpoints = function () { + return this.bendpoints; +}; + +LEdge.prototype.getLca = function () { + return this.lca; +}; + +LEdge.prototype.getSourceInLca = function () { + return this.sourceInLca; +}; + +LEdge.prototype.getTargetInLca = function () { + return this.targetInLca; +}; + +LEdge.prototype.getOtherEnd = function (node) { + if (this.source === node) { + return this.target; + } else if (this.target === node) { + return this.source; + } else { + throw "Node is not incident with this edge"; + } +}; + +LEdge.prototype.getOtherEndInGraph = function (node, graph) { + var otherEnd = this.getOtherEnd(node); + var root = graph.getGraphManager().getRoot(); + + while (true) { + if (otherEnd.getOwner() == graph) { + return otherEnd; + } + + if (otherEnd.getOwner() == root) { + break; + } + + otherEnd = otherEnd.getOwner().getParent(); + } + + return null; +}; + +LEdge.prototype.updateLength = function () { + var clipPointCoordinates = new Array(4); + + this.isOverlapingSourceAndTarget = IGeometry.getIntersection(this.target.getRect(), this.source.getRect(), clipPointCoordinates); + + if (!this.isOverlapingSourceAndTarget) { + this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2]; + this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3]; + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); + } +}; + +LEdge.prototype.updateLengthSimple = function () { + this.lengthX = this.target.getCenterX() - this.source.getCenterX(); + this.lengthY = this.target.getCenterY() - this.source.getCenterY(); + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); +}; + +module.exports = LEdge; + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function LGraphObject(vGraphObject) { + this.vGraphObject = vGraphObject; +} + +module.exports = LGraphObject; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LGraphObject = __webpack_require__(2); +var Integer = __webpack_require__(10); +var RectangleD = __webpack_require__(13); +var LayoutConstants = __webpack_require__(0); +var RandomSeed = __webpack_require__(16); +var PointD = __webpack_require__(4); + +function LNode(gm, loc, size, vNode) { + //Alternative constructor 1 : LNode(LGraphManager gm, Point loc, Dimension size, Object vNode) + if (size == null && vNode == null) { + vNode = loc; + } + + LGraphObject.call(this, vNode); + + //Alternative constructor 2 : LNode(Layout layout, Object vNode) + if (gm.graphManager != null) gm = gm.graphManager; + + this.estimatedSize = Integer.MIN_VALUE; + this.inclusionTreeDepth = Integer.MAX_VALUE; + this.vGraphObject = vNode; + this.edges = []; + this.graphManager = gm; + + if (size != null && loc != null) this.rect = new RectangleD(loc.x, loc.y, size.width, size.height);else this.rect = new RectangleD(); +} + +LNode.prototype = Object.create(LGraphObject.prototype); +for (var prop in LGraphObject) { + LNode[prop] = LGraphObject[prop]; +} + +LNode.prototype.getEdges = function () { + return this.edges; +}; + +LNode.prototype.getChild = function () { + return this.child; +}; + +LNode.prototype.getOwner = function () { + // if (this.owner != null) { + // if (!(this.owner == null || this.owner.getNodes().indexOf(this) > -1)) { + // throw "assert failed"; + // } + // } + + return this.owner; +}; + +LNode.prototype.getWidth = function () { + return this.rect.width; +}; + +LNode.prototype.setWidth = function (width) { + this.rect.width = width; +}; + +LNode.prototype.getHeight = function () { + return this.rect.height; +}; + +LNode.prototype.setHeight = function (height) { + this.rect.height = height; +}; + +LNode.prototype.getCenterX = function () { + return this.rect.x + this.rect.width / 2; +}; + +LNode.prototype.getCenterY = function () { + return this.rect.y + this.rect.height / 2; +}; + +LNode.prototype.getCenter = function () { + return new PointD(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2); +}; + +LNode.prototype.getLocation = function () { + return new PointD(this.rect.x, this.rect.y); +}; + +LNode.prototype.getRect = function () { + return this.rect; +}; + +LNode.prototype.getDiagonal = function () { + return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height); +}; + +/** + * This method returns half the diagonal length of this node. + */ +LNode.prototype.getHalfTheDiagonal = function () { + return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2; +}; + +LNode.prototype.setRect = function (upperLeft, dimension) { + this.rect.x = upperLeft.x; + this.rect.y = upperLeft.y; + this.rect.width = dimension.width; + this.rect.height = dimension.height; +}; + +LNode.prototype.setCenter = function (cx, cy) { + this.rect.x = cx - this.rect.width / 2; + this.rect.y = cy - this.rect.height / 2; +}; + +LNode.prototype.setLocation = function (x, y) { + this.rect.x = x; + this.rect.y = y; +}; + +LNode.prototype.moveBy = function (dx, dy) { + this.rect.x += dx; + this.rect.y += dy; +}; + +LNode.prototype.getEdgeListToNode = function (to) { + var edgeList = []; + var edge; + var self = this; + + self.edges.forEach(function (edge) { + + if (edge.target == to) { + if (edge.source != self) throw "Incorrect edge source!"; + + edgeList.push(edge); + } + }); + + return edgeList; +}; + +LNode.prototype.getEdgesBetween = function (other) { + var edgeList = []; + var edge; + + var self = this; + self.edges.forEach(function (edge) { + + if (!(edge.source == self || edge.target == self)) throw "Incorrect edge source and/or target"; + + if (edge.target == other || edge.source == other) { + edgeList.push(edge); + } + }); + + return edgeList; +}; + +LNode.prototype.getNeighborsList = function () { + var neighbors = new Set(); + + var self = this; + self.edges.forEach(function (edge) { + + if (edge.source == self) { + neighbors.add(edge.target); + } else { + if (edge.target != self) { + throw "Incorrect incidency!"; + } + + neighbors.add(edge.source); + } + }); + + return neighbors; +}; + +LNode.prototype.withChildren = function () { + var withNeighborsList = new Set(); + var childNode; + var children; + + withNeighborsList.add(this); + + if (this.child != null) { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + children = childNode.withChildren(); + children.forEach(function (node) { + withNeighborsList.add(node); + }); + } + } + + return withNeighborsList; +}; + +LNode.prototype.getNoOfChildren = function () { + var noOfChildren = 0; + var childNode; + + if (this.child == null) { + noOfChildren = 1; + } else { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + + noOfChildren += childNode.getNoOfChildren(); + } + } + + if (noOfChildren == 0) { + noOfChildren = 1; + } + return noOfChildren; +}; + +LNode.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; +}; + +LNode.prototype.calcEstimatedSize = function () { + if (this.child == null) { + return this.estimatedSize = (this.rect.width + this.rect.height) / 2; + } else { + this.estimatedSize = this.child.calcEstimatedSize(); + this.rect.width = this.estimatedSize; + this.rect.height = this.estimatedSize; + + return this.estimatedSize; + } +}; + +LNode.prototype.scatter = function () { + var randomCenterX; + var randomCenterY; + + var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterX = LayoutConstants.WORLD_CENTER_X + RandomSeed.nextDouble() * (maxX - minX) + minX; + + var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterY = LayoutConstants.WORLD_CENTER_Y + RandomSeed.nextDouble() * (maxY - minY) + minY; + + this.rect.x = randomCenterX; + this.rect.y = randomCenterY; +}; + +LNode.prototype.updateBounds = function () { + if (this.getChild() == null) { + throw "assert failed"; + } + if (this.getChild().getNodes().length != 0) { + // wrap the children nodes by re-arranging the boundaries + var childGraph = this.getChild(); + childGraph.updateBounds(true); + + this.rect.x = childGraph.getLeft(); + this.rect.y = childGraph.getTop(); + + this.setWidth(childGraph.getRight() - childGraph.getLeft()); + this.setHeight(childGraph.getBottom() - childGraph.getTop()); + + // Update compound bounds considering its label properties + if (LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS) { + + var width = childGraph.getRight() - childGraph.getLeft(); + var height = childGraph.getBottom() - childGraph.getTop(); + + if (this.labelWidth > width) { + this.rect.x -= (this.labelWidth - width) / 2; + this.setWidth(this.labelWidth); + } + + if (this.labelHeight > height) { + if (this.labelPos == "center") { + this.rect.y -= (this.labelHeight - height) / 2; + } else if (this.labelPos == "top") { + this.rect.y -= this.labelHeight - height; + } + this.setHeight(this.labelHeight); + } + } + } +}; + +LNode.prototype.getInclusionTreeDepth = function () { + if (this.inclusionTreeDepth == Integer.MAX_VALUE) { + throw "assert failed"; + } + return this.inclusionTreeDepth; +}; + +LNode.prototype.transform = function (trans) { + var left = this.rect.x; + + if (left > LayoutConstants.WORLD_BOUNDARY) { + left = LayoutConstants.WORLD_BOUNDARY; + } else if (left < -LayoutConstants.WORLD_BOUNDARY) { + left = -LayoutConstants.WORLD_BOUNDARY; + } + + var top = this.rect.y; + + if (top > LayoutConstants.WORLD_BOUNDARY) { + top = LayoutConstants.WORLD_BOUNDARY; + } else if (top < -LayoutConstants.WORLD_BOUNDARY) { + top = -LayoutConstants.WORLD_BOUNDARY; + } + + var leftTop = new PointD(left, top); + var vLeftTop = trans.inverseTransformPoint(leftTop); + + this.setLocation(vLeftTop.x, vLeftTop.y); +}; + +LNode.prototype.getLeft = function () { + return this.rect.x; +}; + +LNode.prototype.getRight = function () { + return this.rect.x + this.rect.width; +}; + +LNode.prototype.getTop = function () { + return this.rect.y; +}; + +LNode.prototype.getBottom = function () { + return this.rect.y + this.rect.height; +}; + +LNode.prototype.getParent = function () { + if (this.owner == null) { + return null; + } + + return this.owner.getParent(); +}; + +module.exports = LNode; + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function PointD(x, y) { + if (x == null && y == null) { + this.x = 0; + this.y = 0; + } else { + this.x = x; + this.y = y; + } +} + +PointD.prototype.getX = function () { + return this.x; +}; + +PointD.prototype.getY = function () { + return this.y; +}; + +PointD.prototype.setX = function (x) { + this.x = x; +}; + +PointD.prototype.setY = function (y) { + this.y = y; +}; + +PointD.prototype.getDifference = function (pt) { + return new DimensionD(this.x - pt.x, this.y - pt.y); +}; + +PointD.prototype.getCopy = function () { + return new PointD(this.x, this.y); +}; + +PointD.prototype.translate = function (dim) { + this.x += dim.width; + this.y += dim.height; + return this; +}; + +module.exports = PointD; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LGraphObject = __webpack_require__(2); +var Integer = __webpack_require__(10); +var LayoutConstants = __webpack_require__(0); +var LGraphManager = __webpack_require__(6); +var LNode = __webpack_require__(3); +var LEdge = __webpack_require__(1); +var RectangleD = __webpack_require__(13); +var Point = __webpack_require__(12); +var LinkedList = __webpack_require__(11); + +function LGraph(parent, obj2, vGraph) { + LGraphObject.call(this, vGraph); + this.estimatedSize = Integer.MIN_VALUE; + this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN; + this.edges = []; + this.nodes = []; + this.isConnected = false; + this.parent = parent; + + if (obj2 != null && obj2 instanceof LGraphManager) { + this.graphManager = obj2; + } else if (obj2 != null && obj2 instanceof Layout) { + this.graphManager = obj2.graphManager; + } +} + +LGraph.prototype = Object.create(LGraphObject.prototype); +for (var prop in LGraphObject) { + LGraph[prop] = LGraphObject[prop]; +} + +LGraph.prototype.getNodes = function () { + return this.nodes; +}; + +LGraph.prototype.getEdges = function () { + return this.edges; +}; + +LGraph.prototype.getGraphManager = function () { + return this.graphManager; +}; + +LGraph.prototype.getParent = function () { + return this.parent; +}; + +LGraph.prototype.getLeft = function () { + return this.left; +}; + +LGraph.prototype.getRight = function () { + return this.right; +}; + +LGraph.prototype.getTop = function () { + return this.top; +}; + +LGraph.prototype.getBottom = function () { + return this.bottom; +}; + +LGraph.prototype.isConnected = function () { + return this.isConnected; +}; + +LGraph.prototype.add = function (obj1, sourceNode, targetNode) { + if (sourceNode == null && targetNode == null) { + var newNode = obj1; + if (this.graphManager == null) { + throw "Graph has no graph mgr!"; + } + if (this.getNodes().indexOf(newNode) > -1) { + throw "Node already in graph!"; + } + newNode.owner = this; + this.getNodes().push(newNode); + + return newNode; + } else { + var newEdge = obj1; + if (!(this.getNodes().indexOf(sourceNode) > -1 && this.getNodes().indexOf(targetNode) > -1)) { + throw "Source or target not in graph!"; + } + + if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) { + throw "Both owners must be this graph!"; + } + + if (sourceNode.owner != targetNode.owner) { + return null; + } + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // set as intra-graph edge + newEdge.isInterGraph = false; + + // add to graph edge list + this.getEdges().push(newEdge); + + // add to incidency lists + sourceNode.edges.push(newEdge); + + if (targetNode != sourceNode) { + targetNode.edges.push(newEdge); + } + + return newEdge; + } +}; + +LGraph.prototype.remove = function (obj) { + var node = obj; + if (obj instanceof LNode) { + if (node == null) { + throw "Node is null!"; + } + if (!(node.owner != null && node.owner == this)) { + throw "Owner graph is invalid!"; + } + if (this.graphManager == null) { + throw "Owner graph manager is invalid!"; + } + // remove incident edges first (make a copy to do it safely) + var edgesToBeRemoved = node.edges.slice(); + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + + if (edge.isInterGraph) { + this.graphManager.remove(edge); + } else { + edge.source.owner.remove(edge); + } + } + + // now the node itself + var index = this.nodes.indexOf(node); + if (index == -1) { + throw "Node not in owner node list!"; + } + + this.nodes.splice(index, 1); + } else if (obj instanceof LEdge) { + var edge = obj; + if (edge == null) { + throw "Edge is null!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + if (!(edge.source.owner != null && edge.target.owner != null && edge.source.owner == this && edge.target.owner == this)) { + throw "Source and/or target owner is invalid!"; + } + + var sourceIndex = edge.source.edges.indexOf(edge); + var targetIndex = edge.target.edges.indexOf(edge); + if (!(sourceIndex > -1 && targetIndex > -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + edge.source.edges.splice(sourceIndex, 1); + + if (edge.target != edge.source) { + edge.target.edges.splice(targetIndex, 1); + } + + var index = edge.source.owner.getEdges().indexOf(edge); + if (index == -1) { + throw "Not in owner's edge list!"; + } + + edge.source.owner.getEdges().splice(index, 1); + } +}; + +LGraph.prototype.updateLeftTop = function () { + var top = Integer.MAX_VALUE; + var left = Integer.MAX_VALUE; + var nodeTop; + var nodeLeft; + var margin; + + var nodes = this.getNodes(); + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeTop = lNode.getTop(); + nodeLeft = lNode.getLeft(); + + if (top > nodeTop) { + top = nodeTop; + } + + if (left > nodeLeft) { + left = nodeLeft; + } + } + + // Do we have any nodes in this graph? + if (top == Integer.MAX_VALUE) { + return null; + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = left - margin; + this.top = top - margin; + + // Apply the margins and return the result + return new Point(this.left, this.top); +}; + +LGraph.prototype.updateBounds = function (recursive) { + // calculate bounds + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + var margin; + + var nodes = this.nodes; + var s = nodes.length; + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + + if (recursive && lNode.child != null) { + lNode.updateBounds(); + } + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + if (left == Integer.MAX_VALUE) { + this.left = this.parent.getLeft(); + this.right = this.parent.getRight(); + this.top = this.parent.getTop(); + this.bottom = this.parent.getBottom(); + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = boundingRect.x - margin; + this.right = boundingRect.x + boundingRect.width + margin; + this.top = boundingRect.y - margin; + this.bottom = boundingRect.y + boundingRect.height + margin; +}; + +LGraph.calculateBounds = function (nodes) { + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + + return boundingRect; +}; + +LGraph.prototype.getInclusionTreeDepth = function () { + if (this == this.graphManager.getRoot()) { + return 1; + } else { + return this.parent.getInclusionTreeDepth(); + } +}; + +LGraph.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; +}; + +LGraph.prototype.calcEstimatedSize = function () { + var size = 0; + var nodes = this.nodes; + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + size += lNode.calcEstimatedSize(); + } + + if (size == 0) { + this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE; + } else { + this.estimatedSize = size / Math.sqrt(this.nodes.length); + } + + return this.estimatedSize; +}; + +LGraph.prototype.updateConnected = function () { + var self = this; + if (this.nodes.length == 0) { + this.isConnected = true; + return; + } + + var queue = new LinkedList(); + var visited = new Set(); + var currentNode = this.nodes[0]; + var neighborEdges; + var currentNeighbor; + var childrenOfNode = currentNode.withChildren(); + childrenOfNode.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + + while (queue.length !== 0) { + currentNode = queue.shift(); + + // Traverse all neighbors of this node + neighborEdges = currentNode.getEdges(); + var size = neighborEdges.length; + for (var i = 0; i < size; i++) { + var neighborEdge = neighborEdges[i]; + currentNeighbor = neighborEdge.getOtherEndInGraph(currentNode, this); + + // Add unvisited neighbors to the list to visit + if (currentNeighbor != null && !visited.has(currentNeighbor)) { + var childrenOfNeighbor = currentNeighbor.withChildren(); + + childrenOfNeighbor.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + } + } + } + + this.isConnected = false; + + if (visited.size >= this.nodes.length) { + var noOfVisitedInThisGraph = 0; + + visited.forEach(function (visitedNode) { + if (visitedNode.owner == self) { + noOfVisitedInThisGraph++; + } + }); + + if (noOfVisitedInThisGraph == this.nodes.length) { + this.isConnected = true; + } + } +}; + +module.exports = LGraph; + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LGraph; +var LEdge = __webpack_require__(1); + +function LGraphManager(layout) { + LGraph = __webpack_require__(5); // It may be better to initilize this out of this function but it gives an error (Right-hand side of 'instanceof' is not callable) now. + this.layout = layout; + + this.graphs = []; + this.edges = []; +} + +LGraphManager.prototype.addRoot = function () { + var ngraph = this.layout.newGraph(); + var nnode = this.layout.newNode(null); + var root = this.add(ngraph, nnode); + this.setRootGraph(root); + return this.rootGraph; +}; + +LGraphManager.prototype.add = function (newGraph, parentNode, newEdge, sourceNode, targetNode) { + //there are just 2 parameters are passed then it adds an LGraph else it adds an LEdge + if (newEdge == null && sourceNode == null && targetNode == null) { + if (newGraph == null) { + throw "Graph is null!"; + } + if (parentNode == null) { + throw "Parent node is null!"; + } + if (this.graphs.indexOf(newGraph) > -1) { + throw "Graph already in this graph mgr!"; + } + + this.graphs.push(newGraph); + + if (newGraph.parent != null) { + throw "Already has a parent!"; + } + if (parentNode.child != null) { + throw "Already has a child!"; + } + + newGraph.parent = parentNode; + parentNode.child = newGraph; + + return newGraph; + } else { + //change the order of the parameters + targetNode = newEdge; + sourceNode = parentNode; + newEdge = newGraph; + var sourceGraph = sourceNode.getOwner(); + var targetGraph = targetNode.getOwner(); + + if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) { + throw "Source not in this graph mgr!"; + } + if (!(targetGraph != null && targetGraph.getGraphManager() == this)) { + throw "Target not in this graph mgr!"; + } + + if (sourceGraph == targetGraph) { + newEdge.isInterGraph = false; + return sourceGraph.add(newEdge, sourceNode, targetNode); + } else { + newEdge.isInterGraph = true; + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // add edge to inter-graph edge list + if (this.edges.indexOf(newEdge) > -1) { + throw "Edge already in inter-graph edge list!"; + } + + this.edges.push(newEdge); + + // add edge to source and target incidency lists + if (!(newEdge.source != null && newEdge.target != null)) { + throw "Edge source and/or target is null!"; + } + + if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) { + throw "Edge already in source and/or target incidency list!"; + } + + newEdge.source.edges.push(newEdge); + newEdge.target.edges.push(newEdge); + + return newEdge; + } + } +}; + +LGraphManager.prototype.remove = function (lObj) { + if (lObj instanceof LGraph) { + var graph = lObj; + if (graph.getGraphManager() != this) { + throw "Graph not in this graph mgr"; + } + if (!(graph == this.rootGraph || graph.parent != null && graph.parent.graphManager == this)) { + throw "Invalid parent node!"; + } + + // first the edges (make a copy to do it safely) + var edgesToBeRemoved = []; + + edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges()); + + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + graph.remove(edge); + } + + // then the nodes (make a copy to do it safely) + var nodesToBeRemoved = []; + + nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes()); + + var node; + s = nodesToBeRemoved.length; + for (var i = 0; i < s; i++) { + node = nodesToBeRemoved[i]; + graph.remove(node); + } + + // check if graph is the root + if (graph == this.rootGraph) { + this.setRootGraph(null); + } + + // now remove the graph itself + var index = this.graphs.indexOf(graph); + this.graphs.splice(index, 1); + + // also reset the parent of the graph + graph.parent = null; + } else if (lObj instanceof LEdge) { + edge = lObj; + if (edge == null) { + throw "Edge is null!"; + } + if (!edge.isInterGraph) { + throw "Not an inter-graph edge!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + + // remove edge from source and target nodes' incidency lists + + if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + var index = edge.source.edges.indexOf(edge); + edge.source.edges.splice(index, 1); + index = edge.target.edges.indexOf(edge); + edge.target.edges.splice(index, 1); + + // remove edge from owner graph manager's inter-graph edge list + + if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) { + throw "Edge owner graph or owner graph manager is null!"; + } + if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) { + throw "Not in owner graph manager's edge list!"; + } + + var index = edge.source.owner.getGraphManager().edges.indexOf(edge); + edge.source.owner.getGraphManager().edges.splice(index, 1); + } +}; + +LGraphManager.prototype.updateBounds = function () { + this.rootGraph.updateBounds(true); +}; + +LGraphManager.prototype.getGraphs = function () { + return this.graphs; +}; + +LGraphManager.prototype.getAllNodes = function () { + if (this.allNodes == null) { + var nodeList = []; + var graphs = this.getGraphs(); + var s = graphs.length; + for (var i = 0; i < s; i++) { + nodeList = nodeList.concat(graphs[i].getNodes()); + } + this.allNodes = nodeList; + } + return this.allNodes; +}; + +LGraphManager.prototype.resetAllNodes = function () { + this.allNodes = null; +}; + +LGraphManager.prototype.resetAllEdges = function () { + this.allEdges = null; +}; + +LGraphManager.prototype.resetAllNodesToApplyGravitation = function () { + this.allNodesToApplyGravitation = null; +}; + +LGraphManager.prototype.getAllEdges = function () { + if (this.allEdges == null) { + var edgeList = []; + var graphs = this.getGraphs(); + var s = graphs.length; + for (var i = 0; i < graphs.length; i++) { + edgeList = edgeList.concat(graphs[i].getEdges()); + } + + edgeList = edgeList.concat(this.edges); + + this.allEdges = edgeList; + } + return this.allEdges; +}; + +LGraphManager.prototype.getAllNodesToApplyGravitation = function () { + return this.allNodesToApplyGravitation; +}; + +LGraphManager.prototype.setAllNodesToApplyGravitation = function (nodeList) { + if (this.allNodesToApplyGravitation != null) { + throw "assert failed"; + } + + this.allNodesToApplyGravitation = nodeList; +}; + +LGraphManager.prototype.getRoot = function () { + return this.rootGraph; +}; + +LGraphManager.prototype.setRootGraph = function (graph) { + if (graph.getGraphManager() != this) { + throw "Root not in this graph mgr!"; + } + + this.rootGraph = graph; + // root graph must have a root node associated with it for convenience + if (graph.parent == null) { + graph.parent = this.layout.newNode("Root node"); + } +}; + +LGraphManager.prototype.getLayout = function () { + return this.layout; +}; + +LGraphManager.prototype.isOneAncestorOfOther = function (firstNode, secondNode) { + if (!(firstNode != null && secondNode != null)) { + throw "assert failed"; + } + + if (firstNode == secondNode) { + return true; + } + // Is second node an ancestor of the first one? + var ownerGraph = firstNode.getOwner(); + var parentNode; + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == secondNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + // Is first node an ancestor of the second one? + ownerGraph = secondNode.getOwner(); + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == firstNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + + return false; +}; + +LGraphManager.prototype.calcLowestCommonAncestors = function () { + var edge; + var sourceNode; + var targetNode; + var sourceAncestorGraph; + var targetAncestorGraph; + + var edges = this.getAllEdges(); + var s = edges.length; + for (var i = 0; i < s; i++) { + edge = edges[i]; + + sourceNode = edge.source; + targetNode = edge.target; + edge.lca = null; + edge.sourceInLca = sourceNode; + edge.targetInLca = targetNode; + + if (sourceNode == targetNode) { + edge.lca = sourceNode.getOwner(); + continue; + } + + sourceAncestorGraph = sourceNode.getOwner(); + + while (edge.lca == null) { + edge.targetInLca = targetNode; + targetAncestorGraph = targetNode.getOwner(); + + while (edge.lca == null) { + if (targetAncestorGraph == sourceAncestorGraph) { + edge.lca = targetAncestorGraph; + break; + } + + if (targetAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca != null) { + throw "assert failed"; + } + edge.targetInLca = targetAncestorGraph.getParent(); + targetAncestorGraph = edge.targetInLca.getOwner(); + } + + if (sourceAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca == null) { + edge.sourceInLca = sourceAncestorGraph.getParent(); + sourceAncestorGraph = edge.sourceInLca.getOwner(); + } + } + + if (edge.lca == null) { + throw "assert failed"; + } + } +}; + +LGraphManager.prototype.calcLowestCommonAncestor = function (firstNode, secondNode) { + if (firstNode == secondNode) { + return firstNode.getOwner(); + } + var firstOwnerGraph = firstNode.getOwner(); + + do { + if (firstOwnerGraph == null) { + break; + } + var secondOwnerGraph = secondNode.getOwner(); + + do { + if (secondOwnerGraph == null) { + break; + } + + if (secondOwnerGraph == firstOwnerGraph) { + return secondOwnerGraph; + } + secondOwnerGraph = secondOwnerGraph.getParent().getOwner(); + } while (true); + + firstOwnerGraph = firstOwnerGraph.getParent().getOwner(); + } while (true); + + return firstOwnerGraph; +}; + +LGraphManager.prototype.calcInclusionTreeDepths = function (graph, depth) { + if (graph == null && depth == null) { + graph = this.rootGraph; + depth = 1; + } + var node; + + var nodes = graph.getNodes(); + var s = nodes.length; + for (var i = 0; i < s; i++) { + node = nodes[i]; + node.inclusionTreeDepth = depth; + + if (node.child != null) { + this.calcInclusionTreeDepths(node.child, depth + 1); + } + } +}; + +LGraphManager.prototype.includesInvalidEdge = function () { + var edge; + + var s = this.edges.length; + for (var i = 0; i < s; i++) { + edge = this.edges[i]; + + if (this.isOneAncestorOfOther(edge.source, edge.target)) { + return true; + } + } + return false; +}; + +module.exports = LGraphManager; + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LayoutConstants = __webpack_require__(0); + +function FDLayoutConstants() {} + +//FDLayoutConstants inherits static props in LayoutConstants +for (var prop in LayoutConstants) { + FDLayoutConstants[prop] = LayoutConstants[prop]; +} + +FDLayoutConstants.MAX_ITERATIONS = 2500; + +FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50; +FDLayoutConstants.DEFAULT_SPRING_STRENGTH = 0.45; +FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500.0; +FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = 0.4; +FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1.0; +FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8; +FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5; +FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true; +FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true; +FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3; +FDLayoutConstants.COOLING_ADAPTATION_FACTOR = 0.33; +FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1000; +FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5000; +FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100.0; +FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3; +FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0; +FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100; +FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1; +FDLayoutConstants.MIN_EDGE_LENGTH = 1; +FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10; + +module.exports = FDLayoutConstants; + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/** + * This class maintains a list of static geometry related utility methods. + * + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + +var Point = __webpack_require__(12); + +function IGeometry() {} + +/** + * This method calculates *half* the amount in x and y directions of the two + * input rectangles needed to separate them keeping their respective + * positioning, and returns the result in the input array. An input + * separation buffer added to the amount in both directions. We assume that + * the two rectangles do intersect. + */ +IGeometry.calcSeparationAmount = function (rectA, rectB, overlapAmount, separationBuffer) { + if (!rectA.intersects(rectB)) { + throw "assert failed"; + } + + var directions = new Array(2); + + this.decideDirectionsForOverlappingNodes(rectA, rectB, directions); + + overlapAmount[0] = Math.min(rectA.getRight(), rectB.getRight()) - Math.max(rectA.x, rectB.x); + overlapAmount[1] = Math.min(rectA.getBottom(), rectB.getBottom()) - Math.max(rectA.y, rectB.y); + + // update the overlapping amounts for the following cases: + if (rectA.getX() <= rectB.getX() && rectA.getRight() >= rectB.getRight()) { + /* Case x.1: + * + * rectA + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectB + */ + overlapAmount[0] += Math.min(rectB.getX() - rectA.getX(), rectA.getRight() - rectB.getRight()); + } else if (rectB.getX() <= rectA.getX() && rectB.getRight() >= rectA.getRight()) { + /* Case x.2: + * + * rectB + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectA + */ + overlapAmount[0] += Math.min(rectA.getX() - rectB.getX(), rectB.getRight() - rectA.getRight()); + } + if (rectA.getY() <= rectB.getY() && rectA.getBottom() >= rectB.getBottom()) { + /* Case y.1: + * ________ rectA + * | + * | + * ______|____ rectB + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectB.getY() - rectA.getY(), rectA.getBottom() - rectB.getBottom()); + } else if (rectB.getY() <= rectA.getY() && rectB.getBottom() >= rectA.getBottom()) { + /* Case y.2: + * ________ rectB + * | + * | + * ______|____ rectA + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectA.getY() - rectB.getY(), rectB.getBottom() - rectA.getBottom()); + } + + // find slope of the line passes two centers + var slope = Math.abs((rectB.getCenterY() - rectA.getCenterY()) / (rectB.getCenterX() - rectA.getCenterX())); + // if centers are overlapped + if (rectB.getCenterY() === rectA.getCenterY() && rectB.getCenterX() === rectA.getCenterX()) { + // assume the slope is 1 (45 degree) + slope = 1.0; + } + + var moveByY = slope * overlapAmount[0]; + var moveByX = overlapAmount[1] / slope; + if (overlapAmount[0] < moveByX) { + moveByX = overlapAmount[0]; + } else { + moveByY = overlapAmount[1]; + } + // return half the amount so that if each rectangle is moved by these + // amounts in opposite directions, overlap will be resolved + overlapAmount[0] = -1 * directions[0] * (moveByX / 2 + separationBuffer); + overlapAmount[1] = -1 * directions[1] * (moveByY / 2 + separationBuffer); +}; + +/** + * This method decides the separation direction of overlapping nodes + * + * if directions[0] = -1, then rectA goes left + * if directions[0] = 1, then rectA goes right + * if directions[1] = -1, then rectA goes up + * if directions[1] = 1, then rectA goes down + */ +IGeometry.decideDirectionsForOverlappingNodes = function (rectA, rectB, directions) { + if (rectA.getCenterX() < rectB.getCenterX()) { + directions[0] = -1; + } else { + directions[0] = 1; + } + + if (rectA.getCenterY() < rectB.getCenterY()) { + directions[1] = -1; + } else { + directions[1] = 1; + } +}; + +/** + * This method calculates the intersection (clipping) points of the two + * input rectangles with line segment defined by the centers of these two + * rectangles. The clipping points are saved in the input double array and + * whether or not the two rectangles overlap is returned. + */ +IGeometry.getIntersection2 = function (rectA, rectB, result) { + //result[0-1] will contain clipPoint of rectA, result[2-3] will contain clipPoint of rectB + var p1x = rectA.getCenterX(); + var p1y = rectA.getCenterY(); + var p2x = rectB.getCenterX(); + var p2y = rectB.getCenterY(); + + //if two rectangles intersect, then clipping points are centers + if (rectA.intersects(rectB)) { + result[0] = p1x; + result[1] = p1y; + result[2] = p2x; + result[3] = p2y; + return true; + } + //variables for rectA + var topLeftAx = rectA.getX(); + var topLeftAy = rectA.getY(); + var topRightAx = rectA.getRight(); + var bottomLeftAx = rectA.getX(); + var bottomLeftAy = rectA.getBottom(); + var bottomRightAx = rectA.getRight(); + var halfWidthA = rectA.getWidthHalf(); + var halfHeightA = rectA.getHeightHalf(); + //variables for rectB + var topLeftBx = rectB.getX(); + var topLeftBy = rectB.getY(); + var topRightBx = rectB.getRight(); + var bottomLeftBx = rectB.getX(); + var bottomLeftBy = rectB.getBottom(); + var bottomRightBx = rectB.getRight(); + var halfWidthB = rectB.getWidthHalf(); + var halfHeightB = rectB.getHeightHalf(); + + //flag whether clipping points are found + var clipPointAFound = false; + var clipPointBFound = false; + + // line is vertical + if (p1x === p2x) { + if (p1y > p2y) { + result[0] = p1x; + result[1] = topLeftAy; + result[2] = p2x; + result[3] = bottomLeftBy; + return false; + } else if (p1y < p2y) { + result[0] = p1x; + result[1] = bottomLeftAy; + result[2] = p2x; + result[3] = topLeftBy; + return false; + } else { + //not line, return null; + } + } + // line is horizontal + else if (p1y === p2y) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = p1y; + result[2] = topRightBx; + result[3] = p2y; + return false; + } else if (p1x < p2x) { + result[0] = topRightAx; + result[1] = p1y; + result[2] = topLeftBx; + result[3] = p2y; + return false; + } else { + //not valid line, return null; + } + } else { + //slopes of rectA's and rectB's diagonals + var slopeA = rectA.height / rectA.width; + var slopeB = rectB.height / rectB.width; + + //slope of line between center of rectA and center of rectB + var slopePrime = (p2y - p1y) / (p2x - p1x); + var cardinalDirectionA = void 0; + var cardinalDirectionB = void 0; + var tempPointAx = void 0; + var tempPointAy = void 0; + var tempPointBx = void 0; + var tempPointBy = void 0; + + //determine whether clipping point is the corner of nodeA + if (-slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = bottomLeftAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } else { + result[0] = topRightAx; + result[1] = topLeftAy; + clipPointAFound = true; + } + } else if (slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = topLeftAy; + clipPointAFound = true; + } else { + result[0] = bottomRightAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } + } + + //determine whether clipping point is the corner of nodeB + if (-slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = bottomLeftBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } else { + result[2] = topRightBx; + result[3] = topLeftBy; + clipPointBFound = true; + } + } else if (slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = topLeftBx; + result[3] = topLeftBy; + clipPointBFound = true; + } else { + result[2] = bottomRightBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } + } + + //if both clipping points are corners + if (clipPointAFound && clipPointBFound) { + return false; + } + + //determine Cardinal Direction of rectangles + if (p1x > p2x) { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 4); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 2); + } else { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 3); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 1); + } + } else { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 1); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 3); + } else { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 2); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 4); + } + } + //calculate clipping Point if it is not found before + if (!clipPointAFound) { + switch (cardinalDirectionA) { + case 1: + tempPointAy = topLeftAy; + tempPointAx = p1x + -halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 2: + tempPointAx = bottomRightAx; + tempPointAy = p1y + halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 3: + tempPointAy = bottomLeftAy; + tempPointAx = p1x + halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 4: + tempPointAx = bottomLeftAx; + tempPointAy = p1y + -halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + } + } + if (!clipPointBFound) { + switch (cardinalDirectionB) { + case 1: + tempPointBy = topLeftBy; + tempPointBx = p2x + -halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 2: + tempPointBx = bottomRightBx; + tempPointBy = p2y + halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 3: + tempPointBy = bottomLeftBy; + tempPointBx = p2x + halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 4: + tempPointBx = bottomLeftBx; + tempPointBy = p2y + -halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + } + } + } + return false; +}; + +/** + * This method returns in which cardinal direction does input point stays + * 1: North + * 2: East + * 3: South + * 4: West + */ +IGeometry.getCardinalDirection = function (slope, slopePrime, line) { + if (slope > slopePrime) { + return line; + } else { + return 1 + line % 4; + } +}; + +/** + * This method calculates the intersection of the two lines defined by + * point pairs (s1,s2) and (f1,f2). + */ +IGeometry.getIntersection = function (s1, s2, f1, f2) { + if (f2 == null) { + return this.getIntersection2(s1, s2, f1); + } + + var x1 = s1.x; + var y1 = s1.y; + var x2 = s2.x; + var y2 = s2.y; + var x3 = f1.x; + var y3 = f1.y; + var x4 = f2.x; + var y4 = f2.y; + var x = void 0, + y = void 0; // intersection point + var a1 = void 0, + a2 = void 0, + b1 = void 0, + b2 = void 0, + c1 = void 0, + c2 = void 0; // coefficients of line eqns. + var denom = void 0; + + a1 = y2 - y1; + b1 = x1 - x2; + c1 = x2 * y1 - x1 * y2; // { a1*x + b1*y + c1 = 0 is line 1 } + + a2 = y4 - y3; + b2 = x3 - x4; + c2 = x4 * y3 - x3 * y4; // { a2*x + b2*y + c2 = 0 is line 2 } + + denom = a1 * b2 - a2 * b1; + + if (denom === 0) { + return null; + } + + x = (b1 * c2 - b2 * c1) / denom; + y = (a2 * c1 - a1 * c2) / denom; + + return new Point(x, y); +}; + +/** + * This method finds and returns the angle of the vector from the + x-axis + * in clockwise direction (compatible w/ Java coordinate system!). + */ +IGeometry.angleOfVector = function (Cx, Cy, Nx, Ny) { + var C_angle = void 0; + + if (Cx !== Nx) { + C_angle = Math.atan((Ny - Cy) / (Nx - Cx)); + + if (Nx < Cx) { + C_angle += Math.PI; + } else if (Ny < Cy) { + C_angle += this.TWO_PI; + } + } else if (Ny < Cy) { + C_angle = this.ONE_AND_HALF_PI; // 270 degrees + } else { + C_angle = this.HALF_PI; // 90 degrees + } + + return C_angle; +}; + +/** + * This method checks whether the given two line segments (one with point + * p1 and p2, the other with point p3 and p4) intersect at a point other + * than these points. + */ +IGeometry.doIntersect = function (p1, p2, p3, p4) { + var a = p1.x; + var b = p1.y; + var c = p2.x; + var d = p2.y; + var p = p3.x; + var q = p3.y; + var r = p4.x; + var s = p4.y; + var det = (c - a) * (s - q) - (r - p) * (d - b); + + if (det === 0) { + return false; + } else { + var lambda = ((s - q) * (r - a) + (p - r) * (s - b)) / det; + var gamma = ((b - d) * (r - a) + (c - a) * (s - b)) / det; + return 0 < lambda && lambda < 1 && 0 < gamma && gamma < 1; + } +}; + +// ----------------------------------------------------------------------------- +// Section: Class Constants +// ----------------------------------------------------------------------------- +/** + * Some useful pre-calculated constants + */ +IGeometry.HALF_PI = 0.5 * Math.PI; +IGeometry.ONE_AND_HALF_PI = 1.5 * Math.PI; +IGeometry.TWO_PI = 2.0 * Math.PI; +IGeometry.THREE_PI = 3.0 * Math.PI; + +module.exports = IGeometry; + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function IMath() {} + +/** + * This method returns the sign of the input value. + */ +IMath.sign = function (value) { + if (value > 0) { + return 1; + } else if (value < 0) { + return -1; + } else { + return 0; + } +}; + +IMath.floor = function (value) { + return value < 0 ? Math.ceil(value) : Math.floor(value); +}; + +IMath.ceil = function (value) { + return value < 0 ? Math.floor(value) : Math.ceil(value); +}; + +module.exports = IMath; + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function Integer() {} + +Integer.MAX_VALUE = 2147483647; +Integer.MIN_VALUE = -2147483648; + +module.exports = Integer; + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var nodeFrom = function nodeFrom(value) { + return { value: value, next: null, prev: null }; +}; + +var add = function add(prev, node, next, list) { + if (prev !== null) { + prev.next = node; + } else { + list.head = node; + } + + if (next !== null) { + next.prev = node; + } else { + list.tail = node; + } + + node.prev = prev; + node.next = next; + + list.length++; + + return node; +}; + +var _remove = function _remove(node, list) { + var prev = node.prev, + next = node.next; + + + if (prev !== null) { + prev.next = next; + } else { + list.head = next; + } + + if (next !== null) { + next.prev = prev; + } else { + list.tail = prev; + } + + node.prev = node.next = null; + + list.length--; + + return node; +}; + +var LinkedList = function () { + function LinkedList(vals) { + var _this = this; + + _classCallCheck(this, LinkedList); + + this.length = 0; + this.head = null; + this.tail = null; + + if (vals != null) { + vals.forEach(function (v) { + return _this.push(v); + }); + } + } + + _createClass(LinkedList, [{ + key: "size", + value: function size() { + return this.length; + } + }, { + key: "insertBefore", + value: function insertBefore(val, otherNode) { + return add(otherNode.prev, nodeFrom(val), otherNode, this); + } + }, { + key: "insertAfter", + value: function insertAfter(val, otherNode) { + return add(otherNode, nodeFrom(val), otherNode.next, this); + } + }, { + key: "insertNodeBefore", + value: function insertNodeBefore(newNode, otherNode) { + return add(otherNode.prev, newNode, otherNode, this); + } + }, { + key: "insertNodeAfter", + value: function insertNodeAfter(newNode, otherNode) { + return add(otherNode, newNode, otherNode.next, this); + } + }, { + key: "push", + value: function push(val) { + return add(this.tail, nodeFrom(val), null, this); + } + }, { + key: "unshift", + value: function unshift(val) { + return add(null, nodeFrom(val), this.head, this); + } + }, { + key: "remove", + value: function remove(node) { + return _remove(node, this); + } + }, { + key: "pop", + value: function pop() { + return _remove(this.tail, this).value; + } + }, { + key: "popNode", + value: function popNode() { + return _remove(this.tail, this); + } + }, { + key: "shift", + value: function shift() { + return _remove(this.head, this).value; + } + }, { + key: "shiftNode", + value: function shiftNode() { + return _remove(this.head, this); + } + }, { + key: "get_object_at", + value: function get_object_at(index) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + return current.value; + } + } + }, { + key: "set_object_at", + value: function set_object_at(index, value) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + current.value = value; + } + } + }]); + + return LinkedList; +}(); + +module.exports = LinkedList; + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/* + *This class is the javascript implementation of the Point.java class in jdk + */ +function Point(x, y, p) { + this.x = null; + this.y = null; + if (x == null && y == null && p == null) { + this.x = 0; + this.y = 0; + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + this.x = x; + this.y = y; + } else if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.x = p.x; + this.y = p.y; + } +} + +Point.prototype.getX = function () { + return this.x; +}; + +Point.prototype.getY = function () { + return this.y; +}; + +Point.prototype.getLocation = function () { + return new Point(this.x, this.y); +}; + +Point.prototype.setLocation = function (x, y, p) { + if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.setLocation(p.x, p.y); + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + //if both parameters are integer just move (x,y) location + if (parseInt(x) == x && parseInt(y) == y) { + this.move(x, y); + } else { + this.x = Math.floor(x + 0.5); + this.y = Math.floor(y + 0.5); + } + } +}; + +Point.prototype.move = function (x, y) { + this.x = x; + this.y = y; +}; + +Point.prototype.translate = function (dx, dy) { + this.x += dx; + this.y += dy; +}; + +Point.prototype.equals = function (obj) { + if (obj.constructor.name == "Point") { + var pt = obj; + return this.x == pt.x && this.y == pt.y; + } + return this == obj; +}; + +Point.prototype.toString = function () { + return new Point().constructor.name + "[x=" + this.x + ",y=" + this.y + "]"; +}; + +module.exports = Point; + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function RectangleD(x, y, width, height) { + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + + if (x != null && y != null && width != null && height != null) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } +} + +RectangleD.prototype.getX = function () { + return this.x; +}; + +RectangleD.prototype.setX = function (x) { + this.x = x; +}; + +RectangleD.prototype.getY = function () { + return this.y; +}; + +RectangleD.prototype.setY = function (y) { + this.y = y; +}; + +RectangleD.prototype.getWidth = function () { + return this.width; +}; + +RectangleD.prototype.setWidth = function (width) { + this.width = width; +}; + +RectangleD.prototype.getHeight = function () { + return this.height; +}; + +RectangleD.prototype.setHeight = function (height) { + this.height = height; +}; + +RectangleD.prototype.getRight = function () { + return this.x + this.width; +}; + +RectangleD.prototype.getBottom = function () { + return this.y + this.height; +}; + +RectangleD.prototype.intersects = function (a) { + if (this.getRight() < a.x) { + return false; + } + + if (this.getBottom() < a.y) { + return false; + } + + if (a.getRight() < this.x) { + return false; + } + + if (a.getBottom() < this.y) { + return false; + } + + return true; +}; + +RectangleD.prototype.getCenterX = function () { + return this.x + this.width / 2; +}; + +RectangleD.prototype.getMinX = function () { + return this.getX(); +}; + +RectangleD.prototype.getMaxX = function () { + return this.getX() + this.width; +}; + +RectangleD.prototype.getCenterY = function () { + return this.y + this.height / 2; +}; + +RectangleD.prototype.getMinY = function () { + return this.getY(); +}; + +RectangleD.prototype.getMaxY = function () { + return this.getY() + this.height; +}; + +RectangleD.prototype.getWidthHalf = function () { + return this.width / 2; +}; + +RectangleD.prototype.getHeightHalf = function () { + return this.height / 2; +}; + +module.exports = RectangleD; + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +function UniqueIDGeneretor() {} + +UniqueIDGeneretor.lastID = 0; + +UniqueIDGeneretor.createID = function (obj) { + if (UniqueIDGeneretor.isPrimitive(obj)) { + return obj; + } + if (obj.uniqueID != null) { + return obj.uniqueID; + } + obj.uniqueID = UniqueIDGeneretor.getString(); + UniqueIDGeneretor.lastID++; + return obj.uniqueID; +}; + +UniqueIDGeneretor.getString = function (id) { + if (id == null) id = UniqueIDGeneretor.lastID; + return "Object#" + id + ""; +}; + +UniqueIDGeneretor.isPrimitive = function (arg) { + var type = typeof arg === "undefined" ? "undefined" : _typeof(arg); + return arg == null || type != "object" && type != "function"; +}; + +module.exports = UniqueIDGeneretor; + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var LayoutConstants = __webpack_require__(0); +var LGraphManager = __webpack_require__(6); +var LNode = __webpack_require__(3); +var LEdge = __webpack_require__(1); +var LGraph = __webpack_require__(5); +var PointD = __webpack_require__(4); +var Transform = __webpack_require__(17); +var Emitter = __webpack_require__(27); + +function Layout(isRemoteUse) { + Emitter.call(this); + + //Layout Quality: 0:draft, 1:default, 2:proof + this.layoutQuality = LayoutConstants.QUALITY; + //Whether layout should create bendpoints as needed or not + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + //Whether layout should be incremental or not + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + //Whether we animate from before to after layout node positions + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + //Whether we animate the layout process or not + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + //Number iterations that should be done between two successive animations + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + /** + * Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When + * they are, both spring and repulsion forces between two leaf nodes can be + * calculated without the expensive clipping point calculations, resulting + * in major speed-up. + */ + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + /** + * This is used for creation of bendpoints by using dummy nodes and edges. + * Maps an LEdge to its dummy bendpoint path. + */ + this.edgeToDummyNodes = new Map(); + this.graphManager = new LGraphManager(this); + this.isLayoutFinished = false; + this.isSubLayout = false; + this.isRemoteUse = false; + + if (isRemoteUse != null) { + this.isRemoteUse = isRemoteUse; + } +} + +Layout.RANDOM_SEED = 1; + +Layout.prototype = Object.create(Emitter.prototype); + +Layout.prototype.getGraphManager = function () { + return this.graphManager; +}; + +Layout.prototype.getAllNodes = function () { + return this.graphManager.getAllNodes(); +}; + +Layout.prototype.getAllEdges = function () { + return this.graphManager.getAllEdges(); +}; + +Layout.prototype.getAllNodesToApplyGravitation = function () { + return this.graphManager.getAllNodesToApplyGravitation(); +}; + +Layout.prototype.newGraphManager = function () { + var gm = new LGraphManager(this); + this.graphManager = gm; + return gm; +}; + +Layout.prototype.newGraph = function (vGraph) { + return new LGraph(null, this.graphManager, vGraph); +}; + +Layout.prototype.newNode = function (vNode) { + return new LNode(this.graphManager, vNode); +}; + +Layout.prototype.newEdge = function (vEdge) { + return new LEdge(null, null, vEdge); +}; + +Layout.prototype.checkLayoutSuccess = function () { + return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge(); +}; + +Layout.prototype.runLayout = function () { + this.isLayoutFinished = false; + + if (this.tilingPreLayout) { + this.tilingPreLayout(); + } + + this.initParameters(); + var isLayoutSuccessfull; + + if (this.checkLayoutSuccess()) { + isLayoutSuccessfull = false; + } else { + isLayoutSuccessfull = this.layout(); + } + + if (LayoutConstants.ANIMATE === 'during') { + // If this is a 'during' layout animation. Layout is not finished yet. + // We need to perform these in index.js when layout is really finished. + return false; + } + + if (isLayoutSuccessfull) { + if (!this.isSubLayout) { + this.doPostLayout(); + } + } + + if (this.tilingPostLayout) { + this.tilingPostLayout(); + } + + this.isLayoutFinished = true; + + return isLayoutSuccessfull; +}; + +/** + * This method performs the operations required after layout. + */ +Layout.prototype.doPostLayout = function () { + //assert !isSubLayout : "Should not be called on sub-layout!"; + // Propagate geometric changes to v-level objects + if (!this.incremental) { + this.transform(); + } + this.update(); +}; + +/** + * This method updates the geometry of the target graph according to + * calculated layout. + */ +Layout.prototype.update2 = function () { + // update bend points + if (this.createBendsAsNeeded) { + this.createBendpointsFromDummyNodes(); + + // reset all edges, since the topology has changed + this.graphManager.resetAllEdges(); + } + + // perform edge, node and root updates if layout is not called + // remotely + if (!this.isRemoteUse) { + // update all edges + var edge; + var allEdges = this.graphManager.getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + edge = allEdges[i]; + // this.update(edge); + } + + // recursively update nodes + var node; + var nodes = this.graphManager.getRoot().getNodes(); + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + // this.update(node); + } + + // update root graph + this.update(this.graphManager.getRoot()); + } +}; + +Layout.prototype.update = function (obj) { + if (obj == null) { + this.update2(); + } else if (obj instanceof LNode) { + var node = obj; + if (node.getChild() != null) { + // since node is compound, recursively update child nodes + var nodes = node.getChild().getNodes(); + for (var i = 0; i < nodes.length; i++) { + update(nodes[i]); + } + } + + // if the l-level node is associated with a v-level graph object, + // then it is assumed that the v-level node implements the + // interface Updatable. + if (node.vGraphObject != null) { + // cast to Updatable without any type check + var vNode = node.vGraphObject; + + // call the update method of the interface + vNode.update(node); + } + } else if (obj instanceof LEdge) { + var edge = obj; + // if the l-level edge is associated with a v-level graph object, + // then it is assumed that the v-level edge implements the + // interface Updatable. + + if (edge.vGraphObject != null) { + // cast to Updatable without any type check + var vEdge = edge.vGraphObject; + + // call the update method of the interface + vEdge.update(edge); + } + } else if (obj instanceof LGraph) { + var graph = obj; + // if the l-level graph is associated with a v-level graph object, + // then it is assumed that the v-level object implements the + // interface Updatable. + + if (graph.vGraphObject != null) { + // cast to Updatable without any type check + var vGraph = graph.vGraphObject; + + // call the update method of the interface + vGraph.update(graph); + } + } +}; + +/** + * This method is used to set all layout parameters to default values + * determined at compile time. + */ +Layout.prototype.initParameters = function () { + if (!this.isSubLayout) { + this.layoutQuality = LayoutConstants.QUALITY; + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + } + + if (this.animationDuringLayout) { + this.animationOnLayout = false; + } +}; + +Layout.prototype.transform = function (newLeftTop) { + if (newLeftTop == undefined) { + this.transform(new PointD(0, 0)); + } else { + // create a transformation object (from Eclipse to layout). When an + // inverse transform is applied, we get upper-left coordinate of the + // drawing or the root graph at given input coordinate (some margins + // already included in calculation of left-top). + + var trans = new Transform(); + var leftTop = this.graphManager.getRoot().updateLeftTop(); + + if (leftTop != null) { + trans.setWorldOrgX(newLeftTop.x); + trans.setWorldOrgY(newLeftTop.y); + + trans.setDeviceOrgX(leftTop.x); + trans.setDeviceOrgY(leftTop.y); + + var nodes = this.getAllNodes(); + var node; + + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + node.transform(trans); + } + } + } +}; + +Layout.prototype.positionNodesRandomly = function (graph) { + + if (graph == undefined) { + //assert !this.incremental; + this.positionNodesRandomly(this.getGraphManager().getRoot()); + this.getGraphManager().getRoot().updateBounds(true); + } else { + var lNode; + var childGraph; + + var nodes = graph.getNodes(); + for (var i = 0; i < nodes.length; i++) { + lNode = nodes[i]; + childGraph = lNode.getChild(); + + if (childGraph == null) { + lNode.scatter(); + } else if (childGraph.getNodes().length == 0) { + lNode.scatter(); + } else { + this.positionNodesRandomly(childGraph); + lNode.updateBounds(); + } + } + } +}; + +/** + * This method returns a list of trees where each tree is represented as a + * list of l-nodes. The method returns a list of size 0 when: + * - The graph is not flat or + * - One of the component(s) of the graph is not a tree. + */ +Layout.prototype.getFlatForest = function () { + var flatForest = []; + var isForest = true; + + // Quick reference for all nodes in the graph manager associated with + // this layout. The list should not be changed. + var allNodes = this.graphManager.getRoot().getNodes(); + + // First be sure that the graph is flat + var isFlat = true; + + for (var i = 0; i < allNodes.length; i++) { + if (allNodes[i].getChild() != null) { + isFlat = false; + } + } + + // Return empty forest if the graph is not flat. + if (!isFlat) { + return flatForest; + } + + // Run BFS for each component of the graph. + + var visited = new Set(); + var toBeVisited = []; + var parents = new Map(); + var unProcessedNodes = []; + + unProcessedNodes = unProcessedNodes.concat(allNodes); + + // Each iteration of this loop finds a component of the graph and + // decides whether it is a tree or not. If it is a tree, adds it to the + // forest and continued with the next component. + + while (unProcessedNodes.length > 0 && isForest) { + toBeVisited.push(unProcessedNodes[0]); + + // Start the BFS. Each iteration of this loop visits a node in a + // BFS manner. + while (toBeVisited.length > 0 && isForest) { + //pool operation + var currentNode = toBeVisited[0]; + toBeVisited.splice(0, 1); + visited.add(currentNode); + + // Traverse all neighbors of this node + var neighborEdges = currentNode.getEdges(); + + for (var i = 0; i < neighborEdges.length; i++) { + var currentNeighbor = neighborEdges[i].getOtherEnd(currentNode); + + // If BFS is not growing from this neighbor. + if (parents.get(currentNode) != currentNeighbor) { + // We haven't previously visited this neighbor. + if (!visited.has(currentNeighbor)) { + toBeVisited.push(currentNeighbor); + parents.set(currentNeighbor, currentNode); + } + // Since we have previously visited this neighbor and + // this neighbor is not parent of currentNode, given + // graph contains a component that is not tree, hence + // it is not a forest. + else { + isForest = false; + break; + } + } + } + } + + // The graph contains a component that is not a tree. Empty + // previously found trees. The method will end. + if (!isForest) { + flatForest = []; + } + // Save currently visited nodes as a tree in our forest. Reset + // visited and parents lists. Continue with the next component of + // the graph, if any. + else { + var temp = [].concat(_toConsumableArray(visited)); + flatForest.push(temp); + //flatForest = flatForest.concat(temp); + //unProcessedNodes.removeAll(visited); + for (var i = 0; i < temp.length; i++) { + var value = temp[i]; + var index = unProcessedNodes.indexOf(value); + if (index > -1) { + unProcessedNodes.splice(index, 1); + } + } + visited = new Set(); + parents = new Map(); + } + } + + return flatForest; +}; + +/** + * This method creates dummy nodes (an l-level node with minimal dimensions) + * for the given edge (one per bendpoint). The existing l-level structure + * is updated accordingly. + */ +Layout.prototype.createDummyNodesForBendpoints = function (edge) { + var dummyNodes = []; + var prev = edge.source; + + var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target); + + for (var i = 0; i < edge.bendpoints.length; i++) { + // create new dummy node + var dummyNode = this.newNode(null); + dummyNode.setRect(new Point(0, 0), new Dimension(1, 1)); + + graph.add(dummyNode); + + // create new dummy edge between prev and dummy node + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, dummyNode); + + dummyNodes.add(dummyNode); + prev = dummyNode; + } + + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, edge.target); + + this.edgeToDummyNodes.set(edge, dummyNodes); + + // remove real edge from graph manager if it is inter-graph + if (edge.isInterGraph()) { + this.graphManager.remove(edge); + } + // else, remove the edge from the current graph + else { + graph.remove(edge); + } + + return dummyNodes; +}; + +/** + * This method creates bendpoints for edges from the dummy nodes + * at l-level. + */ +Layout.prototype.createBendpointsFromDummyNodes = function () { + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + edges = [].concat(_toConsumableArray(this.edgeToDummyNodes.keys())).concat(edges); + + for (var k = 0; k < edges.length; k++) { + var lEdge = edges[k]; + + if (lEdge.bendpoints.length > 0) { + var path = this.edgeToDummyNodes.get(lEdge); + + for (var i = 0; i < path.length; i++) { + var dummyNode = path[i]; + var p = new PointD(dummyNode.getCenterX(), dummyNode.getCenterY()); + + // update bendpoint's location according to dummy node + var ebp = lEdge.bendpoints.get(i); + ebp.x = p.x; + ebp.y = p.y; + + // remove the dummy node, dummy edges incident with this + // dummy node is also removed (within the remove method) + dummyNode.getOwner().remove(dummyNode); + } + + // add the real edge to graph + this.graphManager.add(lEdge, lEdge.source, lEdge.target); + } + } +}; + +Layout.transform = function (sliderValue, defaultValue, minDiv, maxMul) { + if (minDiv != undefined && maxMul != undefined) { + var value = defaultValue; + + if (sliderValue <= 50) { + var minValue = defaultValue / minDiv; + value -= (defaultValue - minValue) / 50 * (50 - sliderValue); + } else { + var maxValue = defaultValue * maxMul; + value += (maxValue - defaultValue) / 50 * (sliderValue - 50); + } + + return value; + } else { + var a, b; + + if (sliderValue <= 50) { + a = 9.0 * defaultValue / 500.0; + b = defaultValue / 10.0; + } else { + a = 9.0 * defaultValue / 50.0; + b = -8 * defaultValue; + } + + return a * sliderValue + b; + } +}; + +/** + * This method finds and returns the center of the given nodes, assuming + * that the given nodes form a tree in themselves. + */ +Layout.findCenterOfTree = function (nodes) { + var list = []; + list = list.concat(nodes); + + var removedNodes = []; + var remainingDegrees = new Map(); + var foundCenter = false; + var centerNode = null; + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + var degree = node.getNeighborsList().size; + remainingDegrees.set(node, node.getNeighborsList().size); + + if (degree == 1) { + removedNodes.push(node); + } + } + + var tempList = []; + tempList = tempList.concat(removedNodes); + + while (!foundCenter) { + var tempList2 = []; + tempList2 = tempList2.concat(tempList); + tempList = []; + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + + var index = list.indexOf(node); + if (index >= 0) { + list.splice(index, 1); + } + + var neighbours = node.getNeighborsList(); + + neighbours.forEach(function (neighbour) { + if (removedNodes.indexOf(neighbour) < 0) { + var otherDegree = remainingDegrees.get(neighbour); + var newDegree = otherDegree - 1; + + if (newDegree == 1) { + tempList.push(neighbour); + } + + remainingDegrees.set(neighbour, newDegree); + } + }); + } + + removedNodes = removedNodes.concat(tempList); + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + } + + return centerNode; +}; + +/** + * During the coarsening process, this layout may be referenced by two graph managers + * this setter function grants access to change the currently being used graph manager + */ +Layout.prototype.setGraphManager = function (gm) { + this.graphManager = gm; +}; + +module.exports = Layout; + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function RandomSeed() {} +// adapted from: https://stackoverflow.com/a/19303725 +RandomSeed.seed = 1; +RandomSeed.x = 0; + +RandomSeed.nextDouble = function () { + RandomSeed.x = Math.sin(RandomSeed.seed++) * 10000; + return RandomSeed.x - Math.floor(RandomSeed.x); +}; + +module.exports = RandomSeed; + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var PointD = __webpack_require__(4); + +function Transform(x, y) { + this.lworldOrgX = 0.0; + this.lworldOrgY = 0.0; + this.ldeviceOrgX = 0.0; + this.ldeviceOrgY = 0.0; + this.lworldExtX = 1.0; + this.lworldExtY = 1.0; + this.ldeviceExtX = 1.0; + this.ldeviceExtY = 1.0; +} + +Transform.prototype.getWorldOrgX = function () { + return this.lworldOrgX; +}; + +Transform.prototype.setWorldOrgX = function (wox) { + this.lworldOrgX = wox; +}; + +Transform.prototype.getWorldOrgY = function () { + return this.lworldOrgY; +}; + +Transform.prototype.setWorldOrgY = function (woy) { + this.lworldOrgY = woy; +}; + +Transform.prototype.getWorldExtX = function () { + return this.lworldExtX; +}; + +Transform.prototype.setWorldExtX = function (wex) { + this.lworldExtX = wex; +}; + +Transform.prototype.getWorldExtY = function () { + return this.lworldExtY; +}; + +Transform.prototype.setWorldExtY = function (wey) { + this.lworldExtY = wey; +}; + +/* Device related */ + +Transform.prototype.getDeviceOrgX = function () { + return this.ldeviceOrgX; +}; + +Transform.prototype.setDeviceOrgX = function (dox) { + this.ldeviceOrgX = dox; +}; + +Transform.prototype.getDeviceOrgY = function () { + return this.ldeviceOrgY; +}; + +Transform.prototype.setDeviceOrgY = function (doy) { + this.ldeviceOrgY = doy; +}; + +Transform.prototype.getDeviceExtX = function () { + return this.ldeviceExtX; +}; + +Transform.prototype.setDeviceExtX = function (dex) { + this.ldeviceExtX = dex; +}; + +Transform.prototype.getDeviceExtY = function () { + return this.ldeviceExtY; +}; + +Transform.prototype.setDeviceExtY = function (dey) { + this.ldeviceExtY = dey; +}; + +Transform.prototype.transformX = function (x) { + var xDevice = 0.0; + var worldExtX = this.lworldExtX; + if (worldExtX != 0.0) { + xDevice = this.ldeviceOrgX + (x - this.lworldOrgX) * this.ldeviceExtX / worldExtX; + } + + return xDevice; +}; + +Transform.prototype.transformY = function (y) { + var yDevice = 0.0; + var worldExtY = this.lworldExtY; + if (worldExtY != 0.0) { + yDevice = this.ldeviceOrgY + (y - this.lworldOrgY) * this.ldeviceExtY / worldExtY; + } + + return yDevice; +}; + +Transform.prototype.inverseTransformX = function (x) { + var xWorld = 0.0; + var deviceExtX = this.ldeviceExtX; + if (deviceExtX != 0.0) { + xWorld = this.lworldOrgX + (x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX; + } + + return xWorld; +}; + +Transform.prototype.inverseTransformY = function (y) { + var yWorld = 0.0; + var deviceExtY = this.ldeviceExtY; + if (deviceExtY != 0.0) { + yWorld = this.lworldOrgY + (y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY; + } + return yWorld; +}; + +Transform.prototype.inverseTransformPoint = function (inPoint) { + var outPoint = new PointD(this.inverseTransformX(inPoint.x), this.inverseTransformY(inPoint.y)); + return outPoint; +}; + +module.exports = Transform; + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var Layout = __webpack_require__(15); +var FDLayoutConstants = __webpack_require__(7); +var LayoutConstants = __webpack_require__(0); +var IGeometry = __webpack_require__(8); +var IMath = __webpack_require__(9); + +function FDLayout() { + Layout.call(this); + + this.useSmartIdealEdgeLengthCalculation = FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.idealEdgeLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH; + this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + this.displacementThresholdPerNode = 3.0 * FDLayoutConstants.DEFAULT_EDGE_LENGTH / 100; + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.initialCoolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.totalDisplacement = 0.0; + this.oldTotalDisplacement = 0.0; + this.maxIterations = FDLayoutConstants.MAX_ITERATIONS; +} + +FDLayout.prototype = Object.create(Layout.prototype); + +for (var prop in Layout) { + FDLayout[prop] = Layout[prop]; +} + +FDLayout.prototype.initParameters = function () { + Layout.prototype.initParameters.call(this, arguments); + + this.totalIterations = 0; + this.notAnimatedIterations = 0; + + this.useFRGridVariant = FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION; + + this.grid = []; +}; + +FDLayout.prototype.calcIdealEdgeLengths = function () { + var edge; + var lcaDepth; + var source; + var target; + var sizeOfSourceInLca; + var sizeOfTargetInLca; + + var allEdges = this.getGraphManager().getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + edge = allEdges[i]; + + edge.idealLength = this.idealEdgeLength; + + if (edge.isInterGraph) { + source = edge.getSource(); + target = edge.getTarget(); + + sizeOfSourceInLca = edge.getSourceInLca().getEstimatedSize(); + sizeOfTargetInLca = edge.getTargetInLca().getEstimatedSize(); + + if (this.useSmartIdealEdgeLengthCalculation) { + edge.idealLength += sizeOfSourceInLca + sizeOfTargetInLca - 2 * LayoutConstants.SIMPLE_NODE_SIZE; + } + + lcaDepth = edge.getLca().getInclusionTreeDepth(); + + edge.idealLength += FDLayoutConstants.DEFAULT_EDGE_LENGTH * FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (source.getInclusionTreeDepth() + target.getInclusionTreeDepth() - 2 * lcaDepth); + } + } +}; + +FDLayout.prototype.initSpringEmbedder = function () { + + var s = this.getAllNodes().length; + if (this.incremental) { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(this.coolingFactor * FDLayoutConstants.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL; + } else { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(FDLayoutConstants.COOLING_ADAPTATION_FACTOR, 1.0 - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } else { + this.coolingFactor = 1.0; + } + this.initialCoolingFactor = this.coolingFactor; + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT; + } + + this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations); + + this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length; + + this.repulsionRange = this.calcRepulsionRange(); +}; + +FDLayout.prototype.calcSpringForces = function () { + var lEdges = this.getAllEdges(); + var edge; + + for (var i = 0; i < lEdges.length; i++) { + edge = lEdges[i]; + + this.calcSpringForce(edge, edge.idealLength); + } +}; + +FDLayout.prototype.calcRepulsionForces = function () { + var gridUpdateAllowed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var forceToNodeSurroundingUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + var i, j; + var nodeA, nodeB; + var lNodes = this.getAllNodes(); + var processedNodeSet; + + if (this.useFRGridVariant) { + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed) { + this.updateGrid(); + } + + processedNodeSet = new Set(); + + // calculate repulsion forces between each nodes and its surrounding + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.calculateRepulsionForceOfANode(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate); + processedNodeSet.add(nodeA); + } + } else { + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + + for (j = i + 1; j < lNodes.length; j++) { + nodeB = lNodes[j]; + + // If both nodes are not members of the same graph, skip. + if (nodeA.getOwner() != nodeB.getOwner()) { + continue; + } + + this.calcRepulsionForce(nodeA, nodeB); + } + } + } +}; + +FDLayout.prototype.calcGravitationalForces = function () { + var node; + var lNodes = this.getAllNodesToApplyGravitation(); + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + this.calcGravitationalForce(node); + } +}; + +FDLayout.prototype.moveNodes = function () { + var lNodes = this.getAllNodes(); + var node; + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + node.move(); + } +}; + +FDLayout.prototype.calcSpringForce = function (edge, idealLength) { + var sourceNode = edge.getSource(); + var targetNode = edge.getTarget(); + + var length; + var springForce; + var springForceX; + var springForceY; + + // Update edge length + if (this.uniformLeafNodeSizes && sourceNode.getChild() == null && targetNode.getChild() == null) { + edge.updateLengthSimple(); + } else { + edge.updateLength(); + + if (edge.isOverlapingSourceAndTarget) { + return; + } + } + + length = edge.getLength(); + + if (length == 0) return; + + // Calculate spring forces + springForce = this.springConstant * (length - idealLength); + + // Project force onto x and y axes + springForceX = springForce * (edge.lengthX / length); + springForceY = springForce * (edge.lengthY / length); + + // Apply forces on the end nodes + sourceNode.springForceX += springForceX; + sourceNode.springForceY += springForceY; + targetNode.springForceX -= springForceX; + targetNode.springForceY -= springForceY; +}; + +FDLayout.prototype.calcRepulsionForce = function (nodeA, nodeB) { + var rectA = nodeA.getRect(); + var rectB = nodeB.getRect(); + var overlapAmount = new Array(2); + var clipPoints = new Array(4); + var distanceX; + var distanceY; + var distanceSquared; + var distance; + var repulsionForce; + var repulsionForceX; + var repulsionForceY; + + if (rectA.intersects(rectB)) // two nodes overlap + { + // calculate separation amount in x and y directions + IGeometry.calcSeparationAmount(rectA, rectB, overlapAmount, FDLayoutConstants.DEFAULT_EDGE_LENGTH / 2.0); + + repulsionForceX = 2 * overlapAmount[0]; + repulsionForceY = 2 * overlapAmount[1]; + + var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren); + + // Apply forces on the two nodes + nodeA.repulsionForceX -= childrenConstant * repulsionForceX; + nodeA.repulsionForceY -= childrenConstant * repulsionForceY; + nodeB.repulsionForceX += childrenConstant * repulsionForceX; + nodeB.repulsionForceY += childrenConstant * repulsionForceY; + } else // no overlap + { + // calculate distance + + if (this.uniformLeafNodeSizes && nodeA.getChild() == null && nodeB.getChild() == null) // simply base repulsion on distance of node centers + { + distanceX = rectB.getCenterX() - rectA.getCenterX(); + distanceY = rectB.getCenterY() - rectA.getCenterY(); + } else // use clipping points + { + IGeometry.getIntersection(rectA, rectB, clipPoints); + + distanceX = clipPoints[2] - clipPoints[0]; + distanceY = clipPoints[3] - clipPoints[1]; + } + + // No repulsion range. FR grid variant should take care of this. + if (Math.abs(distanceX) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceX = IMath.sign(distanceX) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + if (Math.abs(distanceY) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceY = IMath.sign(distanceY) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + distanceSquared = distanceX * distanceX + distanceY * distanceY; + distance = Math.sqrt(distanceSquared); + + repulsionForce = this.repulsionConstant * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared; + + // Project force onto x and y axes + repulsionForceX = repulsionForce * distanceX / distance; + repulsionForceY = repulsionForce * distanceY / distance; + + // Apply forces on the two nodes + nodeA.repulsionForceX -= repulsionForceX; + nodeA.repulsionForceY -= repulsionForceY; + nodeB.repulsionForceX += repulsionForceX; + nodeB.repulsionForceY += repulsionForceY; + } +}; + +FDLayout.prototype.calcGravitationalForce = function (node) { + var ownerGraph; + var ownerCenterX; + var ownerCenterY; + var distanceX; + var distanceY; + var absDistanceX; + var absDistanceY; + var estimatedSize; + ownerGraph = node.getOwner(); + + ownerCenterX = (ownerGraph.getRight() + ownerGraph.getLeft()) / 2; + ownerCenterY = (ownerGraph.getTop() + ownerGraph.getBottom()) / 2; + distanceX = node.getCenterX() - ownerCenterX; + distanceY = node.getCenterY() - ownerCenterY; + absDistanceX = Math.abs(distanceX) + node.getWidth() / 2; + absDistanceY = Math.abs(distanceY) + node.getHeight() / 2; + + if (node.getOwner() == this.graphManager.getRoot()) // in the root graph + { + estimatedSize = ownerGraph.getEstimatedSize() * this.gravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX; + node.gravitationForceY = -this.gravityConstant * distanceY; + } + } else // inside a compound + { + estimatedSize = ownerGraph.getEstimatedSize() * this.compoundGravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX * this.compoundGravityConstant; + node.gravitationForceY = -this.gravityConstant * distanceY * this.compoundGravityConstant; + } + } +}; + +FDLayout.prototype.isConverged = function () { + var converged; + var oscilating = false; + + if (this.totalIterations > this.maxIterations / 3) { + oscilating = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2; + } + + converged = this.totalDisplacement < this.totalDisplacementThreshold; + + this.oldTotalDisplacement = this.totalDisplacement; + + return converged || oscilating; +}; + +FDLayout.prototype.animate = function () { + if (this.animationDuringLayout && !this.isSubLayout) { + if (this.notAnimatedIterations == this.animationPeriod) { + this.update(); + this.notAnimatedIterations = 0; + } else { + this.notAnimatedIterations++; + } + } +}; + +//This method calculates the number of children (weight) for all nodes +FDLayout.prototype.calcNoOfChildrenForAllNodes = function () { + var node; + var allNodes = this.graphManager.getAllNodes(); + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + node.noOfChildren = node.getNoOfChildren(); + } +}; + +// ----------------------------------------------------------------------------- +// Section: FR-Grid Variant Repulsion Force Calculation +// ----------------------------------------------------------------------------- + +FDLayout.prototype.calcGrid = function (graph) { + + var sizeX = 0; + var sizeY = 0; + + sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange)); + sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange)); + + var grid = new Array(sizeX); + + for (var i = 0; i < sizeX; i++) { + grid[i] = new Array(sizeY); + } + + for (var i = 0; i < sizeX; i++) { + for (var j = 0; j < sizeY; j++) { + grid[i][j] = new Array(); + } + } + + return grid; +}; + +FDLayout.prototype.addNodeToGrid = function (v, left, top) { + + var startX = 0; + var finishX = 0; + var startY = 0; + var finishY = 0; + + startX = parseInt(Math.floor((v.getRect().x - left) / this.repulsionRange)); + finishX = parseInt(Math.floor((v.getRect().width + v.getRect().x - left) / this.repulsionRange)); + startY = parseInt(Math.floor((v.getRect().y - top) / this.repulsionRange)); + finishY = parseInt(Math.floor((v.getRect().height + v.getRect().y - top) / this.repulsionRange)); + + for (var i = startX; i <= finishX; i++) { + for (var j = startY; j <= finishY; j++) { + this.grid[i][j].push(v); + v.setGridCoordinates(startX, finishX, startY, finishY); + } + } +}; + +FDLayout.prototype.updateGrid = function () { + var i; + var nodeA; + var lNodes = this.getAllNodes(); + + this.grid = this.calcGrid(this.graphManager.getRoot()); + + // put all nodes to proper grid cells + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.addNodeToGrid(nodeA, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop()); + } +}; + +FDLayout.prototype.calculateRepulsionForceOfANode = function (nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate) { + + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed || forceToNodeSurroundingUpdate) { + var surrounding = new Set(); + nodeA.surrounding = new Array(); + var nodeB; + var grid = this.grid; + + for (var i = nodeA.startX - 1; i < nodeA.finishX + 2; i++) { + for (var j = nodeA.startY - 1; j < nodeA.finishY + 2; j++) { + if (!(i < 0 || j < 0 || i >= grid.length || j >= grid[0].length)) { + for (var k = 0; k < grid[i][j].length; k++) { + nodeB = grid[i][j][k]; + + // If both nodes are not members of the same graph, + // or both nodes are the same, skip. + if (nodeA.getOwner() != nodeB.getOwner() || nodeA == nodeB) { + continue; + } + + // check if the repulsion force between + // nodeA and nodeB has already been calculated + if (!processedNodeSet.has(nodeB) && !surrounding.has(nodeB)) { + var distanceX = Math.abs(nodeA.getCenterX() - nodeB.getCenterX()) - (nodeA.getWidth() / 2 + nodeB.getWidth() / 2); + var distanceY = Math.abs(nodeA.getCenterY() - nodeB.getCenterY()) - (nodeA.getHeight() / 2 + nodeB.getHeight() / 2); + + // if the distance between nodeA and nodeB + // is less then calculation range + if (distanceX <= this.repulsionRange && distanceY <= this.repulsionRange) { + //then add nodeB to surrounding of nodeA + surrounding.add(nodeB); + } + } + } + } + } + } + + nodeA.surrounding = [].concat(_toConsumableArray(surrounding)); + } + for (i = 0; i < nodeA.surrounding.length; i++) { + this.calcRepulsionForce(nodeA, nodeA.surrounding[i]); + } +}; + +FDLayout.prototype.calcRepulsionRange = function () { + return 0.0; +}; + +module.exports = FDLayout; + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LEdge = __webpack_require__(1); +var FDLayoutConstants = __webpack_require__(7); + +function FDLayoutEdge(source, target, vEdge) { + LEdge.call(this, source, target, vEdge); + this.idealLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; +} + +FDLayoutEdge.prototype = Object.create(LEdge.prototype); + +for (var prop in LEdge) { + FDLayoutEdge[prop] = LEdge[prop]; +} + +module.exports = FDLayoutEdge; + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var LNode = __webpack_require__(3); + +function FDLayoutNode(gm, loc, size, vNode) { + // alternative constructor is handled inside LNode + LNode.call(this, gm, loc, size, vNode); + //Spring, repulsion and gravitational forces acting on this node + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + //Amount by which this node is to be moved in this iteration + this.displacementX = 0; + this.displacementY = 0; + + //Start and finish grid coordinates that this node is fallen into + this.startX = 0; + this.finishX = 0; + this.startY = 0; + this.finishY = 0; + + //Geometric neighbors of this node + this.surrounding = []; +} + +FDLayoutNode.prototype = Object.create(LNode.prototype); + +for (var prop in LNode) { + FDLayoutNode[prop] = LNode[prop]; +} + +FDLayoutNode.prototype.setGridCoordinates = function (_startX, _finishX, _startY, _finishY) { + this.startX = _startX; + this.finishX = _finishX; + this.startY = _startY; + this.finishY = _finishY; +}; + +module.exports = FDLayoutNode; + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function DimensionD(width, height) { + this.width = 0; + this.height = 0; + if (width !== null && height !== null) { + this.height = height; + this.width = width; + } +} + +DimensionD.prototype.getWidth = function () { + return this.width; +}; + +DimensionD.prototype.setWidth = function (width) { + this.width = width; +}; + +DimensionD.prototype.getHeight = function () { + return this.height; +}; + +DimensionD.prototype.setHeight = function (height) { + this.height = height; +}; + +module.exports = DimensionD; + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var UniqueIDGeneretor = __webpack_require__(14); + +function HashMap() { + this.map = {}; + this.keys = []; +} + +HashMap.prototype.put = function (key, value) { + var theId = UniqueIDGeneretor.createID(key); + if (!this.contains(theId)) { + this.map[theId] = value; + this.keys.push(key); + } +}; + +HashMap.prototype.contains = function (key) { + var theId = UniqueIDGeneretor.createID(key); + return this.map[key] != null; +}; + +HashMap.prototype.get = function (key) { + var theId = UniqueIDGeneretor.createID(key); + return this.map[theId]; +}; + +HashMap.prototype.keySet = function () { + return this.keys; +}; + +module.exports = HashMap; + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var UniqueIDGeneretor = __webpack_require__(14); + +function HashSet() { + this.set = {}; +} +; + +HashSet.prototype.add = function (obj) { + var theId = UniqueIDGeneretor.createID(obj); + if (!this.contains(theId)) this.set[theId] = obj; +}; + +HashSet.prototype.remove = function (obj) { + delete this.set[UniqueIDGeneretor.createID(obj)]; +}; + +HashSet.prototype.clear = function () { + this.set = {}; +}; + +HashSet.prototype.contains = function (obj) { + return this.set[UniqueIDGeneretor.createID(obj)] == obj; +}; + +HashSet.prototype.isEmpty = function () { + return this.size() === 0; +}; + +HashSet.prototype.size = function () { + return Object.keys(this.set).length; +}; + +//concats this.set to the given list +HashSet.prototype.addAllTo = function (list) { + var keys = Object.keys(this.set); + var length = keys.length; + for (var i = 0; i < length; i++) { + list.push(this.set[keys[i]]); + } +}; + +HashSet.prototype.size = function () { + return Object.keys(this.set).length; +}; + +HashSet.prototype.addAll = function (list) { + var s = list.length; + for (var i = 0; i < s; i++) { + var v = list[i]; + this.add(v); + } +}; + +module.exports = HashSet; + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * A classic Quicksort algorithm with Hoare's partition + * - Works also on LinkedList objects + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + +var LinkedList = __webpack_require__(11); + +var Quicksort = function () { + function Quicksort(A, compareFunction) { + _classCallCheck(this, Quicksort); + + if (compareFunction !== null || compareFunction !== undefined) this.compareFunction = this._defaultCompareFunction; + + var length = void 0; + if (A instanceof LinkedList) length = A.size();else length = A.length; + + this._quicksort(A, 0, length - 1); + } + + _createClass(Quicksort, [{ + key: '_quicksort', + value: function _quicksort(A, p, r) { + if (p < r) { + var q = this._partition(A, p, r); + this._quicksort(A, p, q); + this._quicksort(A, q + 1, r); + } + } + }, { + key: '_partition', + value: function _partition(A, p, r) { + var x = this._get(A, p); + var i = p; + var j = r; + while (true) { + while (this.compareFunction(x, this._get(A, j))) { + j--; + }while (this.compareFunction(this._get(A, i), x)) { + i++; + }if (i < j) { + this._swap(A, i, j); + i++; + j--; + } else return j; + } + } + }, { + key: '_get', + value: function _get(object, index) { + if (object instanceof LinkedList) return object.get_object_at(index);else return object[index]; + } + }, { + key: '_set', + value: function _set(object, index, value) { + if (object instanceof LinkedList) object.set_object_at(index, value);else object[index] = value; + } + }, { + key: '_swap', + value: function _swap(A, i, j) { + var temp = this._get(A, i); + this._set(A, i, this._get(A, j)); + this._set(A, j, temp); + } + }, { + key: '_defaultCompareFunction', + value: function _defaultCompareFunction(a, b) { + return b > a; + } + }]); + + return Quicksort; +}(); + +module.exports = Quicksort; + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Needleman-Wunsch algorithm is an procedure to compute the optimal global alignment of two string + * sequences by S.B.Needleman and C.D.Wunsch (1970). + * + * Aside from the inputs, you can assign the scores for, + * - Match: The two characters at the current index are same. + * - Mismatch: The two characters at the current index are different. + * - Insertion/Deletion(gaps): The best alignment involves one letter aligning to a gap in the other string. + */ + +var NeedlemanWunsch = function () { + function NeedlemanWunsch(sequence1, sequence2) { + var match_score = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + var mismatch_penalty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1; + var gap_penalty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1; + + _classCallCheck(this, NeedlemanWunsch); + + this.sequence1 = sequence1; + this.sequence2 = sequence2; + this.match_score = match_score; + this.mismatch_penalty = mismatch_penalty; + this.gap_penalty = gap_penalty; + + // Just the remove redundancy + this.iMax = sequence1.length + 1; + this.jMax = sequence2.length + 1; + + // Grid matrix of scores + this.grid = new Array(this.iMax); + for (var i = 0; i < this.iMax; i++) { + this.grid[i] = new Array(this.jMax); + + for (var j = 0; j < this.jMax; j++) { + this.grid[i][j] = 0; + } + } + + // Traceback matrix (2D array, each cell is an array of boolean values for [`Diag`, `Up`, `Left`] positions) + this.tracebackGrid = new Array(this.iMax); + for (var _i = 0; _i < this.iMax; _i++) { + this.tracebackGrid[_i] = new Array(this.jMax); + + for (var _j = 0; _j < this.jMax; _j++) { + this.tracebackGrid[_i][_j] = [null, null, null]; + } + } + + // The aligned sequences (return multiple possibilities) + this.alignments = []; + + // Final alignment score + this.score = -1; + + // Calculate scores and tracebacks + this.computeGrids(); + } + + _createClass(NeedlemanWunsch, [{ + key: "getScore", + value: function getScore() { + return this.score; + } + }, { + key: "getAlignments", + value: function getAlignments() { + return this.alignments; + } + + // Main dynamic programming procedure + + }, { + key: "computeGrids", + value: function computeGrids() { + // Fill in the first row + for (var j = 1; j < this.jMax; j++) { + this.grid[0][j] = this.grid[0][j - 1] + this.gap_penalty; + this.tracebackGrid[0][j] = [false, false, true]; + } + + // Fill in the first column + for (var i = 1; i < this.iMax; i++) { + this.grid[i][0] = this.grid[i - 1][0] + this.gap_penalty; + this.tracebackGrid[i][0] = [false, true, false]; + } + + // Fill the rest of the grid + for (var _i2 = 1; _i2 < this.iMax; _i2++) { + for (var _j2 = 1; _j2 < this.jMax; _j2++) { + // Find the max score(s) among [`Diag`, `Up`, `Left`] + var diag = void 0; + if (this.sequence1[_i2 - 1] === this.sequence2[_j2 - 1]) diag = this.grid[_i2 - 1][_j2 - 1] + this.match_score;else diag = this.grid[_i2 - 1][_j2 - 1] + this.mismatch_penalty; + + var up = this.grid[_i2 - 1][_j2] + this.gap_penalty; + var left = this.grid[_i2][_j2 - 1] + this.gap_penalty; + + // If there exists multiple max values, capture them for multiple paths + var maxOf = [diag, up, left]; + var indices = this.arrayAllMaxIndexes(maxOf); + + // Update Grids + this.grid[_i2][_j2] = maxOf[indices[0]]; + this.tracebackGrid[_i2][_j2] = [indices.includes(0), indices.includes(1), indices.includes(2)]; + } + } + + // Update alignment score + this.score = this.grid[this.iMax - 1][this.jMax - 1]; + } + + // Gets all possible valid sequence combinations + + }, { + key: "alignmentTraceback", + value: function alignmentTraceback() { + var inProcessAlignments = []; + + inProcessAlignments.push({ pos: [this.sequence1.length, this.sequence2.length], + seq1: "", + seq2: "" + }); + + while (inProcessAlignments[0]) { + var current = inProcessAlignments[0]; + var directions = this.tracebackGrid[current.pos[0]][current.pos[1]]; + + if (directions[0]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1] - 1], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + if (directions[1]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1]], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: '-' + current.seq2 + }); + } + if (directions[2]) { + inProcessAlignments.push({ pos: [current.pos[0], current.pos[1] - 1], + seq1: '-' + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + + if (current.pos[0] === 0 && current.pos[1] === 0) this.alignments.push({ sequence1: current.seq1, + sequence2: current.seq2 + }); + + inProcessAlignments.shift(); + } + + return this.alignments; + } + + // Helper Functions + + }, { + key: "getAllIndexes", + value: function getAllIndexes(arr, val) { + var indexes = [], + i = -1; + while ((i = arr.indexOf(val, i + 1)) !== -1) { + indexes.push(i); + } + return indexes; + } + }, { + key: "arrayAllMaxIndexes", + value: function arrayAllMaxIndexes(array) { + return this.getAllIndexes(array, Math.max.apply(null, array)); + } + }]); + + return NeedlemanWunsch; +}(); + +module.exports = NeedlemanWunsch; + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var layoutBase = function layoutBase() { + return; +}; + +layoutBase.FDLayout = __webpack_require__(18); +layoutBase.FDLayoutConstants = __webpack_require__(7); +layoutBase.FDLayoutEdge = __webpack_require__(19); +layoutBase.FDLayoutNode = __webpack_require__(20); +layoutBase.DimensionD = __webpack_require__(21); +layoutBase.HashMap = __webpack_require__(22); +layoutBase.HashSet = __webpack_require__(23); +layoutBase.IGeometry = __webpack_require__(8); +layoutBase.IMath = __webpack_require__(9); +layoutBase.Integer = __webpack_require__(10); +layoutBase.Point = __webpack_require__(12); +layoutBase.PointD = __webpack_require__(4); +layoutBase.RandomSeed = __webpack_require__(16); +layoutBase.RectangleD = __webpack_require__(13); +layoutBase.Transform = __webpack_require__(17); +layoutBase.UniqueIDGeneretor = __webpack_require__(14); +layoutBase.Quicksort = __webpack_require__(24); +layoutBase.LinkedList = __webpack_require__(11); +layoutBase.LGraphObject = __webpack_require__(2); +layoutBase.LGraph = __webpack_require__(5); +layoutBase.LEdge = __webpack_require__(1); +layoutBase.LGraphManager = __webpack_require__(6); +layoutBase.LNode = __webpack_require__(3); +layoutBase.Layout = __webpack_require__(15); +layoutBase.LayoutConstants = __webpack_require__(0); +layoutBase.NeedlemanWunsch = __webpack_require__(25); + +module.exports = layoutBase; + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function Emitter() { + this.listeners = []; +} + +var p = Emitter.prototype; + +p.addListener = function (event, callback) { + this.listeners.push({ + event: event, + callback: callback + }); +}; + +p.removeListener = function (event, callback) { + for (var i = this.listeners.length; i >= 0; i--) { + var l = this.listeners[i]; + + if (l.event === event && l.callback === callback) { + this.listeners.splice(i, 1); + } + } +}; + +p.emit = function (event, data) { + for (var i = 0; i < this.listeners.length; i++) { + var l = this.listeners[i]; + + if (event === l.event) { + l.callback(data); + } + } +}; + +module.exports = Emitter; + +/***/ }) +/******/ ]); +}); \ No newline at end of file diff --git a/tools/ui/node_modules/layout-base/layout-schema.png b/tools/ui/node_modules/layout-base/layout-schema.png new file mode 100644 index 0000000000000000000000000000000000000000..94476114976087a2143a8298fbc881bbaaf10404 --- /dev/null +++ b/tools/ui/node_modules/layout-base/layout-schema.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26059cdc98f39bfb43b8aeffcb6ebfd83c91446dc5e877280de97990dfe267ef +size 68527 diff --git a/tools/ui/node_modules/layout-base/nbproject/private/private.properties b/tools/ui/node_modules/layout-base/nbproject/private/private.properties new file mode 100644 index 0000000000000000000000000000000000000000..3b1a22e6c97a8c2654cd087e610829a8b4eebdb8 --- /dev/null +++ b/tools/ui/node_modules/layout-base/nbproject/private/private.properties @@ -0,0 +1 @@ +browser=Chrome.INTEGRATED diff --git a/tools/ui/node_modules/layout-base/nbproject/private/private.xml b/tools/ui/node_modules/layout-base/nbproject/private/private.xml new file mode 100644 index 0000000000000000000000000000000000000000..b57a4a998f07e3fd996274114d974720368e637c --- /dev/null +++ b/tools/ui/node_modules/layout-base/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + + file:/home/hasanbalci/Documents/github/layout-base/layout-base.js + + + diff --git a/tools/ui/node_modules/layout-base/nbproject/project.properties b/tools/ui/node_modules/layout-base/nbproject/project.properties new file mode 100644 index 0000000000000000000000000000000000000000..da97eba5689cca90e15d36e3313b84a7a7df27a4 --- /dev/null +++ b/tools/ui/node_modules/layout-base/nbproject/project.properties @@ -0,0 +1,3 @@ +files.encoding=UTF-8 +site.root.folder= +source.folder= diff --git a/tools/ui/node_modules/layout-base/nbproject/project.xml b/tools/ui/node_modules/layout-base/nbproject/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..71c7a284d09c07c10313f548884f5887c005ae07 --- /dev/null +++ b/tools/ui/node_modules/layout-base/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.web.clientproject + + + layout-base + + + diff --git a/tools/ui/node_modules/layout-base/package.json b/tools/ui/node_modules/layout-base/package.json new file mode 100644 index 0000000000000000000000000000000000000000..6ef101eb9500dbccb0cf96b0aaf04a8b8416c47c --- /dev/null +++ b/tools/ui/node_modules/layout-base/package.json @@ -0,0 +1,37 @@ +{ + "name": "layout-base", + "version": "1.0.2", + "description": "Basic layout model and some utilities for Cytoscape.js layout extensions", + "main": "layout-base.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "build": "cross-env NODE_ENV=production webpack" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/iVis-at-Bilkent/layout-base.git" + }, + "author": "", + "license": "MIT", + "bugs": { + "url": "https://github.com/iVis-at-Bilkent/layout-base/issues" + }, + "homepage": "https://github.com/iVis-at-Bilkent/layout-base#readme", + "devDependencies": { + "babel-core": "^6.24.1", + "babel-loader": "^7.0.0", + "babel-preset-env": "^1.5.1", + "camelcase": "^4.1.0", + "cpy-cli": "^1.0.1", + "cross-env": "^5.1.6", + "eslint": "^3.19.0", + "gh-pages": "^1.1.0", + "npm-run-all": "^4.1.2", + "rimraf": "^2.6.2", + "update": "^0.7.4", + "updater-license": "^1.0.0", + "forever": "^0.15.3", + "webpack": "^2.6.1", + "webpack-dev-server": "^2.4.5" + } +} diff --git a/tools/ui/node_modules/layout-base/src/LEdge.js b/tools/ui/node_modules/layout-base/src/LEdge.js new file mode 100644 index 0000000000000000000000000000000000000000..6905a1ceed2bac66dcc76fdbfd23f43915d739c6 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/LEdge.js @@ -0,0 +1,153 @@ +var LGraphObject = require('./LGraphObject'); +var IGeometry = require('./util/IGeometry'); +var IMath = require('./util/IMath'); + +function LEdge(source, target, vEdge) { + LGraphObject.call(this, vEdge); + + this.isOverlapingSourceAndTarget = false; + this.vGraphObject = vEdge; + this.bendpoints = []; + this.source = source; + this.target = target; +} + +LEdge.prototype = Object.create(LGraphObject.prototype); + +for (var prop in LGraphObject) { + LEdge[prop] = LGraphObject[prop]; +} + +LEdge.prototype.getSource = function () +{ + return this.source; +}; + +LEdge.prototype.getTarget = function () +{ + return this.target; +}; + +LEdge.prototype.isInterGraph = function () +{ + return this.isInterGraph; +}; + +LEdge.prototype.getLength = function () +{ + return this.length; +}; + +LEdge.prototype.isOverlapingSourceAndTarget = function () +{ + return this.isOverlapingSourceAndTarget; +}; + +LEdge.prototype.getBendpoints = function () +{ + return this.bendpoints; +}; + +LEdge.prototype.getLca = function () +{ + return this.lca; +}; + +LEdge.prototype.getSourceInLca = function () +{ + return this.sourceInLca; +}; + +LEdge.prototype.getTargetInLca = function () +{ + return this.targetInLca; +}; + +LEdge.prototype.getOtherEnd = function (node) +{ + if (this.source === node) + { + return this.target; + } + else if (this.target === node) + { + return this.source; + } + else + { + throw "Node is not incident with this edge"; + } +} + +LEdge.prototype.getOtherEndInGraph = function (node, graph) +{ + var otherEnd = this.getOtherEnd(node); + var root = graph.getGraphManager().getRoot(); + + while (true) + { + if (otherEnd.getOwner() == graph) + { + return otherEnd; + } + + if (otherEnd.getOwner() == root) + { + break; + } + + otherEnd = otherEnd.getOwner().getParent(); + } + + return null; +}; + +LEdge.prototype.updateLength = function () +{ + var clipPointCoordinates = new Array(4); + + this.isOverlapingSourceAndTarget = + IGeometry.getIntersection(this.target.getRect(), + this.source.getRect(), + clipPointCoordinates); + + if (!this.isOverlapingSourceAndTarget) + { + this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2]; + this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3]; + + if (Math.abs(this.lengthX) < 1.0) + { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) + { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt( + this.lengthX * this.lengthX + this.lengthY * this.lengthY); + } +}; + +LEdge.prototype.updateLengthSimple = function () +{ + this.lengthX = this.target.getCenterX() - this.source.getCenterX(); + this.lengthY = this.target.getCenterY() - this.source.getCenterY(); + + if (Math.abs(this.lengthX) < 1.0) + { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) + { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt( + this.lengthX * this.lengthX + this.lengthY * this.lengthY); +} + +module.exports = LEdge; diff --git a/tools/ui/node_modules/layout-base/src/LGraph.js b/tools/ui/node_modules/layout-base/src/LGraph.js new file mode 100644 index 0000000000000000000000000000000000000000..93a237aeae95ff522a240bfa88b97eeb84a033d0 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/LGraph.js @@ -0,0 +1,477 @@ +var LGraphObject = require('./LGraphObject'); +var Integer = require('./util/Integer'); +var LayoutConstants = require('./LayoutConstants'); +var LGraphManager = require('./LGraphManager'); +var LNode = require('./LNode'); +var LEdge = require('./LEdge'); +var RectangleD = require('./util/RectangleD'); +var Point = require('./util/Point'); +var LinkedList = require('./util/LinkedList'); + +function LGraph(parent, obj2, vGraph) { + LGraphObject.call(this, vGraph); + this.estimatedSize = Integer.MIN_VALUE; + this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN; + this.edges = []; + this.nodes = []; + this.isConnected = false; + this.parent = parent; + + if (obj2 != null && obj2 instanceof LGraphManager) { + this.graphManager = obj2; + } + else if (obj2 != null && obj2 instanceof Layout) { + this.graphManager = obj2.graphManager; + } +} + +LGraph.prototype = Object.create(LGraphObject.prototype); +for (var prop in LGraphObject) { + LGraph[prop] = LGraphObject[prop]; +} + +LGraph.prototype.getNodes = function () { + return this.nodes; +}; + +LGraph.prototype.getEdges = function () { + return this.edges; +}; + +LGraph.prototype.getGraphManager = function () +{ + return this.graphManager; +}; + +LGraph.prototype.getParent = function () +{ + return this.parent; +}; + +LGraph.prototype.getLeft = function () +{ + return this.left; +}; + +LGraph.prototype.getRight = function () +{ + return this.right; +}; + +LGraph.prototype.getTop = function () +{ + return this.top; +}; + +LGraph.prototype.getBottom = function () +{ + return this.bottom; +}; + +LGraph.prototype.isConnected = function () +{ + return this.isConnected; +}; + +LGraph.prototype.add = function (obj1, sourceNode, targetNode) { + if (sourceNode == null && targetNode == null) { + var newNode = obj1; + if (this.graphManager == null) { + throw "Graph has no graph mgr!"; + } + if (this.getNodes().indexOf(newNode) > -1) { + throw "Node already in graph!"; + } + newNode.owner = this; + this.getNodes().push(newNode); + + return newNode; + } + else { + var newEdge = obj1; + if (!(this.getNodes().indexOf(sourceNode) > -1 && (this.getNodes().indexOf(targetNode)) > -1)) { + throw "Source or target not in graph!"; + } + + if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) { + throw "Both owners must be this graph!"; + } + + if (sourceNode.owner != targetNode.owner) + { + return null; + } + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // set as intra-graph edge + newEdge.isInterGraph = false; + + // add to graph edge list + this.getEdges().push(newEdge); + + // add to incidency lists + sourceNode.edges.push(newEdge); + + if (targetNode != sourceNode) + { + targetNode.edges.push(newEdge); + } + + return newEdge; + } +}; + +LGraph.prototype.remove = function (obj) { + var node = obj; + if (obj instanceof LNode) { + if (node == null) { + throw "Node is null!"; + } + if (!(node.owner != null && node.owner == this)) { + throw "Owner graph is invalid!"; + } + if (this.graphManager == null) { + throw "Owner graph manager is invalid!"; + } + // remove incident edges first (make a copy to do it safely) + var edgesToBeRemoved = node.edges.slice(); + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) + { + edge = edgesToBeRemoved[i]; + + if (edge.isInterGraph) + { + this.graphManager.remove(edge); + } + else + { + edge.source.owner.remove(edge); + } + } + + // now the node itself + var index = this.nodes.indexOf(node); + if (index == -1) { + throw "Node not in owner node list!"; + } + + this.nodes.splice(index, 1); + } + else if (obj instanceof LEdge) { + var edge = obj; + if (edge == null) { + throw "Edge is null!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + if (!(edge.source.owner != null && edge.target.owner != null && + edge.source.owner == this && edge.target.owner == this)) { + throw "Source and/or target owner is invalid!"; + } + + var sourceIndex = edge.source.edges.indexOf(edge); + var targetIndex = edge.target.edges.indexOf(edge); + if (!(sourceIndex > -1 && targetIndex > -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + edge.source.edges.splice(sourceIndex, 1); + + if (edge.target != edge.source) + { + edge.target.edges.splice(targetIndex, 1); + } + + var index = edge.source.owner.getEdges().indexOf(edge); + if (index == -1) { + throw "Not in owner's edge list!"; + } + + edge.source.owner.getEdges().splice(index, 1); + } +}; + +LGraph.prototype.updateLeftTop = function () +{ + var top = Integer.MAX_VALUE; + var left = Integer.MAX_VALUE; + var nodeTop; + var nodeLeft; + var margin; + + var nodes = this.getNodes(); + var s = nodes.length; + + for (var i = 0; i < s; i++) + { + var lNode = nodes[i]; + nodeTop = lNode.getTop(); + nodeLeft = lNode.getLeft(); + + if (top > nodeTop) + { + top = nodeTop; + } + + if (left > nodeLeft) + { + left = nodeLeft; + } + } + + // Do we have any nodes in this graph? + if (top == Integer.MAX_VALUE) + { + return null; + } + + if(nodes[0].getParent().paddingLeft != undefined){ + margin = nodes[0].getParent().paddingLeft; + } + else{ + margin = this.margin; + } + + this.left = left - margin; + this.top = top - margin; + + // Apply the margins and return the result + return new Point(this.left, this.top); +}; + +LGraph.prototype.updateBounds = function (recursive) +{ + // calculate bounds + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + var margin; + + var nodes = this.nodes; + var s = nodes.length; + for (var i = 0; i < s; i++) + { + var lNode = nodes[i]; + + if (recursive && lNode.child != null) + { + lNode.updateBounds(); + } + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) + { + left = nodeLeft; + } + + if (right < nodeRight) + { + right = nodeRight; + } + + if (top > nodeTop) + { + top = nodeTop; + } + + if (bottom < nodeBottom) + { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + if (left == Integer.MAX_VALUE) + { + this.left = this.parent.getLeft(); + this.right = this.parent.getRight(); + this.top = this.parent.getTop(); + this.bottom = this.parent.getBottom(); + } + + if(nodes[0].getParent().paddingLeft != undefined){ + margin = nodes[0].getParent().paddingLeft; + } + else{ + margin = this.margin; + } + + this.left = boundingRect.x - margin; + this.right = boundingRect.x + boundingRect.width + margin; + this.top = boundingRect.y - margin; + this.bottom = boundingRect.y + boundingRect.height + margin; +}; + +LGraph.calculateBounds = function (nodes) +{ + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + + var s = nodes.length; + + for (var i = 0; i < s; i++) + { + var lNode = nodes[i]; + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) + { + left = nodeLeft; + } + + if (right < nodeRight) + { + right = nodeRight; + } + + if (top > nodeTop) + { + top = nodeTop; + } + + if (bottom < nodeBottom) + { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + + return boundingRect; +}; + +LGraph.prototype.getInclusionTreeDepth = function () +{ + if (this == this.graphManager.getRoot()) + { + return 1; + } + else + { + return this.parent.getInclusionTreeDepth(); + } +}; + +LGraph.prototype.getEstimatedSize = function () +{ + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; +}; + +LGraph.prototype.calcEstimatedSize = function () +{ + var size = 0; + var nodes = this.nodes; + var s = nodes.length; + + for (var i = 0; i < s; i++) + { + var lNode = nodes[i]; + size += lNode.calcEstimatedSize(); + } + + if (size == 0) + { + this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE; + } + else + { + this.estimatedSize = size / Math.sqrt(this.nodes.length); + } + + return this.estimatedSize; +}; + +LGraph.prototype.updateConnected = function () +{ + var self = this; + if (this.nodes.length == 0) + { + this.isConnected = true; + return; + } + + var queue = new LinkedList(); + var visited = new Set(); + var currentNode = this.nodes[0]; + var neighborEdges; + var currentNeighbor; + var childrenOfNode = currentNode.withChildren(); + childrenOfNode.forEach(function(node) { + queue.push(node); + visited.add(node); + }); + + while (queue.length !== 0) + { + currentNode = queue.shift(); + + // Traverse all neighbors of this node + neighborEdges = currentNode.getEdges(); + var size = neighborEdges.length; + for (var i = 0; i < size; i++) + { + var neighborEdge = neighborEdges[i]; + currentNeighbor = + neighborEdge.getOtherEndInGraph(currentNode, this); + + // Add unvisited neighbors to the list to visit + if (currentNeighbor != null && + !visited.has(currentNeighbor)) + { + var childrenOfNeighbor = currentNeighbor.withChildren(); + + childrenOfNeighbor.forEach(function(node) { + queue.push(node); + visited.add(node); + }); + } + } + } + + this.isConnected = false; + + if (visited.size >= this.nodes.length) + { + var noOfVisitedInThisGraph = 0; + + visited.forEach(function(visitedNode) { + if (visitedNode.owner == self) + { + noOfVisitedInThisGraph++; + } + }); + + if (noOfVisitedInThisGraph == this.nodes.length) + { + this.isConnected = true; + } + } +}; + +module.exports = LGraph; diff --git a/tools/ui/node_modules/layout-base/src/LGraphManager.js b/tools/ui/node_modules/layout-base/src/LGraphManager.js new file mode 100644 index 0000000000000000000000000000000000000000..a6a9c7f4e6b94a26a79e591dd6cdf5217e39a342 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/LGraphManager.js @@ -0,0 +1,491 @@ +var LGraph; +var LEdge = require('./LEdge'); + +function LGraphManager(layout) { + LGraph = require('./LGraph'); // It may be better to initilize this out of this function but it gives an error (Right-hand side of 'instanceof' is not callable) now. + this.layout = layout; + + this.graphs = []; + this.edges = []; +} + +LGraphManager.prototype.addRoot = function () +{ + var ngraph = this.layout.newGraph(); + var nnode = this.layout.newNode(null); + var root = this.add(ngraph, nnode); + this.setRootGraph(root); + return this.rootGraph; +}; + +LGraphManager.prototype.add = function (newGraph, parentNode, newEdge, sourceNode, targetNode) +{ + //there are just 2 parameters are passed then it adds an LGraph else it adds an LEdge + if (newEdge == null && sourceNode == null && targetNode == null) { + if (newGraph == null) { + throw "Graph is null!"; + } + if (parentNode == null) { + throw "Parent node is null!"; + } + if (this.graphs.indexOf(newGraph) > -1) { + throw "Graph already in this graph mgr!"; + } + + this.graphs.push(newGraph); + + if (newGraph.parent != null) { + throw "Already has a parent!"; + } + if (parentNode.child != null) { + throw "Already has a child!"; + } + + newGraph.parent = parentNode; + parentNode.child = newGraph; + + return newGraph; + } + else { + //change the order of the parameters + targetNode = newEdge; + sourceNode = parentNode; + newEdge = newGraph; + var sourceGraph = sourceNode.getOwner(); + var targetGraph = targetNode.getOwner(); + + if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) { + throw "Source not in this graph mgr!"; + } + if (!(targetGraph != null && targetGraph.getGraphManager() == this)) { + throw "Target not in this graph mgr!"; + } + + if (sourceGraph == targetGraph) + { + newEdge.isInterGraph = false; + return sourceGraph.add(newEdge, sourceNode, targetNode); + } + else + { + newEdge.isInterGraph = true; + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // add edge to inter-graph edge list + if (this.edges.indexOf(newEdge) > -1) { + throw "Edge already in inter-graph edge list!"; + } + + this.edges.push(newEdge); + + // add edge to source and target incidency lists + if (!(newEdge.source != null && newEdge.target != null)) { + throw "Edge source and/or target is null!"; + } + + if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) { + throw "Edge already in source and/or target incidency list!"; + } + + newEdge.source.edges.push(newEdge); + newEdge.target.edges.push(newEdge); + + return newEdge; + } + } +}; + +LGraphManager.prototype.remove = function (lObj) { + if (lObj instanceof LGraph) { + var graph = lObj; + if (graph.getGraphManager() != this) { + throw "Graph not in this graph mgr"; + } + if (!(graph == this.rootGraph || (graph.parent != null && graph.parent.graphManager == this))) { + throw "Invalid parent node!"; + } + + // first the edges (make a copy to do it safely) + var edgesToBeRemoved = []; + + edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges()); + + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) + { + edge = edgesToBeRemoved[i]; + graph.remove(edge); + } + + // then the nodes (make a copy to do it safely) + var nodesToBeRemoved = []; + + nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes()); + + var node; + s = nodesToBeRemoved.length; + for (var i = 0; i < s; i++) + { + node = nodesToBeRemoved[i]; + graph.remove(node); + } + + // check if graph is the root + if (graph == this.rootGraph) + { + this.setRootGraph(null); + } + + // now remove the graph itself + var index = this.graphs.indexOf(graph); + this.graphs.splice(index, 1); + + // also reset the parent of the graph + graph.parent = null; + } + else if (lObj instanceof LEdge) { + edge = lObj; + if (edge == null) { + throw "Edge is null!"; + } + if (!edge.isInterGraph) { + throw "Not an inter-graph edge!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + + // remove edge from source and target nodes' incidency lists + + if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + var index = edge.source.edges.indexOf(edge); + edge.source.edges.splice(index, 1); + index = edge.target.edges.indexOf(edge); + edge.target.edges.splice(index, 1); + + // remove edge from owner graph manager's inter-graph edge list + + if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) { + throw "Edge owner graph or owner graph manager is null!"; + } + if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) { + throw "Not in owner graph manager's edge list!"; + } + + var index = edge.source.owner.getGraphManager().edges.indexOf(edge); + edge.source.owner.getGraphManager().edges.splice(index, 1); + } +}; + +LGraphManager.prototype.updateBounds = function () +{ + this.rootGraph.updateBounds(true); +}; + +LGraphManager.prototype.getGraphs = function () +{ + return this.graphs; +}; + +LGraphManager.prototype.getAllNodes = function () +{ + if (this.allNodes == null) + { + var nodeList = []; + var graphs = this.getGraphs(); + var s = graphs.length; + for (var i = 0; i < s; i++) + { + nodeList = nodeList.concat(graphs[i].getNodes()); + } + this.allNodes = nodeList; + } + return this.allNodes; +}; + +LGraphManager.prototype.resetAllNodes = function () +{ + this.allNodes = null; +}; + +LGraphManager.prototype.resetAllEdges = function () +{ + this.allEdges = null; +}; + +LGraphManager.prototype.resetAllNodesToApplyGravitation = function () +{ + this.allNodesToApplyGravitation = null; +}; + +LGraphManager.prototype.getAllEdges = function () +{ + if (this.allEdges == null) + { + var edgeList = []; + var graphs = this.getGraphs(); + var s = graphs.length; + for (var i = 0; i < graphs.length; i++) + { + edgeList = edgeList.concat(graphs[i].getEdges()); + } + + edgeList = edgeList.concat(this.edges); + + this.allEdges = edgeList; + } + return this.allEdges; +}; + +LGraphManager.prototype.getAllNodesToApplyGravitation = function () +{ + return this.allNodesToApplyGravitation; +}; + +LGraphManager.prototype.setAllNodesToApplyGravitation = function (nodeList) +{ + if (this.allNodesToApplyGravitation != null) { + throw "assert failed"; + } + + this.allNodesToApplyGravitation = nodeList; +}; + +LGraphManager.prototype.getRoot = function () +{ + return this.rootGraph; +}; + +LGraphManager.prototype.setRootGraph = function (graph) +{ + if (graph.getGraphManager() != this) { + throw "Root not in this graph mgr!"; + } + + this.rootGraph = graph; + // root graph must have a root node associated with it for convenience + if (graph.parent == null) + { + graph.parent = this.layout.newNode("Root node"); + } +}; + +LGraphManager.prototype.getLayout = function () +{ + return this.layout; +}; + +LGraphManager.prototype.isOneAncestorOfOther = function (firstNode, secondNode) +{ + if (!(firstNode != null && secondNode != null)) { + throw "assert failed"; + } + + if (firstNode == secondNode) + { + return true; + } + // Is second node an ancestor of the first one? + var ownerGraph = firstNode.getOwner(); + var parentNode; + + do + { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) + { + break; + } + + if (parentNode == secondNode) + { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) + { + break; + } + } while (true); + // Is first node an ancestor of the second one? + ownerGraph = secondNode.getOwner(); + + do + { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) + { + break; + } + + if (parentNode == firstNode) + { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) + { + break; + } + } while (true); + + return false; +}; + +LGraphManager.prototype.calcLowestCommonAncestors = function () +{ + var edge; + var sourceNode; + var targetNode; + var sourceAncestorGraph; + var targetAncestorGraph; + + var edges = this.getAllEdges(); + var s = edges.length; + for (var i = 0; i < s; i++) + { + edge = edges[i]; + + sourceNode = edge.source; + targetNode = edge.target; + edge.lca = null; + edge.sourceInLca = sourceNode; + edge.targetInLca = targetNode; + + if (sourceNode == targetNode) + { + edge.lca = sourceNode.getOwner(); + continue; + } + + sourceAncestorGraph = sourceNode.getOwner(); + + while (edge.lca == null) + { + edge.targetInLca = targetNode; + targetAncestorGraph = targetNode.getOwner(); + + while (edge.lca == null) + { + if (targetAncestorGraph == sourceAncestorGraph) + { + edge.lca = targetAncestorGraph; + break; + } + + if (targetAncestorGraph == this.rootGraph) + { + break; + } + + if (edge.lca != null) { + throw "assert failed"; + } + edge.targetInLca = targetAncestorGraph.getParent(); + targetAncestorGraph = edge.targetInLca.getOwner(); + } + + if (sourceAncestorGraph == this.rootGraph) + { + break; + } + + if (edge.lca == null) + { + edge.sourceInLca = sourceAncestorGraph.getParent(); + sourceAncestorGraph = edge.sourceInLca.getOwner(); + } + } + + if (edge.lca == null) { + throw "assert failed"; + } + } +}; + +LGraphManager.prototype.calcLowestCommonAncestor = function (firstNode, secondNode) +{ + if (firstNode == secondNode) + { + return firstNode.getOwner(); + } + var firstOwnerGraph = firstNode.getOwner(); + + do + { + if (firstOwnerGraph == null) + { + break; + } + var secondOwnerGraph = secondNode.getOwner(); + + do + { + if (secondOwnerGraph == null) + { + break; + } + + if (secondOwnerGraph == firstOwnerGraph) + { + return secondOwnerGraph; + } + secondOwnerGraph = secondOwnerGraph.getParent().getOwner(); + } while (true); + + firstOwnerGraph = firstOwnerGraph.getParent().getOwner(); + } while (true); + + return firstOwnerGraph; +}; + +LGraphManager.prototype.calcInclusionTreeDepths = function (graph, depth) { + if (graph == null && depth == null) { + graph = this.rootGraph; + depth = 1; + } + var node; + + var nodes = graph.getNodes(); + var s = nodes.length; + for (var i = 0; i < s; i++) + { + node = nodes[i]; + node.inclusionTreeDepth = depth; + + if (node.child != null) + { + this.calcInclusionTreeDepths(node.child, depth + 1); + } + } +}; + +LGraphManager.prototype.includesInvalidEdge = function () +{ + var edge; + + var s = this.edges.length; + for (var i = 0; i < s; i++) + { + edge = this.edges[i]; + + if (this.isOneAncestorOfOther(edge.source, edge.target)) + { + return true; + } + } + return false; +}; + +module.exports = LGraphManager; diff --git a/tools/ui/node_modules/layout-base/src/LGraphObject.js b/tools/ui/node_modules/layout-base/src/LGraphObject.js new file mode 100644 index 0000000000000000000000000000000000000000..17305144e25e40d735f6788ff6bd1028e9498816 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/LGraphObject.js @@ -0,0 +1,5 @@ +function LGraphObject(vGraphObject) { + this.vGraphObject = vGraphObject; +} + +module.exports = LGraphObject; diff --git a/tools/ui/node_modules/layout-base/src/LNode.js b/tools/ui/node_modules/layout-base/src/LNode.js new file mode 100644 index 0000000000000000000000000000000000000000..c2c13c2d8cf1ee1e5ad17d7462e11be528da53ff --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/LNode.js @@ -0,0 +1,405 @@ +var LGraphObject = require('./LGraphObject'); +var Integer = require('./util/Integer'); +var RectangleD = require('./util/RectangleD'); +var LayoutConstants = require('./LayoutConstants'); +var RandomSeed = require('./util/RandomSeed'); +var PointD = require('./util/PointD'); + +function LNode(gm, loc, size, vNode) { + //Alternative constructor 1 : LNode(LGraphManager gm, Point loc, Dimension size, Object vNode) + if (size == null && vNode == null) { + vNode = loc; + } + + LGraphObject.call(this, vNode); + + //Alternative constructor 2 : LNode(Layout layout, Object vNode) + if (gm.graphManager != null) + gm = gm.graphManager; + + this.estimatedSize = Integer.MIN_VALUE; + this.inclusionTreeDepth = Integer.MAX_VALUE; + this.vGraphObject = vNode; + this.edges = []; + this.graphManager = gm; + + if (size != null && loc != null) + this.rect = new RectangleD(loc.x, loc.y, size.width, size.height); + else + this.rect = new RectangleD(); +} + +LNode.prototype = Object.create(LGraphObject.prototype); +for (var prop in LGraphObject) { + LNode[prop] = LGraphObject[prop]; +} + +LNode.prototype.getEdges = function () +{ + return this.edges; +}; + +LNode.prototype.getChild = function () +{ + return this.child; +}; + +LNode.prototype.getOwner = function () +{ +// if (this.owner != null) { +// if (!(this.owner == null || this.owner.getNodes().indexOf(this) > -1)) { +// throw "assert failed"; +// } +// } + + return this.owner; +}; + +LNode.prototype.getWidth = function () +{ + return this.rect.width; +}; + +LNode.prototype.setWidth = function (width) +{ + this.rect.width = width; +}; + +LNode.prototype.getHeight = function () +{ + return this.rect.height; +}; + +LNode.prototype.setHeight = function (height) +{ + this.rect.height = height; +}; + +LNode.prototype.getCenterX = function () +{ + return this.rect.x + this.rect.width / 2; +}; + +LNode.prototype.getCenterY = function () +{ + return this.rect.y + this.rect.height / 2; +}; + +LNode.prototype.getCenter = function () +{ + return new PointD(this.rect.x + this.rect.width / 2, + this.rect.y + this.rect.height / 2); +}; + +LNode.prototype.getLocation = function () +{ + return new PointD(this.rect.x, this.rect.y); +}; + +LNode.prototype.getRect = function () +{ + return this.rect; +}; + +LNode.prototype.getDiagonal = function () +{ + return Math.sqrt(this.rect.width * this.rect.width + + this.rect.height * this.rect.height); +}; + +/** + * This method returns half the diagonal length of this node. + */ +LNode.prototype.getHalfTheDiagonal = function () { + return Math.sqrt(this.rect.height * this.rect.height + + this.rect.width * this.rect.width) / 2; +}; + +LNode.prototype.setRect = function (upperLeft, dimension) +{ + this.rect.x = upperLeft.x; + this.rect.y = upperLeft.y; + this.rect.width = dimension.width; + this.rect.height = dimension.height; +}; + +LNode.prototype.setCenter = function (cx, cy) +{ + this.rect.x = cx - this.rect.width / 2; + this.rect.y = cy - this.rect.height / 2; +}; + +LNode.prototype.setLocation = function (x, y) +{ + this.rect.x = x; + this.rect.y = y; +}; + +LNode.prototype.moveBy = function (dx, dy) +{ + this.rect.x += dx; + this.rect.y += dy; +}; + +LNode.prototype.getEdgeListToNode = function (to) +{ + var edgeList = []; + var edge; + var self = this; + + self.edges.forEach(function(edge) { + + if (edge.target == to) + { + if (edge.source != self) + throw "Incorrect edge source!"; + + edgeList.push(edge); + } + }); + + return edgeList; +}; + +LNode.prototype.getEdgesBetween = function (other) +{ + var edgeList = []; + var edge; + + var self = this; + self.edges.forEach(function(edge) { + + if (!(edge.source == self || edge.target == self)) + throw "Incorrect edge source and/or target"; + + if ((edge.target == other) || (edge.source == other)) + { + edgeList.push(edge); + } + }); + + return edgeList; +}; + +LNode.prototype.getNeighborsList = function () +{ + var neighbors = new Set(); + + var self = this; + self.edges.forEach(function(edge) { + + if (edge.source == self) + { + neighbors.add(edge.target); + } + else + { + if (edge.target != self) { + throw "Incorrect incidency!"; + } + + neighbors.add(edge.source); + } + }); + + return neighbors; +}; + +LNode.prototype.withChildren = function () +{ + var withNeighborsList = new Set(); + var childNode; + var children; + + withNeighborsList.add(this); + + if (this.child != null) + { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) + { + childNode = nodes[i]; + children = childNode.withChildren(); + children.forEach(function(node) { + withNeighborsList.add(node); + }); + } + } + + return withNeighborsList; +}; + +LNode.prototype.getNoOfChildren = function () +{ + var noOfChildren = 0; + var childNode; + + if(this.child == null){ + noOfChildren = 1; + } + else + { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) + { + childNode = nodes[i]; + + noOfChildren += childNode.getNoOfChildren(); + } + } + + if(noOfChildren == 0){ + noOfChildren = 1; + } + return noOfChildren; +}; + +LNode.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; +}; + +LNode.prototype.calcEstimatedSize = function () { + if (this.child == null) + { + return this.estimatedSize = (this.rect.width + this.rect.height) / 2; + } + else + { + this.estimatedSize = this.child.calcEstimatedSize(); + this.rect.width = this.estimatedSize; + this.rect.height = this.estimatedSize; + + return this.estimatedSize; + } +}; + +LNode.prototype.scatter = function () { + var randomCenterX; + var randomCenterY; + + var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterX = LayoutConstants.WORLD_CENTER_X + + (RandomSeed.nextDouble() * (maxX - minX)) + minX; + + var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterY = LayoutConstants.WORLD_CENTER_Y + + (RandomSeed.nextDouble() * (maxY - minY)) + minY; + + this.rect.x = randomCenterX; + this.rect.y = randomCenterY +}; + +LNode.prototype.updateBounds = function () { + if (this.getChild() == null) { + throw "assert failed"; + } + if (this.getChild().getNodes().length != 0) + { + // wrap the children nodes by re-arranging the boundaries + var childGraph = this.getChild(); + childGraph.updateBounds(true); + + this.rect.x = childGraph.getLeft(); + this.rect.y = childGraph.getTop(); + + this.setWidth(childGraph.getRight() - childGraph.getLeft()); + this.setHeight(childGraph.getBottom() - childGraph.getTop()); + + // Update compound bounds considering its label properties + if(LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS){ + + var width = childGraph.getRight() - childGraph.getLeft(); + var height = childGraph.getBottom() - childGraph.getTop(); + + if(this.labelWidth > width){ + this.rect.x -= (this.labelWidth - width) / 2; + this.setWidth(this.labelWidth); + } + + if(this.labelHeight > height){ + if(this.labelPos == "center"){ + this.rect.y -= (this.labelHeight - height) / 2; + } + else if(this.labelPos == "top"){ + this.rect.y -= (this.labelHeight - height); + } + this.setHeight(this.labelHeight); + } + } + } +}; + +LNode.prototype.getInclusionTreeDepth = function () +{ + if (this.inclusionTreeDepth == Integer.MAX_VALUE) { + throw "assert failed"; + } + return this.inclusionTreeDepth; +}; + +LNode.prototype.transform = function (trans) +{ + var left = this.rect.x; + + if (left > LayoutConstants.WORLD_BOUNDARY) + { + left = LayoutConstants.WORLD_BOUNDARY; + } + else if (left < -LayoutConstants.WORLD_BOUNDARY) + { + left = -LayoutConstants.WORLD_BOUNDARY; + } + + var top = this.rect.y; + + if (top > LayoutConstants.WORLD_BOUNDARY) + { + top = LayoutConstants.WORLD_BOUNDARY; + } + else if (top < -LayoutConstants.WORLD_BOUNDARY) + { + top = -LayoutConstants.WORLD_BOUNDARY; + } + + var leftTop = new PointD(left, top); + var vLeftTop = trans.inverseTransformPoint(leftTop); + + this.setLocation(vLeftTop.x, vLeftTop.y); +}; + +LNode.prototype.getLeft = function () +{ + return this.rect.x; +}; + +LNode.prototype.getRight = function () +{ + return this.rect.x + this.rect.width; +}; + +LNode.prototype.getTop = function () +{ + return this.rect.y; +}; + +LNode.prototype.getBottom = function () +{ + return this.rect.y + this.rect.height; +}; + +LNode.prototype.getParent = function () +{ + if (this.owner == null) + { + return null; + } + + return this.owner.getParent(); +}; + +module.exports = LNode; diff --git a/tools/ui/node_modules/layout-base/src/Layout.js b/tools/ui/node_modules/layout-base/src/Layout.js new file mode 100644 index 0000000000000000000000000000000000000000..507313723c0a42634fdbbf56d56f180649be2d38 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/Layout.js @@ -0,0 +1,672 @@ +var LayoutConstants = require('./LayoutConstants'); +var LGraphManager = require('./LGraphManager'); +var LNode = require('./LNode'); +var LEdge = require('./LEdge'); +var LGraph = require('./LGraph'); +var PointD = require('./util/PointD'); +var Transform = require('./util/Transform'); +var Emitter = require('./util/Emitter'); + +function Layout(isRemoteUse) { + Emitter.call( this ); + + //Layout Quality: 0:draft, 1:default, 2:proof + this.layoutQuality = LayoutConstants.QUALITY; + //Whether layout should create bendpoints as needed or not + this.createBendsAsNeeded = + LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + //Whether layout should be incremental or not + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + //Whether we animate from before to after layout node positions + this.animationOnLayout = + LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + //Whether we animate the layout process or not + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + //Number iterations that should be done between two successive animations + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + /** + * Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When + * they are, both spring and repulsion forces between two leaf nodes can be + * calculated without the expensive clipping point calculations, resulting + * in major speed-up. + */ + this.uniformLeafNodeSizes = + LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + /** + * This is used for creation of bendpoints by using dummy nodes and edges. + * Maps an LEdge to its dummy bendpoint path. + */ + this.edgeToDummyNodes = new Map(); + this.graphManager = new LGraphManager(this); + this.isLayoutFinished = false; + this.isSubLayout = false; + this.isRemoteUse = false; + + if (isRemoteUse != null) { + this.isRemoteUse = isRemoteUse; + } +} + +Layout.RANDOM_SEED = 1; + +Layout.prototype = Object.create( Emitter.prototype ); + +Layout.prototype.getGraphManager = function () { + return this.graphManager; +}; + +Layout.prototype.getAllNodes = function () { + return this.graphManager.getAllNodes(); +}; + +Layout.prototype.getAllEdges = function () { + return this.graphManager.getAllEdges(); +}; + +Layout.prototype.getAllNodesToApplyGravitation = function () { + return this.graphManager.getAllNodesToApplyGravitation(); +}; + +Layout.prototype.newGraphManager = function () { + var gm = new LGraphManager(this); + this.graphManager = gm; + return gm; +}; + +Layout.prototype.newGraph = function (vGraph) +{ + return new LGraph(null, this.graphManager, vGraph); +}; + +Layout.prototype.newNode = function (vNode) +{ + return new LNode(this.graphManager, vNode); +}; + +Layout.prototype.newEdge = function (vEdge) +{ + return new LEdge(null, null, vEdge); +}; + +Layout.prototype.checkLayoutSuccess = function() { + return (this.graphManager.getRoot() == null) + || this.graphManager.getRoot().getNodes().length == 0 + || this.graphManager.includesInvalidEdge(); +}; + +Layout.prototype.runLayout = function () +{ + this.isLayoutFinished = false; + + if (this.tilingPreLayout) { + this.tilingPreLayout(); + } + + this.initParameters(); + var isLayoutSuccessfull; + + if (this.checkLayoutSuccess()) + { + isLayoutSuccessfull = false; + } + else + { + isLayoutSuccessfull = this.layout(); + } + + if (LayoutConstants.ANIMATE === 'during') { + // If this is a 'during' layout animation. Layout is not finished yet. + // We need to perform these in index.js when layout is really finished. + return false; + } + + if (isLayoutSuccessfull) + { + if (!this.isSubLayout) + { + this.doPostLayout(); + } + } + + if (this.tilingPostLayout) { + this.tilingPostLayout(); + } + + this.isLayoutFinished = true; + + return isLayoutSuccessfull; +}; + +/** + * This method performs the operations required after layout. + */ +Layout.prototype.doPostLayout = function () +{ + //assert !isSubLayout : "Should not be called on sub-layout!"; + // Propagate geometric changes to v-level objects + if(!this.incremental){ + this.transform(); + } + this.update(); +}; + +/** + * This method updates the geometry of the target graph according to + * calculated layout. + */ +Layout.prototype.update2 = function () { + // update bend points + if (this.createBendsAsNeeded) + { + this.createBendpointsFromDummyNodes(); + + // reset all edges, since the topology has changed + this.graphManager.resetAllEdges(); + } + + // perform edge, node and root updates if layout is not called + // remotely + if (!this.isRemoteUse) + { + // update all edges + var edge; + var allEdges = this.graphManager.getAllEdges(); + for (var i = 0; i < allEdges.length; i++) + { + edge = allEdges[i]; +// this.update(edge); + } + + // recursively update nodes + var node; + var nodes = this.graphManager.getRoot().getNodes(); + for (var i = 0; i < nodes.length; i++) + { + node = nodes[i]; +// this.update(node); + } + + // update root graph + this.update(this.graphManager.getRoot()); + } +}; + +Layout.prototype.update = function (obj) { + if (obj == null) { + this.update2(); + } + else if (obj instanceof LNode) { + var node = obj; + if (node.getChild() != null) + { + // since node is compound, recursively update child nodes + var nodes = node.getChild().getNodes(); + for (var i = 0; i < nodes.length; i++) + { + update(nodes[i]); + } + } + + // if the l-level node is associated with a v-level graph object, + // then it is assumed that the v-level node implements the + // interface Updatable. + if (node.vGraphObject != null) + { + // cast to Updatable without any type check + var vNode = node.vGraphObject; + + // call the update method of the interface + vNode.update(node); + } + } + else if (obj instanceof LEdge) { + var edge = obj; + // if the l-level edge is associated with a v-level graph object, + // then it is assumed that the v-level edge implements the + // interface Updatable. + + if (edge.vGraphObject != null) + { + // cast to Updatable without any type check + var vEdge = edge.vGraphObject; + + // call the update method of the interface + vEdge.update(edge); + } + } + else if (obj instanceof LGraph) { + var graph = obj; + // if the l-level graph is associated with a v-level graph object, + // then it is assumed that the v-level object implements the + // interface Updatable. + + if (graph.vGraphObject != null) + { + // cast to Updatable without any type check + var vGraph = graph.vGraphObject; + + // call the update method of the interface + vGraph.update(graph); + } + } +}; + +/** + * This method is used to set all layout parameters to default values + * determined at compile time. + */ +Layout.prototype.initParameters = function () { + if (!this.isSubLayout) + { + this.layoutQuality = LayoutConstants.QUALITY; + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + } + + if (this.animationDuringLayout) + { + this.animationOnLayout = false; + } +}; + +Layout.prototype.transform = function (newLeftTop) { + if (newLeftTop == undefined) { + this.transform(new PointD(0, 0)); + } + else { + // create a transformation object (from Eclipse to layout). When an + // inverse transform is applied, we get upper-left coordinate of the + // drawing or the root graph at given input coordinate (some margins + // already included in calculation of left-top). + + var trans = new Transform(); + var leftTop = this.graphManager.getRoot().updateLeftTop(); + + if (leftTop != null) + { + trans.setWorldOrgX(newLeftTop.x); + trans.setWorldOrgY(newLeftTop.y); + + trans.setDeviceOrgX(leftTop.x); + trans.setDeviceOrgY(leftTop.y); + + var nodes = this.getAllNodes(); + var node; + + for (var i = 0; i < nodes.length; i++) + { + node = nodes[i]; + node.transform(trans); + } + } + } +}; + +Layout.prototype.positionNodesRandomly = function (graph) { + + if (graph == undefined) { + //assert !this.incremental; + this.positionNodesRandomly(this.getGraphManager().getRoot()); + this.getGraphManager().getRoot().updateBounds(true); + } + else { + var lNode; + var childGraph; + + var nodes = graph.getNodes(); + for (var i = 0; i < nodes.length; i++) + { + lNode = nodes[i]; + childGraph = lNode.getChild(); + + if (childGraph == null) + { + lNode.scatter(); + } + else if (childGraph.getNodes().length == 0) + { + lNode.scatter(); + } + else + { + this.positionNodesRandomly(childGraph); + lNode.updateBounds(); + } + } + } +}; + +/** + * This method returns a list of trees where each tree is represented as a + * list of l-nodes. The method returns a list of size 0 when: + * - The graph is not flat or + * - One of the component(s) of the graph is not a tree. + */ +Layout.prototype.getFlatForest = function () +{ + var flatForest = []; + var isForest = true; + + // Quick reference for all nodes in the graph manager associated with + // this layout. The list should not be changed. + var allNodes = this.graphManager.getRoot().getNodes(); + + // First be sure that the graph is flat + var isFlat = true; + + for (var i = 0; i < allNodes.length; i++) + { + if (allNodes[i].getChild() != null) + { + isFlat = false; + } + } + + // Return empty forest if the graph is not flat. + if (!isFlat) + { + return flatForest; + } + + // Run BFS for each component of the graph. + + var visited = new Set(); + var toBeVisited = []; + var parents = new Map(); + var unProcessedNodes = []; + + unProcessedNodes = unProcessedNodes.concat(allNodes); + + // Each iteration of this loop finds a component of the graph and + // decides whether it is a tree or not. If it is a tree, adds it to the + // forest and continued with the next component. + + while (unProcessedNodes.length > 0 && isForest) + { + toBeVisited.push(unProcessedNodes[0]); + + // Start the BFS. Each iteration of this loop visits a node in a + // BFS manner. + while (toBeVisited.length > 0 && isForest) + { + //pool operation + var currentNode = toBeVisited[0]; + toBeVisited.splice(0, 1); + visited.add(currentNode); + + // Traverse all neighbors of this node + var neighborEdges = currentNode.getEdges(); + + for (var i = 0; i < neighborEdges.length; i++) + { + var currentNeighbor = + neighborEdges[i].getOtherEnd(currentNode); + + // If BFS is not growing from this neighbor. + if (parents.get(currentNode) != currentNeighbor) + { + // We haven't previously visited this neighbor. + if (!visited.has(currentNeighbor)) + { + toBeVisited.push(currentNeighbor); + parents.set(currentNeighbor, currentNode); + } + // Since we have previously visited this neighbor and + // this neighbor is not parent of currentNode, given + // graph contains a component that is not tree, hence + // it is not a forest. + else + { + isForest = false; + break; + } + } + } + } + + // The graph contains a component that is not a tree. Empty + // previously found trees. The method will end. + if (!isForest) + { + flatForest = []; + } + // Save currently visited nodes as a tree in our forest. Reset + // visited and parents lists. Continue with the next component of + // the graph, if any. + else + { + var temp = [...visited]; + flatForest.push(temp); + //flatForest = flatForest.concat(temp); + //unProcessedNodes.removeAll(visited); + for (var i = 0; i < temp.length; i++) { + var value = temp[i]; + var index = unProcessedNodes.indexOf(value); + if (index > -1) { + unProcessedNodes.splice(index, 1); + } + } + visited = new Set(); + parents = new Map(); + } + } + + return flatForest; +}; + +/** + * This method creates dummy nodes (an l-level node with minimal dimensions) + * for the given edge (one per bendpoint). The existing l-level structure + * is updated accordingly. + */ +Layout.prototype.createDummyNodesForBendpoints = function (edge) +{ + var dummyNodes = []; + var prev = edge.source; + + var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target); + + for (var i = 0; i < edge.bendpoints.length; i++) + { + // create new dummy node + var dummyNode = this.newNode(null); + dummyNode.setRect(new Point(0, 0), new Dimension(1, 1)); + + graph.add(dummyNode); + + // create new dummy edge between prev and dummy node + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, dummyNode); + + dummyNodes.add(dummyNode); + prev = dummyNode; + } + + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, edge.target); + + this.edgeToDummyNodes.set(edge, dummyNodes); + + // remove real edge from graph manager if it is inter-graph + if (edge.isInterGraph()) + { + this.graphManager.remove(edge); + } + // else, remove the edge from the current graph + else + { + graph.remove(edge); + } + + return dummyNodes; +}; + +/** + * This method creates bendpoints for edges from the dummy nodes + * at l-level. + */ +Layout.prototype.createBendpointsFromDummyNodes = function () +{ + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + edges = [...this.edgeToDummyNodes.keys()].concat(edges); + + for (var k = 0; k < edges.length; k++) + { + var lEdge = edges[k]; + + if (lEdge.bendpoints.length > 0) + { + var path = this.edgeToDummyNodes.get(lEdge); + + for (var i = 0; i < path.length; i++) + { + var dummyNode = path[i]; + var p = new PointD(dummyNode.getCenterX(), + dummyNode.getCenterY()); + + // update bendpoint's location according to dummy node + var ebp = lEdge.bendpoints.get(i); + ebp.x = p.x; + ebp.y = p.y; + + // remove the dummy node, dummy edges incident with this + // dummy node is also removed (within the remove method) + dummyNode.getOwner().remove(dummyNode); + } + + // add the real edge to graph + this.graphManager.add(lEdge, lEdge.source, lEdge.target); + } + } +}; + +Layout.transform = function (sliderValue, defaultValue, minDiv, maxMul) { + if (minDiv != undefined && maxMul != undefined) { + var value = defaultValue; + + if (sliderValue <= 50) + { + var minValue = defaultValue / minDiv; + value -= ((defaultValue - minValue) / 50) * (50 - sliderValue); + } + else + { + var maxValue = defaultValue * maxMul; + value += ((maxValue - defaultValue) / 50) * (sliderValue - 50); + } + + return value; + } + else { + var a, b; + + if (sliderValue <= 50) + { + a = 9.0 * defaultValue / 500.0; + b = defaultValue / 10.0; + } + else + { + a = 9.0 * defaultValue / 50.0; + b = -8 * defaultValue; + } + + return (a * sliderValue + b); + } +}; + +/** + * This method finds and returns the center of the given nodes, assuming + * that the given nodes form a tree in themselves. + */ +Layout.findCenterOfTree = function (nodes) +{ + var list = []; + list = list.concat(nodes); + + var removedNodes = []; + var remainingDegrees = new Map(); + var foundCenter = false; + var centerNode = null; + + if (list.length == 1 || list.length == 2) + { + foundCenter = true; + centerNode = list[0]; + } + + for (var i = 0; i < list.length; i++) + { + var node = list[i]; + var degree = node.getNeighborsList().size; + remainingDegrees.set(node, node.getNeighborsList().size); + + if (degree == 1) + { + removedNodes.push(node); + } + } + + var tempList = []; + tempList = tempList.concat(removedNodes); + + while (!foundCenter) + { + var tempList2 = []; + tempList2 = tempList2.concat(tempList); + tempList = []; + + for (var i = 0; i < list.length; i++) + { + var node = list[i]; + + var index = list.indexOf(node); + if (index >= 0) { + list.splice(index, 1); + } + + var neighbours = node.getNeighborsList(); + + neighbours.forEach(function(neighbour) { + if (removedNodes.indexOf(neighbour) < 0) + { + var otherDegree = remainingDegrees.get(neighbour); + var newDegree = otherDegree - 1; + + if (newDegree == 1) + { + tempList.push(neighbour); + } + + remainingDegrees.set(neighbour, newDegree); + } + }); + } + + removedNodes = removedNodes.concat(tempList); + + if (list.length == 1 || list.length == 2) + { + foundCenter = true; + centerNode = list[0]; + } + } + + return centerNode; +}; + +/** + * During the coarsening process, this layout may be referenced by two graph managers + * this setter function grants access to change the currently being used graph manager + */ +Layout.prototype.setGraphManager = function (gm) +{ + this.graphManager = gm; +}; + +module.exports = Layout; diff --git a/tools/ui/node_modules/layout-base/src/LayoutConstants.js b/tools/ui/node_modules/layout-base/src/LayoutConstants.js new file mode 100644 index 0000000000000000000000000000000000000000..c6645820c81795bf98c5ad6c85f4e32f5a078b5f --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/LayoutConstants.js @@ -0,0 +1,70 @@ +function LayoutConstants() { +} + +/** + * Layout Quality: 0:draft, 1:default, 2:proof + */ +LayoutConstants.QUALITY = 1; + +/** + * Default parameters + */ +LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false; +LayoutConstants.DEFAULT_INCREMENTAL = false; +LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true; +LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false; +LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50; +LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false; + +// ----------------------------------------------------------------------------- +// Section: General other constants +// ----------------------------------------------------------------------------- +/* + * Margins of a graph to be applied on bouding rectangle of its contents. We + * assume margins on all four sides to be uniform. + */ +LayoutConstants.DEFAULT_GRAPH_MARGIN = 15; + +/* + * Whether to consider labels in node dimensions or not + */ +LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false; + +/* + * Default dimension of a non-compound node. + */ +LayoutConstants.SIMPLE_NODE_SIZE = 40; + +/* + * Default dimension of a non-compound node. + */ +LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2; + +/* + * Empty compound node size. When a compound node is empty, its both + * dimensions should be of this value. + */ +LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40; + +/* + * Minimum length that an edge should take during layout + */ +LayoutConstants.MIN_EDGE_LENGTH = 1; + +/* + * World boundaries that layout operates on + */ +LayoutConstants.WORLD_BOUNDARY = 1000000; + +/* + * World boundaries that random positioning can be performed with + */ +LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1000; + +/* + * Coordinates of the world center + */ +LayoutConstants.WORLD_CENTER_X = 1200; +LayoutConstants.WORLD_CENTER_Y = 900; + +module.exports = LayoutConstants; diff --git a/tools/ui/node_modules/layout-base/src/fd/FDLayout.js b/tools/ui/node_modules/layout-base/src/fd/FDLayout.js new file mode 100644 index 0000000000000000000000000000000000000000..9fd986e1476ba5921c415f0a7a36a09914e7d4f2 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/fd/FDLayout.js @@ -0,0 +1,529 @@ +var Layout = require('../Layout'); +var FDLayoutConstants = require('./FDLayoutConstants'); +var LayoutConstants = require('../LayoutConstants'); +var IGeometry = require('../util/IGeometry'); +var IMath = require('../util/IMath'); + +function FDLayout() { + Layout.call(this); + + this.useSmartIdealEdgeLengthCalculation = FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.idealEdgeLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH; + this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + this.displacementThresholdPerNode = (3.0 * FDLayoutConstants.DEFAULT_EDGE_LENGTH) / 100; + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.initialCoolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.totalDisplacement = 0.0; + this.oldTotalDisplacement = 0.0; + this.maxIterations = FDLayoutConstants.MAX_ITERATIONS; +} + +FDLayout.prototype = Object.create(Layout.prototype); + +for (var prop in Layout) { + FDLayout[prop] = Layout[prop]; +} + +FDLayout.prototype.initParameters = function () { + Layout.prototype.initParameters.call(this, arguments); + + this.totalIterations = 0; + this.notAnimatedIterations = 0; + + this.useFRGridVariant = FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION; + + this.grid = []; +}; + +FDLayout.prototype.calcIdealEdgeLengths = function () { + var edge; + var lcaDepth; + var source; + var target; + var sizeOfSourceInLca; + var sizeOfTargetInLca; + + var allEdges = this.getGraphManager().getAllEdges(); + for (var i = 0; i < allEdges.length; i++) + { + edge = allEdges[i]; + + edge.idealLength = this.idealEdgeLength; + + if (edge.isInterGraph) + { + source = edge.getSource(); + target = edge.getTarget(); + + sizeOfSourceInLca = edge.getSourceInLca().getEstimatedSize(); + sizeOfTargetInLca = edge.getTargetInLca().getEstimatedSize(); + + if (this.useSmartIdealEdgeLengthCalculation) + { + edge.idealLength += sizeOfSourceInLca + sizeOfTargetInLca - + 2 * LayoutConstants.SIMPLE_NODE_SIZE; + } + + lcaDepth = edge.getLca().getInclusionTreeDepth(); + + edge.idealLength += FDLayoutConstants.DEFAULT_EDGE_LENGTH * + FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * + (source.getInclusionTreeDepth() + + target.getInclusionTreeDepth() - 2 * lcaDepth); + } + } +}; + +FDLayout.prototype.initSpringEmbedder = function () { + + var s = this.getAllNodes().length; + if (this.incremental) { + if(s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT){ + this.coolingFactor = Math.max(this.coolingFactor*FDLayoutConstants.COOLING_ADAPTATION_FACTOR, this.coolingFactor - + (s-FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT)/(FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT-FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL; + } + else { + if(s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT){ + this.coolingFactor = Math.max(FDLayoutConstants.COOLING_ADAPTATION_FACTOR, 1.0 - + (s-FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT)/(FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT-FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT)*(1-FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } + else { + this.coolingFactor = 1.0; + } + this.initialCoolingFactor = this.coolingFactor; + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT; + } + + this.maxIterations = + Math.max(this.getAllNodes().length * 5, this.maxIterations); + + this.totalDisplacementThreshold = + this.displacementThresholdPerNode * this.getAllNodes().length; + + this.repulsionRange = this.calcRepulsionRange(); +}; + +FDLayout.prototype.calcSpringForces = function () { + var lEdges = this.getAllEdges(); + var edge; + + for (var i = 0; i < lEdges.length; i++) + { + edge = lEdges[i]; + + this.calcSpringForce(edge, edge.idealLength); + } +}; + +FDLayout.prototype.calcRepulsionForces = function (gridUpdateAllowed = true, forceToNodeSurroundingUpdate = false) { + var i, j; + var nodeA, nodeB; + var lNodes = this.getAllNodes(); + var processedNodeSet; + + if (this.useFRGridVariant) + { + if ((this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed)) + { + this.updateGrid(); + } + + processedNodeSet = new Set(); + + // calculate repulsion forces between each nodes and its surrounding + for (i = 0; i < lNodes.length; i++) + { + nodeA = lNodes[i]; + this.calculateRepulsionForceOfANode(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate); + processedNodeSet.add(nodeA); + } + } + else + { + for (i = 0; i < lNodes.length; i++) + { + nodeA = lNodes[i]; + + for (j = i + 1; j < lNodes.length; j++) + { + nodeB = lNodes[j]; + + // If both nodes are not members of the same graph, skip. + if (nodeA.getOwner() != nodeB.getOwner()) + { + continue; + } + + this.calcRepulsionForce(nodeA, nodeB); + } + } + } +}; + +FDLayout.prototype.calcGravitationalForces = function () { + var node; + var lNodes = this.getAllNodesToApplyGravitation(); + + for (var i = 0; i < lNodes.length; i++) + { + node = lNodes[i]; + this.calcGravitationalForce(node); + } +}; + +FDLayout.prototype.moveNodes = function () { + var lNodes = this.getAllNodes(); + var node; + + for (var i = 0; i < lNodes.length; i++) + { + node = lNodes[i]; + node.move(); + } +} + +FDLayout.prototype.calcSpringForce = function (edge, idealLength) { + var sourceNode = edge.getSource(); + var targetNode = edge.getTarget(); + + var length; + var springForce; + var springForceX; + var springForceY; + + // Update edge length + if (this.uniformLeafNodeSizes && + sourceNode.getChild() == null && targetNode.getChild() == null) + { + edge.updateLengthSimple(); + } + else + { + edge.updateLength(); + + if (edge.isOverlapingSourceAndTarget) + { + return; + } + } + + length = edge.getLength(); + + if(length == 0) + return; + + // Calculate spring forces + springForce = this.springConstant * (length - idealLength); + + // Project force onto x and y axes + springForceX = springForce * (edge.lengthX / length); + springForceY = springForce * (edge.lengthY / length); + + // Apply forces on the end nodes + sourceNode.springForceX += springForceX; + sourceNode.springForceY += springForceY; + targetNode.springForceX -= springForceX; + targetNode.springForceY -= springForceY; +}; + +FDLayout.prototype.calcRepulsionForce = function (nodeA, nodeB) { + var rectA = nodeA.getRect(); + var rectB = nodeB.getRect(); + var overlapAmount = new Array(2); + var clipPoints = new Array(4); + var distanceX; + var distanceY; + var distanceSquared; + var distance; + var repulsionForce; + var repulsionForceX; + var repulsionForceY; + + if (rectA.intersects(rectB))// two nodes overlap + { + // calculate separation amount in x and y directions + IGeometry.calcSeparationAmount(rectA, + rectB, + overlapAmount, + FDLayoutConstants.DEFAULT_EDGE_LENGTH / 2.0); + + repulsionForceX = 2 * overlapAmount[0]; + repulsionForceY = 2 * overlapAmount[1]; + + var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren); + + // Apply forces on the two nodes + nodeA.repulsionForceX -= childrenConstant * repulsionForceX; + nodeA.repulsionForceY -= childrenConstant * repulsionForceY; + nodeB.repulsionForceX += childrenConstant * repulsionForceX; + nodeB.repulsionForceY += childrenConstant * repulsionForceY; + } + else// no overlap + { + // calculate distance + + if (this.uniformLeafNodeSizes && + nodeA.getChild() == null && nodeB.getChild() == null)// simply base repulsion on distance of node centers + { + distanceX = rectB.getCenterX() - rectA.getCenterX(); + distanceY = rectB.getCenterY() - rectA.getCenterY(); + } + else// use clipping points + { + IGeometry.getIntersection(rectA, rectB, clipPoints); + + distanceX = clipPoints[2] - clipPoints[0]; + distanceY = clipPoints[3] - clipPoints[1]; + } + + // No repulsion range. FR grid variant should take care of this. + if (Math.abs(distanceX) < FDLayoutConstants.MIN_REPULSION_DIST) + { + distanceX = IMath.sign(distanceX) * + FDLayoutConstants.MIN_REPULSION_DIST; + } + + if (Math.abs(distanceY) < FDLayoutConstants.MIN_REPULSION_DIST) + { + distanceY = IMath.sign(distanceY) * + FDLayoutConstants.MIN_REPULSION_DIST; + } + + distanceSquared = distanceX * distanceX + distanceY * distanceY; + distance = Math.sqrt(distanceSquared); + + repulsionForce = this.repulsionConstant * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared; + + // Project force onto x and y axes + repulsionForceX = repulsionForce * distanceX / distance; + repulsionForceY = repulsionForce * distanceY / distance; + + // Apply forces on the two nodes + nodeA.repulsionForceX -= repulsionForceX; + nodeA.repulsionForceY -= repulsionForceY; + nodeB.repulsionForceX += repulsionForceX; + nodeB.repulsionForceY += repulsionForceY; + } +}; + +FDLayout.prototype.calcGravitationalForce = function (node) { + var ownerGraph; + var ownerCenterX; + var ownerCenterY; + var distanceX; + var distanceY; + var absDistanceX; + var absDistanceY; + var estimatedSize; + ownerGraph = node.getOwner(); + + ownerCenterX = (ownerGraph.getRight() + ownerGraph.getLeft()) / 2; + ownerCenterY = (ownerGraph.getTop() + ownerGraph.getBottom()) / 2; + distanceX = node.getCenterX() - ownerCenterX; + distanceY = node.getCenterY() - ownerCenterY; + absDistanceX = Math.abs(distanceX) + node.getWidth() / 2; + absDistanceY = Math.abs(distanceY) + node.getHeight() / 2; + + if (node.getOwner() == this.graphManager.getRoot())// in the root graph + { + estimatedSize = ownerGraph.getEstimatedSize() * this.gravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) + { + node.gravitationForceX = -this.gravityConstant * distanceX; + node.gravitationForceY = -this.gravityConstant * distanceY; + } + } + else// inside a compound + { + estimatedSize = ownerGraph.getEstimatedSize() * this.compoundGravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) + { + node.gravitationForceX = -this.gravityConstant * distanceX * + this.compoundGravityConstant; + node.gravitationForceY = -this.gravityConstant * distanceY * + this.compoundGravityConstant; + } + } +}; + +FDLayout.prototype.isConverged = function () { + var converged; + var oscilating = false; + + if (this.totalIterations > this.maxIterations / 3) + { + oscilating = + Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2; + } + + converged = this.totalDisplacement < this.totalDisplacementThreshold; + + this.oldTotalDisplacement = this.totalDisplacement; + + return converged || oscilating; +}; + +FDLayout.prototype.animate = function () { + if (this.animationDuringLayout && !this.isSubLayout) + { + if (this.notAnimatedIterations == this.animationPeriod) + { + this.update(); + this.notAnimatedIterations = 0; + } + else + { + this.notAnimatedIterations++; + } + } +}; + +//This method calculates the number of children (weight) for all nodes +FDLayout.prototype.calcNoOfChildrenForAllNodes = function () +{ + var node; + var allNodes = this.graphManager.getAllNodes(); + + for(var i = 0; i < allNodes.length; i++) + { + node = allNodes[i]; + node.noOfChildren = node.getNoOfChildren(); + } +}; + +// ----------------------------------------------------------------------------- +// Section: FR-Grid Variant Repulsion Force Calculation +// ----------------------------------------------------------------------------- + +FDLayout.prototype.calcGrid = function (graph){ + + var sizeX = 0; + var sizeY = 0; + + sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange)); + sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange)); + + var grid = new Array(sizeX); + + for(var i = 0; i < sizeX; i++){ + grid[i] = new Array(sizeY); + } + + for(var i = 0; i < sizeX; i++){ + for(var j = 0; j < sizeY; j++){ + grid[i][j] = new Array(); + } + } + + return grid; +}; + +FDLayout.prototype.addNodeToGrid = function (v, left, top){ + + var startX = 0; + var finishX = 0; + var startY = 0; + var finishY = 0; + + startX = parseInt(Math.floor((v.getRect().x - left) / this.repulsionRange)); + finishX = parseInt(Math.floor((v.getRect().width + v.getRect().x - left) / this.repulsionRange)); + startY = parseInt(Math.floor((v.getRect().y - top) / this.repulsionRange)); + finishY = parseInt(Math.floor((v.getRect().height + v.getRect().y - top) / this.repulsionRange)); + + for (var i = startX; i <= finishX; i++) + { + for (var j = startY; j <= finishY; j++) + { + this.grid[i][j].push(v); + v.setGridCoordinates(startX, finishX, startY, finishY); + } + } + +}; + +FDLayout.prototype.updateGrid = function() { + var i; + var nodeA; + var lNodes = this.getAllNodes(); + + this.grid = this.calcGrid(this.graphManager.getRoot()); + + // put all nodes to proper grid cells + for (i = 0; i < lNodes.length; i++) + { + nodeA = lNodes[i]; + this.addNodeToGrid(nodeA, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop()); + } + +}; + +FDLayout.prototype.calculateRepulsionForceOfANode = function (nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate){ + + if ((this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed) || forceToNodeSurroundingUpdate) + { + var surrounding = new Set(); + nodeA.surrounding = new Array(); + var nodeB; + var grid = this.grid; + + for (var i = (nodeA.startX - 1); i < (nodeA.finishX + 2); i++) + { + for (var j = (nodeA.startY - 1); j < (nodeA.finishY + 2); j++) + { + if (!((i < 0) || (j < 0) || (i >= grid.length) || (j >= grid[0].length))) + { + for (var k = 0; k < grid[i][j].length; k++) { + nodeB = grid[i][j][k]; + + // If both nodes are not members of the same graph, + // or both nodes are the same, skip. + if ((nodeA.getOwner() != nodeB.getOwner()) || (nodeA == nodeB)) + { + continue; + } + + // check if the repulsion force between + // nodeA and nodeB has already been calculated + if (!processedNodeSet.has(nodeB) && !surrounding.has(nodeB)) + { + var distanceX = Math.abs(nodeA.getCenterX()-nodeB.getCenterX()) - + ((nodeA.getWidth()/2) + (nodeB.getWidth()/2)); + var distanceY = Math.abs(nodeA.getCenterY()-nodeB.getCenterY()) - + ((nodeA.getHeight()/2) + (nodeB.getHeight()/2)); + + // if the distance between nodeA and nodeB + // is less then calculation range + if ((distanceX <= this.repulsionRange) && (distanceY <= this.repulsionRange)) + { + //then add nodeB to surrounding of nodeA + surrounding.add(nodeB); + } + } + } + } + } + } + + nodeA.surrounding = [...surrounding]; + + } + for (i = 0; i < nodeA.surrounding.length; i++) + { + this.calcRepulsionForce(nodeA, nodeA.surrounding[i]); + } +}; + +FDLayout.prototype.calcRepulsionRange = function () { + return 0.0; +}; + +module.exports = FDLayout; diff --git a/tools/ui/node_modules/layout-base/src/fd/FDLayoutConstants.js b/tools/ui/node_modules/layout-base/src/fd/FDLayoutConstants.js new file mode 100644 index 0000000000000000000000000000000000000000..35982be9a49f49c073080d4784877622b7545517 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/fd/FDLayoutConstants.js @@ -0,0 +1,34 @@ +var LayoutConstants = require('../LayoutConstants'); + +function FDLayoutConstants() { +} + +//FDLayoutConstants inherits static props in LayoutConstants +for (var prop in LayoutConstants) { + FDLayoutConstants[prop] = LayoutConstants[prop]; +} + +FDLayoutConstants.MAX_ITERATIONS = 2500; + +FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50; +FDLayoutConstants.DEFAULT_SPRING_STRENGTH = 0.45; +FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500.0; +FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = 0.4; +FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1.0; +FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8; +FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5; +FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true; +FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true; +FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3; +FDLayoutConstants.COOLING_ADAPTATION_FACTOR = 0.33; +FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1000; +FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5000; +FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100.0; +FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3; +FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0; +FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100; +FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1; +FDLayoutConstants.MIN_EDGE_LENGTH = 1; +FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10; + +module.exports = FDLayoutConstants; diff --git a/tools/ui/node_modules/layout-base/src/fd/FDLayoutEdge.js b/tools/ui/node_modules/layout-base/src/fd/FDLayoutEdge.js new file mode 100644 index 0000000000000000000000000000000000000000..33df2253fa17fe2afc22004341c733688ca40bb9 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/fd/FDLayoutEdge.js @@ -0,0 +1,15 @@ +var LEdge = require('../LEdge'); +var FDLayoutConstants = require('./FDLayoutConstants'); + +function FDLayoutEdge(source, target, vEdge) { + LEdge.call(this, source, target, vEdge); + this.idealLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; +} + +FDLayoutEdge.prototype = Object.create(LEdge.prototype); + +for (var prop in LEdge) { + FDLayoutEdge[prop] = LEdge[prop]; +} + +module.exports = FDLayoutEdge; diff --git a/tools/ui/node_modules/layout-base/src/fd/FDLayoutNode.js b/tools/ui/node_modules/layout-base/src/fd/FDLayoutNode.js new file mode 100644 index 0000000000000000000000000000000000000000..189e364863f10e515049b8aaf5166a290421b2a2 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/fd/FDLayoutNode.js @@ -0,0 +1,42 @@ +var LNode = require('../LNode'); + +function FDLayoutNode(gm, loc, size, vNode) { + // alternative constructor is handled inside LNode + LNode.call(this, gm, loc, size, vNode); + //Spring, repulsion and gravitational forces acting on this node + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + //Amount by which this node is to be moved in this iteration + this.displacementX = 0; + this.displacementY = 0; + + //Start and finish grid coordinates that this node is fallen into + this.startX = 0; + this.finishX = 0; + this.startY = 0; + this.finishY = 0; + + //Geometric neighbors of this node + this.surrounding = []; +} + +FDLayoutNode.prototype = Object.create(LNode.prototype); + +for (var prop in LNode) { + FDLayoutNode[prop] = LNode[prop]; +} + +FDLayoutNode.prototype.setGridCoordinates = function (_startX, _finishX, _startY, _finishY) +{ + this.startX = _startX; + this.finishX = _finishX; + this.startY = _startY; + this.finishY = _finishY; + +}; + +module.exports = FDLayoutNode; diff --git a/tools/ui/node_modules/layout-base/src/util/DimensionD.js b/tools/ui/node_modules/layout-base/src/util/DimensionD.js new file mode 100644 index 0000000000000000000000000000000000000000..8632401eba8de3f019f3cec4d19f2b7bbec12ad5 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/DimensionD.js @@ -0,0 +1,30 @@ +function DimensionD(width, height) { + this.width = 0; + this.height = 0; + if (width !== null && height !== null) { + this.height = height; + this.width = width; + } +} + +DimensionD.prototype.getWidth = function () +{ + return this.width; +}; + +DimensionD.prototype.setWidth = function (width) +{ + this.width = width; +}; + +DimensionD.prototype.getHeight = function () +{ + return this.height; +}; + +DimensionD.prototype.setHeight = function (height) +{ + this.height = height; +}; + +module.exports = DimensionD; diff --git a/tools/ui/node_modules/layout-base/src/util/Emitter.js b/tools/ui/node_modules/layout-base/src/util/Emitter.js new file mode 100644 index 0000000000000000000000000000000000000000..b4d4934cf849fb2b94d0f6a06221d3a26726ec6b --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/Emitter.js @@ -0,0 +1,34 @@ +function Emitter(){ + this.listeners = []; +} + +var p = Emitter.prototype; + +p.addListener = function( event, callback ){ + this.listeners.push({ + event: event, + callback: callback + }); +}; + +p.removeListener = function( event, callback ){ + for( var i = this.listeners.length; i >= 0; i-- ){ + var l = this.listeners[i]; + + if( l.event === event && l.callback === callback ){ + this.listeners.splice( i, 1 ); + } + } +}; + +p.emit = function( event, data ){ + for( var i = 0; i < this.listeners.length; i++ ){ + var l = this.listeners[i]; + + if( event === l.event ){ + l.callback( data ); + } + } +}; + +module.exports = Emitter; diff --git a/tools/ui/node_modules/layout-base/src/util/HashMap.js b/tools/ui/node_modules/layout-base/src/util/HashMap.js new file mode 100644 index 0000000000000000000000000000000000000000..0d8ad3e21900f92ad62433221325464f8e8ec80f --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/HashMap.js @@ -0,0 +1,30 @@ +var UniqueIDGeneretor = require('./UniqueIDGeneretor'); + +function HashMap() { + this.map = {}; + this.keys = []; +} + +HashMap.prototype.put = function (key, value) { + var theId = UniqueIDGeneretor.createID(key); + if (!this.contains(theId)) { + this.map[theId] = value; + this.keys.push(key); + } +}; + +HashMap.prototype.contains = function (key) { + var theId = UniqueIDGeneretor.createID(key); + return this.map[key] != null; +}; + +HashMap.prototype.get = function (key) { + var theId = UniqueIDGeneretor.createID(key); + return this.map[theId]; +}; + +HashMap.prototype.keySet = function () { + return this.keys; +}; + +module.exports = HashMap; diff --git a/tools/ui/node_modules/layout-base/src/util/HashSet.js b/tools/ui/node_modules/layout-base/src/util/HashSet.js new file mode 100644 index 0000000000000000000000000000000000000000..84c23fc6cdff0e8b90aee8f3d2d71164f0f22422 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/HashSet.js @@ -0,0 +1,55 @@ +var UniqueIDGeneretor = require('./UniqueIDGeneretor'); + +function HashSet() { + this.set = {}; +} +; + +HashSet.prototype.add = function (obj) { + var theId = UniqueIDGeneretor.createID(obj); + if (!this.contains(theId)) + this.set[theId] = obj; +}; + +HashSet.prototype.remove = function (obj) { + delete this.set[UniqueIDGeneretor.createID(obj)]; +}; + +HashSet.prototype.clear = function () { + this.set = {}; +}; + +HashSet.prototype.contains = function (obj) { + return this.set[UniqueIDGeneretor.createID(obj)] == obj; +}; + +HashSet.prototype.isEmpty = function () { + return this.size() === 0; +}; + +HashSet.prototype.size = function () { + return Object.keys(this.set).length; +}; + +//concats this.set to the given list +HashSet.prototype.addAllTo = function (list) { + var keys = Object.keys(this.set); + var length = keys.length; + for (var i = 0; i < length; i++) { + list.push(this.set[keys[i]]); + } +}; + +HashSet.prototype.size = function () { + return Object.keys(this.set).length; +}; + +HashSet.prototype.addAll = function (list) { + var s = list.length; + for (var i = 0; i < s; i++) { + var v = list[i]; + this.add(v); + } +}; + +module.exports = HashSet; diff --git a/tools/ui/node_modules/layout-base/src/util/IGeometry.js b/tools/ui/node_modules/layout-base/src/util/IGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..dfbacb52f76604bc1cede548361ec41b128c5ec1 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/IGeometry.js @@ -0,0 +1,567 @@ +/** + * This class maintains a list of static geometry related utility methods. + * + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + +const Point = require('./Point'); + +function IGeometry() { + +} + +/** + * This method calculates *half* the amount in x and y directions of the two + * input rectangles needed to separate them keeping their respective + * positioning, and returns the result in the input array. An input + * separation buffer added to the amount in both directions. We assume that + * the two rectangles do intersect. + */ +IGeometry.calcSeparationAmount = function (rectA, rectB, overlapAmount, separationBuffer) +{ + if (!rectA.intersects(rectB)) { + throw "assert failed"; + } + + let directions = new Array(2); + + this.decideDirectionsForOverlappingNodes(rectA, rectB, directions); + + overlapAmount[0] = Math.min(rectA.getRight(), rectB.getRight()) - + Math.max(rectA.x, rectB.x); + overlapAmount[1] = Math.min(rectA.getBottom(), rectB.getBottom()) - + Math.max(rectA.y, rectB.y); + + // update the overlapping amounts for the following cases: + if ((rectA.getX() <= rectB.getX()) && (rectA.getRight() >= rectB.getRight())) + { + /* Case x.1: + * + * rectA + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectB + */ + overlapAmount[0] += Math.min((rectB.getX() - rectA.getX()), + (rectA.getRight() - rectB.getRight())); + } + else if ((rectB.getX() <= rectA.getX()) && (rectB.getRight() >= rectA.getRight())) + { + /* Case x.2: + * + * rectB + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectA + */ + overlapAmount[0] += Math.min((rectA.getX() - rectB.getX()), + (rectB.getRight() - rectA.getRight())); + } + if ((rectA.getY() <= rectB.getY()) && (rectA.getBottom() >= rectB.getBottom())) + { + /* Case y.1: + * ________ rectA + * | + * | + * ______|____ rectB + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min((rectB.getY() - rectA.getY()), + (rectA.getBottom() - rectB.getBottom())); + } + else if ((rectB.getY() <= rectA.getY()) && (rectB.getBottom() >= rectA.getBottom())) + { + /* Case y.2: + * ________ rectB + * | + * | + * ______|____ rectA + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min((rectA.getY() - rectB.getY()), + (rectB.getBottom() - rectA.getBottom())); + } + + // find slope of the line passes two centers + let slope = Math.abs((rectB.getCenterY() - rectA.getCenterY()) / + (rectB.getCenterX() - rectA.getCenterX())); + // if centers are overlapped + if ((rectB.getCenterY() === rectA.getCenterY()) && + (rectB.getCenterX() === rectA.getCenterX())) + { + // assume the slope is 1 (45 degree) + slope = 1.0; + } + + let moveByY = slope * overlapAmount[0]; + let moveByX = overlapAmount[1] / slope; + if (overlapAmount[0] < moveByX) + { + moveByX = overlapAmount[0]; + } + else + { + moveByY = overlapAmount[1]; + } + // return half the amount so that if each rectangle is moved by these + // amounts in opposite directions, overlap will be resolved + overlapAmount[0] = -1 * directions[0] * ((moveByX / 2) + separationBuffer); + overlapAmount[1] = -1 * directions[1] * ((moveByY / 2) + separationBuffer); +}; + +/** + * This method decides the separation direction of overlapping nodes + * + * if directions[0] = -1, then rectA goes left + * if directions[0] = 1, then rectA goes right + * if directions[1] = -1, then rectA goes up + * if directions[1] = 1, then rectA goes down + */ +IGeometry.decideDirectionsForOverlappingNodes = function (rectA, rectB, directions) +{ + if (rectA.getCenterX() < rectB.getCenterX()) + { + directions[0] = -1; + } + else + { + directions[0] = 1; + } + + if (rectA.getCenterY() < rectB.getCenterY()) + { + directions[1] = -1; + } + else + { + directions[1] = 1; + } +}; + +/** + * This method calculates the intersection (clipping) points of the two + * input rectangles with line segment defined by the centers of these two + * rectangles. The clipping points are saved in the input double array and + * whether or not the two rectangles overlap is returned. + */ +IGeometry.getIntersection2 = function(rectA, rectB, result) +{ + //result[0-1] will contain clipPoint of rectA, result[2-3] will contain clipPoint of rectB + let p1x = rectA.getCenterX(); + let p1y = rectA.getCenterY(); + let p2x = rectB.getCenterX(); + let p2y = rectB.getCenterY(); + + //if two rectangles intersect, then clipping points are centers + if (rectA.intersects(rectB)) + { + result[0] = p1x; + result[1] = p1y; + result[2] = p2x; + result[3] = p2y; + return true; + } + //variables for rectA + let topLeftAx = rectA.getX(); + let topLeftAy = rectA.getY(); + let topRightAx = rectA.getRight(); + let bottomLeftAx = rectA.getX(); + let bottomLeftAy = rectA.getBottom(); + let bottomRightAx = rectA.getRight(); + let halfWidthA = rectA.getWidthHalf(); + let halfHeightA = rectA.getHeightHalf(); + //variables for rectB + let topLeftBx = rectB.getX(); + let topLeftBy = rectB.getY(); + let topRightBx = rectB.getRight(); + let bottomLeftBx = rectB.getX(); + let bottomLeftBy = rectB.getBottom(); + let bottomRightBx = rectB.getRight(); + let halfWidthB = rectB.getWidthHalf(); + let halfHeightB = rectB.getHeightHalf(); + + //flag whether clipping points are found + let clipPointAFound = false; + let clipPointBFound = false; + + // line is vertical + if (p1x === p2x) + { + if (p1y > p2y) + { + result[0] = p1x; + result[1] = topLeftAy; + result[2] = p2x; + result[3] = bottomLeftBy; + return false; + } + else if (p1y < p2y) + { + result[0] = p1x; + result[1] = bottomLeftAy; + result[2] = p2x; + result[3] = topLeftBy; + return false; + } + else + { + //not line, return null; + } + } + // line is horizontal + else if (p1y === p2y) + { + if (p1x > p2x) + { + result[0] = topLeftAx; + result[1] = p1y; + result[2] = topRightBx; + result[3] = p2y; + return false; + } + else if (p1x < p2x) + { + result[0] = topRightAx; + result[1] = p1y; + result[2] = topLeftBx; + result[3] = p2y; + return false; + } + else + { + //not valid line, return null; + } + } + else + { + //slopes of rectA's and rectB's diagonals + let slopeA = rectA.height / rectA.width; + let slopeB = rectB.height / rectB.width; + + //slope of line between center of rectA and center of rectB + let slopePrime = (p2y - p1y) / (p2x - p1x); + let cardinalDirectionA; + let cardinalDirectionB; + let tempPointAx; + let tempPointAy; + let tempPointBx; + let tempPointBy; + + //determine whether clipping point is the corner of nodeA + if ((-slopeA) === slopePrime) + { + if (p1x > p2x) + { + result[0] = bottomLeftAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } + else + { + result[0] = topRightAx; + result[1] = topLeftAy; + clipPointAFound = true; + } + } + else if (slopeA === slopePrime) + { + if (p1x > p2x) + { + result[0] = topLeftAx; + result[1] = topLeftAy; + clipPointAFound = true; + } + else + { + result[0] = bottomRightAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } + } + + //determine whether clipping point is the corner of nodeB + if ((-slopeB) === slopePrime) + { + if (p2x > p1x) + { + result[2] = bottomLeftBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } + else + { + result[2] = topRightBx; + result[3] = topLeftBy; + clipPointBFound = true; + } + } + else if (slopeB === slopePrime) + { + if (p2x > p1x) + { + result[2] = topLeftBx; + result[3] = topLeftBy; + clipPointBFound = true; + } + else + { + result[2] = bottomRightBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } + } + + //if both clipping points are corners + if (clipPointAFound && clipPointBFound) + { + return false; + } + + //determine Cardinal Direction of rectangles + if (p1x > p2x) + { + if (p1y > p2y) + { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 4); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 2); + } + else + { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 3); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 1); + } + } + else + { + if (p1y > p2y) + { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 1); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 3); + } + else + { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 2); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 4); + } + } + //calculate clipping Point if it is not found before + if (!clipPointAFound) + { + switch (cardinalDirectionA) + { + case 1: + tempPointAy = topLeftAy; + tempPointAx = p1x + (-halfHeightA) / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 2: + tempPointAx = bottomRightAx; + tempPointAy = p1y + halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 3: + tempPointAy = bottomLeftAy; + tempPointAx = p1x + halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 4: + tempPointAx = bottomLeftAx; + tempPointAy = p1y + (-halfWidthA) * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + } + } + if (!clipPointBFound) + { + switch (cardinalDirectionB) + { + case 1: + tempPointBy = topLeftBy; + tempPointBx = p2x + (-halfHeightB) / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 2: + tempPointBx = bottomRightBx; + tempPointBy = p2y + halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 3: + tempPointBy = bottomLeftBy; + tempPointBx = p2x + halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 4: + tempPointBx = bottomLeftBx; + tempPointBy = p2y + (-halfWidthB) * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + } + } + } + return false; +}; + +/** + * This method returns in which cardinal direction does input point stays + * 1: North + * 2: East + * 3: South + * 4: West + */ +IGeometry.getCardinalDirection = function (slope, slopePrime, line) +{ + if (slope > slopePrime) + { + return line; + } + else + { + return 1 + line % 4; + } +}; + +/** + * This method calculates the intersection of the two lines defined by + * point pairs (s1,s2) and (f1,f2). + */ +IGeometry.getIntersection = function(s1, s2, f1, f2) +{ + if (f2 == null) { + return this.getIntersection2(s1, s2, f1); + } + + let x1 = s1.x; + let y1 = s1.y; + let x2 = s2.x; + let y2 = s2.y; + let x3 = f1.x; + let y3 = f1.y; + let x4 = f2.x; + let y4 = f2.y; + let x, y; // intersection point + let a1, a2, b1, b2, c1, c2; // coefficients of line eqns. + let denom; + + a1 = y2 - y1; + b1 = x1 - x2; + c1 = x2 * y1 - x1 * y2; // { a1*x + b1*y + c1 = 0 is line 1 } + + a2 = y4 - y3; + b2 = x3 - x4; + c2 = x4 * y3 - x3 * y4; // { a2*x + b2*y + c2 = 0 is line 2 } + + denom = a1 * b2 - a2 * b1; + + if (denom === 0) + { + return null; + } + + x = (b1 * c2 - b2 * c1) / denom; + y = (a2 * c1 - a1 * c2) / denom; + + return new Point(x, y); +}; + +/** + * This method finds and returns the angle of the vector from the + x-axis + * in clockwise direction (compatible w/ Java coordinate system!). + */ +IGeometry.angleOfVector = function(Cx, Cy, Nx, Ny) +{ + let C_angle; + + if (Cx !== Nx) + { + C_angle = Math.atan((Ny - Cy) / (Nx - Cx)); + + if (Nx < Cx) + { + C_angle += Math.PI; + } + else if (Ny < Cy) + { + C_angle += this.TWO_PI; + } + } + else if (Ny < Cy) + { + C_angle = this.ONE_AND_HALF_PI; // 270 degrees + } + else + { + C_angle = this.HALF_PI; // 90 degrees + } + + return C_angle; +}; + + +/** + * This method checks whether the given two line segments (one with point + * p1 and p2, the other with point p3 and p4) intersect at a point other + * than these points. + */ +IGeometry.doIntersect = function(p1, p2, p3, p4){ + let a = p1.x; + let b = p1.y; + let c = p2.x; + let d = p2.y; + let p = p3.x; + let q = p3.y; + let r = p4.x; + let s = p4.y; + let det = (c - a) * (s - q) - (r - p) * (d - b); + + if (det === 0) { + return false; + } else { + let lambda = ((s - q) * (r - a) + (p - r) * (s - b)) / det; + let gamma = ((b - d) * (r - a) + (c - a) * (s - b)) / det; + return (0 < lambda && lambda < 1) && (0 < gamma && gamma < 1); + } +}; + + +// ----------------------------------------------------------------------------- +// Section: Class Constants +// ----------------------------------------------------------------------------- +/** + * Some useful pre-calculated constants + */ +IGeometry.HALF_PI = 0.5 * Math.PI; +IGeometry.ONE_AND_HALF_PI = 1.5 * Math.PI; +IGeometry.TWO_PI = 2.0 * Math.PI; +IGeometry.THREE_PI = 3.0 * Math.PI; + + +module.exports = IGeometry; diff --git a/tools/ui/node_modules/layout-base/src/util/IMath.js b/tools/ui/node_modules/layout-base/src/util/IMath.js new file mode 100644 index 0000000000000000000000000000000000000000..c9dd5da9d4717be284f30292ff3cac97089be8fd --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/IMath.js @@ -0,0 +1,30 @@ +function IMath() { +} + +/** + * This method returns the sign of the input value. + */ +IMath.sign = function (value) { + if (value > 0) + { + return 1; + } + else if (value < 0) + { + return -1; + } + else + { + return 0; + } +}; + +IMath.floor = function (value) { + return value < 0 ? Math.ceil(value) : Math.floor(value); +}; + +IMath.ceil = function (value) { + return value < 0 ? Math.floor(value) : Math.ceil(value); +}; + +module.exports = IMath; diff --git a/tools/ui/node_modules/layout-base/src/util/Integer.js b/tools/ui/node_modules/layout-base/src/util/Integer.js new file mode 100644 index 0000000000000000000000000000000000000000..e8e755ca89faea0fe9ab48fd19991315ed809809 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/Integer.js @@ -0,0 +1,7 @@ +function Integer() { +} + +Integer.MAX_VALUE = 2147483647; +Integer.MIN_VALUE = -2147483648; + +module.exports = Integer; diff --git a/tools/ui/node_modules/layout-base/src/util/LinkedList.js b/tools/ui/node_modules/layout-base/src/util/LinkedList.js new file mode 100644 index 0000000000000000000000000000000000000000..3a7cf9cc6e60b3b4a3caa523585a3962cc5eee6c --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/LinkedList.js @@ -0,0 +1,130 @@ +const nodeFrom = value => ({ value, next: null, prev: null }); + +const add = ( prev, node, next, list ) => { + if( prev !== null ){ + prev.next = node; + } else { + list.head = node; + } + + if( next !== null ){ + next.prev = node; + } else { + list.tail = node; + } + + node.prev = prev; + node.next = next; + + list.length++; + + return node; +}; + +const remove = ( node, list ) => { + let { prev, next } = node; + + if( prev !== null ){ + prev.next = next; + } else { + list.head = next; + } + + if( next !== null ){ + next.prev = prev; + } else { + list.tail = prev; + } + + node.prev = node.next = null; + + list.length--; + + return node; +}; + +class LinkedList { + constructor( vals ){ + this.length = 0; + this.head = null; + this.tail = null; + + if( vals != null ){ + vals.forEach( v => this.push(v) ); + } + } + + size(){ + return this.length; + } + + insertBefore( val, otherNode ){ + return add( otherNode.prev, nodeFrom(val), otherNode, this ); + } + + insertAfter( val, otherNode ){ + return add( otherNode, nodeFrom(val), otherNode.next, this ); + } + + insertNodeBefore( newNode, otherNode ){ + return add( otherNode.prev, newNode, otherNode, this ); + } + + insertNodeAfter( newNode, otherNode ){ + return add( otherNode, newNode, otherNode.next, this ); + } + + push( val ){ + return add( this.tail, nodeFrom(val), null, this ); + } + + unshift( val ){ + return add( null, nodeFrom(val), this.head, this ); + } + + remove( node ){ + return remove( node, this ); + } + + pop(){ + return remove( this.tail, this ).value; + } + + popNode(){ + return remove( this.tail, this ); + } + + shift(){ + return remove( this.head, this ).value; + } + + shiftNode(){ + return remove( this.head, this ); + } + + get_object_at( index ){ + if(index <= this.length()){ + var i = 1; + var current = this.head; + while(i < index){ + current = current.next; + i++; + } + return current.value; + } + } + + set_object_at( index, value){ + if(index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + current.value = value; + } + } +} + +module.exports = LinkedList; diff --git a/tools/ui/node_modules/layout-base/src/util/Point.js b/tools/ui/node_modules/layout-base/src/util/Point.js new file mode 100644 index 0000000000000000000000000000000000000000..0e905fc982a175bbb5f681ebcf4f4103f0537188 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/Point.js @@ -0,0 +1,73 @@ +/* + *This class is the javascript implementation of the Point.java class in jdk + */ +function Point(x, y, p) { + this.x = null; + this.y = null; + if (x == null && y == null && p == null) { + this.x = 0; + this.y = 0; + } + else if (typeof x == 'number' && typeof y == 'number' && p == null) { + this.x = x; + this.y = y; + } + else if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.x = p.x; + this.y = p.y; + } +} + +Point.prototype.getX = function () { + return this.x; +} + +Point.prototype.getY = function () { + return this.y; +} + +Point.prototype.getLocation = function () { + return new Point(this.x, this.y); +} + +Point.prototype.setLocation = function (x, y, p) { + if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.setLocation(p.x, p.y); + } + else if (typeof x == 'number' && typeof y == 'number' && p == null) { + //if both parameters are integer just move (x,y) location + if (parseInt(x) == x && parseInt(y) == y) { + this.move(x, y); + } + else { + this.x = Math.floor(x + 0.5); + this.y = Math.floor(y + 0.5); + } + } +} + +Point.prototype.move = function (x, y) { + this.x = x; + this.y = y; +} + +Point.prototype.translate = function (dx, dy) { + this.x += dx; + this.y += dy; +} + +Point.prototype.equals = function (obj) { + if (obj.constructor.name == "Point") { + var pt = obj; + return (this.x == pt.x) && (this.y == pt.y); + } + return this == obj; +} + +Point.prototype.toString = function () { + return new Point().constructor.name + "[x=" + this.x + ",y=" + this.y + "]"; +} + +module.exports = Point; diff --git a/tools/ui/node_modules/layout-base/src/util/PointD.js b/tools/ui/node_modules/layout-base/src/util/PointD.js new file mode 100644 index 0000000000000000000000000000000000000000..4fc34ec4e7dc32fe0d1d639e9bbc2c45f93e0fa0 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/PointD.js @@ -0,0 +1,48 @@ +function PointD(x, y) { + if (x == null && y == null) { + this.x = 0; + this.y = 0; + } else { + this.x = x; + this.y = y; + } +} + +PointD.prototype.getX = function () +{ + return this.x; +}; + +PointD.prototype.getY = function () +{ + return this.y; +}; + +PointD.prototype.setX = function (x) +{ + this.x = x; +}; + +PointD.prototype.setY = function (y) +{ + this.y = y; +}; + +PointD.prototype.getDifference = function (pt) +{ + return new DimensionD(this.x - pt.x, this.y - pt.y); +}; + +PointD.prototype.getCopy = function () +{ + return new PointD(this.x, this.y); +}; + +PointD.prototype.translate = function (dim) +{ + this.x += dim.width; + this.y += dim.height; + return this; +}; + +module.exports = PointD; diff --git a/tools/ui/node_modules/layout-base/src/util/Quicksort.js b/tools/ui/node_modules/layout-base/src/util/Quicksort.js new file mode 100644 index 0000000000000000000000000000000000000000..cee9ecb96980084a928dc550e8dafd9782ecee39 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/Quicksort.js @@ -0,0 +1,77 @@ +/** + * A classic Quicksort algorithm with Hoare's partition + * - Works also on LinkedList objects + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + +const LinkedList = require('./LinkedList.js'); + +class Quicksort { + constructor(A, compareFunction) { + if(compareFunction !== null || compareFunction !== undefined) + this.compareFunction = this._defaultCompareFunction; + + let length; + if( A instanceof LinkedList ) + length = A.size(); + else + length = A.length; + + this._quicksort(A, 0, length - 1); + } + + _quicksort(A, p, r){ + if(p < r) { + let q = this._partition(A, p, r); + this._quicksort(A, p, q); + this._quicksort(A, q + 1, r); + } + } + + _partition(A, p, r){ + let x = this._get(A, p); + let i = p; + let j = r; + while(true){ + while (this.compareFunction(x, this._get(A, j))) + j--; + while (this.compareFunction(this._get(A, i), x)) + i++; + + if (i < j){ + this._swap(A, i, j); + i++; + j--; + } + else + return j; + } + } + + _get(object, index){ + if( object instanceof LinkedList) + return object.get_object_at(index); + else + return object[index]; + } + + _set(object, index, value){ + if( object instanceof LinkedList) + object.set_object_at(index, value); + else + object[index] = value; + } + + _swap(A, i, j){ + let temp = this._get(A, i); + this._set(A, i, this._get(A, j)); + this._set(A, j, temp); + } + + _defaultCompareFunction(a, b){ + return b > a; + } +} + +module.exports = Quicksort; \ No newline at end of file diff --git a/tools/ui/node_modules/layout-base/src/util/RandomSeed.js b/tools/ui/node_modules/layout-base/src/util/RandomSeed.js new file mode 100644 index 0000000000000000000000000000000000000000..f71f40ff7ec10ea75fc5efe67edfa73c7d8fa952 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/RandomSeed.js @@ -0,0 +1,12 @@ +function RandomSeed() { +} +// adapted from: https://stackoverflow.com/a/19303725 +RandomSeed.seed = 1; +RandomSeed.x = 0; + +RandomSeed.nextDouble = function () { + RandomSeed.x = Math.sin(RandomSeed.seed++) * 10000; + return RandomSeed.x - Math.floor(RandomSeed.x); +}; + +module.exports = RandomSeed; diff --git a/tools/ui/node_modules/layout-base/src/util/RectangleD.js b/tools/ui/node_modules/layout-base/src/util/RectangleD.js new file mode 100644 index 0000000000000000000000000000000000000000..d36e3571ddb424b495258bfdf2b611070b4b5c8c --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/RectangleD.js @@ -0,0 +1,130 @@ +function RectangleD(x, y, width, height) { + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + + if (x != null && y != null && width != null && height != null) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } +} + +RectangleD.prototype.getX = function () +{ + return this.x; +}; + +RectangleD.prototype.setX = function (x) +{ + this.x = x; +}; + +RectangleD.prototype.getY = function () +{ + return this.y; +}; + +RectangleD.prototype.setY = function (y) +{ + this.y = y; +}; + +RectangleD.prototype.getWidth = function () +{ + return this.width; +}; + +RectangleD.prototype.setWidth = function (width) +{ + this.width = width; +}; + +RectangleD.prototype.getHeight = function () +{ + return this.height; +}; + +RectangleD.prototype.setHeight = function (height) +{ + this.height = height; +}; + +RectangleD.prototype.getRight = function () +{ + return this.x + this.width; +}; + +RectangleD.prototype.getBottom = function () +{ + return this.y + this.height; +}; + +RectangleD.prototype.intersects = function (a) +{ + if (this.getRight() < a.x) + { + return false; + } + + if (this.getBottom() < a.y) + { + return false; + } + + if (a.getRight() < this.x) + { + return false; + } + + if (a.getBottom() < this.y) + { + return false; + } + + return true; +}; + +RectangleD.prototype.getCenterX = function () +{ + return this.x + this.width / 2; +}; + +RectangleD.prototype.getMinX = function () +{ + return this.getX(); +}; + +RectangleD.prototype.getMaxX = function () +{ + return this.getX() + this.width; +}; + +RectangleD.prototype.getCenterY = function () +{ + return this.y + this.height / 2; +}; + +RectangleD.prototype.getMinY = function () +{ + return this.getY(); +}; + +RectangleD.prototype.getMaxY = function () +{ + return this.getY() + this.height; +}; + +RectangleD.prototype.getWidthHalf = function () +{ + return this.width / 2; +}; + +RectangleD.prototype.getHeightHalf = function () +{ + return this.height / 2; +}; + +module.exports = RectangleD; diff --git a/tools/ui/node_modules/layout-base/src/util/Transform.js b/tools/ui/node_modules/layout-base/src/util/Transform.js new file mode 100644 index 0000000000000000000000000000000000000000..fc7c120f36d32c97404f9915e255067e2a6db553 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/Transform.js @@ -0,0 +1,157 @@ +var PointD = require('./PointD'); + +function Transform(x, y) { + this.lworldOrgX = 0.0; + this.lworldOrgY = 0.0; + this.ldeviceOrgX = 0.0; + this.ldeviceOrgY = 0.0; + this.lworldExtX = 1.0; + this.lworldExtY = 1.0; + this.ldeviceExtX = 1.0; + this.ldeviceExtY = 1.0; +} + +Transform.prototype.getWorldOrgX = function () +{ + return this.lworldOrgX; +} + +Transform.prototype.setWorldOrgX = function (wox) +{ + this.lworldOrgX = wox; +} + +Transform.prototype.getWorldOrgY = function () +{ + return this.lworldOrgY; +} + +Transform.prototype.setWorldOrgY = function (woy) +{ + this.lworldOrgY = woy; +} + +Transform.prototype.getWorldExtX = function () +{ + return this.lworldExtX; +} + +Transform.prototype.setWorldExtX = function (wex) +{ + this.lworldExtX = wex; +} + +Transform.prototype.getWorldExtY = function () +{ + return this.lworldExtY; +} + +Transform.prototype.setWorldExtY = function (wey) +{ + this.lworldExtY = wey; +} + +/* Device related */ + +Transform.prototype.getDeviceOrgX = function () +{ + return this.ldeviceOrgX; +} + +Transform.prototype.setDeviceOrgX = function (dox) +{ + this.ldeviceOrgX = dox; +} + +Transform.prototype.getDeviceOrgY = function () +{ + return this.ldeviceOrgY; +} + +Transform.prototype.setDeviceOrgY = function (doy) +{ + this.ldeviceOrgY = doy; +} + +Transform.prototype.getDeviceExtX = function () +{ + return this.ldeviceExtX; +} + +Transform.prototype.setDeviceExtX = function (dex) +{ + this.ldeviceExtX = dex; +} + +Transform.prototype.getDeviceExtY = function () +{ + return this.ldeviceExtY; +} + +Transform.prototype.setDeviceExtY = function (dey) +{ + this.ldeviceExtY = dey; +} + +Transform.prototype.transformX = function (x) +{ + var xDevice = 0.0; + var worldExtX = this.lworldExtX; + if (worldExtX != 0.0) + { + xDevice = this.ldeviceOrgX + + ((x - this.lworldOrgX) * this.ldeviceExtX / worldExtX); + } + + return xDevice; +} + +Transform.prototype.transformY = function (y) +{ + var yDevice = 0.0; + var worldExtY = this.lworldExtY; + if (worldExtY != 0.0) + { + yDevice = this.ldeviceOrgY + + ((y - this.lworldOrgY) * this.ldeviceExtY / worldExtY); + } + + + return yDevice; +} + +Transform.prototype.inverseTransformX = function (x) +{ + var xWorld = 0.0; + var deviceExtX = this.ldeviceExtX; + if (deviceExtX != 0.0) + { + xWorld = this.lworldOrgX + + ((x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX); + } + + + return xWorld; +} + +Transform.prototype.inverseTransformY = function (y) +{ + var yWorld = 0.0; + var deviceExtY = this.ldeviceExtY; + if (deviceExtY != 0.0) + { + yWorld = this.lworldOrgY + + ((y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY); + } + return yWorld; +} + +Transform.prototype.inverseTransformPoint = function (inPoint) +{ + var outPoint = + new PointD(this.inverseTransformX(inPoint.x), + this.inverseTransformY(inPoint.y)); + return outPoint; +} + +module.exports = Transform; diff --git a/tools/ui/node_modules/layout-base/src/util/UniqueIDGeneretor.js b/tools/ui/node_modules/layout-base/src/util/UniqueIDGeneretor.js new file mode 100644 index 0000000000000000000000000000000000000000..0f85c326c04f5b079c38c404f3c93a5069dd1de8 --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/UniqueIDGeneretor.js @@ -0,0 +1,29 @@ +function UniqueIDGeneretor() { +} + +UniqueIDGeneretor.lastID = 0; + +UniqueIDGeneretor.createID = function (obj) { + if (UniqueIDGeneretor.isPrimitive(obj)) { + return obj; + } + if (obj.uniqueID != null) { + return obj.uniqueID; + } + obj.uniqueID = UniqueIDGeneretor.getString(); + UniqueIDGeneretor.lastID++; + return obj.uniqueID; +} + +UniqueIDGeneretor.getString = function (id) { + if (id == null) + id = UniqueIDGeneretor.lastID; + return "Object#" + id + ""; +} + +UniqueIDGeneretor.isPrimitive = function (arg) { + var type = typeof arg; + return arg == null || (type != "object" && type != "function"); +} + +module.exports = UniqueIDGeneretor; diff --git a/tools/ui/node_modules/layout-base/src/util/alignment/NeedlemanWunsch.js b/tools/ui/node_modules/layout-base/src/util/alignment/NeedlemanWunsch.js new file mode 100644 index 0000000000000000000000000000000000000000..6a63781d523c98b75aa5fbaed1b6a1f11685f1cf --- /dev/null +++ b/tools/ui/node_modules/layout-base/src/util/alignment/NeedlemanWunsch.js @@ -0,0 +1,158 @@ +/** + * Needleman-Wunsch algorithm is an procedure to compute the optimal global alignment of two string + * sequences by S.B.Needleman and C.D.Wunsch (1970). + * + * Aside from the inputs, you can assign the scores for, + * - Match: The two characters at the current index are same. + * - Mismatch: The two characters at the current index are different. + * - Insertion/Deletion(gaps): The best alignment involves one letter aligning to a gap in the other string. + */ + +class NeedlemanWunsch { + constructor(sequence1, sequence2, match_score = 1, mismatch_penalty = -1, gap_penalty = -1) { + this.sequence1 = sequence1; + this.sequence2 = sequence2; + this.match_score = match_score; + this.mismatch_penalty = mismatch_penalty; + this.gap_penalty = gap_penalty; + + // Just the remove redundancy + this.iMax = sequence1.length + 1; + this.jMax = sequence2.length + 1; + + // Grid matrix of scores + this.grid = new Array(this.iMax); + for(let i = 0; i < this.iMax; i++){ + this.grid[i] = new Array(this.jMax ); + + for(let j = 0; j < this.jMax ; j++) + this.grid[i][j] = 0; + } + + // Traceback matrix (2D array, each cell is an array of boolean values for [`Diag`, `Up`, `Left`] positions) + this.tracebackGrid = new Array(this.iMax); + for(let i = 0; i < this.iMax; i++) { + this.tracebackGrid[i] = new Array(this.jMax); + + for(let j = 0; j < this.jMax ; j++) + this.tracebackGrid[i][j] = [null, null, null]; + } + + // The aligned sequences (return multiple possibilities) + this.alignments = []; + + // Final alignment score + this.score = -1; + + // Calculate scores and tracebacks + this.computeGrids(); + } + + getScore(){ + return this.score; + } + + getAlignments(){ + return this.alignments; + } + + // Main dynamic programming procedure + computeGrids(){ + // Fill in the first row + for (let j = 1; j < this.jMax; j++) { + this.grid[0][j] = this.grid[0][j-1] + this.gap_penalty; + this.tracebackGrid[0][j] = [false, false, true]; + } + + // Fill in the first column + for (let i = 1; i < this.iMax; i++) { + this.grid[i][0] = this.grid[i-1][0] + this.gap_penalty; + this.tracebackGrid[i][0] = [false, true, false]; + } + + // Fill the rest of the grid + for(let i = 1; i < this.iMax; i++){ + for(let j = 1; j < this.jMax; j++){ + // Find the max score(s) among [`Diag`, `Up`, `Left`] + let diag; + if(this.sequence1[i-1] === this.sequence2[j-1]) + diag = this.grid[i-1][j-1] + this.match_score; + else + diag = this.grid[i-1][j-1] + this.mismatch_penalty; + + let up = this.grid[i-1][j] + this.gap_penalty; + let left = this.grid[i][j-1] + this.gap_penalty; + + // If there exists multiple max values, capture them for multiple paths + let maxOf = [diag,up,left]; + let indices = this.arrayAllMaxIndexes(maxOf); + + // Update Grids + this.grid[i][j] = maxOf[indices[0]]; + this.tracebackGrid[i][j] = [indices.includes(0), indices.includes(1), indices.includes(2)]; + } + } + + // Update alignment score + this.score = this.grid[this.iMax-1][this.jMax-1]; + } + + // Gets all possible valid sequence combinations + alignmentTraceback(){ + let inProcessAlignments = []; + + inProcessAlignments.push({ pos: [this.sequence1.length, this.sequence2.length], + seq1: "", + seq2: "" + }); + + while(inProcessAlignments[0]){ + let current = inProcessAlignments[0]; + let directions = this.tracebackGrid[current.pos[0]][current.pos[1]]; + + if(directions[0]){ + inProcessAlignments.push({ pos: [current.pos[0]-1, current.pos[1]-1], + seq1: (this.sequence1[current.pos[0]-1] + current.seq1), + seq2: (this.sequence2[current.pos[1]-1] + current.seq2) + }); + } + if(directions[1]){ + inProcessAlignments.push({ pos: [current.pos[0]-1, current.pos[1]], + seq1: this.sequence1[current.pos[0]-1] + current.seq1, + seq2: '-' + current.seq2 + }); + } + if(directions[2]){ + inProcessAlignments.push({ pos: [current.pos[0], current.pos[1]-1], + seq1:'-' + current.seq1, + seq2: this.sequence2[current.pos[1]-1] + current.seq2 + }); + } + + if(current.pos[0] === 0 && current.pos[1] === 0) + this.alignments.push({sequence1 : current.seq1, + sequence2: current.seq2 + }); + + inProcessAlignments.shift(); + } + + return this.alignments; + } + + // Helper Functions + + getAllIndexes(arr, val) { + let indexes = [], i = -1; + while ((i = arr.indexOf(val, i+1)) !== -1){ + indexes.push(i); + } + return indexes; + } + + arrayAllMaxIndexes(array){ + return this.getAllIndexes(array, Math.max.apply(null, array)); + } +} + +module.exports = NeedlemanWunsch; \ No newline at end of file diff --git a/tools/ui/node_modules/layout-base/webpack.config.js b/tools/ui/node_modules/layout-base/webpack.config.js new file mode 100644 index 0000000000000000000000000000000000000000..660d204276d58a75fbfa379105f0d22e57a7980e --- /dev/null +++ b/tools/ui/node_modules/layout-base/webpack.config.js @@ -0,0 +1,35 @@ +const path = require('path'); +const pkg = require('./package.json'); +const camelcase = require('camelcase'); +const process = require('process'); +const webpack = require('webpack'); +const env = process.env; +const NODE_ENV = env.NODE_ENV; +const MIN = env.MIN; +const PROD = NODE_ENV === 'production'; + +let config = { + devtool: PROD ? false : 'inline-source-map', + entry: './index.js', + output: { + path: path.join( __dirname ), + filename: 'layout-base.js', + library: camelcase( pkg.name ), + libraryTarget: 'umd' + }, + module: { + rules: [ + { test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' } + ] + }, + plugins: MIN ? [ + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false, + drop_console: false, + } + }) + ] : [] +}; + +module.exports = config; diff --git a/tools/ui/node_modules/leven/index.d.ts b/tools/ui/node_modules/leven/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..571833ae44b7d6bdf588f370a6ce903b00cfba0e --- /dev/null +++ b/tools/ui/node_modules/leven/index.d.ts @@ -0,0 +1,21 @@ +declare const leven: { + /** + Measure the difference between two strings. + + @example + ``` + import leven = require('leven'); + + leven('cat', 'cow'); + //=> 2 + ``` + */ + (left: string, right: string): number; + + // TODO: Remove this for the next major release, refactor the whole definition to: + // declare function leven(left: string, right: string): number; + // export = leven; + default: typeof leven; +}; + +export = leven; diff --git a/tools/ui/node_modules/leven/index.js b/tools/ui/node_modules/leven/index.js new file mode 100644 index 0000000000000000000000000000000000000000..25f5a3d5c8bd4dcd7ad102da893fc05c094ee066 --- /dev/null +++ b/tools/ui/node_modules/leven/index.js @@ -0,0 +1,77 @@ +'use strict'; +const array = []; +const charCodeCache = []; + +const leven = (left, right) => { + if (left === right) { + return 0; + } + + const swap = left; + + // Swapping the strings if `a` is longer than `b` so we know which one is the + // shortest & which one is the longest + if (left.length > right.length) { + left = right; + right = swap; + } + + let leftLength = left.length; + let rightLength = right.length; + + // Performing suffix trimming: + // We can linearly drop suffix common to both strings since they + // don't increase distance at all + // Note: `~-` is the bitwise way to perform a `- 1` operation + while (leftLength > 0 && (left.charCodeAt(~-leftLength) === right.charCodeAt(~-rightLength))) { + leftLength--; + rightLength--; + } + + // Performing prefix trimming + // We can linearly drop prefix common to both strings since they + // don't increase distance at all + let start = 0; + + while (start < leftLength && (left.charCodeAt(start) === right.charCodeAt(start))) { + start++; + } + + leftLength -= start; + rightLength -= start; + + if (leftLength === 0) { + return rightLength; + } + + let bCharCode; + let result; + let temp; + let temp2; + let i = 0; + let j = 0; + + while (i < leftLength) { + charCodeCache[i] = left.charCodeAt(start + i); + array[i] = ++i; + } + + while (j < rightLength) { + bCharCode = right.charCodeAt(start + j); + temp = j++; + result = j; + + for (i = 0; i < leftLength; i++) { + temp2 = bCharCode === charCodeCache[i] ? temp : temp + 1; + temp = array[i]; + // eslint-disable-next-line no-multi-assign + result = array[i] = temp > result ? temp2 > result ? result + 1 : temp2 : temp2 > temp ? temp + 1 : temp2; + } + } + + return result; +}; + +module.exports = leven; +// TODO: Remove this for the next major release +module.exports.default = leven; diff --git a/tools/ui/node_modules/leven/license b/tools/ui/node_modules/leven/license new file mode 100644 index 0000000000000000000000000000000000000000..e7af2f77107d73046421ef56c4684cbfdd3c1e89 --- /dev/null +++ b/tools/ui/node_modules/leven/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/ui/node_modules/leven/package.json b/tools/ui/node_modules/leven/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e1b3d8ee0cb25a38a39df43684eddddd88bcf112 --- /dev/null +++ b/tools/ui/node_modules/leven/package.json @@ -0,0 +1,57 @@ +{ + "name": "leven", + "version": "3.1.0", + "description": "Measure the difference between two strings using the fastest JS implementation of the Levenshtein distance algorithm", + "license": "MIT", + "repository": "sindresorhus/leven", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=6" + }, + "scripts": { + "test": "xo && ava && tsd", + "bench": "matcha bench.js" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "leven", + "levenshtein", + "distance", + "algorithm", + "algo", + "string", + "difference", + "diff", + "fast", + "fuzzy", + "similar", + "similarity", + "compare", + "comparison", + "edit", + "text", + "match", + "matching" + ], + "devDependencies": { + "ava": "^1.4.1", + "fast-levenshtein": "^2.0.6", + "ld": "^0.1.0", + "levdist": "^2.2.9", + "levenshtein": "^1.0.5", + "levenshtein-component": "^0.0.1", + "levenshtein-edit-distance": "^2.0.3", + "matcha": "^0.7.0", + "natural": "^0.6.3", + "talisman": "^0.21.0", + "tsd": "^0.7.2", + "xo": "^0.24.0" + } +} diff --git a/tools/ui/node_modules/leven/readme.md b/tools/ui/node_modules/leven/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..33625c46f0059558a34102f683b82be7b6569656 --- /dev/null +++ b/tools/ui/node_modules/leven/readme.md @@ -0,0 +1,50 @@ +# leven [![Build Status](https://travis-ci.org/sindresorhus/leven.svg?branch=master)](https://travis-ci.org/sindresorhus/leven) + +> Measure the difference between two strings
+> One of the fastest JS implementations of the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) algorithm + + +## Install + +``` +$ npm install leven +``` + + +## Usage + +```js +const leven = require('leven'); + +leven('cat', 'cow'); +//=> 2 +``` + + +## Benchmark + +``` +$ npm run bench +``` + +``` + 165,926 op/s » leven + 164,398 op/s » talisman + 1,044 op/s » levenshtein-edit-distance + 628 op/s » fast-levenshtein + 497 op/s » levenshtein-component + 195 op/s » ld + 190 op/s » levenshtein + 168 op/s » levdist + 10 op/s » natural +``` + + +## Related + +- [leven-cli](https://github.com/sindresorhus/leven-cli) - CLI for this module + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/tools/ui/node_modules/levn/LICENSE b/tools/ui/node_modules/levn/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..525b11850e6f2cc73b10854d14a4532797ed0a07 --- /dev/null +++ b/tools/ui/node_modules/levn/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) George Zahariev + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/ui/node_modules/levn/README.md b/tools/ui/node_modules/levn/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7ab008d6664f3af62a84995beb4b5ad4ebf3b24f --- /dev/null +++ b/tools/ui/node_modules/levn/README.md @@ -0,0 +1,196 @@ +# levn [![Build Status](https://travis-ci.org/gkz/levn.png)](https://travis-ci.org/gkz/levn) +__Light ECMAScript (JavaScript) Value Notation__ +Levn is a library which allows you to parse a string into a JavaScript value based on an expected type. It is meant for short amounts of human entered data (eg. config files, command line arguments). + +Levn aims to concisely describe JavaScript values in text, and allow for the extraction and validation of those values. Levn uses [type-check](https://github.com/gkz/type-check) for its type format, and to validate the results. MIT license. Version 0.4.1. + +__How is this different than JSON?__ levn is meant to be written by humans only, is (due to the previous point) much more concise, can be validated against supplied types, has regex and date literals, and can easily be extended with custom types. On the other hand, it is probably slower and thus less efficient at transporting large amounts of data, which is fine since this is not its purpose. + + npm install levn + +For updates on levn, [follow me on twitter](https://twitter.com/gkzahariev). + + +## Quick Examples + +```js +var parse = require('levn').parse; +parse('Number', '2'); // 2 +parse('String', '2'); // '2' +parse('String', 'levn'); // 'levn' +parse('String', 'a b'); // 'a b' +parse('Boolean', 'true'); // true + +parse('Date', '#2011-11-11#'); // (Date object) +parse('Date', '2011-11-11'); // (Date object) +parse('RegExp', '/[a-z]/gi'); // /[a-z]/gi +parse('RegExp', 're'); // /re/ +parse('Int', '2'); // 2 + +parse('Number | String', 'str'); // 'str' +parse('Number | String', '2'); // 2 + +parse('[Number]', '[1,2,3]'); // [1,2,3] +parse('(String, Boolean)', '(hi, false)'); // ['hi', false] +parse('{a: String, b: Number}', '{a: str, b: 2}'); // {a: 'str', b: 2} + +// at the top level, you can ommit surrounding delimiters +parse('[Number]', '1,2,3'); // [1,2,3] +parse('(String, Boolean)', 'hi, false'); // ['hi', false] +parse('{a: String, b: Number}', 'a: str, b: 2'); // {a: 'str', b: 2} + +// wildcard - auto choose type +parse('*', '[hi,(null,[42]),{k: true}]'); // ['hi', [null, [42]], {k: true}] +``` +## Usage + +`require('levn');` returns an object that exposes three properties. `VERSION` is the current version of the library as a string. `parse` and `parsedTypeParse` are functions. + +```js +// parse(type, input, options); +parse('[Number]', '1,2,3'); // [1, 2, 3] + +// parsedTypeParse(parsedType, input, options); +var parsedType = require('type-check').parseType('[Number]'); +parsedTypeParse(parsedType, '1,2,3'); // [1, 2, 3] +``` + +### parse(type, input, options) + +`parse` casts the string `input` into a JavaScript value according to the specified `type` in the [type format](https://github.com/gkz/type-check#type-format) (and taking account the optional `options`) and returns the resulting JavaScript value. + +##### arguments +* type - `String` - the type written in the [type format](https://github.com/gkz/type-check#type-format) which to check against +* input - `String` - the value written in the [levn format](#levn-format) +* options - `Maybe Object` - an optional parameter specifying additional [options](#options) + +##### returns +`*` - the resulting JavaScript value + +##### example +```js +parse('[Number]', '1,2,3'); // [1, 2, 3] +``` + +### parsedTypeParse(parsedType, input, options) + +`parsedTypeParse` casts the string `input` into a JavaScript value according to the specified `type` which has already been parsed (and taking account the optional `options`) and returns the resulting JavaScript value. You can parse a type using the [type-check](https://github.com/gkz/type-check) library's `parseType` function. + +##### arguments +* type - `Object` - the type in the parsed type format which to check against +* input - `String` - the value written in the [levn format](#levn-format) +* options - `Maybe Object` - an optional parameter specifying additional [options](#options) + +##### returns +`*` - the resulting JavaScript value + +##### example +```js +var parsedType = require('type-check').parseType('[Number]'); +parsedTypeParse(parsedType, '1,2,3'); // [1, 2, 3] +``` + +## Levn Format + +Levn can use the type information you provide to choose the appropriate value to produce from the input. For the same input, it will choose a different output value depending on the type provided. For example, `parse('Number', '2')` will produce the number `2`, but `parse('String', '2')` will produce the string `"2"`. + +If you do not provide type information, and simply use `*`, levn will parse the input according the unambiguous "explicit" mode, which we will now detail - you can also set the `explicit` option to true manually in the [options](#options). + +* `"string"`, `'string'` are parsed as a String, eg. `"a msg"` is `"a msg"` +* `#date#` is parsed as a Date, eg. `#2011-11-11#` is `new Date('2011-11-11')` +* `/regexp/flags` is parsed as a RegExp, eg. `/re/gi` is `/re/gi` +* `undefined`, `null`, `NaN`, `true`, and `false` are all their JavaScript equivalents +* `[element1, element2, etc]` is an Array, and the casting procedure is recursively applied to each element. Eg. `[1,2,3]` is `[1,2,3]`. +* `(element1, element2, etc)` is an tuple, and the casting procedure is recursively applied to each element. Eg. `(1, a)` is `(1, a)` (is `[1, 'a']`). +* `{key1: val1, key2: val2, ...}` is an Object, and the casting procedure is recursively applied to each property. Eg. `{a: 1, b: 2}` is `{a: 1, b: 2}`. +* Any test which does not fall under the above, and which does not contain special characters (`[``]``(``)``{``}``:``,`) is a string, eg. `$12- blah` is `"$12- blah"`. + +If you do provide type information, you can make your input more concise as the program already has some information about what it expects. Please see the [type format](https://github.com/gkz/type-check#type-format) section of [type-check](https://github.com/gkz/type-check) for more information about how to specify types. There are some rules about what levn can do with the information: + +* If a String is expected, and only a String, all characters of the input (including any special ones) will become part of the output. Eg. `[({})]` is `"[({})]"`, and `"hi"` is `'"hi"'`. +* If a Date is expected, the surrounding `#` can be omitted from date literals. Eg. `2011-11-11` is `new Date('2011-11-11')`. +* If a RegExp is expected, no flags need to be specified, and the regex is not using any of the special characters,the opening and closing `/` can be omitted - this will have the affect of setting the source of the regex to the input. Eg. `regex` is `/regex/`. +* If an Array is expected, and it is the root node (at the top level), the opening `[` and closing `]` can be omitted. Eg. `1,2,3` is `[1,2,3]`. +* If a tuple is expected, and it is the root node (at the top level), the opening `(` and closing `)` can be omitted. Eg. `1, a` is `(1, a)` (is `[1, 'a']`). +* If an Object is expected, and it is the root node (at the top level), the opening `{` and closing `}` can be omitted. Eg `a: 1, b: 2` is `{a: 1, b: 2}`. + +If you list multiple types (eg. `Number | String`), it will first attempt to cast to the first type and then validate - if the validation fails it will move on to the next type and so forth, left to right. You must be careful as some types will succeed with any input, such as String. Thus put String at the end of your list. In non-explicit mode, Date and RegExp will succeed with a large variety of input - also be careful with these and list them near the end if not last in your list. + +Whitespace between special characters and elements is inconsequential. + +## Options + +Options is an object. It is an optional parameter to the `parse` and `parsedTypeParse` functions. + +### Explicit + +A `Boolean`. By default it is `false`. + +__Example:__ + +```js +parse('RegExp', 're', {explicit: false}); // /re/ +parse('RegExp', 're', {explicit: true}); // Error: ... does not type check... +parse('RegExp | String', 're', {explicit: true}); // 're' +``` + +`explicit` sets whether to be in explicit mode or not. Using `*` automatically activates explicit mode. For more information, read the [levn format](#levn-format) section. + +### customTypes + +An `Object`. Empty `{}` by default. + +__Example:__ + +```js +var options = { + customTypes: { + Even: { + typeOf: 'Number', + validate: function (x) { + return x % 2 === 0; + }, + cast: function (x) { + return {type: 'Just', value: parseInt(x)}; + } + } + } +} +parse('Even', '2', options); // 2 +parse('Even', '3', options); // Error: Value: "3" does not type check... +``` + +__Another Example:__ +```js +function Person(name, age){ + this.name = name; + this.age = age; +} +var options = { + customTypes: { + Person: { + typeOf: 'Object', + validate: function (x) { + x instanceof Person; + }, + cast: function (value, options, typesCast) { + var name, age; + if ({}.toString.call(value).slice(8, -1) !== 'Object') { + return {type: 'Nothing'}; + } + name = typesCast(value.name, [{type: 'String'}], options); + age = typesCast(value.age, [{type: 'Numger'}], options); + return {type: 'Just', value: new Person(name, age)}; + } + } +} +parse('Person', '{name: Laura, age: 25}', options); // Person {name: 'Laura', age: 25} +``` + +`customTypes` is an object whose keys are the name of the types, and whose values are an object with three properties, `typeOf`, `validate`, and `cast`. For more information about `typeOf` and `validate`, please see the [custom types](https://github.com/gkz/type-check#custom-types) section of type-check. + +`cast` is a function which receives three arguments, the value under question, options, and the typesCast function. In `cast`, attempt to cast the value into the specified type. If you are successful, return an object in the format `{type: 'Just', value: CAST-VALUE}`, if you know it won't work, return `{type: 'Nothing'}`. You can use the `typesCast` function to cast any child values. Remember to pass `options` to it. In your function you can also check for `options.explicit` and act accordingly. + +## Technical About + +`levn` is written in [LiveScript](http://livescript.net/) - a language that compiles to JavaScript. It uses [type-check](https://github.com/gkz/type-check) to both parse types and validate values. It also uses the [prelude.ls](http://preludels.com/) library. diff --git a/tools/ui/node_modules/levn/lib/cast.js b/tools/ui/node_modules/levn/lib/cast.js new file mode 100644 index 0000000000000000000000000000000000000000..92cb9a6d799311197c44006fe713aa35f1bad918 --- /dev/null +++ b/tools/ui/node_modules/levn/lib/cast.js @@ -0,0 +1,327 @@ +// Generated by LiveScript 1.6.0 +(function(){ + var parsedTypeCheck, types, toString$ = {}.toString; + parsedTypeCheck = require('type-check').parsedTypeCheck; + types = { + '*': function(value, options){ + switch (toString$.call(value).slice(8, -1)) { + case 'Array': + return typeCast(value, { + type: 'Array' + }, options); + case 'Object': + return typeCast(value, { + type: 'Object' + }, options); + default: + return { + type: 'Just', + value: typesCast(value, [ + { + type: 'Undefined' + }, { + type: 'Null' + }, { + type: 'NaN' + }, { + type: 'Boolean' + }, { + type: 'Number' + }, { + type: 'Date' + }, { + type: 'RegExp' + }, { + type: 'Array' + }, { + type: 'Object' + }, { + type: 'String' + } + ], (options.explicit = true, options)) + }; + } + }, + Undefined: function(it){ + if (it === 'undefined' || it === void 8) { + return { + type: 'Just', + value: void 8 + }; + } else { + return { + type: 'Nothing' + }; + } + }, + Null: function(it){ + if (it === 'null') { + return { + type: 'Just', + value: null + }; + } else { + return { + type: 'Nothing' + }; + } + }, + NaN: function(it){ + if (it === 'NaN') { + return { + type: 'Just', + value: NaN + }; + } else { + return { + type: 'Nothing' + }; + } + }, + Boolean: function(it){ + if (it === 'true') { + return { + type: 'Just', + value: true + }; + } else if (it === 'false') { + return { + type: 'Just', + value: false + }; + } else { + return { + type: 'Nothing' + }; + } + }, + Number: function(it){ + return { + type: 'Just', + value: +it + }; + }, + Int: function(it){ + return { + type: 'Just', + value: +it + }; + }, + Float: function(it){ + return { + type: 'Just', + value: +it + }; + }, + Date: function(value, options){ + var that; + if (that = /^\#([\s\S]*)\#$/.exec(value)) { + return { + type: 'Just', + value: new Date(+that[1] || that[1]) + }; + } else if (options.explicit) { + return { + type: 'Nothing' + }; + } else { + return { + type: 'Just', + value: new Date(+value || value) + }; + } + }, + RegExp: function(value, options){ + var that; + if (that = /^\/([\s\S]*)\/([gimy]*)$/.exec(value)) { + return { + type: 'Just', + value: new RegExp(that[1], that[2]) + }; + } else if (options.explicit) { + return { + type: 'Nothing' + }; + } else { + return { + type: 'Just', + value: new RegExp(value) + }; + } + }, + Array: function(value, options){ + return castArray(value, { + of: [{ + type: '*' + }] + }, options); + }, + Object: function(value, options){ + return castFields(value, { + of: {} + }, options); + }, + String: function(it){ + var replace, that; + if (toString$.call(it).slice(8, -1) !== 'String') { + return { + type: 'Nothing' + }; + } + replace = function(value, quote){ + return value.replace(/\\([^u]|u[0-9a-fA-F]{4})/g, function(all, escaped){ + switch (escaped[0]) { + case quote: + return quote; + case '\\': + return '\\'; + case 'b': + return '\b'; + case 'f': + return '\f'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 't': + return '\t'; + case 'u': + return JSON.parse("\"" + all + "\""); + default: + return escaped; + } + }); + }; + if (that = it.match(/^'([\s\S]*)'$/)) { + return { + type: 'Just', + value: replace(that[1], "'") + }; + } else if (that = it.match(/^"([\s\S]*)"$/)) { + return { + type: 'Just', + value: replace(that[1], '"') + }; + } else { + return { + type: 'Just', + value: it + }; + } + } + }; + function castArray(node, type, options){ + var typeOf, element; + if (toString$.call(node).slice(8, -1) !== 'Array') { + return { + type: 'Nothing' + }; + } + typeOf = type.of; + return { + type: 'Just', + value: (function(){ + var i$, ref$, len$, results$ = []; + for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) { + element = ref$[i$]; + results$.push(typesCast(element, typeOf, options)); + } + return results$; + }()) + }; + } + function castTuple(node, type, options){ + var result, i, i$, ref$, len$, types, cast; + if (toString$.call(node).slice(8, -1) !== 'Array') { + return { + type: 'Nothing' + }; + } + result = []; + i = 0; + for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) { + types = ref$[i$]; + cast = typesCast(node[i], types, options); + if (toString$.call(cast).slice(8, -1) !== 'Undefined') { + result.push(cast); + } + i++; + } + if (node.length <= i) { + return { + type: 'Just', + value: result + }; + } else { + return { + type: 'Nothing' + }; + } + } + function castFields(node, type, options){ + var typeOf, key, value; + if (toString$.call(node).slice(8, -1) !== 'Object') { + return { + type: 'Nothing' + }; + } + typeOf = type.of; + return { + type: 'Just', + value: (function(){ + var ref$, resultObj$ = {}; + for (key in ref$ = node) { + value = ref$[key]; + resultObj$[typesCast(key, [{ + type: 'String' + }], options)] = typesCast(value, typeOf[key] || [{ + type: '*' + }], options); + } + return resultObj$; + }()) + }; + } + function typeCast(node, typeObj, options){ + var type, structure, castFunc, ref$; + type = typeObj.type, structure = typeObj.structure; + if (type) { + castFunc = ((ref$ = options.customTypes[type]) != null ? ref$.cast : void 8) || types[type]; + if (!castFunc) { + throw new Error("Type not defined: " + type + "."); + } + return castFunc(node, options, typesCast); + } else { + switch (structure) { + case 'array': + return castArray(node, typeObj, options); + case 'tuple': + return castTuple(node, typeObj, options); + case 'fields': + return castFields(node, typeObj, options); + } + } + } + function typesCast(node, types, options){ + var i$, len$, type, ref$, valueType, value; + for (i$ = 0, len$ = types.length; i$ < len$; ++i$) { + type = types[i$]; + ref$ = typeCast(node, type, options), valueType = ref$.type, value = ref$.value; + if (valueType === 'Nothing') { + continue; + } + if (parsedTypeCheck([type], value, { + customTypes: options.customTypes + })) { + return value; + } + } + throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types) + "."); + } + module.exports = function(node, types, options){ + if (!options.explicit && types.length === 1 && types[0].type === 'String') { + return node; + } + return typesCast(node, types, options); + }; +}).call(this); diff --git a/tools/ui/node_modules/levn/lib/index.js b/tools/ui/node_modules/levn/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b8b668409de18c485df03defbfa4c85e17f73f2a --- /dev/null +++ b/tools/ui/node_modules/levn/lib/index.js @@ -0,0 +1,22 @@ +// Generated by LiveScript 1.6.0 +(function(){ + var parseString, cast, parseType, VERSION, parsedTypeParse, parse; + parseString = require('./parse-string'); + cast = require('./cast'); + parseType = require('type-check').parseType; + VERSION = '0.4.1'; + parsedTypeParse = function(parsedType, string, options){ + options == null && (options = {}); + options.explicit == null && (options.explicit = false); + options.customTypes == null && (options.customTypes = {}); + return cast(parseString(parsedType, string, options), parsedType, options); + }; + parse = function(type, string, options){ + return parsedTypeParse(parseType(type), string, options); + }; + module.exports = { + VERSION: VERSION, + parse: parse, + parsedTypeParse: parsedTypeParse + }; +}).call(this); diff --git a/tools/ui/node_modules/levn/lib/parse-string.js b/tools/ui/node_modules/levn/lib/parse-string.js new file mode 100644 index 0000000000000000000000000000000000000000..eaed2f06d58a0426ef4c22e546ca9f681611fb8e --- /dev/null +++ b/tools/ui/node_modules/levn/lib/parse-string.js @@ -0,0 +1,113 @@ +// Generated by LiveScript 1.6.0 +(function(){ + var reject, special, tokenRegex; + reject = require('prelude-ls').reject; + function consumeOp(tokens, op){ + if (tokens[0] === op) { + return tokens.shift(); + } else { + throw new Error("Expected '" + op + "', but got '" + tokens[0] + "' instead in " + JSON.stringify(tokens) + "."); + } + } + function maybeConsumeOp(tokens, op){ + if (tokens[0] === op) { + return tokens.shift(); + } + } + function consumeList(tokens, arg$, hasDelimiters){ + var open, close, result, untilTest; + open = arg$[0], close = arg$[1]; + if (hasDelimiters) { + consumeOp(tokens, open); + } + result = []; + untilTest = "," + (hasDelimiters ? close : ''); + while (tokens.length && (hasDelimiters && tokens[0] !== close)) { + result.push(consumeElement(tokens, untilTest)); + maybeConsumeOp(tokens, ','); + } + if (hasDelimiters) { + consumeOp(tokens, close); + } + return result; + } + function consumeArray(tokens, hasDelimiters){ + return consumeList(tokens, ['[', ']'], hasDelimiters); + } + function consumeTuple(tokens, hasDelimiters){ + return consumeList(tokens, ['(', ')'], hasDelimiters); + } + function consumeFields(tokens, hasDelimiters){ + var result, untilTest, key; + if (hasDelimiters) { + consumeOp(tokens, '{'); + } + result = {}; + untilTest = "," + (hasDelimiters ? '}' : ''); + while (tokens.length && (!hasDelimiters || tokens[0] !== '}')) { + key = consumeValue(tokens, ':'); + consumeOp(tokens, ':'); + result[key] = consumeElement(tokens, untilTest); + maybeConsumeOp(tokens, ','); + } + if (hasDelimiters) { + consumeOp(tokens, '}'); + } + return result; + } + function consumeValue(tokens, untilTest){ + var out; + untilTest == null && (untilTest = ''); + out = ''; + while (tokens.length && -1 === untilTest.indexOf(tokens[0])) { + out += tokens.shift(); + } + return out; + } + function consumeElement(tokens, untilTest){ + switch (tokens[0]) { + case '[': + return consumeArray(tokens, true); + case '(': + return consumeTuple(tokens, true); + case '{': + return consumeFields(tokens, true); + default: + return consumeValue(tokens, untilTest); + } + } + function consumeTopLevel(tokens, types, options){ + var ref$, type, structure, origTokens, result, finalResult, x$, y$; + ref$ = types[0], type = ref$.type, structure = ref$.structure; + origTokens = tokens.concat(); + if (!options.explicit && types.length === 1 && ((!type && structure) || (type === 'Array' || type === 'Object'))) { + result = structure === 'array' || type === 'Array' + ? consumeArray(tokens, tokens[0] === '[') + : structure === 'tuple' + ? consumeTuple(tokens, tokens[0] === '(') + : consumeFields(tokens, tokens[0] === '{'); + finalResult = tokens.length ? consumeElement(structure === 'array' || type === 'Array' + ? (x$ = origTokens, x$.unshift('['), x$.push(']'), x$) + : (y$ = origTokens, y$.unshift('('), y$.push(')'), y$)) : result; + } else { + finalResult = consumeElement(tokens); + } + return finalResult; + } + special = /\[\]\(\)}{:,/.source; + tokenRegex = RegExp('("(?:\\\\"|[^"])*")|(\'(?:\\\\\'|[^\'])*\')|(/(?:\\\\/|[^/])*/[a-zA-Z]*)|(#.*#)|([' + special + '])|([^\\s' + special + '](?:\\s*[^\\s' + special + ']+)*)|\\s*'); + module.exports = function(types, string, options){ + var tokens, node; + options == null && (options = {}); + if (!options.explicit && types.length === 1 && types[0].type === 'String') { + return string; + } + tokens = reject(not$, string.split(tokenRegex)); + node = consumeTopLevel(tokens, types, options); + if (!node) { + throw new Error("Error parsing '" + string + "'."); + } + return node; + }; + function not$(x){ return !x; } +}).call(this); diff --git a/tools/ui/node_modules/levn/package.json b/tools/ui/node_modules/levn/package.json new file mode 100644 index 0000000000000000000000000000000000000000..0c356d6978eef04f3e1072b89f2bb9828dcd44ae --- /dev/null +++ b/tools/ui/node_modules/levn/package.json @@ -0,0 +1,46 @@ +{ + "name": "levn", + "version": "0.4.1", + "author": "George Zahariev ", + "description": "Light ECMAScript (JavaScript) Value Notation - human written, concise, typed, flexible", + "homepage": "https://github.com/gkz/levn", + "keywords": [ + "levn", + "light", + "ecmascript", + "value", + "notation", + "json", + "typed", + "human", + "concise", + "typed", + "flexible" + ], + "files": [ + "lib", + "README.md", + "LICENSE" + ], + "main": "./lib/", + "bugs": "https://github.com/gkz/levn/issues", + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + }, + "repository": { + "type": "git", + "url": "git://github.com/gkz/levn.git" + }, + "scripts": { + "test": "make test" + }, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "devDependencies": { + "livescript": "^1.6.0", + "mocha": "^7.1.1" + } +} diff --git a/tools/ui/node_modules/lightningcss-linux-x64-gnu/LICENSE b/tools/ui/node_modules/lightningcss-linux-x64-gnu/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..89fe5b2004873b5f5237874446f65df5c02f9dc2 --- /dev/null +++ b/tools/ui/node_modules/lightningcss-linux-x64-gnu/LICENSE @@ -0,0 +1,373 @@ + Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" +means each individual or legal entity that creates, contributes to +the creation of, or owns Covered Software. + +1.2. "Contributor Version" +means the combination of the Contributions of others (if any) used +by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" +means Covered Software of a particular Contributor. + +1.4. "Covered Software" +means Source Code Form to which the initial Contributor has attached +the notice in Exhibit A, the Executable Form of such Source Code +Form, and Modifications of such Source Code Form, in each case +including portions thereof. + +1.5. "Incompatible With Secondary Licenses" +means + +(a) that the initial Contributor has attached the notice described +in Exhibit B to the Covered Software; or + +(b) that the Covered Software was made available under the terms of +version 1.1 or earlier of the License, but not also under the +terms of a Secondary License. + +1.6. "Executable Form" +means any form of the work other than Source Code Form. + +1.7. "Larger Work" +means a work that combines Covered Software with other material, in +a separate file or files, that is not Covered Software. + +1.8. "License" +means this document. + +1.9. "Licensable" +means having the right to grant, to the maximum extent possible, +whether at the time of the initial grant or subsequently, any and +all of the rights conveyed by this License. + +1.10. "Modifications" +means any of the following: + +(a) any file in Source Code Form that results from an addition to, +deletion from, or modification of the contents of Covered +Software; or + +(b) any new file in Source Code Form that contains any Covered +Software. + +1.11. "Patent Claims" of a Contributor +means any patent claim(s), including without limitation, method, +process, and apparatus claims, in any patent Licensable by such +Contributor that would be infringed, but for the grant of the +License, by the making, using, selling, offering for sale, having +made, import, or transfer of either its Contributions or its +Contributor Version. + +1.12. "Secondary License" +means either the GNU General Public License, Version 2.0, the GNU +Lesser General Public License, Version 2.1, the GNU Affero General +Public License, Version 3.0, or any later versions of those +licenses. + +1.13. "Source Code Form" +means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") +means an individual or a legal entity exercising rights under this +License. For legal entities, "You" includes any entity that +controls, is controlled by, or is under common control with You. For +purposes of this definition, "control" means (a) the power, direct +or indirect, to cause the direction or management of such entity, +whether by contract or otherwise, or (b) ownership of more than +fifty percent (50%) of the outstanding shares or beneficial +ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) +Licensable by such Contributor to use, reproduce, make available, +modify, display, perform, distribute, and otherwise exploit its +Contributions, either on an unmodified basis, with Modifications, or +as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer +for sale, have made, import, and otherwise transfer either its +Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; +or + +(b) for infringements caused by: (i) Your and any other third party's +modifications of Covered Software, or (ii) the combination of its +Contributions with other software (except as part of its Contributor +Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of +its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code +Form, as described in Section 3.1, and You must inform recipients of +the Executable Form how they can obtain a copy of such Source Code +Form by reasonable means in a timely manner, at a charge no more +than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this +License, or sublicense it under different terms, provided that the +license for the Executable Form does not attempt to limit or alter +the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + +This Source Code Form is "Incompatible With Secondary Licenses", as +defined by the Mozilla Public License, v. 2.0. diff --git a/tools/ui/node_modules/lightningcss-linux-x64-gnu/README.md b/tools/ui/node_modules/lightningcss-linux-x64-gnu/README.md new file mode 100644 index 0000000000000000000000000000000000000000..84f87d329ba13dd109a00f05af2e2c805e92c9fb --- /dev/null +++ b/tools/ui/node_modules/lightningcss-linux-x64-gnu/README.md @@ -0,0 +1 @@ +This is the x86_64-unknown-linux-gnu build of lightningcss. See https://github.com/parcel-bundler/lightningcss for details. \ No newline at end of file diff --git a/tools/ui/node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node b/tools/ui/node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node new file mode 100644 index 0000000000000000000000000000000000000000..1b3131f55389bb7e87e5ad4d32e56ba8389bdfd9 --- /dev/null +++ b/tools/ui/node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95391c184f5685282aea0831e1c41907bc9190270b9683d3452aaf8d275d0349 +size 9222960 diff --git a/tools/ui/node_modules/lightningcss-linux-x64-gnu/package.json b/tools/ui/node_modules/lightningcss-linux-x64-gnu/package.json new file mode 100644 index 0000000000000000000000000000000000000000..2aded46e1beb772f181f53bdbd7fb3664b321ec0 --- /dev/null +++ b/tools/ui/node_modules/lightningcss-linux-x64-gnu/package.json @@ -0,0 +1,37 @@ +{ + "name": "lightningcss-linux-x64-gnu", + "version": "1.30.1", + "license": "MPL-2.0", + "description": "A CSS parser, transformer, and minifier written in Rust", + "main": "lightningcss.linux-x64-gnu.node", + "browserslist": "last 2 versions, not dead", + "publishConfig": { + "access": "public" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "repository": { + "type": "git", + "url": "https://github.com/parcel-bundler/lightningcss.git" + }, + "engines": { + "node": ">= 12.0.0" + }, + "files": [ + "lightningcss.linux-x64-gnu.node" + ], + "resolutions": { + "lightningcss": "link:." + }, + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ] +} diff --git a/tools/ui/node_modules/lightningcss-linux-x64-musl/LICENSE b/tools/ui/node_modules/lightningcss-linux-x64-musl/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..89fe5b2004873b5f5237874446f65df5c02f9dc2 --- /dev/null +++ b/tools/ui/node_modules/lightningcss-linux-x64-musl/LICENSE @@ -0,0 +1,373 @@ + Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" +means each individual or legal entity that creates, contributes to +the creation of, or owns Covered Software. + +1.2. "Contributor Version" +means the combination of the Contributions of others (if any) used +by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" +means Covered Software of a particular Contributor. + +1.4. "Covered Software" +means Source Code Form to which the initial Contributor has attached +the notice in Exhibit A, the Executable Form of such Source Code +Form, and Modifications of such Source Code Form, in each case +including portions thereof. + +1.5. "Incompatible With Secondary Licenses" +means + +(a) that the initial Contributor has attached the notice described +in Exhibit B to the Covered Software; or + +(b) that the Covered Software was made available under the terms of +version 1.1 or earlier of the License, but not also under the +terms of a Secondary License. + +1.6. "Executable Form" +means any form of the work other than Source Code Form. + +1.7. "Larger Work" +means a work that combines Covered Software with other material, in +a separate file or files, that is not Covered Software. + +1.8. "License" +means this document. + +1.9. "Licensable" +means having the right to grant, to the maximum extent possible, +whether at the time of the initial grant or subsequently, any and +all of the rights conveyed by this License. + +1.10. "Modifications" +means any of the following: + +(a) any file in Source Code Form that results from an addition to, +deletion from, or modification of the contents of Covered +Software; or + +(b) any new file in Source Code Form that contains any Covered +Software. + +1.11. "Patent Claims" of a Contributor +means any patent claim(s), including without limitation, method, +process, and apparatus claims, in any patent Licensable by such +Contributor that would be infringed, but for the grant of the +License, by the making, using, selling, offering for sale, having +made, import, or transfer of either its Contributions or its +Contributor Version. + +1.12. "Secondary License" +means either the GNU General Public License, Version 2.0, the GNU +Lesser General Public License, Version 2.1, the GNU Affero General +Public License, Version 3.0, or any later versions of those +licenses. + +1.13. "Source Code Form" +means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") +means an individual or a legal entity exercising rights under this +License. For legal entities, "You" includes any entity that +controls, is controlled by, or is under common control with You. For +purposes of this definition, "control" means (a) the power, direct +or indirect, to cause the direction or management of such entity, +whether by contract or otherwise, or (b) ownership of more than +fifty percent (50%) of the outstanding shares or beneficial +ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) +Licensable by such Contributor to use, reproduce, make available, +modify, display, perform, distribute, and otherwise exploit its +Contributions, either on an unmodified basis, with Modifications, or +as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer +for sale, have made, import, and otherwise transfer either its +Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; +or + +(b) for infringements caused by: (i) Your and any other third party's +modifications of Covered Software, or (ii) the combination of its +Contributions with other software (except as part of its Contributor +Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of +its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code +Form, as described in Section 3.1, and You must inform recipients of +the Executable Form how they can obtain a copy of such Source Code +Form by reasonable means in a timely manner, at a charge no more +than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this +License, or sublicense it under different terms, provided that the +license for the Executable Form does not attempt to limit or alter +the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + +This Source Code Form is "Incompatible With Secondary Licenses", as +defined by the Mozilla Public License, v. 2.0. diff --git a/tools/ui/node_modules/lightningcss-linux-x64-musl/README.md b/tools/ui/node_modules/lightningcss-linux-x64-musl/README.md new file mode 100644 index 0000000000000000000000000000000000000000..527d999c040b8306953424fabc4cc377a45b156f --- /dev/null +++ b/tools/ui/node_modules/lightningcss-linux-x64-musl/README.md @@ -0,0 +1 @@ +This is the x86_64-unknown-linux-musl build of lightningcss. See https://github.com/parcel-bundler/lightningcss for details. \ No newline at end of file diff --git a/tools/ui/node_modules/lightningcss-linux-x64-musl/lightningcss.linux-x64-musl.node b/tools/ui/node_modules/lightningcss-linux-x64-musl/lightningcss.linux-x64-musl.node new file mode 100644 index 0000000000000000000000000000000000000000..519d4f9a59002b7aafc7d9ac9a9e6f3ce518375a --- /dev/null +++ b/tools/ui/node_modules/lightningcss-linux-x64-musl/lightningcss.linux-x64-musl.node @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92ab4cf61134dde755edc4fa29c9ad81b6d9d27101a06ceff13f9cb51cafb11a +size 9218664 diff --git a/tools/ui/node_modules/lightningcss-linux-x64-musl/package.json b/tools/ui/node_modules/lightningcss-linux-x64-musl/package.json new file mode 100644 index 0000000000000000000000000000000000000000..9a204940f50a250a7a9a2433f4b6401c204ecbdd --- /dev/null +++ b/tools/ui/node_modules/lightningcss-linux-x64-musl/package.json @@ -0,0 +1,37 @@ +{ + "name": "lightningcss-linux-x64-musl", + "version": "1.30.1", + "license": "MPL-2.0", + "description": "A CSS parser, transformer, and minifier written in Rust", + "main": "lightningcss.linux-x64-musl.node", + "browserslist": "last 2 versions, not dead", + "publishConfig": { + "access": "public" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "repository": { + "type": "git", + "url": "https://github.com/parcel-bundler/lightningcss.git" + }, + "engines": { + "node": ">= 12.0.0" + }, + "files": [ + "lightningcss.linux-x64-musl.node" + ], + "resolutions": { + "lightningcss": "link:." + }, + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ] +} diff --git a/tools/ui/node_modules/lightningcss/LICENSE b/tools/ui/node_modules/lightningcss/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..89fe5b2004873b5f5237874446f65df5c02f9dc2 --- /dev/null +++ b/tools/ui/node_modules/lightningcss/LICENSE @@ -0,0 +1,373 @@ + Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" +means each individual or legal entity that creates, contributes to +the creation of, or owns Covered Software. + +1.2. "Contributor Version" +means the combination of the Contributions of others (if any) used +by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" +means Covered Software of a particular Contributor. + +1.4. "Covered Software" +means Source Code Form to which the initial Contributor has attached +the notice in Exhibit A, the Executable Form of such Source Code +Form, and Modifications of such Source Code Form, in each case +including portions thereof. + +1.5. "Incompatible With Secondary Licenses" +means + +(a) that the initial Contributor has attached the notice described +in Exhibit B to the Covered Software; or + +(b) that the Covered Software was made available under the terms of +version 1.1 or earlier of the License, but not also under the +terms of a Secondary License. + +1.6. "Executable Form" +means any form of the work other than Source Code Form. + +1.7. "Larger Work" +means a work that combines Covered Software with other material, in +a separate file or files, that is not Covered Software. + +1.8. "License" +means this document. + +1.9. "Licensable" +means having the right to grant, to the maximum extent possible, +whether at the time of the initial grant or subsequently, any and +all of the rights conveyed by this License. + +1.10. "Modifications" +means any of the following: + +(a) any file in Source Code Form that results from an addition to, +deletion from, or modification of the contents of Covered +Software; or + +(b) any new file in Source Code Form that contains any Covered +Software. + +1.11. "Patent Claims" of a Contributor +means any patent claim(s), including without limitation, method, +process, and apparatus claims, in any patent Licensable by such +Contributor that would be infringed, but for the grant of the +License, by the making, using, selling, offering for sale, having +made, import, or transfer of either its Contributions or its +Contributor Version. + +1.12. "Secondary License" +means either the GNU General Public License, Version 2.0, the GNU +Lesser General Public License, Version 2.1, the GNU Affero General +Public License, Version 3.0, or any later versions of those +licenses. + +1.13. "Source Code Form" +means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") +means an individual or a legal entity exercising rights under this +License. For legal entities, "You" includes any entity that +controls, is controlled by, or is under common control with You. For +purposes of this definition, "control" means (a) the power, direct +or indirect, to cause the direction or management of such entity, +whether by contract or otherwise, or (b) ownership of more than +fifty percent (50%) of the outstanding shares or beneficial +ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) +Licensable by such Contributor to use, reproduce, make available, +modify, display, perform, distribute, and otherwise exploit its +Contributions, either on an unmodified basis, with Modifications, or +as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer +for sale, have made, import, and otherwise transfer either its +Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; +or + +(b) for infringements caused by: (i) Your and any other third party's +modifications of Covered Software, or (ii) the combination of its +Contributions with other software (except as part of its Contributor +Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of +its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code +Form, as described in Section 3.1, and You must inform recipients of +the Executable Form how they can obtain a copy of such Source Code +Form by reasonable means in a timely manner, at a charge no more +than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this +License, or sublicense it under different terms, provided that the +license for the Executable Form does not attempt to limit or alter +the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + +This Source Code Form is "Incompatible With Secondary Licenses", as +defined by the Mozilla Public License, v. 2.0. diff --git a/tools/ui/node_modules/lightningcss/README.md b/tools/ui/node_modules/lightningcss/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f44d7b3cdc7f59e2cf8a8326cb2b05de5305d9a3 --- /dev/null +++ b/tools/ui/node_modules/lightningcss/README.md @@ -0,0 +1,105 @@ +# ⚡️ Lightning CSS + +An extremely fast CSS parser, transformer, and minifier written in Rust. Use it with [Parcel](https://parceljs.org), as a standalone library or CLI, or via a plugin with any other tool. + +performance and build size charts +performance and build size charts + +## Features + +- **Extremely fast** – Parsing and minifying large files is completed in milliseconds, often with significantly smaller output than other tools. See [benchmarks](#benchmarks) below. +- **Typed property values** – many other CSS parsers treat property values as an untyped series of tokens. This means that each transformer that wants to do something with these values must interpret them itself, leading to duplicate work and inconsistencies. Lightning CSS parses all values using the grammar from the CSS specification, and exposes a specific value type for each property. +- **Browser-grade parser** – Lightning CSS is built on the [cssparser](https://github.com/servo/rust-cssparser) and [selectors](https://github.com/servo/stylo/tree/main/selectors) crates created by Mozilla and used by Firefox and Servo. These provide a solid general purpose CSS-parsing foundation on top of which Lightning CSS implements support for all specific CSS rules and properties. +- **Minification** – One of the main purposes of Lightning CSS is to minify CSS to make it smaller. This includes many optimizations including: + - Combining longhand properties into shorthands where possible. + - Merging adjacent rules with the same selectors or declarations when it is safe to do so. + - Combining CSS transforms into a single matrix or vice versa when smaller. + - Removing vendor prefixes that are not needed, based on the provided browser targets. + - Reducing `calc()` expressions where possible. + - Converting colors to shorter hex notation where possible. + - Minifying gradients. + - Minifying CSS grid templates. + - Normalizing property value order. + - Removing default property sub-values which will be inferred by browsers. + - Many micro-optimizations, e.g. converting to shorter units, removing unnecessary quotation marks, etc. +- **Vendor prefixing** – Lightning CSS accepts a list of browser targets, and automatically adds (and removes) vendor prefixes. +- **Browserslist configuration** – Lightning CSS supports opt-in browserslist configuration discovery to resolve browser targets and integrate with your existing tools and config setup. +- **Syntax lowering** – Lightning CSS parses modern CSS syntax, and generates more compatible output where needed, based on browser targets. + - CSS Nesting + - Custom media queries (draft spec) + - Logical properties + * [Color Level 5](https://drafts.csswg.org/css-color-5/) + - `color-mix()` function + - Relative color syntax, e.g. `lab(from purple calc(l * .8) a b)` + - [Color Level 4](https://drafts.csswg.org/css-color-4/) + - `lab()`, `lch()`, `oklab()`, and `oklch()` colors + - `color()` function supporting predefined color spaces such as `display-p3` and `xyz` + - Space separated components in `rgb` and `hsl` functions + - Hex with alpha syntax + - `hwb()` color syntax + - Percent syntax for opacity + - `#rgba` and `#rrggbbaa` hex colors + - Selectors + - `:not` with multiple arguments + - `:lang` with multiple arguments + - `:dir` + - `:is` + - Double position gradient stops (e.g. `red 40% 80%`) + - `clamp()`, `round()`, `rem()`, and `mod()` math functions + - Alignment shorthands (e.g. `place-items`) + - Two-value `overflow` shorthand + - Media query range syntax (e.g. `@media (width <= 100px)` or `@media (100px < width < 500px)`) + - Multi-value `display` property (e.g. `inline flex`) + - `system-ui` font family fallbacks +- **CSS modules** – Lightning CSS supports compiling a subset of [CSS modules](https://github.com/css-modules/css-modules) features. + - Locally scoped class and id selectors + - Locally scoped custom identifiers, e.g. `@keyframes` names, grid lines/areas, `@counter-style` names, etc. + - Opt-in support for locally scoped CSS variables and other dashed identifiers. + - `:local()` and `:global()` selectors + - The `composes` property +- **Custom transforms** – The Lightning CSS visitor API can be used to implement custom transform plugins. + +## Documentation + +Lightning CSS can be used from [Parcel](https://parceljs.org), as a standalone library from JavaScript or Rust, using a standalone CLI, or wrapped as a plugin within any other tool. See the [Lightning CSS website](https://lightningcss.dev/docs.html) for documentation. + +## Benchmarks + +performance and build size charts +performance and build size charts + +``` +$ node bench.js bootstrap-4.css +cssnano: 544.809ms +159636 bytes + +esbuild: 17.199ms +160332 bytes + +lightningcss: 4.16ms +143091 bytes + + +$ node bench.js animate.css +cssnano: 283.105ms +71723 bytes + +esbuild: 11.858ms +72183 bytes + +lightningcss: 1.973ms +23666 bytes + + +$ node bench.js tailwind.css +cssnano: 2.198s +1925626 bytes + +esbuild: 107.668ms +1961642 bytes + +lightningcss: 43.368ms +1824130 bytes +``` + +For more benchmarks comparing more tools and input, see [here](http://goalsmashers.github.io/css-minification-benchmark/). Note that some of the tools shown perform unsafe optimizations that may change the behavior of the original CSS in favor of smaller file size. Lightning CSS does not do this – the output CSS should always behave identically to the input. Keep this in mind when comparing file sizes between tools. diff --git a/tools/ui/node_modules/lightningcss/node/ast.d.ts b/tools/ui/node_modules/lightningcss/node/ast.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..08d9d786e45e72d823156b69bb02d7327cb69f76 --- /dev/null +++ b/tools/ui/node_modules/lightningcss/node/ast.d.ts @@ -0,0 +1,9739 @@ +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export type String = string; +/** + * A CSS rule. + */ +export type Rule = | { + type: "media"; + value: MediaRule; + } +| { + type: "import"; + value: ImportRule; + } +| { + type: "style"; + value: StyleRule; + } +| { + type: "keyframes"; + value: KeyframesRule; + } +| { + type: "font-face"; + value: FontFaceRule; + } +| { + type: "font-palette-values"; + value: FontPaletteValuesRule; + } +| { + type: "font-feature-values"; + value: FontFeatureValuesRule; + } +| { + type: "page"; + value: PageRule; + } +| { + type: "supports"; + value: SupportsRule; + } +| { + type: "counter-style"; + value: CounterStyleRule; + } +| { + type: "namespace"; + value: NamespaceRule; + } +| { + type: "moz-document"; + value: MozDocumentRule; + } +| { + type: "nesting"; + value: NestingRule; + } +| { + type: "nested-declarations"; + value: NestedDeclarationsRule; + } +| { + type: "viewport"; + value: ViewportRule; + } +| { + type: "custom-media"; + value: CustomMediaRule; + } +| { + type: "layer-statement"; + value: LayerStatementRule; + } +| { + type: "layer-block"; + value: LayerBlockRule; + } +| { + type: "property"; + value: PropertyRule; + } +| { + type: "container"; + value: ContainerRule; + } +| { + type: "scope"; + value: ScopeRule; + } +| { + type: "starting-style"; + value: StartingStyleRule; + } +| { + type: "view-transition"; + value: ViewTransitionRule; + } +| { + type: "ignored"; + } +| { + type: "unknown"; + value: UnknownAtRule; + } +| { + type: "custom"; + value: DefaultAtRule; + }; +/** + * Represents a media condition. + */ +export type MediaCondition = + | { + type: "feature"; + value: QueryFeatureFor_MediaFeatureId; + } + | { + type: "not"; + value: MediaCondition; + } + | { + /** + * The conditions for the operator. + */ + conditions: MediaCondition[]; + /** + * The operator for the conditions. + */ + operator: Operator; + type: "operation"; + }; +/** + * A generic media feature or container feature. + */ +export type QueryFeatureFor_MediaFeatureId = + | { + /** + * The name of the feature. + */ + name: MediaFeatureNameFor_MediaFeatureId; + type: "plain"; + /** + * The feature value. + */ + value: MediaFeatureValue; + } + | { + /** + * The name of the feature. + */ + name: MediaFeatureNameFor_MediaFeatureId; + type: "boolean"; + } + | { + /** + * The name of the feature. + */ + name: MediaFeatureNameFor_MediaFeatureId; + /** + * A comparator. + */ + operator: MediaFeatureComparison; + type: "range"; + /** + * The feature value. + */ + value: MediaFeatureValue; + } + | { + /** + * The end value. + */ + end: MediaFeatureValue; + /** + * A comparator for the end value. + */ + endOperator: MediaFeatureComparison; + /** + * The name of the feature. + */ + name: MediaFeatureNameFor_MediaFeatureId; + /** + * A start value. + */ + start: MediaFeatureValue; + /** + * A comparator for the start value. + */ + startOperator: MediaFeatureComparison; + type: "interval"; + }; +/** + * A media feature name. + */ +export type MediaFeatureNameFor_MediaFeatureId = MediaFeatureId | String | String; +/** + * A media query feature identifier. + */ +export type MediaFeatureId = + | "width" + | "height" + | "aspect-ratio" + | "orientation" + | "overflow-block" + | "overflow-inline" + | "horizontal-viewport-segments" + | "vertical-viewport-segments" + | "display-mode" + | "resolution" + | "scan" + | "grid" + | "update" + | "environment-blending" + | "color" + | "color-index" + | "monochrome" + | "color-gamut" + | "dynamic-range" + | "inverted-colors" + | "pointer" + | "hover" + | "any-pointer" + | "any-hover" + | "nav-controls" + | "video-color-gamut" + | "video-dynamic-range" + | "scripting" + | "prefers-reduced-motion" + | "prefers-reduced-transparency" + | "prefers-contrast" + | "forced-colors" + | "prefers-color-scheme" + | "prefers-reduced-data" + | "device-width" + | "device-height" + | "device-aspect-ratio" + | "-webkit-device-pixel-ratio" + | "-moz-device-pixel-ratio"; +/** + * [media feature value](https://drafts.csswg.org/mediaqueries/#typedef-mf-value) within a media query. + * + * See [MediaFeature](MediaFeature). + */ +export type MediaFeatureValue = + | { + type: "length"; + value: Length; + } + | { + type: "number"; + value: number; + } + | { + type: "integer"; + value: number; + } + | { + type: "boolean"; + value: boolean; + } + | { + type: "resolution"; + value: Resolution; + } + | { + type: "ratio"; + value: Ratio; + } + | { + type: "ident"; + value: String; + } + | { + type: "env"; + value: EnvironmentVariable; + }; +/** + * A CSS [``](https://www.w3.org/TR/css-values-4/#lengths) value, with support for `calc()`. + */ +export type Length = + | { + type: "value"; + value: LengthValue; + } + | { + type: "calc"; + value: CalcFor_Length; + }; +export type LengthUnit = + | "px" + | "in" + | "cm" + | "mm" + | "q" + | "pt" + | "pc" + | "em" + | "rem" + | "ex" + | "rex" + | "ch" + | "rch" + | "cap" + | "rcap" + | "ic" + | "ric" + | "lh" + | "rlh" + | "vw" + | "lvw" + | "svw" + | "dvw" + | "cqw" + | "vh" + | "lvh" + | "svh" + | "dvh" + | "cqh" + | "vi" + | "svi" + | "lvi" + | "dvi" + | "cqi" + | "vb" + | "svb" + | "lvb" + | "dvb" + | "cqb" + | "vmin" + | "svmin" + | "lvmin" + | "dvmin" + | "cqmin" + | "vmax" + | "svmax" + | "lvmax" + | "dvmax" + | "cqmax"; +/** + * A mathematical expression used within the [`calc()`](https://www.w3.org/TR/css-values-4/#calc-func) function. + * + * This type supports generic value types. Values such as [Length](super::length::Length), [Percentage](super::percentage::Percentage), [Time](super::time::Time), and [Angle](super::angle::Angle) support `calc()` expressions. + */ +export type CalcFor_Length = + | { + type: "value"; + value: Length; + } + | { + type: "number"; + value: number; + } + | { + type: "sum"; + /** + * @minItems 2 + * @maxItems 2 + */ + value: [CalcFor_Length, CalcFor_Length]; + } + | { + type: "product"; + /** + * @minItems 2 + * @maxItems 2 + */ + value: [number, CalcFor_Length]; + } + | { + type: "function"; + value: MathFunctionFor_Length; + }; +/** + * A CSS [math function](https://www.w3.org/TR/css-values-4/#math-function). + * + * Math functions may be used in most properties and values that accept numeric values, including lengths, percentages, angles, times, etc. + */ +export type MathFunctionFor_Length = + | { + type: "calc"; + value: CalcFor_Length; + } + | { + type: "min"; + value: CalcFor_Length[]; + } + | { + type: "max"; + value: CalcFor_Length[]; + } + | { + type: "clamp"; + /** + * @minItems 3 + * @maxItems 3 + */ + value: [CalcFor_Length, CalcFor_Length, CalcFor_Length]; + } + | { + type: "round"; + /** + * @minItems 3 + * @maxItems 3 + */ + value: [RoundingStrategy, CalcFor_Length, CalcFor_Length]; + } + | { + type: "rem"; + /** + * @minItems 2 + * @maxItems 2 + */ + value: [CalcFor_Length, CalcFor_Length]; + } + | { + type: "mod"; + /** + * @minItems 2 + * @maxItems 2 + */ + value: [CalcFor_Length, CalcFor_Length]; + } + | { + type: "abs"; + value: CalcFor_Length; + } + | { + type: "sign"; + value: CalcFor_Length; + } + | { + type: "hypot"; + value: CalcFor_Length[]; + }; +/** + * A [rounding strategy](https://www.w3.org/TR/css-values-4/#typedef-rounding-strategy), as used in the `round()` function. + */ +export type RoundingStrategy = "nearest" | "up" | "down" | "to-zero"; +/** + * A CSS [``](https://www.w3.org/TR/css-values-4/#resolution) value. + */ +export type Resolution = + | { + type: "dpi"; + value: number; + } + | { + type: "dpcm"; + value: number; + } + | { + type: "dppx"; + value: number; + }; +/** + * A CSS [``](https://www.w3.org/TR/css-values-4/#ratios) value, representing the ratio of two numeric values. + * + * @minItems 2 + * @maxItems 2 + */ +export type Ratio = [number, number]; +/** + * A raw CSS token, or a parsed value. + */ +export type TokenOrValue = + | { + type: "token"; + value: Token; + } + | { + type: "color"; + value: CssColor; + } + | { + type: "unresolved-color"; + value: UnresolvedColor; + } + | { + type: "url"; + value: Url; + } + | { + type: "var"; + value: Variable; + } + | { + type: "env"; + value: EnvironmentVariable; + } + | { + type: "function"; + value: Function; + } + | { + type: "length"; + value: LengthValue; + } + | { + type: "angle"; + value: Angle; + } + | { + type: "time"; + value: Time; + } + | { + type: "resolution"; + value: Resolution; + } + | { + type: "dashed-ident"; + value: String; + } + | { + type: "animation-name"; + value: AnimationName; + }; +/** + * A raw CSS token. + */ +export type Token = + | { + type: "ident"; + value: String; + } + | { + type: "at-keyword"; + value: String; + } + | { + type: "hash"; + value: String; + } + | { + type: "id-hash"; + value: String; + } + | { + type: "string"; + value: String; + } + | { + type: "unquoted-url"; + value: String; + } + | { + type: "delim"; + value: string; + } + | { + type: "number"; + /** + * The value as a float + */ + value: number; + } + | { + type: "percentage"; + /** + * The value as a float, divided by 100 so that the nominal range is 0.0 to 1.0. + */ + value: number; + } + | { + type: "dimension"; + /** + * The unit, e.g. "px" in `12px` + */ + unit: String; + /** + * The value as a float + */ + value: number; + } + | { + type: "white-space"; + value: String; + } + | { + type: "comment"; + value: String; + } + | { + type: "colon"; + } + | { + type: "semicolon"; + } + | { + type: "comma"; + } + | { + type: "include-match"; + } + | { + type: "dash-match"; + } + | { + type: "prefix-match"; + } + | { + type: "suffix-match"; + } + | { + type: "substring-match"; + } + | { + type: "cdo"; + } + | { + type: "cdc"; + } + | { + type: "function"; + value: String; + } + | { + type: "parenthesis-block"; + } + | { + type: "square-bracket-block"; + } + | { + type: "curly-bracket-block"; + } + | { + type: "bad-url"; + value: String; + } + | { + type: "bad-string"; + value: String; + } + | { + type: "close-parenthesis"; + } + | { + type: "close-square-bracket"; + } + | { + type: "close-curly-bracket"; + }; +/** + * A CSS [``](https://www.w3.org/TR/css-color-4/#color-type) value. + * + * CSS supports many different color spaces to represent colors. The most common values are stored as RGBA using a single byte per component. Less common values are stored using a `Box` to reduce the amount of memory used per color. + * + * Each color space is represented as a struct that implements the `From` and `Into` traits for all other color spaces, so it is possible to convert between color spaces easily. In addition, colors support [interpolation](#method.interpolate) as in the `color-mix()` function. + */ +export type CssColor = CurrentColor | RGBColor | LABColor | PredefinedColor | FloatColor | LightDark | SystemColor; +export type CurrentColor = { + type: "currentcolor"; +}; +export type RGBColor = { + /** + * The alpha component. + */ + alpha: number; + /** + * The blue component. + */ + b: number; + /** + * The green component. + */ + g: number; + /** + * The red component. + */ + r: number; + type: "rgb"; +}; +/** + * A color in a LAB color space, including the `lab()`, `lch()`, `oklab()`, and `oklch()` functions. + */ +export type LABColor = + | { + /** + * The a component. + */ + a: number; + /** + * The alpha component. + */ + alpha: number; + /** + * The b component. + */ + b: number; + /** + * The lightness component. + */ + l: number; + type: "lab"; + } + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The chroma component. + */ + c: number; + /** + * The hue component. + */ + h: number; + /** + * The lightness component. + */ + l: number; + type: "lch"; + } + | { + /** + * The a component. + */ + a: number; + /** + * The alpha component. + */ + alpha: number; + /** + * The b component. + */ + b: number; + /** + * The lightness component. + */ + l: number; + type: "oklab"; + } + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The chroma component. + */ + c: number; + /** + * The hue component. + */ + h: number; + /** + * The lightness component. + */ + l: number; + type: "oklch"; + }; +/** + * A color in a predefined color space, e.g. `display-p3`. + */ +export type PredefinedColor = + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The blue component. + */ + b: number; + /** + * The green component. + */ + g: number; + /** + * The red component. + */ + r: number; + type: "srgb"; + } + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The blue component. + */ + b: number; + /** + * The green component. + */ + g: number; + /** + * The red component. + */ + r: number; + type: "srgb-linear"; + } + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The blue component. + */ + b: number; + /** + * The green component. + */ + g: number; + /** + * The red component. + */ + r: number; + type: "display-p3"; + } + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The blue component. + */ + b: number; + /** + * The green component. + */ + g: number; + /** + * The red component. + */ + r: number; + type: "a98-rgb"; + } + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The blue component. + */ + b: number; + /** + * The green component. + */ + g: number; + /** + * The red component. + */ + r: number; + type: "prophoto-rgb"; + } + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The blue component. + */ + b: number; + /** + * The green component. + */ + g: number; + /** + * The red component. + */ + r: number; + type: "rec2020"; + } + | { + /** + * The alpha component. + */ + alpha: number; + type: "xyz-d50"; + /** + * The x component. + */ + x: number; + /** + * The y component. + */ + y: number; + /** + * The z component. + */ + z: number; + } + | { + /** + * The alpha component. + */ + alpha: number; + type: "xyz-d65"; + /** + * The x component. + */ + x: number; + /** + * The y component. + */ + y: number; + /** + * The z component. + */ + z: number; + }; +/** + * A floating point representation of color types that are usually stored as RGBA. These are used when there are any `none` components, which are represented as NaN. + */ +export type FloatColor = + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The blue component. + */ + b: number; + /** + * The green component. + */ + g: number; + /** + * The red component. + */ + r: number; + type: "rgb"; + } + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The hue component. + */ + h: number; + /** + * The lightness component. + */ + l: number; + /** + * The saturation component. + */ + s: number; + type: "hsl"; + } + | { + /** + * The alpha component. + */ + alpha: number; + /** + * The blackness component. + */ + b: number; + /** + * The hue component. + */ + h: number; + type: "hwb"; + /** + * The whiteness component. + */ + w: number; + }; +export type LightDark = { + dark: CssColor; + light: CssColor; + type: "light-dark"; +}; +/** + * A CSS [system color](https://drafts.csswg.org/css-color/#css-system-colors) keyword. + */ +export type SystemColor = + | "accentcolor" + | "accentcolortext" + | "activetext" + | "buttonborder" + | "buttonface" + | "buttontext" + | "canvas" + | "canvastext" + | "field" + | "fieldtext" + | "graytext" + | "highlight" + | "highlighttext" + | "linktext" + | "mark" + | "marktext" + | "selecteditem" + | "selecteditemtext" + | "visitedtext" + | "activeborder" + | "activecaption" + | "appworkspace" + | "background" + | "buttonhighlight" + | "buttonshadow" + | "captiontext" + | "inactiveborder" + | "inactivecaption" + | "inactivecaptiontext" + | "infobackground" + | "infotext" + | "menu" + | "menutext" + | "scrollbar" + | "threeddarkshadow" + | "threedface" + | "threedhighlight" + | "threedlightshadow" + | "threedshadow" + | "window" + | "windowframe" + | "windowtext"; +/** + * A color value with an unresolved alpha value (e.g. a variable). These can be converted from the modern slash syntax to older comma syntax. This can only be done when the only unresolved component is the alpha since variables can resolve to multiple tokens. + */ +export type UnresolvedColor = + | { + /** + * The unresolved alpha component. + */ + alpha: TokenOrValue[]; + /** + * The blue component. + */ + b: number; + /** + * The green component. + */ + g: number; + /** + * The red component. + */ + r: number; + type: "rgb"; + } + | { + /** + * The unresolved alpha component. + */ + alpha: TokenOrValue[]; + /** + * The hue component. + */ + h: number; + /** + * The lightness component. + */ + l: number; + /** + * The saturation component. + */ + s: number; + type: "hsl"; + } + | { + /** + * The dark value. + */ + dark: TokenOrValue[]; + /** + * The light value. + */ + light: TokenOrValue[]; + type: "light-dark"; + }; +/** + * Defines where the class names referenced in the `composes` property are located. + * + * See [Composes](Composes). + */ +export type Specifier = + | { + type: "global"; + } + | { + type: "file"; + value: String; + } + | { + type: "source-index"; + value: number; + }; +/** + * A CSS [``](https://www.w3.org/TR/css-values-4/#angles) value. + * + * Angles may be explicit or computed by `calc()`, but are always stored and serialized as their computed value. + */ +export type Angle = + | { + type: "deg"; + value: number; + } + | { + type: "rad"; + value: number; + } + | { + type: "grad"; + value: number; + } + | { + type: "turn"; + value: number; + }; +/** + * A CSS [`