sourcemonkey 0.0.0-stage → 0.5.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 (367) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +87 -2
  3. package/dist/bytes.js +37 -0
  4. package/dist/channel-placeholder.js +5 -0
  5. package/dist/collection-scan.js +17 -0
  6. package/dist/collections.html +353 -0
  7. package/dist/compare.html +358 -0
  8. package/dist/composed-source.js +205 -0
  9. package/dist/connect-prompt.html +47 -0
  10. package/dist/debug/icons.html +211 -0
  11. package/dist/debug/storage.html +163 -0
  12. package/dist/debug-log.js +75 -0
  13. package/dist/diagnostic-location.js +64 -0
  14. package/dist/eval-hook.js +308 -0
  15. package/dist/extension/background.js +5263 -0
  16. package/dist/extension/channel.js +133 -0
  17. package/dist/extension/code-links.js +187 -0
  18. package/dist/extension/code-tabs.js +460 -0
  19. package/dist/extension/collection-dialog.js +619 -0
  20. package/dist/extension/collection-display.js +322 -0
  21. package/dist/extension/collections.js +2905 -0
  22. package/dist/extension/compare.js +867 -0
  23. package/dist/extension/concurrency.js +186 -0
  24. package/dist/extension/connect-grants.js +109 -0
  25. package/dist/extension/connect-prompt-page.js +70 -0
  26. package/dist/extension/connect-prompt.js +266 -0
  27. package/dist/extension/copy-button.js +63 -0
  28. package/dist/extension/copy-dialog.js +502 -0
  29. package/dist/extension/copy-preference.js +66 -0
  30. package/dist/extension/debug/icons.js +203 -0
  31. package/dist/extension/debug/storage.js +365 -0
  32. package/dist/extension/deep-link.js +77 -0
  33. package/dist/extension/delete-dialog.js +432 -0
  34. package/dist/extension/delete-icon.js +40 -0
  35. package/dist/extension/details-tooltips.js +66 -0
  36. package/dist/extension/directories.js +679 -0
  37. package/dist/extension/export-backup.js +407 -0
  38. package/dist/extension/export-dialog.js +142 -0
  39. package/dist/extension/file-access.js +74 -0
  40. package/dist/extension/file-changes.js +346 -0
  41. package/dist/extension/frame-info.js +85 -0
  42. package/dist/extension/github-provider.js +336 -0
  43. package/dist/extension/glyph.js +84 -0
  44. package/dist/extension/gm-bindings.js +601 -0
  45. package/dist/extension/gm-download.js +419 -0
  46. package/dist/extension/gm-menu.js +228 -0
  47. package/dist/extension/gm-notification.js +141 -0
  48. package/dist/extension/gm-originator-map.js +23 -0
  49. package/dist/extension/gm-tab-data.js +121 -0
  50. package/dist/extension/gm-tab.js +160 -0
  51. package/dist/extension/gm-url-change.js +111 -0
  52. package/dist/extension/gm-url-scheme.js +27 -0
  53. package/dist/extension/gm-values.js +176 -0
  54. package/dist/extension/gm-window-control.js +104 -0
  55. package/dist/extension/gm-xhr-headers.js +333 -0
  56. package/dist/extension/gm-xhr.js +584 -0
  57. package/dist/extension/injector.js +3145 -0
  58. package/dist/extension/install-capture.js +277 -0
  59. package/dist/extension/line-diff.js +233 -0
  60. package/dist/extension/local-copy.js +560 -0
  61. package/dist/extension/local-delete.js +276 -0
  62. package/dist/extension/location-kinds.js +108 -0
  63. package/dist/extension/log-format.js +158 -0
  64. package/dist/extension/managed-changes.js +361 -0
  65. package/dist/extension/managed-items.js +57 -0
  66. package/dist/extension/match-index.js +375 -0
  67. package/dist/extension/missing-scripts.js +66 -0
  68. package/dist/extension/more-menu.js +109 -0
  69. package/dist/extension/move-dialog.js +197 -0
  70. package/dist/extension/offscreen.js +37 -0
  71. package/dist/extension/options.js +504 -0
  72. package/dist/extension/page-heading.js +170 -0
  73. package/dist/extension/page-links.js +199 -0
  74. package/dist/extension/parse-check-client.js +70 -0
  75. package/dist/extension/parse-check.js +161 -0
  76. package/dist/extension/parse-sandbox-host.js +172 -0
  77. package/dist/extension/parse-sandbox.js +175 -0
  78. package/dist/extension/popup-commands-open.js +41 -0
  79. package/dist/extension/popup-view.js +387 -0
  80. package/dist/extension/popup.js +703 -0
  81. package/dist/extension/prism-userscript.js +53 -0
  82. package/dist/extension/refresh-error.js +136 -0
  83. package/dist/extension/refresh-targets.js +160 -0
  84. package/dist/extension/related-versions.js +1144 -0
  85. package/dist/extension/resize-observer-loop.js +19 -0
  86. package/dist/extension/row-cache.js +387 -0
  87. package/dist/extension/script-blobs.js +413 -0
  88. package/dist/extension/script-details.js +658 -0
  89. package/dist/extension/script-enablement.js +285 -0
  90. package/dist/extension/script-identity.js +310 -0
  91. package/dist/extension/script-keys.js +54 -0
  92. package/dist/extension/script-log-id.js +155 -0
  93. package/dist/extension/script-log.js +290 -0
  94. package/dist/extension/script-rejection.js +104 -0
  95. package/dist/extension/script-sites.js +158 -0
  96. package/dist/extension/script-store.js +3507 -0
  97. package/dist/extension/script-updater.js +991 -0
  98. package/dist/extension/script-url-hash.js +61 -0
  99. package/dist/extension/select-all.js +37 -0
  100. package/dist/extension/select-open-guard.js +90 -0
  101. package/dist/extension/site-icon.js +1261 -0
  102. package/dist/extension/sm-dev-link.js +302 -0
  103. package/dist/extension/solo-click.js +58 -0
  104. package/dist/extension/sticky-numbers.js +188 -0
  105. package/dist/extension/storage-breakdown.js +253 -0
  106. package/dist/extension/storage-scan.js +86 -0
  107. package/dist/extension/storage-usage.js +194 -0
  108. package/dist/extension/structural-keys.js +29 -0
  109. package/dist/extension/sw-teardown.js +36 -0
  110. package/dist/extension/tab-status.js +403 -0
  111. package/dist/extension/toolbar-summary.js +105 -0
  112. package/dist/extension/user-scripts-access.js +43 -0
  113. package/dist/extension/userscript.js +3672 -0
  114. package/dist/extension/value-store.js +204 -0
  115. package/dist/extension/version-probe-fetch.js +68 -0
  116. package/dist/extension/worker-client.js +109 -0
  117. package/dist/extension/worker-ops.js +171 -0
  118. package/dist/extension/zip-writer.js +24 -0
  119. package/dist/external-files.js +878 -0
  120. package/dist/file-loader.js +436 -0
  121. package/dist/file-locations.js +439 -0
  122. package/dist/generated-wrappers.js +5 -0
  123. package/dist/github-auth.js +148 -0
  124. package/dist/github-urls.js +46 -0
  125. package/dist/gm-api-catalog.js +217 -0
  126. package/dist/gm-connect.js +273 -0
  127. package/dist/gm-xhr-types.js +5 -0
  128. package/dist/http-read.js +142 -0
  129. package/dist/icons/icon-128.png +0 -0
  130. package/dist/icons/icon-16.png +0 -0
  131. package/dist/icons/icon-48.png +0 -0
  132. package/dist/local-file-overrides.js +558 -0
  133. package/dist/manifest.json +38 -0
  134. package/dist/markup-response.js +126 -0
  135. package/dist/match-targets.js +305 -0
  136. package/dist/menu-captions.js +22 -0
  137. package/dist/offscreen.html +39 -0
  138. package/dist/options.html +197 -0
  139. package/dist/parse-check-protocol.js +51 -0
  140. package/dist/parse-location.js +171 -0
  141. package/dist/parse-sandbox.html +56 -0
  142. package/dist/phase-timing.js +155 -0
  143. package/dist/popup.html +197 -0
  144. package/dist/public-suffixes.js +6957 -0
  145. package/dist/run-context.js +31 -0
  146. package/dist/runtime-messages.js +34 -0
  147. package/dist/sandboxed-page.js +35 -0
  148. package/dist/script-build.js +787 -0
  149. package/dist/script-display.js +383 -0
  150. package/dist/script-icon.js +43 -0
  151. package/dist/script-links.js +204 -0
  152. package/dist/script-source-url.js +214 -0
  153. package/dist/script-world.js +65 -0
  154. package/dist/sm-dev-protocol.js +84 -0
  155. package/dist/source-map.js +177 -0
  156. package/dist/stack-link.js +138 -0
  157. package/dist/styles.css +825 -0
  158. package/dist/unsafe-window-use.js +229 -0
  159. package/dist/url-match.js +734 -0
  160. package/dist/userscript-header.js +248 -0
  161. package/dist/userscript.html +1165 -0
  162. package/dist/vendor/fflate.LICENSE +21 -0
  163. package/dist/vendor/fflate.js +2692 -0
  164. package/dist/vendor/prism/prism-line-numbers.css +1 -0
  165. package/dist/vendor/prism/prism-line-numbers.js +1 -0
  166. package/dist/vendor/prism/prism.css +1 -0
  167. package/dist/vendor/prism/prism.js +1946 -0
  168. package/dist/version-compare.js +141 -0
  169. package/dist/version-probe.js +120 -0
  170. package/lib/build-info.json +1 -0
  171. package/lib/bytes.d.ts +3 -0
  172. package/lib/bytes.js +37 -0
  173. package/lib/channel-placeholder.d.ts +1 -0
  174. package/lib/channel-placeholder.js +5 -0
  175. package/lib/collection-scan.d.ts +8 -0
  176. package/lib/collection-scan.js +17 -0
  177. package/lib/composed-source.d.ts +28 -0
  178. package/lib/composed-source.js +205 -0
  179. package/lib/debug-log.d.ts +9 -0
  180. package/lib/debug-log.js +75 -0
  181. package/lib/diagnostic-location.d.ts +8 -0
  182. package/lib/diagnostic-location.js +64 -0
  183. package/lib/eval-hook.d.ts +34 -0
  184. package/lib/eval-hook.js +308 -0
  185. package/lib/external-files.d.ts +111 -0
  186. package/lib/external-files.js +878 -0
  187. package/lib/file-loader.d.ts +48 -0
  188. package/lib/file-loader.js +436 -0
  189. package/lib/file-locations.d.ts +44 -0
  190. package/lib/file-locations.js +439 -0
  191. package/lib/generated-wrappers.d.ts +11 -0
  192. package/lib/generated-wrappers.js +5 -0
  193. package/lib/github-auth.d.ts +12 -0
  194. package/lib/github-auth.js +148 -0
  195. package/lib/github-urls.d.ts +1 -0
  196. package/lib/github-urls.js +46 -0
  197. package/lib/gm-api-catalog.d.ts +24 -0
  198. package/lib/gm-api-catalog.js +217 -0
  199. package/lib/gm-connect.d.ts +34 -0
  200. package/lib/gm-connect.js +273 -0
  201. package/lib/gm-xhr-types.d.ts +68 -0
  202. package/lib/gm-xhr-types.js +5 -0
  203. package/lib/harness/browser-extensions.d.ts +73 -0
  204. package/lib/harness/browser-extensions.js +285 -0
  205. package/lib/harness/browser-lang.d.ts +20 -0
  206. package/lib/harness/browser-lang.js +86 -0
  207. package/lib/harness/browser-launch.d.ts +14 -0
  208. package/lib/harness/browser-launch.js +184 -0
  209. package/lib/harness/checks.d.ts +110 -0
  210. package/lib/harness/checks.js +321 -0
  211. package/lib/harness/cli.d.ts +2 -0
  212. package/lib/harness/cli.js +2259 -0
  213. package/lib/harness/command-args.d.ts +91 -0
  214. package/lib/harness/command-args.js +369 -0
  215. package/lib/harness/command-lines.d.ts +80 -0
  216. package/lib/harness/command-lines.js +180 -0
  217. package/lib/harness/command-list.d.ts +206 -0
  218. package/lib/harness/command-list.js +1475 -0
  219. package/lib/harness/console-commands.d.ts +463 -0
  220. package/lib/harness/console-commands.js +3216 -0
  221. package/lib/harness/download-watch.d.ts +21 -0
  222. package/lib/harness/download-watch.js +156 -0
  223. package/lib/harness/extension-backend.d.ts +41 -0
  224. package/lib/harness/extension-backend.js +100 -0
  225. package/lib/harness/extension-host.d.ts +112 -0
  226. package/lib/harness/extension-host.js +552 -0
  227. package/lib/harness/extension-launch.d.ts +67 -0
  228. package/lib/harness/extension-launch.js +285 -0
  229. package/lib/harness/extension-link.d.ts +315 -0
  230. package/lib/harness/extension-link.js +607 -0
  231. package/lib/harness/external-manager.d.ts +146 -0
  232. package/lib/harness/external-manager.js +414 -0
  233. package/lib/harness/fixture.d.ts +165 -0
  234. package/lib/harness/fixture.js +461 -0
  235. package/lib/harness/frame-sessions.d.ts +71 -0
  236. package/lib/harness/frame-sessions.js +248 -0
  237. package/lib/harness/frames.d.ts +68 -0
  238. package/lib/harness/frames.js +216 -0
  239. package/lib/harness/help-format.d.ts +17 -0
  240. package/lib/harness/help-format.js +127 -0
  241. package/lib/harness/host.d.ts +352 -0
  242. package/lib/harness/host.js +423 -0
  243. package/lib/harness/index.d.ts +8 -0
  244. package/lib/harness/index.js +10 -0
  245. package/lib/harness/input-file.d.ts +18 -0
  246. package/lib/harness/input-file.js +61 -0
  247. package/lib/harness/json-output.d.ts +565 -0
  248. package/lib/harness/json-output.js +71 -0
  249. package/lib/harness/manager-actions.d.ts +21 -0
  250. package/lib/harness/manager-actions.js +129 -0
  251. package/lib/harness/manager-commands.d.ts +142 -0
  252. package/lib/harness/manager-commands.js +1196 -0
  253. package/lib/harness/manager-fetch.d.ts +33 -0
  254. package/lib/harness/manager-fetch.js +239 -0
  255. package/lib/harness/managers.d.ts +24 -0
  256. package/lib/harness/managers.js +27 -0
  257. package/lib/harness/output-style.d.ts +125 -0
  258. package/lib/harness/output-style.js +322 -0
  259. package/lib/harness/page-commands.d.ts +134 -0
  260. package/lib/harness/page-commands.js +1141 -0
  261. package/lib/harness/page-output.d.ts +67 -0
  262. package/lib/harness/page-output.js +139 -0
  263. package/lib/harness/page-watch.d.ts +171 -0
  264. package/lib/harness/page-watch.js +607 -0
  265. package/lib/harness/parse-check-node.d.ts +3 -0
  266. package/lib/harness/parse-check-node.js +132 -0
  267. package/lib/harness/path-args.d.ts +22 -0
  268. package/lib/harness/path-args.js +148 -0
  269. package/lib/harness/playwright-chromium.d.ts +16 -0
  270. package/lib/harness/playwright-chromium.js +86 -0
  271. package/lib/harness/prepare.d.ts +168 -0
  272. package/lib/harness/prepare.js +364 -0
  273. package/lib/harness/prompt-editor.d.ts +17 -0
  274. package/lib/harness/prompt-editor.js +354 -0
  275. package/lib/harness/prompt-history.d.ts +13 -0
  276. package/lib/harness/prompt-history.js +89 -0
  277. package/lib/harness/rebuild-advice.d.ts +6 -0
  278. package/lib/harness/rebuild-advice.js +39 -0
  279. package/lib/harness/run-log.d.ts +47 -0
  280. package/lib/harness/run-log.js +140 -0
  281. package/lib/harness/run-logs.d.ts +132 -0
  282. package/lib/harness/run-logs.js +241 -0
  283. package/lib/harness/run.d.ts +194 -0
  284. package/lib/harness/run.js +1973 -0
  285. package/lib/harness/runs.d.ts +229 -0
  286. package/lib/harness/runs.js +726 -0
  287. package/lib/harness/save-html.d.ts +39 -0
  288. package/lib/harness/save-html.js +89 -0
  289. package/lib/harness/saved-pages.d.ts +120 -0
  290. package/lib/harness/saved-pages.js +275 -0
  291. package/lib/harness/script-mark.d.ts +17 -0
  292. package/lib/harness/script-mark.js +56 -0
  293. package/lib/harness/snapshot.d.ts +143 -0
  294. package/lib/harness/snapshot.js +474 -0
  295. package/lib/harness/stuck-tabs.d.ts +19 -0
  296. package/lib/harness/stuck-tabs.js +131 -0
  297. package/lib/harness/tab-refs.d.ts +20 -0
  298. package/lib/harness/tab-refs.js +80 -0
  299. package/lib/harness/tampermonkey.d.ts +71 -0
  300. package/lib/harness/tampermonkey.js +356 -0
  301. package/lib/harness/tm-ids.d.ts +18 -0
  302. package/lib/harness/tm-ids.js +88 -0
  303. package/lib/harness/violentmonkey.d.ts +34 -0
  304. package/lib/harness/violentmonkey.js +162 -0
  305. package/lib/harness/wait.d.ts +77 -0
  306. package/lib/harness/wait.js +458 -0
  307. package/lib/http-read.d.ts +30 -0
  308. package/lib/http-read.js +142 -0
  309. package/lib/local-file-overrides.d.ts +35 -0
  310. package/lib/local-file-overrides.js +558 -0
  311. package/lib/manifest.json +38 -0
  312. package/lib/markup-response.d.ts +11 -0
  313. package/lib/markup-response.js +126 -0
  314. package/lib/match-targets.d.ts +18 -0
  315. package/lib/match-targets.js +305 -0
  316. package/lib/menu-captions.d.ts +1 -0
  317. package/lib/menu-captions.js +22 -0
  318. package/lib/parse-check-protocol.d.ts +27 -0
  319. package/lib/parse-check-protocol.js +51 -0
  320. package/lib/parse-location.d.ts +12 -0
  321. package/lib/parse-location.js +171 -0
  322. package/lib/phase-timing.d.ts +12 -0
  323. package/lib/phase-timing.js +155 -0
  324. package/lib/public-suffixes.d.ts +1 -0
  325. package/lib/public-suffixes.js +6957 -0
  326. package/lib/run-context.d.ts +2 -0
  327. package/lib/run-context.js +31 -0
  328. package/lib/runtime-messages.d.ts +10 -0
  329. package/lib/runtime-messages.js +34 -0
  330. package/lib/sandboxed-page.d.ts +5 -0
  331. package/lib/sandboxed-page.js +35 -0
  332. package/lib/script-build.d.ts +111 -0
  333. package/lib/script-build.js +787 -0
  334. package/lib/script-display.d.ts +51 -0
  335. package/lib/script-display.js +383 -0
  336. package/lib/script-icon.d.ts +16 -0
  337. package/lib/script-icon.js +43 -0
  338. package/lib/script-links.d.ts +24 -0
  339. package/lib/script-links.js +204 -0
  340. package/lib/script-source-url.d.ts +8 -0
  341. package/lib/script-source-url.js +214 -0
  342. package/lib/script-world.d.ts +6 -0
  343. package/lib/script-world.js +65 -0
  344. package/lib/sm-dev-protocol.d.ts +251 -0
  345. package/lib/sm-dev-protocol.js +84 -0
  346. package/lib/source-map.d.ts +32 -0
  347. package/lib/source-map.js +177 -0
  348. package/lib/stack-link.d.ts +15 -0
  349. package/lib/stack-link.js +138 -0
  350. package/lib/unsafe-window-use.d.ts +1 -0
  351. package/lib/unsafe-window-use.js +229 -0
  352. package/lib/url-match.d.ts +40 -0
  353. package/lib/url-match.js +734 -0
  354. package/lib/userscript-header.d.ts +33 -0
  355. package/lib/userscript-header.js +248 -0
  356. package/lib/version-compare.d.ts +6 -0
  357. package/lib/version-compare.js +141 -0
  358. package/lib/version-probe.d.ts +17 -0
  359. package/lib/version-probe.js +120 -0
  360. package/package.json +55 -3
  361. package/skills/SourceMonkey-dev/SKILL.md +868 -0
  362. package/skills/SourceMonkey-dev/references/cdp.md +293 -0
  363. package/skills/SourceMonkey-dev/references/commands.md +297 -0
  364. package/skills/SourceMonkey-dev/references/other-managers.md +63 -0
  365. package/skills/SourceMonkey-dev/references/specs.md +46 -0
  366. package/skills/SourceMonkey-friction/SKILL.md +103 -0
  367. package/skills/SourceMonkey-friction/references/template.md +59 -0
@@ -0,0 +1,211 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>SourceMonkey | Debug | Icons</title>
6
+ <link rel="stylesheet" href="../styles.css" />
7
+ <style>
8
+ body { font: 14px system-ui, sans-serif; margin: 0; color: #222; --page-width: 1120px; }
9
+ button { font: inherit; padding: 0 11px; cursor: pointer; }
10
+ .toolbar {
11
+ display: flex;
12
+ align-items: center;
13
+ justify-content: space-between;
14
+ margin: 14px 0 10px;
15
+ gap: 12px;
16
+ }
17
+ .summary { color: #555; font-size: 0.92em; margin: 0; }
18
+ .empty-state {
19
+ margin: 24px 0;
20
+ padding: 18px;
21
+ border: 1px dashed #ccc;
22
+ border-radius: 6px;
23
+ color: #666;
24
+ text-align: center;
25
+ }
26
+ table.icons-table {
27
+ width: 100%;
28
+ border-collapse: collapse;
29
+ font-size: 13px;
30
+ }
31
+ table.icons-table th,
32
+ table.icons-table td {
33
+ padding: 6px 8px;
34
+ border-bottom: 1px solid #eee;
35
+ text-align: left;
36
+ vertical-align: middle;
37
+ }
38
+ table.icons-table th {
39
+ font-weight: 600;
40
+ color: #444;
41
+ border-bottom: 2px solid #ddd;
42
+ white-space: nowrap;
43
+ }
44
+ td.col-icon { width: 28px; text-align: center; }
45
+ td.col-icon img,
46
+ td.col-icon svg {
47
+ width: 16px;
48
+ height: 16px;
49
+ vertical-align: middle;
50
+ }
51
+ td.col-target {
52
+ max-width: 360px;
53
+ overflow-wrap: anywhere;
54
+ }
55
+ td.col-target a {
56
+ color: #0969da;
57
+ text-decoration: none;
58
+ }
59
+ td.col-target a:hover { text-decoration: underline; }
60
+ .kind-chip {
61
+ display: inline-block;
62
+ padding: 1px 6px;
63
+ border-radius: 4px;
64
+ font-size: 11px;
65
+ font-weight: 600;
66
+ text-transform: uppercase;
67
+ background: #f0f2f5;
68
+ color: #444;
69
+ }
70
+ .kind-chip.kind-origin { background: #e6f4ea; color: #137333; }
71
+ .kind-chip.kind-path { background: #e8f0fe; color: #1967d2; }
72
+ .kind-chip.kind-url { background: #fef7e0; color: #b06000; }
73
+ .status-badge {
74
+ display: inline-block;
75
+ padding: 1px 5px;
76
+ border-radius: 3px;
77
+ font-size: 11px;
78
+ margin-left: 4px;
79
+ }
80
+ .status-ok { background: #e6f4ea; color: #137333; }
81
+ .status-miss { background: #f1f3f4; color: #5f6368; }
82
+ .status-stale { background: #fce8e6; color: #c5221f; }
83
+ td.col-time {
84
+ white-space: nowrap;
85
+ font-variant-numeric: tabular-nums;
86
+ color: #444;
87
+ }
88
+ td.col-actions {
89
+ white-space: nowrap;
90
+ text-align: right;
91
+ }
92
+ .row-actions {
93
+ display: inline-flex;
94
+ gap: 4px;
95
+ align-items: center;
96
+ }
97
+ </style>
98
+ </head>
99
+ <body>
100
+ <!-- Shared glyph sprite: the one copy of every inline SVG glyph in the
101
+ extension. scripts/build.mjs inlines it into each page wherever the
102
+ page writes an `#include glyph-sprite` marker comment. (Spelling
103
+ that marker out here would be nice, but its own closing `--` plus
104
+ `>` would end THIS comment and spill the rest onto the page.)
105
+
106
+ One source of truth: the markup used to be copy-pasted into each
107
+ page's HTML, which is how two pages end up with glyphs that have
108
+ quietly drifted apart.
109
+
110
+ Each symbol is defined once per page and referenced by a `use`
111
+ element, so a hundred rows share one copy of the path data instead
112
+ of inlining it per row.
113
+
114
+ #sm-globe favicon placeholder until a site icon loads, and
115
+ the permanent icon for a script with no resolvable
116
+ origin (src/extension/site-icon.ts; styling on
117
+ `.site-icon-globe`).
118
+ #sm-trash remove SourceMonkey's record of a script.
119
+ #sm-trash-file delete the script FILE from disk — the same can,
120
+ badged with a disk. Both painted by
121
+ src/extension/delete-icon.ts, which explains the pair.
122
+ The can is drawn ~19% smaller than #sm-trash — its
123
+ own inner scale(.9) inside the normalizing
124
+ wrapper's scale(.9) — so the badge has a corner to
125
+ sit in without swallowing the can. Deliberate: the two appear in the same
126
+ column in the "Other versions" panel, and the
127
+ badged one has to stay a can at 15px.
128
+ #sm-copy the viewer's "copy this to the clipboard" button,
129
+ #sm-check and the checkmark it flashes on success
130
+ (src/extension/copy-button.ts).
131
+ #sm-refresh refetch a collection, a script, or one row of the
132
+ "Other versions" table. Its busy state is this
133
+ same arc spinning (`.btn-glyph.spinning`), so the
134
+ button never changes shape mid-refresh.
135
+ #sm-gear open a collection's rename / options dialog.
136
+ #sm-open open a location in a new tab (the collection
137
+ dialog's button beside its location box).
138
+ #sm-swap the compare page's "swap the two sides" button:
139
+ two arrows, one each way, the same width so their
140
+ ends line up.
141
+
142
+ Colour comes from `currentColor`, so a button's own `color` (and
143
+ its hover) drives the glyph.
144
+
145
+ OPTICAL SIZING — read before editing a path or a stroke width.
146
+ Identical 16px boxes do not make icons look the same size; the ink
147
+ inside them has to match too. As drawn, these ranged from 18 to
148
+ 23.3 units of 24, and the gear read ~22% larger than the arrow. So
149
+ a glyph that needed resizing is wrapped in
150
+ <g transform="translate(12 12) scale(k) translate(-12 -12)">
151
+ and its `stroke-width` is DIVIDED by the same k. Consequences:
152
+ - The number in the file is not the number that renders. Every
153
+ glyph here strokes at 1.75 units once its wrapper is applied
154
+ (1.9/... , 1.95/.9, 1.667*1.05, 1.825*.959). Change a stroke
155
+ width and you break that unless you change k with it.
156
+ - #sm-refresh translates by -13, not -12: Feather's rotate-cw is
157
+ drawn a unit right of centre, and this puts it back. It is not
158
+ a typo.
159
+ - #sm-copy and #sm-check are deliberately outside this: they
160
+ stroke at 2.0 in the 14px copy button. That button sits beside
161
+ the 1.75 set only in the collection dialog, next to #sm-open,
162
+ where the smaller box evens out the heavier stroke. -->
163
+ <svg width="0" height="0" style="position:absolute" aria-hidden="true">
164
+ <symbol id="sm-globe" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"></circle><path d="M2 12h20"></path><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></symbol>
165
+ <symbol id="sm-trash" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 6h17"></path><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"></path><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"></path><path d="M10 10.5v7"></path><path d="M14 10.5v7"></path></symbol>
166
+ <symbol id="sm-trash-file" viewBox="0 0 24 24"><g transform="translate(12 12) scale(.9) translate(-12 -12)"><mask id="sm-trash-file-cut" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24"><rect width="24" height="24" fill="#fff"></rect><circle cx="19.6" cy="19.6" r="5.2" fill="#000"></circle></mask><g mask="url(#sm-trash-file-cut)" transform="translate(-.7 -1.5) scale(.9)" fill="none" stroke="currentColor" stroke-width="2.167" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 6h17"></path><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"></path><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"></path><path d="M10 10.5v7"></path><path d="M14 10.5v7"></path></g><g transform="translate(14.53 14.36) scale(.422)" fill="none" stroke="currentColor" stroke-width="4.611" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"></path></g></g></symbol>
167
+ <symbol id="sm-copy" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></symbol>
168
+ <symbol id="sm-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></symbol>
169
+ <symbol id="sm-refresh" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.667" stroke-linecap="round" stroke-linejoin="round"><g transform="translate(12 12) scale(1.05) translate(-13 -12)"><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path><polyline points="23 4 23 10 17 10"></polyline></g></symbol>
170
+ <symbol id="sm-swap" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7.5h18"></path><path d="M16.5 3l4.5 4.5-4.5 4.5"></path><path d="M21 16.5H3"></path><path d="M7.5 12L3 16.5 7.5 21"></path></symbol>
171
+ <symbol id="sm-gear" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.825" stroke-linecap="round" stroke-linejoin="round"><g transform="translate(12 12) scale(.959) translate(-12 -12)"><circle cx="12" cy="12" r="3.1"></circle><path d="M19.4 14.6a1.6 1.6 0 0 0 .32 1.77l.06.06a1.95 1.95 0 1 1-2.76 2.76l-.06-.06a1.6 1.6 0 0 0-1.77-.32 1.6 1.6 0 0 0-.97 1.47V21a1.95 1.95 0 1 1-3.9 0v-.1a1.6 1.6 0 0 0-1.05-1.47 1.6 1.6 0 0 0-1.77.32l-.06.06a1.95 1.95 0 1 1-2.76-2.76l.06-.06a1.6 1.6 0 0 0 .32-1.77 1.6 1.6 0 0 0-1.47-.97H3a1.95 1.95 0 1 1 0-3.9h.1a1.6 1.6 0 0 0 1.47-1.05 1.6 1.6 0 0 0-.32-1.77l-.06-.06a1.95 1.95 0 1 1 2.76-2.76l.06.06a1.6 1.6 0 0 0 1.77.32H9a1.6 1.6 0 0 0 .97-1.47V3a1.95 1.95 0 1 1 3.9 0v.1a1.6 1.6 0 0 0 .97 1.47 1.6 1.6 0 0 0 1.77-.32l.06-.06a1.95 1.95 0 1 1 2.76 2.76l-.06.06a1.6 1.6 0 0 0-.32 1.77V9a1.6 1.6 0 0 0 1.47.97H21a1.95 1.95 0 1 1 0 3.9h-.1a1.6 1.6 0 0 0-1.47.97z"></path></g></symbol>
172
+ <symbol id="sm-open" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><path d="M10 14L21 3"></path></symbol>
173
+ </svg>
174
+ <header class="page-header">
175
+ <div class="page-header-inner">
176
+ <a class="page-home page-icon-link" href="../collections.html" target="_blank"
177
+ rel="noopener" tabindex="-1" aria-hidden="true">
178
+ <img class="page-icon" src="../icons/icon-48.png" alt="" />
179
+ </a>
180
+ <h1><a class="page-home brand" href="../collections.html" target="_blank" rel="noopener"
181
+ title="Open the collections page">SourceMonkey</a><span class="brand"> |</span> Debug <span class="brand">|</span> Icons</h1>
182
+ <div class="page-header-actions">
183
+ <button id="delete-all" type="button" title="Delete all cached icons">Delete All</button>
184
+ </div>
185
+ </div>
186
+ </header>
187
+
188
+ <div class="page-body">
189
+ <div class="toolbar">
190
+ <p id="icons-summary" class="summary"></p>
191
+ </div>
192
+ <div id="icons-empty" class="empty-state" hidden>No cached icons in storage.</div>
193
+ <table id="icons-table" class="icons-table" hidden>
194
+ <thead>
195
+ <tr>
196
+ <th>Icon</th>
197
+ <th>Site / Target</th>
198
+ <th>Scope</th>
199
+ <th>Details</th>
200
+ <th>Fetched</th>
201
+ <th>Expires</th>
202
+ <th>Actions</th>
203
+ </tr>
204
+ </thead>
205
+ <tbody id="icons-tbody"></tbody>
206
+ </table>
207
+ </div>
208
+
209
+ <script src="../extension/debug/icons.js" type="module"></script>
210
+ </body>
211
+ </html>
@@ -0,0 +1,163 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>SourceMonkey | Debug | Storage</title>
6
+ <link rel="stylesheet" href="../styles.css" />
7
+ <style>
8
+ /* No `--page-width`: the table takes the full window width, for its wide columns. */
9
+ body { font: 14px system-ui, sans-serif; margin: 0; color: #222; }
10
+ .toolbar { display: flex; align-items: center; gap: 16px; margin: 14px 0 10px; }
11
+ .summary { color: #555; font-size: 0.92em; margin: 0; }
12
+ .views { display: inline-flex; border: 1px solid #ccc; border-radius: 6px; overflow: hidden; flex: none; }
13
+ .views button {
14
+ font: inherit; font-size: 13px; padding: 3px 12px; border: 0; background: #fff;
15
+ color: inherit; cursor: pointer; border-left: 1px solid #ccc;
16
+ }
17
+ .views button:first-child { border-left: 0; }
18
+ .views button[aria-pressed="true"] { background: #e8f0fe; color: #1967d2; font-weight: 600; }
19
+ .empty-state {
20
+ margin: 24px 0;
21
+ padding: 18px;
22
+ border: 1px dashed #ccc;
23
+ border-radius: 6px;
24
+ color: #666;
25
+ text-align: center;
26
+ }
27
+ /* Fixed layout: long collection and script names wrap in their
28
+ columns instead of squeezing the rest. */
29
+ table.storage-table {
30
+ width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed;
31
+ }
32
+ table.storage-table th, table.storage-table td {
33
+ padding: 4px 8px; text-align: left; vertical-align: top; overflow-wrap: anywhere;
34
+ }
35
+ table.storage-table th {
36
+ font-weight: 600; color: #444; border-bottom: 2px solid #ddd; white-space: nowrap;
37
+ }
38
+ col.col-collection { width: 15%; }
39
+ col.col-name { width: 22%; }
40
+ col.col-values-name { width: 35%; }
41
+ col.col-size { width: 80px; }
42
+ col.col-shared { width: 110px; }
43
+ col.col-count { width: 90px; }
44
+ th.sortable { cursor: pointer; user-select: none; }
45
+ th.sortable:hover { color: #0969da; }
46
+ th .sort-arrow { color: #0969da; font-size: 10px; margin-left: 3px; }
47
+ th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
48
+ tbody.group { border-top: 1px solid #e3e3e3; }
49
+ tr.group-head td { font-weight: 600; padding-top: 7px; }
50
+ tr.group-item td { color: #444; padding-top: 1px; padding-bottom: 1px; }
51
+ td.item { padding-left: 24px; }
52
+ /* A use's names on a file's heading line aren't part of the heading. */
53
+ tr.group-head td.use { font-weight: normal; }
54
+ tbody.group > tr:last-child td { padding-bottom: 7px; }
55
+ table.storage-table a { color: #0969da; text-decoration: none; }
56
+ table.storage-table a:hover { text-decoration: underline; }
57
+ .kind { color: #666; font-family: ui-monospace, monospace; font-size: 12px; white-space: nowrap; }
58
+ .loc { font-family: ui-monospace, monospace; font-size: 12px; }
59
+ .muted { color: #888; font-style: italic; }
60
+ </style>
61
+ </head>
62
+ <body>
63
+ <!-- Shared glyph sprite: the one copy of every inline SVG glyph in the
64
+ extension. scripts/build.mjs inlines it into each page wherever the
65
+ page writes an `#include glyph-sprite` marker comment. (Spelling
66
+ that marker out here would be nice, but its own closing `--` plus
67
+ `>` would end THIS comment and spill the rest onto the page.)
68
+
69
+ One source of truth: the markup used to be copy-pasted into each
70
+ page's HTML, which is how two pages end up with glyphs that have
71
+ quietly drifted apart.
72
+
73
+ Each symbol is defined once per page and referenced by a `use`
74
+ element, so a hundred rows share one copy of the path data instead
75
+ of inlining it per row.
76
+
77
+ #sm-globe favicon placeholder until a site icon loads, and
78
+ the permanent icon for a script with no resolvable
79
+ origin (src/extension/site-icon.ts; styling on
80
+ `.site-icon-globe`).
81
+ #sm-trash remove SourceMonkey's record of a script.
82
+ #sm-trash-file delete the script FILE from disk — the same can,
83
+ badged with a disk. Both painted by
84
+ src/extension/delete-icon.ts, which explains the pair.
85
+ The can is drawn ~19% smaller than #sm-trash — its
86
+ own inner scale(.9) inside the normalizing
87
+ wrapper's scale(.9) — so the badge has a corner to
88
+ sit in without swallowing the can. Deliberate: the two appear in the same
89
+ column in the "Other versions" panel, and the
90
+ badged one has to stay a can at 15px.
91
+ #sm-copy the viewer's "copy this to the clipboard" button,
92
+ #sm-check and the checkmark it flashes on success
93
+ (src/extension/copy-button.ts).
94
+ #sm-refresh refetch a collection, a script, or one row of the
95
+ "Other versions" table. Its busy state is this
96
+ same arc spinning (`.btn-glyph.spinning`), so the
97
+ button never changes shape mid-refresh.
98
+ #sm-gear open a collection's rename / options dialog.
99
+ #sm-open open a location in a new tab (the collection
100
+ dialog's button beside its location box).
101
+ #sm-swap the compare page's "swap the two sides" button:
102
+ two arrows, one each way, the same width so their
103
+ ends line up.
104
+
105
+ Colour comes from `currentColor`, so a button's own `color` (and
106
+ its hover) drives the glyph.
107
+
108
+ OPTICAL SIZING — read before editing a path or a stroke width.
109
+ Identical 16px boxes do not make icons look the same size; the ink
110
+ inside them has to match too. As drawn, these ranged from 18 to
111
+ 23.3 units of 24, and the gear read ~22% larger than the arrow. So
112
+ a glyph that needed resizing is wrapped in
113
+ <g transform="translate(12 12) scale(k) translate(-12 -12)">
114
+ and its `stroke-width` is DIVIDED by the same k. Consequences:
115
+ - The number in the file is not the number that renders. Every
116
+ glyph here strokes at 1.75 units once its wrapper is applied
117
+ (1.9/... , 1.95/.9, 1.667*1.05, 1.825*.959). Change a stroke
118
+ width and you break that unless you change k with it.
119
+ - #sm-refresh translates by -13, not -12: Feather's rotate-cw is
120
+ drawn a unit right of centre, and this puts it back. It is not
121
+ a typo.
122
+ - #sm-copy and #sm-check are deliberately outside this: they
123
+ stroke at 2.0 in the 14px copy button. That button sits beside
124
+ the 1.75 set only in the collection dialog, next to #sm-open,
125
+ where the smaller box evens out the heavier stroke. -->
126
+ <svg width="0" height="0" style="position:absolute" aria-hidden="true">
127
+ <symbol id="sm-globe" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"></circle><path d="M2 12h20"></path><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></symbol>
128
+ <symbol id="sm-trash" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 6h17"></path><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"></path><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"></path><path d="M10 10.5v7"></path><path d="M14 10.5v7"></path></symbol>
129
+ <symbol id="sm-trash-file" viewBox="0 0 24 24"><g transform="translate(12 12) scale(.9) translate(-12 -12)"><mask id="sm-trash-file-cut" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24"><rect width="24" height="24" fill="#fff"></rect><circle cx="19.6" cy="19.6" r="5.2" fill="#000"></circle></mask><g mask="url(#sm-trash-file-cut)" transform="translate(-.7 -1.5) scale(.9)" fill="none" stroke="currentColor" stroke-width="2.167" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 6h17"></path><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"></path><path d="M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"></path><path d="M10 10.5v7"></path><path d="M14 10.5v7"></path></g><g transform="translate(14.53 14.36) scale(.422)" fill="none" stroke="currentColor" stroke-width="4.611" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5"></path></g></g></symbol>
130
+ <symbol id="sm-copy" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></symbol>
131
+ <symbol id="sm-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></symbol>
132
+ <symbol id="sm-refresh" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.667" stroke-linecap="round" stroke-linejoin="round"><g transform="translate(12 12) scale(1.05) translate(-13 -12)"><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path><polyline points="23 4 23 10 17 10"></polyline></g></symbol>
133
+ <symbol id="sm-swap" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7.5h18"></path><path d="M16.5 3l4.5 4.5-4.5 4.5"></path><path d="M21 16.5H3"></path><path d="M7.5 12L3 16.5 7.5 21"></path></symbol>
134
+ <symbol id="sm-gear" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.825" stroke-linecap="round" stroke-linejoin="round"><g transform="translate(12 12) scale(.959) translate(-12 -12)"><circle cx="12" cy="12" r="3.1"></circle><path d="M19.4 14.6a1.6 1.6 0 0 0 .32 1.77l.06.06a1.95 1.95 0 1 1-2.76 2.76l-.06-.06a1.6 1.6 0 0 0-1.77-.32 1.6 1.6 0 0 0-.97 1.47V21a1.95 1.95 0 1 1-3.9 0v-.1a1.6 1.6 0 0 0-1.05-1.47 1.6 1.6 0 0 0-1.77.32l-.06.06a1.95 1.95 0 1 1-2.76-2.76l.06-.06a1.6 1.6 0 0 0 .32-1.77 1.6 1.6 0 0 0-1.47-.97H3a1.95 1.95 0 1 1 0-3.9h.1a1.6 1.6 0 0 0 1.47-1.05 1.6 1.6 0 0 0-.32-1.77l-.06-.06a1.95 1.95 0 1 1 2.76-2.76l.06.06a1.6 1.6 0 0 0 1.77.32H9a1.6 1.6 0 0 0 .97-1.47V3a1.95 1.95 0 1 1 3.9 0v.1a1.6 1.6 0 0 0 .97 1.47 1.6 1.6 0 0 0 1.77-.32l.06-.06a1.95 1.95 0 1 1 2.76 2.76l-.06.06a1.6 1.6 0 0 0-.32 1.77V9a1.6 1.6 0 0 0 1.47.97H21a1.95 1.95 0 1 1 0 3.9h-.1a1.6 1.6 0 0 0-1.47.97z"></path></g></symbol>
135
+ <symbol id="sm-open" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><path d="M10 14L21 3"></path></symbol>
136
+ </svg>
137
+ <header class="page-header">
138
+ <div class="page-header-inner">
139
+ <a class="page-home page-icon-link" href="../collections.html" target="_blank"
140
+ rel="noopener" tabindex="-1" aria-hidden="true">
141
+ <img class="page-icon" src="../icons/icon-48.png" alt="" />
142
+ </a>
143
+ <h1><a class="page-home brand" href="../collections.html" target="_blank" rel="noopener"
144
+ title="Open the collections page">SourceMonkey</a><span class="brand"> |</span> Debug <span class="brand">|</span> Storage</h1>
145
+ </div>
146
+ </header>
147
+
148
+ <div class="page-body">
149
+ <div class="toolbar">
150
+ <div class="views" role="group" aria-label="View">
151
+ <button type="button" data-view="script" aria-pressed="true">By script</button>
152
+ <button type="button" data-view="file" aria-pressed="false">By file</button>
153
+ <button type="button" data-view="values" aria-pressed="false">Stored values</button>
154
+ </div>
155
+ <p id="storage-summary" class="summary"></p>
156
+ </div>
157
+ <div id="storage-empty" class="empty-state" hidden></div>
158
+ <table id="storage-table" class="storage-table" hidden></table>
159
+ </div>
160
+
161
+ <script src="../extension/debug/storage.js" type="module"></script>
162
+ </body>
163
+ </html>
@@ -0,0 +1,75 @@
1
+ // Debug-only console logging gate.
2
+ //
3
+ // Several lifecycle messages (per-navigation match list, per-refresh
4
+ // "update check" / "no change") are useful when diagnosing matcher or
5
+ // updater behavior but far too noisy for normal use — they fire on
6
+ // every click. They're off by default and gated through `dlog` /
7
+ // `dwarn`. Flip on by setting `chrome.storage.local`'s
8
+ // `smDebugLogging` key to `true` (e.g. from the SW DevTools console:
9
+ // `chrome.storage.local.set({ smDebugLogging: true })`).
10
+ export const DEBUG_LOGGING_KEY = 'smDebugLogging';
11
+ let enabled = false;
12
+ export function isDebugLoggingEnabled() {
13
+ return enabled;
14
+ }
15
+ // Test/debug hook. Production callers should toggle the storage key
16
+ // instead so the change persists and is observed via onChanged.
17
+ export function _setDebugLoggingForTests(value) {
18
+ enabled = value;
19
+ }
20
+ // Settles once the setting has been read in this context.
21
+ let loading = null;
22
+ let loaded = false;
23
+ export function loadDebugLoggingFlag() {
24
+ loading = (async () => {
25
+ try {
26
+ const got = await chrome.storage.local.get(DEBUG_LOGGING_KEY);
27
+ enabled = got[DEBUG_LOGGING_KEY] === true;
28
+ }
29
+ catch {
30
+ enabled = false;
31
+ }
32
+ loaded = true;
33
+ })();
34
+ return loading;
35
+ }
36
+ // Whether the setting is still being read: a line about work done before
37
+ // then can wait for `debugLoggingSettled` rather than be dropped.
38
+ export function debugLoggingPending() {
39
+ return loading !== null && !loaded;
40
+ }
41
+ // Whether debug logging is on, once the setting has been read (at once
42
+ // in a context that never reads it).
43
+ export async function debugLoggingSettled() {
44
+ await loading;
45
+ return enabled;
46
+ }
47
+ // Idempotent, matching `match-index.ts`'s storage listener. Several
48
+ // contexts install this (the worker and the extension pages), and a
49
+ // context that called twice would double every flag update.
50
+ let listenerInstalled = false;
51
+ export function installDebugLoggingListener() {
52
+ if (listenerInstalled)
53
+ return;
54
+ listenerInstalled = true;
55
+ chrome.storage.onChanged.addListener((changes, areaName) => {
56
+ if (areaName !== 'local')
57
+ return;
58
+ const change = changes[DEBUG_LOGGING_KEY];
59
+ if (!change)
60
+ return;
61
+ enabled = change.newValue === true;
62
+ });
63
+ }
64
+ export function dlog(...args) {
65
+ if (enabled)
66
+ console.log(...args);
67
+ }
68
+ export function dwarn(...args) {
69
+ // console.info (not console.warn / .error) — see background.ts sm:error
70
+ // handler for the rationale: Chrome surfaces SW warn+error into the
71
+ // chrome://extensions/?errors panel, which should be reserved for
72
+ // actual extension bugs, not SourceMonkey's own diagnostic chatter.
73
+ if (enabled)
74
+ console.info(...args);
75
+ }
@@ -0,0 +1,64 @@
1
+ // Where a diagnostic came from, and the one way to say it.
2
+ //
3
+ // SourceMonkey judges a script from its content in several places — the
4
+ // metadata-block split, header validation, `@require` / `@resource`
5
+ // resolution, the install-time parse check — and every one of those
6
+ // verdicts is *about* a specific line of a specific file. This module
7
+ // is the shared vocabulary for that: a location shape the producers
8
+ // attach, and a label the surfaces render.
9
+ //
10
+ // Deliberately tiny and dependency-free. It is imported by the service
11
+ // worker, by extension pages, and by the wire protocol module, so it
12
+ // must stay cheap enough that none of them think twice about it.
13
+ // The human-readable "where", without the surrounding phrasing —
14
+ // e.g. `my.user.js, line 12, column 5`.
15
+ //
16
+ // Split out from `describeDiagnostic` on purpose: it is the part a UI
17
+ // turns into a link, so having it as its own function keeps the linked
18
+ // text and the plain-text rendering from drifting into two spellings of
19
+ // the same place.
20
+ export function locationLabel(location) {
21
+ let label = location.file;
22
+ // Column without line is meaningless, so it is only ever appended
23
+ // inside the line branch.
24
+ if (location.line !== undefined) {
25
+ label += `, line ${location.line}`;
26
+ if (location.column !== undefined)
27
+ label += `, column ${location.column}`;
28
+ }
29
+ return label;
30
+ }
31
+ // `<message> (in <where>)`, or just the message when there's nowhere to
32
+ // point. The single phrasing shared by the store's `invalid` message,
33
+ // the install preview's warning, the collections page's hover text and the
34
+ // Log — so the same verdict can never read two different ways.
35
+ export function describeDiagnostic(message, location) {
36
+ if (!location)
37
+ return message;
38
+ return `${message} (in ${locationLabel(location)})`;
39
+ }
40
+ // A location is only useful if it names a file, and a line of 0 or less
41
+ // is not a line. Producers build these from parsed source and from data
42
+ // that crossed a `postMessage` boundary, and consumers turn them into
43
+ // clickable jumps, so the shape is checked once here rather than at
44
+ // each of those.
45
+ export function validLocation(location) {
46
+ if (!location || typeof location.file !== 'string' || !location.file)
47
+ return undefined;
48
+ const line = positiveInt(location.line);
49
+ if (location.line !== undefined && line === undefined)
50
+ return undefined;
51
+ const column = positiveInt(location.column);
52
+ const out = { file: location.file };
53
+ if (line !== undefined)
54
+ out.line = line;
55
+ // A bad column is dropped rather than failing the whole location: the
56
+ // line is the part that gets the reader to the right place, and the
57
+ // column is an accent on top of it.
58
+ if (line !== undefined && column !== undefined)
59
+ out.column = column;
60
+ return out;
61
+ }
62
+ function positiveInt(n) {
63
+ return typeof n === 'number' && Number.isInteger(n) && n > 0 ? n : undefined;
64
+ }