@diagrammo/dgmo 0.50.2 → 0.51.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/dist/advanced.d.ts +85 -23
- package/dist/advanced.js +207 -161
- package/dist/{analyzer-UYKBXAKR.js → analyzer-BJ54GIFB.js} +3 -3
- package/dist/auto.css +31 -8
- package/dist/auto.d.ts +6 -0
- package/dist/auto.js +169 -133
- package/dist/auto.mjs +2148 -1024
- package/dist/block.css +28 -8
- package/dist/block.js +97 -68
- package/dist/{charts-d3-MUW3LTML.js → charts-d3-7E4B4IMW.js} +9 -9
- package/dist/{chunk-6IAA2QQ2.js → chunk-2EQMXBBQ.js} +2 -2
- package/dist/{chunk-XJLKLU4D.js → chunk-2ILHQOL3.js} +3 -3
- package/dist/{chunk-SXRTRMEE.js → chunk-2UJSV2VT.js} +3 -3
- package/dist/{chunk-LE4MYMLI.js → chunk-32XPAAET.js} +5 -5
- package/dist/{chunk-NU3XLTGP.js → chunk-332ZR4QU.js} +4 -4
- package/dist/{chunk-F7BFXWNQ.js → chunk-3JLKYGBQ.js} +2 -2
- package/dist/{chunk-QROYX7TT.js → chunk-3LV2NCB6.js} +3 -3
- package/dist/{chunk-SVTI362O.js → chunk-3ODS2VGL.js} +97 -97
- package/dist/{chunk-3XGZF2QJ.js → chunk-3YSQZ75W.js} +6 -6
- package/dist/{chunk-FJUNPCYI.js → chunk-467TVMQL.js} +2 -2
- package/dist/{chunk-HHXOONLX.js → chunk-4B5YISOR.js} +38 -1
- package/dist/{chunk-6HJBFVLO.js → chunk-4QZ43D7I.js} +3 -3
- package/dist/{chunk-QJJZSROI.js → chunk-4VWJ4LW2.js} +7 -7
- package/dist/chunk-4XFBQT5O.js +35 -0
- package/dist/{chunk-2C56LEML.js → chunk-5F5ELR3V.js} +3 -3
- package/dist/{chunk-EAMEADTV.js → chunk-5PDTIBLV.js} +83 -21
- package/dist/{chunk-C2CVAM3U.js → chunk-5PZT4DQG.js} +160 -87
- package/dist/{chunk-IAEC4KLA.js → chunk-5QKQSSPO.js} +2 -2
- package/dist/{chunk-5OWVC2A6.js → chunk-5SVOCD5W.js} +6 -6
- package/dist/{chunk-VBYSIOOY.js → chunk-5WPNFSXP.js} +3 -3
- package/dist/{chunk-4MJ7M6YL.js → chunk-5X6YQA2J.js} +7 -7
- package/dist/{chunk-JJUOHGX2.js → chunk-65WJYYKJ.js} +4 -4
- package/dist/{chunk-3UIKSPFB.js → chunk-6BQFET7X.js} +3 -3
- package/dist/{chunk-U2HGPLZS.js → chunk-6H7O2OPM.js} +14 -1
- package/dist/{chunk-DZXYF2F5.js → chunk-6K2M4VSR.js} +3 -3
- package/dist/{chunk-PGEGPSCZ.js → chunk-6MNGECP2.js} +2 -2
- package/dist/{chunk-3XPUDB7B.js → chunk-6NFYEQDX.js} +266 -38
- package/dist/{chunk-4XK3FLFB.js → chunk-6NYWYNBI.js} +3 -3
- package/dist/{chunk-TWQUYVP3.js → chunk-7DF4J4RL.js} +4 -4
- package/dist/{chunk-H73FP42Q.js → chunk-7DYOELRK.js} +3 -3
- package/dist/{chunk-L3UHP6TD.js → chunk-7L4UJOY6.js} +1 -2
- package/dist/{chunk-QJP6PG7F.js → chunk-AB7INMR5.js} +9 -9
- package/dist/{chunk-3LKM6FMW.js → chunk-AE7II3E3.js} +2 -2
- package/dist/{chunk-BTUTZMPT.js → chunk-AFIEPDLX.js} +97 -42
- package/dist/chunk-APKUAJ2L.js +220 -0
- package/dist/{chunk-X6EZPSW6.js → chunk-AXW3M6OQ.js} +7 -7
- package/dist/{chunk-66RUL3XF.js → chunk-B63YB7X3.js} +5 -5
- package/dist/{chunk-DSWVNQVS.js → chunk-BGP54HVR.js} +4 -59
- package/dist/{chunk-3NODSS6A.js → chunk-BYJBIALT.js} +7 -7
- package/dist/{chunk-3YPY3OXD.js → chunk-CC4YRBWV.js} +2 -2
- package/dist/{chunk-HLJVEAOF.js → chunk-DY7XLRHK.js} +8 -33
- package/dist/{chunk-OMNGQPEZ.js → chunk-E7Y3SYKW.js} +3 -3
- package/dist/{chunk-HTMN2Z6U.js → chunk-EDA6C7MV.js} +50 -7
- package/dist/{chunk-7L3R6I3U.js → chunk-ENRS56GC.js} +3 -3
- package/dist/{chunk-2KGXHFYK.js → chunk-EXOQP75F.js} +7 -7
- package/dist/{chunk-BBGDM4NQ.js → chunk-F3FYUFUH.js} +26 -8
- package/dist/{chunk-GL5UZ6NY.js → chunk-FC5I2KXV.js} +3 -3
- package/dist/{chunk-VVW3F3MD.js → chunk-FTBZV6NE.js} +9 -9
- package/dist/{chunk-7QKLIMRZ.js → chunk-G3PF3S7P.js} +41 -46
- package/dist/{chunk-J6K7RP6P.js → chunk-GD6L76WD.js} +3 -3
- package/dist/{chunk-I2WKW7C7.js → chunk-GGHRAITI.js} +3 -3
- package/dist/{chunk-DN66GPY5.js → chunk-GNSFLJAA.js} +24 -3
- package/dist/{chunk-IUMPEA64.js → chunk-GROLTAWZ.js} +4 -4
- package/dist/{chunk-Q4V4XQWV.js → chunk-GTWKD3QT.js} +2 -2
- package/dist/{chunk-F2L5GCQ4.js → chunk-GU46PPT3.js} +3 -3
- package/dist/{chunk-6IUAK7RZ.js → chunk-H6PI3KJT.js} +2 -2
- package/dist/{chunk-SCQ5VPUF.js → chunk-HFMYN6N2.js} +2 -2
- package/dist/{chunk-GKC3HILQ.js → chunk-I2QZFCS2.js} +27 -4
- package/dist/{chunk-MCZ5LBZD.js → chunk-IE477RQZ.js} +7 -7
- package/dist/{chunk-3Y2DRD7S.js → chunk-IEDMFNU7.js} +3 -3
- package/dist/{chunk-M5RXSRO2.js → chunk-IEWG6J7C.js} +4 -4
- package/dist/{chunk-P7CE7LXL.js → chunk-IUJODQKX.js} +6 -6
- package/dist/{chunk-NWED7CYO.js → chunk-IUO34HKW.js} +6 -6
- package/dist/{chunk-NX4EQS3U.js → chunk-J76PIKAT.js} +2 -2
- package/dist/{chunk-O7WP4ZD4.js → chunk-JED6ZDEE.js} +2 -2
- package/dist/{chunk-6BFZKBGD.js → chunk-JJXGQIRV.js} +2 -2
- package/dist/{chunk-O7NUCTFU.js → chunk-JM4LEPY3.js} +2 -2
- package/dist/{chunk-VDOOQZUD.js → chunk-JSSX2SX4.js} +4 -4
- package/dist/{chunk-SQLNBA64.js → chunk-KFNWFNAA.js} +3 -3
- package/dist/{chunk-KQ57MHRO.js → chunk-KJGG2JKQ.js} +143 -82
- package/dist/{chunk-OTAL43EH.js → chunk-LV4BETUU.js} +8 -2
- package/dist/{chunk-VUJGMJE6.js → chunk-MVN25IF6.js} +4 -4
- package/dist/{chunk-CLD2OKV7.js → chunk-MX2EY5Y7.js} +2 -2
- package/dist/{chunk-T5SHNNGP.js → chunk-ND76YJCN.js} +59 -25
- package/dist/{chunk-KFZYNWWO.js → chunk-NEQ6GJXB.js} +4 -4
- package/dist/{chunk-PFHVU7UA.js → chunk-NI3XQBPB.js} +2 -2
- package/dist/{chunk-WW32K72E.js → chunk-OJTXTQA2.js} +9 -9
- package/dist/{chunk-YNRDWYZP.js → chunk-OQKP2X3D.js} +170 -51
- package/dist/{chunk-AHGF2YYA.js → chunk-OTOHI4JO.js} +2 -2
- package/dist/{chunk-HEVYAHLW.js → chunk-OU7HLO7I.js} +4 -4
- package/dist/{chunk-GBE54KY6.js → chunk-OZPBJM5Q.js} +3 -3
- package/dist/{chunk-EOFPYPAU.js → chunk-P3NRSSUU.js} +51 -11
- package/dist/{chunk-TSA237IM.js → chunk-PZDBOK2Q.js} +2 -2
- package/dist/{chunk-3P2DKJCG.js → chunk-Q62FEYK3.js} +2 -2
- package/dist/{chunk-DFTFPYUD.js → chunk-QHI5XVUJ.js} +7 -7
- package/dist/{chunk-HQCHYB5F.js → chunk-QOOUC2J5.js} +2 -2
- package/dist/{chunk-XEGTMVYY.js → chunk-QZPEGJOM.js} +2 -2
- package/dist/{chunk-TN35C5KM.js → chunk-RAHVMKBG.js} +2 -2
- package/dist/chunk-RBDIYLA5.js +267 -0
- package/dist/{chunk-OTQKUHRS.js → chunk-RBHWPDBB.js} +3 -3
- package/dist/{chunk-BH3UYK36.js → chunk-RLFVAKEO.js} +3 -3
- package/dist/{chunk-3LH5CLP4.js → chunk-RXKTSFDL.js} +150 -5
- package/dist/{chunk-RZ6YKEUJ.js → chunk-TK2VQQX2.js} +6 -6
- package/dist/{chunk-I7F2A35O.js → chunk-TMACGPW5.js} +25 -47
- package/dist/{chunk-5GJYGP5Z.js → chunk-TRM2J7ZN.js} +8 -8
- package/dist/{chunk-BCYVE3N5.js → chunk-TYS6CSS5.js} +2 -2
- package/dist/{chunk-5WFIYXQ6.js → chunk-U5SI5NIM.js} +91 -228
- package/dist/{chunk-KHEYDLMT.js → chunk-VB4UJ3H2.js} +2 -2
- package/dist/{chunk-HGN652MU.js → chunk-VL2O2F3W.js} +2 -2
- package/dist/{chunk-ONA5KPV3.js → chunk-VNSXLA6G.js} +4 -4
- package/dist/{chunk-CMCR5WBW.js → chunk-WBRZJOEC.js} +3 -3
- package/dist/{chunk-5LWQH6QV.js → chunk-WCT3NYCV.js} +1 -1
- package/dist/{chunk-T4VOVZT5.js → chunk-WJ7RW65H.js} +4 -4
- package/dist/{chunk-SCHXJTZL.js → chunk-WQLMU7VG.js} +2 -2
- package/dist/{chunk-C4GQDB5L.js → chunk-WRNFDFPU.js} +2 -2
- package/dist/{chunk-66NVRO4K.js → chunk-X7EC3L2H.js} +7 -7
- package/dist/{chunk-QXKWYZNR.js → chunk-XEQXCIBC.js} +3 -3
- package/dist/{chunk-C63UWAKM.js → chunk-Y2ZE3MSG.js} +2 -2
- package/dist/{chunk-FA6K3FWM.js → chunk-Y6GBQTBK.js} +6 -6
- package/dist/{chunk-7UEMZREK.js → chunk-YAA6IID3.js} +2 -2
- package/dist/{chunk-PZFVK3IH.js → chunk-YGJZWZTY.js} +2 -2
- package/dist/{chunk-7TV5Y53Y.js → chunk-ZJ3LS7DW.js} +3 -3
- package/dist/{chunk-PH5X4GIP.js → chunk-ZO27FGJS.js} +2 -2
- package/dist/cli.cjs +163 -147
- package/dist/clock.js +91 -5
- package/dist/countdown.js +208 -82
- package/dist/dgmo-router-Y2VEX46B.js +86 -0
- package/dist/dimensions-F7B5C4BJ.js +22 -0
- package/dist/editor.js +14 -1
- package/dist/element.d.ts +6 -0
- package/dist/element.js +170 -134
- package/dist/element.mjs +2112 -1009
- package/dist/{flowchart-parser-OE4WHLTF.js → flowchart-parser-MY53QWTZ.js} +4 -4
- package/dist/{flowchart-renderer-GPCSMTOR.js → flowchart-renderer-AQSMEMYF.js} +8 -8
- package/dist/highlight.js +14 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +55 -53
- package/dist/{layout-7SKMFYHL.js → layout-46N4JJYK.js} +5 -5
- package/dist/layout-4DIUOX2T.js +14 -0
- package/dist/{layout-7H4H46CS.js → layout-7QXCNOVS.js} +3 -3
- package/dist/{layout-NXG63LWH.js → layout-AM2JWW3X.js} +4 -4
- package/dist/{layout-7MZ5NF2N.js → layout-CBCLPMSG.js} +5 -5
- package/dist/{layout-DC4TVXER.js → layout-EE6GE46Y.js} +5 -5
- package/dist/{layout-FGQWRYYW.js → layout-F4WO357A.js} +3 -3
- package/dist/layout-G23F7LDH.js +9 -0
- package/dist/{layout-QNUQLEHU.js → layout-HYZPWAK5.js} +3 -3
- package/dist/{layout-FWODLIMP.js → layout-JDJAEQ3P.js} +6 -6
- package/dist/layout-MUPRALE5.js +14 -0
- package/dist/{layout-34CLNICW.js → layout-OAC4PEAC.js} +5 -5
- package/dist/{layout-5BG6DFCU.js → layout-YVTNOTN4.js} +6 -6
- package/dist/{layout-PUQCB6AN.js → layout-ZDOSXL5G.js} +7 -7
- package/dist/{layout-search-QS44PI5R.js → layout-search-55FU6HD3.js} +6 -157
- package/dist/map-data/gazetteer.json +1 -1
- package/dist/{parser-36HVKU5U.js → parser-2Q2T4C3B.js} +6 -5
- package/dist/{parser-B5FVS7O6.js → parser-3A42DZ72.js} +3 -3
- package/dist/{parser-CSFUN3CT.js → parser-4RFTKAQX.js} +5 -4
- package/dist/{parser-IJBMRXMC.js → parser-57ILIFZ2.js} +5 -5
- package/dist/{parser-DFFEDKHH.js → parser-5A2UWU6B.js} +3 -3
- package/dist/{parser-H3XEPFPV.js → parser-5PDYJGWA.js} +4 -4
- package/dist/{parser-O4HIUN6G.js → parser-6BJEXUFX.js} +4 -4
- package/dist/{parser-MTOMTWTD.js → parser-6ZKABF5S.js} +6 -5
- package/dist/{parser-WAV5JRPT.js → parser-AIMHGJRR.js} +4 -4
- package/dist/{parser-TXND652E.js → parser-AZJ25OKK.js} +4 -4
- package/dist/{parser-4AI5ZN5F.js → parser-B77S5SZM.js} +3 -3
- package/dist/{parser-IBWNAPY4.js → parser-BEPSWJAD.js} +3 -3
- package/dist/{parser-D5VILGN2.js → parser-BKI42XBQ.js} +4 -4
- package/dist/{parser-LWKKBNSA.js → parser-C3D7MVXY.js} +3 -3
- package/dist/{parser-HYRTF3DO.js → parser-CDG7CHV5.js} +3 -3
- package/dist/{parser-CVMEDULU.js → parser-CZOJ7XQ6.js} +4 -4
- package/dist/{parser-AXKBDGNO.js → parser-E2RL6JYF.js} +5 -5
- package/dist/{parser-PSA4UBSP.js → parser-EH5VE7ZN.js} +4 -4
- package/dist/{parser-K3XXLMUW.js → parser-FQ6GZFMR.js} +4 -4
- package/dist/{parser-RV4M6AS2.js → parser-GKLZKEIK.js} +4 -4
- package/dist/{parser-MPCE5JBG.js → parser-H6ABKHZZ.js} +4 -4
- package/dist/{parser-RZPVAQVX.js → parser-I6GGFKOQ.js} +4 -3
- package/dist/{parser-W4PQUGX3.js → parser-JA7JQ7NF.js} +4 -4
- package/dist/{parser-5OXGPNBF.js → parser-KKTJ6M3Y.js} +5 -5
- package/dist/parser-OK22AC6Y.js +14 -0
- package/dist/{parser-4NO6VZ6S.js → parser-OK2ILHRT.js} +4 -4
- package/dist/{parser-YS7TOS2K.js → parser-OUTPNJWC.js} +3 -3
- package/dist/{parser-KCR2WS3V.js → parser-PORDUX5E.js} +4 -4
- package/dist/{parser-VKOJM7KS.js → parser-SRVFR7PM.js} +4 -4
- package/dist/{parser-TGQZJ5OT.js → parser-UKFFZCFJ.js} +4 -4
- package/dist/{parser-JJR52VAT.js → parser-UMWPLORP.js} +5 -5
- package/dist/{parser-AGVYTQXV.js → parser-Z4TZV2CB.js} +4 -4
- package/dist/{renderer-A5VE5BCI.js → renderer-2AUFT3E2.js} +8 -8
- package/dist/{renderer-FPE3J5VZ.js → renderer-2HTNBIF2.js} +11 -11
- package/dist/{renderer-R2WNIC2C.js → renderer-3K3IB7D5.js} +8 -8
- package/dist/{renderer-2AZ5HJFK.js → renderer-3YNIWF5I.js} +4 -4
- package/dist/{renderer-P5ROYQGU.js → renderer-3YPZHMOU.js} +3 -3
- package/dist/{renderer-JCCHNECZ.js → renderer-4WR6WMVF.js} +9 -9
- package/dist/{renderer-HDCCZURL.js → renderer-66MERVQ2.js} +9 -9
- package/dist/{renderer-2QPMJ2DA.js → renderer-6RKQPNJI.js} +9 -9
- package/dist/{renderer-FYSVXL7M.js → renderer-ARMJBP6C.js} +11 -11
- package/dist/{renderer-6OKF44KS.js → renderer-CO2DW7S7.js} +13 -13
- package/dist/{renderer-BSR2O2H6.js → renderer-EDJ2O4S5.js} +13 -12
- package/dist/{renderer-CYB4LK3G.js → renderer-F7U3MFCV.js} +9 -9
- package/dist/{renderer-5KVCNMOJ.js → renderer-GD2COXVL.js} +4 -2
- package/dist/{renderer-B5TBNZJE.js → renderer-GQIESYEM.js} +8 -8
- package/dist/{renderer-ODUUOPVT.js → renderer-HCKJDFXD.js} +13 -13
- package/dist/{renderer-QAOBLRXV.js → renderer-HYGHO4SJ.js} +10 -10
- package/dist/{renderer-5DSEWF74.js → renderer-JC3RDUT7.js} +8 -8
- package/dist/{renderer-7RH2SI3B.js → renderer-KQB7UGDS.js} +3 -3
- package/dist/{renderer-45PSOL3E.js → renderer-NKJ24TEA.js} +5 -5
- package/dist/{renderer-AUW2BE6G.js → renderer-OYO67VZK.js} +9 -9
- package/dist/{renderer-DAXMXIKD.js → renderer-QIWVHWZO.js} +3 -3
- package/dist/{renderer-PSMMZCKH.js → renderer-QRWACQRI.js} +8 -8
- package/dist/{renderer-4ITCHBT7.js → renderer-QXGN5H3A.js} +5 -5
- package/dist/renderer-QXPP4TA2.js +27 -0
- package/dist/{renderer-KS7YZJE2.js → renderer-RGIYOTKJ.js} +10 -10
- package/dist/{renderer-FF24KZCI.js → renderer-RHT4MHFU.js} +8 -8
- package/dist/{renderer-PPIHO5FI.js → renderer-RYR3TJ46.js} +12 -11
- package/dist/{renderer-NGXZTRK6.js → renderer-SRKDNDFB.js} +8 -8
- package/dist/{renderer-SBS3YWU5.js → renderer-TGTUABCI.js} +8 -8
- package/dist/{renderer-7SD6MSBS.js → renderer-TXJFKPOG.js} +11 -11
- package/dist/{renderer-HVCU2C3Z.js → renderer-UV6MI64M.js} +3 -3
- package/dist/renderer-radial-FWABAZHB.js +21 -0
- package/dist/{resolver-FHBCO3PL.js → resolver-EMTGNR3D.js} +4 -3
- package/dist/{state-parser-3REXRK3R.js → state-parser-6T6CNMPX.js} +4 -4
- package/dist/{state-renderer-XYLNRWXR.js → state-renderer-AWZ3ECAX.js} +8 -8
- package/dist/{themes-PdPR1-hC.d.ts → themes-32xj5ZTW.d.ts} +27 -0
- package/docs/language-reference.md +93 -10
- package/gallery/fixtures/clock.dgmo +3 -3
- package/gallery/fixtures/countdown-tz.dgmo +5 -0
- package/package.json +1 -1
- package/dist/dgmo-router-CE2G67FV.js +0 -84
- package/dist/dimensions-OTBKC5M6.js +0 -22
- package/dist/layout-6RDJHS6E.js +0 -9
- package/dist/layout-J36454XU.js +0 -14
- package/dist/layout-LD6XTLD6.js +0 -14
- package/dist/parser-4WQQQXCG.js +0 -13
- package/dist/renderer-UYMQQCJK.js +0 -24
- package/dist/renderer-radial-F7X5F2VU.js +0 -21
package/dist/clock.js
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
// src/clock/resolve.ts
|
|
2
|
+
var CLOCK_RAMP = [
|
|
3
|
+
[0, "#3d478f"],
|
|
4
|
+
[4, "#4a4d8c"],
|
|
5
|
+
[6, "#c98a6b"],
|
|
6
|
+
[8, "#d9a441"],
|
|
7
|
+
[11, "#e0b23c"],
|
|
8
|
+
[13, "#4f96c4"],
|
|
9
|
+
[16, "#cc7a33"],
|
|
10
|
+
[19, "#8a5aa0"],
|
|
11
|
+
[24, "#3d478f"]
|
|
12
|
+
];
|
|
13
|
+
function hexLerp(a, b, t) {
|
|
14
|
+
const pa = [1, 3, 5].map((i) => parseInt(a.slice(i, i + 2), 16));
|
|
15
|
+
const pb = [1, 3, 5].map((i) => parseInt(b.slice(i, i + 2), 16));
|
|
16
|
+
const c = pa.map(
|
|
17
|
+
(v, i) => Math.round(v + (pb[i] - v) * t).toString(16).padStart(2, "0")
|
|
18
|
+
);
|
|
19
|
+
return `#${c.join("")}`;
|
|
20
|
+
}
|
|
21
|
+
function rampColor(h) {
|
|
22
|
+
const hh = (h % 24 + 24) % 24;
|
|
23
|
+
for (let i = 0; i < CLOCK_RAMP.length - 1; i++) {
|
|
24
|
+
const [h0, c0] = CLOCK_RAMP[i];
|
|
25
|
+
const [h1, c1] = CLOCK_RAMP[i + 1];
|
|
26
|
+
if (hh >= h0 && hh <= h1) return hexLerp(c0, c1, (hh - h0) / (h1 - h0));
|
|
27
|
+
}
|
|
28
|
+
return CLOCK_RAMP[0][1];
|
|
29
|
+
}
|
|
2
30
|
var SOON_MIN = 60;
|
|
3
31
|
var RAD = Math.PI / 180;
|
|
4
32
|
var DAY_MS = 864e5;
|
|
@@ -42,6 +70,33 @@ function zoneParts(zone, nowMs) {
|
|
|
42
70
|
function pad2(n) {
|
|
43
71
|
return n < 10 ? "0" + n : String(n);
|
|
44
72
|
}
|
|
73
|
+
var WEEKDAY_SHORT = [
|
|
74
|
+
"Sun",
|
|
75
|
+
"Mon",
|
|
76
|
+
"Tue",
|
|
77
|
+
"Wed",
|
|
78
|
+
"Thu",
|
|
79
|
+
"Fri",
|
|
80
|
+
"Sat"
|
|
81
|
+
];
|
|
82
|
+
function formatOffsetLabel(offsetMin) {
|
|
83
|
+
if (offsetMin === 0) return "UTC";
|
|
84
|
+
const sign = offsetMin < 0 ? "-" : "+";
|
|
85
|
+
const abs = Math.abs(offsetMin);
|
|
86
|
+
const h = Math.floor(abs / 60);
|
|
87
|
+
const mm = abs % 60;
|
|
88
|
+
return `UTC${sign}${h}${mm ? ":" + pad2(mm) : ""}`;
|
|
89
|
+
}
|
|
90
|
+
function fixedParts(offsetMin, nowMs) {
|
|
91
|
+
const d = new Date(nowMs + offsetMin * 6e4);
|
|
92
|
+
return {
|
|
93
|
+
h: d.getUTCHours(),
|
|
94
|
+
m: d.getUTCMinutes(),
|
|
95
|
+
s: d.getUTCSeconds(),
|
|
96
|
+
weekday: WEEKDAY_SHORT[d.getUTCDay()],
|
|
97
|
+
offsetLabel: formatOffsetLabel(offsetMin)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
45
100
|
function formatTime(h, m, s, hours12) {
|
|
46
101
|
const sec = pad2(s);
|
|
47
102
|
if (hours12) {
|
|
@@ -129,6 +184,22 @@ function handAngles(h, m, s) {
|
|
|
129
184
|
};
|
|
130
185
|
}
|
|
131
186
|
|
|
187
|
+
// src/palettes/color-utils.ts
|
|
188
|
+
function mix(a, b, pct) {
|
|
189
|
+
const parse = (h) => {
|
|
190
|
+
const r = h.replace("#", "");
|
|
191
|
+
const f = r.length === 3 ? [...r].map((c2) => c2 + c2).join("") : r;
|
|
192
|
+
return [
|
|
193
|
+
parseInt(f.substring(0, 2), 16),
|
|
194
|
+
parseInt(f.substring(2, 4), 16),
|
|
195
|
+
parseInt(f.substring(4, 6), 16)
|
|
196
|
+
];
|
|
197
|
+
};
|
|
198
|
+
const [ar, ag, ab] = parse(a), [br, bg, bb] = parse(b), t = pct / 100;
|
|
199
|
+
const c = (x, y) => Math.round(x * t + y * (1 - t)).toString(16).padStart(2, "0");
|
|
200
|
+
return `#${c(ar, br)}${c(ag, bg)}${c(ab, bb)}`;
|
|
201
|
+
}
|
|
202
|
+
|
|
132
203
|
// src/clock/ticker.ts
|
|
133
204
|
function readWork(node) {
|
|
134
205
|
const start = node.getAttribute("data-dgmo-clock-work-start");
|
|
@@ -151,7 +222,8 @@ function setPart(group, sel, textContent) {
|
|
|
151
222
|
function updateRow(group, now) {
|
|
152
223
|
const zone = group.getAttribute("data-dgmo-clock-zone");
|
|
153
224
|
if (!zone) return;
|
|
154
|
-
const
|
|
225
|
+
const fixedAttr = group.getAttribute("data-dgmo-clock-fixed-offset");
|
|
226
|
+
const parts = fixedAttr !== null ? fixedParts(Number(fixedAttr), now) : zoneParts(zone, now);
|
|
155
227
|
const latAttr = group.getAttribute("data-dgmo-clock-lat");
|
|
156
228
|
const lonAttr = group.getAttribute("data-dgmo-clock-lon");
|
|
157
229
|
const sunOn = group.getAttribute("data-dgmo-clock-sun") === "1";
|
|
@@ -167,9 +239,13 @@ function updateRow(group, now) {
|
|
|
167
239
|
setHand(group, "h", ang.hour);
|
|
168
240
|
setHand(group, "m", ang.minute);
|
|
169
241
|
setHand(group, "s", ang.second);
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
|
|
242
|
+
const mode = group.getAttribute("data-dgmo-clock-auto-mode");
|
|
243
|
+
const cardFill = group.getAttribute("data-dgmo-clock-cardfill");
|
|
244
|
+
let autoSolid = null;
|
|
245
|
+
if (mode === "daylight") autoSolid = up ? c("day") : c("night");
|
|
246
|
+
else if (mode === "time") autoSolid = rampColor(parts.h);
|
|
247
|
+
else if (mode) autoSolid = group.getAttribute("data-dgmo-clock-auto-solid");
|
|
248
|
+
const faceFill = autoSolid && cardFill ? mix(autoSolid, cardFill, 20) : group.getAttribute("data-dgmo-clock-auto-face") ?? stTint;
|
|
173
249
|
const handColor = autoSolid ?? stColor;
|
|
174
250
|
const face = group.querySelector("[data-dgmo-clock-facebg]");
|
|
175
251
|
if (face) face.setAttribute("fill", faceFill);
|
|
@@ -181,7 +257,7 @@ function updateRow(group, now) {
|
|
|
181
257
|
if (secondHand) secondHand.setAttribute("stroke", handColor);
|
|
182
258
|
setPart(group, '[data-dgmo-clock-digital-part="main"]', ts.main);
|
|
183
259
|
setPart(group, '[data-dgmo-clock-digital-part="sec"]', `:${ts.sec}`);
|
|
184
|
-
setPart(group, '[data-dgmo-clock-digital-part="ap"]',
|
|
260
|
+
setPart(group, '[data-dgmo-clock-digital-part="ap"]', ts.ap);
|
|
185
261
|
setPart(group, "[data-dgmo-clock-ampm]", ts.ap.toUpperCase());
|
|
186
262
|
const work = readWork(group);
|
|
187
263
|
const status = workStatus(parts, work);
|
|
@@ -203,6 +279,16 @@ function updateRow(group, now) {
|
|
|
203
279
|
}
|
|
204
280
|
}
|
|
205
281
|
}
|
|
282
|
+
const lane = group.querySelector("[data-dgmo-clock-lane]");
|
|
283
|
+
if (lane && mode) {
|
|
284
|
+
let laneFill = null;
|
|
285
|
+
if (mode === "daylight") laneFill = stTint;
|
|
286
|
+
else if (mode === "time" && cardFill)
|
|
287
|
+
laneFill = mix(rampColor(parts.h), cardFill, 14);
|
|
288
|
+
else if (mode === "work" && status)
|
|
289
|
+
laneFill = status.cls === "ok" ? c("ok-soft") : status.cls === "soon" ? c("soon-soft") : c("off-soft");
|
|
290
|
+
if (laneFill) lane.setAttribute("fill", laneFill);
|
|
291
|
+
}
|
|
206
292
|
const sunEl = group.querySelector("[data-dgmo-clock-sun-line]");
|
|
207
293
|
if (sun && sunEl) {
|
|
208
294
|
if (sunEl.textContent !== sun.text) sunEl.textContent = sun.text;
|
package/dist/countdown.js
CHANGED
|
@@ -1,6 +1,102 @@
|
|
|
1
1
|
// src/countdown/resolve.ts
|
|
2
2
|
var DAY_MS = 864e5;
|
|
3
3
|
var WEEK_MS = 7 * DAY_MS;
|
|
4
|
+
var ZONE_WD = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
5
|
+
function zoneFields(ms, tz) {
|
|
6
|
+
const d = new Date(ms);
|
|
7
|
+
if (!tz) {
|
|
8
|
+
return {
|
|
9
|
+
year: d.getFullYear(),
|
|
10
|
+
month: d.getMonth(),
|
|
11
|
+
day: d.getDate(),
|
|
12
|
+
hour: d.getHours(),
|
|
13
|
+
minute: d.getMinutes(),
|
|
14
|
+
second: d.getSeconds(),
|
|
15
|
+
weekday: d.getDay()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const o = {};
|
|
20
|
+
new Intl.DateTimeFormat("en-US", {
|
|
21
|
+
timeZone: tz,
|
|
22
|
+
hour12: false,
|
|
23
|
+
year: "numeric",
|
|
24
|
+
month: "2-digit",
|
|
25
|
+
day: "2-digit",
|
|
26
|
+
hour: "2-digit",
|
|
27
|
+
minute: "2-digit",
|
|
28
|
+
second: "2-digit",
|
|
29
|
+
weekday: "short"
|
|
30
|
+
}).formatToParts(d).forEach((x) => {
|
|
31
|
+
o[x.type] = x.value;
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
year: Number(o["year"]),
|
|
35
|
+
month: Number(o["month"]) - 1,
|
|
36
|
+
day: Number(o["day"]),
|
|
37
|
+
hour: Number(o["hour"]) % 24,
|
|
38
|
+
minute: Number(o["minute"]),
|
|
39
|
+
second: Number(o["second"]),
|
|
40
|
+
weekday: Math.max(0, ZONE_WD.indexOf(o["weekday"] ?? "Sun"))
|
|
41
|
+
};
|
|
42
|
+
} catch {
|
|
43
|
+
return {
|
|
44
|
+
year: d.getUTCFullYear(),
|
|
45
|
+
month: d.getUTCMonth(),
|
|
46
|
+
day: d.getUTCDate(),
|
|
47
|
+
hour: d.getUTCHours(),
|
|
48
|
+
minute: d.getUTCMinutes(),
|
|
49
|
+
second: d.getUTCSeconds(),
|
|
50
|
+
weekday: d.getUTCDay()
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function zoneOffsetMs(tz, ms) {
|
|
55
|
+
const f = zoneFields(ms, tz);
|
|
56
|
+
const asUTC = Date.UTC(f.year, f.month, f.day, f.hour, f.minute, f.second);
|
|
57
|
+
return asUTC - Math.floor(ms / 1e3) * 1e3;
|
|
58
|
+
}
|
|
59
|
+
function wallToMs(y, mo, d, h, mi, tz) {
|
|
60
|
+
if (!tz) return new Date(y, mo, d, h, mi).getTime();
|
|
61
|
+
const guess = Date.UTC(y, mo, d, h, mi);
|
|
62
|
+
const off1 = zoneOffsetMs(tz, guess);
|
|
63
|
+
const ms = guess - off1;
|
|
64
|
+
const off2 = zoneOffsetMs(tz, ms);
|
|
65
|
+
return off2 === off1 ? ms : guess - off2;
|
|
66
|
+
}
|
|
67
|
+
function zoneOffsetLabel(ms, tz) {
|
|
68
|
+
if (!tz) return "";
|
|
69
|
+
try {
|
|
70
|
+
const off = new Intl.DateTimeFormat("en-US", {
|
|
71
|
+
timeZone: tz,
|
|
72
|
+
timeZoneName: "shortOffset"
|
|
73
|
+
}).formatToParts(new Date(ms)).find((x) => x.type === "timeZoneName");
|
|
74
|
+
return off ? off.value.replace("GMT", "UTC") : "";
|
|
75
|
+
} catch {
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
var DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
80
|
+
var LOCAL_DT_RE = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/;
|
|
81
|
+
function targetToMs(target, tz = null) {
|
|
82
|
+
const s = target.trim();
|
|
83
|
+
if (DATE_ONLY_RE.test(s)) {
|
|
84
|
+
const [y, m, d] = s.split("-").map(Number);
|
|
85
|
+
return wallToMs(y, m - 1, d, 0, 0, tz);
|
|
86
|
+
}
|
|
87
|
+
const dt = LOCAL_DT_RE.exec(s);
|
|
88
|
+
if (dt) {
|
|
89
|
+
return wallToMs(
|
|
90
|
+
Number(dt[1]),
|
|
91
|
+
Number(dt[2]) - 1,
|
|
92
|
+
Number(dt[3]),
|
|
93
|
+
Number(dt[4]),
|
|
94
|
+
Number(dt[5]),
|
|
95
|
+
tz
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return new Date(s).getTime();
|
|
99
|
+
}
|
|
4
100
|
function ordinalWord(n) {
|
|
5
101
|
const abs = Math.abs(n);
|
|
6
102
|
const tens = abs % 100;
|
|
@@ -14,16 +110,24 @@ function ordinalWord(n) {
|
|
|
14
110
|
function applyOrdinalTemplate(template, n) {
|
|
15
111
|
return template.replace(/\bNth\b/g, ordinalWord(n)).replace(/\bN\b/g, String(n));
|
|
16
112
|
}
|
|
17
|
-
function dayStart(ms) {
|
|
18
|
-
const
|
|
19
|
-
return
|
|
113
|
+
function dayStart(ms, tz = null) {
|
|
114
|
+
const f = zoneFields(ms, tz);
|
|
115
|
+
return wallToMs(f.year, f.month, f.day, 0, 0, tz);
|
|
20
116
|
}
|
|
21
|
-
function
|
|
117
|
+
function dayDelta(a, b, tz = null) {
|
|
118
|
+
return Math.round((dayStart(b, tz) - dayStart(a, tz)) / DAY_MS);
|
|
119
|
+
}
|
|
120
|
+
function sameDay(a, b, tz = null) {
|
|
121
|
+
const x = zoneFields(a, tz);
|
|
122
|
+
const y = zoneFields(b, tz);
|
|
123
|
+
return x.year === y.year && x.month === y.month && x.day === y.day;
|
|
124
|
+
}
|
|
125
|
+
function nthWeekdayOfMonth(year, month, weekday, nth, hour, minute, tz) {
|
|
22
126
|
if (nth < 0) {
|
|
23
127
|
const last = new Date(year, month + 1, 0).getDate();
|
|
24
128
|
for (let d = last; d >= 1; d--) {
|
|
25
129
|
if (new Date(year, month, d).getDay() === weekday) {
|
|
26
|
-
return
|
|
130
|
+
return wallToMs(year, month, d, hour, minute, tz);
|
|
27
131
|
}
|
|
28
132
|
}
|
|
29
133
|
return null;
|
|
@@ -32,20 +136,21 @@ function nthWeekdayOfMonth(year, month, weekday, nth, hour, minute) {
|
|
|
32
136
|
const offset = (weekday - firstDow + 7) % 7;
|
|
33
137
|
const day = 1 + offset + (nth - 1) * 7;
|
|
34
138
|
if (day > new Date(year, month + 1, 0).getDate()) return null;
|
|
35
|
-
return
|
|
139
|
+
return wallToMs(year, month, day, hour, minute, tz);
|
|
36
140
|
}
|
|
37
141
|
function resolveNext(rule, now) {
|
|
38
|
-
const
|
|
142
|
+
const tz = rule.tz ?? null;
|
|
143
|
+
const nowF = zoneFields(now, tz);
|
|
39
144
|
const { hour, minute } = rule;
|
|
40
|
-
const passes = rule.allDay ? (t) => dayStart(t) >= dayStart(now) : (t) => t > now;
|
|
145
|
+
const passes = rule.allDay ? (t) => dayStart(t, tz) >= dayStart(now, tz) : (t) => t > now;
|
|
41
146
|
const dayExists = (y, m, d) => new Date(y, m, d).getMonth() === m;
|
|
42
147
|
switch (rule.kind) {
|
|
43
148
|
case "month-day": {
|
|
44
149
|
const month = rule.month;
|
|
45
150
|
const day = rule.day;
|
|
46
|
-
for (let y =
|
|
151
|
+
for (let y = nowF.year; ; y++) {
|
|
47
152
|
if (!dayExists(y, month, day)) continue;
|
|
48
|
-
const t =
|
|
153
|
+
const t = wallToMs(y, month, day, hour, minute, tz);
|
|
49
154
|
if (passes(t)) return t;
|
|
50
155
|
}
|
|
51
156
|
}
|
|
@@ -53,10 +158,10 @@ function resolveNext(rule, now) {
|
|
|
53
158
|
case "last-weekday": {
|
|
54
159
|
const weekday = rule.weekday;
|
|
55
160
|
const nth = rule.kind === "last-weekday" ? -1 : rule.nth;
|
|
56
|
-
let y =
|
|
57
|
-
let m =
|
|
161
|
+
let y = nowF.year;
|
|
162
|
+
let m = nowF.month;
|
|
58
163
|
for (let i = 0; i < 24; i++) {
|
|
59
|
-
const t = nthWeekdayOfMonth(y, m, weekday, nth, hour, minute);
|
|
164
|
+
const t = nthWeekdayOfMonth(y, m, weekday, nth, hour, minute, tz);
|
|
60
165
|
if (t !== null && passes(t)) return t;
|
|
61
166
|
m++;
|
|
62
167
|
if (m > 11) {
|
|
@@ -69,14 +174,17 @@ function resolveNext(rule, now) {
|
|
|
69
174
|
case "weekly": {
|
|
70
175
|
const weekday = rule.weekday;
|
|
71
176
|
for (let i = 0; i < 8; i++) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
177
|
+
const cal = new Date(nowF.year, nowF.month, nowF.day + i);
|
|
178
|
+
if (cal.getDay() !== weekday) continue;
|
|
179
|
+
const t = wallToMs(
|
|
180
|
+
cal.getFullYear(),
|
|
181
|
+
cal.getMonth(),
|
|
182
|
+
cal.getDate(),
|
|
76
183
|
hour,
|
|
77
|
-
minute
|
|
184
|
+
minute,
|
|
185
|
+
tz
|
|
78
186
|
);
|
|
79
|
-
if (
|
|
187
|
+
if (passes(t)) return t;
|
|
80
188
|
}
|
|
81
189
|
return now + WEEK_MS;
|
|
82
190
|
}
|
|
@@ -84,15 +192,15 @@ function resolveNext(rule, now) {
|
|
|
84
192
|
const n = rule.intervalN ?? 1;
|
|
85
193
|
const anchor = rule.anchorMs ?? now;
|
|
86
194
|
if (rule.intervalUnit === "month") {
|
|
87
|
-
const a =
|
|
88
|
-
const day = a.
|
|
195
|
+
const a = zoneFields(anchor, tz);
|
|
196
|
+
const day = a.day;
|
|
89
197
|
for (let k = 0; ; k++) {
|
|
90
|
-
const y = a.
|
|
91
|
-
const m = a.
|
|
198
|
+
const y = a.year;
|
|
199
|
+
const m = a.month + k * n;
|
|
92
200
|
const yy = y + Math.floor(m / 12);
|
|
93
201
|
const mm = (m % 12 + 12) % 12;
|
|
94
202
|
if (!dayExists(yy, mm, day)) continue;
|
|
95
|
-
const t2 =
|
|
203
|
+
const t2 = wallToMs(yy, mm, day, hour, minute, tz);
|
|
96
204
|
if (passes(t2)) return t2;
|
|
97
205
|
}
|
|
98
206
|
}
|
|
@@ -153,6 +261,10 @@ function formatCount(remainingMs, opts) {
|
|
|
153
261
|
const dayPrefix = has("d") && days > 0 ? `${days}d${clock ? " " : ""}` : "";
|
|
154
262
|
return dayPrefix + clock || plural(days, "day");
|
|
155
263
|
}
|
|
264
|
+
function splitClockSeconds(s) {
|
|
265
|
+
const m = /^(.+:\d{2}):(\d{2})$/.exec(s);
|
|
266
|
+
return m ? { lead: m[1], sec: ":" + m[2] } : { lead: s, sec: null };
|
|
267
|
+
}
|
|
156
268
|
function formatWordsDetail(remainingMs) {
|
|
157
269
|
const totalMin = Math.floor(Math.max(0, remainingMs) / 6e4);
|
|
158
270
|
const d = Math.floor(totalMin / 1440);
|
|
@@ -164,15 +276,15 @@ function formatWordsDetail(remainingMs) {
|
|
|
164
276
|
parts.push(`${m} minute${m === 1 ? "" : "s"}`);
|
|
165
277
|
return parts.join(" ");
|
|
166
278
|
}
|
|
167
|
-
function breakdown(nowMs, targetMs) {
|
|
168
|
-
const n =
|
|
169
|
-
const t =
|
|
170
|
-
let y = t.
|
|
171
|
-
let mo = t.
|
|
172
|
-
let d = t.
|
|
173
|
-
let h = t.
|
|
174
|
-
let mi = t.
|
|
175
|
-
let s = t.
|
|
279
|
+
function breakdown(nowMs, targetMs, tz = null) {
|
|
280
|
+
const n = zoneFields(nowMs, tz);
|
|
281
|
+
const t = zoneFields(targetMs, tz);
|
|
282
|
+
let y = t.year - n.year;
|
|
283
|
+
let mo = t.month - n.month;
|
|
284
|
+
let d = t.day - n.day;
|
|
285
|
+
let h = t.hour - n.hour;
|
|
286
|
+
let mi = t.minute - n.minute;
|
|
287
|
+
let s = t.second - n.second;
|
|
176
288
|
if (s < 0) {
|
|
177
289
|
s += 60;
|
|
178
290
|
mi--;
|
|
@@ -186,7 +298,7 @@ function breakdown(nowMs, targetMs) {
|
|
|
186
298
|
d--;
|
|
187
299
|
}
|
|
188
300
|
if (d < 0) {
|
|
189
|
-
d += new Date(t.
|
|
301
|
+
d += new Date(t.year, t.month, 0).getDate();
|
|
190
302
|
mo--;
|
|
191
303
|
}
|
|
192
304
|
if (mo < 0) {
|
|
@@ -195,8 +307,8 @@ function breakdown(nowMs, targetMs) {
|
|
|
195
307
|
}
|
|
196
308
|
return { years: y, months: mo, days: d, hours: h, minutes: mi, seconds: s };
|
|
197
309
|
}
|
|
198
|
-
function humanUnits(nowMs, targetMs) {
|
|
199
|
-
const b = breakdown(nowMs, targetMs);
|
|
310
|
+
function humanUnits(nowMs, targetMs, tz = null) {
|
|
311
|
+
const b = breakdown(nowMs, targetMs, tz);
|
|
200
312
|
return [
|
|
201
313
|
[b.years, "year"],
|
|
202
314
|
[b.months, "month"],
|
|
@@ -205,8 +317,8 @@ function humanUnits(nowMs, targetMs) {
|
|
|
205
317
|
[b.minutes, "minute"]
|
|
206
318
|
];
|
|
207
319
|
}
|
|
208
|
-
function formatHuman(nowMs, targetMs) {
|
|
209
|
-
const units = humanUnits(nowMs, targetMs);
|
|
320
|
+
function formatHuman(nowMs, targetMs, tz = null) {
|
|
321
|
+
const units = humanUnits(nowMs, targetMs, tz);
|
|
210
322
|
let i = 0;
|
|
211
323
|
while (i < units.length - 1 && units[i][0] === 0) i++;
|
|
212
324
|
const rest = units.slice(i);
|
|
@@ -215,8 +327,8 @@ function formatHuman(nowMs, targetMs) {
|
|
|
215
327
|
const secondary = rest.slice(2).filter((p) => p[0] > 0);
|
|
216
328
|
return { big: say(primary) || "now", sub: say(secondary) };
|
|
217
329
|
}
|
|
218
|
-
function formatCompound(nowMs, targetMs, maxUnits = 2) {
|
|
219
|
-
const all = humanUnits(nowMs, targetMs);
|
|
330
|
+
function formatCompound(nowMs, targetMs, maxUnits = 2, tz = null) {
|
|
331
|
+
const all = humanUnits(nowMs, targetMs, tz);
|
|
220
332
|
let i = 0;
|
|
221
333
|
while (i < all.length - 1 && all[i][0] === 0) i++;
|
|
222
334
|
const chosen = all.slice(i, i + maxUnits).filter((p, idx) => p[0] > 0 || idx === 0);
|
|
@@ -238,35 +350,54 @@ var MONTH_ABBR = [
|
|
|
238
350
|
"Nov",
|
|
239
351
|
"Dec"
|
|
240
352
|
];
|
|
241
|
-
function formatDate(ms) {
|
|
242
|
-
const
|
|
243
|
-
return `${WEEKDAY_ABBR[
|
|
353
|
+
function formatDate(ms, tz = null) {
|
|
354
|
+
const f = zoneFields(ms, tz);
|
|
355
|
+
return `${WEEKDAY_ABBR[f.weekday]} ${MONTH_ABBR[f.month]} ${f.day} ${f.year}`;
|
|
244
356
|
}
|
|
245
|
-
function formatFooter(resolvedMs, hasTime) {
|
|
246
|
-
const parts = [formatDate(resolvedMs)];
|
|
357
|
+
function formatFooter(resolvedMs, hasTime, tz = null) {
|
|
358
|
+
const parts = [formatDate(resolvedMs, tz)];
|
|
247
359
|
if (hasTime) {
|
|
248
|
-
const
|
|
249
|
-
parts.push(`${pad2(
|
|
360
|
+
const f = zoneFields(resolvedMs, tz);
|
|
361
|
+
parts.push(`${pad2(f.hour)}:${pad2(f.minute)}`);
|
|
362
|
+
const label = zoneOffsetLabel(resolvedMs, tz);
|
|
363
|
+
if (label) parts.push(label);
|
|
250
364
|
}
|
|
251
365
|
return parts.join(" \xB7 ");
|
|
252
366
|
}
|
|
253
367
|
|
|
254
368
|
// src/countdown/ticker.ts
|
|
255
|
-
var DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
256
|
-
function dayStartLocal(ms) {
|
|
257
|
-
const d = new Date(ms);
|
|
258
|
-
return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
259
|
-
}
|
|
260
|
-
function dayDeltaLocal(aMs, bMs) {
|
|
261
|
-
const a = new Date(aMs);
|
|
262
|
-
const b = new Date(bMs);
|
|
263
|
-
const a0 = new Date(a.getFullYear(), a.getMonth(), a.getDate()).getTime();
|
|
264
|
-
const b0 = new Date(b.getFullYear(), b.getMonth(), b.getDate()).getTime();
|
|
265
|
-
return Math.round((b0 - a0) / DAY_MS);
|
|
266
|
-
}
|
|
267
369
|
function pad22(n) {
|
|
268
370
|
return n < 10 ? "0" + n : String(n);
|
|
269
371
|
}
|
|
372
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
373
|
+
function setClockText(el, str) {
|
|
374
|
+
if (el.hasAttribute("data-dgmo-cd-clock")) {
|
|
375
|
+
const { lead, sec } = splitClockSeconds(str);
|
|
376
|
+
if (sec !== null) {
|
|
377
|
+
let leadT = el.querySelector("[data-cd-lead]");
|
|
378
|
+
let secT = el.querySelector("[data-cd-sec]");
|
|
379
|
+
if (!leadT || !secT) {
|
|
380
|
+
while (el.firstChild) el.removeChild(el.firstChild);
|
|
381
|
+
const doc = el.ownerDocument;
|
|
382
|
+
leadT = doc.createElementNS(SVG_NS, "tspan");
|
|
383
|
+
leadT.setAttribute("data-cd-lead", "");
|
|
384
|
+
secT = doc.createElementNS(SVG_NS, "tspan");
|
|
385
|
+
secT.setAttribute("data-cd-sec", "");
|
|
386
|
+
const size = el.getAttribute("data-dgmo-cd-sec-size");
|
|
387
|
+
const fill = el.getAttribute("data-dgmo-cd-sec-fill");
|
|
388
|
+
if (size) secT.setAttribute("font-size", size);
|
|
389
|
+
if (fill) secT.setAttribute("fill", fill);
|
|
390
|
+
secT.setAttribute("font-weight", "700");
|
|
391
|
+
el.appendChild(leadT);
|
|
392
|
+
el.appendChild(secT);
|
|
393
|
+
}
|
|
394
|
+
if (leadT.textContent !== lead) leadT.textContent = lead;
|
|
395
|
+
if (secT.textContent !== sec) secT.textContent = sec;
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (el.textContent !== str) el.textContent = str;
|
|
400
|
+
}
|
|
270
401
|
function polar(cx, cy, r, deg) {
|
|
271
402
|
const a = (deg - 90) * Math.PI / 180;
|
|
272
403
|
return [cx + r * Math.cos(a), cy + r * Math.sin(a)];
|
|
@@ -308,13 +439,8 @@ function updateGauges(svg, remaining) {
|
|
|
308
439
|
if (cap.textContent !== t) cap.textContent = t;
|
|
309
440
|
}
|
|
310
441
|
}
|
|
311
|
-
function
|
|
312
|
-
const
|
|
313
|
-
if (DATE_ONLY_RE.test(s)) {
|
|
314
|
-
const p = s.split("-").map(Number);
|
|
315
|
-
return new Date(p[0], p[1] - 1, p[2]).getTime();
|
|
316
|
-
}
|
|
317
|
-
const t = new Date(s).getTime();
|
|
442
|
+
function targetToMs2(target, tz) {
|
|
443
|
+
const t = targetToMs(target, tz);
|
|
318
444
|
return Number.isFinite(t) ? t : null;
|
|
319
445
|
}
|
|
320
446
|
function readRule(node) {
|
|
@@ -335,14 +461,10 @@ function readRule(node) {
|
|
|
335
461
|
allDay: node.getAttribute("data-dgmo-recur-allday") !== "0",
|
|
336
462
|
intervalN: num("data-dgmo-recur-interval-n"),
|
|
337
463
|
intervalUnit: node.getAttribute("data-dgmo-recur-interval-unit") ?? void 0,
|
|
338
|
-
anchorMs: num("data-dgmo-recur-anchor")
|
|
464
|
+
anchorMs: num("data-dgmo-recur-anchor"),
|
|
465
|
+
tz: node.getAttribute("data-dgmo-recur-tz") ?? void 0
|
|
339
466
|
};
|
|
340
467
|
}
|
|
341
|
-
function sameLocalDay(a, b) {
|
|
342
|
-
const x = new Date(a);
|
|
343
|
-
const y = new Date(b);
|
|
344
|
-
return x.getFullYear() === y.getFullYear() && x.getMonth() === y.getMonth() && x.getDate() === y.getDate();
|
|
345
|
-
}
|
|
346
468
|
function readFields(node) {
|
|
347
469
|
const raw = node.getAttribute("data-dgmo-countdown-fields");
|
|
348
470
|
if (!raw) return ["d", "h", "m", "s"];
|
|
@@ -355,13 +477,14 @@ function updateNode(node, now) {
|
|
|
355
477
|
const fields = readFields(node);
|
|
356
478
|
const onDay = node.getAttribute("data-dgmo-countdown-onday");
|
|
357
479
|
const title = node.getAttribute("data-dgmo-countdown-title");
|
|
480
|
+
const tz = node.getAttribute("data-dgmo-countdown-tz");
|
|
358
481
|
let resolvedMs;
|
|
359
482
|
let expiredNow = false;
|
|
360
483
|
if (rule) {
|
|
361
484
|
resolvedMs = resolveNext(rule, now);
|
|
362
485
|
} else {
|
|
363
486
|
const target = node.getAttribute("data-dgmo-countdown");
|
|
364
|
-
resolvedMs = target ?
|
|
487
|
+
resolvedMs = target ? targetToMs2(target, tz) : null;
|
|
365
488
|
if (resolvedMs !== null && resolvedMs - now <= 0) expiredNow = true;
|
|
366
489
|
}
|
|
367
490
|
if (resolvedMs === null) return;
|
|
@@ -370,7 +493,7 @@ function updateNode(node, now) {
|
|
|
370
493
|
const custom = node.getAttribute("data-dgmo-countdown-expired");
|
|
371
494
|
const hasTime = node.getAttribute("data-dgmo-countdown-hastime") === "1";
|
|
372
495
|
const frozen = expiredNow && custom !== null;
|
|
373
|
-
const clockFinale = hasTime && !frozen &&
|
|
496
|
+
const clockFinale = hasTime && !frozen && dayDelta(now, resolvedMs, tz) <= 0;
|
|
374
497
|
let text;
|
|
375
498
|
if (frozen) {
|
|
376
499
|
text = custom;
|
|
@@ -383,21 +506,21 @@ function updateNode(node, now) {
|
|
|
383
506
|
text = remaining < 0 ? `${clock} ago` : clock;
|
|
384
507
|
} else if (expiredNow) {
|
|
385
508
|
if (units === "compound" || units === "human")
|
|
386
|
-
text = `${formatCompound(resolvedMs, now)} ago`;
|
|
509
|
+
text = `${formatCompound(resolvedMs, now, 2, tz)} ago`;
|
|
387
510
|
else {
|
|
388
511
|
const elapsed = -remaining;
|
|
389
512
|
text = elapsed <= 0 ? "Now!" : `${formatCount(elapsed, { units, round, fields })} ago`;
|
|
390
513
|
}
|
|
391
|
-
} else if (rule &&
|
|
514
|
+
} else if (rule && sameDay(resolvedMs, now, tz)) {
|
|
392
515
|
text = onDay ?? "Today!";
|
|
393
516
|
} else if (units === "human") {
|
|
394
|
-
text = hasTime ? formatHuman(now, resolvedMs).big : formatHuman(
|
|
517
|
+
text = hasTime ? formatHuman(now, resolvedMs, tz).big : formatHuman(dayStart(now, tz), dayStart(resolvedMs, tz), tz).big;
|
|
395
518
|
} else if (units === "compound") {
|
|
396
|
-
text = formatCompound(now, resolvedMs);
|
|
519
|
+
text = formatCompound(now, resolvedMs, 2, tz);
|
|
397
520
|
} else {
|
|
398
521
|
text = formatCount(Math.max(0, remaining), { units, round, fields });
|
|
399
522
|
}
|
|
400
|
-
|
|
523
|
+
setClockText(node, text);
|
|
401
524
|
node.setAttribute(
|
|
402
525
|
"aria-label",
|
|
403
526
|
title ? `${title}: ${text}` : expiredNow ? text : `${text} remaining`
|
|
@@ -407,7 +530,7 @@ function updateNode(node, now) {
|
|
|
407
530
|
const footer = svg.querySelector("[data-dgmo-countdown-footer]");
|
|
408
531
|
if (footer && !expiredNow) {
|
|
409
532
|
const hasTime2 = node.getAttribute("data-dgmo-countdown-hastime") === "1";
|
|
410
|
-
footer.textContent = formatFooter(resolvedMs, hasTime2);
|
|
533
|
+
footer.textContent = formatFooter(resolvedMs, hasTime2, tz);
|
|
411
534
|
}
|
|
412
535
|
const eyebrowEl = svg.querySelector("[data-dgmo-countdown-eyebrow]");
|
|
413
536
|
if (eyebrowEl && sinceAttr) {
|
|
@@ -420,9 +543,12 @@ function updateNode(node, now) {
|
|
|
420
543
|
const detail = svg.querySelector("[data-dgmo-countdown-detail]");
|
|
421
544
|
if (detail && !expiredNow && !clockFinale) {
|
|
422
545
|
if (units === "words") {
|
|
423
|
-
detail
|
|
546
|
+
setClockText(detail, formatWordsDetail(Math.max(0, remaining)));
|
|
424
547
|
} else if (units === "human" && remaining > 0) {
|
|
425
|
-
|
|
548
|
+
setClockText(
|
|
549
|
+
detail,
|
|
550
|
+
hasTime ? formatCount(remaining, { units: "clock", round, fields }) : formatHuman(dayStart(now, tz), dayStart(resolvedMs, tz), tz).sub
|
|
551
|
+
);
|
|
426
552
|
}
|
|
427
553
|
}
|
|
428
554
|
if (clockFinale) updateGauges(svg, remaining);
|