@heycys/gallery 0.1.1 → 0.2.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.
Files changed (473) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/browser/editor/components/align.mjs +58 -0
  3. package/browser/editor/components/code/index.mjs +1 -1
  4. package/browser/editor/components/columns/page.mjs +4 -4
  5. package/browser/editor/components/embed/index.mjs +2 -2
  6. package/browser/editor/components/embed/page.mjs +1 -1
  7. package/browser/editor/components/file/page.mjs +4 -4
  8. package/browser/editor/components/flowchart/add.mjs +7 -6
  9. package/browser/editor/components/flowchart/page.mjs +1 -1
  10. package/browser/editor/components/heading/index.mjs +7 -6
  11. package/browser/editor/components/icons.mjs +11 -0
  12. package/browser/editor/components/image/crop.mjs +6 -9
  13. package/browser/editor/components/image/index.mjs +2 -0
  14. package/browser/editor/components/image/page.mjs +172 -90
  15. package/browser/editor/components/installed/index.mjs +15 -4
  16. package/browser/editor/components/installed/page.mjs +103 -25
  17. package/browser/editor/components/installed/served.mjs +6 -5
  18. package/browser/editor/components/instances.mjs +18 -0
  19. package/browser/editor/components/list/page.mjs +3 -6
  20. package/browser/editor/components/media/icons.mjs +13 -8
  21. package/browser/editor/components/media/page.mjs +5 -3
  22. package/browser/editor/components/media/toolbar.mjs +12 -3
  23. package/browser/editor/components/paragraph/index.mjs +4 -3
  24. package/browser/editor/components/registry.mjs +30 -9
  25. package/browser/editor/components/table/index.mjs +61 -2
  26. package/browser/editor/components/table/page.mjs +1 -1
  27. package/browser/editor/page/after/index.mjs +288 -0
  28. package/browser/editor/page/align.mjs +91 -0
  29. package/browser/editor/page/annotate/card.mjs +3 -6
  30. package/browser/editor/page/autosave.mjs +310 -37
  31. package/browser/editor/page/beside.mjs +5 -6
  32. package/browser/editor/page/block-menu/index.mjs +6 -3
  33. package/browser/editor/page/blocks.mjs +3 -1
  34. package/browser/editor/page/board/client.mjs +57 -0
  35. package/browser/editor/page/board/hint.mjs +182 -0
  36. package/browser/editor/page/board/history.mjs +119 -0
  37. package/browser/editor/page/board/index.mjs +1059 -0
  38. package/browser/editor/page/board/motion.mjs +177 -0
  39. package/browser/editor/page/board/settings.mjs +210 -0
  40. package/browser/editor/page/caret.mjs +1 -1
  41. package/browser/editor/page/changes/bar.mjs +6 -14
  42. package/browser/editor/page/changes/index.mjs +2 -2
  43. package/browser/editor/page/clipboard/import/html.mjs +29 -6
  44. package/browser/editor/page/clipboard/import/inline.mjs +32 -0
  45. package/browser/editor/page/clipboard/import/markdown.mjs +58 -13
  46. package/browser/editor/page/clipboard/import/read.mjs +6 -1
  47. package/browser/editor/page/clipboard/import/to-blocks.mjs +44 -12
  48. package/browser/editor/page/clipboard/import/yuque.mjs +622 -0
  49. package/browser/editor/page/clipboard/index.mjs +133 -15
  50. package/browser/editor/page/clipboard/own/blocks.mjs +13 -14
  51. package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
  52. package/browser/editor/page/clipboard/own/describe.mjs +6 -2
  53. package/browser/editor/page/clipboard/own/selection.mjs +1 -1
  54. package/browser/editor/page/columns/index.mjs +48 -46
  55. package/browser/editor/page/commit.mjs +80 -22
  56. package/browser/editor/page/conflicts.mjs +7 -7
  57. package/browser/editor/page/core.mjs +34 -16
  58. package/browser/editor/page/custom-page.mjs +110 -0
  59. package/browser/editor/page/editor.mjs +71 -17
  60. package/browser/editor/page/emoji-picker/styles.mjs +7 -12
  61. package/browser/editor/page/emoji-picker/upload.mjs +2 -2
  62. package/browser/editor/page/handle/index.mjs +5 -8
  63. package/browser/editor/page/history.mjs +41 -6
  64. package/browser/editor/page/insert/index.mjs +20 -22
  65. package/browser/editor/page/links/index.mjs +5 -3
  66. package/browser/editor/page/links/pages.mjs +27 -9
  67. package/browser/editor/page/look.mjs +54 -3
  68. package/browser/editor/page/margin.mjs +18 -3
  69. package/browser/editor/page/media-menu/index.mjs +6 -7
  70. package/browser/editor/page/menu.mjs +33 -14
  71. package/browser/editor/page/notices.mjs +2 -2
  72. package/browser/editor/page/page-objects.mjs +9 -2
  73. package/browser/editor/page/panel.mjs +4 -9
  74. package/browser/editor/page/present-links.mjs +15 -5
  75. package/browser/editor/page/present-shell.mjs +63 -0
  76. package/browser/editor/page/resize/index.mjs +42 -29
  77. package/browser/editor/page/selection/index.mjs +10 -2
  78. package/browser/editor/page/served.mjs +14 -0
  79. package/browser/editor/page/session.mjs +48 -4
  80. package/browser/editor/page/slash-menu/index.mjs +3 -3
  81. package/browser/editor/page/table/binding.mjs +87 -0
  82. package/browser/editor/page/table/cells.mjs +102 -46
  83. package/browser/editor/page/table/index.mjs +24 -9
  84. package/browser/editor/page/table/pictures.mjs +299 -0
  85. package/browser/editor/page/table/views.mjs +103 -0
  86. package/browser/editor/page/table/widths.mjs +82 -10
  87. package/browser/editor/page/text-select/index.mjs +26 -12
  88. package/browser/editor/page/todo-writes.mjs +75 -0
  89. package/browser/editor/page/typing/index.mjs +97 -15
  90. package/browser/editor/page/typing/leave.mjs +19 -5
  91. package/browser/editor/page/ui.mjs +13 -0
  92. package/browser/shared/block-packs.mjs +419 -0
  93. package/browser/shared/board-places.mjs +224 -0
  94. package/browser/shared/card-size.mjs +59 -0
  95. package/browser/shared/colors.mjs +3 -2
  96. package/browser/shared/component-catalog.mjs +330 -46
  97. package/browser/shared/component-source.mjs +39 -0
  98. package/browser/shared/components/heading.mjs +2 -1
  99. package/browser/shared/components/index.mjs +12 -3
  100. package/browser/shared/components/installed.mjs +35 -3
  101. package/browser/shared/components/page.mjs +20 -8
  102. package/browser/shared/components/paragraph.mjs +8 -1
  103. package/browser/shared/components/state.mjs +5 -1
  104. package/browser/shared/components/table.mjs +1 -0
  105. package/browser/shared/document-look.mjs +10 -5
  106. package/browser/shared/drafts.mjs +432 -0
  107. package/browser/shared/emoji/line-icons.mjs +37 -0
  108. package/browser/shared/extension-sidebar.mjs +126 -0
  109. package/browser/shared/extensions.mjs +79 -0
  110. package/browser/shared/file-table.mjs +101 -0
  111. package/browser/shared/http.mjs +9 -0
  112. package/browser/shared/i18n/en.mjs +330 -27
  113. package/browser/shared/json-layout.mjs +47 -0
  114. package/browser/shared/net-cache.mjs +133 -0
  115. package/browser/shared/net-keys.mjs +32 -0
  116. package/browser/shared/net-policy.mjs +177 -0
  117. package/browser/shared/outline-shape.mjs +128 -0
  118. package/browser/shared/outline.mjs +359 -67
  119. package/browser/shared/pack-manifest.mjs +88 -0
  120. package/browser/shared/page-address.mjs +6 -3
  121. package/browser/shared/page-cards.mjs +308 -0
  122. package/browser/shared/page-links.mjs +69 -6
  123. package/browser/shared/pages.mjs +500 -0
  124. package/browser/shared/paths.mjs +6 -0
  125. package/browser/shared/pinyin.mjs +92 -0
  126. package/browser/shared/present-step.mjs +17 -0
  127. package/browser/shared/preview-server.mjs +3 -7
  128. package/browser/shared/session.mjs +8 -1
  129. package/browser/shared/shipped-blocks.mjs +299 -0
  130. package/browser/shared/sidebar-head.mjs +70 -0
  131. package/browser/shared/table-chart.mjs +33 -1
  132. package/browser/shared/todos.mjs +83 -0
  133. package/browser/shared/user-directory.mjs +24 -0
  134. package/browser/shared/versions.mjs +14 -0
  135. package/browser/shared/web-links.mjs +139 -0
  136. package/browser/shared/workspace-columns.mjs +120 -0
  137. package/browser/shared/workspace-name.mjs +154 -0
  138. package/browser/shared/workspace-query.mjs +125 -0
  139. package/browser/shared/workspace-registry.mjs +272 -0
  140. package/browser/shared/workspace.mjs +171 -20
  141. package/dist/chunk-2OHANJ6Q.mjs +2 -0
  142. package/dist/chunk-3MBRL2PM.mjs +16 -0
  143. package/dist/chunk-4OKWZY5E.mjs +2 -0
  144. package/dist/chunk-4OZWXZE5.mjs +5 -0
  145. package/dist/chunk-5K44HLTZ.mjs +2 -0
  146. package/dist/{chunk-5ZKJ3H4P.mjs → chunk-5XA2ZBAE.mjs} +3 -3
  147. package/dist/{chunk-4FS7Z7WR.mjs → chunk-67N2QJYT.mjs} +1 -1
  148. package/dist/chunk-6KBYRA2C.mjs +2 -0
  149. package/dist/chunk-6N3PX4XX.mjs +8 -0
  150. package/dist/{chunk-V5JTW2LH.mjs → chunk-6QBHU4DF.mjs} +1 -1
  151. package/dist/chunk-7JDX4E65.mjs +13 -0
  152. package/dist/chunk-7M2BQQGZ.mjs +2 -0
  153. package/dist/chunk-7OG26PGF.mjs +2 -0
  154. package/dist/chunk-AHN3NFKJ.mjs +3 -0
  155. package/dist/chunk-ALZ6ZENZ.mjs +3 -0
  156. package/dist/chunk-AR5D57ZD.mjs +170 -0
  157. package/dist/{chunk-W3BGBJQW.mjs → chunk-BFJGHSQN.mjs} +1 -1
  158. package/dist/{chunk-LS4F7JUM.mjs → chunk-BZ5RAF7L.mjs} +1 -1
  159. package/dist/chunk-CMA72MAG.mjs +2 -0
  160. package/dist/{chunk-LCTHTZIL.mjs → chunk-DAZL73VK.mjs} +91 -91
  161. package/dist/{chunk-Y6RLRPG3.mjs → chunk-DJISHPUL.mjs} +1 -1
  162. package/dist/chunk-DR73Y2UJ.mjs +3 -0
  163. package/dist/{chunk-FDLXYYG4.mjs → chunk-EAIFITAV.mjs} +1 -1
  164. package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
  165. package/dist/chunk-EP25HDAJ.mjs +2 -0
  166. package/dist/{chunk-GB5SOYQJ.mjs → chunk-ERLAIBOA.mjs} +2 -2
  167. package/dist/chunk-EURLTOTZ.mjs +4 -0
  168. package/dist/chunk-F4ZA6JRZ.mjs +3 -0
  169. package/dist/chunk-F6HVDZR4.mjs +2 -0
  170. package/dist/chunk-FDMAXMQA.mjs +2 -0
  171. package/dist/chunk-FETSREUN.mjs +5 -0
  172. package/dist/chunk-GHOYKMQ3.mjs +4 -0
  173. package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
  174. package/dist/chunk-HDWTZ763.mjs +12 -0
  175. package/dist/chunk-HPOI4ZX7.mjs +6 -0
  176. package/dist/{chunk-BGGDRNYQ.mjs → chunk-HXG7EOPJ.mjs} +1 -1
  177. package/dist/chunk-IA4PSIMD.mjs +2 -0
  178. package/dist/{chunk-E7LWZRXY.mjs → chunk-ITOH5EGO.mjs} +1 -1
  179. package/dist/chunk-IV64FFI4.mjs +2 -0
  180. package/dist/chunk-J43Z6LSS.mjs +2 -0
  181. package/dist/chunk-J5PUIV3Y.mjs +4 -0
  182. package/dist/chunk-JA7G53PC.mjs +2 -0
  183. package/dist/chunk-JEUK3ZO7.mjs +2 -0
  184. package/dist/chunk-JLTZF4LA.mjs +2 -0
  185. package/dist/chunk-JZT7I2OJ.mjs +2 -0
  186. package/dist/chunk-K5XATEOO.mjs +2 -0
  187. package/dist/chunk-L2SUIS5S.mjs +2 -0
  188. package/dist/chunk-L7UP52JO.mjs +2 -0
  189. package/dist/chunk-LM4XFQHZ.mjs +2 -0
  190. package/dist/chunk-MN7BZL4R.mjs +2 -0
  191. package/dist/chunk-MTYYHM2G.mjs +15 -0
  192. package/dist/chunk-MXUBKDRO.mjs +15 -0
  193. package/dist/chunk-NAMN3RAF.mjs +2 -0
  194. package/dist/{chunk-SYGN7GLU.mjs → chunk-OEXWRJME.mjs} +1 -1
  195. package/dist/chunk-OFHXGWOX.mjs +2 -0
  196. package/dist/chunk-ORID3AE7.mjs +166 -0
  197. package/dist/chunk-PAREWQGB.mjs +4 -0
  198. package/dist/chunk-PGDE24N5.mjs +2 -0
  199. package/dist/chunk-POTA2FV4.mjs +2 -0
  200. package/dist/chunk-PUOQ65NC.mjs +2 -0
  201. package/dist/chunk-Q4UEPUWF.mjs +2 -0
  202. package/dist/chunk-QE5RG76S.mjs +549 -0
  203. package/dist/chunk-R2ZDLJYT.mjs +10 -0
  204. package/dist/{chunk-7DTINW6U.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  205. package/dist/chunk-SWUTTZCN.mjs +2 -0
  206. package/dist/chunk-TANZRINB.mjs +2 -0
  207. package/dist/chunk-TR7TWGHB.mjs +2 -0
  208. package/dist/chunk-U5XL7D6A.mjs +3 -0
  209. package/dist/{chunk-XNROSH2T.mjs → chunk-U7NZI6N4.mjs} +2 -2
  210. package/dist/chunk-UGWMMEJ5.mjs +15 -0
  211. package/dist/chunk-UJQJKNGK.mjs +2 -0
  212. package/dist/chunk-UYVCQK3H.mjs +22 -0
  213. package/dist/chunk-VFX2KNHP.mjs +4 -0
  214. package/dist/chunk-VS7JIGJW.mjs +24 -0
  215. package/dist/chunk-W7665ZEC.mjs +6 -0
  216. package/dist/chunk-WQDQWCX5.mjs +2 -0
  217. package/dist/chunk-YI43RG4P.mjs +2 -0
  218. package/dist/chunk-YLPSMDIS.mjs +5 -0
  219. package/dist/chunk-YNAWBAYN.mjs +3 -0
  220. package/dist/chunk-YROX2O22.mjs +2 -0
  221. package/dist/chunk-ZDLPUOAG.mjs +6 -0
  222. package/dist/{chunk-IVDLMMBD.mjs → chunk-ZHEHPMBK.mjs} +1 -1
  223. package/dist/chunk-ZQS6H473.mjs +16 -0
  224. package/dist/chunk-ZTHICSSF.mjs +2 -0
  225. package/dist/chunk-ZWWC4KLF.mjs +20 -0
  226. package/dist/cli.mjs +1 -1
  227. package/dist/server.mjs +1 -1
  228. package/dist/{chunk-U6KNPJPR.mjs → update-fetch.mjs} +1 -1
  229. package/dist/worker.mjs +1 -1
  230. package/kit/board.css +95 -0
  231. package/kit/board.js +250 -0
  232. package/kit/charts.js +5 -71
  233. package/kit/code.js +17 -17
  234. package/kit/report.css +335 -18
  235. package/kit/runtime.js +1638 -125
  236. package/kit/state.js +10 -1
  237. package/kit/tables.js +130 -43
  238. package/kit/ui.js +79 -35
  239. package/package.json +2 -1
  240. package/packs/gallery/card/component.json +14 -0
  241. package/packs/gallery/card/example.html +10 -0
  242. package/packs/gallery/card/preview.svg +1 -0
  243. package/packs/gallery/card/style.css +6 -0
  244. package/packs/gallery/card/template.html +6 -0
  245. package/packs/gallery/card/writing.md +14 -0
  246. package/packs/gallery/chart-card/component.json +15 -0
  247. package/packs/gallery/chart-card/example.html +14 -0
  248. package/packs/gallery/chart-card/kit.js +130 -0
  249. package/packs/gallery/chart-card/preview.svg +1 -0
  250. package/packs/gallery/chart-card/style.css +42 -0
  251. package/packs/gallery/chart-card/template.html +13 -0
  252. package/packs/gallery/chart-card/writing.md +20 -0
  253. package/packs/gallery/chart-view/component.json +20 -0
  254. package/packs/gallery/chart-view/example.html +13 -0
  255. package/packs/gallery/chart-view/kit.js +355 -0
  256. package/packs/gallery/chart-view/preview.svg +1 -0
  257. package/packs/gallery/chart-view/style.css +94 -0
  258. package/packs/gallery/chart-view/template.html +3 -0
  259. package/packs/gallery/chart-view/writing.md +22 -0
  260. package/packs/gallery/countdown/component.json +18 -0
  261. package/packs/gallery/countdown/example.html +3 -0
  262. package/packs/gallery/countdown/kit.js +216 -0
  263. package/packs/gallery/countdown/preview.svg +1 -0
  264. package/packs/gallery/countdown/style.css +118 -0
  265. package/packs/gallery/countdown/template.html +3 -0
  266. package/packs/gallery/countdown/writing.md +22 -0
  267. package/packs/gallery/habit/component.json +14 -0
  268. package/packs/gallery/habit/example.html +3 -0
  269. package/packs/gallery/habit/kit.js +334 -0
  270. package/packs/gallery/habit/preview.svg +1 -0
  271. package/packs/gallery/habit/style.css +174 -0
  272. package/packs/gallery/habit/template.html +3 -0
  273. package/packs/gallery/habit/writing.md +21 -0
  274. package/packs/gallery/heatmap/component.json +18 -0
  275. package/packs/gallery/heatmap/example.html +3 -0
  276. package/packs/gallery/heatmap/kit.js +513 -0
  277. package/packs/gallery/heatmap/preview.svg +1 -0
  278. package/packs/gallery/heatmap/style.css +189 -0
  279. package/packs/gallery/heatmap/template.html +3 -0
  280. package/packs/gallery/heatmap/writing.md +21 -0
  281. package/packs/gallery/kanban/component.json +18 -0
  282. package/packs/gallery/kanban/example.html +12 -0
  283. package/packs/gallery/kanban/kit.js +540 -0
  284. package/packs/gallery/kanban/preview.svg +1 -0
  285. package/packs/gallery/kanban/style.css +212 -0
  286. package/packs/gallery/kanban/template.html +3 -0
  287. package/packs/gallery/kanban/writing.md +20 -0
  288. package/packs/gallery/metric/component.json +22 -0
  289. package/packs/gallery/metric/example.html +15 -0
  290. package/packs/gallery/metric/kit.js +248 -0
  291. package/packs/gallery/metric/preview.svg +1 -0
  292. package/packs/gallery/metric/style.css +92 -0
  293. package/packs/gallery/metric/template.html +3 -0
  294. package/packs/gallery/metric/writing.md +23 -0
  295. package/packs/gallery/note/component.json +14 -0
  296. package/packs/gallery/note/example.html +3 -0
  297. package/packs/gallery/note/kit.js +129 -0
  298. package/packs/gallery/note/preview.svg +1 -0
  299. package/packs/gallery/note/style.css +97 -0
  300. package/packs/gallery/note/template.html +3 -0
  301. package/packs/gallery/note/writing.md +18 -0
  302. package/packs/gallery/pack.json +8 -0
  303. package/packs/gallery/recent/component.json +13 -0
  304. package/packs/gallery/recent/example.html +1 -0
  305. package/packs/gallery/recent/kit.js +293 -0
  306. package/packs/gallery/recent/preview.svg +1 -0
  307. package/packs/gallery/recent/style.css +85 -0
  308. package/packs/gallery/recent/template.html +1 -0
  309. package/packs/gallery/recent/writing.md +15 -0
  310. package/packs/gallery/static/component.json +13 -0
  311. package/packs/gallery/static/example.html +11 -0
  312. package/packs/gallery/static/preview.svg +1 -0
  313. package/packs/gallery/static/style.css +171 -0
  314. package/packs/gallery/static/template.html +1 -0
  315. package/packs/gallery/static/writing.md +18 -0
  316. package/packs/gallery/stats/component.json +13 -0
  317. package/packs/gallery/stats/example.html +1 -0
  318. package/packs/gallery/stats/kit.js +347 -0
  319. package/packs/gallery/stats/preview.svg +1 -0
  320. package/packs/gallery/stats/style.css +73 -0
  321. package/packs/gallery/stats/template.html +1 -0
  322. package/packs/gallery/stats/writing.md +11 -0
  323. package/packs/gallery/today/component.json +12 -0
  324. package/packs/gallery/today/example.html +1 -0
  325. package/packs/gallery/today/kit.js +220 -0
  326. package/packs/gallery/today/preview.svg +1 -0
  327. package/packs/gallery/today/style.css +149 -0
  328. package/packs/gallery/today/template.html +1 -0
  329. package/packs/gallery/today/writing.md +14 -0
  330. package/packs/gallery/todos/component.json +19 -0
  331. package/packs/gallery/todos/example.html +3 -0
  332. package/packs/gallery/todos/kit.js +489 -0
  333. package/packs/gallery/todos/preview.svg +1 -0
  334. package/packs/gallery/todos/style.css +214 -0
  335. package/packs/gallery/todos/template.html +3 -0
  336. package/packs/gallery/todos/writing.md +30 -0
  337. package/packs/gallery/weather/component.json +19 -0
  338. package/packs/gallery/weather/example.html +3 -0
  339. package/packs/gallery/weather/kit.js +387 -0
  340. package/packs/gallery/weather/preview.svg +1 -0
  341. package/packs/gallery/weather/style.css +140 -0
  342. package/packs/gallery/weather/template.html +3 -0
  343. package/packs/gallery/weather/writing.md +26 -0
  344. package/packs/gallery-soft/countdown/component.json +18 -0
  345. package/packs/gallery-soft/countdown/example.html +3 -0
  346. package/packs/gallery-soft/countdown/kit.js +206 -0
  347. package/packs/gallery-soft/countdown/preview.svg +1 -0
  348. package/packs/gallery-soft/countdown/style.css +211 -0
  349. package/packs/gallery-soft/countdown/template.html +3 -0
  350. package/packs/gallery-soft/countdown/writing.md +24 -0
  351. package/packs/gallery-soft/habit/component.json +14 -0
  352. package/packs/gallery-soft/habit/example.html +3 -0
  353. package/packs/gallery-soft/habit/kit.js +366 -0
  354. package/packs/gallery-soft/habit/preview.svg +1 -0
  355. package/packs/gallery-soft/habit/style.css +251 -0
  356. package/packs/gallery-soft/habit/template.html +3 -0
  357. package/packs/gallery-soft/habit/writing.md +23 -0
  358. package/packs/gallery-soft/heatmap/component.json +18 -0
  359. package/packs/gallery-soft/heatmap/example.html +3 -0
  360. package/packs/gallery-soft/heatmap/kit.js +498 -0
  361. package/packs/gallery-soft/heatmap/preview.svg +1 -0
  362. package/packs/gallery-soft/heatmap/style.css +181 -0
  363. package/packs/gallery-soft/heatmap/template.html +3 -0
  364. package/packs/gallery-soft/heatmap/writing.md +23 -0
  365. package/packs/gallery-soft/note/component.json +14 -0
  366. package/packs/gallery-soft/note/example.html +3 -0
  367. package/packs/gallery-soft/note/kit.js +162 -0
  368. package/packs/gallery-soft/note/preview.svg +1 -0
  369. package/packs/gallery-soft/note/style.css +148 -0
  370. package/packs/gallery-soft/note/template.html +3 -0
  371. package/packs/gallery-soft/note/writing.md +20 -0
  372. package/packs/gallery-soft/pack.json +8 -0
  373. package/packs/gallery-soft/recent/component.json +13 -0
  374. package/packs/gallery-soft/recent/example.html +1 -0
  375. package/packs/gallery-soft/recent/kit.js +335 -0
  376. package/packs/gallery-soft/recent/preview.svg +1 -0
  377. package/packs/gallery-soft/recent/style.css +160 -0
  378. package/packs/gallery-soft/recent/template.html +1 -0
  379. package/packs/gallery-soft/recent/writing.md +17 -0
  380. package/packs/gallery-soft/static/component.json +13 -0
  381. package/packs/gallery-soft/static/example.html +12 -0
  382. package/packs/gallery-soft/static/preview.svg +1 -0
  383. package/packs/gallery-soft/static/style.css +186 -0
  384. package/packs/gallery-soft/static/template.html +1 -0
  385. package/packs/gallery-soft/static/writing.md +20 -0
  386. package/packs/gallery-soft/stats/component.json +13 -0
  387. package/packs/gallery-soft/stats/example.html +1 -0
  388. package/packs/gallery-soft/stats/kit.js +341 -0
  389. package/packs/gallery-soft/stats/preview.svg +1 -0
  390. package/packs/gallery-soft/stats/style.css +119 -0
  391. package/packs/gallery-soft/stats/template.html +1 -0
  392. package/packs/gallery-soft/stats/writing.md +13 -0
  393. package/packs/gallery-soft/today/component.json +12 -0
  394. package/packs/gallery-soft/today/example.html +1 -0
  395. package/packs/gallery-soft/today/kit.js +222 -0
  396. package/packs/gallery-soft/today/preview.svg +1 -0
  397. package/packs/gallery-soft/today/style.css +178 -0
  398. package/packs/gallery-soft/today/template.html +1 -0
  399. package/packs/gallery-soft/today/writing.md +16 -0
  400. package/packs/gallery-soft/todos/component.json +19 -0
  401. package/packs/gallery-soft/todos/example.html +3 -0
  402. package/packs/gallery-soft/todos/kit.js +527 -0
  403. package/packs/gallery-soft/todos/preview.svg +1 -0
  404. package/packs/gallery-soft/todos/style.css +212 -0
  405. package/packs/gallery-soft/todos/template.html +3 -0
  406. package/packs/gallery-soft/todos/writing.md +32 -0
  407. package/packs/gallery-soft/weather/component.json +19 -0
  408. package/packs/gallery-soft/weather/example.html +3 -0
  409. package/packs/gallery-soft/weather/kit.js +411 -0
  410. package/packs/gallery-soft/weather/preview.svg +1 -0
  411. package/packs/gallery-soft/weather/style.css +185 -0
  412. package/packs/gallery-soft/weather/template.html +3 -0
  413. package/packs/gallery-soft/weather/writing.md +28 -0
  414. package/release.json +12 -10
  415. package/sdk/doc-kit.d.ts +396 -5
  416. package/sdk/doc-state.d.ts +2 -0
  417. package/skill/SKILL.md +56 -23
  418. package/skill/references/block-script.md +140 -0
  419. package/skill/references/building-blocks.md +257 -0
  420. package/skill/references/extensions.md +59 -0
  421. package/skill/references/pages-and-data.md +225 -0
  422. package/skill/references/writing-html.md +8 -4
  423. package/skill/sdk/doc-kit.d.ts +396 -5
  424. package/skill/sdk/doc-state.d.ts +2 -0
  425. package/web/assets/index-BM_K-Auu.css +1 -0
  426. package/web/assets/index-DRslOBiv.js +15 -0
  427. package/web/index.html +2 -2
  428. package/dist/chunk-3HIRPVLU.mjs +0 -2
  429. package/dist/chunk-5MHMDLZD.mjs +0 -4
  430. package/dist/chunk-64K7IPLO.mjs +0 -255
  431. package/dist/chunk-6QXGZM36.mjs +0 -8
  432. package/dist/chunk-6RGJOMJP.mjs +0 -16
  433. package/dist/chunk-AJ73XJF3.mjs +0 -2
  434. package/dist/chunk-AUZGSZJH.mjs +0 -13
  435. package/dist/chunk-BFE45AKL.mjs +0 -2
  436. package/dist/chunk-BXO2ZY5P.mjs +0 -2
  437. package/dist/chunk-CEH4MRCC.mjs +0 -2
  438. package/dist/chunk-CY2FNNAB.mjs +0 -16
  439. package/dist/chunk-DFUDV4LX.mjs +0 -2
  440. package/dist/chunk-DKXG4XDG.mjs +0 -2
  441. package/dist/chunk-EZQ34M3F.mjs +0 -124
  442. package/dist/chunk-EZY3WC6Z.mjs +0 -15
  443. package/dist/chunk-FUKQNOQS.mjs +0 -9
  444. package/dist/chunk-JPOSLGOC.mjs +0 -6
  445. package/dist/chunk-JVHHHGEA.mjs +0 -3
  446. package/dist/chunk-L3QKH4OK.mjs +0 -26
  447. package/dist/chunk-LAE5NQ4B.mjs +0 -2
  448. package/dist/chunk-LEF6DRCK.mjs +0 -59
  449. package/dist/chunk-NO5NJCHO.mjs +0 -2
  450. package/dist/chunk-NQPVAU63.mjs +0 -2
  451. package/dist/chunk-NSKUTQ5J.mjs +0 -5
  452. package/dist/chunk-O35FIXRB.mjs +0 -2
  453. package/dist/chunk-P2CAZPDP.mjs +0 -3
  454. package/dist/chunk-PL6GHLGD.mjs +0 -15
  455. package/dist/chunk-QJIR2BLP.mjs +0 -6
  456. package/dist/chunk-QUPLVPB2.mjs +0 -7
  457. package/dist/chunk-R7BNENLY.mjs +0 -4
  458. package/dist/chunk-S6O4UHLC.mjs +0 -2
  459. package/dist/chunk-SGJWQKEI.mjs +0 -2
  460. package/dist/chunk-TX6JH7TR.mjs +0 -2
  461. package/dist/chunk-TYK6VNAB.mjs +0 -10
  462. package/dist/chunk-UALRNVSE.mjs +0 -4
  463. package/dist/chunk-V3HXVQEM.mjs +0 -2
  464. package/dist/chunk-V5VXUJKG.mjs +0 -2
  465. package/dist/chunk-VBXMADMP.mjs +0 -2
  466. package/dist/chunk-VNV55RUA.mjs +0 -2
  467. package/dist/chunk-VPD2PS35.mjs +0 -2
  468. package/dist/chunk-W4VKN3GF.mjs +0 -7
  469. package/dist/chunk-W5BXXPDJ.mjs +0 -3
  470. package/dist/chunk-XUNHRCOG.mjs +0 -6
  471. package/skill/references/building-components.md +0 -367
  472. package/web/assets/index-Bh74DfsV.css +0 -1
  473. package/web/assets/index-UW0RyFFt.js +0 -13
@@ -0,0 +1,347 @@
1
+ // gallery/stats (工作区统计): four numbers of the workspace, each over a small picture of itself, read
2
+ // through context.workspace.query("stats") and query("activity") (its manifest's needs hold "workspace"):
3
+ // its documents (a square a document, those edited this week, since Monday 0:00, in the accent), the
4
+ // words of all its documents (and, from the record of edits, how they grew over the last 30 days: a line
5
+ // of the total at the end of each day, and the words added in all), its to-dos done of all (a bar), and
6
+ // the edits made this week (the record's, the reader's and the Agent's: a bar a day, Monday to Sunday,
7
+ // today's in the accent, the days to come a stub; and against the same days of the week before, 比上周同期
8
+ // +14%). A workspace with none of them shows each 0 and says what each waits for. It reads again whenever
9
+ // the workspace says they changed (the `data` signal, "stats" or "activity": a document written, a to-do
10
+ // checked, a document made or gone) and as a day begins (the kit's clock: a new week starts on a Monday).
11
+ // It holds no part and writes nothing: all it shows is drawn (the manifest's `runtime`). Where the
12
+ // workspace cannot be read (an exported file, where it has no server; a server that does not answer) each
13
+ // number is a dash and a line says why. The words are the page's language (the UI's where Gallery says
14
+ // it, else the page's lang); a big number of words is said short (12.4万, 124K).
15
+ //
16
+ // Its face (the pack's design B, in the kit's card tokens) has no head: the four labels, each after a
17
+ // small picture of what it counts, are its titles; four cells in a row a hairline apart (an 8 × 2 card,
18
+ // the default, and a 12 × 2 one, `data-layout` "row" and "wide", by context.size), or two by two (a 4 × 4
19
+ // card, "square"), each its label, its number (28px, 32px on a wide card), its picture and a faint line
20
+ // under it.
21
+
22
+ const WORDS = {
23
+ zh: {
24
+ documents: "文档",
25
+ words: "总字数",
26
+ todos: "待办完成",
27
+ week: "本周编辑",
28
+ pieces: "篇",
29
+ times: "次",
30
+ wordUnit: "字",
31
+ tenThousand: "万字",
32
+ editedWeek: (/** @type {number} */ count) => ["", String(count), " 篇本周改过"],
33
+ month: (/** @type {string} */ added) => ["近 30 天 ", added, ""],
34
+ left: (/** @type {number} */ percent, /** @type {number} */ open) => [`${percent}%`, ` · 还剩 ${open} 项`],
35
+ allDone: "全部完成",
36
+ against: (/** @type {string} */ delta) => ["比上周同期 ", delta, ""],
37
+ lastNone: "上周同期没有编辑",
38
+ zero: { documents: "新建一篇就从这里开始", todos: "还没有待办", week: "这周还没动过" },
39
+ offline: "在 Gallery 里打开时显示",
40
+ failed: "读不到工作区的统计",
41
+ locale: "zh-CN",
42
+ },
43
+ en: {
44
+ documents: "Documents",
45
+ words: "Words",
46
+ todos: "To-dos done",
47
+ week: "Edits this week",
48
+ pieces: "",
49
+ times: "",
50
+ wordUnit: "",
51
+ tenThousand: "",
52
+ editedWeek: (/** @type {number} */ count) => ["", String(count), " edited this week"],
53
+ month: (/** @type {string} */ added) => ["", added, " in 30 days"],
54
+ left: (/** @type {number} */ percent, /** @type {number} */ open) => [`${percent}%`, ` · ${open} left`],
55
+ allDone: "All done",
56
+ against: (/** @type {string} */ delta) => ["", delta, " on last week"],
57
+ lastNone: "None this time last week",
58
+ zero: { documents: "Make one to start", todos: "No to-dos yet", week: "Nothing yet this week" },
59
+ offline: "Shown when opened in Gallery",
60
+ failed: "The workspace's numbers could not be read",
61
+ locale: "en",
62
+ },
63
+ };
64
+
65
+ /** The days of the record it reads: 30 for the words, and this week and the one before for the edits. */
66
+ const DAYS = 37;
67
+
68
+ /** The language the page speaks: the UI's where Gallery says it (data-ge-language), else its lang's. */
69
+ function languageOf(/** @type {HTMLElement} */ root) {
70
+ const ui = root.getAttribute("data-ge-language");
71
+ return (ui !== null ? ui === "en" : /^en(?:-|$)/i.test(root.lang)) ? "en" : "zh";
72
+ }
73
+
74
+ /**
75
+ * A count as the card writes it, in `language`: whole and grouped up to 99,999 (12,345), shorter past
76
+ * it (12.3万, 123.5K), as the language writes a big number.
77
+ * @param {number} value
78
+ * @param {"zh" | "en"} language
79
+ */
80
+ function countOf(value, language) {
81
+ const big = Math.abs(value) >= 100_000;
82
+ return new Intl.NumberFormat(WORDS[language].locale, big ? { notation: "compact", maximumFractionDigits: 1 } : { maximumFractionDigits: 0 }).format(value);
83
+ }
84
+
85
+ /**
86
+ * The words of the workspace as the card's number says them: { value, unit }: in Chinese 万字 from
87
+ * 10,000 (12.4 万字), else 字; in English 12.4K from 10,000.
88
+ * @param {number} words
89
+ * @param {"zh" | "en"} language
90
+ */
91
+ function wordsOf(words, language) {
92
+ const said = WORDS[language];
93
+ if (Math.abs(words) < 10_000) return { value: countOf(words, language), unit: said.wordUnit };
94
+ if (language === "zh") return { value: (words / 10_000).toFixed(1), unit: said.tenThousand };
95
+ return { value: `${(words / 1000).toFixed(1)}K`, unit: "" };
96
+ }
97
+
98
+ /** A change of words, signed and short (+6万, +5,432, −120). @param {number} value @param {"zh" | "en"} language */
99
+ function addedOf(value, language) {
100
+ const sign = value > 0 ? "+" : value < 0 ? "−" : "+";
101
+ const size = Math.abs(value);
102
+ if (size < 10_000) return `${sign}${countOf(size, language)}`;
103
+ const short = (Math.round(size / 1000) / 10).toFixed(1).replace(/\.0$/, "");
104
+ return `${sign}${language === "zh" ? `${short}万` : `${(Math.round(size / 100) / 10).toFixed(1).replace(/\.0$/, "")}K`}`;
105
+ }
106
+
107
+ const two = (/** @type {number} */ value) => String(value).padStart(2, "0");
108
+ /** A local day as the record writes it, YYYY-MM-DD. @param {Date} date */
109
+ const dayOf = (date) => `${date.getFullYear()}-${two(date.getMonth() + 1)}-${two(date.getDate())}`;
110
+ /** The day `count` days after `date` (before, negative), at noon. @param {Date} date @param {number} count */
111
+ const after = (date, count) => new Date(date.getFullYear(), date.getMonth(), date.getDate() + count, 12);
112
+
113
+ /**
114
+ * What the record of edits says for the card (`days`: query("activity")'s data, [{ date, edits, words }];
115
+ * `total`: the words of the workspace now; `today`: a Date): `curve`, the words in all at the end of each
116
+ * of the last 30 days, oldest first (a day before the record started taken as no change), none below 0;
117
+ * `added`, the words those days added, never more than the total (the record counts each edit's change,
118
+ * and a document deleted takes its words out of the total and none out of the record, so that the days
119
+ * before it would read as fewer words than none); `week`, the edits of each day Monday to Sunday (null for a day to come); `edits`,
120
+ * this week's; `last`, those of the week before up to the same weekday; `delta`, their change in percent
121
+ * (null where the week before had none).
122
+ * @param {Array<{ date: string, edits: number, words: number }>} days
123
+ * @param {number} total
124
+ * @param {Date} today
125
+ */
126
+ function trendOf(days, total, today) {
127
+ const by = new Map(days.map((day) => [day.date, day]));
128
+ const curve = [];
129
+ let words = total;
130
+ for (let back = 0; back < 30; back++) {
131
+ curve.unshift(Math.max(0, words));
132
+ words -= by.get(dayOf(after(today, -back)))?.words ?? 0;
133
+ }
134
+ const added = total - Math.max(0, words);
135
+ const weekday = (today.getDay() + 6) % 7;
136
+ /** @type {Array<number | null>} */
137
+ const week = Array.from({ length: 7 }, (_, index) => (index > weekday ? null : by.get(dayOf(after(today, index - weekday)))?.edits ?? 0));
138
+ let edits = 0;
139
+ for (const value of week) edits += value ?? 0;
140
+ let last = 0;
141
+ for (let index = 0; index <= weekday; index++) last += by.get(dayOf(after(today, index - weekday - 7)))?.edits ?? 0;
142
+ return { curve, added, week, edits, last, delta: last > 0 ? Math.round((edits / last - 1) * 100) : null };
143
+ }
144
+
145
+ /**
146
+ * The four cells the card shows of `stats` (workspace.query("stats")'s data), or of none (null: a dash
147
+ * each), and of the record's `trend` (trendOf's, or null), in `language`: [{ key, label, value, unit, of,
148
+ * caption: [before, bold, after] }].
149
+ * @param {{ documents: number, todos: { done: number, total: number }, words: number, editedThisWeek: number } | null} stats
150
+ * @param {ReturnType<typeof trendOf> | null} trend
151
+ * @param {"zh" | "en"} language
152
+ */
153
+ function cellsOf(stats, trend, language) {
154
+ const said = WORDS[language];
155
+ const dash = "—";
156
+ if (!stats) return ["documents", "words", "todos", "week"].map((key) => ({ key, label: said[/** @type {"documents"} */ (key)], value: dash, unit: "", of: "", caption: ["", "", ""] }));
157
+ const open = stats.todos.total - stats.todos.done;
158
+ const percent = stats.todos.total > 0 ? Math.round((100 * stats.todos.done) / stats.todos.total) : 0;
159
+ const words = wordsOf(stats.words, language);
160
+ const edits = trend?.edits ?? 0;
161
+ const delta = trend?.delta;
162
+ return [
163
+ { key: "documents", label: said.documents, value: countOf(stats.documents, language), unit: said.pieces, of: "", caption: stats.documents === 0 ? ["", "", said.zero.documents] : said.editedWeek(stats.editedThisWeek) },
164
+ { key: "words", label: said.words, value: words.value, unit: words.unit, of: "", caption: said.month(addedOf(trend?.added ?? 0, language)) },
165
+ { key: "todos", label: said.todos, value: countOf(stats.todos.done, language), unit: "", of: `/ ${countOf(stats.todos.total, language)}`, caption: stats.todos.total === 0 ? ["", "", said.zero.todos] : open === 0 ? ["", "100%", ` · ${said.allDone}`] : ["", ...said.left(percent, open)] },
166
+ { key: "week", label: said.week, value: countOf(edits, language), unit: said.times, of: "", caption: edits === 0 ? ["", "", said.zero.week] : delta === null || delta === undefined ? ["", "", said.lastNone] : said.against(`${delta > 0 ? "+" : delta < 0 ? "−" : ""}${Math.abs(delta)}%`) },
167
+ ];
168
+ }
169
+
170
+ // The cells' small pictures, of lines, 24 x 24.
171
+ const ICONS = {
172
+ documents: '<path d="M7 3.5h6.5L18 8v11a1.5 1.5 0 0 1-1.5 1.5h-9.5A1.5 1.5 0 0 1 5.5 19V5A1.5 1.5 0 0 1 7 3.5z"/><path d="M13.5 3.5V8H18"/>',
173
+ words: '<path d="M5 6.5h14M5 12h14M5 17.5h9"/>',
174
+ todos: '<rect x="3.5" y="4" width="6.5" height="6.5" rx="1.8"/><path d="M5.2 7.3l1.3 1.3 2-2.1"/><rect x="3.5" y="13.5" width="6.5" height="6.5" rx="1.8"/><path d="M13.5 7.2h7M13.5 16.8h7"/>',
175
+ week: '<path d="M5 19.5v-6M10 19.5v-13M15 19.5v-9M20 19.5v-4"/>',
176
+ };
177
+
178
+ /** The pictures' sizes by the card's layout: the line's and the bars' width and height, and the squares' columns, side and gap. */
179
+ const SIZES = {
180
+ row: { width: 112, height: 24, columns: 11, side: 6, gap: 2 },
181
+ wide: { width: 190, height: 24, columns: 16, side: 8, gap: 3 },
182
+ square: { width: 104, height: 40, columns: 8, side: 8, gap: 3 },
183
+ };
184
+
185
+ let made_ = 0; // the gradients' ids, one each
186
+
187
+ /**
188
+ * The documents as squares, `lit` of them (those edited this week) in the accent: at most three rows of
189
+ * `columns`, a square standing for more than one document past that; the rows as even as they can be
190
+ * (12 in two rows of 6, 23 in 8, 8 and 7), so that no square is left alone on a row of its own.
191
+ * @param {number} count @param {number} lit @param {{ columns: number, side: number, gap: number }} size
192
+ */
193
+ function squares(count, lit, { columns, side, gap }) {
194
+ const most = columns * 3;
195
+ const shown = Math.min(count, most);
196
+ const on = count > most ? Math.round((lit / count) * shown) : Math.min(lit, shown);
197
+ const rows = Math.max(1, Math.ceil(shown / columns));
198
+ const across = Math.max(1, Math.ceil(shown / rows));
199
+ let drawn = "";
200
+ for (let index = 0; index < shown; index++) {
201
+ drawn += `<rect x="${(index % across) * (side + gap)}" y="${Math.floor(index / across) * (side + gap)}" width="${side}" height="${side}" rx="${side > 6 ? 2 : 1.6}" class="gallery-stats-${index < on ? "on" : "off"}"/>`;
202
+ }
203
+ if (shown === 0) drawn = `<rect width="${columns * (side + gap) - gap}" height="6" rx="3" class="gallery-stats-empty"/>`;
204
+ const height = shown === 0 ? 6 : rows * (side + gap) - gap;
205
+ return `<svg width="${columns * (side + gap) - gap}" height="${height}" aria-hidden="true">${drawn}</svg>`;
206
+ }
207
+
208
+ /** The words over 30 days as a line, its area fading under it and a dot at its end. @param {number[]} values @param {{ width: number, height: number }} size */
209
+ function curveOf(values, { width, height }) {
210
+ const low = Math.min(...values);
211
+ const high = Math.max(...values);
212
+ if (high === low) return `<svg width="${width}" height="${height}" aria-hidden="true"><line x1="0" x2="${width}" y1="${height - 2}" y2="${height - 2}" class="gallery-stats-flat" stroke-width="1.8" stroke-linecap="round"/></svg>`;
213
+ const step = width / (values.length - 1);
214
+ const y = (/** @type {number} */ value) => height - 3 - ((value - low) / (high - low)) * (height - 7);
215
+ const points = values.map((value, index) => [index * step, y(value)]);
216
+ const line = points.map(([x, at], index) => `${index ? "L" : "M"}${x.toFixed(1)} ${at.toFixed(1)}`).join("");
217
+ const [endX, endY] = points[points.length - 1];
218
+ const id = `gallery-stats-fade-${++made_}`;
219
+ return `<svg width="${width}" height="${height}" aria-hidden="true"><defs><linearGradient id="${id}" x1="0" x2="0" y1="0" y2="1"><stop offset="0" class="gallery-stats-stop" stop-opacity=".22"/><stop offset="1" class="gallery-stats-stop" stop-opacity="0"/></linearGradient></defs><path d="${line}L${width} ${height}L0 ${height}Z" fill="url(#${id})"/><path d="${line}" fill="none" class="gallery-stats-line" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/><circle cx="${endX}" cy="${endY}" r="3.2" class="gallery-stats-end" stroke-width="2"/></svg>`;
220
+ }
221
+
222
+ /** This week's edits, a bar a day, today's in the accent, a day to come a stub. @param {Array<number | null>} values @param {number} today @param {{ width: number, height: number }} size */
223
+ function barsOf(values, today, { width, height }) {
224
+ const most = Math.max(1, ...values.filter((value) => value !== null));
225
+ const bar = Math.min(12, (width - 30) / 7);
226
+ const gap = (width - 7 * bar) / 6;
227
+ const none = values.every((value) => !value);
228
+ let drawn = "";
229
+ values.forEach((value, index) => {
230
+ const x = index * (bar + gap);
231
+ if (value === null || none) return void (drawn += `<rect x="${x}" y="${height - 2}" width="${bar}" height="2" rx="1" class="gallery-stats-stub"/>`);
232
+ const tall = Math.max(3, (value / most) * height);
233
+ drawn += `<path d="M${x} ${height}V${height - tall + 3}a3 3 0 0 1 3-3h${bar - 6}a3 3 0 0 1 3 3V${height}Z" class="gallery-stats-${index === today ? "today" : "day"}"/>`;
234
+ });
235
+ return `<svg width="${width}" height="${height}" aria-hidden="true">${drawn}</svg>`;
236
+ }
237
+
238
+ /**
239
+ * An element of the face, of `kind` (its class).
240
+ * @template {keyof HTMLElementTagNameMap} K
241
+ * @param {K} tag
242
+ * @param {string} kind
243
+ * @param {string} [text]
244
+ */
245
+ function made(tag, kind, text) {
246
+ const node = document.createElement(tag);
247
+ node.className = `gallery-stats-${kind}`;
248
+ if (text !== undefined) node.textContent = text;
249
+ return node;
250
+ }
251
+
252
+ DocKit.component({
253
+ id: "gallery/stats",
254
+ on: ["data", "clock", "layout"],
255
+ mount(host, context) {
256
+ const language = languageOf(document.documentElement);
257
+ const words = WORDS[language];
258
+ const face = made("div", "face");
259
+ const grid = made("dl", "grid");
260
+ const line = made("p", "line");
261
+ line.hidden = true;
262
+ face.append(grid, line);
263
+ host.append(face);
264
+ const workspace = context.workspace;
265
+ if (!workspace) return void context.fail(new Error("its manifest's needs hold \"workspace\": context.workspace is not there"));
266
+ /** @type {Parameters<typeof cellsOf>[0]} */
267
+ let stats = null;
268
+ /** @type {Array<{ date: string, edits: number, words: number }>} */
269
+ let days = [];
270
+ let drawnKey = "";
271
+ // The cells, each its label over its number, its picture and its line, drawn again only when what they say is another.
272
+ const draw = () => {
273
+ const size = context.size;
274
+ const layout = !size ? "row" : size.w >= 12 ? "wide" : size.w <= 4 ? "square" : "row";
275
+ face.dataset.layout = layout;
276
+ face.toggleAttribute("data-unread", !stats);
277
+ const now = new Date();
278
+ const trend = stats ? trendOf(days, stats.words, now) : null;
279
+ const cells = cellsOf(stats, trend, language);
280
+ const key = JSON.stringify([layout, cells, trend, dayOf(now)]);
281
+ if (key === drawnKey) return;
282
+ drawnKey = key;
283
+ const sizes = SIZES[/** @type {keyof typeof SIZES} */ (layout)];
284
+ grid.replaceChildren(...cells.map(({ key: kind, label, value, unit, of, caption }) => {
285
+ const cell = made("div", "cell");
286
+ cell.dataset.stat = kind;
287
+ const name = made("dt", "label");
288
+ name.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ICONS[/** @type {keyof typeof ICONS} */ (kind)]}</svg>`;
289
+ name.append(made("span", "label-words", label));
290
+ const number = made("dd", "value");
291
+ number.append(made("span", "number", value));
292
+ if (unit) number.append(made("span", "unit", unit));
293
+ if (of) number.append(made("span", "of", of));
294
+ const picture = made("dd", "picture");
295
+ if (stats && trend) {
296
+ if (kind === "documents") picture.innerHTML = squares(stats.documents, stats.editedThisWeek, sizes);
297
+ if (kind === "words") picture.innerHTML = curveOf(trend.curve, sizes);
298
+ if (kind === "todos") {
299
+ const bar = made("span", "bar");
300
+ const fill = made("span", "fill");
301
+ fill.style.width = `${stats.todos.total > 0 ? (100 * stats.todos.done) / stats.todos.total : 0}%`;
302
+ bar.append(fill);
303
+ picture.append(bar);
304
+ }
305
+ if (kind === "week") picture.innerHTML = barsOf(trend.week, (now.getDay() + 6) % 7, sizes);
306
+ }
307
+ const foot = made("dd", "caption");
308
+ if (kind === "documents" && stats && stats.documents > 0) foot.append(made("i", "mark"));
309
+ const [before, bold, after_] = caption;
310
+ if (before) foot.append(before);
311
+ if (bold) foot.append(made("b", "strong", bold));
312
+ if (after_) foot.append(after_);
313
+ if (!stats) foot.textContent = " ";
314
+ cell.append(name, number, picture, foot);
315
+ return cell;
316
+ }));
317
+ };
318
+ let asking = 0; // the last read asked: an older answer that comes after it is dropped
319
+ const read = () => {
320
+ const ticket = ++asking;
321
+ const record = workspace.query("activity", { days: DAYS }).then(({ data }) => data, () => []);
322
+ workspace.query("stats").then(async ({ data }) => {
323
+ const kept = await record;
324
+ if (ticket !== asking || context.signal.aborted) return;
325
+ line.hidden = true;
326
+ stats = data;
327
+ days = Array.isArray(kept) ? kept : [];
328
+ draw();
329
+ }, (/** @type {any} */ error) => {
330
+ if (ticket !== asking || context.signal.aborted) return;
331
+ stats = null;
332
+ days = [];
333
+ draw();
334
+ line.hidden = false;
335
+ line.textContent = error?.code === "offline" ? words.offline : words.failed;
336
+ });
337
+ };
338
+ draw();
339
+ read();
340
+ return {
341
+ update(reason, detail) {
342
+ if ((reason === "data" && (detail === "stats" || detail === "activity")) || (reason === "clock" && detail === "day")) read();
343
+ else if (reason === "layout") draw();
344
+ },
345
+ };
346
+ },
347
+ });
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 120"><rect width="240" height="120" rx="8" fill="#f3f3f1"/><rect x="10.5" y="30.5" width="219" height="59" rx="8" fill="#ffffff" stroke="#e6e6e3"/><rect x="18" y="38" width="22" height="4" rx="2" fill="#a6a5a1"/><rect x="18" y="46" width="18" height="11" rx="3" fill="#1d1d1b"/><line x1="68" x2="68" y1="38" y2="82" stroke="#efefed"/><rect x="72" y="38" width="22" height="4" rx="2" fill="#a6a5a1"/><rect x="72" y="46" width="18" height="11" rx="3" fill="#1d1d1b"/><line x1="122" x2="122" y1="38" y2="82" stroke="#efefed"/><rect x="126" y="38" width="22" height="4" rx="2" fill="#a6a5a1"/><rect x="126" y="46" width="18" height="11" rx="3" fill="#1d1d1b"/><line x1="176" x2="176" y1="38" y2="82" stroke="#efefed"/><rect x="180" y="38" width="22" height="4" rx="2" fill="#a6a5a1"/><rect x="180" y="46" width="18" height="11" rx="3" fill="#1d1d1b"/><rect x="18" y="66" width="4" height="4" rx="1" fill="#4084cf"/><rect x="24" y="66" width="4" height="4" rx="1" fill="#4084cf"/><rect x="30" y="66" width="4" height="4" rx="1" fill="#4084cf"/><rect x="36" y="66" width="4" height="4" rx="1" fill="#4084cf"/><rect x="42" y="66" width="4" height="4" rx="1" fill="#e7e7e5"/><rect x="48" y="66" width="4" height="4" rx="1" fill="#e7e7e5"/><rect x="18" y="72" width="4" height="4" rx="1" fill="#e7e7e5"/><rect x="24" y="72" width="4" height="4" rx="1" fill="#e7e7e5"/><rect x="30" y="72" width="4" height="4" rx="1" fill="#e7e7e5"/><rect x="36" y="72" width="4" height="4" rx="1" fill="#e7e7e5"/><rect x="42" y="72" width="4" height="4" rx="1" fill="#e7e7e5"/><rect x="48" y="72" width="4" height="4" rx="1" fill="#e7e7e5"/><path d="M72 80l8-3 8 1 8-4 8-1 8-5" fill="none" stroke="#4084cf" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><rect x="126" y="74" width="40" height="4" rx="2" fill="#e7e7e5"/><rect x="126" y="74" width="28" height="4" rx="2" fill="#4084cf"/><rect x="180" y="72" width="6" height="10" rx="3" fill="#b0cbeb"/><rect x="189" y="76" width="6" height="6" rx="3" fill="#b0cbeb"/><rect x="198" y="73" width="6" height="9" rx="3" fill="#b0cbeb"/><rect x="207" y="79" width="6" height="3" rx="1.5" fill="#4084cf"/><rect x="214" y="81" width="5" height="1.5" rx="0.75" fill="#e7e7e5"/><rect x="221" y="81" width="5" height="1.5" rx="0.75" fill="#e7e7e5"/><rect x="228" y="81" width="5" height="1.5" rx="0.75" fill="#e7e7e5"/></svg>
@@ -0,0 +1,73 @@
1
+ /* Every selector starts at the instance and goes down a step at a time (>), so that nothing here
2
+ reaches the rest of the page. The pack's design B, in the kit's card tokens: no head, four cells, each
3
+ its label after a small picture of what it counts (12px, muted; the picture faint), its number (28px,
4
+ 32px on a wide card) with its unit or its whole after it, its picture at the bottom (the documents'
5
+ squares, the words' line and the area fading under it, the to-dos' bar, the week's bars: the accent and
6
+ its middle shade, on the track) and a faint line under it, its key words 600. In a row (8 × 2, 12 × 2)
7
+ the cells stand a hairline apart, the face out over the card's padding at its sides so that each cell has
8
+ the card's own 16px; two by two (4 × 4) the face fills the card, each cell padded 16px, lined between
9
+ them. Unread (no workspace) a faint dash each and a line at the bottom left. Light and dark. */
10
+ [data-doc-component="gallery/stats"] {
11
+ font-family: var(--gallery-font);
12
+ font-size: 13px;
13
+ line-height: 1.5;
14
+ color: var(--gallery-text);
15
+ > .gallery-stats-face { position: relative; display: flex; flex-direction: column; box-sizing: border-box; min-height: 0; }
16
+ > .gallery-stats-face > .gallery-stats-grid { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); min-height: 0; margin: 0; }
17
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell { display: flex; flex-direction: column; min-width: 0; padding: 0 16px; }
18
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell + .gallery-stats-cell { border-left: 1px solid var(--gallery-hair); }
19
+ > .gallery-stats-face[data-unread] > .gallery-stats-grid > .gallery-stats-cell + .gallery-stats-cell { border-left-color: transparent; }
20
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > dd { margin: 0; }
21
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-label { display: flex; align-items: center; gap: 6px; padding-inline-end: 0; font-size: 12px; line-height: 16px; color: var(--gallery-muted); white-space: nowrap; }
22
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-label > svg { flex: none; width: 13px; height: 13px; color: var(--gallery-faint); }
23
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-label > .gallery-stats-label-words { overflow: hidden; text-overflow: ellipsis; }
24
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-value { display: flex; align-items: baseline; margin-top: 7px; white-space: nowrap; }
25
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-value > .gallery-stats-number {
26
+ font-size: 28px;
27
+ line-height: 1;
28
+ font-weight: var(--gallery-numeral-weight);
29
+ letter-spacing: var(--gallery-numeral-tracking);
30
+ font-variant-numeric: lining-nums;
31
+ color: var(--gallery-text-strong);
32
+ }
33
+ > .gallery-stats-face[data-unread] > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-value > .gallery-stats-number { font-weight: 300; color: var(--gallery-faintest); }
34
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-value > .gallery-stats-unit { margin-left: 3px; font-size: var(--gallery-unit); font-weight: 500; color: var(--gallery-muted); }
35
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-value > .gallery-stats-of { margin-left: 3px; font-size: 15px; font-weight: 600; color: var(--gallery-faint); }
36
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-picture { margin-top: auto; }
37
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-picture > svg { display: block; overflow: visible; }
38
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-caption { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 11.5px; line-height: 16px; color: var(--gallery-faint); white-space: nowrap; overflow: hidden; }
39
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-caption > .gallery-stats-mark { flex: none; width: 6px; height: 6px; border-radius: 2px; background: var(--gallery-accent); }
40
+ > .gallery-stats-face > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-caption > .gallery-stats-strong { font-weight: 600; color: var(--gallery-muted); }
41
+ /* The pictures' colors. */
42
+ > .gallery-stats-face .gallery-stats-on { fill: var(--gallery-accent); }
43
+ > .gallery-stats-face :is(.gallery-stats-off, .gallery-stats-stub) { fill: var(--gallery-track); }
44
+ > .gallery-stats-face .gallery-stats-empty { fill: var(--gallery-fill); }
45
+ > .gallery-stats-face .gallery-stats-flat { stroke: var(--gallery-track); }
46
+ > .gallery-stats-face .gallery-stats-line { stroke: var(--gallery-accent); }
47
+ > .gallery-stats-face .gallery-stats-stop { stop-color: var(--gallery-accent); }
48
+ > .gallery-stats-face .gallery-stats-end { fill: var(--gallery-accent); stroke: var(--gallery-card-fill); }
49
+ > .gallery-stats-face .gallery-stats-today { fill: var(--gallery-accent); }
50
+ > .gallery-stats-face .gallery-stats-day { fill: var(--gallery-accent-mid); }
51
+ > .gallery-stats-face .gallery-stats-bar { position: relative; display: block; height: 6px; border-radius: 3px; overflow: hidden; background: var(--gallery-track); }
52
+ > .gallery-stats-face .gallery-stats-bar > .gallery-stats-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--gallery-accent); }
53
+ /* Unread: a line at the bottom left. */
54
+ > .gallery-stats-face > .gallery-stats-line { position: absolute; left: 16px; bottom: 0; margin: 0; font-size: 11.5px; line-height: 16px; color: var(--gallery-faint); }
55
+ > .gallery-stats-face > .gallery-stats-line[hidden] { display: none; }
56
+ /* A wide card: the numbers larger. */
57
+ > .gallery-stats-face[data-layout="wide"] > .gallery-stats-grid > .gallery-stats-cell > .gallery-stats-value > .gallery-stats-number { font-size: 32px; }
58
+ /* A square card: two by two. */
59
+ > .gallery-stats-face[data-layout="square"] > .gallery-stats-grid { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
60
+ > .gallery-stats-face[data-layout="square"] > .gallery-stats-grid > .gallery-stats-cell { padding: 16px; }
61
+ > .gallery-stats-face[data-layout="square"] > .gallery-stats-grid > .gallery-stats-cell + .gallery-stats-cell { border-left: 0; }
62
+ > .gallery-stats-face[data-layout="square"] > .gallery-stats-grid > .gallery-stats-cell:nth-child(2n) { border-left: 1px solid var(--gallery-hair); }
63
+ > .gallery-stats-face[data-layout="square"] > .gallery-stats-grid > .gallery-stats-cell:nth-child(n + 3) { border-top: 1px solid var(--gallery-hair); }
64
+ > .gallery-stats-face[data-layout="square"][data-unread] > .gallery-stats-grid > .gallery-stats-cell { border-color: transparent; }
65
+ > .gallery-stats-face[data-layout="square"] .gallery-stats-bar { height: 8px; border-radius: 4px; }
66
+ > .gallery-stats-face[data-layout="square"] .gallery-stats-bar > .gallery-stats-fill { border-radius: 4px; }
67
+ > .gallery-stats-face[data-layout="square"] > .gallery-stats-line { bottom: 16px; }
68
+ }
69
+ /* On a custom page the face is the card's: out over its padding at its sides (all round when square), so
70
+ that each cell has the card's own room. */
71
+ .gallery-card > [data-doc-component="gallery/stats"] { height: 100%; }
72
+ .gallery-card > [data-doc-component="gallery/stats"] > .gallery-stats-face { height: 100%; margin: 0 calc(-1 * var(--gallery-card-pad)); }
73
+ .gallery-card > [data-doc-component="gallery/stats"] > .gallery-stats-face[data-layout="square"] { height: calc(100% + 2 * var(--gallery-card-pad)); margin: calc(-1 * var(--gallery-card-pad)); }
@@ -0,0 +1 @@
1
+ <div data-doc-component="gallery/stats"></div>
@@ -0,0 +1,11 @@
1
+ # 工作区统计 (gallery/stats)
2
+
3
+ A card for a custom page (its places are `page`, its needs `workspace`): four numbers of the workspace, its documents (文档), its to-dos done of all (待办完成, 3/12), the words of all its documents (总字数) and how many documents were edited this week, since Monday (本周编辑). Use it on the home page.
4
+
5
+ ## How to write it
6
+
7
+ Put it on a custom page as a card of its board, `<section class="gallery-card" data-card-id="…" data-x data-y data-w data-h>`, holding one instance, after `gallery block add stats`: the instance is empty, `<div data-doc-component="gallery/stats"></div>`, everything on it drawn by its script. It has no settings and holds no data: there is nothing to fill in and nothing it writes. Sizes: 8 × 2 (the default: the four in a row), 12 × 2 (the same, larger) and 4 × 4 (two by two).
8
+
9
+ ## How it looks
10
+
11
+ In Gallery 风格's look (the kit's card tokens, light and dark): a head of a small gray chip and a title, its end clear of the card's grip; one hero; the rest small and gray; the accent on the data and on today alone. It has no head: the four labels are its titles, each after a small picture of what it counts, four cells a hairline apart (two by two on a 4 × 4 card), each a number (28px) and a small chart of its own: the documents a square each, those edited this week in the accent; the words a line of their total over the last 30 days and what those days added (近 30 天 +6万); the to-dos done a bar (70% · 还剩 8 项); the edits this week a bar a day, today's in the accent, against the same days of the week before (比上周同期 +14%). An empty workspace says 0 and what each waits for; where the workspace cannot be read, a dash each.
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "gallery/today",
3
+ "apiVersion": 1,
4
+ "version": "2.0.0",
5
+ "name": { "zh": "问候与日期", "en": "Greeting and date" },
6
+ "description": { "zh": "按时间问候,显示今天的日期和星期,到点自己更新", "en": "A greeting by the time of day, today's date and weekday, kept up to date by the clock" },
7
+ "words": "wenhouyuriqi wenhou riqi xingqi jintian today greeting date 问候 日期 星期 今天 时间",
8
+ "parts": {},
9
+ "runtime": { "generated": [":scope > .gallery-today-face"] },
10
+ "places": ["page"],
11
+ "card": { "sizes": [[4, 2], [2, 2], [4, 1]], "resize": true }
12
+ }
@@ -0,0 +1 @@
1
+ <div data-doc-component="gallery/today"></div>