@5even7/dlc-ui 0.2.18 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +147 -144
- package/LICENSE +21 -21
- package/README.md +338 -338
- package/THIRD_PARTY_NOTICES.md +17 -0
- package/dist/avatar-creator.cjs +7221 -0
- package/dist/avatar-creator.mjs +9278 -0
- package/dist/capsule.cjs +185 -66
- package/dist/capsule.mjs +1208 -1103
- package/dist/color.cjs +186 -67
- package/dist/color.mjs +1157 -1052
- package/dist/emo.cjs +166 -47
- package/dist/emo.mjs +324 -219
- package/dist/index.cjs +6806 -98
- package/dist/index.mjs +13240 -4296
- package/dist/index.umd.js +6806 -98
- package/dist/index.umd.min.js +1 -1
- package/dist/progress.cjs +195 -76
- package/dist/progress.mjs +2293 -2188
- package/dist/vue2.cjs +7001 -247
- package/dist/vue2.mjs +13664 -4691
- package/dist/vue3.cjs +7001 -247
- package/dist/vue3.mjs +13664 -4691
- package/package.json +146 -136
- package/styles/avatar-creator.css +13 -0
- package/styles/base.css +32 -32
- package/styles/color.css +18 -18
- package/styles/emo.css +89 -89
- package/styles/progress.css +96 -96
- package/styles/theme.css +1 -0
- package/types/avatar-creator.d.ts +124 -0
- package/types/capsule.d.ts +15 -15
- package/types/color.d.ts +15 -15
- package/types/emo.d.ts +37 -37
- package/types/index.d.ts +581 -554
- package/types/progress.d.ts +16 -16
- package/types/vue2.d.ts +11 -10
- package/types/vue3.d.ts +169 -146
package/dist/emo.cjs
CHANGED
|
@@ -161,9 +161,9 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
/**
|
|
165
|
-
* Tiny event emitter. Accepts any event name so the API stays open for
|
|
166
|
-
* future events (hover, click, custom) without breaking changes.
|
|
164
|
+
/**
|
|
165
|
+
* Tiny event emitter. Accepts any event name so the API stays open for
|
|
166
|
+
* future events (hover, click, custom) without breaking changes.
|
|
167
167
|
*/
|
|
168
168
|
function createEmitter() {
|
|
169
169
|
// Plain object storage (no Map/Set) so the legacy build has no API
|
|
@@ -213,9 +213,9 @@ function createEmitter() {
|
|
|
213
213
|
|
|
214
214
|
var UNIT_PATTERN = /^[\d.]+(?:px|%|vw|vh|vmin|vmax|em|rem)$/;
|
|
215
215
|
|
|
216
|
-
/**
|
|
217
|
-
* Normalize a size option to a CSS length string.
|
|
218
|
-
* Accepts numbers (treated as px) or strings with px/%, vw/vh/vmin/vmax, em/rem.
|
|
216
|
+
/**
|
|
217
|
+
* Normalize a size option to a CSS length string.
|
|
218
|
+
* Accepts numbers (treated as px) or strings with px/%, vw/vh/vmin/vmax, em/rem.
|
|
219
219
|
*/
|
|
220
220
|
function parseSize(value) {
|
|
221
221
|
if (typeof value === 'number') {
|
|
@@ -26703,10 +26703,16 @@ function getEmoAnimation() {
|
|
|
26703
26703
|
|
|
26704
26704
|
/**
|
|
26705
26705
|
* Color helpers. `normalizeColor` converts any supported CSS color
|
|
26706
|
-
* (hex / named / rgb() / rgba()) into a 6-digit hex string,
|
|
26707
|
-
* keep working with #rrggbb only. rgba() alpha is
|
|
26708
|
-
* the WebGL shader has no per-color alpha channel, and
|
|
26709
|
-
* opaque by design — use component-level `opacity` for
|
|
26706
|
+
* (hex / named / rgb() / rgba() / hsl() / hsla()) into a 6-digit hex string,
|
|
26707
|
+
* so renderers can keep working with #rrggbb only. rgba()/hsla() alpha is
|
|
26708
|
+
* intentionally dropped: the WebGL shader has no per-color alpha channel, and
|
|
26709
|
+
* the component is opaque by design — use component-level `opacity` for
|
|
26710
|
+
* transparency.
|
|
26711
|
+
*
|
|
26712
|
+
* `normalizeColorWithAlpha` keeps the alpha channel: it returns a 6-digit hex
|
|
26713
|
+
* when alpha is 1, an 8-digit #rrggbbaa hex when alpha < 1, and the literal
|
|
26714
|
+
* string 'transparent' for `transparent`. Use it for renderers (e.g. SVG)
|
|
26715
|
+
* that can represent per-color transparency.
|
|
26710
26716
|
*/
|
|
26711
26717
|
|
|
26712
26718
|
var NAMED_COLORS = {
|
|
@@ -26862,48 +26868,161 @@ var NAMED_COLORS = {
|
|
|
26862
26868
|
function clampChannel(value) {
|
|
26863
26869
|
return Math.min(255, Math.max(0, Math.round(value)));
|
|
26864
26870
|
}
|
|
26865
|
-
function
|
|
26866
|
-
|
|
26871
|
+
function clampUnit(value) {
|
|
26872
|
+
return Math.min(1, Math.max(0, value));
|
|
26873
|
+
}
|
|
26874
|
+
function hexPair(value) {
|
|
26875
|
+
var text = clampChannel(value).toString(16);
|
|
26876
|
+
return text.length === 1 ? "0".concat(text) : text;
|
|
26877
|
+
}
|
|
26878
|
+
|
|
26879
|
+
/**
|
|
26880
|
+
* Parse the argument list of rgb()/rgba()/hsl()/hsla() (comma syntax or
|
|
26881
|
+
* modern space + slash syntax). Returns { parts, alpha } where alpha is 1 when
|
|
26882
|
+
* omitted. Returns null when the argument list cannot be parsed.
|
|
26883
|
+
*/
|
|
26884
|
+
function parseFunctionArgs(args) {
|
|
26885
|
+
var parts = args.split(/[,\s]+/).map(function (part) {
|
|
26886
|
+
return part.trim();
|
|
26887
|
+
}).filter(function (part) {
|
|
26888
|
+
return part !== '' && part !== '/';
|
|
26889
|
+
});
|
|
26867
26890
|
if (parts.length < 3) return null;
|
|
26868
|
-
var
|
|
26869
|
-
|
|
26870
|
-
|
|
26871
|
-
|
|
26872
|
-
|
|
26873
|
-
|
|
26874
|
-
|
|
26875
|
-
|
|
26876
|
-
|
|
26877
|
-
|
|
26878
|
-
|
|
26879
|
-
|
|
26880
|
-
|
|
26891
|
+
var alpha = 1;
|
|
26892
|
+
if (parts.length >= 4) {
|
|
26893
|
+
var alphaText = parts.pop().trim();
|
|
26894
|
+
if (alphaText.endsWith('%')) {
|
|
26895
|
+
var percent = parseFloat(alphaText);
|
|
26896
|
+
if (!Number.isFinite(percent)) return null;
|
|
26897
|
+
alpha = clampUnit(percent / 100);
|
|
26898
|
+
} else {
|
|
26899
|
+
var number = Number(alphaText);
|
|
26900
|
+
if (!Number.isFinite(number)) return null;
|
|
26901
|
+
alpha = clampUnit(number);
|
|
26902
|
+
}
|
|
26903
|
+
}
|
|
26904
|
+
return {
|
|
26905
|
+
parts: parts,
|
|
26906
|
+
alpha: alpha
|
|
26881
26907
|
};
|
|
26882
|
-
|
|
26908
|
+
}
|
|
26909
|
+
function parseChannel(value) {
|
|
26910
|
+
if (typeof value !== 'string' || value === '') return null;
|
|
26911
|
+
var text = value.trim();
|
|
26912
|
+
if (text.endsWith('%')) return clampChannel(parseFloat(text) / 100 * 255);
|
|
26913
|
+
var number = Number(text);
|
|
26914
|
+
return Number.isFinite(number) ? clampChannel(number) : null;
|
|
26915
|
+
}
|
|
26916
|
+
function parsePercent(value) {
|
|
26917
|
+
if (typeof value !== 'string' || value === '') return null;
|
|
26918
|
+
var text = value.trim();
|
|
26919
|
+
if (!text.endsWith('%')) return null;
|
|
26920
|
+
var number = parseFloat(text);
|
|
26921
|
+
return Number.isFinite(number) ? Math.min(100, Math.max(0, number)) : null;
|
|
26922
|
+
}
|
|
26923
|
+
function parseHue(value) {
|
|
26924
|
+
if (typeof value !== 'string' || value === '') return null;
|
|
26925
|
+
var number = parseFloat(value);
|
|
26926
|
+
return Number.isFinite(number) ? number : null;
|
|
26927
|
+
}
|
|
26928
|
+
|
|
26929
|
+
/** Standard HSL -> RGB. h in degrees, s/l in 0..100, returns r/g/b in 0..255. */
|
|
26930
|
+
function hslToRgb(h, s, l) {
|
|
26931
|
+
var hue = (h % 360 + 360) % 360 / 360;
|
|
26932
|
+
var saturation = s / 100;
|
|
26933
|
+
var lightness = l / 100;
|
|
26934
|
+
var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
26935
|
+
var section = hue * 6;
|
|
26936
|
+
var x = chroma * (1 - Math.abs(section % 2 - 1));
|
|
26937
|
+
var red = 0;
|
|
26938
|
+
var green = 0;
|
|
26939
|
+
var blue = 0;
|
|
26940
|
+
if (section < 1) {
|
|
26941
|
+
red = chroma;
|
|
26942
|
+
green = x;
|
|
26943
|
+
} else if (section < 2) {
|
|
26944
|
+
red = x;
|
|
26945
|
+
green = chroma;
|
|
26946
|
+
} else if (section < 3) {
|
|
26947
|
+
green = chroma;
|
|
26948
|
+
blue = x;
|
|
26949
|
+
} else if (section < 4) {
|
|
26950
|
+
green = x;
|
|
26951
|
+
blue = chroma;
|
|
26952
|
+
} else if (section < 5) {
|
|
26953
|
+
red = x;
|
|
26954
|
+
blue = chroma;
|
|
26955
|
+
} else {
|
|
26956
|
+
red = chroma;
|
|
26957
|
+
blue = x;
|
|
26958
|
+
}
|
|
26959
|
+
var match = lightness - chroma / 2;
|
|
26960
|
+
return [Math.round((red + match) * 255), Math.round((green + match) * 255), Math.round((blue + match) * 255)];
|
|
26883
26961
|
}
|
|
26884
26962
|
|
|
26885
26963
|
/**
|
|
26886
|
-
*
|
|
26887
|
-
*
|
|
26888
|
-
*
|
|
26889
|
-
* including percentages. Alpha in rgba() is ignored.
|
|
26964
|
+
* Parse any supported CSS color. When keepAlpha is true the alpha channel is
|
|
26965
|
+
* preserved (8-digit hex for alpha < 1); when false it is dropped. 'transparent'
|
|
26966
|
+
* is only preserved when keepAlpha is true.
|
|
26890
26967
|
*/
|
|
26891
|
-
function
|
|
26968
|
+
function parseColor(value, keepAlpha) {
|
|
26892
26969
|
if (typeof value !== 'string') return null;
|
|
26893
26970
|
var input = value.trim();
|
|
26894
26971
|
if (!input) return null;
|
|
26895
26972
|
var lower = input.toLowerCase();
|
|
26896
26973
|
if (NAMED_COLORS[lower]) return NAMED_COLORS[lower];
|
|
26897
|
-
|
|
26898
|
-
|
|
26899
|
-
|
|
26900
|
-
|
|
26901
|
-
|
|
26902
|
-
|
|
26974
|
+
// #rgb / #rgba / #rrggbb / #rrggbbaa,以及无 # 前缀的 6/8 位 hex(dicebear 习惯)
|
|
26975
|
+
var hexMatch = input.match(/^#?([0-9a-f]{3,8})$/i);
|
|
26976
|
+
if (hexMatch) {
|
|
26977
|
+
var _hex = hexMatch[1].toLowerCase();
|
|
26978
|
+
if (_hex.length === 3 || _hex.length === 4) {
|
|
26979
|
+
_hex = _hex.split('').map(function (c) {
|
|
26980
|
+
return c + c;
|
|
26981
|
+
}).join('');
|
|
26982
|
+
}
|
|
26983
|
+
return "#".concat(_hex.slice(0, 6));
|
|
26903
26984
|
}
|
|
26904
|
-
var
|
|
26905
|
-
if (
|
|
26906
|
-
|
|
26985
|
+
var funcMatch = input.match(/^(rgba?|hsla?)\(([^)]*)\)$/i);
|
|
26986
|
+
if (!funcMatch) return null;
|
|
26987
|
+
var kind = funcMatch[1].toLowerCase();
|
|
26988
|
+
var parsed = parseFunctionArgs(funcMatch[2]);
|
|
26989
|
+
if (!parsed) return null;
|
|
26990
|
+
var parts = parsed.parts;
|
|
26991
|
+
parsed.alpha;
|
|
26992
|
+
var red;
|
|
26993
|
+
var green;
|
|
26994
|
+
var blue;
|
|
26995
|
+
if (kind === 'rgb' || kind === 'rgba') {
|
|
26996
|
+
if (parts.length !== 3) return null;
|
|
26997
|
+
red = parseChannel(parts[0]);
|
|
26998
|
+
green = parseChannel(parts[1]);
|
|
26999
|
+
blue = parseChannel(parts[2]);
|
|
27000
|
+
if (red === null || green === null || blue === null) return null;
|
|
27001
|
+
} else {
|
|
27002
|
+
if (parts.length !== 3) return null;
|
|
27003
|
+
var hue = parseHue(parts[0]);
|
|
27004
|
+
var saturation = parsePercent(parts[1]);
|
|
27005
|
+
var lightness = parsePercent(parts[2]);
|
|
27006
|
+
if (hue === null || saturation === null || lightness === null) return null;
|
|
27007
|
+
var _hslToRgb = hslToRgb(hue, saturation, lightness);
|
|
27008
|
+
var _hslToRgb2 = _slicedToArray(_hslToRgb, 3);
|
|
27009
|
+
red = _hslToRgb2[0];
|
|
27010
|
+
green = _hslToRgb2[1];
|
|
27011
|
+
blue = _hslToRgb2[2];
|
|
27012
|
+
}
|
|
27013
|
+
var hex = "#".concat(hexPair(red)).concat(hexPair(green)).concat(hexPair(blue));
|
|
27014
|
+
return hex;
|
|
27015
|
+
}
|
|
27016
|
+
|
|
27017
|
+
/**
|
|
27018
|
+
* Convert any supported CSS color into `#rrggbb`. Returns null when the
|
|
27019
|
+
* value cannot be parsed. Supports: #rgb / #rgba / #rrggbb / #rrggbbaa
|
|
27020
|
+
* (case-insensitive), bare 6/8-digit hex, CSS named colors, rgb() / rgba() /
|
|
27021
|
+
* hsl() / hsla() with comma or modern space syntax, including percentages.
|
|
27022
|
+
* Alpha is ignored.
|
|
27023
|
+
*/
|
|
27024
|
+
function normalizeColor(value) {
|
|
27025
|
+
return parseColor(value);
|
|
26907
27026
|
}
|
|
26908
27027
|
function hexToRgb01(color) {
|
|
26909
27028
|
var hex = normalizeColor(color);
|
|
@@ -27162,10 +27281,10 @@ function createMiaoRenderer(_ref) {
|
|
|
27162
27281
|
};
|
|
27163
27282
|
}
|
|
27164
27283
|
|
|
27165
|
-
/**
|
|
27166
|
-
* Document-level shared rAF scheduler. Every component instance subscribes
|
|
27167
|
-
* its own frame callback; the whole page runs ONE animation loop (like the
|
|
27168
|
-
* original demo), which avoids jank from many competing rAF loops.
|
|
27284
|
+
/**
|
|
27285
|
+
* Document-level shared rAF scheduler. Every component instance subscribes
|
|
27286
|
+
* its own frame callback; the whole page runs ONE animation loop (like the
|
|
27287
|
+
* original demo), which avoids jank from many competing rAF loops.
|
|
27169
27288
|
*/
|
|
27170
27289
|
var subscribers = [];
|
|
27171
27290
|
var running = false;
|
|
@@ -27242,9 +27361,9 @@ function subscribeScheduler(onFrame, isPaused) {
|
|
|
27242
27361
|
};
|
|
27243
27362
|
}
|
|
27244
27363
|
|
|
27245
|
-
/**
|
|
27246
|
-
* Gates drawing on "element intersects viewport AND the page tab is visible".
|
|
27247
|
-
* Falls back to always-visible when IntersectionObserver is unavailable.
|
|
27364
|
+
/**
|
|
27365
|
+
* Gates drawing on "element intersects viewport AND the page tab is visible".
|
|
27366
|
+
* Falls back to always-visible when IntersectionObserver is unavailable.
|
|
27248
27367
|
*/
|
|
27249
27368
|
function createVisibilityGuard(element) {
|
|
27250
27369
|
var onChange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|