@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/dist/color.mjs CHANGED
@@ -91,51 +91,35 @@ const PALETTES = {
91
91
  * Capsule 预置:仅星云材质 NC-01~NC-06(NC-07~09 aurora 已移除)。
92
92
  * 颜色引用公共色板,seed/speed 决定形态与流速。
93
93
  */
94
- const CAPSULE_PRESETS = [
95
- { id: 'original', code: 'NC-01', name: 'ORIGINAL', group: 'warm', seed: 1.7, speed: 0.5, colors: [...PALETTES.original] },
96
- { id: 'ocean', code: 'NC-02', name: 'OCEAN', group: 'cold', seed: 8.2, speed: 0.48, colors: [...PALETTES.ocean] },
97
- { id: 'klein', code: 'NC-03', name: 'KLEIN', group: 'cold', seed: 14.1, speed: 0.49, colors: [...PALETTES.klein] },
98
- { id: 'ultraviolet', code: 'NC-04', name: 'ULTRAVIOLET', group: 'cold', seed: 23.4, speed: 0.47, colors: [...PALETTES.ultraviolet] },
99
- { id: 'chrome', code: 'NC-05', name: 'CHROME', group: 'cold', seed: 37.8, speed: 0.42, colors: [...PALETTES.chrome] },
100
- { id: 'plus', code: 'NC-06', name: 'PLUS', group: 'warm', seed: 51.3, speed: 0.5, colors: [...PALETTES.plus] }
94
+ const CAPSULE_PRESETS = [
95
+ { id: 'original', code: 'NC-01', name: '初光', group: 'warm', seed: 1.7, speed: 0.5, colors: [...PALETTES.original] },
96
+ { id: 'ocean', code: 'NC-02', name: '沧溟', group: 'cold', seed: 8.2, speed: 0.48, colors: [...PALETTES.ocean] },
97
+ { id: 'klein', code: 'NC-03', name: '玄夜', group: 'cold', seed: 14.1, speed: 0.49, colors: [...PALETTES.klein] },
98
+ { id: 'ultraviolet', code: 'NC-04', name: '紫霄', group: 'cold', seed: 23.4, speed: 0.47, colors: [...PALETTES.ultraviolet] },
99
+ { id: 'chrome', code: 'NC-05', name: '银汉', group: 'cold', seed: 37.8, speed: 0.42, colors: [...PALETTES.chrome] },
100
+ { id: 'plus', code: 'NC-06', name: '熔金', group: 'warm', seed: 51.3, speed: 0.5, colors: [...PALETTES.plus] }
101
101
  ];
102
102
 
103
- function validatePreset(preset) {
104
- return Boolean(
105
- preset &&
106
- typeof preset.id === 'string' &&
107
- typeof preset.code === 'string' &&
108
- typeof preset.name === 'string' &&
109
- Number.isFinite(preset.seed) &&
110
- Number.isFinite(preset.speed) &&
111
- Array.isArray(preset.colors) &&
112
- preset.colors.length === 4
113
- );
114
- }
115
-
116
- function getPreset(kind, ref) {
117
- const list = CAPSULE_PRESETS ;
118
- if (!list) throw new Error(`Unknown preset kind: ${kind} (use "capsule" or "progress")`);
119
- if (ref && typeof ref === 'object') {
120
- const valid = validatePreset(ref) ;
121
- if (!valid) throw new Error(`Invalid ${kind} preset object`);
122
- return ref;
123
- }
124
- const key = String(ref).trim().toLowerCase();
125
- const found = list.find(
126
- (preset) =>
127
- preset.id.toLowerCase() === key ||
128
- preset.code.toLowerCase() === key ||
129
- preset.name.toLowerCase() === key
130
- );
131
- if (!found) throw new Error(`Unknown ${kind} preset: ${ref}`);
132
- return found;
103
+ /**
104
+ * Resolve a preset by its literary name (e.g. '沧溟').
105
+ * Matching is case-insensitive and ignores surrounding whitespace,
106
+ * so '沧溟' and ' 沧溟 ' both work.
107
+ */
108
+ function getPreset(kind, ref) {
109
+ const list = CAPSULE_PRESETS ;
110
+ if (!list) throw new Error(`Unknown preset kind: ${kind} (use "capsule" or "progress")`);
111
+ const key = String(ref).trim().toLowerCase();
112
+ const found = list.find(
113
+ (preset) => preset.name.toLowerCase() === key
114
+ );
115
+ if (!found) throw new Error(`Unknown ${kind} preset: ${ref}`);
116
+ return found;
133
117
  }
134
118
 
135
119
  const DEFAULTS = {
136
120
  capsule: {
137
- quality: 'auto',
138
- renderer: 'auto',
121
+ quality: 'auto',
122
+ renderer: 'auto',
139
123
  respectReducedMotion: true}};
140
124
 
141
125
  function hexToRgb01(hex) {
@@ -616,7 +600,7 @@ function createColorBackground(host, options = {}) {
616
600
  throw new Error('createColorBackground: host element is required');
617
601
  }
618
602
 
619
- const preset = { ...getPreset('capsule', options.preset ?? 'NC-01') };
603
+ const preset = { ...getPreset('capsule', options.preset ?? '初光') };
620
604
  const merged = normalizeOptions(
621
605
  {
622
606
  quality: DEFAULTS.capsule.quality,
package/dist/index.cjs CHANGED
@@ -320,7 +320,7 @@ var PALETTES$1 = {
320
320
  var CAPSULE_PRESETS = [{
321
321
  id: 'original',
322
322
  code: 'NC-01',
323
- name: 'ORIGINAL',
323
+ name: '初光',
324
324
  group: 'warm',
325
325
  seed: 1.7,
326
326
  speed: 0.5,
@@ -328,7 +328,7 @@ var CAPSULE_PRESETS = [{
328
328
  }, {
329
329
  id: 'ocean',
330
330
  code: 'NC-02',
331
- name: 'OCEAN',
331
+ name: '沧溟',
332
332
  group: 'cold',
333
333
  seed: 8.2,
334
334
  speed: 0.48,
@@ -336,7 +336,7 @@ var CAPSULE_PRESETS = [{
336
336
  }, {
337
337
  id: 'klein',
338
338
  code: 'NC-03',
339
- name: 'KLEIN',
339
+ name: '玄夜',
340
340
  group: 'cold',
341
341
  seed: 14.1,
342
342
  speed: 0.49,
@@ -344,7 +344,7 @@ var CAPSULE_PRESETS = [{
344
344
  }, {
345
345
  id: 'ultraviolet',
346
346
  code: 'NC-04',
347
- name: 'ULTRAVIOLET',
347
+ name: '紫霄',
348
348
  group: 'cold',
349
349
  seed: 23.4,
350
350
  speed: 0.47,
@@ -352,7 +352,7 @@ var CAPSULE_PRESETS = [{
352
352
  }, {
353
353
  id: 'chrome',
354
354
  code: 'NC-05',
355
- name: 'CHROME',
355
+ name: '银汉',
356
356
  group: 'cold',
357
357
  seed: 37.8,
358
358
  speed: 0.42,
@@ -360,7 +360,7 @@ var CAPSULE_PRESETS = [{
360
360
  }, {
361
361
  id: 'plus',
362
362
  code: 'NC-06',
363
- name: 'PLUS',
363
+ name: '熔金',
364
364
  group: 'warm',
365
365
  seed: 51.3,
366
366
  speed: 0.5,
@@ -370,7 +370,7 @@ var CAPSULE_PRESETS = [{
370
370
  var PROGRESS_PRESETS = [{
371
371
  id: 'model-training',
372
372
  code: 'NC-10',
373
- name: 'MODEL TRAINING',
373
+ name: '星火',
374
374
  subtitle: 'SHA 4.5 + 100 2026 TKN',
375
375
  group: 'progress',
376
376
  initialProgress: 43,
@@ -379,7 +379,7 @@ var PROGRESS_PRESETS = [{
379
379
  }, {
380
380
  id: 'agent-migration',
381
381
  code: 'NC-11',
382
- name: 'AGENT MIGRATION',
382
+ name: '迁流',
383
383
  subtitle: 'TRANSFERRING PROTOCOL',
384
384
  group: 'progress',
385
385
  initialProgress: 33,
@@ -388,7 +388,7 @@ var PROGRESS_PRESETS = [{
388
388
  }, {
389
389
  id: 'visual-training',
390
390
  code: 'NC-12',
391
- name: 'VISUAL TRAINING',
391
+ name: '幻境',
392
392
  subtitle: 'GENERATING POWER ++',
393
393
  group: 'progress',
394
394
  initialProgress: 58,
@@ -397,7 +397,7 @@ var PROGRESS_PRESETS = [{
397
397
  }, {
398
398
  id: 'tide',
399
399
  code: 'NC-13',
400
- name: 'TIDE',
400
+ name: '汐潮',
401
401
  subtitle: 'MOON PULL / COAST',
402
402
  group: 'progress',
403
403
  initialProgress: 30,
@@ -407,23 +407,18 @@ var PROGRESS_PRESETS = [{
407
407
 
408
408
  var PRESETS = CAPSULE_PRESETS;
409
409
  var ALL_PRESETS = [].concat(_toConsumableArray(CAPSULE_PRESETS), _toConsumableArray(PROGRESS_PRESETS));
410
- function validatePreset(preset) {
411
- 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);
412
- }
413
- function validateProgressPreset(preset) {
414
- return Boolean(preset && typeof preset.id === 'string' && typeof preset.code === 'string' && typeof preset.name === 'string' && preset.group === 'progress' && Number.isFinite(preset.initialProgress) && ['flow', 'tide'].indexOf(preset.edgeStyle || 'flow') !== -1 && Array.isArray(preset.colors) && preset.colors.length === 4);
415
- }
410
+
411
+ /**
412
+ * Resolve a preset by its literary name (e.g. '沧溟').
413
+ * Matching is case-insensitive and ignores surrounding whitespace,
414
+ * so '沧溟' and ' 沧溟 ' both work.
415
+ */
416
416
  function getPreset(kind, ref) {
417
417
  var list = kind === 'capsule' ? CAPSULE_PRESETS : kind === 'progress' ? PROGRESS_PRESETS : null;
418
418
  if (!list) throw new Error("Unknown preset kind: ".concat(kind, " (use \"capsule\" or \"progress\")"));
419
- if (ref && _typeof(ref) === 'object') {
420
- var valid = kind === 'capsule' ? validatePreset(ref) : validateProgressPreset(ref);
421
- if (!valid) throw new Error("Invalid ".concat(kind, " preset object"));
422
- return ref;
423
- }
424
419
  var key = String(ref).trim().toLowerCase();
425
420
  var found = list.find(function (preset) {
426
- return preset.id.toLowerCase() === key || preset.code.toLowerCase() === key || preset.name.toLowerCase() === key;
421
+ return preset.name.toLowerCase() === key;
427
422
  });
428
423
  if (!found) throw new Error("Unknown ".concat(kind, " preset: ").concat(ref));
429
424
  return found;
@@ -436,7 +431,6 @@ var DEFAULTS = {
436
431
  quality: 'auto',
437
432
  renderer: 'auto',
438
433
  respectReducedMotion: true,
439
- interactive: true,
440
434
  mouseColor: true,
441
435
  showCopy: true
442
436
  },
@@ -869,8 +863,8 @@ function prefersReducedMotion$2() {
869
863
  * Mount a cosmic (nebula) capsule into `container`.
870
864
  *
871
865
  * Options: preset (id/code/name or object), width, height (number=px or
872
- * string with px/%/vw/vh/em/rem), colors, seed, speed, quality, interactive,
873
- * respectReducedMotion, copy, cssVars.
866
+ * string with px/%/vw/vh/em/rem), colors, seed, speed, quality,
867
+ * respectReducedMotion, copy, cssVars.
874
868
  */
875
869
  function createCapsule(container) {
876
870
  var _options$preset;
@@ -878,7 +872,7 @@ function createCapsule(container) {
878
872
  if (!container || typeof container.appendChild !== 'function') {
879
873
  throw new Error('createCapsule: container element is required');
880
874
  }
881
- var preset = _objectSpread2({}, getPreset('capsule', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : 'NC-01'));
875
+ var preset = _objectSpread2({}, getPreset('capsule', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : '初光'));
882
876
  var merged = normalizeOptions(DEFAULTS.capsule, preset, options);
883
877
  var copy = _objectSpread2(_objectSpread2({}, COPY), merged.copy || {});
884
878
  var root = document.createElement('div');
@@ -957,18 +951,16 @@ function createCapsule(container) {
957
951
  }) : null;
958
952
  if (resizeObserver) resizeObserver.observe(root);else window.addEventListener('resize', renderer.resize);
959
953
  var visibility = createVisibilityGuard(root);
960
- if (merged.interactive !== false) {
961
- root.addEventListener('pointerenter', function () {
962
- return emitter.emit('pointerenter', {
963
- preset: _objectSpread2({}, preset)
964
- });
954
+ root.addEventListener('pointerenter', function () {
955
+ return emitter.emit('pointerenter', {
956
+ preset: _objectSpread2({}, preset)
965
957
  });
966
- root.addEventListener('pointerleave', function () {
967
- return emitter.emit('pointerleave', {
968
- preset: _objectSpread2({}, preset)
969
- });
958
+ });
959
+ root.addEventListener('pointerleave', function () {
960
+ return emitter.emit('pointerleave', {
961
+ preset: _objectSpread2({}, preset)
970
962
  });
971
- }
963
+ });
972
964
  root.addEventListener('click', function (event) {
973
965
  emitter.emit('click', {
974
966
  event: event,
@@ -1033,6 +1025,20 @@ function createCapsule(container) {
1033
1025
  }));
1034
1026
  return this;
1035
1027
  },
1028
+ setSeed: function setSeed(seed) {
1029
+ var value = Number(seed);
1030
+ if (!Number.isFinite(value)) return this;
1031
+ preset.seed = value;
1032
+ renderer.setPreset(_objectSpread2({}, preset));
1033
+ return this;
1034
+ },
1035
+ setSpeed: function setSpeed(speed) {
1036
+ var value = Number(speed);
1037
+ if (!Number.isFinite(value)) return this;
1038
+ preset.speed = value;
1039
+ renderer.setPreset(_objectSpread2({}, preset));
1040
+ return this;
1041
+ },
1036
1042
  setSize: function setSize(width, height) {
1037
1043
  if (width !== undefined) merged.width = width;
1038
1044
  if (height !== undefined) merged.height = height;
@@ -2061,7 +2067,7 @@ function createProgressCapsule(container) {
2061
2067
  if (!container || typeof container.appendChild !== 'function') {
2062
2068
  throw new Error('createProgressCapsule: container element is required');
2063
2069
  }
2064
- var preset = _objectSpread2({}, getPreset('progress', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : 'NC-10'));
2070
+ var preset = _objectSpread2({}, getPreset('progress', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : '星火'));
2065
2071
  var merged = normalizeOptions(DEFAULTS.progress, preset, options);
2066
2072
  var copy = _objectSpread2(_objectSpread2({}, COPY), merged.copy || {});
2067
2073
  var root = document.createElement('div');
@@ -2217,6 +2223,26 @@ function createProgressCapsule(container) {
2217
2223
  });
2218
2224
  return this;
2219
2225
  },
2226
+ setEdgeStyle: function setEdgeStyle(edgeStyle) {
2227
+ var value = String(edgeStyle || '').toLowerCase();
2228
+ if (value !== 'flow' && value !== 'tide') return this;
2229
+ preset.edgeStyle = value;
2230
+ controller.profile = value === 'tide' ? FLOW_PROFILES.tide : FLOW_PROFILES[preset.id] || FLOW_PROFILES['visual-training'];
2231
+ if (overlay) {
2232
+ overlay.dispose();
2233
+ overlay = attachProgressFlowOverlay({
2234
+ root: root,
2235
+ canvas: canvas,
2236
+ preset: preset,
2237
+ getProgress: function getProgress() {
2238
+ return controller.value;
2239
+ }
2240
+ });
2241
+ }
2242
+ controller.webglActive = Boolean(overlay);
2243
+ controller.resizeCanvas();
2244
+ return this;
2245
+ },
2220
2246
  setColors: function setColors(colors) {
2221
2247
  if (!Array.isArray(colors) || colors.length !== 4) return this;
2222
2248
  controller.setColors(colors);
@@ -2282,7 +2308,7 @@ function createColorBackground(host) {
2282
2308
  if (!host || typeof host.appendChild !== 'function') {
2283
2309
  throw new Error('createColorBackground: host element is required');
2284
2310
  }
2285
- var preset = _objectSpread2({}, getPreset('capsule', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : 'NC-01'));
2311
+ var preset = _objectSpread2({}, getPreset('capsule', (_options$preset = options.preset) !== null && _options$preset !== void 0 ? _options$preset : '初光'));
2286
2312
  var merged = normalizeOptions({
2287
2313
  quality: DEFAULTS.capsule.quality,
2288
2314
  renderer: DEFAULTS.capsule.renderer,
@@ -2426,5 +2452,3 @@ exports.parseSize = parseSize;
2426
2452
  exports.pauseAll = pauseAll;
2427
2453
  exports.resumeAll = resumeAll;
2428
2454
  exports.validateColors = validateColors;
2429
- exports.validatePreset = validatePreset;
2430
- exports.validateProgressPreset = validateProgressPreset;
package/dist/index.mjs CHANGED
@@ -112,50 +112,50 @@ const PALETTES$1 = {
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$1.original] },
117
- { id: 'ocean', code: 'NC-02', name: 'OCEAN', group: 'cold', seed: 8.2, speed: 0.48, colors: [...PALETTES$1.ocean] },
118
- { id: 'klein', code: 'NC-03', name: 'KLEIN', group: 'cold', seed: 14.1, speed: 0.49, colors: [...PALETTES$1.klein] },
119
- { id: 'ultraviolet', code: 'NC-04', name: 'ULTRAVIOLET', group: 'cold', seed: 23.4, speed: 0.47, colors: [...PALETTES$1.ultraviolet] },
120
- { id: 'chrome', code: 'NC-05', name: 'CHROME', group: 'cold', seed: 37.8, speed: 0.42, colors: [...PALETTES$1.chrome] },
121
- { id: 'plus', code: 'NC-06', name: 'PLUS', group: 'warm', seed: 51.3, speed: 0.5, colors: [...PALETTES$1.plus] }
115
+ const CAPSULE_PRESETS = [
116
+ { id: 'original', code: 'NC-01', name: '初光', group: 'warm', seed: 1.7, speed: 0.5, colors: [...PALETTES$1.original] },
117
+ { id: 'ocean', code: 'NC-02', name: '沧溟', group: 'cold', seed: 8.2, speed: 0.48, colors: [...PALETTES$1.ocean] },
118
+ { id: 'klein', code: 'NC-03', name: '玄夜', group: 'cold', seed: 14.1, speed: 0.49, colors: [...PALETTES$1.klein] },
119
+ { id: 'ultraviolet', code: 'NC-04', name: '紫霄', group: 'cold', seed: 23.4, speed: 0.47, colors: [...PALETTES$1.ultraviolet] },
120
+ { id: 'chrome', code: 'NC-05', name: '银汉', group: 'cold', seed: 37.8, speed: 0.42, colors: [...PALETTES$1.chrome] },
121
+ { id: 'plus', code: 'NC-06', name: '熔金', group: 'warm', seed: 51.3, speed: 0.5, colors: [...PALETTES$1.plus] }
122
122
  ];
123
123
 
124
124
  const PROGRESS_PRESETS = [
125
- {
126
- id: 'model-training',
127
- code: 'NC-10',
128
- name: 'MODEL TRAINING',
125
+ {
126
+ id: 'model-training',
127
+ code: 'NC-10',
128
+ name: '星火',
129
129
  subtitle: 'SHA 4.5 + 100 2026 TKN',
130
130
  group: 'progress',
131
131
  initialProgress: 43,
132
132
  edgeStyle: 'flow',
133
133
  colors: ['#2B1025', '#FF3F94', '#FF8A3D', '#FFF06A']
134
134
  },
135
- {
136
- id: 'agent-migration',
137
- code: 'NC-11',
138
- name: 'AGENT MIGRATION',
135
+ {
136
+ id: 'agent-migration',
137
+ code: 'NC-11',
138
+ name: '迁流',
139
139
  subtitle: 'TRANSFERRING PROTOCOL',
140
140
  group: 'progress',
141
141
  initialProgress: 33,
142
142
  edgeStyle: 'flow',
143
143
  colors: ['#101C37', '#245BFF', '#00CFFF', '#5DFFE6']
144
144
  },
145
- {
146
- id: 'visual-training',
147
- code: 'NC-12',
148
- name: 'VISUAL TRAINING',
145
+ {
146
+ id: 'visual-training',
147
+ code: 'NC-12',
148
+ name: '幻境',
149
149
  subtitle: 'GENERATING POWER ++',
150
150
  group: 'progress',
151
151
  initialProgress: 58,
152
152
  edgeStyle: 'flow',
153
153
  colors: ['#21142D', '#7042FF', '#42F58D', '#C4FF8A']
154
154
  },
155
- {
156
- id: 'tide',
157
- code: 'NC-13',
158
- name: 'TIDE',
155
+ {
156
+ id: 'tide',
157
+ code: 'NC-13',
158
+ name: '汐潮',
159
159
  subtitle: 'MOON PULL / COAST',
160
160
  group: 'progress',
161
161
  initialProgress: 30,
@@ -164,65 +164,34 @@ const PROGRESS_PRESETS = [
164
164
  }
165
165
  ];
166
166
 
167
- const PRESETS = CAPSULE_PRESETS;
168
- const ALL_PRESETS = [...CAPSULE_PRESETS, ...PROGRESS_PRESETS];
169
-
170
- function validatePreset(preset) {
171
- return Boolean(
172
- preset &&
173
- typeof preset.id === 'string' &&
174
- typeof preset.code === 'string' &&
175
- typeof preset.name === 'string' &&
176
- Number.isFinite(preset.seed) &&
177
- Number.isFinite(preset.speed) &&
178
- Array.isArray(preset.colors) &&
179
- preset.colors.length === 4
180
- );
181
- }
182
-
183
- function validateProgressPreset(preset) {
184
- return Boolean(
185
- preset &&
186
- typeof preset.id === 'string' &&
187
- typeof preset.code === 'string' &&
188
- typeof preset.name === 'string' &&
189
- preset.group === 'progress' &&
190
- Number.isFinite(preset.initialProgress) &&
191
- ['flow', 'tide'].indexOf(preset.edgeStyle || 'flow') !== -1 &&
192
- Array.isArray(preset.colors) &&
193
- preset.colors.length === 4
194
- );
195
- }
196
-
197
- function getPreset(kind, ref) {
198
- const list = kind === 'capsule' ? CAPSULE_PRESETS : kind === 'progress' ? PROGRESS_PRESETS : null;
199
- if (!list) throw new Error(`Unknown preset kind: ${kind} (use "capsule" or "progress")`);
200
- if (ref && typeof ref === 'object') {
201
- const valid = kind === 'capsule' ? validatePreset(ref) : validateProgressPreset(ref);
202
- if (!valid) throw new Error(`Invalid ${kind} preset object`);
203
- return ref;
204
- }
205
- const key = String(ref).trim().toLowerCase();
206
- const found = list.find(
207
- (preset) =>
208
- preset.id.toLowerCase() === key ||
209
- preset.code.toLowerCase() === key ||
210
- preset.name.toLowerCase() === key
211
- );
212
- if (!found) throw new Error(`Unknown ${kind} preset: ${ref}`);
213
- return found;
167
+ const PRESETS = CAPSULE_PRESETS;
168
+ const ALL_PRESETS = [...CAPSULE_PRESETS, ...PROGRESS_PRESETS];
169
+
170
+ /**
171
+ * Resolve a preset by its literary name (e.g. '沧溟').
172
+ * Matching is case-insensitive and ignores surrounding whitespace,
173
+ * so '沧溟' and ' 沧溟 ' both work.
174
+ */
175
+ function getPreset(kind, ref) {
176
+ const list = kind === 'capsule' ? CAPSULE_PRESETS : kind === 'progress' ? PROGRESS_PRESETS : null;
177
+ if (!list) throw new Error(`Unknown preset kind: ${kind} (use "capsule" or "progress")`);
178
+ const key = String(ref).trim().toLowerCase();
179
+ const found = list.find(
180
+ (preset) => preset.name.toLowerCase() === key
181
+ );
182
+ if (!found) throw new Error(`Unknown ${kind} preset: ${ref}`);
183
+ return found;
214
184
  }
215
185
 
216
186
  const DEFAULTS = {
217
187
  capsule: {
218
188
  width: '100%',
219
189
  height: 160,
220
- quality: 'auto',
221
- renderer: 'auto',
222
- respectReducedMotion: true,
223
- interactive: true,
224
- mouseColor: true,
225
- showCopy: true
190
+ quality: 'auto',
191
+ renderer: 'auto',
192
+ respectReducedMotion: true,
193
+ mouseColor: true,
194
+ showCopy: true
226
195
  },
227
196
  progress: {
228
197
  width: 454,
@@ -737,15 +706,15 @@ function prefersReducedMotion$2() {
737
706
  * Mount a cosmic (nebula) capsule into `container`.
738
707
  *
739
708
  * Options: preset (id/code/name or object), width, height (number=px or
740
- * string with px/%/vw/vh/em/rem), colors, seed, speed, quality, interactive,
741
- * respectReducedMotion, copy, cssVars.
709
+ * string with px/%/vw/vh/em/rem), colors, seed, speed, quality,
710
+ * respectReducedMotion, copy, cssVars.
742
711
  */
743
712
  function createCapsule(container, options = {}) {
744
713
  if (!container || typeof container.appendChild !== 'function') {
745
714
  throw new Error('createCapsule: container element is required');
746
715
  }
747
716
 
748
- const preset = { ...getPreset('capsule', options.preset ?? 'NC-01') };
717
+ const preset = { ...getPreset('capsule', options.preset ?? '初光') };
749
718
  const merged = normalizeOptions(DEFAULTS.capsule, preset, options);
750
719
  const copy = { ...COPY, ...(merged.copy || {}) };
751
720
 
@@ -832,10 +801,8 @@ function createCapsule(container, options = {}) {
832
801
 
833
802
  const visibility = createVisibilityGuard(root);
834
803
 
835
- if (merged.interactive !== false) {
836
- root.addEventListener('pointerenter', () => emitter.emit('pointerenter', { preset: { ...preset } }));
837
- root.addEventListener('pointerleave', () => emitter.emit('pointerleave', { preset: { ...preset } }));
838
- }
804
+ root.addEventListener('pointerenter', () => emitter.emit('pointerenter', { preset: { ...preset } }));
805
+ root.addEventListener('pointerleave', () => emitter.emit('pointerleave', { preset: { ...preset } }));
839
806
  root.addEventListener('click', (event) => {
840
807
  emitter.emit('click', { event, preset: { ...preset } });
841
808
  });
@@ -875,12 +842,26 @@ function createCapsule(container, options = {}) {
875
842
  emitter.emit('presetchange', { preset: { ...next } });
876
843
  return this;
877
844
  },
878
- setColors(colors) {
879
- if (!Array.isArray(colors) || colors.length !== 4) return this;
880
- preset.colors = colors;
881
- renderer.setPreset({ ...preset, colors });
882
- return this;
883
- },
845
+ setColors(colors) {
846
+ if (!Array.isArray(colors) || colors.length !== 4) return this;
847
+ preset.colors = colors;
848
+ renderer.setPreset({ ...preset, colors });
849
+ return this;
850
+ },
851
+ setSeed(seed) {
852
+ const value = Number(seed);
853
+ if (!Number.isFinite(value)) return this;
854
+ preset.seed = value;
855
+ renderer.setPreset({ ...preset });
856
+ return this;
857
+ },
858
+ setSpeed(speed) {
859
+ const value = Number(speed);
860
+ if (!Number.isFinite(value)) return this;
861
+ preset.speed = value;
862
+ renderer.setPreset({ ...preset });
863
+ return this;
864
+ },
884
865
  setSize(width, height) {
885
866
  if (width !== undefined) merged.width = width;
886
867
  if (height !== undefined) merged.height = height;
@@ -2065,7 +2046,7 @@ function createProgressCapsule(container, options = {}) {
2065
2046
  throw new Error('createProgressCapsule: container element is required');
2066
2047
  }
2067
2048
 
2068
- const preset = { ...getPreset('progress', options.preset ?? 'NC-10') };
2049
+ const preset = { ...getPreset('progress', options.preset ?? '星火') };
2069
2050
  const merged = normalizeOptions(DEFAULTS.progress, preset, options);
2070
2051
  const copy = { ...COPY, ...(merged.copy || {}) };
2071
2052
 
@@ -2204,9 +2185,9 @@ function createProgressCapsule(container, options = {}) {
2204
2185
  controller.setRange(min, max);
2205
2186
  return this;
2206
2187
  },
2207
- setPreset(ref) {
2208
- const next = getPreset('progress', ref);
2209
- Object.assign(preset, next);
2188
+ setPreset(ref) {
2189
+ const next = getPreset('progress', ref);
2190
+ Object.assign(preset, next);
2210
2191
  controller.preset = next;
2211
2192
  controller.profile = next.edgeStyle === 'tide'
2212
2193
  ? FLOW_PROFILES.tide
@@ -2220,10 +2201,25 @@ function createProgressCapsule(container, options = {}) {
2220
2201
  }
2221
2202
  controller.webglActive = Boolean(overlay);
2222
2203
  controller.resizeCanvas();
2223
- emitter.emit('presetchange', { preset: { ...next } });
2224
- return this;
2225
- },
2226
- setColors(colors) {
2204
+ emitter.emit('presetchange', { preset: { ...next } });
2205
+ return this;
2206
+ },
2207
+ setEdgeStyle(edgeStyle) {
2208
+ const value = String(edgeStyle || '').toLowerCase();
2209
+ if (value !== 'flow' && value !== 'tide') return this;
2210
+ preset.edgeStyle = value;
2211
+ controller.profile = value === 'tide'
2212
+ ? FLOW_PROFILES.tide
2213
+ : (FLOW_PROFILES[preset.id] || FLOW_PROFILES['visual-training']);
2214
+ if (overlay) {
2215
+ overlay.dispose();
2216
+ overlay = attachProgressFlowOverlay({ root, canvas, preset, getProgress: () => controller.value });
2217
+ }
2218
+ controller.webglActive = Boolean(overlay);
2219
+ controller.resizeCanvas();
2220
+ return this;
2221
+ },
2222
+ setColors(colors) {
2227
2223
  if (!Array.isArray(colors) || colors.length !== 4) return this;
2228
2224
  controller.setColors(colors);
2229
2225
  if (overlay) overlay.setColors(colors);
@@ -2287,7 +2283,7 @@ function createColorBackground(host, options = {}) {
2287
2283
  throw new Error('createColorBackground: host element is required');
2288
2284
  }
2289
2285
 
2290
- const preset = { ...getPreset('capsule', options.preset ?? 'NC-01') };
2286
+ const preset = { ...getPreset('capsule', options.preset ?? '初光') };
2291
2287
  const merged = normalizeOptions(
2292
2288
  {
2293
2289
  quality: DEFAULTS.capsule.quality,
@@ -2428,4 +2424,4 @@ function createColorBackground(host, options = {}) {
2428
2424
  };
2429
2425
  }
2430
2426
 
2431
- export { ALL_PRESETS, COPY, CosmicRenderer, DEFAULTS, FallbackRenderer, PRESETS, PROGRESS_PRESETS, ProgressCapsuleController, ProgressFlowRenderer, QUALITY_TIERS, createCapsule, createColorBackground, createProgressCapsule, dprCapFor, getPreset, hexToRgb01$1 as hexToRgb01, hexToRgba, parseSize, pauseAll, resumeAll, validateColors, validatePreset, validateProgressPreset };
2427
+ export { ALL_PRESETS, COPY, CosmicRenderer, DEFAULTS, FallbackRenderer, PRESETS, PROGRESS_PRESETS, ProgressCapsuleController, ProgressFlowRenderer, QUALITY_TIERS, createCapsule, createColorBackground, createProgressCapsule, dprCapFor, getPreset, hexToRgb01$1 as hexToRgb01, hexToRgba, parseSize, pauseAll, resumeAll, validateColors };