@diagrammo/dgmo 0.25.3 → 0.25.4

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 (49) hide show
  1. package/package.json +1 -1
  2. package/src/cli.ts +0 -9
  3. package/src/d3.ts +180 -46
  4. package/src/render.ts +80 -39
  5. package/dist/advanced.cjs +0 -62454
  6. package/dist/advanced.d.cts +0 -5684
  7. package/dist/advanced.d.ts +0 -5684
  8. package/dist/advanced.js +0 -62207
  9. package/dist/auto.cjs +0 -59764
  10. package/dist/auto.css +0 -214
  11. package/dist/auto.d.cts +0 -39
  12. package/dist/auto.d.ts +0 -39
  13. package/dist/auto.js +0 -437
  14. package/dist/auto.mjs +0 -59774
  15. package/dist/cli.cjs +0 -465
  16. package/dist/editor.cjs +0 -432
  17. package/dist/editor.d.cts +0 -26
  18. package/dist/editor.d.ts +0 -26
  19. package/dist/editor.js +0 -401
  20. package/dist/highlight.cjs +0 -720
  21. package/dist/highlight.d.cts +0 -32
  22. package/dist/highlight.d.ts +0 -32
  23. package/dist/highlight.js +0 -690
  24. package/dist/index.cjs +0 -58950
  25. package/dist/index.d.cts +0 -375
  26. package/dist/index.d.ts +0 -375
  27. package/dist/index.js +0 -58954
  28. package/dist/internal.cjs +0 -62456
  29. package/dist/internal.d.cts +0 -5684
  30. package/dist/internal.d.ts +0 -5684
  31. package/dist/internal.js +0 -62207
  32. package/dist/map-data/PROVENANCE.json +0 -1
  33. package/dist/map-data/gazetteer.json +0 -1
  34. package/dist/map-data/lakes.json +0 -1
  35. package/dist/map-data/mountain-ranges.json +0 -1
  36. package/dist/map-data/na-lakes.json +0 -1
  37. package/dist/map-data/na-land.json +0 -1
  38. package/dist/map-data/region-names.json +0 -1
  39. package/dist/map-data/rivers.json +0 -1
  40. package/dist/map-data/us-states.json +0 -1
  41. package/dist/map-data/water-bodies.json +0 -1
  42. package/dist/map-data/world-coarse.json +0 -1
  43. package/dist/map-data/world-detail.json +0 -1
  44. package/dist/pert.cjs +0 -325
  45. package/dist/pert.d.cts +0 -554
  46. package/dist/pert.d.ts +0 -554
  47. package/dist/pert.js +0 -294
  48. package/src/editor/dgmo.grammar.js +0 -18
  49. package/src/editor/dgmo.grammar.terms.js +0 -35
package/dist/pert.js DELETED
@@ -1,294 +0,0 @@
1
- // src/pert/internal.ts
2
- var UNIT_TO_DAYS_LOCAL = {
3
- min: 1 / (60 * 24),
4
- h: 1 / 24,
5
- d: 1,
6
- bd: 1,
7
- // PERT has no calendar; bd ≈ d for analytical purposes
8
- w: 7,
9
- m: 30,
10
- q: 90,
11
- y: 365,
12
- s: 14
13
- // sprint (14 calendar days) — not seconds
14
- };
15
- function unitToDays(unit) {
16
- return UNIT_TO_DAYS_LOCAL[unit];
17
- }
18
-
19
- // src/pert/monte-carlo.ts
20
- function lagDays(lag) {
21
- return lag === null ? 0 : lag.amount * unitToDays(lag.unit);
22
- }
23
- function mulberry32(seed) {
24
- let s = seed >>> 0;
25
- return () => {
26
- s = s + 1831565813 >>> 0;
27
- let t = s;
28
- t = Math.imul(t ^ t >>> 15, t | 1);
29
- t ^= t + Math.imul(t ^ t >>> 7, t | 61);
30
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
31
- };
32
- }
33
- function standardNormal(rng) {
34
- let u = 0;
35
- let v = 0;
36
- while (u === 0) u = rng();
37
- while (v === 0) v = rng();
38
- return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v);
39
- }
40
- function gamma(shape, rng) {
41
- if (shape < 1) {
42
- const u = rng();
43
- return gamma(shape + 1, rng) * Math.pow(u, 1 / shape);
44
- }
45
- const d = shape - 1 / 3;
46
- const c = 1 / Math.sqrt(9 * d);
47
- while (true) {
48
- let x;
49
- let v;
50
- do {
51
- x = standardNormal(rng);
52
- v = 1 + c * x;
53
- } while (v <= 0);
54
- v = v * v * v;
55
- const u = rng();
56
- if (u < 1 - 0.0331 * x * x * x * x) return d * v;
57
- if (Math.log(u) < x * x / 2 + d * (1 - v + Math.log(v))) return d * v;
58
- }
59
- }
60
- function sampleBeta(alpha, beta, rng) {
61
- const x = gamma(alpha, rng);
62
- const y = gamma(beta, rng);
63
- return x / (x + y);
64
- }
65
- function sampleBetaPert(o, m, p, rng) {
66
- if (o === p) return m;
67
- const range = p - o;
68
- const alpha = 1 + 4 * (m - o) / range;
69
- const beta = 1 + 4 * (p - m) / range;
70
- return o + sampleBeta(alpha, beta, rng) * range;
71
- }
72
- function simulate(resolved, expanded, _predecessors, _successors, topo, terminals, poisoned, opts) {
73
- const rng = mulberry32(opts.seed);
74
- const expById = /* @__PURE__ */ new Map();
75
- for (const e of expanded) expById.set(e.id, e);
76
- const completionTimes = new Array(opts.trials);
77
- const criticalityCount = /* @__PURE__ */ new Map();
78
- for (const id of topo) criticalityCount.set(id, 0);
79
- const pathCount = /* @__PURE__ */ new Map();
80
- const pathById = /* @__PURE__ */ new Map();
81
- const incomingEdges = /* @__PURE__ */ new Map();
82
- for (const id of topo) incomingEdges.set(id, []);
83
- for (const e of resolved.edges) incomingEdges.get(e.target)?.push(e);
84
- const es = /* @__PURE__ */ new Map();
85
- const ef = /* @__PURE__ */ new Map();
86
- const predOnLongestPath = /* @__PURE__ */ new Map();
87
- for (let trial = 0; trial < opts.trials; trial++) {
88
- for (const id of topo) {
89
- const exp = expById.get(id);
90
- let duration;
91
- if (!exp || poisoned.has(id)) {
92
- duration = 0;
93
- } else if (exp.o === exp.p) {
94
- duration = exp.m;
95
- } else {
96
- duration = sampleBetaPert(exp.o, exp.m, exp.p, rng);
97
- }
98
- let esLower = 0;
99
- let efLower = -Infinity;
100
- let bestPred = null;
101
- let bestPredVal = -Infinity;
102
- for (const edge of incomingEdges.get(id) ?? []) {
103
- const aEs = es.get(edge.source) ?? 0;
104
- const aEf = ef.get(edge.source) ?? 0;
105
- const lag = lagDays(edge.lag);
106
- let candES = -Infinity;
107
- let candEF = -Infinity;
108
- switch (edge.type) {
109
- case "FS":
110
- candES = aEf + lag;
111
- break;
112
- case "SS":
113
- candES = aEs + lag;
114
- break;
115
- case "FF":
116
- candEF = aEf + lag;
117
- break;
118
- case "SF":
119
- candEF = aEs + lag;
120
- break;
121
- }
122
- if (candES > esLower) esLower = candES;
123
- if (candEF > efLower) efLower = candEF;
124
- const contribution = Math.max(candES, candEF - duration);
125
- if (contribution > bestPredVal) {
126
- bestPredVal = contribution;
127
- bestPred = edge.source;
128
- }
129
- }
130
- let esVal = esLower;
131
- let efVal = esVal + duration;
132
- if (efLower > efVal) {
133
- efVal = efLower;
134
- esVal = efVal - duration;
135
- }
136
- es.set(id, esVal);
137
- ef.set(id, efVal);
138
- predOnLongestPath.set(id, bestPred);
139
- }
140
- let endEf = 0;
141
- let endId = terminals[0] ?? null;
142
- for (const id of topo) {
143
- const e = ef.get(id) ?? 0;
144
- if (e > endEf) {
145
- endEf = e;
146
- endId = id;
147
- }
148
- }
149
- completionTimes[trial] = endEf;
150
- if (endId !== null) {
151
- const path = [];
152
- let cur = endId;
153
- while (cur !== null) {
154
- path.unshift(cur);
155
- criticalityCount.set(cur, (criticalityCount.get(cur) ?? 0) + 1);
156
- cur = predOnLongestPath.get(cur) ?? null;
157
- }
158
- const key = path.join("\0");
159
- pathCount.set(key, (pathCount.get(key) ?? 0) + 1);
160
- if (!pathById.has(key)) pathById.set(key, path);
161
- }
162
- }
163
- completionTimes.sort((a, b) => a - b);
164
- const pct = (frac) => {
165
- const idx = Math.min(
166
- completionTimes.length - 1,
167
- Math.max(0, Math.floor(frac * completionTimes.length))
168
- );
169
- return completionTimes[idx] ?? 0;
170
- };
171
- const minDurationDays = completionTimes[0] ?? 0;
172
- const maxDurationDays = completionTimes[completionTimes.length - 1] ?? 0;
173
- let modalKey = "";
174
- let modalCount = -1;
175
- for (const [key, count] of pathCount) {
176
- if (count > modalCount) {
177
- modalCount = count;
178
- modalKey = key;
179
- } else if (count === modalCount) {
180
- const a = pathById.get(modalKey) ?? [];
181
- const b = pathById.get(key) ?? [];
182
- const va = pathVariance(a, expById);
183
- const vb = pathVariance(b, expById);
184
- if (vb > va) {
185
- modalKey = key;
186
- } else if (vb === va && key.localeCompare(modalKey) < 0) {
187
- modalKey = key;
188
- }
189
- }
190
- }
191
- const criticalityByActivity = {};
192
- for (const id of topo) {
193
- criticalityByActivity[id] = (criticalityCount.get(id) ?? 0) / opts.trials;
194
- }
195
- return {
196
- trials: opts.trials,
197
- seed: opts.seed,
198
- p50: pct(0.5),
199
- p80: pct(0.8),
200
- p95: pct(0.95),
201
- p16: pct(0.16),
202
- p84: pct(0.84),
203
- criticalityByActivity,
204
- modalCriticalPath: pathById.get(modalKey) ?? [],
205
- // Analyzer populates this after MC returns by running the
206
- // deterministic per-activity tornado pass. Empty here so the
207
- // type contract is satisfied even in scrubber/fast paths that
208
- // never compute swings.
209
- tornadoSwings: [],
210
- minDurationDays,
211
- maxDurationDays
212
- };
213
- }
214
- function pathVariance(path, expById) {
215
- let sum = 0;
216
- for (const id of path) {
217
- const e = expById.get(id);
218
- if (!e) continue;
219
- const sigma = (e.p - e.o) / 6;
220
- sum += sigma * sigma;
221
- }
222
- return sum;
223
- }
224
- function buildSimulationContext(resolved) {
225
- const predecessors = /* @__PURE__ */ new Map();
226
- const successors = /* @__PURE__ */ new Map();
227
- for (const r of resolved.activities) {
228
- predecessors.set(r.activity.id, []);
229
- successors.set(r.activity.id, []);
230
- }
231
- for (const e of resolved.edges) {
232
- successors.get(e.source)?.push(e.target);
233
- predecessors.get(e.target)?.push(e.source);
234
- }
235
- const inDegree = /* @__PURE__ */ new Map();
236
- for (const r of resolved.activities) {
237
- inDegree.set(r.activity.id, predecessors.get(r.activity.id).length);
238
- }
239
- const queue = [];
240
- for (const [id, deg] of inDegree) if (deg === 0) queue.push(id);
241
- const topo = [];
242
- while (queue.length > 0) {
243
- const id = queue.shift();
244
- topo.push(id);
245
- for (const next of successors.get(id) ?? []) {
246
- const deg = (inDegree.get(next) ?? 0) - 1;
247
- inDegree.set(next, deg);
248
- if (deg === 0) queue.push(next);
249
- }
250
- }
251
- const terminals = [];
252
- for (const r of resolved.activities) {
253
- if ((successors.get(r.activity.id) ?? []).length === 0) {
254
- terminals.push(r.activity.id);
255
- }
256
- }
257
- const poisoned = /* @__PURE__ */ new Set();
258
- for (const r of resolved.activities) {
259
- if (r.activity.duration === null) {
260
- const stack = [r.activity.id];
261
- while (stack.length > 0) {
262
- const id = stack.pop();
263
- if (poisoned.has(id)) continue;
264
- poisoned.add(id);
265
- for (const next of successors.get(id) ?? []) stack.push(next);
266
- }
267
- }
268
- }
269
- return { predecessors, successors, topo, terminals, poisoned };
270
- }
271
- function simulateCanonical(resolved, expanded, opts) {
272
- const ctx = buildSimulationContext(resolved);
273
- return simulate(
274
- resolved,
275
- expanded,
276
- ctx.predecessors,
277
- ctx.successors,
278
- ctx.topo,
279
- ctx.terminals,
280
- ctx.poisoned,
281
- { trials: opts.trials, seed: opts.seed }
282
- );
283
- }
284
- function simulateFast(resolved, expanded, opts) {
285
- return simulateCanonical(resolved, expanded, opts);
286
- }
287
- export {
288
- buildSimulationContext,
289
- mulberry32,
290
- sampleBetaPert,
291
- simulateCanonical,
292
- simulateFast
293
- };
294
- //# sourceMappingURL=pert.js.map
@@ -1,18 +0,0 @@
1
- // This file was generated by lezer-generator. You probably shouldn't edit it.
2
- import {LRParser} from "@lezer/lr"
3
- import {specializeKeyword} from "./tokens"
4
- export const parser = LRParser.deserialize({
5
- version: 14,
6
- states: "!WQVQPOOOOQO'#DU'#DUOOQO'#DP'#DPO%]QPO'#CdOOQO'#DO'#DOQVQPOOOOQO-E6}-E6}OOQO,59O,59OOOQO-E6|-E6|",
7
- stateData: "&Q~OvOS~OPPOQPORPOSPOTPOVSOXPOYPOZPO[PO]PO^PO_PO`POaPObPOcPOdPOePOfPOgPOhPOiPOjPOkPOlPOmPOnPOoPOpPOqPOwSO~OPPOQPORPOSPOTPOXPOYPOZPO[PO]PO^PO_PO`POaPObPOcPOdPOePOfPOgPOhPOiPOjPOkPOlPOmPOnPOoPOpPOqPO~OwVO~P#]OVXYZ[]^_`ghijklmnabcdefopqk~",
8
- goto: "!byPPPPPPPPzPPPPPPPPPPPPPPPPPPPPPPPPP!O!UPPPP!]TSOTQTORWTSROTRURVQORT",
9
- nodeNames: "⚠ ChartType TagKeyword DirectiveKeyword ControlKeyword ModifierKeyword Document Comment ContentLine SyncArrow AsyncArrow Duration DateLiteral Percentage Number SectionMarker Url OpenBracket CloseBracket OpenParen CloseParen OpenAngle CloseAngle Pipe Colon Comma Plus Dash Tilde Star Question QuotedString Identifier Punct",
10
- maxTerm: 40,
11
- skippedNodes: [0],
12
- repeatNodeCount: 2,
13
- tokenData: "<v~RzOX#uXY#zYZ$VZp#upq#zqr#urs$[st#uux#uxy%eyz%lz{%s{|%z|}&R}!O&Y!O!P#u!P!Q&i!Q!['Y![!]/{!]!^#u!^!_0S!_!`0Z!`!a0h!a!b0o!b!c#u!c!}0v!}#O3|#O#P#u#P#Q4R#Q#R#u#R#S0v#S#T#u#T#[0v#[#]4Y#]#o0v#o#p#u#p#q<Y#q#r#u#r#s<a#s;'S#u;'S;=`<p<%lO#u~#zOq~~$PQv~XY#zpq#z~$[Ow~~$aUq~OY$sZr$srs%Ys;'S$s;'S;=`%_<%lO$s~$vUOY$sZr$srs%Ys;'S$s;'S;=`%_<%lO$s~%_Oo~~%bP;=`<%l$s~%lOc~q~~%sOd~q~~%zOm~q~~&ROj~q~~&YOi~q~~&aPk~q~!`!a&d~&iOX~~&nPq~!P!Q&q~&vSV~OY&qZ;'S&q;'S;=`'S<%lO&q~'VP;=`<%l&q~'a]^~q~uv(Y|}(_!O!P)[!Q![*{#R#S/g#U#V*V#W#X*]#[#]*]#a#b*j#e#f*]#g#h*]#k#l*]#m#n*]~(_O]~~(bP!Q![(e~(hP!Q![(k~(nP!Q![(q~(vQ^~|}(_!O!P(|~)PP!Q![)S~)XP^~!Q![)S~)_P!Q![)b~)gY^~uv(Y!Q![)b#U#V*V#W#X*]#[#]*]#a#b*j#e#f*]#g#h*]#k#l*]#m#n*]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!Q![1|!_!`1|!a!b1|!b!c1|!c!}1|#R#S1|#T#d1|#d#e7z#e#o1|~8Pbp~qr1|st1|vw1|wx1|{|1|}!O3Q!O!P1|!P!Q1|!Q![1|![!]9X!_!`1|!a!b1|!b!c1|!c!}1|#R#S1|#T#g1|#g#h;R#h#o1|~9[P!P!Q9_~9bP!P!Q9e~9hYOX:WZp:Wqy:Wz|:W}!`:W!a#P:W#Q#p:W#q;'S:W;'S;=`:{<%lO:W~:]Y`~OX:WZp:Wqy:Wz|:W}!`:W!a#P:W#Q#p:W#q;'S:W;'S;=`:{<%lO:W~;OP;=`<%l:W~;W`p~qr1|st1|vw1|wx1|{|1|}!O3Q!O!P1|!P!Q1|!Q![1|![!]9X!_!`1|!a!b1|!b!c1|!c!}1|#R#S1|#T#o1|~<aOg~q~~<hPl~q~!`!a<k~<pOY~~<sP;=`<%l#u",
14
- tokenizers: [0],
15
- topRules: {"Document":[0,6]},
16
- specialized: [{term: 32, get: (value, stack) => (specializeKeyword(value, stack) << 1), external: specializeKeyword}],
17
- tokenPrec: 204
18
- })
@@ -1,35 +0,0 @@
1
- // This file was generated by lezer-generator. You probably shouldn't edit it.
2
- export const
3
- ChartType = 1,
4
- TagKeyword = 2,
5
- DirectiveKeyword = 3,
6
- ControlKeyword = 4,
7
- ModifierKeyword = 5,
8
- Document = 6,
9
- Comment = 7,
10
- ContentLine = 8,
11
- SyncArrow = 9,
12
- AsyncArrow = 10,
13
- Duration = 11,
14
- DateLiteral = 12,
15
- Percentage = 13,
16
- Number = 14,
17
- SectionMarker = 15,
18
- Url = 16,
19
- OpenBracket = 17,
20
- CloseBracket = 18,
21
- OpenParen = 19,
22
- CloseParen = 20,
23
- OpenAngle = 21,
24
- CloseAngle = 22,
25
- Pipe = 23,
26
- Colon = 24,
27
- Comma = 25,
28
- Plus = 26,
29
- Dash = 27,
30
- Tilde = 28,
31
- Star = 29,
32
- Question = 30,
33
- QuotedString = 31,
34
- Identifier = 32,
35
- Punct = 33