@vanduo-oss/vd3-cbun 1.2.0 → 1.3.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +16 -14
  3. package/SKILL.md +3 -3
  4. package/dist/charts/index.cjs +18 -8
  5. package/dist/charts/index.cjs.map +2 -2
  6. package/dist/charts/index.d.ts +1 -1
  7. package/dist/charts/index.js +18 -8
  8. package/dist/charts/index.js.map +2 -2
  9. package/dist/charts/vue.d.ts +78 -7
  10. package/dist/code-editor/index.cjs +5 -3
  11. package/dist/code-editor/index.cjs.map +2 -2
  12. package/dist/code-editor/index.js +5 -3
  13. package/dist/code-editor/index.js.map +2 -2
  14. package/dist/draw/core.d.ts +6 -9
  15. package/dist/draw/index.cjs +13 -4
  16. package/dist/draw/index.cjs.map +2 -2
  17. package/dist/draw/index.d.ts +3 -7
  18. package/dist/draw/index.js +13 -4
  19. package/dist/draw/index.js.map +2 -2
  20. package/dist/draw/shapes.d.ts +12 -0
  21. package/dist/flowchart/index.cjs +4 -4
  22. package/dist/flowchart/index.cjs.map +2 -2
  23. package/dist/flowchart/index.js +4 -4
  24. package/dist/flowchart/index.js.map +2 -2
  25. package/dist/hex-grid/index.cjs +90 -62
  26. package/dist/hex-grid/index.cjs.map +3 -3
  27. package/dist/hex-grid/index.d.ts +1 -1
  28. package/dist/hex-grid/index.js +90 -62
  29. package/dist/hex-grid/index.js.map +3 -3
  30. package/dist/hex-grid/vue.d.ts +25 -1
  31. package/dist/index.js +4 -4
  32. package/dist/index.js.map +2 -2
  33. package/dist/meta.json +53 -53
  34. package/dist/music-player/index.cjs +3 -4
  35. package/dist/music-player/index.cjs.map +2 -2
  36. package/dist/music-player/index.d.ts +9 -1
  37. package/dist/music-player/index.js +3 -4
  38. package/dist/music-player/index.js.map +2 -2
  39. package/dist/music-player/vue.d.ts +49 -1
  40. package/package.json +1 -1
@@ -10,13 +10,9 @@ export {
10
10
  type VdDrawExposed,
11
11
  } from './vue';
12
12
 
13
- export {
14
- VdDraw as VdDrawCore,
15
- VD_DRAW_VERSION,
16
- DRAW_TOOLS,
17
- DRAW_SHAPE_TYPES,
18
- BRUSH_PRESETS,
19
- } from './core';
13
+ export { VdDraw as VdDrawCore } from './core';
14
+
15
+ export { VD_DRAW_VERSION, DRAW_TOOLS, DRAW_SHAPE_TYPES, BRUSH_PRESETS } from './shapes';
20
16
 
21
17
  export type {
22
18
  DrawTool,
@@ -81,6 +81,8 @@ var MIN_SCALE = 0.2;
81
81
  var MAX_SCALE = 4;
82
82
  var DEFAULT_GRID_SIZE = 20;
83
83
  var DEFAULT_STROKE_WIDTH = 2;
84
+ var MAX_SHAPES = 1e4;
85
+ var MAX_POINTS_PER_SHAPE = 1e5;
84
86
  var idCounter = 0;
85
87
  function createId(prefix = "sh") {
86
88
  idCounter += 1;
@@ -339,7 +341,9 @@ function coerceNumber(value, fallback = 0) {
339
341
  function coercePoints(raw) {
340
342
  if (!Array.isArray(raw)) return [];
341
343
  const pts = [];
342
- for (const p of raw) {
344
+ const limit = Math.min(raw.length, MAX_POINTS_PER_SHAPE);
345
+ for (let i = 0; i < limit; i += 1) {
346
+ const p = raw[i];
343
347
  if (Array.isArray(p) && p.length >= 2 && Number.isFinite(Number(p[0])) && Number.isFinite(Number(p[1]))) {
344
348
  const pt = [round(Number(p[0])), round(Number(p[1]))];
345
349
  if (p.length >= 3 && Number.isFinite(Number(p[2]))) pt.push(clamp(Number(p[2]), 0, 1));
@@ -428,8 +432,9 @@ function normalizeDocument(data) {
428
432
  const usedIds = /* @__PURE__ */ new Set();
429
433
  const rawShapes = Array.isArray(raw.shapes) ? raw.shapes : [];
430
434
  const shapes = [];
431
- for (const rawShape of rawShapes) {
432
- const shape = normalizeShape(rawShape, usedIds);
435
+ const shapeLimit = Math.min(rawShapes.length, MAX_SHAPES);
436
+ for (let i = 0; i < shapeLimit; i += 1) {
437
+ const shape = normalizeShape(rawShapes[i], usedIds);
433
438
  if (shape) shapes.push(shape);
434
439
  }
435
440
  const groupCounts = /* @__PURE__ */ new Map();
@@ -1412,7 +1417,11 @@ var VdDraw = class {
1412
1417
  _recordHistory(reason, targetKey) {
1413
1418
  if (!this.historyEnabled || this.isApplyingHistory) return;
1414
1419
  const snapshot = this.toJSON();
1415
- const coalesce = COALESCE_REASONS.has(reason) && reason === this.lastReason && targetKey != null && targetKey === this.lastTargetKey && this.historyIndex >= 0;
1420
+ const coalesce = COALESCE_REASONS.has(reason) && reason === this.lastReason && targetKey != null && targetKey === this.lastTargetKey && this.historyIndex >= 0 && // Only coalesce onto the TOP of the stack. Without this guard a
1421
+ // coalescing edit made right after an undo overwrites an earlier
1422
+ // (non-top) snapshot, corrupting the redo branch and losing base state.
1423
+ // Mirrors the flowchart core's canCoalesce guard.
1424
+ this.historyIndex === this.history.length - 1;
1416
1425
  if (coalesce) {
1417
1426
  this.history[this.historyIndex] = snapshot;
1418
1427
  } else {