@5even7/dlc-ui 0.2.18 → 0.2.20
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 +158 -144
- package/EXTENDING.md +114 -0
- package/LICENSE +21 -21
- package/README.md +389 -338
- package/THIRD_PARTY_NOTICES.md +221 -0
- package/dist/avatar-creator/styles/humation.mjs +26 -0
- package/dist/avatar-creator/styles.mjs +76 -0
- package/dist/avatar-creator.cjs +7831 -0
- package/dist/avatar-creator.mjs +74 -0
- package/dist/capsule.cjs +185 -66
- package/dist/capsule.mjs +364 -1340
- package/dist/chunks/avatar-creator-DiAmhpRa.mjs +687 -0
- package/dist/chunks/color-DnmNceaf.mjs +350 -0
- package/dist/chunks/controls-B5_ctvvA.mjs +160 -0
- package/dist/chunks/copy-7J0XIj_0.mjs +13 -0
- package/dist/chunks/cosmic-fallback-v8G5_ibh.mjs +408 -0
- package/dist/chunks/emitter-CxLYMSbw.mjs +38 -0
- package/dist/chunks/emo-Dvahy5Qr.mjs +1140 -0
- package/dist/chunks/hash-BiO02UNb.mjs +38 -0
- package/dist/chunks/humation-B9OPUGL7.mjs +2987 -0
- package/dist/chunks/identicon-BUdMd-yf.mjs +3063 -0
- package/dist/chunks/index-BchW1tWE.mjs +478 -0
- package/dist/chunks/index-BtH8Lbra.mjs +296 -0
- package/dist/chunks/index-C02dvGLD.mjs +263 -0
- package/dist/chunks/index-CFybYBA1.mjs +278 -0
- package/dist/chunks/index-DgI872-7.mjs +241 -0
- package/dist/chunks/index-_sf_14Zu.mjs +455 -0
- package/dist/chunks/index-w5Pzdwhv.mjs +305 -0
- package/dist/chunks/motion-a8_f8_Ui.mjs +177 -0
- package/dist/chunks/number-BqWLX0iQ.mjs +231 -0
- package/dist/chunks/progress-KweS4Rx0.mjs +1836 -0
- package/dist/chunks/size-Bztk2ryJ.mjs +22 -0
- package/dist/chunks/wrapper-DXhy1E7Z.mjs +514 -0
- package/dist/color.cjs +186 -67
- package/dist/color.mjs +341 -1280
- package/dist/emo/miao/angry.mjs +4 -0
- package/dist/emo/miao/asleep.mjs +4 -0
- package/dist/emo/miao/badminton.mjs +4 -0
- package/dist/emo/miao/confident.mjs +4 -0
- package/dist/emo/miao/cry.mjs +4 -0
- package/dist/emo/miao/investigate.mjs +4 -0
- package/dist/emo/miao/laugh.mjs +4 -0
- package/dist/emo/miao/leisure.mjs +4 -0
- package/dist/emo/miao/mock.mjs +4 -0
- package/dist/emo/miao/music.mjs +4 -0
- package/dist/emo/miao/mute.mjs +4 -0
- package/dist/emo/miao/panic.mjs +4 -0
- package/dist/emo/miao/ponder.mjs +4 -0
- package/dist/emo/miao/question.mjs +4 -0
- package/dist/emo/miao/sad.mjs +4 -0
- package/dist/emo/miao/shocked.mjs +4 -0
- package/dist/emo/miao/shy.mjs +4 -0
- package/dist/emo/miao/sigh.mjs +4 -0
- package/dist/emo/miao/smile.mjs +4 -0
- package/dist/emo/miao/snigger.mjs +4 -0
- package/dist/emo/miao/static.mjs +4 -0
- package/dist/emo/miao/yawn.mjs +4 -0
- package/dist/emo/miao/yummy.mjs +4 -0
- package/dist/emo.cjs +27161 -25964
- package/dist/emo.mjs +8 -1421
- package/dist/index.cjs +32729 -24466
- package/dist/index.mjs +16 -4757
- package/dist/index.umd.js +33115 -24852
- package/dist/index.umd.min.js +3 -1
- package/dist/progress.cjs +195 -76
- package/dist/progress.mjs +7 -2448
- package/dist/vue2.cjs +33282 -25002
- package/dist/vue2.mjs +63 -5131
- package/dist/vue3.cjs +33282 -25002
- package/dist/vue3.mjs +53 -5122
- package/package.json +161 -136
- package/styles/avatar-creator.css +38 -0
- package/styles/base.css +32 -32
- package/styles/color.css +18 -18
- package/styles/emo.css +110 -89
- package/styles/progress.css +96 -96
- package/styles/theme.css +1 -0
- package/types/avatar-creator-styles.d.ts +10 -0
- package/types/avatar-creator.d.ts +143 -0
- package/types/capsule.d.ts +15 -15
- package/types/color.d.ts +15 -15
- package/types/emo-miao.d.ts +9 -0
- package/types/emo.d.ts +38 -37
- package/types/index.d.ts +593 -554
- package/types/progress.d.ts +16 -16
- package/types/vue2.d.ts +11 -10
- package/types/vue3.d.ts +169 -146
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const UNIT_PATTERN = /^[\d.]+(?:px|%|vw|vh|vmin|vmax|em|rem)$/;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Normalize a size option to a CSS length string.
|
|
5
|
+
* Accepts numbers (treated as px) or strings with px/%, vw/vh/vmin/vmax, em/rem.
|
|
6
|
+
*/
|
|
7
|
+
function parseSize(value) {
|
|
8
|
+
if (typeof value === 'number') {
|
|
9
|
+
if (!Number.isFinite(value) || value < 0) throw new Error(`Invalid size: ${value}`);
|
|
10
|
+
return `${value}px`;
|
|
11
|
+
}
|
|
12
|
+
if (typeof value !== 'string') throw new Error(`Invalid size: ${String(value)}`);
|
|
13
|
+
const trimmed = value.trim();
|
|
14
|
+
if (!trimmed) throw new Error('Invalid size: empty string');
|
|
15
|
+
if (/^\d+(?:\.\d+)?$/.test(trimmed)) return `${trimmed}px`;
|
|
16
|
+
if (!UNIT_PATTERN.test(trimmed)) {
|
|
17
|
+
throw new Error(`Invalid size or unsupported unit: "${value}" (use px, %, vw, vh, vmin, vmax, em, rem)`);
|
|
18
|
+
}
|
|
19
|
+
return trimmed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { parseSize as p };
|
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Options-API wrapper factory. The only framework difference is the
|
|
3
|
+
* render function: Vue2 passes `h` as an argument, Vue3 needs the imported
|
|
4
|
+
* `h` (see vue2.js / vue3.js). Lifecycle options cover both.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const CAPSULE_EVENTS = [
|
|
8
|
+
'ready', 'error', 'click', 'pointerdown', 'pointerup', 'dblclick',
|
|
9
|
+
'pointerenter', 'pointerleave', 'presetchange', 'contextlost', 'contextrestored'
|
|
10
|
+
];
|
|
11
|
+
const PROGRESS_EVENTS = [
|
|
12
|
+
'ready', 'error', 'change', 'input', 'update:modelValue',
|
|
13
|
+
'dragstart', 'dragend', 'presetchange', 'contextlost', 'contextrestored'
|
|
14
|
+
];
|
|
15
|
+
const COLOR_EVENTS = ['ready', 'error', 'presetchange', 'contextlost', 'contextrestored'];
|
|
16
|
+
const EMO_EVENTS = ['ready', 'error', 'complete', 'loopComplete', 'segmentStart', 'namechange', 'typechange'];
|
|
17
|
+
const AVATAR_EVENTS = ['ready', 'change', 'warning', 'error'];
|
|
18
|
+
|
|
19
|
+
function hookEvents(controller, events, emit) {
|
|
20
|
+
for (const event of events) {
|
|
21
|
+
if (event === 'input' || event === 'update:modelValue') continue;
|
|
22
|
+
controller.on(event, (payload) => {
|
|
23
|
+
emit(event, payload);
|
|
24
|
+
if (event === 'change' && payload && (payload.source === 'drag' || payload.source === 'keyboard')) {
|
|
25
|
+
if (events.indexOf('input') !== -1) emit('input', payload.value);
|
|
26
|
+
if (events.indexOf('update:modelValue') !== -1) emit('update:modelValue', payload.value);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function makeWrapper({ name, props, events, create, render, methods, watch }) {
|
|
33
|
+
const internalMethods = {
|
|
34
|
+
mountController(extraState = {}) {
|
|
35
|
+
this.controller = create(this.$el, { ...this.$props, ...extraState });
|
|
36
|
+
hookEvents(this.controller, events, (event, payload) => this.$emit(event, payload));
|
|
37
|
+
this.moveSlots();
|
|
38
|
+
this.applyAttrs();
|
|
39
|
+
},
|
|
40
|
+
recreate() {
|
|
41
|
+
const extraState = this.runtimeState();
|
|
42
|
+
if (this.controller) this.controller.dispose();
|
|
43
|
+
this.mountController(extraState);
|
|
44
|
+
// 结构属性连续变化时,插槽内容可能在重建后才被 Vue 写入容器,
|
|
45
|
+
// 补一次搬运确保不丢。
|
|
46
|
+
this.$nextTick(() => this.moveSlots());
|
|
47
|
+
},
|
|
48
|
+
scheduleRecreate() {
|
|
49
|
+
if (this._recreateQueued) return;
|
|
50
|
+
this._recreateQueued = true;
|
|
51
|
+
this.$nextTick(() => {
|
|
52
|
+
this._recreateQueued = false;
|
|
53
|
+
this.recreate();
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
moveSlots() {
|
|
57
|
+
if (!this.controller || !this.controller.element || !this.$el) return;
|
|
58
|
+
const root = this.controller.element;
|
|
59
|
+
const textLayer = root.querySelector('.hj-capsule-text, .hj-progress-text');
|
|
60
|
+
const visualLayer = root.querySelector('.hj-capsule-visual, .hj-progress-visual');
|
|
61
|
+
const move = (wrapper, layer) => {
|
|
62
|
+
if (!wrapper || !layer) return;
|
|
63
|
+
for (const node of Array.from(wrapper.childNodes)) layer.appendChild(node);
|
|
64
|
+
};
|
|
65
|
+
const refs = this.$refs || {};
|
|
66
|
+
move(refs.slotText, textLayer);
|
|
67
|
+
move(refs.slotColor, visualLayer);
|
|
68
|
+
},
|
|
69
|
+
applyAttrs() {
|
|
70
|
+
if (!this.controller || !this.controller.element || !this.$attrs) return;
|
|
71
|
+
const root = this.controller.element;
|
|
72
|
+
for (const key of Object.keys(this.$attrs)) {
|
|
73
|
+
if (key === 'class' || key === 'style') continue;
|
|
74
|
+
const value = this.$attrs[key];
|
|
75
|
+
if (value == null || value === false) root.removeAttribute(key);
|
|
76
|
+
else root.setAttribute(key, String(value));
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
runtimeState() {
|
|
80
|
+
const controller = this.controller;
|
|
81
|
+
if (!controller || !controller.dirty) return {};
|
|
82
|
+
const dirty = controller.dirty;
|
|
83
|
+
const state = {};
|
|
84
|
+
if (dirty.preset && controller.preset) state.preset = controller.preset.name;
|
|
85
|
+
if (dirty.seed && controller.preset && controller.preset.seed !== undefined) state.seed = controller.preset.seed;
|
|
86
|
+
if (dirty.speed && controller.preset && controller.preset.speed !== undefined) state.speed = controller.preset.speed;
|
|
87
|
+
if (dirty.colors && controller.preset && Array.isArray(controller.preset.colors)) {
|
|
88
|
+
state.colors = [...controller.preset.colors];
|
|
89
|
+
}
|
|
90
|
+
if (dirty.textRatio && controller.textRatio !== undefined) state.textRatio = controller.textRatio;
|
|
91
|
+
if (dirty.cssVars && controller.cssVars) state.cssVars = { ...controller.cssVars };
|
|
92
|
+
if (dirty.value && typeof controller.getValue === 'function') state.value = controller.getValue();
|
|
93
|
+
if (dirty.edgeStyle && controller.preset) state.edgeStyle = controller.preset.edgeStyle;
|
|
94
|
+
if (dirty.opacity) state.opacity = controller.opacity;
|
|
95
|
+
if (dirty.fallbackColor) state.fallbackColor = controller.fallbackColor;
|
|
96
|
+
if (dirty.mouseColor) state.mouseColor = controller.mouseColor;
|
|
97
|
+
if (dirty.quality) state.quality = controller.quality;
|
|
98
|
+
if (dirty.renderScale) state.renderScale = controller.renderScale;
|
|
99
|
+
if (dirty.paused) state.paused = controller.paused;
|
|
100
|
+
if (dirty.static) state.static = controller.static;
|
|
101
|
+
if (dirty.fps) state.fps = controller.fps;
|
|
102
|
+
if (dirty.step) state.step = controller.step;
|
|
103
|
+
if (dirty.precision) state.precision = controller.precision;
|
|
104
|
+
if (dirty.formatValue) state.formatValue = controller.formatValue;
|
|
105
|
+
if (dirty.direction) state.direction = controller.direction;
|
|
106
|
+
if (dirty.showValue) state.showValue = controller.showValue;
|
|
107
|
+
if (dirty.valueSuffix) state.valueSuffix = controller.valueSuffix;
|
|
108
|
+
return state;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
name,
|
|
114
|
+
props,
|
|
115
|
+
emits: events,
|
|
116
|
+
render,
|
|
117
|
+
inheritAttrs: false,
|
|
118
|
+
mounted() {
|
|
119
|
+
this.mountController();
|
|
120
|
+
},
|
|
121
|
+
beforeUnmount() {
|
|
122
|
+
if (this.controller) this.controller.dispose();
|
|
123
|
+
},
|
|
124
|
+
beforeDestroy() {
|
|
125
|
+
if (this.controller) this.controller.dispose();
|
|
126
|
+
},
|
|
127
|
+
updated() {
|
|
128
|
+
this.moveSlots();
|
|
129
|
+
this.applyAttrs();
|
|
130
|
+
},
|
|
131
|
+
watch: {
|
|
132
|
+
preset(value) { if (value && this.controller) this.controller.setPreset(value); },
|
|
133
|
+
colors(value) { if (value && this.controller) this.controller.setColors(value); },
|
|
134
|
+
width(value) { if (value !== undefined && this.controller) this.controller.setSize(value); },
|
|
135
|
+
height(value) { if (value !== undefined && this.controller) this.controller.setSize(undefined, value); },
|
|
136
|
+
quality(value) { if (value && this.controller) this.controller.setQuality(value); },
|
|
137
|
+
...(watch || {})
|
|
138
|
+
},
|
|
139
|
+
methods: { ...internalMethods, ...(methods || {}) }
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function makeCapsuleWrapper(createCapsule, render) {
|
|
144
|
+
return makeWrapper({
|
|
145
|
+
name: 'dlc-capsule',
|
|
146
|
+
props: [
|
|
147
|
+
'preset', 'width', 'height', 'colors', 'seed', 'speed',
|
|
148
|
+
'textRatio', 'label', 'mouseColor', 'renderer', 'quality', 'respectReducedMotion', 'cssVars',
|
|
149
|
+
'paused', 'static', 'fps', 'renderScale', 'powerPreference'
|
|
150
|
+
],
|
|
151
|
+
events: CAPSULE_EVENTS,
|
|
152
|
+
create: createCapsule,
|
|
153
|
+
render,
|
|
154
|
+
watch: {
|
|
155
|
+
seed(value) {
|
|
156
|
+
const seed = Number(value);
|
|
157
|
+
if (this.controller && Number.isFinite(seed)) {
|
|
158
|
+
this.controller.setSeed(seed);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
speed(value) {
|
|
162
|
+
const speed = Number(value);
|
|
163
|
+
if (this.controller && Number.isFinite(speed)) {
|
|
164
|
+
this.controller.setSpeed(speed);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
textRatio(value) {
|
|
168
|
+
if (value !== undefined && this.controller) this.controller.setTextRatio(Number(value));
|
|
169
|
+
},
|
|
170
|
+
cssVars(value) {
|
|
171
|
+
if (value && this.controller) this.controller.setCssVars(value);
|
|
172
|
+
},
|
|
173
|
+
label(value) {
|
|
174
|
+
if (this.controller) this.controller.setLabel(value);
|
|
175
|
+
},
|
|
176
|
+
mouseColor(value) {
|
|
177
|
+
if (this.controller) this.controller.setMouseColor(value);
|
|
178
|
+
},
|
|
179
|
+
paused(value) {
|
|
180
|
+
if (this.controller) this.controller.setPaused(value);
|
|
181
|
+
},
|
|
182
|
+
static(value) {
|
|
183
|
+
if (this.controller) this.controller.setStatic(value);
|
|
184
|
+
},
|
|
185
|
+
fps(value) {
|
|
186
|
+
if (value !== undefined && this.controller) this.controller.setFps(value);
|
|
187
|
+
},
|
|
188
|
+
renderScale(value) {
|
|
189
|
+
if (value !== undefined && this.controller) this.controller.setRenderScale(value);
|
|
190
|
+
},
|
|
191
|
+
renderer() {
|
|
192
|
+
this.scheduleRecreate();
|
|
193
|
+
},
|
|
194
|
+
powerPreference() {
|
|
195
|
+
this.scheduleRecreate();
|
|
196
|
+
},
|
|
197
|
+
respectReducedMotion() {
|
|
198
|
+
this.scheduleRecreate();
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
methods: {
|
|
202
|
+
randomize() { return this.controller && this.controller.randomize(); },
|
|
203
|
+
pause() { return this.controller && this.controller.pause(); },
|
|
204
|
+
resume() { return this.controller && this.controller.resume(); },
|
|
205
|
+
setPreset(preset) { return this.controller && this.controller.setPreset(preset); },
|
|
206
|
+
setSize(width, height) { return this.controller && this.controller.setSize(width, height); },
|
|
207
|
+
setColors(colors) { return this.controller && this.controller.setColors(colors); },
|
|
208
|
+
setText(content) { return this.controller && this.controller.setText(content); },
|
|
209
|
+
setColorContent(content) { return this.controller && this.controller.setColorContent(content); },
|
|
210
|
+
setTextRatio(ratio) { return this.controller && this.controller.setTextRatio(ratio); },
|
|
211
|
+
setCssVars(vars) { return this.controller && this.controller.setCssVars(vars); },
|
|
212
|
+
setLabel(label) { return this.controller && this.controller.setLabel(label); },
|
|
213
|
+
setSeed(seed) { return this.controller && this.controller.setSeed(seed); },
|
|
214
|
+
setSpeed(speed) { return this.controller && this.controller.setSpeed(speed); },
|
|
215
|
+
setMouseColor(value) { return this.controller && this.controller.setMouseColor(value); },
|
|
216
|
+
setQuality(quality) { return this.controller && this.controller.setQuality(quality); },
|
|
217
|
+
setRenderScale(value) { return this.controller && this.controller.setRenderScale(value); },
|
|
218
|
+
setPaused(value) { return this.controller && this.controller.setPaused(value); },
|
|
219
|
+
setStatic(value) { return this.controller && this.controller.setStatic(value); },
|
|
220
|
+
setFps(value) { return this.controller && this.controller.setFps(value); },
|
|
221
|
+
getController() { return this.controller; }
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function makeProgressWrapper(createProgressCapsule, render) {
|
|
227
|
+
return makeWrapper({
|
|
228
|
+
name: 'dlc-progress',
|
|
229
|
+
props: [
|
|
230
|
+
'preset', 'width', 'height', 'value', 'modelValue', 'min', 'max', 'step',
|
|
231
|
+
'draggable', 'disabled', 'readonly', 'edgeStyle', 'colors', 'textRatio', 'label', 'showValue', 'valueSuffix',
|
|
232
|
+
'keyboard', 'direction', 'precision', 'formatValue',
|
|
233
|
+
'quality', 'renderer', 'respectReducedMotion', 'cssVars',
|
|
234
|
+
'paused', 'static', 'fps', 'renderScale', 'powerPreference'
|
|
235
|
+
],
|
|
236
|
+
events: PROGRESS_EVENTS,
|
|
237
|
+
create: createProgressCapsule,
|
|
238
|
+
render,
|
|
239
|
+
watch: {
|
|
240
|
+
value(value) {
|
|
241
|
+
if (value !== undefined && this.modelValue === undefined && this.controller) this.controller.setValue(value);
|
|
242
|
+
},
|
|
243
|
+
modelValue(value) {
|
|
244
|
+
if (value !== undefined && this.controller) this.controller.setValue(value);
|
|
245
|
+
},
|
|
246
|
+
min(value) {
|
|
247
|
+
if (value !== undefined && this.controller) this.controller.setRange(value, this.controller.max);
|
|
248
|
+
},
|
|
249
|
+
max(value) {
|
|
250
|
+
if (value !== undefined && this.controller) this.controller.setRange(this.controller.min, value);
|
|
251
|
+
},
|
|
252
|
+
step(value) {
|
|
253
|
+
if (value !== undefined && this.controller) this.controller.setStep(value);
|
|
254
|
+
},
|
|
255
|
+
edgeStyle(value) {
|
|
256
|
+
if (value && this.controller) this.controller.setEdgeStyle(value);
|
|
257
|
+
},
|
|
258
|
+
textRatio(value) {
|
|
259
|
+
if (value !== undefined && this.controller) this.controller.setTextRatio(Number(value));
|
|
260
|
+
},
|
|
261
|
+
cssVars(value) {
|
|
262
|
+
if (value && this.controller) this.controller.setCssVars(value);
|
|
263
|
+
},
|
|
264
|
+
label(value) {
|
|
265
|
+
if (this.controller) this.controller.setLabel(value);
|
|
266
|
+
},
|
|
267
|
+
valueSuffix(value) {
|
|
268
|
+
if (value !== undefined && this.controller) this.controller.setValueSuffix(value);
|
|
269
|
+
},
|
|
270
|
+
showValue(value) {
|
|
271
|
+
if (this.controller) this.controller.setShowValue(value);
|
|
272
|
+
},
|
|
273
|
+
direction(value) {
|
|
274
|
+
if (value && this.controller) this.controller.setDirection(value);
|
|
275
|
+
},
|
|
276
|
+
precision(value) {
|
|
277
|
+
if (value !== undefined && this.controller) this.controller.setPrecision(value);
|
|
278
|
+
},
|
|
279
|
+
formatValue(value) {
|
|
280
|
+
if (this.controller) this.controller.setFormatValue(value);
|
|
281
|
+
},
|
|
282
|
+
paused(value) {
|
|
283
|
+
if (this.controller) this.controller.setPaused(value);
|
|
284
|
+
},
|
|
285
|
+
static(value) {
|
|
286
|
+
if (this.controller) this.controller.setStatic(value);
|
|
287
|
+
},
|
|
288
|
+
fps(value) {
|
|
289
|
+
if (value !== undefined && this.controller) this.controller.setFps(value);
|
|
290
|
+
},
|
|
291
|
+
renderScale(value) {
|
|
292
|
+
if (value !== undefined && this.controller) this.controller.setRenderScale(value);
|
|
293
|
+
},
|
|
294
|
+
disabled() {
|
|
295
|
+
this.scheduleRecreate();
|
|
296
|
+
},
|
|
297
|
+
readonly() {
|
|
298
|
+
this.scheduleRecreate();
|
|
299
|
+
},
|
|
300
|
+
draggable() {
|
|
301
|
+
this.scheduleRecreate();
|
|
302
|
+
},
|
|
303
|
+
renderer() {
|
|
304
|
+
this.scheduleRecreate();
|
|
305
|
+
},
|
|
306
|
+
keyboard() {
|
|
307
|
+
this.scheduleRecreate();
|
|
308
|
+
},
|
|
309
|
+
powerPreference() {
|
|
310
|
+
this.scheduleRecreate();
|
|
311
|
+
},
|
|
312
|
+
respectReducedMotion() {
|
|
313
|
+
this.scheduleRecreate();
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
methods: {
|
|
317
|
+
setValue(value) { return this.controller && this.controller.setValue(value); },
|
|
318
|
+
getValue() { return this.controller ? this.controller.getValue() : undefined; },
|
|
319
|
+
setRange(min, max) { return this.controller && this.controller.setRange(min, max); },
|
|
320
|
+
setStep(step) { return this.controller && this.controller.setStep(step); },
|
|
321
|
+
randomize() { return this.controller && this.controller.randomize(); },
|
|
322
|
+
pause() { return this.controller && this.controller.pause(); },
|
|
323
|
+
resume() { return this.controller && this.controller.resume(); },
|
|
324
|
+
setPreset(preset) { return this.controller && this.controller.setPreset(preset); },
|
|
325
|
+
setSize(width, height) { return this.controller && this.controller.setSize(width, height); },
|
|
326
|
+
setColors(colors) { return this.controller && this.controller.setColors(colors); },
|
|
327
|
+
setText(content) { return this.controller && this.controller.setText(content); },
|
|
328
|
+
setColorContent(content) { return this.controller && this.controller.setColorContent(content); },
|
|
329
|
+
setTextRatio(ratio) { return this.controller && this.controller.setTextRatio(ratio); },
|
|
330
|
+
setCssVars(vars) { return this.controller && this.controller.setCssVars(vars); },
|
|
331
|
+
setLabel(label) { return this.controller && this.controller.setLabel(label); },
|
|
332
|
+
setValueSuffix(suffix) { return this.controller && this.controller.setValueSuffix(suffix); },
|
|
333
|
+
setShowValue(show) { return this.controller && this.controller.setShowValue(show); },
|
|
334
|
+
setDirection(direction) { return this.controller && this.controller.setDirection(direction); },
|
|
335
|
+
setEdgeStyle(edgeStyle) { return this.controller && this.controller.setEdgeStyle(edgeStyle); },
|
|
336
|
+
setPrecision(precision) { return this.controller && this.controller.setPrecision(precision); },
|
|
337
|
+
setFormatValue(formatter) { return this.controller && this.controller.setFormatValue(formatter); },
|
|
338
|
+
setQuality(quality) { return this.controller && this.controller.setQuality(quality); },
|
|
339
|
+
setRenderScale(value) { return this.controller && this.controller.setRenderScale(value); },
|
|
340
|
+
setPaused(value) { return this.controller && this.controller.setPaused(value); },
|
|
341
|
+
setStatic(value) { return this.controller && this.controller.setStatic(value); },
|
|
342
|
+
setFps(value) { return this.controller && this.controller.setFps(value); },
|
|
343
|
+
getController() { return this.controller; }
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function makeColorWrapper(createColorBackground, render) {
|
|
349
|
+
return makeWrapper({
|
|
350
|
+
name: 'dlc-color',
|
|
351
|
+
props: [
|
|
352
|
+
'preset', 'colors', 'seed', 'speed', 'quality', 'renderer',
|
|
353
|
+
'mouseColor', 'respectReducedMotion', 'opacity', 'fallbackColor',
|
|
354
|
+
'paused', 'static', 'fps', 'renderScale', 'powerPreference'
|
|
355
|
+
],
|
|
356
|
+
events: COLOR_EVENTS,
|
|
357
|
+
create: createColorBackground,
|
|
358
|
+
render,
|
|
359
|
+
watch: {
|
|
360
|
+
seed(value) {
|
|
361
|
+
const seed = Number(value);
|
|
362
|
+
if (this.controller && Number.isFinite(seed)) this.controller.setSeed(seed);
|
|
363
|
+
},
|
|
364
|
+
speed(value) {
|
|
365
|
+
const speed = Number(value);
|
|
366
|
+
if (this.controller && Number.isFinite(speed)) this.controller.setSpeed(speed);
|
|
367
|
+
},
|
|
368
|
+
opacity(value) {
|
|
369
|
+
if (value !== undefined && this.controller) this.controller.setOpacity(Number(value));
|
|
370
|
+
},
|
|
371
|
+
fallbackColor(value) {
|
|
372
|
+
if (this.controller) this.controller.setFallbackColor(value);
|
|
373
|
+
},
|
|
374
|
+
mouseColor(value) {
|
|
375
|
+
if (this.controller) this.controller.setMouseColor(value);
|
|
376
|
+
},
|
|
377
|
+
paused(value) {
|
|
378
|
+
if (this.controller) this.controller.setPaused(value);
|
|
379
|
+
},
|
|
380
|
+
static(value) {
|
|
381
|
+
if (this.controller) this.controller.setStatic(value);
|
|
382
|
+
},
|
|
383
|
+
fps(value) {
|
|
384
|
+
if (value !== undefined && this.controller) this.controller.setFps(value);
|
|
385
|
+
},
|
|
386
|
+
renderScale(value) {
|
|
387
|
+
if (value !== undefined && this.controller) this.controller.setRenderScale(value);
|
|
388
|
+
},
|
|
389
|
+
renderer() {
|
|
390
|
+
this.scheduleRecreate();
|
|
391
|
+
},
|
|
392
|
+
respectReducedMotion() {
|
|
393
|
+
this.scheduleRecreate();
|
|
394
|
+
},
|
|
395
|
+
powerPreference() {
|
|
396
|
+
this.scheduleRecreate();
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
methods: {
|
|
400
|
+
setPreset(preset) { return this.controller && this.controller.setPreset(preset); },
|
|
401
|
+
setColors(colors) { return this.controller && this.controller.setColors(colors); },
|
|
402
|
+
setSeed(seed) { return this.controller && this.controller.setSeed(seed); },
|
|
403
|
+
setSpeed(speed) { return this.controller && this.controller.setSpeed(speed); },
|
|
404
|
+
setQuality(quality) { return this.controller && this.controller.setQuality(quality); },
|
|
405
|
+
setRenderScale(value) { return this.controller && this.controller.setRenderScale(value); },
|
|
406
|
+
setOpacity(value) { return this.controller && this.controller.setOpacity(value); },
|
|
407
|
+
setFallbackColor(value) { return this.controller && this.controller.setFallbackColor(value); },
|
|
408
|
+
setMouseColor(value) { return this.controller && this.controller.setMouseColor(value); },
|
|
409
|
+
randomize() { return this.controller && this.controller.randomize(); },
|
|
410
|
+
pause() { return this.controller && this.controller.pause(); },
|
|
411
|
+
resume() { return this.controller && this.controller.resume(); },
|
|
412
|
+
setPaused(value) { return this.controller && this.controller.setPaused(value); },
|
|
413
|
+
setStatic(value) { return this.controller && this.controller.setStatic(value); },
|
|
414
|
+
setFps(value) { return this.controller && this.controller.setFps(value); },
|
|
415
|
+
getController() { return this.controller; }
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function makeEmoWrapper(createEmo, render) {
|
|
421
|
+
return makeWrapper({
|
|
422
|
+
name: 'dlc-emo',
|
|
423
|
+
props: [
|
|
424
|
+
'type', 'name', 'width', 'height', 'partColors',
|
|
425
|
+
'speed', 'loop', 'autoplay', 'direction', 'opacity', 'fit',
|
|
426
|
+
'renderer', 'paused', 'segment', 'background', 'label', 'instanceName', 'respectReducedMotion',
|
|
427
|
+
'shape', 'interactive'
|
|
428
|
+
],
|
|
429
|
+
events: EMO_EVENTS,
|
|
430
|
+
create: createEmo,
|
|
431
|
+
render,
|
|
432
|
+
watch: {
|
|
433
|
+
type(value) { if (value && this.controller) this.controller.setType(value); },
|
|
434
|
+
name(value) { if (value && this.controller) this.controller.setName(value); },
|
|
435
|
+
partColors(value) { if (this.controller) this.controller.setPartColors(value); },
|
|
436
|
+
speed(value) { if (value !== undefined && this.controller) this.controller.setSpeed(value); },
|
|
437
|
+
loop(value) { if (this.controller) this.controller.setLoop(value); },
|
|
438
|
+
autoplay(value) { if (this.controller) this.controller.setAutoplay(value); },
|
|
439
|
+
direction(value) { if (value !== undefined && this.controller) this.controller.setDirection(value); },
|
|
440
|
+
opacity(value) { if (value !== undefined && this.controller) this.controller.setOpacity(value); },
|
|
441
|
+
fit(value) { if (value && this.controller) this.controller.setFit(value); },
|
|
442
|
+
renderer(value) { if (value && this.controller) this.controller.setRenderer(value); },
|
|
443
|
+
paused(value) { if (this.controller) this.controller.setPaused(value); },
|
|
444
|
+
segment(value) { if (this.controller) this.controller.setSegment(value); },
|
|
445
|
+
background(value) { if (this.controller) this.controller.setBackground(value); },
|
|
446
|
+
label(value) { if (this.controller) this.controller.setLabel(value); },
|
|
447
|
+
shape(value) { if (value && this.controller) this.controller.setShape(value); },
|
|
448
|
+
interactive(value) { if (this.controller) this.controller.setInteractive(value); },
|
|
449
|
+
instanceName() { this.scheduleRecreate(); },
|
|
450
|
+
respectReducedMotion() { this.scheduleRecreate(); }
|
|
451
|
+
},
|
|
452
|
+
methods: {
|
|
453
|
+
play() { return this.controller && this.controller.play(); },
|
|
454
|
+
pause() { return this.controller && this.controller.pause(); },
|
|
455
|
+
stop() { return this.controller && this.controller.stop(); },
|
|
456
|
+
setPaused(value) { return this.controller && this.controller.setPaused(value); },
|
|
457
|
+
setSpeed(value) { return this.controller && this.controller.setSpeed(value); },
|
|
458
|
+
setDirection(value) { return this.controller && this.controller.setDirection(value); },
|
|
459
|
+
setSegment(value) { return this.controller && this.controller.setSegment(value); },
|
|
460
|
+
setName(value) { return this.controller && this.controller.setName(value); },
|
|
461
|
+
setType(value) { return this.controller && this.controller.setType(value); },
|
|
462
|
+
setPartColors(value) { return this.controller && this.controller.setPartColors(value); },
|
|
463
|
+
setOpacity(value) { return this.controller && this.controller.setOpacity(value); },
|
|
464
|
+
setBackground(value) { return this.controller && this.controller.setBackground(value); },
|
|
465
|
+
setSize(width, height) { return this.controller && this.controller.setSize(width, height); },
|
|
466
|
+
setFit(value) { return this.controller && this.controller.setFit(value); },
|
|
467
|
+
setRenderer(value) { return this.controller && this.controller.setRenderer(value); },
|
|
468
|
+
setLoop(value) { return this.controller && this.controller.setLoop(value); },
|
|
469
|
+
setAutoplay(value) { return this.controller && this.controller.setAutoplay(value); },
|
|
470
|
+
setShape(value) { return this.controller && this.controller.setShape(value); },
|
|
471
|
+
setInteractive(value) { return this.controller && this.controller.setInteractive(value); },
|
|
472
|
+
setLabel(value) { return this.controller && this.controller.setLabel(value); },
|
|
473
|
+
getController() { return this.controller; }
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function makeAvatarWrapper(createAvatarCreator, render) {
|
|
479
|
+
return makeWrapper({
|
|
480
|
+
name: 'dlc-avatar-creator',
|
|
481
|
+
props: ['provider', 'avatarStyle', 'seed', 'size', 'background', 'providerOptions', 'strict'],
|
|
482
|
+
events: AVATAR_EVENTS,
|
|
483
|
+
create: (el, opts) => createAvatarCreator(el, {
|
|
484
|
+
...opts,
|
|
485
|
+
style: opts.avatarStyle
|
|
486
|
+
}),
|
|
487
|
+
render,
|
|
488
|
+
watch: {
|
|
489
|
+
provider(value) { if (value && this.controller) this.controller.setProvider(value); },
|
|
490
|
+
avatarStyle(value) { if (value && this.controller) this.controller.setStyle(value); },
|
|
491
|
+
seed(value) { if (value !== undefined && this.controller) this.controller.setSeed(value); },
|
|
492
|
+
size(value) { if (value !== undefined && this.controller) this.controller.setSize(value); },
|
|
493
|
+
background(value) { if (this.controller) this.controller.setBackground(value); },
|
|
494
|
+
providerOptions(value) { if (value && this.controller) this.controller.setProviderOptions(value); }
|
|
495
|
+
},
|
|
496
|
+
methods: {
|
|
497
|
+
// avatar 无运行时状态(dirty/preset 等字段不存在),recreate 不适用;
|
|
498
|
+
// 覆盖共享 runtimeState,避免继承引用不存在字段的实现。
|
|
499
|
+
runtimeState() { return {}; },
|
|
500
|
+
setProvider(provider) { return this.controller && this.controller.setProvider(provider); },
|
|
501
|
+
setStyle(style) { return this.controller && this.controller.setStyle(style); },
|
|
502
|
+
setSeed(seed) { return this.controller && this.controller.setSeed(seed); },
|
|
503
|
+
setSize(size) { return this.controller && this.controller.setSize(size); },
|
|
504
|
+
setBackground(background) { return this.controller && this.controller.setBackground(background); },
|
|
505
|
+
setProviderOptions(options) { return this.controller && this.controller.setProviderOptions(options); },
|
|
506
|
+
getSvg() { return this.controller ? this.controller.getSvg() : ''; },
|
|
507
|
+
toDataUri() { return this.controller ? this.controller.toDataUri() : ''; },
|
|
508
|
+
randomize() { return this.controller && this.controller.randomize(); },
|
|
509
|
+
getController() { return this.controller; }
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
export { makeProgressWrapper as a, makeColorWrapper as b, makeEmoWrapper as c, makeAvatarWrapper as d, makeCapsuleWrapper as m };
|