@diagrammo/dgmo 0.8.16 → 0.8.18
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/cli.cjs +98 -98
- package/dist/editor.cjs +1 -1
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.js +1 -1
- package/dist/editor.js.map +1 -1
- package/dist/highlight.cjs +1 -1
- package/dist/highlight.cjs.map +1 -1
- package/dist/highlight.js +1 -1
- package/dist/highlight.js.map +1 -1
- package/dist/index.cjs +787 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +807 -28
- package/dist/index.js.map +1 -1
- package/docs/guide/how-dgmo-thinks.md +277 -0
- package/docs/guide/registry.json +1 -0
- package/gallery/fixtures/gantt-sprints.dgmo +20 -0
- package/package.json +1 -1
- package/src/colors.ts +1 -1
- package/src/editor/dgmo.grammar +1 -1
- package/src/editor/dgmo.grammar.js +1 -1
- package/src/gantt/calculator.ts +120 -7
- package/src/gantt/parser.ts +98 -3
- package/src/gantt/renderer.ts +259 -6
- package/src/gantt/types.ts +23 -2
- package/src/sharing.ts +4 -3
- package/src/utils/duration.ts +16 -2
- package/src/utils/legend-layout.ts +8 -4
package/dist/index.js
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
7
|
var __esm = (fn, res) => function __init() {
|
|
4
8
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
9
|
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
6
13
|
var __export = (target, all) => {
|
|
7
14
|
for (var name in all)
|
|
8
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
16
|
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
10
33
|
|
|
11
34
|
// src/diagnostics.ts
|
|
12
35
|
function makeDgmoError(line10, message, severity = "error") {
|
|
@@ -2229,13 +2252,13 @@ function capsuleWidth(name, entries, containerWidth, addonWidth = 0) {
|
|
|
2229
2252
|
visibleEntries: entries.length
|
|
2230
2253
|
};
|
|
2231
2254
|
}
|
|
2232
|
-
const rowWidth = maxCapsuleW - LEGEND_CAPSULE_PAD
|
|
2255
|
+
const rowWidth = maxCapsuleW - LEGEND_CAPSULE_PAD;
|
|
2233
2256
|
let row = 1;
|
|
2234
|
-
let rowX = pw + 4;
|
|
2257
|
+
let rowX = LEGEND_CAPSULE_PAD + pw + 4 + addonWidth;
|
|
2235
2258
|
let visible = 0;
|
|
2236
2259
|
for (let i = 0; i < entries.length; i++) {
|
|
2237
2260
|
const ew2 = entryWidth(entries[i].value);
|
|
2238
|
-
if (rowX + ew2 > rowWidth &&
|
|
2261
|
+
if (rowX + ew2 > rowWidth && i > 0) {
|
|
2239
2262
|
row++;
|
|
2240
2263
|
rowX = 0;
|
|
2241
2264
|
if (row > LEGEND_MAX_ENTRY_ROWS) {
|
|
@@ -2401,7 +2424,7 @@ function buildCapsuleLayout(group, containerWidth, addonWidth = 0) {
|
|
|
2401
2424
|
let ex = LEGEND_CAPSULE_PAD + pw + 4 + addonWidth;
|
|
2402
2425
|
let ey = 0;
|
|
2403
2426
|
let rowX = ex;
|
|
2404
|
-
const maxRowW = containerWidth - LEGEND_CAPSULE_PAD
|
|
2427
|
+
const maxRowW = containerWidth - LEGEND_CAPSULE_PAD;
|
|
2405
2428
|
let currentRow = 0;
|
|
2406
2429
|
for (let i = 0; i < info.visibleEntries; i++) {
|
|
2407
2430
|
const entry = group.entries[i];
|
|
@@ -10337,7 +10360,7 @@ function addBusinessDays(startDate, count, workweek, holidaySet, direction = 1)
|
|
|
10337
10360
|
}
|
|
10338
10361
|
return current;
|
|
10339
10362
|
}
|
|
10340
|
-
function addGanttDuration(startDate, duration, holidays, holidaySet, direction = 1) {
|
|
10363
|
+
function addGanttDuration(startDate, duration, holidays, holidaySet, direction = 1, opts) {
|
|
10341
10364
|
const { amount, unit } = duration;
|
|
10342
10365
|
switch (unit) {
|
|
10343
10366
|
case "bd":
|
|
@@ -10399,10 +10422,22 @@ function addGanttDuration(startDate, duration, holidays, holidaySet, direction =
|
|
|
10399
10422
|
result.setTime(result.getTime() + amount * 6e4 * direction);
|
|
10400
10423
|
return result;
|
|
10401
10424
|
}
|
|
10425
|
+
case "s": {
|
|
10426
|
+
if (!opts?.sprintLength) {
|
|
10427
|
+
throw new Error(
|
|
10428
|
+
'Sprint duration unit "s" requires sprintLength configuration'
|
|
10429
|
+
);
|
|
10430
|
+
}
|
|
10431
|
+
const sl = opts.sprintLength;
|
|
10432
|
+
const totalDays = amount * sl.amount * (sl.unit === "w" ? 7 : 1);
|
|
10433
|
+
const result = new Date(startDate);
|
|
10434
|
+
result.setDate(result.getDate() + Math.round(totalDays) * direction);
|
|
10435
|
+
return result;
|
|
10436
|
+
}
|
|
10402
10437
|
}
|
|
10403
10438
|
}
|
|
10404
10439
|
function parseDuration(s) {
|
|
10405
|
-
const match = s.trim().match(/^(\d+(?:\.\d+)?)(min|bd|d|w|m|q|y|h)$/);
|
|
10440
|
+
const match = s.trim().match(/^(\d+(?:\.\d+)?)(min|bd|d|w|m|q|y|h|s)$/);
|
|
10406
10441
|
if (!match) return null;
|
|
10407
10442
|
return { amount: parseFloat(match[1]), unit: match[2] };
|
|
10408
10443
|
}
|
|
@@ -10489,7 +10524,11 @@ function parseGantt(content, palette) {
|
|
|
10489
10524
|
defaultSwimlaneGroup: null,
|
|
10490
10525
|
activeTag: null,
|
|
10491
10526
|
optionLineNumbers: {},
|
|
10492
|
-
holidaysLineNumber: null
|
|
10527
|
+
holidaysLineNumber: null,
|
|
10528
|
+
sprintLength: null,
|
|
10529
|
+
sprintNumber: null,
|
|
10530
|
+
sprintStart: null,
|
|
10531
|
+
sprintMode: null
|
|
10493
10532
|
},
|
|
10494
10533
|
diagnostics,
|
|
10495
10534
|
error: null
|
|
@@ -10905,6 +10944,55 @@ function parseGantt(content, palette) {
|
|
|
10905
10944
|
case "active-tag":
|
|
10906
10945
|
result.options.activeTag = value;
|
|
10907
10946
|
break;
|
|
10947
|
+
case "sprint-length": {
|
|
10948
|
+
const dur = parseDuration(value);
|
|
10949
|
+
if (!dur) {
|
|
10950
|
+
warn(
|
|
10951
|
+
lineNumber,
|
|
10952
|
+
`Invalid sprint-length value: "${value}". Expected a duration like "2w" or "10d".`
|
|
10953
|
+
);
|
|
10954
|
+
} else if (dur.unit !== "d" && dur.unit !== "w") {
|
|
10955
|
+
warn(
|
|
10956
|
+
lineNumber,
|
|
10957
|
+
`sprint-length only accepts "d" or "w" units, got "${dur.unit}".`
|
|
10958
|
+
);
|
|
10959
|
+
} else if (dur.amount <= 0) {
|
|
10960
|
+
warn(lineNumber, `sprint-length must be greater than 0.`);
|
|
10961
|
+
} else if (!Number.isInteger(dur.amount * (dur.unit === "w" ? 7 : 1))) {
|
|
10962
|
+
warn(
|
|
10963
|
+
lineNumber,
|
|
10964
|
+
`sprint-length must resolve to a whole number of days.`
|
|
10965
|
+
);
|
|
10966
|
+
} else {
|
|
10967
|
+
result.options.sprintLength = dur;
|
|
10968
|
+
}
|
|
10969
|
+
break;
|
|
10970
|
+
}
|
|
10971
|
+
case "sprint-number": {
|
|
10972
|
+
const n = Number(value);
|
|
10973
|
+
if (!Number.isFinite(n) || !Number.isInteger(n) || n <= 0) {
|
|
10974
|
+
warn(
|
|
10975
|
+
lineNumber,
|
|
10976
|
+
`sprint-number must be a positive integer, got "${value}".`
|
|
10977
|
+
);
|
|
10978
|
+
} else {
|
|
10979
|
+
result.options.sprintNumber = n;
|
|
10980
|
+
}
|
|
10981
|
+
break;
|
|
10982
|
+
}
|
|
10983
|
+
case "sprint-start": {
|
|
10984
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
10985
|
+
warn(
|
|
10986
|
+
lineNumber,
|
|
10987
|
+
`sprint-start requires a full date (YYYY-MM-DD), got "${value}".`
|
|
10988
|
+
);
|
|
10989
|
+
} else if (Number.isNaN((/* @__PURE__ */ new Date(value + "T00:00:00")).getTime())) {
|
|
10990
|
+
warn(lineNumber, `sprint-start is not a valid date: "${value}".`);
|
|
10991
|
+
} else {
|
|
10992
|
+
result.options.sprintStart = value;
|
|
10993
|
+
}
|
|
10994
|
+
break;
|
|
10995
|
+
}
|
|
10908
10996
|
}
|
|
10909
10997
|
continue;
|
|
10910
10998
|
}
|
|
@@ -11085,6 +11173,21 @@ function parseGantt(content, palette) {
|
|
|
11085
11173
|
result.options.sort = "default";
|
|
11086
11174
|
}
|
|
11087
11175
|
validateTagGroupNames(result.tagGroups, warn);
|
|
11176
|
+
const hasSprintOption = result.options.sprintLength !== null || result.options.sprintNumber !== null || result.options.sprintStart !== null;
|
|
11177
|
+
const hasSprintUnit = hasSprintDurationUnit(result.nodes);
|
|
11178
|
+
if (hasSprintOption) {
|
|
11179
|
+
result.options.sprintMode = "explicit";
|
|
11180
|
+
} else if (hasSprintUnit) {
|
|
11181
|
+
result.options.sprintMode = "auto";
|
|
11182
|
+
}
|
|
11183
|
+
if (result.options.sprintMode) {
|
|
11184
|
+
if (!result.options.sprintLength) {
|
|
11185
|
+
result.options.sprintLength = { amount: 2, unit: "w" };
|
|
11186
|
+
}
|
|
11187
|
+
if (result.options.sprintNumber === null) {
|
|
11188
|
+
result.options.sprintNumber = 1;
|
|
11189
|
+
}
|
|
11190
|
+
}
|
|
11088
11191
|
return result;
|
|
11089
11192
|
function makeTask(labelRaw, duration, uncertain, ln, explicitStart) {
|
|
11090
11193
|
const segments = labelRaw.split("|");
|
|
@@ -11202,6 +11305,16 @@ function parseWorkweek(s) {
|
|
|
11202
11305
|
function isKnownOption(key) {
|
|
11203
11306
|
return KNOWN_OPTIONS5.has(key);
|
|
11204
11307
|
}
|
|
11308
|
+
function hasSprintDurationUnit(nodes) {
|
|
11309
|
+
for (const node of nodes) {
|
|
11310
|
+
if (node.kind === "task") {
|
|
11311
|
+
if (node.duration?.unit === "s") return true;
|
|
11312
|
+
} else if (node.kind === "group" || node.kind === "parallel") {
|
|
11313
|
+
if (hasSprintDurationUnit(node.children)) return true;
|
|
11314
|
+
}
|
|
11315
|
+
}
|
|
11316
|
+
return false;
|
|
11317
|
+
}
|
|
11205
11318
|
var DURATION_RE, EXPLICIT_DATE_RE, TIMELINE_DURATION_RE, GROUP_RE2, DEPENDENCY_RE, COMMENT_RE, ERA_RE, MARKER_RE, HOLIDAY_DATE_RE, HOLIDAY_RANGE_RE, WORKWEEK_RE, ERA_ENTRY_RE, MARKER_ENTRY_RE, WEEKDAY_MAP, KNOWN_OPTIONS5, KNOWN_BOOLEANS4;
|
|
11206
11319
|
var init_parser9 = __esm({
|
|
11207
11320
|
"src/gantt/parser.ts"() {
|
|
@@ -11211,9 +11324,9 @@ var init_parser9 = __esm({
|
|
|
11211
11324
|
init_parsing();
|
|
11212
11325
|
init_duration();
|
|
11213
11326
|
init_palettes();
|
|
11214
|
-
DURATION_RE = /^(\d+(?:\.\d+)?)(min|bd|d|w|m|q|y|h)(\?)?\s+(.+)$/;
|
|
11327
|
+
DURATION_RE = /^(\d+(?:\.\d+)?)(min|bd|d|w|m|q|y|h|s)(\?)?\s+(.+)$/;
|
|
11215
11328
|
EXPLICIT_DATE_RE = /^(\d{4}-\d{2}-\d{2}(?: \d{2}:\d{2})?)\s+(.+)$/;
|
|
11216
|
-
TIMELINE_DURATION_RE = /^(\d{4}-\d{2}-\d{2}(?: \d{2}:\d{2})?)\s*(?:->|\u2013>)\s*(\d+(?:\.\d+)?)(min|bd|d|w|m|q|y|h)(\?)?\s+(.+)$/;
|
|
11329
|
+
TIMELINE_DURATION_RE = /^(\d{4}-\d{2}-\d{2}(?: \d{2}:\d{2})?)\s*(?:->|\u2013>)\s*(\d+(?:\.\d+)?)(min|bd|d|w|m|q|y|h|s)(\?)?\s+(.+)$/;
|
|
11217
11330
|
GROUP_RE2 = /^\[(.+?)\]\s*(.*)$/;
|
|
11218
11331
|
DEPENDENCY_RE = /^(?:-(.+?))?->\s*(.+)$/;
|
|
11219
11332
|
COMMENT_RE = /^\/\//;
|
|
@@ -11248,7 +11361,10 @@ var init_parser9 = __esm({
|
|
|
11248
11361
|
"dependencies",
|
|
11249
11362
|
"chart",
|
|
11250
11363
|
"sort",
|
|
11251
|
-
"active-tag"
|
|
11364
|
+
"active-tag",
|
|
11365
|
+
"sprint-length",
|
|
11366
|
+
"sprint-number",
|
|
11367
|
+
"sprint-start"
|
|
11252
11368
|
]);
|
|
11253
11369
|
KNOWN_BOOLEANS4 = /* @__PURE__ */ new Set([
|
|
11254
11370
|
"critical-path",
|
|
@@ -22645,6 +22761,7 @@ function calculateSchedule(parsed) {
|
|
|
22645
22761
|
tagGroups: parsed.tagGroups,
|
|
22646
22762
|
eras: parsed.eras,
|
|
22647
22763
|
markers: parsed.markers,
|
|
22764
|
+
sprints: [],
|
|
22648
22765
|
options: parsed.options,
|
|
22649
22766
|
diagnostics,
|
|
22650
22767
|
error: parsed.error
|
|
@@ -22666,6 +22783,7 @@ function calculateSchedule(parsed) {
|
|
|
22666
22783
|
} else {
|
|
22667
22784
|
projectStart = new Date(2e3, 0, 1);
|
|
22668
22785
|
}
|
|
22786
|
+
const sprintOpts = parsed.options.sprintLength ? { sprintLength: parsed.options.sprintLength } : void 0;
|
|
22669
22787
|
const depOffsetMap = /* @__PURE__ */ new Map();
|
|
22670
22788
|
const allTasks = collectTasks(parsed.nodes);
|
|
22671
22789
|
if (allTasks.length === 0) {
|
|
@@ -22747,7 +22865,8 @@ function calculateSchedule(parsed) {
|
|
|
22747
22865
|
depOffset.duration,
|
|
22748
22866
|
parsed.holidays,
|
|
22749
22867
|
holidaySet,
|
|
22750
|
-
depOffset.direction
|
|
22868
|
+
depOffset.direction,
|
|
22869
|
+
sprintOpts
|
|
22751
22870
|
);
|
|
22752
22871
|
}
|
|
22753
22872
|
if (predEnd.getTime() > start.getTime()) {
|
|
@@ -22761,7 +22880,8 @@ function calculateSchedule(parsed) {
|
|
|
22761
22880
|
task.offset.duration,
|
|
22762
22881
|
parsed.holidays,
|
|
22763
22882
|
holidaySet,
|
|
22764
|
-
task.offset.direction
|
|
22883
|
+
task.offset.direction,
|
|
22884
|
+
sprintOpts
|
|
22765
22885
|
);
|
|
22766
22886
|
if (start.getTime() < projectStart.getTime()) {
|
|
22767
22887
|
warn(
|
|
@@ -22801,7 +22921,9 @@ function calculateSchedule(parsed) {
|
|
|
22801
22921
|
start,
|
|
22802
22922
|
task.duration,
|
|
22803
22923
|
parsed.holidays,
|
|
22804
|
-
holidaySet
|
|
22924
|
+
holidaySet,
|
|
22925
|
+
1,
|
|
22926
|
+
sprintOpts
|
|
22805
22927
|
);
|
|
22806
22928
|
}
|
|
22807
22929
|
} else {
|
|
@@ -22815,7 +22937,8 @@ function calculateSchedule(parsed) {
|
|
|
22815
22937
|
taskMap,
|
|
22816
22938
|
depOffsetMap,
|
|
22817
22939
|
parsed.holidays,
|
|
22818
|
-
holidaySet
|
|
22940
|
+
holidaySet,
|
|
22941
|
+
sprintOpts
|
|
22819
22942
|
) : /* @__PURE__ */ new Set();
|
|
22820
22943
|
const uncertainSet = /* @__PURE__ */ new Set();
|
|
22821
22944
|
for (const taskId of sortedIds) {
|
|
@@ -22855,6 +22978,20 @@ function calculateSchedule(parsed) {
|
|
|
22855
22978
|
result.startDate = minDate;
|
|
22856
22979
|
result.endDate = maxDate;
|
|
22857
22980
|
}
|
|
22981
|
+
if (parsed.options.sprintMode && parsed.options.sprintLength && result.tasks.length > 0) {
|
|
22982
|
+
result.sprints = generateSprintBands(
|
|
22983
|
+
parsed.options,
|
|
22984
|
+
result.startDate,
|
|
22985
|
+
result.endDate,
|
|
22986
|
+
projectStart
|
|
22987
|
+
);
|
|
22988
|
+
if (result.sprints.length > 0) {
|
|
22989
|
+
const lastSprintEnd = result.sprints[result.sprints.length - 1].endDate;
|
|
22990
|
+
if (lastSprintEnd.getTime() > result.endDate.getTime()) {
|
|
22991
|
+
result.endDate = lastSprintEnd;
|
|
22992
|
+
}
|
|
22993
|
+
}
|
|
22994
|
+
}
|
|
22858
22995
|
const topLevelGroups = parsed.nodes.filter((n) => n.kind === "group");
|
|
22859
22996
|
if (topLevelGroups.length >= 2) {
|
|
22860
22997
|
const names = topLevelGroups.map(
|
|
@@ -23055,7 +23192,7 @@ function breakCycle(cycle, taskMap, depOffsetMap) {
|
|
|
23055
23192
|
}
|
|
23056
23193
|
}
|
|
23057
23194
|
}
|
|
23058
|
-
function computeCriticalPath(sortedIds, taskMap, depOffsetMap, holidays, holidaySet) {
|
|
23195
|
+
function computeCriticalPath(sortedIds, taskMap, depOffsetMap, holidays, holidaySet, sprintOpts) {
|
|
23059
23196
|
if (sortedIds.length === 0) return /* @__PURE__ */ new Set();
|
|
23060
23197
|
const latestEnd = /* @__PURE__ */ new Map();
|
|
23061
23198
|
const latestStart = /* @__PURE__ */ new Map();
|
|
@@ -23093,7 +23230,8 @@ function computeCriticalPath(sortedIds, taskMap, depOffsetMap, holidays, holiday
|
|
|
23093
23230
|
succTask.offset.duration,
|
|
23094
23231
|
holidays,
|
|
23095
23232
|
holidaySet,
|
|
23096
|
-
reverseDir
|
|
23233
|
+
reverseDir,
|
|
23234
|
+
sprintOpts
|
|
23097
23235
|
);
|
|
23098
23236
|
succLS = adjusted.getTime();
|
|
23099
23237
|
}
|
|
@@ -23105,7 +23243,8 @@ function computeCriticalPath(sortedIds, taskMap, depOffsetMap, holidays, holiday
|
|
|
23105
23243
|
depOffset.duration,
|
|
23106
23244
|
holidays,
|
|
23107
23245
|
holidaySet,
|
|
23108
|
-
reverseDir
|
|
23246
|
+
reverseDir,
|
|
23247
|
+
sprintOpts
|
|
23109
23248
|
);
|
|
23110
23249
|
succLS = adjusted.getTime();
|
|
23111
23250
|
}
|
|
@@ -23180,6 +23319,51 @@ function buildResolvedGroups(nodes, taskMap, groups, depth) {
|
|
|
23180
23319
|
}
|
|
23181
23320
|
}
|
|
23182
23321
|
}
|
|
23322
|
+
function generateSprintBands(options, chartStart, chartEnd, projectStart) {
|
|
23323
|
+
const sprintLength = options.sprintLength;
|
|
23324
|
+
const sprintNumber = options.sprintNumber ?? 1;
|
|
23325
|
+
let anchorDate;
|
|
23326
|
+
if (options.sprintStart) {
|
|
23327
|
+
anchorDate = /* @__PURE__ */ new Date(options.sprintStart + "T00:00:00");
|
|
23328
|
+
} else if (options.start) {
|
|
23329
|
+
anchorDate = new Date(projectStart);
|
|
23330
|
+
} else {
|
|
23331
|
+
const now = /* @__PURE__ */ new Date();
|
|
23332
|
+
anchorDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
23333
|
+
}
|
|
23334
|
+
anchorDate.setHours(0, 0, 0, 0);
|
|
23335
|
+
const sprintDays = Math.round(
|
|
23336
|
+
sprintLength.amount * (sprintLength.unit === "w" ? 7 : 1)
|
|
23337
|
+
);
|
|
23338
|
+
if (sprintDays <= 0) return [];
|
|
23339
|
+
if (Number.isNaN(anchorDate.getTime())) return [];
|
|
23340
|
+
const chartStartTime = new Date(chartStart);
|
|
23341
|
+
chartStartTime.setHours(0, 0, 0, 0);
|
|
23342
|
+
const chartEndTime = new Date(chartEnd);
|
|
23343
|
+
chartEndTime.setHours(0, 0, 0, 0);
|
|
23344
|
+
const msPerDay = 864e5;
|
|
23345
|
+
const dayDiff = Math.floor(
|
|
23346
|
+
(chartStartTime.getTime() - anchorDate.getTime()) / msPerDay
|
|
23347
|
+
);
|
|
23348
|
+
const startSprintIndex = Math.floor(dayDiff / sprintDays);
|
|
23349
|
+
const sprints = [];
|
|
23350
|
+
const maxSprints = 1e3;
|
|
23351
|
+
for (let i = startSprintIndex; sprints.length < maxSprints; i++) {
|
|
23352
|
+
const sprintStartDate = new Date(anchorDate);
|
|
23353
|
+
sprintStartDate.setDate(sprintStartDate.getDate() + i * sprintDays);
|
|
23354
|
+
sprintStartDate.setHours(0, 0, 0, 0);
|
|
23355
|
+
const sprintEndDate = new Date(sprintStartDate);
|
|
23356
|
+
sprintEndDate.setDate(sprintEndDate.getDate() + sprintDays);
|
|
23357
|
+
sprintEndDate.setHours(0, 0, 0, 0);
|
|
23358
|
+
if (sprintStartDate.getTime() >= chartEndTime.getTime() + msPerDay) break;
|
|
23359
|
+
sprints.push({
|
|
23360
|
+
number: sprintNumber + i,
|
|
23361
|
+
startDate: sprintStartDate,
|
|
23362
|
+
endDate: sprintEndDate
|
|
23363
|
+
});
|
|
23364
|
+
}
|
|
23365
|
+
return sprints;
|
|
23366
|
+
}
|
|
23183
23367
|
function formatDate(d) {
|
|
23184
23368
|
const y = d.getFullYear();
|
|
23185
23369
|
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
@@ -23286,14 +23470,16 @@ function renderGantt(container, resolved, palette, isDark, options, exportDims)
|
|
|
23286
23470
|
const tagLegendReserve = resolved.tagGroups.length > 0 ? LEGEND_HEIGHT + 8 : 0;
|
|
23287
23471
|
const topDateLabelReserve = 22;
|
|
23288
23472
|
const hasOverheadLabels = resolved.markers.length > 0 || resolved.eras.length > 0;
|
|
23289
|
-
const markerLabelReserve = hasOverheadLabels ?
|
|
23473
|
+
const markerLabelReserve = hasOverheadLabels ? 28 : 0;
|
|
23474
|
+
const sprintLabelReserve = resolved.sprints.length > 0 ? 16 : 0;
|
|
23290
23475
|
const CONTENT_TOP_PAD = 16;
|
|
23291
|
-
const marginTop = titleHeight + tagLegendReserve + topDateLabelReserve + markerLabelReserve;
|
|
23476
|
+
const marginTop = titleHeight + tagLegendReserve + topDateLabelReserve + markerLabelReserve + sprintLabelReserve;
|
|
23292
23477
|
const contentH = isTagMode ? totalRows * (BAR_H + ROW_GAP) : totalRows * (BAR_H + ROW_GAP) + GROUP_GAP2 * resolved.groups.length;
|
|
23293
23478
|
const innerHeight = CONTENT_TOP_PAD + contentH;
|
|
23294
23479
|
const outerHeight = marginTop + innerHeight + BOTTOM_MARGIN;
|
|
23295
23480
|
const containerWidth = exportDims?.width ?? (container.clientWidth || 800);
|
|
23296
|
-
const
|
|
23481
|
+
const sprintRightPad = resolved.sprints.length > 0 ? 50 : 0;
|
|
23482
|
+
const innerWidth = containerWidth - leftMargin - RIGHT_MARGIN - sprintRightPad;
|
|
23297
23483
|
const svg = d3Selection10.select(container).append("svg").attr("viewBox", `0 0 ${containerWidth} ${outerHeight}`).attr("width", exportDims ? containerWidth : "100%").attr("preserveAspectRatio", "xMidYMin meet").attr("font-family", FONT_FAMILY).style("overflow", "visible");
|
|
23298
23484
|
const g = svg.append("g").attr("transform", `translate(${leftMargin}, ${marginTop})`);
|
|
23299
23485
|
if (title) {
|
|
@@ -23373,6 +23559,7 @@ function renderGantt(container, resolved, palette, isDark, options, exportDims)
|
|
|
23373
23559
|
onClickItem
|
|
23374
23560
|
);
|
|
23375
23561
|
renderErasAndMarkers(g, svg, resolved, xScale, innerHeight, palette);
|
|
23562
|
+
renderSprintBands(g, svg, resolved, xScale, innerHeight, palette);
|
|
23376
23563
|
let todayDate = null;
|
|
23377
23564
|
let todayX = -1;
|
|
23378
23565
|
const todayColor = palette.accent || "#e74c3c";
|
|
@@ -24276,7 +24463,7 @@ function renderErasAndMarkers(g, svg, resolved, xScale, innerHeight, palette) {
|
|
|
24276
24463
|
const eraEndDate = parseDateStringToDate(era.endDate);
|
|
24277
24464
|
const eraG = g.append("g").attr("class", "gantt-era-group").attr("data-line-number", String(era.lineNumber));
|
|
24278
24465
|
const eraRect = eraG.append("rect").attr("class", "gantt-era").attr("x", sx).attr("y", 0).attr("width", ex - sx).attr("height", innerHeight).attr("fill", color).attr("opacity", baseEraOpacity);
|
|
24279
|
-
eraG.append("text").attr("class", "gantt-era-label").attr("x", (sx + ex) / 2).attr("y", -
|
|
24466
|
+
eraG.append("text").attr("class", "gantt-era-label").attr("x", (sx + ex) / 2).attr("y", -34).attr("text-anchor", "middle").attr("font-size", "10px").attr("fill", color).attr("opacity", 0.7).style("cursor", "pointer").text(era.label);
|
|
24280
24467
|
eraG.on("mouseenter", () => {
|
|
24281
24468
|
g.selectAll(".gantt-task").attr(
|
|
24282
24469
|
"opacity",
|
|
@@ -24322,8 +24509,8 @@ function renderErasAndMarkers(g, svg, resolved, xScale, innerHeight, palette) {
|
|
|
24322
24509
|
const mx = xScale(parseDateToFractionalYear(marker.date));
|
|
24323
24510
|
const markerDate = parseDateStringToDate(marker.date);
|
|
24324
24511
|
const diamondSize = 5;
|
|
24325
|
-
const labelY = -
|
|
24326
|
-
const diamondY =
|
|
24512
|
+
const labelY = -34;
|
|
24513
|
+
const diamondY = -2;
|
|
24327
24514
|
const markerG = g.append("g").attr("class", "gantt-marker-group").attr("data-line-number", String(marker.lineNumber)).style("cursor", "pointer");
|
|
24328
24515
|
markerG.append("rect").attr("x", mx - 40).attr("y", labelY - 12).attr("width", 80).attr("height", innerHeight - labelY + 12).attr("fill", "transparent").attr("pointer-events", "all");
|
|
24329
24516
|
markerG.append("text").attr("class", "gantt-marker-label").attr("x", mx).attr("y", labelY).attr("text-anchor", "middle").attr("font-size", "11px").attr("font-weight", "600").attr("fill", color).text(marker.label);
|
|
@@ -24383,6 +24570,139 @@ function renderErasAndMarkers(g, svg, resolved, xScale, innerHeight, palette) {
|
|
|
24383
24570
|
});
|
|
24384
24571
|
}
|
|
24385
24572
|
}
|
|
24573
|
+
function renderSprintBands(g, svg, resolved, xScale, innerHeight, palette) {
|
|
24574
|
+
if (resolved.sprints.length === 0) return;
|
|
24575
|
+
if (resolved.eras.length > 0) return;
|
|
24576
|
+
const bandColor = palette.textMuted || palette.text || "#888";
|
|
24577
|
+
const chartMinX = 0;
|
|
24578
|
+
for (let i = 0; i < resolved.sprints.length; i++) {
|
|
24579
|
+
const sprint = resolved.sprints[i];
|
|
24580
|
+
const rawSx = xScale(dateToFractionalYear(sprint.startDate));
|
|
24581
|
+
const rawEx = xScale(dateToFractionalYear(sprint.endDate));
|
|
24582
|
+
if (rawEx <= rawSx) continue;
|
|
24583
|
+
const sx = Math.max(rawSx, chartMinX);
|
|
24584
|
+
const ex = rawEx;
|
|
24585
|
+
const bandWidth = ex - sx;
|
|
24586
|
+
if (bandWidth <= 0) continue;
|
|
24587
|
+
const sprintG = g.append("g").attr("class", "gantt-sprint-group").style("cursor", "pointer");
|
|
24588
|
+
const sprintRect = sprintG.append("rect").attr("class", "gantt-sprint-band").attr("x", sx).attr("y", 0).attr("width", bandWidth).attr("height", innerHeight).attr("fill", bandColor).attr("opacity", sprint.number % 2 === 0 ? SPRINT_BAND_OPACITY : 0);
|
|
24589
|
+
if (sprint.number % 2 !== 0) {
|
|
24590
|
+
sprintG.append("rect").attr("x", sx).attr("y", 0).attr("width", bandWidth).attr("height", innerHeight).attr("fill", "transparent");
|
|
24591
|
+
}
|
|
24592
|
+
const sprintLabel = sprintG.append("text").attr("class", "gantt-sprint-label").attr("x", (sx + ex) / 2).attr("y", -22).attr("text-anchor", "middle").attr("font-size", "10px").attr("font-weight", "600").attr("fill", bandColor).attr("opacity", 0.4).text(String(sprint.number));
|
|
24593
|
+
if (i > 0 && rawSx >= chartMinX) {
|
|
24594
|
+
sprintG.append("line").attr("class", "gantt-sprint-boundary").attr("x1", sx).attr("y1", -6).attr("x2", sx).attr("y2", innerHeight).attr("stroke", bandColor).attr("stroke-width", 1).attr("stroke-dasharray", "3 3").attr("opacity", SPRINT_BOUNDARY_OPACITY);
|
|
24595
|
+
}
|
|
24596
|
+
const sprintStartMs = sprint.startDate.getTime();
|
|
24597
|
+
const sprintEndMs = sprint.endDate.getTime();
|
|
24598
|
+
const overlappingTaskIds = /* @__PURE__ */ new Set();
|
|
24599
|
+
for (const rt of resolved.tasks) {
|
|
24600
|
+
const taskStart = rt.startDate.getTime();
|
|
24601
|
+
const taskEnd = rt.endDate.getTime();
|
|
24602
|
+
if (taskStart < sprintEndMs && taskEnd > sprintStartMs) {
|
|
24603
|
+
overlappingTaskIds.add(rt.task.id);
|
|
24604
|
+
}
|
|
24605
|
+
if (taskStart === taskEnd && taskStart >= sprintStartMs && taskStart < sprintEndMs) {
|
|
24606
|
+
overlappingTaskIds.add(rt.task.id);
|
|
24607
|
+
}
|
|
24608
|
+
}
|
|
24609
|
+
const overlappingGroupNames = /* @__PURE__ */ new Set();
|
|
24610
|
+
for (const rg of resolved.groups) {
|
|
24611
|
+
const gStart = rg.startDate.getTime();
|
|
24612
|
+
const gEnd = rg.endDate.getTime();
|
|
24613
|
+
if (gStart < sprintEndMs && gEnd > sprintStartMs) {
|
|
24614
|
+
overlappingGroupNames.add(rg.name);
|
|
24615
|
+
}
|
|
24616
|
+
}
|
|
24617
|
+
const baseOpacity = sprint.number % 2 === 0 ? SPRINT_BAND_OPACITY : 0;
|
|
24618
|
+
sprintG.on("mouseenter", () => {
|
|
24619
|
+
g.selectAll(".gantt-task").each(function() {
|
|
24620
|
+
const el = d3Selection10.select(this);
|
|
24621
|
+
const id = el.attr("data-task-id");
|
|
24622
|
+
el.attr(
|
|
24623
|
+
"opacity",
|
|
24624
|
+
id && overlappingTaskIds.has(id) ? 1 : FADE_OPACITY
|
|
24625
|
+
);
|
|
24626
|
+
});
|
|
24627
|
+
g.selectAll(".gantt-milestone").each(function() {
|
|
24628
|
+
const el = d3Selection10.select(this);
|
|
24629
|
+
const id = el.attr("data-task-id");
|
|
24630
|
+
el.attr(
|
|
24631
|
+
"opacity",
|
|
24632
|
+
id && overlappingTaskIds.has(id) ? 1 : FADE_OPACITY
|
|
24633
|
+
);
|
|
24634
|
+
});
|
|
24635
|
+
svg.selectAll(".gantt-task-label").each(function() {
|
|
24636
|
+
const el = d3Selection10.select(this);
|
|
24637
|
+
const id = el.attr("data-task-id");
|
|
24638
|
+
el.attr(
|
|
24639
|
+
"opacity",
|
|
24640
|
+
id && overlappingTaskIds.has(id) ? 1 : FADE_OPACITY
|
|
24641
|
+
);
|
|
24642
|
+
});
|
|
24643
|
+
g.selectAll(
|
|
24644
|
+
".gantt-group-bar, .gantt-group-summary"
|
|
24645
|
+
).each(function() {
|
|
24646
|
+
const el = d3Selection10.select(this);
|
|
24647
|
+
const name = el.attr("data-group");
|
|
24648
|
+
el.attr(
|
|
24649
|
+
"opacity",
|
|
24650
|
+
name && overlappingGroupNames.has(name) ? 1 : FADE_OPACITY
|
|
24651
|
+
);
|
|
24652
|
+
});
|
|
24653
|
+
svg.selectAll(".gantt-group-label").each(function() {
|
|
24654
|
+
const el = d3Selection10.select(this);
|
|
24655
|
+
const name = el.attr("data-group");
|
|
24656
|
+
el.attr(
|
|
24657
|
+
"opacity",
|
|
24658
|
+
name && overlappingGroupNames.has(name) ? 1 : FADE_OPACITY
|
|
24659
|
+
);
|
|
24660
|
+
});
|
|
24661
|
+
svg.selectAll(".gantt-lane-header").attr("opacity", FADE_OPACITY);
|
|
24662
|
+
g.selectAll(
|
|
24663
|
+
".gantt-lane-band, .gantt-lane-accent, .gantt-lane-band-group"
|
|
24664
|
+
).attr("opacity", FADE_OPACITY);
|
|
24665
|
+
g.selectAll(
|
|
24666
|
+
".gantt-dep-arrow, .gantt-dep-arrowhead"
|
|
24667
|
+
).attr("opacity", FADE_OPACITY);
|
|
24668
|
+
g.selectAll(".gantt-marker-group").attr(
|
|
24669
|
+
"opacity",
|
|
24670
|
+
FADE_OPACITY
|
|
24671
|
+
);
|
|
24672
|
+
sprintRect.attr("opacity", SPRINT_HOVER_OPACITY);
|
|
24673
|
+
const startVisible = rawSx >= chartMinX;
|
|
24674
|
+
if (startVisible) {
|
|
24675
|
+
showGanttDateIndicators(
|
|
24676
|
+
g,
|
|
24677
|
+
xScale,
|
|
24678
|
+
sprint.startDate,
|
|
24679
|
+
sprint.endDate,
|
|
24680
|
+
innerHeight,
|
|
24681
|
+
bandColor
|
|
24682
|
+
);
|
|
24683
|
+
} else {
|
|
24684
|
+
showGanttDateIndicators(
|
|
24685
|
+
g,
|
|
24686
|
+
xScale,
|
|
24687
|
+
sprint.endDate,
|
|
24688
|
+
null,
|
|
24689
|
+
innerHeight,
|
|
24690
|
+
bandColor
|
|
24691
|
+
);
|
|
24692
|
+
}
|
|
24693
|
+
const accentColor = palette.accent || palette.text || bandColor;
|
|
24694
|
+
sprintLabel.text(`Sprint ${sprint.number}`).attr("font-size", "13px").attr("font-weight", "700").attr("fill", accentColor).attr("opacity", 1);
|
|
24695
|
+
}).on("mouseleave", () => {
|
|
24696
|
+
resetHighlight(g, svg);
|
|
24697
|
+
sprintRect.attr("opacity", baseOpacity);
|
|
24698
|
+
sprintLabel.text(String(sprint.number)).attr("font-size", "10px").attr("font-weight", "600").attr("fill", bandColor).attr("opacity", 0.4);
|
|
24699
|
+
hideGanttDateIndicators(g);
|
|
24700
|
+
});
|
|
24701
|
+
}
|
|
24702
|
+
const lastSprint = resolved.sprints[resolved.sprints.length - 1];
|
|
24703
|
+
const lastEx = xScale(dateToFractionalYear(lastSprint.endDate));
|
|
24704
|
+
g.append("line").attr("class", "gantt-sprint-boundary").attr("x1", lastEx).attr("y1", -6).attr("x2", lastEx).attr("y2", innerHeight).attr("stroke", bandColor).attr("stroke-width", 1).attr("stroke-dasharray", "3 3").attr("opacity", SPRINT_BOUNDARY_OPACITY);
|
|
24705
|
+
}
|
|
24386
24706
|
function parseDateStringToDate(s) {
|
|
24387
24707
|
const parts = s.split("-").map((p) => parseInt(p, 10));
|
|
24388
24708
|
const year = parts[0];
|
|
@@ -24855,7 +25175,7 @@ function renderTimeScaleHorizontal(g, scale, innerWidth, innerHeight, textColor)
|
|
|
24855
25175
|
g.append("text").attr("class", "gantt-scale-tick").attr("x", tick.pos).attr("y", innerHeight + tickLen + 12).attr("text-anchor", "middle").attr("font-size", "10px").attr("fill", textColor).attr("opacity", opacity).text(tick.label);
|
|
24856
25176
|
}
|
|
24857
25177
|
}
|
|
24858
|
-
var BAR_H, ROW_GAP, GROUP_GAP2, MILESTONE_SIZE, MIN_LEFT_MARGIN, BOTTOM_MARGIN, RIGHT_MARGIN, CHAR_W2, LABEL_PAD, LABEL_GAP, BAND_ACCENT_W, BAND_RADIUS, bandClipCounter, JS_DAY_TO_WEEKDAY2, ERA_COLORS, FADE_OPACITY, MONTH_ABBR;
|
|
25178
|
+
var BAR_H, ROW_GAP, GROUP_GAP2, MILESTONE_SIZE, MIN_LEFT_MARGIN, BOTTOM_MARGIN, RIGHT_MARGIN, CHAR_W2, LABEL_PAD, LABEL_GAP, BAND_ACCENT_W, BAND_RADIUS, bandClipCounter, JS_DAY_TO_WEEKDAY2, ERA_COLORS, SPRINT_BAND_OPACITY, SPRINT_HOVER_OPACITY, SPRINT_BOUNDARY_OPACITY, FADE_OPACITY, MONTH_ABBR;
|
|
24859
25179
|
var init_renderer9 = __esm({
|
|
24860
25180
|
"src/gantt/renderer.ts"() {
|
|
24861
25181
|
"use strict";
|
|
@@ -24890,6 +25210,9 @@ var init_renderer9 = __esm({
|
|
|
24890
25210
|
"sat"
|
|
24891
25211
|
];
|
|
24892
25212
|
ERA_COLORS = ["#5e81ac", "#a3be8c", "#ebcb8b", "#d08770", "#b48ead"];
|
|
25213
|
+
SPRINT_BAND_OPACITY = 0.05;
|
|
25214
|
+
SPRINT_HOVER_OPACITY = 0.12;
|
|
25215
|
+
SPRINT_BOUNDARY_OPACITY = 0.3;
|
|
24893
25216
|
FADE_OPACITY = 0.1;
|
|
24894
25217
|
MONTH_ABBR = [
|
|
24895
25218
|
"Jan",
|
|
@@ -30945,6 +31268,463 @@ var init_d3 = __esm({
|
|
|
30945
31268
|
}
|
|
30946
31269
|
});
|
|
30947
31270
|
|
|
31271
|
+
// node_modules/.pnpm/lz-string@1.5.0/node_modules/lz-string/libs/lz-string.js
|
|
31272
|
+
var require_lz_string = __commonJS({
|
|
31273
|
+
"node_modules/.pnpm/lz-string@1.5.0/node_modules/lz-string/libs/lz-string.js"(exports, module) {
|
|
31274
|
+
"use strict";
|
|
31275
|
+
var LZString = (function() {
|
|
31276
|
+
var f = String.fromCharCode;
|
|
31277
|
+
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
31278
|
+
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
31279
|
+
var baseReverseDic = {};
|
|
31280
|
+
function getBaseValue(alphabet, character) {
|
|
31281
|
+
if (!baseReverseDic[alphabet]) {
|
|
31282
|
+
baseReverseDic[alphabet] = {};
|
|
31283
|
+
for (var i = 0; i < alphabet.length; i++) {
|
|
31284
|
+
baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
|
31285
|
+
}
|
|
31286
|
+
}
|
|
31287
|
+
return baseReverseDic[alphabet][character];
|
|
31288
|
+
}
|
|
31289
|
+
var LZString2 = {
|
|
31290
|
+
compressToBase64: function(input) {
|
|
31291
|
+
if (input == null) return "";
|
|
31292
|
+
var res = LZString2._compress(input, 6, function(a) {
|
|
31293
|
+
return keyStrBase64.charAt(a);
|
|
31294
|
+
});
|
|
31295
|
+
switch (res.length % 4) {
|
|
31296
|
+
// To produce valid Base64
|
|
31297
|
+
default:
|
|
31298
|
+
// When could this happen ?
|
|
31299
|
+
case 0:
|
|
31300
|
+
return res;
|
|
31301
|
+
case 1:
|
|
31302
|
+
return res + "===";
|
|
31303
|
+
case 2:
|
|
31304
|
+
return res + "==";
|
|
31305
|
+
case 3:
|
|
31306
|
+
return res + "=";
|
|
31307
|
+
}
|
|
31308
|
+
},
|
|
31309
|
+
decompressFromBase64: function(input) {
|
|
31310
|
+
if (input == null) return "";
|
|
31311
|
+
if (input == "") return null;
|
|
31312
|
+
return LZString2._decompress(input.length, 32, function(index) {
|
|
31313
|
+
return getBaseValue(keyStrBase64, input.charAt(index));
|
|
31314
|
+
});
|
|
31315
|
+
},
|
|
31316
|
+
compressToUTF16: function(input) {
|
|
31317
|
+
if (input == null) return "";
|
|
31318
|
+
return LZString2._compress(input, 15, function(a) {
|
|
31319
|
+
return f(a + 32);
|
|
31320
|
+
}) + " ";
|
|
31321
|
+
},
|
|
31322
|
+
decompressFromUTF16: function(compressed) {
|
|
31323
|
+
if (compressed == null) return "";
|
|
31324
|
+
if (compressed == "") return null;
|
|
31325
|
+
return LZString2._decompress(compressed.length, 16384, function(index) {
|
|
31326
|
+
return compressed.charCodeAt(index) - 32;
|
|
31327
|
+
});
|
|
31328
|
+
},
|
|
31329
|
+
//compress into uint8array (UCS-2 big endian format)
|
|
31330
|
+
compressToUint8Array: function(uncompressed) {
|
|
31331
|
+
var compressed = LZString2.compress(uncompressed);
|
|
31332
|
+
var buf = new Uint8Array(compressed.length * 2);
|
|
31333
|
+
for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) {
|
|
31334
|
+
var current_value = compressed.charCodeAt(i);
|
|
31335
|
+
buf[i * 2] = current_value >>> 8;
|
|
31336
|
+
buf[i * 2 + 1] = current_value % 256;
|
|
31337
|
+
}
|
|
31338
|
+
return buf;
|
|
31339
|
+
},
|
|
31340
|
+
//decompress from uint8array (UCS-2 big endian format)
|
|
31341
|
+
decompressFromUint8Array: function(compressed) {
|
|
31342
|
+
if (compressed === null || compressed === void 0) {
|
|
31343
|
+
return LZString2.decompress(compressed);
|
|
31344
|
+
} else {
|
|
31345
|
+
var buf = new Array(compressed.length / 2);
|
|
31346
|
+
for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) {
|
|
31347
|
+
buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1];
|
|
31348
|
+
}
|
|
31349
|
+
var result = [];
|
|
31350
|
+
buf.forEach(function(c) {
|
|
31351
|
+
result.push(f(c));
|
|
31352
|
+
});
|
|
31353
|
+
return LZString2.decompress(result.join(""));
|
|
31354
|
+
}
|
|
31355
|
+
},
|
|
31356
|
+
//compress into a string that is already URI encoded
|
|
31357
|
+
compressToEncodedURIComponent: function(input) {
|
|
31358
|
+
if (input == null) return "";
|
|
31359
|
+
return LZString2._compress(input, 6, function(a) {
|
|
31360
|
+
return keyStrUriSafe.charAt(a);
|
|
31361
|
+
});
|
|
31362
|
+
},
|
|
31363
|
+
//decompress from an output of compressToEncodedURIComponent
|
|
31364
|
+
decompressFromEncodedURIComponent: function(input) {
|
|
31365
|
+
if (input == null) return "";
|
|
31366
|
+
if (input == "") return null;
|
|
31367
|
+
input = input.replace(/ /g, "+");
|
|
31368
|
+
return LZString2._decompress(input.length, 32, function(index) {
|
|
31369
|
+
return getBaseValue(keyStrUriSafe, input.charAt(index));
|
|
31370
|
+
});
|
|
31371
|
+
},
|
|
31372
|
+
compress: function(uncompressed) {
|
|
31373
|
+
return LZString2._compress(uncompressed, 16, function(a) {
|
|
31374
|
+
return f(a);
|
|
31375
|
+
});
|
|
31376
|
+
},
|
|
31377
|
+
_compress: function(uncompressed, bitsPerChar, getCharFromInt) {
|
|
31378
|
+
if (uncompressed == null) return "";
|
|
31379
|
+
var i, value, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
|
|
31380
|
+
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
31381
|
+
context_c = uncompressed.charAt(ii);
|
|
31382
|
+
if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
|
|
31383
|
+
context_dictionary[context_c] = context_dictSize++;
|
|
31384
|
+
context_dictionaryToCreate[context_c] = true;
|
|
31385
|
+
}
|
|
31386
|
+
context_wc = context_w + context_c;
|
|
31387
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) {
|
|
31388
|
+
context_w = context_wc;
|
|
31389
|
+
} else {
|
|
31390
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
31391
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
31392
|
+
for (i = 0; i < context_numBits; i++) {
|
|
31393
|
+
context_data_val = context_data_val << 1;
|
|
31394
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31395
|
+
context_data_position = 0;
|
|
31396
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31397
|
+
context_data_val = 0;
|
|
31398
|
+
} else {
|
|
31399
|
+
context_data_position++;
|
|
31400
|
+
}
|
|
31401
|
+
}
|
|
31402
|
+
value = context_w.charCodeAt(0);
|
|
31403
|
+
for (i = 0; i < 8; i++) {
|
|
31404
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
31405
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31406
|
+
context_data_position = 0;
|
|
31407
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31408
|
+
context_data_val = 0;
|
|
31409
|
+
} else {
|
|
31410
|
+
context_data_position++;
|
|
31411
|
+
}
|
|
31412
|
+
value = value >> 1;
|
|
31413
|
+
}
|
|
31414
|
+
} else {
|
|
31415
|
+
value = 1;
|
|
31416
|
+
for (i = 0; i < context_numBits; i++) {
|
|
31417
|
+
context_data_val = context_data_val << 1 | value;
|
|
31418
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31419
|
+
context_data_position = 0;
|
|
31420
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31421
|
+
context_data_val = 0;
|
|
31422
|
+
} else {
|
|
31423
|
+
context_data_position++;
|
|
31424
|
+
}
|
|
31425
|
+
value = 0;
|
|
31426
|
+
}
|
|
31427
|
+
value = context_w.charCodeAt(0);
|
|
31428
|
+
for (i = 0; i < 16; i++) {
|
|
31429
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
31430
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31431
|
+
context_data_position = 0;
|
|
31432
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31433
|
+
context_data_val = 0;
|
|
31434
|
+
} else {
|
|
31435
|
+
context_data_position++;
|
|
31436
|
+
}
|
|
31437
|
+
value = value >> 1;
|
|
31438
|
+
}
|
|
31439
|
+
}
|
|
31440
|
+
context_enlargeIn--;
|
|
31441
|
+
if (context_enlargeIn == 0) {
|
|
31442
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
31443
|
+
context_numBits++;
|
|
31444
|
+
}
|
|
31445
|
+
delete context_dictionaryToCreate[context_w];
|
|
31446
|
+
} else {
|
|
31447
|
+
value = context_dictionary[context_w];
|
|
31448
|
+
for (i = 0; i < context_numBits; i++) {
|
|
31449
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
31450
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31451
|
+
context_data_position = 0;
|
|
31452
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31453
|
+
context_data_val = 0;
|
|
31454
|
+
} else {
|
|
31455
|
+
context_data_position++;
|
|
31456
|
+
}
|
|
31457
|
+
value = value >> 1;
|
|
31458
|
+
}
|
|
31459
|
+
}
|
|
31460
|
+
context_enlargeIn--;
|
|
31461
|
+
if (context_enlargeIn == 0) {
|
|
31462
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
31463
|
+
context_numBits++;
|
|
31464
|
+
}
|
|
31465
|
+
context_dictionary[context_wc] = context_dictSize++;
|
|
31466
|
+
context_w = String(context_c);
|
|
31467
|
+
}
|
|
31468
|
+
}
|
|
31469
|
+
if (context_w !== "") {
|
|
31470
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
31471
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
31472
|
+
for (i = 0; i < context_numBits; i++) {
|
|
31473
|
+
context_data_val = context_data_val << 1;
|
|
31474
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31475
|
+
context_data_position = 0;
|
|
31476
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31477
|
+
context_data_val = 0;
|
|
31478
|
+
} else {
|
|
31479
|
+
context_data_position++;
|
|
31480
|
+
}
|
|
31481
|
+
}
|
|
31482
|
+
value = context_w.charCodeAt(0);
|
|
31483
|
+
for (i = 0; i < 8; i++) {
|
|
31484
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
31485
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31486
|
+
context_data_position = 0;
|
|
31487
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31488
|
+
context_data_val = 0;
|
|
31489
|
+
} else {
|
|
31490
|
+
context_data_position++;
|
|
31491
|
+
}
|
|
31492
|
+
value = value >> 1;
|
|
31493
|
+
}
|
|
31494
|
+
} else {
|
|
31495
|
+
value = 1;
|
|
31496
|
+
for (i = 0; i < context_numBits; i++) {
|
|
31497
|
+
context_data_val = context_data_val << 1 | value;
|
|
31498
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31499
|
+
context_data_position = 0;
|
|
31500
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31501
|
+
context_data_val = 0;
|
|
31502
|
+
} else {
|
|
31503
|
+
context_data_position++;
|
|
31504
|
+
}
|
|
31505
|
+
value = 0;
|
|
31506
|
+
}
|
|
31507
|
+
value = context_w.charCodeAt(0);
|
|
31508
|
+
for (i = 0; i < 16; i++) {
|
|
31509
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
31510
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31511
|
+
context_data_position = 0;
|
|
31512
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31513
|
+
context_data_val = 0;
|
|
31514
|
+
} else {
|
|
31515
|
+
context_data_position++;
|
|
31516
|
+
}
|
|
31517
|
+
value = value >> 1;
|
|
31518
|
+
}
|
|
31519
|
+
}
|
|
31520
|
+
context_enlargeIn--;
|
|
31521
|
+
if (context_enlargeIn == 0) {
|
|
31522
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
31523
|
+
context_numBits++;
|
|
31524
|
+
}
|
|
31525
|
+
delete context_dictionaryToCreate[context_w];
|
|
31526
|
+
} else {
|
|
31527
|
+
value = context_dictionary[context_w];
|
|
31528
|
+
for (i = 0; i < context_numBits; i++) {
|
|
31529
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
31530
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31531
|
+
context_data_position = 0;
|
|
31532
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31533
|
+
context_data_val = 0;
|
|
31534
|
+
} else {
|
|
31535
|
+
context_data_position++;
|
|
31536
|
+
}
|
|
31537
|
+
value = value >> 1;
|
|
31538
|
+
}
|
|
31539
|
+
}
|
|
31540
|
+
context_enlargeIn--;
|
|
31541
|
+
if (context_enlargeIn == 0) {
|
|
31542
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
31543
|
+
context_numBits++;
|
|
31544
|
+
}
|
|
31545
|
+
}
|
|
31546
|
+
value = 2;
|
|
31547
|
+
for (i = 0; i < context_numBits; i++) {
|
|
31548
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
31549
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31550
|
+
context_data_position = 0;
|
|
31551
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31552
|
+
context_data_val = 0;
|
|
31553
|
+
} else {
|
|
31554
|
+
context_data_position++;
|
|
31555
|
+
}
|
|
31556
|
+
value = value >> 1;
|
|
31557
|
+
}
|
|
31558
|
+
while (true) {
|
|
31559
|
+
context_data_val = context_data_val << 1;
|
|
31560
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
31561
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
31562
|
+
break;
|
|
31563
|
+
} else context_data_position++;
|
|
31564
|
+
}
|
|
31565
|
+
return context_data.join("");
|
|
31566
|
+
},
|
|
31567
|
+
decompress: function(compressed) {
|
|
31568
|
+
if (compressed == null) return "";
|
|
31569
|
+
if (compressed == "") return null;
|
|
31570
|
+
return LZString2._decompress(compressed.length, 32768, function(index) {
|
|
31571
|
+
return compressed.charCodeAt(index);
|
|
31572
|
+
});
|
|
31573
|
+
},
|
|
31574
|
+
_decompress: function(length, resetValue, getNextValue) {
|
|
31575
|
+
var dictionary = [], next, enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = { val: getNextValue(0), position: resetValue, index: 1 };
|
|
31576
|
+
for (i = 0; i < 3; i += 1) {
|
|
31577
|
+
dictionary[i] = i;
|
|
31578
|
+
}
|
|
31579
|
+
bits = 0;
|
|
31580
|
+
maxpower = Math.pow(2, 2);
|
|
31581
|
+
power = 1;
|
|
31582
|
+
while (power != maxpower) {
|
|
31583
|
+
resb = data.val & data.position;
|
|
31584
|
+
data.position >>= 1;
|
|
31585
|
+
if (data.position == 0) {
|
|
31586
|
+
data.position = resetValue;
|
|
31587
|
+
data.val = getNextValue(data.index++);
|
|
31588
|
+
}
|
|
31589
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
31590
|
+
power <<= 1;
|
|
31591
|
+
}
|
|
31592
|
+
switch (next = bits) {
|
|
31593
|
+
case 0:
|
|
31594
|
+
bits = 0;
|
|
31595
|
+
maxpower = Math.pow(2, 8);
|
|
31596
|
+
power = 1;
|
|
31597
|
+
while (power != maxpower) {
|
|
31598
|
+
resb = data.val & data.position;
|
|
31599
|
+
data.position >>= 1;
|
|
31600
|
+
if (data.position == 0) {
|
|
31601
|
+
data.position = resetValue;
|
|
31602
|
+
data.val = getNextValue(data.index++);
|
|
31603
|
+
}
|
|
31604
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
31605
|
+
power <<= 1;
|
|
31606
|
+
}
|
|
31607
|
+
c = f(bits);
|
|
31608
|
+
break;
|
|
31609
|
+
case 1:
|
|
31610
|
+
bits = 0;
|
|
31611
|
+
maxpower = Math.pow(2, 16);
|
|
31612
|
+
power = 1;
|
|
31613
|
+
while (power != maxpower) {
|
|
31614
|
+
resb = data.val & data.position;
|
|
31615
|
+
data.position >>= 1;
|
|
31616
|
+
if (data.position == 0) {
|
|
31617
|
+
data.position = resetValue;
|
|
31618
|
+
data.val = getNextValue(data.index++);
|
|
31619
|
+
}
|
|
31620
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
31621
|
+
power <<= 1;
|
|
31622
|
+
}
|
|
31623
|
+
c = f(bits);
|
|
31624
|
+
break;
|
|
31625
|
+
case 2:
|
|
31626
|
+
return "";
|
|
31627
|
+
}
|
|
31628
|
+
dictionary[3] = c;
|
|
31629
|
+
w = c;
|
|
31630
|
+
result.push(c);
|
|
31631
|
+
while (true) {
|
|
31632
|
+
if (data.index > length) {
|
|
31633
|
+
return "";
|
|
31634
|
+
}
|
|
31635
|
+
bits = 0;
|
|
31636
|
+
maxpower = Math.pow(2, numBits);
|
|
31637
|
+
power = 1;
|
|
31638
|
+
while (power != maxpower) {
|
|
31639
|
+
resb = data.val & data.position;
|
|
31640
|
+
data.position >>= 1;
|
|
31641
|
+
if (data.position == 0) {
|
|
31642
|
+
data.position = resetValue;
|
|
31643
|
+
data.val = getNextValue(data.index++);
|
|
31644
|
+
}
|
|
31645
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
31646
|
+
power <<= 1;
|
|
31647
|
+
}
|
|
31648
|
+
switch (c = bits) {
|
|
31649
|
+
case 0:
|
|
31650
|
+
bits = 0;
|
|
31651
|
+
maxpower = Math.pow(2, 8);
|
|
31652
|
+
power = 1;
|
|
31653
|
+
while (power != maxpower) {
|
|
31654
|
+
resb = data.val & data.position;
|
|
31655
|
+
data.position >>= 1;
|
|
31656
|
+
if (data.position == 0) {
|
|
31657
|
+
data.position = resetValue;
|
|
31658
|
+
data.val = getNextValue(data.index++);
|
|
31659
|
+
}
|
|
31660
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
31661
|
+
power <<= 1;
|
|
31662
|
+
}
|
|
31663
|
+
dictionary[dictSize++] = f(bits);
|
|
31664
|
+
c = dictSize - 1;
|
|
31665
|
+
enlargeIn--;
|
|
31666
|
+
break;
|
|
31667
|
+
case 1:
|
|
31668
|
+
bits = 0;
|
|
31669
|
+
maxpower = Math.pow(2, 16);
|
|
31670
|
+
power = 1;
|
|
31671
|
+
while (power != maxpower) {
|
|
31672
|
+
resb = data.val & data.position;
|
|
31673
|
+
data.position >>= 1;
|
|
31674
|
+
if (data.position == 0) {
|
|
31675
|
+
data.position = resetValue;
|
|
31676
|
+
data.val = getNextValue(data.index++);
|
|
31677
|
+
}
|
|
31678
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
31679
|
+
power <<= 1;
|
|
31680
|
+
}
|
|
31681
|
+
dictionary[dictSize++] = f(bits);
|
|
31682
|
+
c = dictSize - 1;
|
|
31683
|
+
enlargeIn--;
|
|
31684
|
+
break;
|
|
31685
|
+
case 2:
|
|
31686
|
+
return result.join("");
|
|
31687
|
+
}
|
|
31688
|
+
if (enlargeIn == 0) {
|
|
31689
|
+
enlargeIn = Math.pow(2, numBits);
|
|
31690
|
+
numBits++;
|
|
31691
|
+
}
|
|
31692
|
+
if (dictionary[c]) {
|
|
31693
|
+
entry = dictionary[c];
|
|
31694
|
+
} else {
|
|
31695
|
+
if (c === dictSize) {
|
|
31696
|
+
entry = w + w.charAt(0);
|
|
31697
|
+
} else {
|
|
31698
|
+
return null;
|
|
31699
|
+
}
|
|
31700
|
+
}
|
|
31701
|
+
result.push(entry);
|
|
31702
|
+
dictionary[dictSize++] = w + entry.charAt(0);
|
|
31703
|
+
enlargeIn--;
|
|
31704
|
+
w = entry;
|
|
31705
|
+
if (enlargeIn == 0) {
|
|
31706
|
+
enlargeIn = Math.pow(2, numBits);
|
|
31707
|
+
numBits++;
|
|
31708
|
+
}
|
|
31709
|
+
}
|
|
31710
|
+
}
|
|
31711
|
+
};
|
|
31712
|
+
return LZString2;
|
|
31713
|
+
})();
|
|
31714
|
+
if (typeof define === "function" && define.amd) {
|
|
31715
|
+
define(function() {
|
|
31716
|
+
return LZString;
|
|
31717
|
+
});
|
|
31718
|
+
} else if (typeof module !== "undefined" && module != null) {
|
|
31719
|
+
module.exports = LZString;
|
|
31720
|
+
} else if (typeof angular !== "undefined" && angular != null) {
|
|
31721
|
+
angular.module("LZString", []).factory("LZString", function() {
|
|
31722
|
+
return LZString;
|
|
31723
|
+
});
|
|
31724
|
+
}
|
|
31725
|
+
}
|
|
31726
|
+
});
|
|
31727
|
+
|
|
30948
31728
|
// src/index.ts
|
|
30949
31729
|
init_diagnostics();
|
|
30950
31730
|
|
|
@@ -31731,13 +32511,12 @@ init_colors();
|
|
|
31731
32511
|
init_palettes();
|
|
31732
32512
|
|
|
31733
32513
|
// src/sharing.ts
|
|
31734
|
-
|
|
31735
|
-
var { compressToEncodedURIComponent, decompressFromEncodedURIComponent } = lzString;
|
|
32514
|
+
var import_lz_string = __toESM(require_lz_string(), 1);
|
|
31736
32515
|
var DEFAULT_BASE_URL = "https://online.diagrammo.app";
|
|
31737
32516
|
var COMPRESSED_SIZE_LIMIT = 8192;
|
|
31738
32517
|
function encodeDiagramUrl(dsl, options) {
|
|
31739
32518
|
const baseUrl = options?.baseUrl ?? DEFAULT_BASE_URL;
|
|
31740
|
-
const compressed = compressToEncodedURIComponent(dsl);
|
|
32519
|
+
const compressed = (0, import_lz_string.compressToEncodedURIComponent)(dsl);
|
|
31741
32520
|
const byteSize = new TextEncoder().encode(compressed).byteLength;
|
|
31742
32521
|
if (byteSize > COMPRESSED_SIZE_LIMIT) {
|
|
31743
32522
|
return {
|
|
@@ -31808,7 +32587,7 @@ function decodeDiagramUrl(hash) {
|
|
|
31808
32587
|
}
|
|
31809
32588
|
if (!payload) return { dsl: "", viewState, filename };
|
|
31810
32589
|
try {
|
|
31811
|
-
const result = decompressFromEncodedURIComponent(payload);
|
|
32590
|
+
const result = (0, import_lz_string.decompressFromEncodedURIComponent)(payload);
|
|
31812
32591
|
return { dsl: result ?? "", viewState, filename };
|
|
31813
32592
|
} catch {
|
|
31814
32593
|
return { dsl: "", viewState, filename };
|