@5even7/dlc-ui 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
- # Changelog
2
-
3
- ## 0.1.0 - 2026-08-07
1
+ # Changelog
2
+
3
+ ## 0.2.0 - 2026-08-08
4
+
5
+ - `preset` 简化为只接受文学名称字符串:胶囊 `初光 / 沧溟 / 玄夜 / 紫霄 / 银汉 / 熔金`,进度 `星火 / 迁流 / 幻境 / 汐潮`;不再支持编号、id、名称三选一或自定义预置对象。
6
+ - `colors` / `seed` / `speed` 改为独立属性,传入即覆盖预置内置值,不传用预置默认;新增胶囊控制器 `setSeed()` / `setSpeed()`。
7
+ - 移除 `interactive` 属性(指针扭曲效果统一由 `mouseColor` 控制,组件事件始终派发)。
8
+ - 新增进度控制器 `setEdgeStyle('flow' | 'tide')` 热切换边界风格。
9
+
10
+ ## 0.1.0 - 2026-08-07
4
11
 
5
12
  - 从 画境观屿 演示项目抽出框架无关组件核心:`createCapsule` / `createProgressCapsule`。
6
13
  - 包名正式改为 `@5even7/dlc-ui`,入口:根入口、`/capsule`、`/progress`、`/color`、`/vue3`、`/vue2`,样式入口 `style.css` / 各组件 `style.css`。
package/README.md CHANGED
@@ -12,15 +12,16 @@ npm install @5even7/dlc-ui
12
12
 
13
13
  ## 预置列表
14
14
 
15
- | 类型 | 预置 | 说明 |
16
- | --- | --- | --- |
17
- | capsule | `NC-01` ORIGINAL / `NC-02` OCEAN / `NC-03` KLEIN / `NC-04` ULTRAVIOLET / `NC-05` CHROME / `NC-06` PLUS | 星云材质 |
18
- | progress | `NC-10` MODEL TRAINING / `NC-11` AGENT MIGRATION / `NC-12` VISUAL TRAINING | 流体进度 |
19
- | progress | `NC-13` TIDE | 潮汐边界(潮起潮落) |
20
-
21
- `dlc-color` 复用同一套星云渲染器,只做背景层,没有自己的预置表,直接使用上表 capsule 的 6 个预置。
22
-
23
- `preset` 可以传 id(`'ocean'`)、编号(`'NC-02'`)、名称(`'OCEAN'`)或自定义预置对象(含 `colors` 等字段)。
15
+ | 类型 | 预置 | 说明 |
16
+ | --- | --- | --- |
17
+ | capsule | `初光`(NC-01)/ `沧溟`(NC-02)/ `玄夜`(NC-03)/ `紫霄`(NC-04)/ `银汉`(NC-05)/ `熔金`(NC-06 | 星云材质 |
18
+ | progress | `星火`(NC-10)/ `迁流`(NC-11)/ `幻境`(NC-12 | 流体进度 |
19
+ | progress | `汐潮`(NC-13 | 潮汐边界(潮起潮落) |
20
+
21
+ `dlc-color` 复用同一套星云渲染器,只做背景层,没有自己的预置表,直接使用上表 capsule 的 6 个预置。
22
+
23
+ `preset` 只接受上表中的文学名称(如 `'沧溟'`),大小写不敏感、首尾空格忽略;不传时使用默认预置 `初光`(胶囊/背景层)或 `星火`(进度条)。
24
+ `colors`、`seed`、`speed` 是独立属性,传了会覆盖预置内置值;不传则用预置默认值。
24
25
 
25
26
  ## H5 使用
26
27
 
@@ -30,14 +31,14 @@ npm install @5even7/dlc-ui
30
31
  import { createCapsule, createProgressCapsule } from '@5even7/dlc-ui';
31
32
  import '@5even7/dlc-ui/style.css';
32
33
 
33
- const capsule = createCapsule(document.querySelector('#host-a'), {
34
- preset: 'ocean',
34
+ const capsule = createCapsule(document.querySelector('#host-a'), {
35
+ preset: '沧溟',
35
36
  width: '100%',
36
37
  height: 160
37
38
  });
38
39
 
39
- const progress = createProgressCapsule(document.querySelector('#host-b'), {
40
- preset: 'tide',
40
+ const progress = createProgressCapsule(document.querySelector('#host-b'), {
41
+ preset: '汐潮',
41
42
  width: 454,
42
43
  height: 104
43
44
  });
@@ -53,13 +54,13 @@ progress.on('change', ({ value, source }) => console.log(value, source));
53
54
  import { createColorBackground } from '@5even7/dlc-ui/color';
54
55
  import '@5even7/dlc-ui/color/style.css';
55
56
 
56
- const background = createColorBackground(document.querySelector('#bg-host'), {
57
- preset: 'ocean',
57
+ const background = createColorBackground(document.querySelector('#bg-host'), {
58
+ preset: '沧溟',
58
59
  quality: 'auto'
59
60
  });
60
61
 
61
62
  // 需要时再切换/暂停
62
- background.setPreset('klein');
63
+ background.setPreset('玄夜');
63
64
  background.pause();
64
65
  ```
65
66
 
@@ -107,8 +108,8 @@ function onProgressChange({ value }) {
107
108
  </script>
108
109
 
109
110
  <template>
110
- <CosmicCapsule preset="ocean" width="100%" height="160" @click="...">
111
- <ProgressCapsule preset="tide" :width="454" :height="104" @change="onProgressChange" />
111
+ <CosmicCapsule preset="沧溟" width="100%" height="160" @click="...">
112
+ <ProgressCapsule preset="汐潮" :width="454" :height="104" @change="onProgressChange" />
112
113
  </template>
113
114
  ```
114
115
 
@@ -120,7 +121,7 @@ import '@5even7/dlc-ui/style.css';
120
121
 
121
122
  export default {
122
123
  components: { CosmicCapsule, ProgressCapsule },
123
- template: '<ProgressCapsule preset="tide" :width="454" :height="104" @change="onChange" />'
124
+ template: '<ProgressCapsule preset="汐潮" :width="454" :height="104" @change="onChange" />'
124
125
  };
125
126
  ```
126
127
 
@@ -128,11 +129,13 @@ export default {
128
129
 
129
130
  两个组件共有的属性:`preset`、`width`、`height`(数字=px,或 `px/%/vw/vh/vmin/vmax/em/rem` 字符串)、`colors`、`quality`(`auto/low/medium/high`)、`renderer`(`auto/webgl2/canvas2d`,`canvas2d` 可强制走降级路径,便于对比观感或省电)、`respectReducedMotion`、`copy`、`cssVars`。
130
131
 
131
- 星云胶囊专属:`seed`、`speed`、`interactive`(指针交互,默认 `true`)、`mouseColor`(颜色随鼠标旋涡,默认 `true`;关闭后不影响 click/悬浮/长按等事件)。
132
+ 星云胶囊专属:`seed`、`speed`、`mouseColor`(颜色随鼠标旋涡,默认 `true`;关闭后不影响 click/悬浮/长按等事件)。`seed`/`speed` 不传时用预置内置值,传入即覆盖。
132
133
 
133
134
  进度胶囊专属:`value`、`min`、`max`、`draggable`、`keyboard`、`edgeStyle`(`flow/tide`)。
134
135
 
135
- dlc-color 背景层专属(`createColorBackground(host, options)`):`preset`、`colors`、`seed`、`speed`、`quality`、`renderer`、`mouseColor`、`respectReducedMotion`、`opacity`(0~1)、`fallbackColor`(预置底色/十六进制色/false)。它返回的控制器支持 `setPreset / setColors / setQuality / setOpacity / randomize / pause / resume / dispose` 和 `ready / presetchange / error` 事件。
136
+ dlc-color 背景层专属(`createColorBackground(host, options)`):`preset`、`colors`、`seed`、`speed`、`quality`、`renderer`、`mouseColor`、`respectReducedMotion`、`opacity`(0~1)、`fallbackColor`(预置底色/十六进制色/false)。它返回的控制器支持 `setPreset / setColors / setQuality / setOpacity / randomize / pause / resume / dispose` 和 `ready / presetchange / error` 事件。
137
+
138
+ 胶囊控制器额外支持 `setSeed(seed)` / `setSpeed(speed)` 热更新;进度控制器额外支持 `setEdgeStyle('flow' | 'tide')` 热切换边界风格。`setPreset` 只接受文学名称字符串(如 `'汐潮'`)。
136
139
 
137
140
  > 进度条是完全受控组件:组件自身不再自动增长,`value` 由使用方驱动。要自动步进,自己写定时器加值即可:
138
141
  >
@@ -174,7 +177,7 @@ dlc-color 背景层专属(`createColorBackground(host, options)`):`preset`
174
177
  也可以在创建时传 `cssVars`:
175
178
 
176
179
  ```js
177
- createProgressCapsule(el, { preset: 'tide', cssVars: { '--hj-radius': '12px' } });
180
+ createProgressCapsule(el, { preset: '汐潮', cssVars: { '--hj-radius': '12px' } });
178
181
  ```
179
182
 
180
183
  主要变量:`--hj-radius`、`--hj-bg`、`--hj-ink`、`--hj-muted`、`--hj-font`、`--hj-mono`、`--hj-copy-width`、`--hj-copy-min-width`、`--hj-copy-pad-x`、`--hj-copy-gradient`、`--hj-shadow`、`--hj-name-size`、`--hj-copy-left`、`--hj-value-right`、`--hj-copy-max-width`。
package/dist/capsule.cjs CHANGED
@@ -317,7 +317,7 @@ var PALETTES = {
317
317
  var CAPSULE_PRESETS = [{
318
318
  id: 'original',
319
319
  code: 'NC-01',
320
- name: 'ORIGINAL',
320
+ name: '初光',
321
321
  group: 'warm',
322
322
  seed: 1.7,
323
323
  speed: 0.5,
@@ -325,7 +325,7 @@ var CAPSULE_PRESETS = [{
325
325
  }, {
326
326
  id: 'ocean',
327
327
  code: 'NC-02',
328
- name: 'OCEAN',
328
+ name: '沧溟',
329
329
  group: 'cold',
330
330
  seed: 8.2,
331
331
  speed: 0.48,
@@ -333,7 +333,7 @@ var CAPSULE_PRESETS = [{
333
333
  }, {
334
334
  id: 'klein',
335
335
  code: 'NC-03',
336
- name: 'KLEIN',
336
+ name: '玄夜',
337
337
  group: 'cold',
338
338
  seed: 14.1,
339
339
  speed: 0.49,
@@ -341,7 +341,7 @@ var CAPSULE_PRESETS = [{
341
341
  }, {
342
342
  id: 'ultraviolet',
343
343
  code: 'NC-04',
344
- name: 'ULTRAVIOLET',
344
+ name: '紫霄',
345
345
  group: 'cold',
346
346
  seed: 23.4,
347
347
  speed: 0.47,
@@ -349,7 +349,7 @@ var CAPSULE_PRESETS = [{
349
349
  }, {
350
350
  id: 'chrome',
351
351
  code: 'NC-05',
352
- name: 'CHROME',
352
+ name: '银汉',
353
353
  group: 'cold',
354
354
  seed: 37.8,
355
355
  speed: 0.42,
@@ -357,7 +357,7 @@ var CAPSULE_PRESETS = [{
357
357
  }, {
358
358
  id: 'plus',
359
359
  code: 'NC-06',
360
- name: 'PLUS',
360
+ name: '熔金',
361
361
  group: 'warm',
362
362
  seed: 51.3,
363
363
  speed: 0.5,
@@ -367,7 +367,7 @@ var CAPSULE_PRESETS = [{
367
367
  var PROGRESS_PRESETS = [{
368
368
  id: 'model-training',
369
369
  code: 'NC-10',
370
- name: 'MODEL TRAINING',
370
+ name: '星火',
371
371
  subtitle: 'SHA 4.5 + 100 2026 TKN',
372
372
  group: 'progress',
373
373
  initialProgress: 43,
@@ -376,7 +376,7 @@ var PROGRESS_PRESETS = [{
376
376
  }, {
377
377
  id: 'agent-migration',
378
378
  code: 'NC-11',
379
- name: 'AGENT MIGRATION',
379
+ name: '迁流',
380
380
  subtitle: 'TRANSFERRING PROTOCOL',
381
381
  group: 'progress',
382
382
  initialProgress: 33,
@@ -385,7 +385,7 @@ var PROGRESS_PRESETS = [{
385
385
  }, {
386
386
  id: 'visual-training',
387
387
  code: 'NC-12',
388
- name: 'VISUAL TRAINING',
388
+ name: '幻境',
389
389
  subtitle: 'GENERATING POWER ++',
390
390
  group: 'progress',
391
391
  initialProgress: 58,
@@ -394,7 +394,7 @@ var PROGRESS_PRESETS = [{
394
394
  }, {
395
395
  id: 'tide',
396
396
  code: 'NC-13',
397
- name: 'TIDE',
397
+ name: '汐潮',
398
398
  subtitle: 'MOON PULL / COAST',
399
399
  group: 'progress',
400
400
  initialProgress: 30,
@@ -403,20 +403,18 @@ var PROGRESS_PRESETS = [{
403
403
  }];
404
404
 
405
405
  [].concat(_toConsumableArray(CAPSULE_PRESETS), _toConsumableArray(PROGRESS_PRESETS));
406
- function validatePreset(preset) {
407
- return Boolean(preset && typeof preset.id === 'string' && typeof preset.code === 'string' && typeof preset.name === 'string' && Number.isFinite(preset.seed) && Number.isFinite(preset.speed) && Array.isArray(preset.colors) && preset.colors.length === 4);
408
- }
406
+
407
+ /**
408
+ * Resolve a preset by its literary name (e.g. '沧溟').
409
+ * Matching is case-insensitive and ignores surrounding whitespace,
410
+ * so '沧溟' and ' 沧溟 ' both work.
411
+ */
409
412
  function getPreset(kind, ref) {
410
413
  var list = CAPSULE_PRESETS ;
411
414
  if (!list) throw new Error("Unknown preset kind: ".concat(kind, " (use \"capsule\" or \"progress\")"));
412
- if (ref && _typeof(ref) === 'object') {
413
- var valid = validatePreset(ref) ;
414
- if (!valid) throw new Error("Invalid ".concat(kind, " preset object"));
415
- return ref;
416
- }
417
415
  var key = String(ref).trim().toLowerCase();
418
416
  var found = list.find(function (preset) {
419
- return preset.id.toLowerCase() === key || preset.code.toLowerCase() === key || preset.name.toLowerCase() === key;
417
+ return preset.name.toLowerCase() === key;
420
418
  });
421
419
  if (!found) throw new Error("Unknown ".concat(kind, " preset: ").concat(ref));
422
420
  return found;
@@ -429,7 +427,6 @@ var DEFAULTS = {
429
427
  quality: 'auto',
430
428
  renderer: 'auto',
431
429
  respectReducedMotion: true,
432
- interactive: true,
433
430
  mouseColor: true,
434
431
  showCopy: true
435
432
  }};
@@ -836,8 +833,8 @@ function prefersReducedMotion() {
836
833
  * Mount a cosmic (nebula) capsule into `container`.
837
834
  *
838
835
  * Options: preset (id/code/name or object), width, height (number=px or
839
- * string with px/%/vw/vh/em/rem), colors, seed, speed, quality, interactive,
840
- * respectReducedMotion, copy, cssVars.
836
+ * string with px/%/vw/vh/em/rem), colors, seed, speed, quality,
837
+ * respectReducedMotion, copy, cssVars.
841
838
  */
842
839
  function createCapsule(container) {
843
840
  var _options$preset;
@@ -845,7 +842,7 @@ function createCapsule(container) {
845
842
  if (!container || typeof container.appendChild !== 'function') {
846
843
  throw new Error('createCapsule: container element is required');
847
844
  }
848
- var preset = _objectSpread2({}, getPreset('capsule', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : 'NC-01'));
845
+ var preset = _objectSpread2({}, getPreset('capsule', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : '初光'));
849
846
  var merged = normalizeOptions(DEFAULTS.capsule, preset, options);
850
847
  var copy = _objectSpread2(_objectSpread2({}, COPY), merged.copy || {});
851
848
  var root = document.createElement('div');
@@ -924,18 +921,16 @@ function createCapsule(container) {
924
921
  }) : null;
925
922
  if (resizeObserver) resizeObserver.observe(root);else window.addEventListener('resize', renderer.resize);
926
923
  var visibility = createVisibilityGuard(root);
927
- if (merged.interactive !== false) {
928
- root.addEventListener('pointerenter', function () {
929
- return emitter.emit('pointerenter', {
930
- preset: _objectSpread2({}, preset)
931
- });
924
+ root.addEventListener('pointerenter', function () {
925
+ return emitter.emit('pointerenter', {
926
+ preset: _objectSpread2({}, preset)
932
927
  });
933
- root.addEventListener('pointerleave', function () {
934
- return emitter.emit('pointerleave', {
935
- preset: _objectSpread2({}, preset)
936
- });
928
+ });
929
+ root.addEventListener('pointerleave', function () {
930
+ return emitter.emit('pointerleave', {
931
+ preset: _objectSpread2({}, preset)
937
932
  });
938
- }
933
+ });
939
934
  root.addEventListener('click', function (event) {
940
935
  emitter.emit('click', {
941
936
  event: event,
@@ -1000,6 +995,20 @@ function createCapsule(container) {
1000
995
  }));
1001
996
  return this;
1002
997
  },
998
+ setSeed: function setSeed(seed) {
999
+ var value = Number(seed);
1000
+ if (!Number.isFinite(value)) return this;
1001
+ preset.seed = value;
1002
+ renderer.setPreset(_objectSpread2({}, preset));
1003
+ return this;
1004
+ },
1005
+ setSpeed: function setSpeed(speed) {
1006
+ var value = Number(speed);
1007
+ if (!Number.isFinite(value)) return this;
1008
+ preset.speed = value;
1009
+ renderer.setPreset(_objectSpread2({}, preset));
1010
+ return this;
1011
+ },
1003
1012
  setSize: function setSize(width, height) {
1004
1013
  if (width !== undefined) merged.width = width;
1005
1014
  if (height !== undefined) merged.height = height;
package/dist/capsule.mjs CHANGED
@@ -112,57 +112,40 @@ const PALETTES = {
112
112
  * Capsule 预置:仅星云材质 NC-01~NC-06(NC-07~09 aurora 已移除)。
113
113
  * 颜色引用公共色板,seed/speed 决定形态与流速。
114
114
  */
115
- const CAPSULE_PRESETS = [
116
- { id: 'original', code: 'NC-01', name: 'ORIGINAL', group: 'warm', seed: 1.7, speed: 0.5, colors: [...PALETTES.original] },
117
- { id: 'ocean', code: 'NC-02', name: 'OCEAN', group: 'cold', seed: 8.2, speed: 0.48, colors: [...PALETTES.ocean] },
118
- { id: 'klein', code: 'NC-03', name: 'KLEIN', group: 'cold', seed: 14.1, speed: 0.49, colors: [...PALETTES.klein] },
119
- { id: 'ultraviolet', code: 'NC-04', name: 'ULTRAVIOLET', group: 'cold', seed: 23.4, speed: 0.47, colors: [...PALETTES.ultraviolet] },
120
- { id: 'chrome', code: 'NC-05', name: 'CHROME', group: 'cold', seed: 37.8, speed: 0.42, colors: [...PALETTES.chrome] },
121
- { id: 'plus', code: 'NC-06', name: 'PLUS', group: 'warm', seed: 51.3, speed: 0.5, colors: [...PALETTES.plus] }
115
+ const CAPSULE_PRESETS = [
116
+ { id: 'original', code: 'NC-01', name: '初光', group: 'warm', seed: 1.7, speed: 0.5, colors: [...PALETTES.original] },
117
+ { id: 'ocean', code: 'NC-02', name: '沧溟', group: 'cold', seed: 8.2, speed: 0.48, colors: [...PALETTES.ocean] },
118
+ { id: 'klein', code: 'NC-03', name: '玄夜', group: 'cold', seed: 14.1, speed: 0.49, colors: [...PALETTES.klein] },
119
+ { id: 'ultraviolet', code: 'NC-04', name: '紫霄', group: 'cold', seed: 23.4, speed: 0.47, colors: [...PALETTES.ultraviolet] },
120
+ { id: 'chrome', code: 'NC-05', name: '银汉', group: 'cold', seed: 37.8, speed: 0.42, colors: [...PALETTES.chrome] },
121
+ { id: 'plus', code: 'NC-06', name: '熔金', group: 'warm', seed: 51.3, speed: 0.5, colors: [...PALETTES.plus] }
122
122
  ];
123
123
 
124
- function validatePreset(preset) {
125
- return Boolean(
126
- preset &&
127
- typeof preset.id === 'string' &&
128
- typeof preset.code === 'string' &&
129
- typeof preset.name === 'string' &&
130
- Number.isFinite(preset.seed) &&
131
- Number.isFinite(preset.speed) &&
132
- Array.isArray(preset.colors) &&
133
- preset.colors.length === 4
134
- );
135
- }
136
-
137
- function getPreset(kind, ref) {
138
- const list = CAPSULE_PRESETS ;
139
- if (!list) throw new Error(`Unknown preset kind: ${kind} (use "capsule" or "progress")`);
140
- if (ref && typeof ref === 'object') {
141
- const valid = validatePreset(ref) ;
142
- if (!valid) throw new Error(`Invalid ${kind} preset object`);
143
- return ref;
144
- }
145
- const key = String(ref).trim().toLowerCase();
146
- const found = list.find(
147
- (preset) =>
148
- preset.id.toLowerCase() === key ||
149
- preset.code.toLowerCase() === key ||
150
- preset.name.toLowerCase() === key
151
- );
152
- if (!found) throw new Error(`Unknown ${kind} preset: ${ref}`);
153
- return found;
124
+ /**
125
+ * Resolve a preset by its literary name (e.g. '沧溟').
126
+ * Matching is case-insensitive and ignores surrounding whitespace,
127
+ * so '沧溟' and ' 沧溟 ' both work.
128
+ */
129
+ function getPreset(kind, ref) {
130
+ const list = CAPSULE_PRESETS ;
131
+ if (!list) throw new Error(`Unknown preset kind: ${kind} (use "capsule" or "progress")`);
132
+ const key = String(ref).trim().toLowerCase();
133
+ const found = list.find(
134
+ (preset) => preset.name.toLowerCase() === key
135
+ );
136
+ if (!found) throw new Error(`Unknown ${kind} preset: ${ref}`);
137
+ return found;
154
138
  }
155
139
 
156
140
  const DEFAULTS = {
157
141
  capsule: {
158
142
  width: '100%',
159
143
  height: 160,
160
- quality: 'auto',
161
- renderer: 'auto',
162
- respectReducedMotion: true,
163
- interactive: true,
164
- mouseColor: true,
165
- showCopy: true
144
+ quality: 'auto',
145
+ renderer: 'auto',
146
+ respectReducedMotion: true,
147
+ mouseColor: true,
148
+ showCopy: true
166
149
  }};
167
150
 
168
151
  /**
@@ -650,15 +633,15 @@ function prefersReducedMotion() {
650
633
  * Mount a cosmic (nebula) capsule into `container`.
651
634
  *
652
635
  * Options: preset (id/code/name or object), width, height (number=px or
653
- * string with px/%/vw/vh/em/rem), colors, seed, speed, quality, interactive,
654
- * respectReducedMotion, copy, cssVars.
636
+ * string with px/%/vw/vh/em/rem), colors, seed, speed, quality,
637
+ * respectReducedMotion, copy, cssVars.
655
638
  */
656
639
  function createCapsule(container, options = {}) {
657
640
  if (!container || typeof container.appendChild !== 'function') {
658
641
  throw new Error('createCapsule: container element is required');
659
642
  }
660
643
 
661
- const preset = { ...getPreset('capsule', options.preset ?? 'NC-01') };
644
+ const preset = { ...getPreset('capsule', options.preset ?? '初光') };
662
645
  const merged = normalizeOptions(DEFAULTS.capsule, preset, options);
663
646
  const copy = { ...COPY, ...(merged.copy || {}) };
664
647
 
@@ -745,10 +728,8 @@ function createCapsule(container, options = {}) {
745
728
 
746
729
  const visibility = createVisibilityGuard(root);
747
730
 
748
- if (merged.interactive !== false) {
749
- root.addEventListener('pointerenter', () => emitter.emit('pointerenter', { preset: { ...preset } }));
750
- root.addEventListener('pointerleave', () => emitter.emit('pointerleave', { preset: { ...preset } }));
751
- }
731
+ root.addEventListener('pointerenter', () => emitter.emit('pointerenter', { preset: { ...preset } }));
732
+ root.addEventListener('pointerleave', () => emitter.emit('pointerleave', { preset: { ...preset } }));
752
733
  root.addEventListener('click', (event) => {
753
734
  emitter.emit('click', { event, preset: { ...preset } });
754
735
  });
@@ -788,12 +769,26 @@ function createCapsule(container, options = {}) {
788
769
  emitter.emit('presetchange', { preset: { ...next } });
789
770
  return this;
790
771
  },
791
- setColors(colors) {
792
- if (!Array.isArray(colors) || colors.length !== 4) return this;
793
- preset.colors = colors;
794
- renderer.setPreset({ ...preset, colors });
795
- return this;
796
- },
772
+ setColors(colors) {
773
+ if (!Array.isArray(colors) || colors.length !== 4) return this;
774
+ preset.colors = colors;
775
+ renderer.setPreset({ ...preset, colors });
776
+ return this;
777
+ },
778
+ setSeed(seed) {
779
+ const value = Number(seed);
780
+ if (!Number.isFinite(value)) return this;
781
+ preset.seed = value;
782
+ renderer.setPreset({ ...preset });
783
+ return this;
784
+ },
785
+ setSpeed(speed) {
786
+ const value = Number(speed);
787
+ if (!Number.isFinite(value)) return this;
788
+ preset.speed = value;
789
+ renderer.setPreset({ ...preset });
790
+ return this;
791
+ },
797
792
  setSize(width, height) {
798
793
  if (width !== undefined) merged.width = width;
799
794
  if (height !== undefined) merged.height = height;
package/dist/color.cjs CHANGED
@@ -296,7 +296,7 @@ var PALETTES = {
296
296
  var CAPSULE_PRESETS = [{
297
297
  id: 'original',
298
298
  code: 'NC-01',
299
- name: 'ORIGINAL',
299
+ name: '初光',
300
300
  group: 'warm',
301
301
  seed: 1.7,
302
302
  speed: 0.5,
@@ -304,7 +304,7 @@ var CAPSULE_PRESETS = [{
304
304
  }, {
305
305
  id: 'ocean',
306
306
  code: 'NC-02',
307
- name: 'OCEAN',
307
+ name: '沧溟',
308
308
  group: 'cold',
309
309
  seed: 8.2,
310
310
  speed: 0.48,
@@ -312,7 +312,7 @@ var CAPSULE_PRESETS = [{
312
312
  }, {
313
313
  id: 'klein',
314
314
  code: 'NC-03',
315
- name: 'KLEIN',
315
+ name: '玄夜',
316
316
  group: 'cold',
317
317
  seed: 14.1,
318
318
  speed: 0.49,
@@ -320,7 +320,7 @@ var CAPSULE_PRESETS = [{
320
320
  }, {
321
321
  id: 'ultraviolet',
322
322
  code: 'NC-04',
323
- name: 'ULTRAVIOLET',
323
+ name: '紫霄',
324
324
  group: 'cold',
325
325
  seed: 23.4,
326
326
  speed: 0.47,
@@ -328,7 +328,7 @@ var CAPSULE_PRESETS = [{
328
328
  }, {
329
329
  id: 'chrome',
330
330
  code: 'NC-05',
331
- name: 'CHROME',
331
+ name: '银汉',
332
332
  group: 'cold',
333
333
  seed: 37.8,
334
334
  speed: 0.42,
@@ -336,7 +336,7 @@ var CAPSULE_PRESETS = [{
336
336
  }, {
337
337
  id: 'plus',
338
338
  code: 'NC-06',
339
- name: 'PLUS',
339
+ name: '熔金',
340
340
  group: 'warm',
341
341
  seed: 51.3,
342
342
  speed: 0.5,
@@ -346,7 +346,7 @@ var CAPSULE_PRESETS = [{
346
346
  var PROGRESS_PRESETS = [{
347
347
  id: 'model-training',
348
348
  code: 'NC-10',
349
- name: 'MODEL TRAINING',
349
+ name: '星火',
350
350
  subtitle: 'SHA 4.5 + 100 2026 TKN',
351
351
  group: 'progress',
352
352
  initialProgress: 43,
@@ -355,7 +355,7 @@ var PROGRESS_PRESETS = [{
355
355
  }, {
356
356
  id: 'agent-migration',
357
357
  code: 'NC-11',
358
- name: 'AGENT MIGRATION',
358
+ name: '迁流',
359
359
  subtitle: 'TRANSFERRING PROTOCOL',
360
360
  group: 'progress',
361
361
  initialProgress: 33,
@@ -364,7 +364,7 @@ var PROGRESS_PRESETS = [{
364
364
  }, {
365
365
  id: 'visual-training',
366
366
  code: 'NC-12',
367
- name: 'VISUAL TRAINING',
367
+ name: '幻境',
368
368
  subtitle: 'GENERATING POWER ++',
369
369
  group: 'progress',
370
370
  initialProgress: 58,
@@ -373,7 +373,7 @@ var PROGRESS_PRESETS = [{
373
373
  }, {
374
374
  id: 'tide',
375
375
  code: 'NC-13',
376
- name: 'TIDE',
376
+ name: '汐潮',
377
377
  subtitle: 'MOON PULL / COAST',
378
378
  group: 'progress',
379
379
  initialProgress: 30,
@@ -382,20 +382,18 @@ var PROGRESS_PRESETS = [{
382
382
  }];
383
383
 
384
384
  [].concat(_toConsumableArray(CAPSULE_PRESETS), _toConsumableArray(PROGRESS_PRESETS));
385
- function validatePreset(preset) {
386
- return Boolean(preset && typeof preset.id === 'string' && typeof preset.code === 'string' && typeof preset.name === 'string' && Number.isFinite(preset.seed) && Number.isFinite(preset.speed) && Array.isArray(preset.colors) && preset.colors.length === 4);
387
- }
385
+
386
+ /**
387
+ * Resolve a preset by its literary name (e.g. '沧溟').
388
+ * Matching is case-insensitive and ignores surrounding whitespace,
389
+ * so '沧溟' and ' 沧溟 ' both work.
390
+ */
388
391
  function getPreset(kind, ref) {
389
392
  var list = CAPSULE_PRESETS ;
390
393
  if (!list) throw new Error("Unknown preset kind: ".concat(kind, " (use \"capsule\" or \"progress\")"));
391
- if (ref && _typeof(ref) === 'object') {
392
- var valid = validatePreset(ref) ;
393
- if (!valid) throw new Error("Invalid ".concat(kind, " preset object"));
394
- return ref;
395
- }
396
394
  var key = String(ref).trim().toLowerCase();
397
395
  var found = list.find(function (preset) {
398
- return preset.id.toLowerCase() === key || preset.code.toLowerCase() === key || preset.name.toLowerCase() === key;
396
+ return preset.name.toLowerCase() === key;
399
397
  });
400
398
  if (!found) throw new Error("Unknown ".concat(kind, " preset: ").concat(ref));
401
399
  return found;
@@ -803,7 +801,7 @@ function createColorBackground(host) {
803
801
  if (!host || typeof host.appendChild !== 'function') {
804
802
  throw new Error('createColorBackground: host element is required');
805
803
  }
806
- var preset = _objectSpread2({}, getPreset('capsule', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : 'NC-01'));
804
+ var preset = _objectSpread2({}, getPreset('capsule', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : '初光'));
807
805
  var merged = normalizeOptions({
808
806
  quality: DEFAULTS.capsule.quality,
809
807
  renderer: DEFAULTS.capsule.renderer,