@monster-orange/den-ui 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +515 -1
- package/bin/den-ui-parity.mjs +440 -0
- package/inventory/fonts-dir.cjs +8 -0
- package/inventory/fonts-dir.mjs +10 -0
- package/inventory/nav-inventory.d.ts +133 -0
- package/inventory/nav-inventory.js +839 -0
- package/inventory/reference/den-chromium-1280.json +5388 -0
- package/inventory/reference/den-chromium-390.json +3834 -0
- package/inventory/reference/den-webkit-1280.json +5388 -0
- package/inventory/reference/den-webkit-390.json +3834 -0
- package/package.json +40 -3
- package/src/busy-words.d.ts +2 -0
- package/src/busy-words.js +6 -0
- package/src/busy.css +155 -0
- package/src/busy.d.ts +80 -0
- package/src/busy.js +105 -35
- package/src/dialog.css +103 -0
- package/src/dialog.d.ts +44 -0
- package/src/dialog.js +95 -30
- package/src/icons.d.ts +4 -0
- package/src/icons.js +43 -0
- package/src/kit.d.ts +217 -0
- package/src/kit.js +299 -0
- package/src/marks/den.svg +6 -0
- package/src/report-shot.d.ts +47 -0
- package/src/report-shot.js +437 -0
- package/src/report.css +387 -0
- package/src/report.d.ts +61 -0
- package/src/report.js +909 -0
- package/src/shell-client.d.ts +149 -0
- package/src/shell-client.js +820 -0
- package/src/shell-html.d.ts +305 -0
- package/src/shell-html.js +903 -0
- package/src/shell.css +1010 -0
- package/src/strings.d.ts +18 -0
- package/src/strings.js +565 -0
- package/src/time.d.ts +18 -0
- package/src/time.js +14 -2
- package/src/tokens.css +81 -67
- package/src/update-pill.d.ts +17 -0
- package/src/version.d.ts +7 -0
- package/src/version.js +31 -0
- package/src/whatsnew.css +235 -0
- package/src/whatsnew.d.ts +36 -0
- package/src/whatsnew.js +411 -0
package/src/kit.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* den-ui in the page: one entry for the kit's components, also set as
|
|
3
|
+
* window.DenUI. Every call to the product's server goes through the
|
|
4
|
+
* adapter the product gives; the kit names no URL of its own.
|
|
5
|
+
*
|
|
6
|
+
* import DenUI from "/kit/kit.js"; // or window.DenUI after it loads
|
|
7
|
+
* DenUI.configure({
|
|
8
|
+
* lang: "en", // or () => lang
|
|
9
|
+
* product: { name: "Acme" }, // {product} in the kit's words
|
|
10
|
+
* adapter: {
|
|
11
|
+
* changelog: () => Promise<entries>, What's new
|
|
12
|
+
* applyUpdate: () => Promise<unknown>, the update pill's Reload
|
|
13
|
+
* fileReport: (payload) => Promise<{ number, url } | { error }>,
|
|
14
|
+
* request: (id) => Promise<{ state, result?, error? }>, Check again
|
|
15
|
+
* ...the Report form's fuller calls (report.js)
|
|
16
|
+
* },
|
|
17
|
+
* report: { busy, mine, page, screenshot, library }, Report's options
|
|
18
|
+
* reportOff: false, // hides every Report button
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* DenUI.hydrate(root, opts) binds the shell shell-html.js drew (on the
|
|
22
|
+
* server, or by mount); see shell-client.js.
|
|
23
|
+
* The version chip opens What's new; any
|
|
24
|
+
* [data-den-report] and ⌘⇧F open Report.
|
|
25
|
+
* DenUI.mount(root, model) draws shellHtml(model) into root, then
|
|
26
|
+
* hydrates it (a page with no server render)
|
|
27
|
+
* DenUI.shellHtml(model) the markup (shell-html.js)
|
|
28
|
+
* DenUI.scopeHtml, searchHtml, bellButtonHtml, bellPanelHtml,
|
|
29
|
+
* accountHtml (0.7.0) the scope crumbs, the search with ⌘K
|
|
30
|
+
* inside, the bell and its panel, and the
|
|
31
|
+
* rail's account entry; hydrate wires them
|
|
32
|
+
* DenUI.settingsHtml, appearanceButtonHtml, appearanceMenuHtml,
|
|
33
|
+
* waitingHtml (0.7.0) the rail's Settings, ◐ ▾ and its menu
|
|
34
|
+
* (hydrate's opts.appearance: { menu,
|
|
35
|
+
* onPick }), the update-waiting pill
|
|
36
|
+
* (DenUI.version.waiting(o | null))
|
|
37
|
+
* DenUI.version.set(label), .unread(on), .label(running, changelog)
|
|
38
|
+
* DenUI.whatsNew.open(), .close(), .load(), .setEntries(list)
|
|
39
|
+
* DenUI.update.set({ version, message, reloadLabel, dismissLabel,
|
|
40
|
+
* cancelLabel, askFirst?, onDismiss? }), .hide()
|
|
41
|
+
* DenUI.report.open({ prefill, opener }), .button({ inFoot })
|
|
42
|
+
* focus goes back to opener (else the
|
|
43
|
+
* control that opened it) on close
|
|
44
|
+
* DenUI.busy.run(action, run, opts) the working pop-up (busy.js)
|
|
45
|
+
* DenUI.strings(lang, table) the product's own words, or its versions
|
|
46
|
+
* of the kit's; DenUI.t(key, vars)
|
|
47
|
+
*/
|
|
48
|
+
import { addStrings, kitT, setProduct } from "./strings.js";
|
|
49
|
+
import {
|
|
50
|
+
accountHtml,
|
|
51
|
+
accountMenuHtml,
|
|
52
|
+
appearanceButtonHtml,
|
|
53
|
+
appearanceMenuHtml,
|
|
54
|
+
bellButtonHtml,
|
|
55
|
+
bellPanelHtml,
|
|
56
|
+
esc,
|
|
57
|
+
icon,
|
|
58
|
+
navItemHtml,
|
|
59
|
+
railHtml,
|
|
60
|
+
reportButtonHtml,
|
|
61
|
+
reportPrefillOf,
|
|
62
|
+
scopeCrumbHtml,
|
|
63
|
+
scopeHtml,
|
|
64
|
+
searchHtml,
|
|
65
|
+
settingsHtml,
|
|
66
|
+
shellHtml,
|
|
67
|
+
topBarHtml,
|
|
68
|
+
markHtml,
|
|
69
|
+
versionChipHtml,
|
|
70
|
+
waitingHtml,
|
|
71
|
+
} from "./shell-html.js";
|
|
72
|
+
import {
|
|
73
|
+
hydrateAccount,
|
|
74
|
+
attachMenuFilter,
|
|
75
|
+
hydrateAppearance,
|
|
76
|
+
hydrateBell,
|
|
77
|
+
hydrateScope,
|
|
78
|
+
hydrateSearch,
|
|
79
|
+
hydrateShell,
|
|
80
|
+
setWaiting,
|
|
81
|
+
syncPinToggles,
|
|
82
|
+
} from "./shell-client.js";
|
|
83
|
+
import { setUnread, setVersion, versionLabel } from "./version.js";
|
|
84
|
+
import {
|
|
85
|
+
closeWhatsNew,
|
|
86
|
+
configureWhatsNew,
|
|
87
|
+
loadWhatsNew,
|
|
88
|
+
openWhatsNew,
|
|
89
|
+
setEntries,
|
|
90
|
+
} from "./whatsnew.js";
|
|
91
|
+
import { configureReport, openReport } from "./report.js";
|
|
92
|
+
import { showUpdate } from "./update-pill.js";
|
|
93
|
+
import { busyAction, configureBusy } from "./busy.js";
|
|
94
|
+
|
|
95
|
+
const state = {
|
|
96
|
+
lang: "en",
|
|
97
|
+
adapter: {},
|
|
98
|
+
reportOff: false,
|
|
99
|
+
pill: null,
|
|
100
|
+
};
|
|
101
|
+
const lang = () =>
|
|
102
|
+
typeof state.lang === "function" ? state.lang() : state.lang;
|
|
103
|
+
|
|
104
|
+
export function configure(o = {}) {
|
|
105
|
+
if (o.lang !== undefined) state.lang = o.lang;
|
|
106
|
+
if (o.adapter) state.adapter = o.adapter;
|
|
107
|
+
if (o.reportOff !== undefined) state.reportOff = !!o.reportOff;
|
|
108
|
+
if (o.product) setProduct(o.product.name);
|
|
109
|
+
const ad = state.adapter;
|
|
110
|
+
configureWhatsNew({
|
|
111
|
+
lang,
|
|
112
|
+
changelog: ad.changelog || null,
|
|
113
|
+
...(o.whatsNew || {}),
|
|
114
|
+
});
|
|
115
|
+
const r = o.report || {};
|
|
116
|
+
configureReport({ lang, adapter: ad, ...r });
|
|
117
|
+
if (ad.request) configureBusy({ request: ad.request });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function t(key, vars) {
|
|
121
|
+
return kitT(lang(), key, vars);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function strings(l, table) {
|
|
125
|
+
addStrings(l, table);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const version = {
|
|
129
|
+
label: versionLabel,
|
|
130
|
+
set: (label) => setVersion(label),
|
|
131
|
+
unread: (on) => setUnread(on),
|
|
132
|
+
/** 0.7.0: the update-waiting pill after the chip; null hides it. */
|
|
133
|
+
waiting: (o) => setWaiting(o),
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const whatsNew = {
|
|
137
|
+
open: openWhatsNew,
|
|
138
|
+
close: closeWhatsNew,
|
|
139
|
+
load: loadWhatsNew,
|
|
140
|
+
setEntries,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const update = {
|
|
144
|
+
/** Shows the pill for a new version (Reload: adapter.applyUpdate()). */
|
|
145
|
+
set(o = {}) {
|
|
146
|
+
update.hide();
|
|
147
|
+
state.pill = showUpdate({
|
|
148
|
+
message: o.message ?? kitT(lang(), "kit.update.msg"),
|
|
149
|
+
reloadLabel: o.reloadLabel ?? kitT(lang(), "kit.update.reload"),
|
|
150
|
+
dismissLabel: o.dismissLabel ?? kitT(lang(), "kit.update.notNow"),
|
|
151
|
+
cancelLabel: o.cancelLabel ?? kitT(lang(), "kit.update.cancel"),
|
|
152
|
+
region: o.region ?? kitT(lang(), "kit.update.region"),
|
|
153
|
+
askFirst: o.askFirst,
|
|
154
|
+
onReload:
|
|
155
|
+
o.onReload ||
|
|
156
|
+
(() =>
|
|
157
|
+
Promise.resolve(state.adapter.applyUpdate?.()).then(() =>
|
|
158
|
+
location.reload(),
|
|
159
|
+
)),
|
|
160
|
+
onDismiss: () => {
|
|
161
|
+
state.pill = null;
|
|
162
|
+
o.onDismiss?.();
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
return state.pill;
|
|
166
|
+
},
|
|
167
|
+
hide() {
|
|
168
|
+
state.pill?.hide();
|
|
169
|
+
state.pill = null;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export const report = {
|
|
174
|
+
open: (opts = {}) =>
|
|
175
|
+
state.reportOff ? Promise.resolve(null) : openReport(opts),
|
|
176
|
+
button: (o = {}) =>
|
|
177
|
+
state.reportOff ? "" : reportButtonHtml({ ...o, lang: lang() }),
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const busy = {
|
|
181
|
+
run: (action, run, opts) => busyAction(action, run, opts),
|
|
182
|
+
configure: configureBusy,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Binds the drawn shell, the chip and Report (see the top), and the 0.7.0
|
|
187
|
+
* pieces it finds: the scope crumbs (opts.scope), the search
|
|
188
|
+
* (opts.search: { onActivate }), the bell (opts.bell: { items, title,
|
|
189
|
+
* empty, onOpen, … }), the account entry (opts.account: { onAction }) and
|
|
190
|
+
* ◐ ▾ (opts.appearance: { menu, onPick }; .appearance on the shell).
|
|
191
|
+
* The shell it returns has .scope, .search and .bell for those found.
|
|
192
|
+
* false for any of them: not wired.
|
|
193
|
+
*/
|
|
194
|
+
export function hydrate(root, opts = {}) {
|
|
195
|
+
const shell = hydrateShell(root, { lang, ...opts });
|
|
196
|
+
if (opts.scope !== false && root.querySelector(".den-scope"))
|
|
197
|
+
shell.scope = hydrateScope(root, opts.scope || {});
|
|
198
|
+
const search = root.querySelector(".den-search");
|
|
199
|
+
if (search && opts.search !== false)
|
|
200
|
+
shell.search = hydrateSearch(search, opts.search || {});
|
|
201
|
+
const bell = root.querySelector(".den-bell");
|
|
202
|
+
if (bell && opts.bell !== false)
|
|
203
|
+
shell.bell = hydrateBell(bell, { lang, ...(opts.bell || {}) });
|
|
204
|
+
if (opts.account !== false) {
|
|
205
|
+
const acct = hydrateAccount(root, { lang, ...(opts.account || {}) });
|
|
206
|
+
if (acct) shell.account = acct;
|
|
207
|
+
}
|
|
208
|
+
const um = root.querySelector(".appearance-btn");
|
|
209
|
+
if (um && opts.appearance)
|
|
210
|
+
shell.appearance = hydrateAppearance(um, { lang, ...opts.appearance });
|
|
211
|
+
const chip = root.querySelector("#version-pill");
|
|
212
|
+
if (chip && opts.versionChip !== false)
|
|
213
|
+
chip.addEventListener("click", () => whatsNew.open());
|
|
214
|
+
if (opts.report !== false) {
|
|
215
|
+
document.addEventListener("click", (e) => {
|
|
216
|
+
const b =
|
|
217
|
+
e.target && e.target.closest
|
|
218
|
+
? e.target.closest("[data-den-report]")
|
|
219
|
+
: null;
|
|
220
|
+
if (!b) return;
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
const prefill = reportPrefillOf(b);
|
|
223
|
+
void report.open(prefill ? { prefill, opener: b } : { opener: b });
|
|
224
|
+
});
|
|
225
|
+
// ⌘⇧F (Ctrl+Shift+F) opens Report from anywhere, over a dialog too.
|
|
226
|
+
document.addEventListener(
|
|
227
|
+
"keydown",
|
|
228
|
+
(e) => {
|
|
229
|
+
if (
|
|
230
|
+
(e.metaKey || e.ctrlKey) &&
|
|
231
|
+
e.shiftKey &&
|
|
232
|
+
!e.altKey &&
|
|
233
|
+
(e.key === "F" || e.key === "f" || e.code === "KeyF") &&
|
|
234
|
+
!state.reportOff
|
|
235
|
+
) {
|
|
236
|
+
e.preventDefault();
|
|
237
|
+
void report.open();
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
true,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return shell;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function mount(root, model = {}) {
|
|
247
|
+
root.innerHTML = shellHtml({
|
|
248
|
+
lang: lang(),
|
|
249
|
+
report: !state.reportOff,
|
|
250
|
+
...model,
|
|
251
|
+
});
|
|
252
|
+
return hydrate(root, model.hydrate || {});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const DenUI = {
|
|
256
|
+
configure,
|
|
257
|
+
hydrate,
|
|
258
|
+
mount,
|
|
259
|
+
shellHtml,
|
|
260
|
+
topBarHtml,
|
|
261
|
+
markHtml,
|
|
262
|
+
railHtml,
|
|
263
|
+
navItemHtml,
|
|
264
|
+
versionChipHtml,
|
|
265
|
+
reportButtonHtml,
|
|
266
|
+
reportPrefillOf,
|
|
267
|
+
scopeHtml,
|
|
268
|
+
scopeCrumbHtml,
|
|
269
|
+
searchHtml,
|
|
270
|
+
bellButtonHtml,
|
|
271
|
+
bellPanelHtml,
|
|
272
|
+
accountHtml,
|
|
273
|
+
accountMenuHtml,
|
|
274
|
+
settingsHtml,
|
|
275
|
+
appearanceButtonHtml,
|
|
276
|
+
appearanceMenuHtml,
|
|
277
|
+
waitingHtml,
|
|
278
|
+
hydrateAppearance,
|
|
279
|
+
setWaiting,
|
|
280
|
+
hydrateScope,
|
|
281
|
+
hydrateSearch,
|
|
282
|
+
hydrateBell,
|
|
283
|
+
hydrateAccount,
|
|
284
|
+
attachMenuFilter,
|
|
285
|
+
syncPinToggles,
|
|
286
|
+
icon,
|
|
287
|
+
esc,
|
|
288
|
+
t,
|
|
289
|
+
strings,
|
|
290
|
+
version,
|
|
291
|
+
whatsNew,
|
|
292
|
+
update,
|
|
293
|
+
report,
|
|
294
|
+
busy,
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
if (typeof window !== "undefined") window.DenUI = DenUI;
|
|
298
|
+
|
|
299
|
+
export default DenUI;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" role="img" aria-label="Den">
|
|
2
|
+
<rect width="32" height="32" rx="7" fill="#3a2e22"/>
|
|
3
|
+
<path d="M5 26.5h22" stroke="#9bbb63" stroke-width="2" stroke-linecap="round"/>
|
|
4
|
+
<path d="M8 26V15a8 8 0 0 1 16 0v11h-4.5V15.5a3.5 3.5 0 0 0-7 0V26z" fill="#f2eee8"/>
|
|
5
|
+
<path d="M13 26v-9.5a3 3 0 0 1 6 0V26z" fill="#c8a46a" opacity="0.9"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** A mask: a rectangle in fractions of the image (0..1). */
|
|
2
|
+
export interface Mask {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function configureShots(o?: { library?: string }): void;
|
|
9
|
+
/** The page as the person sees it, or null (never throws). */
|
|
10
|
+
export declare function capture(o?: {
|
|
11
|
+
seconds?: number;
|
|
12
|
+
skip?: (node: Node) => boolean;
|
|
13
|
+
}): Promise<HTMLCanvasElement | null>;
|
|
14
|
+
export declare function masked(
|
|
15
|
+
canvas: HTMLCanvasElement,
|
|
16
|
+
masks: Mask[],
|
|
17
|
+
): HTMLCanvasElement;
|
|
18
|
+
export declare function rectOf(
|
|
19
|
+
a: { x: number; y: number },
|
|
20
|
+
b: { x: number; y: number },
|
|
21
|
+
): Mask;
|
|
22
|
+
export declare function rectOfPercent(
|
|
23
|
+
x: number,
|
|
24
|
+
y: number,
|
|
25
|
+
w: number,
|
|
26
|
+
h: number,
|
|
27
|
+
): Mask;
|
|
28
|
+
export declare function toBlob(canvas: HTMLCanvasElement): Promise<Blob | null>;
|
|
29
|
+
export declare function saveAndCopy(
|
|
30
|
+
canvas: HTMLCanvasElement,
|
|
31
|
+
name?: string,
|
|
32
|
+
): Promise<{ saved: boolean; copied: boolean }>;
|
|
33
|
+
export declare function canvasOf(
|
|
34
|
+
src: string | Blob,
|
|
35
|
+
): Promise<HTMLCanvasElement | null>;
|
|
36
|
+
export declare function keepShot(
|
|
37
|
+
id: string,
|
|
38
|
+
canvas: HTMLCanvasElement | null,
|
|
39
|
+
masks: Mask[],
|
|
40
|
+
noShot: boolean,
|
|
41
|
+
): Promise<boolean>;
|
|
42
|
+
export declare function loadShot(id: string): Promise<{
|
|
43
|
+
canvas: HTMLCanvasElement | null;
|
|
44
|
+
masks: Mask[];
|
|
45
|
+
noShot: boolean;
|
|
46
|
+
} | null>;
|
|
47
|
+
export declare function dropShot(id: string): Promise<void>;
|