@magland/mochi 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +108 -0
  3. package/dist/ansi.js +174 -0
  4. package/dist/api/admin.js +416 -0
  5. package/dist/api/auth.js +166 -0
  6. package/dist/api/backup.js +598 -0
  7. package/dist/api/ci.js +336 -0
  8. package/dist/api/contents.js +339 -0
  9. package/dist/api/issues.js +165 -0
  10. package/dist/api/pulls.js +244 -0
  11. package/dist/api/releases.js +83 -0
  12. package/dist/api/repos.js +156 -0
  13. package/dist/api/write.js +518 -0
  14. package/dist/api.js +326 -0
  15. package/dist/assets.js +29 -0
  16. package/dist/atom.js +32 -0
  17. package/dist/atomic.js +171 -0
  18. package/dist/avatar.js +81 -0
  19. package/dist/browse.js +630 -0
  20. package/dist/build-info.json +4 -0
  21. package/dist/ci/actionref.js +86 -0
  22. package/dist/ci/api.js +829 -0
  23. package/dist/ci/artifacts.js +201 -0
  24. package/dist/ci/dispatch.js +30 -0
  25. package/dist/ci/engine.js +1321 -0
  26. package/dist/ci/expr.js +526 -0
  27. package/dist/ci/manual.js +199 -0
  28. package/dist/ci/present.js +82 -0
  29. package/dist/ci/protocol.js +6 -0
  30. package/dist/ci/runners.js +256 -0
  31. package/dist/ci/runs.js +208 -0
  32. package/dist/ci/trigger.js +28 -0
  33. package/dist/ci/views.js +441 -0
  34. package/dist/ci/wake.js +194 -0
  35. package/dist/ci/web.js +617 -0
  36. package/dist/ci/workflow.js +436 -0
  37. package/dist/cli/admin-cmd.js +324 -0
  38. package/dist/cli/api-cmd.js +128 -0
  39. package/dist/cli/backup-cmd.js +1500 -0
  40. package/dist/cli/exit.js +69 -0
  41. package/dist/cli/input.js +64 -0
  42. package/dist/cli/issue-cmd.js +243 -0
  43. package/dist/cli/output.js +93 -0
  44. package/dist/cli/parse.js +317 -0
  45. package/dist/cli/pr-cmd.js +289 -0
  46. package/dist/cli/release-cmd.js +171 -0
  47. package/dist/cli/repo-cmd.js +763 -0
  48. package/dist/cli/repo.js +101 -0
  49. package/dist/cli/run-cmd.js +438 -0
  50. package/dist/cli/target.js +54 -0
  51. package/dist/cli-api.js +84 -0
  52. package/dist/compare.js +111 -0
  53. package/dist/config.js +212 -0
  54. package/dist/credentials.js +235 -0
  55. package/dist/deploy-cli.js +859 -0
  56. package/dist/deploy-runner-cli.js +592 -0
  57. package/dist/diff.js +171 -0
  58. package/dist/discussion.js +253 -0
  59. package/dist/egress.js +559 -0
  60. package/dist/filecache.js +68 -0
  61. package/dist/find.js +162 -0
  62. package/dist/forms.js +737 -0
  63. package/dist/git.js +547 -0
  64. package/dist/githttp.js +428 -0
  65. package/dist/html.js +87 -0
  66. package/dist/icons.js +101 -0
  67. package/dist/import-cli.js +316 -0
  68. package/dist/index.js +752 -0
  69. package/dist/issues.js +308 -0
  70. package/dist/issueweb.js +447 -0
  71. package/dist/job-cli.js +197 -0
  72. package/dist/jobtoken.js +96 -0
  73. package/dist/languages.js +383 -0
  74. package/dist/layout.js +100 -0
  75. package/dist/lfs.js +438 -0
  76. package/dist/lfsstore.js +425 -0
  77. package/dist/limit.js +259 -0
  78. package/dist/logo.js +61 -0
  79. package/dist/markdown.js +382 -0
  80. package/dist/migrate.js +334 -0
  81. package/dist/multipart.js +90 -0
  82. package/dist/ops.js +869 -0
  83. package/dist/pagescript.js +465 -0
  84. package/dist/perms.js +370 -0
  85. package/dist/pointer.js +55 -0
  86. package/dist/profile.js +106 -0
  87. package/dist/pulls.js +320 -0
  88. package/dist/pullweb.js +461 -0
  89. package/dist/redirects.js +455 -0
  90. package/dist/releases.js +435 -0
  91. package/dist/render.js +233 -0
  92. package/dist/runner/actions.js +448 -0
  93. package/dist/runner/client.js +428 -0
  94. package/dist/runner/context.js +247 -0
  95. package/dist/runner/docker.js +197 -0
  96. package/dist/runner/externals.js +175 -0
  97. package/dist/runner/job.js +290 -0
  98. package/dist/runner/manual-run.js +272 -0
  99. package/dist/runner/overrides.js +554 -0
  100. package/dist/runner/steps.js +571 -0
  101. package/dist/runner/wake.js +84 -0
  102. package/dist/runner-cli.js +405 -0
  103. package/dist/scan.js +231 -0
  104. package/dist/server.js +424 -0
  105. package/dist/session.js +267 -0
  106. package/dist/site.js +259 -0
  107. package/dist/siteshost.js +94 -0
  108. package/dist/source.js +90 -0
  109. package/dist/style.js +1295 -0
  110. package/dist/themes.js +369 -0
  111. package/dist/vault.js +442 -0
  112. package/dist/version.js +88 -0
  113. package/dist/views.js +1007 -0
  114. package/dist/web.js +182 -0
  115. package/dist/webops.js +1402 -0
  116. package/package.json +71 -0
package/dist/themes.js ADDED
@@ -0,0 +1,369 @@
1
+ "use strict";
2
+ // The theme collection. A theme is a set of semantic color (and typography)
3
+ // tokens emitted as CSS custom properties, plus the highlight.js stylesheet
4
+ // whose token colors suit it. The structural CSS in style.ts never names a
5
+ // color directly, so adding a theme means adding an entry here and nothing
6
+ // else.
7
+ //
8
+ // A theme is a property of the vault, not of the visitor: one vault is one
9
+ // interface, and the operator chooses how it looks. See config.ts for storage.
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.DARK_COUNTERPART = exports.DEFAULT_THEME = exports.THEMES = void 0;
12
+ exports.findTheme = findTheme;
13
+ exports.resolveTheme = resolveTheme;
14
+ exports.themeNames = themeNames;
15
+ exports.setActiveTheme = setActiveTheme;
16
+ exports.activeTheme = activeTheme;
17
+ exports.themeVarsCss = themeVarsCss;
18
+ exports.allThemeVarsCss = allThemeVarsCss;
19
+ exports.darkFor = darkFor;
20
+ const SANS = '-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif';
21
+ const MONO = 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace';
22
+ const SERIF = 'ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif';
23
+ // Terminal colours tuned for each ground: dark-enough hues for a light page,
24
+ // bright-enough ones for a dark page. Primer's ANSI sets, which are the ones
25
+ // GitHub renders its own logs with.
26
+ // The blue is VS Code's light-terminal blue rather than Primer's #0969da,
27
+ // which is the GitHub theme's accent: the smoke suite (rightly) checks that
28
+ // one theme's signature colours do not leak into another's root block.
29
+ const ANSI_LIGHT = {
30
+ ansiBlack: '#57606a',
31
+ ansiRed: '#cf222e',
32
+ ansiGreen: '#116329',
33
+ ansiYellow: '#9a6700',
34
+ ansiBlue: '#0451a5',
35
+ ansiMagenta: '#8250df',
36
+ ansiCyan: '#1b7c83',
37
+ ansiWhite: '#6e7781',
38
+ ansiBrightBlack: '#8c959f',
39
+ ansiBrightRed: '#a40e26',
40
+ ansiBrightGreen: '#1a7f37',
41
+ ansiBrightYellow: '#b08800',
42
+ ansiBrightBlue: '#218bff',
43
+ ansiBrightMagenta: '#a475f9',
44
+ ansiBrightCyan: '#3192aa',
45
+ ansiBrightWhite: '#8c959f',
46
+ };
47
+ const ANSI_DARK = {
48
+ ansiBlack: '#6e7681',
49
+ ansiRed: '#ff7b72',
50
+ ansiGreen: '#3fb950',
51
+ ansiYellow: '#d29922',
52
+ ansiBlue: '#58a6ff',
53
+ ansiMagenta: '#bc8cff',
54
+ ansiCyan: '#39c5cf',
55
+ ansiWhite: '#b1bac4',
56
+ ansiBrightBlack: '#8c959f',
57
+ ansiBrightRed: '#ffa198',
58
+ ansiBrightGreen: '#56d364',
59
+ ansiBrightYellow: '#e3b341',
60
+ ansiBrightBlue: '#79c0ff',
61
+ ansiBrightMagenta: '#d2a8ff',
62
+ ansiBrightCyan: '#56d4dd',
63
+ ansiBrightWhite: '#d0d7de',
64
+ };
65
+ exports.THEMES = [
66
+ {
67
+ name: 'paper',
68
+ label: 'Paper',
69
+ blurb: 'Warm off-white with teal links and serif headings. The default.',
70
+ dark: false,
71
+ hljs: 'rose-pine-dawn',
72
+ vars: {
73
+ ...ANSI_LIGHT,
74
+ bg: '#fbf9f5',
75
+ fg: '#2b2621',
76
+ fgMuted: '#6c6157',
77
+ fgSubtle: '#8a7f73',
78
+ surface: '#f3ede4',
79
+ surfaceHover: '#eae2d6',
80
+ border: '#ddd3c4',
81
+ borderSoft: '#e7dfd2',
82
+ accent: '#0f6466',
83
+ accentSoft: '#3f9295',
84
+ focus: '#0f646633',
85
+ tabMarker: '#c96442',
86
+ chipBg: 'rgba(140,127,110,0.18)',
87
+ primary: '#2f7d5d',
88
+ primaryHover: '#276b4f',
89
+ onPrimary: '#ffffff',
90
+ danger: '#b3261e',
91
+ dangerHover: '#961c16',
92
+ onDanger: '#ffffff',
93
+ alertTip: '#2f7d5d',
94
+ alertImportant: '#7a4fa3',
95
+ alertWarning: '#b5730f',
96
+ diffAdd: '#e4f2e6',
97
+ diffDel: '#fbe6e2',
98
+ diffHunk: '#e2eef0',
99
+ diffMeta: '#f5f0e8',
100
+ okBg: '#e4f2e6',
101
+ okBorder: '#2f7d5d55',
102
+ errBg: '#fbe6e2',
103
+ errBorder: '#b3261e55',
104
+ shadow: 'rgba(43,38,33,0.16)',
105
+ overlay: 'rgba(43,38,33,0.32)',
106
+ lineMark: '#f6ecd0',
107
+ codeBg: '#fffdf9',
108
+ inputBg: '#fffdf9',
109
+ inlineCodeBg: 'rgba(140,127,110,0.18)',
110
+ radius: '8px',
111
+ fontUi: SANS,
112
+ fontHead: SERIF,
113
+ fontMono: MONO,
114
+ },
115
+ },
116
+ {
117
+ name: 'github',
118
+ label: 'GitHub',
119
+ blurb: 'The familiar light gray and blue, for people who want no surprises.',
120
+ dark: false,
121
+ hljs: 'github',
122
+ vars: {
123
+ ...ANSI_LIGHT,
124
+ bg: '#ffffff',
125
+ fg: '#1f2328',
126
+ fgMuted: '#57606a',
127
+ fgSubtle: '#6e7781',
128
+ surface: '#f6f8fa',
129
+ surfaceHover: '#eef1f4',
130
+ border: '#d0d7de',
131
+ borderSoft: '#d8dee4',
132
+ accent: '#0969da',
133
+ accentSoft: '#54aeff',
134
+ focus: '#0969da33',
135
+ tabMarker: '#fd8c73',
136
+ chipBg: 'rgba(175,184,193,0.2)',
137
+ primary: '#1f883d',
138
+ primaryHover: '#1a7f37',
139
+ onPrimary: '#ffffff',
140
+ danger: '#cf222e',
141
+ dangerHover: '#a40e26',
142
+ onDanger: '#ffffff',
143
+ alertTip: '#1a7f37',
144
+ alertImportant: '#8250df',
145
+ alertWarning: '#9a6700',
146
+ diffAdd: '#e6ffec',
147
+ diffDel: '#ffebe9',
148
+ diffHunk: '#ddf4ff',
149
+ diffMeta: '#fafbfc',
150
+ okBg: '#dafbe1',
151
+ okBorder: '#1f883d55',
152
+ errBg: '#ffebe9',
153
+ errBorder: '#cf222e55',
154
+ shadow: 'rgba(31,35,40,0.15)',
155
+ overlay: 'rgba(31,35,40,0.32)',
156
+ lineMark: '#fff8c5',
157
+ codeBg: '#ffffff',
158
+ inputBg: '#ffffff',
159
+ inlineCodeBg: 'rgba(175,184,193,0.2)',
160
+ radius: '6px',
161
+ fontUi: SANS,
162
+ fontHead: SANS,
163
+ fontMono: MONO,
164
+ },
165
+ },
166
+ {
167
+ name: 'slate',
168
+ label: 'Slate',
169
+ blurb: 'Cool gray surfaces with an indigo accent.',
170
+ dark: false,
171
+ hljs: 'atom-one-light',
172
+ vars: {
173
+ ...ANSI_LIGHT,
174
+ bg: '#ffffff',
175
+ fg: '#1c1e2b',
176
+ fgMuted: '#5a5f72',
177
+ fgSubtle: '#767c8f',
178
+ surface: '#f4f5f9',
179
+ surfaceHover: '#e9ebf3',
180
+ border: '#d5d8e3',
181
+ borderSoft: '#e0e3ec',
182
+ accent: '#4b46b8',
183
+ accentSoft: '#8b86e8',
184
+ focus: '#4b46b833',
185
+ tabMarker: '#7c5cff',
186
+ chipBg: 'rgba(120,126,150,0.18)',
187
+ primary: '#4b46b8',
188
+ primaryHover: '#3e3a9c',
189
+ onPrimary: '#ffffff',
190
+ danger: '#c02a3f',
191
+ dangerHover: '#a11f32',
192
+ onDanger: '#ffffff',
193
+ alertTip: '#2f8a5a',
194
+ alertImportant: '#7c5cff',
195
+ alertWarning: '#a56b0a',
196
+ diffAdd: '#e8f5ec',
197
+ diffDel: '#fdeaed',
198
+ diffHunk: '#ebeafb',
199
+ diffMeta: '#f7f8fb',
200
+ okBg: '#e8f5ec',
201
+ okBorder: '#2f8a5a55',
202
+ errBg: '#fdeaed',
203
+ errBorder: '#c02a3f55',
204
+ shadow: 'rgba(28,30,43,0.16)',
205
+ overlay: 'rgba(28,30,43,0.34)',
206
+ lineMark: '#eeecfb',
207
+ codeBg: '#ffffff',
208
+ inputBg: '#ffffff',
209
+ inlineCodeBg: 'rgba(120,126,150,0.16)',
210
+ radius: '6px',
211
+ fontUi: SANS,
212
+ fontHead: SANS,
213
+ fontMono: MONO,
214
+ },
215
+ },
216
+ {
217
+ name: 'midnight',
218
+ label: 'Midnight',
219
+ blurb: 'A dark theme with azure links, for low light.',
220
+ dark: true,
221
+ hljs: 'github-dark',
222
+ vars: {
223
+ ...ANSI_DARK,
224
+ bg: '#0f1319',
225
+ fg: '#e6edf3',
226
+ fgMuted: '#9198a1',
227
+ fgSubtle: '#7d848d',
228
+ surface: '#171d26',
229
+ surfaceHover: '#1f2731',
230
+ border: '#2b333f',
231
+ borderSoft: '#232b35',
232
+ accent: '#58a6ff',
233
+ accentSoft: '#4b8fd6',
234
+ focus: '#58a6ff44',
235
+ tabMarker: '#f78166',
236
+ chipBg: 'rgba(110,118,129,0.4)',
237
+ primary: '#238636',
238
+ primaryHover: '#2ea043',
239
+ onPrimary: '#ffffff',
240
+ danger: '#da3633',
241
+ dangerHover: '#f85149',
242
+ onDanger: '#ffffff',
243
+ alertTip: '#3fb950',
244
+ alertImportant: '#a371f7',
245
+ alertWarning: '#d29922',
246
+ diffAdd: '#12261c',
247
+ diffDel: '#2d1417',
248
+ diffHunk: '#0d2740',
249
+ diffMeta: '#171d26',
250
+ okBg: '#12261c',
251
+ okBorder: '#2ea04366',
252
+ errBg: '#2d1417',
253
+ errBorder: '#f8514966',
254
+ shadow: 'rgba(1,4,9,0.85)',
255
+ overlay: 'rgba(1,4,9,0.66)',
256
+ lineMark: '#2b2512',
257
+ codeBg: '#0d1117',
258
+ inputBg: '#0d1117',
259
+ inlineCodeBg: 'rgba(110,118,129,0.4)',
260
+ radius: '6px',
261
+ fontUi: SANS,
262
+ fontHead: SANS,
263
+ fontMono: MONO,
264
+ },
265
+ },
266
+ {
267
+ name: 'terminal',
268
+ label: 'Terminal',
269
+ blurb: 'Near-black, phosphor green, monospace throughout.',
270
+ dark: true,
271
+ hljs: 'monokai',
272
+ vars: {
273
+ ...ANSI_DARK,
274
+ bg: '#08090b',
275
+ fg: '#d5ded7',
276
+ fgMuted: '#7f8c84',
277
+ fgSubtle: '#6b776f',
278
+ surface: '#101315',
279
+ surfaceHover: '#171b1e',
280
+ border: '#242a2d',
281
+ borderSoft: '#1c2124',
282
+ accent: '#4ade80',
283
+ accentSoft: '#3fae67',
284
+ focus: '#4ade8044',
285
+ tabMarker: '#4ade80',
286
+ chipBg: 'rgba(120,140,128,0.28)',
287
+ primary: '#166534',
288
+ primaryHover: '#1a7a3f',
289
+ onPrimary: '#eafff1',
290
+ danger: '#b91c1c',
291
+ dangerHover: '#dc2626',
292
+ onDanger: '#ffffff',
293
+ alertTip: '#4ade80',
294
+ alertImportant: '#c084fc',
295
+ alertWarning: '#facc15',
296
+ diffAdd: '#0c2415',
297
+ diffDel: '#2a1113',
298
+ diffHunk: '#0b2027',
299
+ diffMeta: '#101315',
300
+ okBg: '#0c2415',
301
+ okBorder: '#4ade8055',
302
+ errBg: '#2a1113',
303
+ errBorder: '#dc262655',
304
+ shadow: 'rgba(0,0,0,0.8)',
305
+ overlay: 'rgba(0,0,0,0.7)',
306
+ lineMark: '#13251a',
307
+ codeBg: '#0a0c0e',
308
+ inputBg: '#0a0c0e',
309
+ inlineCodeBg: 'rgba(120,140,128,0.24)',
310
+ radius: '3px',
311
+ fontUi: MONO,
312
+ fontHead: MONO,
313
+ fontMono: MONO,
314
+ },
315
+ },
316
+ ];
317
+ exports.DEFAULT_THEME = 'paper';
318
+ function findTheme(name) {
319
+ if (!name)
320
+ return null;
321
+ return exports.THEMES.find((t) => t.name === name) ?? null;
322
+ }
323
+ function resolveTheme(name) {
324
+ return findTheme(name) ?? findTheme(exports.DEFAULT_THEME);
325
+ }
326
+ function themeNames() {
327
+ return exports.THEMES.map((t) => t.name);
328
+ }
329
+ // One process serves one vault, and the theme is a property of the vault, so
330
+ // the active theme is process state rather than something threaded through
331
+ // every view. A middleware re-syncs it from config.json on each request, so
332
+ // hand-edits take effect without a restart.
333
+ let active = resolveTheme(exports.DEFAULT_THEME);
334
+ function setActiveTheme(name) {
335
+ active = resolveTheme(name);
336
+ }
337
+ function activeTheme() {
338
+ return active;
339
+ }
340
+ function kebab(s) {
341
+ return s.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
342
+ }
343
+ function themeVarsCss(theme, selector = ':root') {
344
+ const decls = Object.entries(theme.vars)
345
+ .map(([k, v]) => ` --${kebab(k)}: ${v};`)
346
+ .join('\n');
347
+ return `${selector} {\n color-scheme: ${theme.dark ? 'dark' : 'light'};\n${decls}\n}\n`;
348
+ }
349
+ /**
350
+ * Every theme's tokens in one stylesheet: the vault's own under :root, and all
351
+ * of them again under the attribute the page carries. The stylesheet is the
352
+ * same for every visitor and so stays cacheable, and a reader who has chosen a
353
+ * different appearance gets it by one attribute on <html> rather than by a
354
+ * request of their own. The cost is the four sets of tokens nobody is using,
355
+ * which is about four kilobytes.
356
+ */
357
+ function allThemeVarsCss(vault) {
358
+ return (themeVarsCss(vault) +
359
+ exports.THEMES.map((t) => themeVarsCss(t, `[data-theme="${t.name}"]`)).join(''));
360
+ }
361
+ /**
362
+ * The dark theme a light vault falls back to when the reader's system asks for
363
+ * dark and they have expressed no preference of their own. A vault whose theme
364
+ * is already dark keeps it: the operator has answered the question.
365
+ */
366
+ exports.DARK_COUNTERPART = 'midnight';
367
+ function darkFor(vault) {
368
+ return vault.dark ? vault.name : exports.DARK_COUNTERPART;
369
+ }