@popcorn245/cornfield-components 0.51.8 → 0.52.1

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 (33) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/around-BFqYTZ0K.js +78 -0
  3. package/dist/chunks/corn-layers-Cni5rISZ.js +275 -0
  4. package/dist/chunks/{corn-map-M7xt4MYk.js → corn-map-B2-YxiEL.js} +8 -5
  5. package/dist/chunks/corn-node-panel-BkvJThlp.js +42 -0
  6. package/dist/chunks/{corn-review-yQU3IpY5.js → corn-review-5wf7AT4o.js} +1047 -2564
  7. package/dist/chunks/corn-search-CXs5d06S.js +484 -0
  8. package/dist/chunks/{engine-ClfnAsgM.js → engine-BmXtSISH.js} +3691 -3577
  9. package/dist/chunks/layers-Bj4Tluxe.js +191 -0
  10. package/dist/chunks/{map-LS9aQk6z.js → map-BZRFOYkt.js} +803 -751
  11. package/dist/chunks/node-panel-BdvFvWCE.js +1291 -0
  12. package/dist/chunks/{review-source-CPiFTfyc.js → review-source-CK5tYIqk.js} +1 -1
  13. package/dist/chunks/{scope-Dg_uzefP.js → scope-CqPbHcKL.js} +24 -23
  14. package/dist/chunks/sheets-D-sMZzSs.js +204 -0
  15. package/dist/chunks/source-address-C70zNPIj.js +79 -0
  16. package/dist/chunks/{status-CYQD5PwL.js → status-DI5QLlAp.js} +78 -77
  17. package/dist/corn-layers.js +1 -0
  18. package/dist/corn-map.js +1 -1
  19. package/dist/corn-node-panel.js +1 -0
  20. package/dist/corn-review.js +1 -1
  21. package/dist/corn-scope.js +3 -3
  22. package/dist/corn-search.js +1 -0
  23. package/dist/index.js +8 -5
  24. package/dist/manifest.json +101 -36
  25. package/dist/tokens.css +8 -2
  26. package/dist/types/components.d.ts +90 -0
  27. package/dist/types/corn-layers.d.ts +2 -0
  28. package/dist/types/corn-node-panel.d.ts +2 -0
  29. package/dist/types/corn-search.d.ts +2 -0
  30. package/dist/types/index.d.ts +3 -0
  31. package/dist/version.json +1 -1
  32. package/package.json +14 -2
  33. package/dist/chunks/source-address-B7hYRgt8.js +0 -251
@@ -0,0 +1,191 @@
1
+ import { E as e, N as t, O as n, ft as r, gt as i, ht as a, l as o, lt as s, o as c, ot as l, pt as u, qt as d, tt as f, ut as p, wt as m } from "./engine-BmXtSISH.js";
2
+ // ../explorer/engine/layers.js
3
+ var h = (e) => e.match && e.match.type ? [].concat(e.match.type) : [], g = {
4
+ flow: "#fb923c",
5
+ runs: "#5eead4"
6
+ }, _ = (e) => {
7
+ let t = h(e)[0];
8
+ return t && m[t] ? m[t].color : g[e.key];
9
+ }, v = /* @__PURE__ */ new Set([
10
+ "stack",
11
+ "machine",
12
+ "container",
13
+ "device",
14
+ "house",
15
+ "persona"
16
+ ]), y = r.map((e) => ({
17
+ ...e,
18
+ color: _(e)
19
+ })), b = "cornfield:layers", x = /^[a-z][a-z0-9-]{0,40}$/, S = (e) => e.slot("layers", () => ({
20
+ changes: {},
21
+ storeKey: b
22
+ }));
23
+ function C(e, t) {
24
+ S(e).storeKey = t;
25
+ }
26
+ var w = (e, t) => Object.hasOwn(e.state.layerDefaults, t) ? e.state.layerDefaults[t] : !v.has(t), T = (e, t) => l(e.state, t), E = "#94a3b8", D = "\\d{1,3}(?:\\.\\d+)?%?", O = RegExp(`^(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\\(\\s*${D}(?:\\s*,\\s*|\\s+)${D}(?:\\s*,\\s*|\\s+)${D}(?:\\s*[,/]\\s*(?:\\d*\\.)?\\d+%?)?\\s*\\))$`, "i"), k = (e) => typeof e == "string" && e.length <= 64 && O.test(e.trim()) ? e.trim() : E;
27
+ function A(e, n, r) {
28
+ return k(c(o(e).get().values, n) || t(f(r, e.state.theme)));
29
+ }
30
+ var j = (e, t) => {
31
+ let n = h(t);
32
+ return n.length > 1 && n.find((t) => e.state.nodes.some((e) => e.type === t)) || n[0] || t.key;
33
+ };
34
+ function M(t) {
35
+ let { state: r } = t, o = (e) => {
36
+ let n = j(t, e);
37
+ return {
38
+ ...e,
39
+ color: A(t, {
40
+ type: n,
41
+ group: e.key
42
+ }, m[n] ? m[n].color : e.color)
43
+ };
44
+ }, s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
45
+ r.nodes.forEach((e) => {
46
+ let t = p(r, e);
47
+ if (!t) return;
48
+ s.add(t);
49
+ let n = i(e);
50
+ n !== t && c.add(n);
51
+ });
52
+ let l = (i) => {
53
+ let a = r.nodes.find((e) => p(r, e) === i.key);
54
+ return { color: A(t, a ? {
55
+ type: a.type,
56
+ layer: i.key,
57
+ group: n(a)
58
+ } : {
59
+ type: i.key,
60
+ layer: i.key
61
+ }, a ? e(a) : E) };
62
+ }, u = r.projectLayers.filter((e) => s.has(e.key)).map((e) => ({
63
+ key: e.key,
64
+ label: e.label,
65
+ desc: e.desc || "",
66
+ project: !0,
67
+ ...l(e)
68
+ })), d = y.filter((e) => !e.overlay && (s.has(e.key) || !c.has(e.key))).map(o), f = /* @__PURE__ */ new Set([...y.map((e) => e.key), ...r.projectLayers.map((e) => e.key)]), h = [];
69
+ return s.forEach((e) => {
70
+ f.has(e) || (f.add(e), h.push({
71
+ key: e,
72
+ label: e.charAt(0).toUpperCase() + e.slice(1),
73
+ color: A(t, {
74
+ type: e,
75
+ group: e
76
+ }, E),
77
+ desc: `Nodes of the type ${e}`
78
+ }));
79
+ }), {
80
+ layers: [...a(u, d, r.layerOrder), ...h],
81
+ overlays: y.filter((e) => e.overlay).map(o)
82
+ };
83
+ }
84
+ function N(e) {
85
+ let t = S(e).storeKey;
86
+ if (!t) return {};
87
+ try {
88
+ let n = JSON.parse(e.store.get(t) || "{}");
89
+ return !n || typeof n != "object" || Array.isArray(n) ? {} : Object.fromEntries(Object.entries(n).filter(([e, t]) => x.test(e) && typeof t == "boolean"));
90
+ } catch {
91
+ return {};
92
+ }
93
+ }
94
+ function P(e) {
95
+ let { changes: t, storeKey: n } = S(e);
96
+ n && (Object.keys(t).length ? e.store.set(n, JSON.stringify(t)) : e.store.remove(n));
97
+ }
98
+ function F(e, t, n) {
99
+ let { changes: r } = S(e);
100
+ n === w(e, t) ? delete r[t] : r[t] = n;
101
+ }
102
+ function I(e, t) {
103
+ let { state: n } = e, r = u(t);
104
+ n.projectLayers = r.add, n.layerOrder = r.order;
105
+ let i = {};
106
+ for (let e of y) i[e.key] = !v.has(e.key);
107
+ for (let e of r.add) i[e.key] = !0;
108
+ for (let e of r.off) i[e] = !1;
109
+ n.layerDefaults = i;
110
+ let a = S(e);
111
+ a.changes = N(e);
112
+ for (let [e, t] of Object.entries(i)) n.activeLayers[e] = t;
113
+ for (let [e, t] of Object.entries(a.changes)) n.activeLayers[e] = t;
114
+ V(e);
115
+ }
116
+ function L(e) {
117
+ let { state: t } = e, n = /* @__PURE__ */ new Set(), r = [];
118
+ t.nodes.forEach((e) => {
119
+ if (typeof e.kind != "string" || !e.kind) return;
120
+ let t = `${e.type}\u0000${e.kind}`;
121
+ n.has(t) || (n.add(t), r.push([e.type, e.kind]));
122
+ }), o(e).setSubjects({
123
+ kinds: r,
124
+ layers: t.projectLayers.map((e) => e.key)
125
+ });
126
+ }
127
+ function R(e) {
128
+ let t = e.slot("layers-draw", () => ({ drawing: !1 }));
129
+ t.drawing = !0;
130
+ try {
131
+ L(e);
132
+ } finally {
133
+ t.drawing = !1;
134
+ }
135
+ e.emit("layers:redraw");
136
+ }
137
+ var z = (e) => e.slot("layers-draw", () => ({ drawing: !1 })).drawing, B = (e, t) => e.on("layers", t);
138
+ function V(e) {
139
+ e.touchScene(), e.emit("layers"), R(e), e.map && (e.map.render(), e.map.ensureFlowLoop());
140
+ }
141
+ function H(e, t, n, { viewer: r = !1, scenario: i = !1 } = {}) {
142
+ let { state: a } = e, o = a.review && a.proposal ? a.review : null;
143
+ if (o ? ((i ? o.step : o.manual)[t] = n, o.rev++) : (a.activeLayers[t] = n, r && (F(e, t, n), P(e))), V(e), r) {
144
+ let { layers: r, overlays: i } = M(e), s = [...r, ...i].find((e) => e.key === t), c = a.nodes.filter((t) => e.map.isNodeVisible(t)).length;
145
+ d(e, `${s ? s.label : t} ${n ? "on" : "off"}${o ? " for this review" : ""}. ${c} ${c === 1 ? "node" : "nodes"} shown.`);
146
+ }
147
+ }
148
+ function U(e, t, n = {}) {
149
+ H(e, t, !l(e.state, t), n);
150
+ }
151
+ function W(e, t, { viewer: n = !1 } = {}) {
152
+ let { state: r } = e, { layers: i } = M(e), a = /* @__PURE__ */ new Set([
153
+ ...y.filter((e) => !e.overlay).map((e) => e.key),
154
+ ...r.projectLayers.map((e) => e.key),
155
+ ...i.map((e) => e.key)
156
+ ]), o = r.review && r.proposal ? r.review : null;
157
+ if (o ? (a.forEach((e) => {
158
+ o.manual[e] = t;
159
+ }), o.rev++) : (a.forEach((i) => {
160
+ r.activeLayers[i] = t, n && F(e, i, t);
161
+ }), n && P(e)), V(e), n) {
162
+ let n = r.nodes.filter((t) => e.map.isNodeVisible(t)).length;
163
+ d(e, `${t ? "All" : "No"} layers on${o ? " for this review" : ""}. ${n} ${n === 1 ? "node" : "nodes"} shown.`);
164
+ }
165
+ }
166
+ function G(e) {
167
+ e.state.review = {
168
+ whole: !1,
169
+ manual: {},
170
+ step: {},
171
+ rev: 0
172
+ };
173
+ }
174
+ function K(e) {
175
+ e.state.review && (e.state.review = null, e.touchScene(), R(e));
176
+ }
177
+ function q(e) {
178
+ let { state: t } = e;
179
+ if (!t.review || !t.proposal || t.review.whole) return "";
180
+ let { layers: n } = M(e), r = new Set(t.nodes.map((e) => p(t, e)));
181
+ return n.some((e) => r.has(e.key) && s(t, e.key)) ? `Showing ${n.filter((t) => T(e, t.key)).length} of ${n.length} layers: the ones this proposal changes.` : "";
182
+ }
183
+ function J(e, t) {
184
+ let { state: n } = e, r = n.review && n.proposal ? n.review : null;
185
+ r && r.whole !== t && (r.whole = t, r.rev++, V(e), d(e, t ? "Showing the whole map." : q(e) || "Showing the change: the rest of the map is greyed."));
186
+ }
187
+ function Y(e) {
188
+ let { review: t } = e.state;
189
+ return !t || !Object.keys(t.step).length ? !1 : (t.step = {}, t.rev++, e.touchScene(), R(e), !0);
190
+ }
191
+ export { U as _, T as a, B as c, q as d, H as f, W as g, k as h, K as i, R as l, J as m, G as n, C as o, I as p, Y as r, M as s, y as t, z as u };