@diagrammo/dgmo 0.49.0 → 0.50.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/.cursorrules +6 -2
- package/.github/copilot-instructions.md +6 -2
- package/.windsurfrules +6 -2
- package/SKILL.md +6 -2
- package/dist/advanced.d.ts +419 -12
- package/dist/advanced.js +557 -195
- package/dist/auto.js +129 -119
- package/dist/auto.mjs +11543 -4815
- package/dist/block.js +145 -48
- package/dist/{charts-d3-EW3YQTEA.js → charts-d3-DKUD7MQE.js} +5 -5
- package/dist/{chunk-5FGDJIJX.js → chunk-2C56LEML.js} +3 -3
- package/dist/{chunk-35BBZDFE.js → chunk-2JJ2KNPI.js} +4 -4
- package/dist/{chunk-ZTLWVRNS.js → chunk-2QYTMIRR.js} +2 -2
- package/dist/{chunk-VC3TR4NL.js → chunk-3G6TMNVF.js} +3 -3
- package/dist/{chunk-ZDUQGL3N.js → chunk-3LKM6FMW.js} +2 -2
- package/dist/{chunk-4BD7EVPK.js → chunk-3P2DKJCG.js} +2 -2
- package/dist/{chunk-6CLKNXVP.js → chunk-3TDRHT4J.js} +457 -78
- package/dist/chunk-3XPUDB7B.js +420 -0
- package/dist/{chunk-DDTJ5N7Q.js → chunk-3ZPC476N.js} +6 -6
- package/dist/{chunk-BPIJLRYE.js → chunk-4BMJQFNK.js} +3 -3
- package/dist/{chunk-N4J5KGWG.js → chunk-4S723I74.js} +8 -8
- package/dist/{chunk-4YNP6O47.js → chunk-5JSWBPZZ.js} +3 -3
- package/dist/{chunk-KUBBJ2CD.js → chunk-5Z736BSU.js} +6 -6
- package/dist/{chunk-MJCG5K2O.js → chunk-6BFZKBGD.js} +2 -2
- package/dist/{chunk-XCC2RENT.js → chunk-6IAA2QQ2.js} +2 -2
- package/dist/{chunk-FUCAB3KQ.js → chunk-6M5PJFQG.js} +3 -3
- package/dist/{chunk-T7IKPCMI.js → chunk-6X4AKWLF.js} +3 -3
- package/dist/{chunk-JFPY3UJ7.js → chunk-6ZT4U37Q.js} +8 -8
- package/dist/{chunk-CLR4A2N2.js → chunk-7G2ER4CY.js} +4 -4
- package/dist/chunk-7PQYTZMA.js +681 -0
- package/dist/{chunk-LG4TWW4U.js → chunk-7RB5Q6MB.js} +8 -8
- package/dist/{chunk-7OVSJI2V.js → chunk-A3WQVFBS.js} +3 -3
- package/dist/{chunk-X2CH42BN.js → chunk-ASS5YYIZ.js} +7 -7
- package/dist/{chunk-3NFJWFNP.js → chunk-BDXC7MDK.js} +1045 -124
- package/dist/chunk-BTUTZMPT.js +482 -0
- package/dist/{chunk-UVCXZEGU.js → chunk-CVV36CWI.js} +2 -2
- package/dist/{chunk-TC3YWBFO.js → chunk-DMJJ3CEQ.js} +29 -8
- package/dist/{chunk-NVT6C2VE.js → chunk-EJTKV7CY.js} +4 -4
- package/dist/{chunk-4NQ3IKUM.js → chunk-ER5SCQWQ.js} +5 -5
- package/dist/{chunk-7VLUGEMJ.js → chunk-F5UDBSJY.js} +4 -4
- package/dist/{chunk-IHLSHCPZ.js → chunk-FAL7NOK3.js} +5 -5
- package/dist/{chunk-YRVLP7UU.js → chunk-FB2WHOEQ.js} +4 -4
- package/dist/chunk-FL4IOQ37.js +379 -0
- package/dist/{chunk-6VE3VLWM.js → chunk-GBE54KY6.js} +6 -5
- package/dist/{chunk-ZXL6MB4R.js → chunk-GL5UZ6NY.js} +3 -3
- package/dist/{chunk-3BIAFYD2.js → chunk-GPWHQ5FJ.js} +2 -2
- package/dist/chunk-GROQGHCT.js +960 -0
- package/dist/{chunk-GB3YZTAM.js → chunk-H73FP42Q.js} +5 -5
- package/dist/{chunk-O5MQPK7E.js → chunk-I4IFRCUB.js} +3 -3
- package/dist/{chunk-IUK7AGD4.js → chunk-I7F2A35O.js} +2 -2
- package/dist/{chunk-YTN572Q2.js → chunk-IA3FJYWR.js} +2 -2
- package/dist/{chunk-RI4NIMFP.js → chunk-JFYIP7XU.js} +75 -35
- package/dist/{chunk-UWDO3O52.js → chunk-JZNMXEIV.js} +2 -2
- package/dist/chunk-KJXIHOVL.js +940 -0
- package/dist/{chunk-26RVGM44.js → chunk-L2ZTFHAY.js} +2 -2
- package/dist/{chunk-PU3AUQPA.js → chunk-M5RXSRO2.js} +2 -2
- package/dist/{chunk-XKTN7CZF.js → chunk-NFFIKVNO.js} +4 -4
- package/dist/{chunk-SVDWQGX2.js → chunk-NISQC5KW.js} +139 -78
- package/dist/{chunk-4HVNZ7WF.js → chunk-O4VUFXIH.js} +3 -3
- package/dist/{chunk-F743CM2N.js → chunk-O76UD6VJ.js} +3 -3
- package/dist/{chunk-TLKMTQYL.js → chunk-OHQEMBLI.js} +3 -3
- package/dist/{chunk-BGJV5ATD.js → chunk-ONA5KPV3.js} +2 -2
- package/dist/{chunk-ZNQX6QWH.js → chunk-OTAL43EH.js} +6 -2
- package/dist/{chunk-FMKTYMP4.js → chunk-OTP5KVLO.js} +3 -3
- package/dist/{chunk-5ZZLLBFK.js → chunk-PGEGPSCZ.js} +2 -2
- package/dist/{chunk-XJ7J6WOO.js → chunk-PJUGRJHJ.js} +4 -4
- package/dist/{chunk-6SA7FJE4.js → chunk-PLZI6KPM.js} +10 -10
- package/dist/{chunk-AJ2PEY7J.js → chunk-PMN3Q7RJ.js} +2 -2
- package/dist/chunk-Q4V4XQWV.js +158 -0
- package/dist/{chunk-5XCM7UUW.js → chunk-QDFNCATJ.js} +99 -35
- package/dist/{chunk-CEHZOPGM.js → chunk-QFQ35BTO.js} +2 -2
- package/dist/{chunk-4UDKKGHH.js → chunk-QUJGFNFN.js} +2 -2
- package/dist/{chunk-IBC35BTK.js → chunk-R56LASIN.js} +2 -2
- package/dist/{chunk-SJEGO2QL.js → chunk-RV26LTUU.js} +4 -4
- package/dist/chunk-RV6A2B5S.js +354 -0
- package/dist/{chunk-65RTDUZH.js → chunk-S5GRONXL.js} +3 -3
- package/dist/{chunk-K6HNAY5V.js → chunk-SCHXJTZL.js} +2 -2
- package/dist/{chunk-ALRHIR6I.js → chunk-SGFZZAUO.js} +4 -4
- package/dist/{chunk-KV6Y2HE6.js → chunk-SU2VBK4L.js} +4 -4
- package/dist/{chunk-D5AVQCDN.js → chunk-T4BRO3Z6.js} +3 -3
- package/dist/{chunk-IFK3GIUW.js → chunk-TSA237IM.js} +2 -2
- package/dist/{chunk-SQDFK5ZQ.js → chunk-TWCLK2GA.js} +3 -3
- package/dist/{chunk-DKEPS5LH.js → chunk-U2HGPLZS.js} +36 -2
- package/dist/{chunk-EYN7VFKL.js → chunk-URSQLCTR.js} +3 -3
- package/dist/{chunk-BCT5G2VN.js → chunk-UUS2GIJZ.js} +5 -5
- package/dist/{chunk-LVHPTBO3.js → chunk-UXOSVCLJ.js} +4 -4
- package/dist/{chunk-HBVD67XG.js → chunk-WCUHAQKB.js} +2 -2
- package/dist/{chunk-YYX3SU6H.js → chunk-WWN566I7.js} +257 -101
- package/dist/{chunk-YM2BSPYW.js → chunk-X2NMFTG3.js} +2 -2
- package/dist/{chunk-ZREZOIGS.js → chunk-XCLHOZAM.js} +6 -6
- package/dist/{chunk-KQAEKMIX.js → chunk-XDXNDSKO.js} +2 -2
- package/dist/{chunk-RTERS6S5.js → chunk-XMVQ5F4M.js} +4 -4
- package/dist/{chunk-4FIV4K4Z.js → chunk-YA7D2N2O.js} +7 -7
- package/dist/{chunk-B57V3DWN.js → chunk-YB3FW24O.js} +3 -3
- package/dist/chunk-YNRDWYZP.js +295 -0
- package/dist/{chunk-2WMBWZY2.js → chunk-YZLMKW4T.js} +3 -3
- package/dist/{chunk-SGHSY3LU.js → chunk-Z6XJQ6KO.js} +81 -6
- package/dist/cli.cjs +153 -144
- package/dist/clock.d.ts +10 -0
- package/dist/clock.js +235 -0
- package/dist/countdown.d.ts +12 -0
- package/dist/countdown.js +450 -0
- package/dist/dgmo-router-QOMFCOOV.js +84 -0
- package/dist/{dimensions-WSIJXT5Q.js → dimensions-P5FSX2QN.js} +5 -5
- package/dist/editor.js +39 -1
- package/dist/element.js +131 -121
- package/dist/element.mjs +11543 -4815
- package/dist/{flowchart-parser-IVZN7CQN.js → flowchart-parser-OE4WHLTF.js} +4 -4
- package/dist/{flowchart-renderer-GMI2U3DD.js → flowchart-renderer-GPCSMTOR.js} +6 -6
- package/dist/highlight.d.ts +17 -1
- package/dist/highlight.js +156 -5
- package/dist/index.js +50 -45
- package/dist/{layout-HQMBPJVS.js → layout-46366KBT.js} +2 -2
- package/dist/{layout-D42XE4RE.js → layout-5BG6DFCU.js} +3 -3
- package/dist/{layout-K2ZN3Q42.js → layout-T3OZU5QW.js} +4 -4
- package/dist/{layout-S3EK4IYO.js → layout-TJIWF7EM.js} +4 -4
- package/dist/{layout-GZ2CWONU.js → layout-VYELEAW7.js} +4 -4
- package/dist/{layout-4Z5JM7PT.js → layout-WZHNDT2O.js} +4 -4
- package/dist/{parser-OBQG655V.js → parser-45DENHFZ.js} +4 -4
- package/dist/{parser-MCJWF5G3.js → parser-4AI5ZN5F.js} +3 -3
- package/dist/{parser-SMBJO3XN.js → parser-4P36TUVD.js} +4 -4
- package/dist/{parser-ZYC3XGNS.js → parser-5AURY4A6.js} +4 -4
- package/dist/{parser-WISPH7LW.js → parser-A2BEFMGK.js} +4 -4
- package/dist/parser-B5FVS7O6.js +11 -0
- package/dist/{parser-KPMN5KKE.js → parser-C2HF2C2E.js} +4 -4
- package/dist/parser-CSFUN3CT.js +14 -0
- package/dist/{parser-TITK4YW6.js → parser-D3QT6GWN.js} +5 -5
- package/dist/{parser-ZKF5K2H2.js → parser-D5637H5H.js} +4 -4
- package/dist/{parser-IKZFTLOJ.js → parser-DFFEDKHH.js} +3 -3
- package/dist/parser-DOKMZXVZ.js +13 -0
- package/dist/parser-FMPCVFRK.js +15 -0
- package/dist/{parser-UBGPTIZD.js → parser-HYRTF3DO.js} +3 -3
- package/dist/{parser-TNYX5S7E.js → parser-I2UIJKVQ.js} +4 -4
- package/dist/{parser-K647FRI4.js → parser-IBWNAPY4.js} +3 -3
- package/dist/{parser-JD7OQ2E6.js → parser-KUQWRPIT.js} +4 -4
- package/dist/{parser-HVJFTOXL.js → parser-LWKKBNSA.js} +3 -3
- package/dist/{parser-4ROBKVUR.js → parser-O4QFCUW7.js} +5 -5
- package/dist/{parser-BL7Z72EY.js → parser-PGMQDD4G.js} +4 -4
- package/dist/{parser-QJYS7KQQ.js → parser-Q4QKCIWQ.js} +4 -4
- package/dist/{parser-UGA23PYK.js → parser-QTOB4KFL.js} +4 -4
- package/dist/{parser-DERPY5KC.js → parser-QYYM4QVW.js} +4 -4
- package/dist/{parser-GFSOPDB7.js → parser-RZMQP7MM.js} +4 -4
- package/dist/parser-RZPVAQVX.js +11 -0
- package/dist/parser-SOUJOEYI.js +13 -0
- package/dist/{parser-MBJSBTL5.js → parser-UQE5OWZI.js} +5 -5
- package/dist/{parser-MRBPXXIV.js → parser-WAV5JRPT.js} +4 -4
- package/dist/{parser-4BKIFG2C.js → parser-YLKYBRIT.js} +5 -5
- package/dist/{parser-D6ONJQFR.js → parser-YS7TOS2K.js} +3 -3
- package/dist/{parser-CLMFZWCC.js → parser-ZSOWUBML.js} +5 -5
- package/dist/{parser-XWUDFJ7P.js → parser-ZTBATMLX.js} +4 -4
- package/dist/{renderer-LWGJFT3D.js → renderer-35HSIDMZ.js} +5 -5
- package/dist/{renderer-BB5PREMY.js → renderer-4ITCHBT7.js} +4 -4
- package/dist/{renderer-YHXPN3GF.js → renderer-67NPCBIS.js} +7 -7
- package/dist/{renderer-TPIBXNOS.js → renderer-6GHYK7DX.js} +6 -6
- package/dist/{renderer-VICQ4WNY.js → renderer-6RNGHC5Z.js} +5 -5
- package/dist/renderer-72LGR2YF.js +14 -0
- package/dist/{renderer-W5RMOURB.js → renderer-7SWMIFMM.js} +6 -6
- package/dist/{renderer-6L3NBEY5.js → renderer-BBCEFILK.js} +6 -6
- package/dist/{renderer-VFUVRNLK.js → renderer-BSW7SRIZ.js} +4 -4
- package/dist/{renderer-CGW7QPNA.js → renderer-BY533UWU.js} +7 -7
- package/dist/{renderer-V3JEMWMM.js → renderer-BZSBPTZJ.js} +6 -6
- package/dist/{renderer-DKESNMU5.js → renderer-CXUC4KAD.js} +6 -6
- package/dist/{renderer-XEKIRPI6.js → renderer-FZUKFUNZ.js} +5 -5
- package/dist/renderer-G2NLGNKF.js +17 -0
- package/dist/{renderer-THD6V5TL.js → renderer-GO3FE3RA.js} +9 -7
- package/dist/{renderer-ROV756WT.js → renderer-HPGR6USK.js} +5 -5
- package/dist/renderer-ICJN2SA2.js +24 -0
- package/dist/{renderer-4IUPINAE.js → renderer-INEXO7B6.js} +7 -7
- package/dist/{renderer-SQ3JUAI7.js → renderer-KDYCFRBX.js} +6 -6
- package/dist/renderer-KY4KQBTF.js +19 -0
- package/dist/{renderer-MJDDU27W.js → renderer-LBN65V45.js} +10 -10
- package/dist/{renderer-UZF3JROD.js → renderer-MGBWOCXG.js} +8 -8
- package/dist/{renderer-MFJ7HY2H.js → renderer-O4JKUGKO.js} +5 -5
- package/dist/{renderer-QL5KO6SK.js → renderer-OOGFODWP.js} +7 -7
- package/dist/{renderer-A5VFZQQK.js → renderer-Q6ZKPLS6.js} +6 -6
- package/dist/{renderer-TYXRHMRI.js → renderer-SZQ326M5.js} +9 -9
- package/dist/{renderer-6T3KK4S3.js → renderer-TKG6LS4U.js} +7 -7
- package/dist/{renderer-QNHUXCRL.js → renderer-TQMZGDAX.js} +9 -9
- package/dist/{renderer-radial-MHO2VDXN.js → renderer-radial-JELMHQ24.js} +6 -6
- package/dist/{state-parser-RX3GXOIB.js → state-parser-3REXRK3R.js} +4 -4
- package/dist/{state-renderer-AJUKGNWU.js → state-renderer-XYLNRWXR.js} +6 -6
- package/docs/ai-integration.md +6 -2
- package/docs/language-reference.md +253 -22
- package/gallery/fixtures/body.dgmo +17 -0
- package/gallery/fixtures/bracket.dgmo +30 -0
- package/gallery/fixtures/clock.dgmo +8 -0
- package/gallery/fixtures/countdown.dgmo +3 -0
- package/gallery/fixtures/goal.dgmo +4 -0
- package/package.json +12 -4
- package/dist/dgmo-router-ODKPEJ3P.js +0 -79
- package/dist/parser-667RGSUW.js +0 -13
- package/dist/parser-J3P2D6IP.js +0 -13
package/dist/clock.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Run one update pass over every clock row inside `root`. */
|
|
2
|
+
declare function tickClocks(root?: ParentNode): void;
|
|
3
|
+
/**
|
|
4
|
+
* Update `root` immediately, then (once per page) register a single 1s interval
|
|
5
|
+
* that re-scans the whole document. Idempotent — safe to call on every render /
|
|
6
|
+
* route change. No-op with no DOM.
|
|
7
|
+
*/
|
|
8
|
+
declare function startClocks(root?: ParentNode): void;
|
|
9
|
+
|
|
10
|
+
export { startClocks, tickClocks };
|
package/dist/clock.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// src/clock/resolve.ts
|
|
2
|
+
var SOON_MIN = 60;
|
|
3
|
+
var RAD = Math.PI / 180;
|
|
4
|
+
var DAY_MS = 864e5;
|
|
5
|
+
var J1970 = 2440588;
|
|
6
|
+
var J2000 = 2451545;
|
|
7
|
+
function zoneParts(zone, nowMs) {
|
|
8
|
+
const d = new Date(nowMs);
|
|
9
|
+
try {
|
|
10
|
+
const o = {};
|
|
11
|
+
new Intl.DateTimeFormat("en-US", {
|
|
12
|
+
timeZone: zone,
|
|
13
|
+
hour12: false,
|
|
14
|
+
hour: "2-digit",
|
|
15
|
+
minute: "2-digit",
|
|
16
|
+
second: "2-digit",
|
|
17
|
+
weekday: "short"
|
|
18
|
+
}).formatToParts(d).forEach((x) => {
|
|
19
|
+
o[x.type] = x.value;
|
|
20
|
+
});
|
|
21
|
+
const off = new Intl.DateTimeFormat("en-US", {
|
|
22
|
+
timeZone: zone,
|
|
23
|
+
timeZoneName: "shortOffset"
|
|
24
|
+
}).formatToParts(d).find((x) => x.type === "timeZoneName");
|
|
25
|
+
return {
|
|
26
|
+
h: parseInt(o["hour"], 10) % 24,
|
|
27
|
+
m: parseInt(o["minute"], 10),
|
|
28
|
+
s: parseInt(o["second"], 10),
|
|
29
|
+
weekday: o["weekday"],
|
|
30
|
+
offsetLabel: off ? off.value.replace("GMT", "UTC") : ""
|
|
31
|
+
};
|
|
32
|
+
} catch {
|
|
33
|
+
return {
|
|
34
|
+
h: d.getUTCHours(),
|
|
35
|
+
m: d.getUTCMinutes(),
|
|
36
|
+
s: d.getUTCSeconds(),
|
|
37
|
+
weekday: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][d.getUTCDay()],
|
|
38
|
+
offsetLabel: "UTC"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function pad2(n) {
|
|
43
|
+
return n < 10 ? "0" + n : String(n);
|
|
44
|
+
}
|
|
45
|
+
function formatTime(h, m, s, hours12) {
|
|
46
|
+
const sec = pad2(s);
|
|
47
|
+
if (hours12) {
|
|
48
|
+
const ap = h < 12 ? "am" : "pm";
|
|
49
|
+
let hr = h % 12;
|
|
50
|
+
if (hr === 0) hr = 12;
|
|
51
|
+
return { main: `${hr}:${pad2(m)}`, sec, ap };
|
|
52
|
+
}
|
|
53
|
+
return { main: `${pad2(h)}:${pad2(m)}`, sec, ap: "" };
|
|
54
|
+
}
|
|
55
|
+
function fmtDelta(ms) {
|
|
56
|
+
const m = Math.max(0, Math.round(ms / 6e4));
|
|
57
|
+
if (m < 90) return `${m}m`;
|
|
58
|
+
return `${Math.floor(m / 60)}h ${m % 60}m`;
|
|
59
|
+
}
|
|
60
|
+
function workStatus(parts, work) {
|
|
61
|
+
if (!work) return null;
|
|
62
|
+
const min = parts.h * 60 + parts.m;
|
|
63
|
+
if (!work.days[parts.weekday]) return { cls: "off", text: "Weekend" };
|
|
64
|
+
if (min < work.startMin) {
|
|
65
|
+
const d = work.startMin - min;
|
|
66
|
+
return {
|
|
67
|
+
cls: d <= SOON_MIN ? "soon" : "off",
|
|
68
|
+
text: `starts in ${fmtDelta(d * 6e4)}`
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (min < work.endMin) {
|
|
72
|
+
return { cls: "ok", text: `${fmtDelta((work.endMin - min) * 6e4)} left` };
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
cls: "off",
|
|
76
|
+
text: `ended ${fmtDelta((min - work.endMin) * 6e4)} ago`
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function toJulian(ms) {
|
|
80
|
+
return ms / DAY_MS - 0.5 + J1970;
|
|
81
|
+
}
|
|
82
|
+
function fromJulian(j) {
|
|
83
|
+
return (j + 0.5 - J1970) * DAY_MS;
|
|
84
|
+
}
|
|
85
|
+
function sunTimes(nowMs, lat, lon) {
|
|
86
|
+
const lw = -lon * RAD;
|
|
87
|
+
const phi = lat * RAD;
|
|
88
|
+
const J = toJulian(nowMs);
|
|
89
|
+
const n = Math.round(J - J2000 - 9e-4 - lw / (2 * Math.PI));
|
|
90
|
+
const Jn = J2000 + 9e-4 + lw / (2 * Math.PI) + n;
|
|
91
|
+
const M = (357.5291 + 0.98560028 * (Jn - J2000)) * RAD;
|
|
92
|
+
const C = (1.9148 * Math.sin(M) + 0.02 * Math.sin(2 * M) + 3e-4 * Math.sin(3 * M)) * RAD;
|
|
93
|
+
const L = M + C + Math.PI + 102.9372 * RAD;
|
|
94
|
+
const Jt = Jn + 53e-4 * Math.sin(M) - 69e-4 * Math.sin(2 * L);
|
|
95
|
+
const dec = Math.asin(Math.sin(L) * Math.sin(23.44 * RAD));
|
|
96
|
+
const cw = (Math.sin(-0.833 * RAD) - Math.sin(phi) * Math.sin(dec)) / (Math.cos(phi) * Math.cos(dec));
|
|
97
|
+
if (cw > 1) return { polar: "night" };
|
|
98
|
+
if (cw < -1) return { polar: "day" };
|
|
99
|
+
const w = Math.acos(cw);
|
|
100
|
+
const Jset = J2000 + 9e-4 + (w + lw) / (2 * Math.PI) + n + 53e-4 * Math.sin(M) - 69e-4 * Math.sin(2 * L);
|
|
101
|
+
return {
|
|
102
|
+
sunriseMs: fromJulian(Jt - (Jset - Jt)),
|
|
103
|
+
sunsetMs: fromJulian(Jset)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function sunLine(nowMs, lat, lon) {
|
|
107
|
+
const t = sunTimes(nowMs, lat, lon);
|
|
108
|
+
if (t.polar) {
|
|
109
|
+
return {
|
|
110
|
+
up: t.polar === "day",
|
|
111
|
+
text: t.polar === "day" ? "midnight sun" : "polar night"
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (nowMs < t.sunriseMs) {
|
|
115
|
+
return { up: false, text: `sunrise in ${fmtDelta(t.sunriseMs - nowMs)}` };
|
|
116
|
+
}
|
|
117
|
+
if (nowMs < t.sunsetMs) {
|
|
118
|
+
return { up: true, text: `sunset in ${fmtDelta(t.sunsetMs - nowMs)}` };
|
|
119
|
+
}
|
|
120
|
+
const tm = sunTimes(nowMs + DAY_MS, lat, lon);
|
|
121
|
+
if (tm.polar) return { up: false, text: "sunrise in \u2014" };
|
|
122
|
+
return { up: false, text: `sunrise in ${fmtDelta(tm.sunriseMs - nowMs)}` };
|
|
123
|
+
}
|
|
124
|
+
function handAngles(h, m, s) {
|
|
125
|
+
return {
|
|
126
|
+
hour: (h % 12 + m / 60) * 30,
|
|
127
|
+
minute: (m + s / 60) * 6,
|
|
128
|
+
second: s * 6
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/clock/ticker.ts
|
|
133
|
+
function readWork(node) {
|
|
134
|
+
const start = node.getAttribute("data-dgmo-clock-work-start");
|
|
135
|
+
const end = node.getAttribute("data-dgmo-clock-work-end");
|
|
136
|
+
if (start === null || end === null) return null;
|
|
137
|
+
const days = {};
|
|
138
|
+
(node.getAttribute("data-dgmo-clock-work-days") ?? "").split(",").filter(Boolean).forEach((d) => {
|
|
139
|
+
days[d] = true;
|
|
140
|
+
});
|
|
141
|
+
return { startMin: Number(start), endMin: Number(end), days };
|
|
142
|
+
}
|
|
143
|
+
function setHand(group, which, angle) {
|
|
144
|
+
const hand = group.querySelector(`[data-dgmo-clock-hand="${which}"]`);
|
|
145
|
+
if (hand) hand.setAttribute("transform", `rotate(${angle} 50 50)`);
|
|
146
|
+
}
|
|
147
|
+
function setPart(group, sel, textContent) {
|
|
148
|
+
const el = group.querySelector(sel);
|
|
149
|
+
if (el && el.textContent !== textContent) el.textContent = textContent;
|
|
150
|
+
}
|
|
151
|
+
function updateRow(group, now) {
|
|
152
|
+
const zone = group.getAttribute("data-dgmo-clock-zone");
|
|
153
|
+
if (!zone) return;
|
|
154
|
+
const parts = zoneParts(zone, now);
|
|
155
|
+
const latAttr = group.getAttribute("data-dgmo-clock-lat");
|
|
156
|
+
const lonAttr = group.getAttribute("data-dgmo-clock-lon");
|
|
157
|
+
const sunOn = group.getAttribute("data-dgmo-clock-sun") === "1";
|
|
158
|
+
const hasCoords = latAttr !== null && lonAttr !== null;
|
|
159
|
+
const sun = sunOn && hasCoords ? sunLine(now, Number(latAttr), Number(lonAttr)) : null;
|
|
160
|
+
const up = sun ? sun.up : parts.h >= 6 && parts.h < 18;
|
|
161
|
+
const c = (name) => group.getAttribute(`data-dgmo-clock-c-${name}`) ?? "";
|
|
162
|
+
const stColor = up ? c("day") : c("night");
|
|
163
|
+
const stTint = up ? c("day-soft") : c("night-soft");
|
|
164
|
+
const hours12 = group.getAttribute("data-dgmo-clock-hours12") !== "0";
|
|
165
|
+
const ts = formatTime(parts.h, parts.m, parts.s, hours12);
|
|
166
|
+
const ang = handAngles(parts.h, parts.m, parts.s);
|
|
167
|
+
setHand(group, "h", ang.hour);
|
|
168
|
+
setHand(group, "m", ang.minute);
|
|
169
|
+
setHand(group, "s", ang.second);
|
|
170
|
+
const autoSolid = group.getAttribute("data-dgmo-clock-auto-solid");
|
|
171
|
+
const autoFace = group.getAttribute("data-dgmo-clock-auto-face");
|
|
172
|
+
const faceFill = autoFace ?? stTint;
|
|
173
|
+
const handColor = autoSolid ?? stColor;
|
|
174
|
+
const face = group.querySelector("[data-dgmo-clock-facebg]");
|
|
175
|
+
if (face) face.setAttribute("fill", faceFill);
|
|
176
|
+
const ring = group.querySelector("[data-dgmo-clock-facering]");
|
|
177
|
+
if (ring && autoSolid) ring.setAttribute("stroke", autoSolid);
|
|
178
|
+
const center = group.querySelector("[data-dgmo-clock-center]");
|
|
179
|
+
if (center) center.setAttribute("fill", handColor);
|
|
180
|
+
const secondHand = group.querySelector('[data-dgmo-clock-hand="s"]');
|
|
181
|
+
if (secondHand) secondHand.setAttribute("stroke", handColor);
|
|
182
|
+
setPart(group, '[data-dgmo-clock-digital-part="main"]', ts.main);
|
|
183
|
+
setPart(group, '[data-dgmo-clock-digital-part="sec"]', `:${ts.sec}`);
|
|
184
|
+
setPart(group, '[data-dgmo-clock-digital-part="ap"]', ` ${ts.ap}`);
|
|
185
|
+
setPart(group, "[data-dgmo-clock-ampm]", ts.ap.toUpperCase());
|
|
186
|
+
const work = readWork(group);
|
|
187
|
+
const status = workStatus(parts, work);
|
|
188
|
+
const statusEl = group.querySelector("[data-dgmo-clock-status]");
|
|
189
|
+
if (status && statusEl) {
|
|
190
|
+
const col = status.cls === "ok" ? c("ok") : status.cls === "soon" ? c("soon") : c("off");
|
|
191
|
+
if (statusEl.textContent !== status.text)
|
|
192
|
+
statusEl.textContent = status.text;
|
|
193
|
+
statusEl.setAttribute("fill", col);
|
|
194
|
+
const dot = group.querySelector("[data-dgmo-clock-status-dot]");
|
|
195
|
+
if (dot) {
|
|
196
|
+
if (status.cls === "off") {
|
|
197
|
+
dot.setAttribute("fill", "none");
|
|
198
|
+
dot.setAttribute("stroke", col);
|
|
199
|
+
dot.setAttribute("stroke-width", "1.4");
|
|
200
|
+
} else {
|
|
201
|
+
dot.setAttribute("fill", col);
|
|
202
|
+
dot.setAttribute("stroke", "none");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const sunEl = group.querySelector("[data-dgmo-clock-sun-line]");
|
|
207
|
+
if (sun && sunEl) {
|
|
208
|
+
if (sunEl.textContent !== sun.text) sunEl.textContent = sun.text;
|
|
209
|
+
const icon = group.querySelector("[data-dgmo-clock-sun-icon]");
|
|
210
|
+
if (icon) {
|
|
211
|
+
const sunG = icon.querySelector('[data-clock-glyph="sun"]');
|
|
212
|
+
const moonG = icon.querySelector('[data-clock-glyph="moon"]');
|
|
213
|
+
if (sunG) sunG.setAttribute("display", up ? "inline" : "none");
|
|
214
|
+
if (moonG) moonG.setAttribute("display", up ? "none" : "inline");
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function tickClocks(root = document) {
|
|
219
|
+
if (typeof document === "undefined") return;
|
|
220
|
+
const now = Date.now();
|
|
221
|
+
root.querySelectorAll("[data-dgmo-clock]").forEach((group) => updateRow(group, now));
|
|
222
|
+
}
|
|
223
|
+
var intervalStarted = false;
|
|
224
|
+
function startClocks(root = document) {
|
|
225
|
+
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
226
|
+
tickClocks(root);
|
|
227
|
+
if (intervalStarted) return;
|
|
228
|
+
intervalStarted = true;
|
|
229
|
+
window.setInterval(() => tickClocks(document), 1e3);
|
|
230
|
+
}
|
|
231
|
+
export {
|
|
232
|
+
startClocks,
|
|
233
|
+
tickClocks
|
|
234
|
+
};
|
|
235
|
+
//# sourceMappingURL=clock.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const DAY_MS = 86400000;
|
|
2
|
+
|
|
3
|
+
/** Run one update pass over every countdown node inside `root`. */
|
|
4
|
+
declare function tickCountdowns(root?: ParentNode): void;
|
|
5
|
+
/**
|
|
6
|
+
* Update `root` immediately, then (once per page) register a single 1s interval
|
|
7
|
+
* that re-scans the whole document. Idempotent — safe to call on every render /
|
|
8
|
+
* route change (mirrors remark's `clickHandlerBound` guard). No-op with no DOM.
|
|
9
|
+
*/
|
|
10
|
+
declare function startCountdowns(root?: ParentNode): void;
|
|
11
|
+
|
|
12
|
+
export { DAY_MS, startCountdowns, tickCountdowns };
|