@vinena/knobs 0.5.0 → 0.5.2

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 (75) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +7 -0
  3. package/dist/early.global.js +6 -6
  4. package/dist/{elementsview-6g274ptr.js → elementsview-2z4pkrdz.js} +4 -4
  5. package/dist/{elementsview-pkzp9kc6.js → elementsview-qn8qyksa.js} +4 -4
  6. package/dist/engine/browserdraw.d.ts +24 -2
  7. package/dist/engine/browserkit.d.ts +18 -1
  8. package/dist/engine/browserui.d.ts +162 -22
  9. package/dist/engine/devicon.d.ts +59 -0
  10. package/dist/engine/fit.d.ts +4 -3
  11. package/dist/engine/foldflip.d.ts +40 -0
  12. package/dist/engine/identity.d.ts +7 -4
  13. package/dist/engine/mock.d.ts +16 -0
  14. package/dist/engine/mockdata.d.ts +4 -1
  15. package/dist/engine/mockdraw.d.ts +14 -2
  16. package/dist/engine/pageshot.d.ts +5 -2
  17. package/dist/engine/safaridraw.d.ts +162 -10
  18. package/dist/engine/screen.d.ts +24 -0
  19. package/dist/engine/store.d.ts +2 -1
  20. package/dist/engine/tabicon.d.ts +43 -0
  21. package/dist/engine/toplayer.d.ts +62 -0
  22. package/dist/engine/touchpointer.d.ts +0 -21
  23. package/dist/engine/underbar.d.ts +61 -0
  24. package/dist/{framekit-g96t6nmq.js → framekit-te90cjs0.js} +2325 -1572
  25. package/dist/{framekit-3n7p79ht.js → framekit-w0v516w5.js} +2325 -1572
  26. package/dist/host.d.ts +51 -0
  27. package/dist/{index-64rd634h.js → index-30fc6php.js} +1 -1
  28. package/dist/{index-dvr4x91q.js → index-9re7sv56.js} +20 -8
  29. package/dist/{index-0casarhy.js → index-agwr37gw.js} +1 -1
  30. package/dist/{index-2d6wvs8h.js → index-dan2kpsd.js} +4 -4
  31. package/dist/{index-kzsb9drs.js → index-hv02xka3.js} +20 -8
  32. package/dist/{index-peh33xjv.js → index-pewcdh28.js} +1 -1
  33. package/dist/{index-d0cjxjsm.js → index-r72tz2vn.js} +1 -1
  34. package/dist/{index-33x9hxe3.js → index-sxe5079a.js} +605 -187
  35. package/dist/{index-5d6qzte3.js → index-trx7bxdk.js} +4 -4
  36. package/dist/{index-5baxvd3v.js → index-xjhwp5cj.js} +275 -112
  37. package/dist/index.d.ts +26 -1
  38. package/dist/index.global.js +270 -176
  39. package/dist/index.js +398 -124
  40. package/dist/instance.d.ts +23 -4
  41. package/dist/{react-pdvseef0.js → react-05jh9jv5.js} +1 -1
  42. package/dist/{react-4kbj1t4h.js → react-16spgn0h.js} +1 -1
  43. package/dist/{react-65tgdbs8.js → react-4pvp6amm.js} +1 -1
  44. package/dist/{react-qv0nykcv.js → react-ayg1bgw3.js} +602 -184
  45. package/dist/{react-xxfpfddf.js → react-exjcpxma.js} +1 -1
  46. package/dist/{react-carf84xv.js → react-fm9y8dbn.js} +275 -112
  47. package/dist/{react-mv9y20jy.js → react-sw8d8c94.js} +4 -4
  48. package/dist/{react-71a9ypex.js → react-zy1mmhgz.js} +4 -4
  49. package/dist/react.js +394 -123
  50. package/dist/{storageview-vdkbp6rt.js → storageview-r595qpt9.js} +4 -4
  51. package/dist/{storageview-j9d44f99.js → storageview-s7heg93p.js} +4 -4
  52. package/dist/types.d.ts +7 -0
  53. package/dist/ui/footer.d.ts +9 -2
  54. package/dist/ui/panel.d.ts +16 -2
  55. package/dist/ui/settings.d.ts +17 -1
  56. package/dist/version.d.ts +2 -0
  57. package/package.json +3 -2
  58. package/skills/devknobs/SKILL.md +1 -1
  59. package/dist/elementsview-jnkbhzkj.js +0 -2873
  60. package/dist/elementsview-tf4qzmtw.js +0 -2874
  61. package/dist/engine/endroom.d.ts +0 -21
  62. package/dist/framekit-095qevka.js +0 -8838
  63. package/dist/framekit-q5aad770.js +0 -8839
  64. package/dist/index-hw56t3zy.js +0 -4800
  65. package/dist/index-k015tb6c.js +0 -357
  66. package/dist/index-ke6v7919.js +0 -4801
  67. package/dist/index-qxye1j73.js +0 -528
  68. package/dist/index-z5ytnj01.js +0 -4563
  69. package/dist/index-zvze25nf.js +0 -686
  70. package/dist/react-eygws6cx.js +0 -358
  71. package/dist/react-sq9pkw4k.js +0 -687
  72. package/dist/react-vjm88w4t.js +0 -4564
  73. package/dist/react-znfrjqk8.js +0 -529
  74. package/dist/storageview-sb23henh.js +0 -2729
  75. package/dist/storageview-vf8v8q8j.js +0 -2728
@@ -1,358 +0,0 @@
1
- "use client";
2
- import {
3
- button,
4
- el,
5
- lay,
6
- rowBox,
7
- rowButton
8
- } from "./react-sq9pkw4k.js";
9
- import {
10
- getState,
11
- icon
12
- } from "./react-qv0nykcv.js";
13
- import {
14
- __require,
15
- isDevknobsFrame,
16
- newer,
17
- webStorage
18
- } from "./react-carf84xv.js";
19
-
20
- // src/ui/pane.ts
21
- var PANE_WIDTH = 340;
22
- var listeners = new Set;
23
- var shell = null;
24
- function emit(view) {
25
- for (const listener of [...listeners])
26
- listener(view);
27
- }
28
- function openPane(view) {
29
- shell?.open(view);
30
- }
31
- function closePane() {
32
- shell?.close();
33
- }
34
- function paneView() {
35
- return shell?.view() ?? null;
36
- }
37
- function showPane(id) {
38
- shell?.show(id);
39
- }
40
- function retitlePane(id, title) {
41
- shell?.retitle(id, title);
42
- }
43
- function onPane(listener) {
44
- listeners.add(listener);
45
- return () => {
46
- listeners.delete(listener);
47
- };
48
- }
49
- function viewHead() {
50
- const back = button("main", "");
51
- const actions = el("div", "view-actions");
52
- const { box, label } = rowBox({
53
- main: back,
54
- glyph: icon("chevron-left"),
55
- title: "",
56
- after: [actions]
57
- });
58
- box.className = `${box.className} view-head`;
59
- return { box, back, title: label, actions };
60
- }
61
- function focused() {
62
- let at = document.activeElement;
63
- while (at?.shadowRoot?.activeElement)
64
- at = at.shadowRoot.activeElement;
65
- return at;
66
- }
67
- function showing(node) {
68
- return node.isConnected && node.getClientRects().length > 0;
69
- }
70
- function createPane(context) {
71
- const { root, tips } = context;
72
- const node = el("div", "view pane");
73
- node.setAttribute("role", "group");
74
- const { box: head, back, title, actions } = viewHead();
75
- back.addEventListener("click", leave);
76
- back.addEventListener("pointerenter", () => shown?.point?.(true));
77
- back.addEventListener("pointerleave", () => shown?.point?.(false));
78
- const body = el("div", "view-body");
79
- node.append(head, body);
80
- let shown = null;
81
- let cleanup = null;
82
- let watches = [];
83
- let opener = null;
84
- function holdsFocus() {
85
- const at = root.activeElement;
86
- return at !== null && node.contains(at);
87
- }
88
- function name(text) {
89
- title.textContent = text;
90
- node.setAttribute("aria-label", text);
91
- back.setAttribute("aria-label", `back from ${text}`);
92
- }
93
- function actionButton(action) {
94
- const control = rowButton("view-action", icon(action.icon), action.label);
95
- const { hint, pressed } = action;
96
- const told = hint ? () => [action.label, hint()].filter(Boolean).join(" · ") : action.label;
97
- tips.tooltip(control, told);
98
- control.addEventListener("click", () => action.run());
99
- if (pressed) {
100
- const mark = () => control.setAttribute("aria-pressed", pressed() ? "true" : "false");
101
- mark();
102
- if (action.watch)
103
- watches.push(action.watch(mark));
104
- }
105
- return control;
106
- }
107
- function unmount() {
108
- tips.hide();
109
- const done = cleanup;
110
- cleanup = null;
111
- shown = null;
112
- for (const stop of watches.splice(0))
113
- stop();
114
- done?.();
115
- }
116
- function open(view) {
117
- if (shown?.id === view.id)
118
- return;
119
- if (shown)
120
- unmount();
121
- else
122
- opener = focused();
123
- body.replaceChildren();
124
- body.scrollTop = 0;
125
- shown = view;
126
- lay(node, view.layout);
127
- name(view.title);
128
- actions.replaceChildren(...(view.actions ?? []).map(actionButton));
129
- const made = view.mount(body);
130
- cleanup = typeof made === "function" ? made : null;
131
- context.uncover();
132
- context.openPanel();
133
- context.render();
134
- back.focus({ preventScroll: true });
135
- emit(view.id);
136
- }
137
- function close() {
138
- if (!shown)
139
- return;
140
- const inside = holdsFocus();
141
- unmount();
142
- context.render();
143
- if (!node.classList.contains("leaving"))
144
- body.replaceChildren();
145
- if (inside) {
146
- const to = opener instanceof HTMLElement && showing(opener) ? opener : context.home;
147
- to.focus({ preventScroll: true });
148
- }
149
- opener = null;
150
- emit(null);
151
- }
152
- function leave() {
153
- if (shown?.back)
154
- shown.back();
155
- else
156
- close();
157
- }
158
- const pane = {
159
- node,
160
- open,
161
- close,
162
- drop() {
163
- if (!shown)
164
- return;
165
- unmount();
166
- opener = null;
167
- emit(null);
168
- },
169
- retitle(id, text) {
170
- if (shown?.id === id)
171
- name(text);
172
- },
173
- show(id) {
174
- if (shown?.id !== id)
175
- return;
176
- context.uncover();
177
- context.openPanel();
178
- context.render();
179
- },
180
- view: () => shown?.id ?? null,
181
- focus() {
182
- if (shown)
183
- back.focus({ preventScroll: true });
184
- return shown !== null;
185
- },
186
- escape() {
187
- if (shown && shown.escape?.() !== true)
188
- leave();
189
- },
190
- landed() {
191
- if (!shown)
192
- body.replaceChildren();
193
- },
194
- destroy() {
195
- if (shown) {
196
- unmount();
197
- emit(null);
198
- }
199
- if (shell === pane)
200
- shell = null;
201
- }
202
- };
203
- shell = pane;
204
- return pane;
205
- }
206
-
207
- // src/ui/storageaction.ts
208
- var STORAGE_VIEW = "storage";
209
- function load() {
210
- return import("./storageview-sb23henh.js").then((loaded) => loaded.storageView({
211
- visible: () => getState().panel.open && !document.hidden
212
- }));
213
- }
214
- function createStorageControl(loadView = load) {
215
- let asked = 0;
216
- const isOn = () => paneView() === STORAGE_VIEW;
217
- const close = () => {
218
- asked++;
219
- if (isOn())
220
- closePane();
221
- };
222
- return {
223
- toggle() {
224
- if (isOn()) {
225
- close();
226
- return;
227
- }
228
- const mine = ++asked;
229
- loadView().then((view) => {
230
- if (mine === asked)
231
- openPane(view);
232
- }, () => {});
233
- },
234
- isOn,
235
- close,
236
- subscribe: (listener) => onPane(() => listener()),
237
- destroy() {
238
- close();
239
- }
240
- };
241
- }
242
-
243
- // src/storage/onload.ts
244
- var PRESETS_KEY = "devknobs:storage-presets";
245
- var PRESETS_VERSION = 1;
246
- var DONE = Symbol.for("devknobs.presets");
247
- function fields(value) {
248
- return typeof value === "object" && value !== null && !Array.isArray(value) ? Object.fromEntries(Object.entries(value)) : {};
249
- }
250
- function list(value) {
251
- return Array.isArray(value) ? value.map(fields) : [];
252
- }
253
- function storedPresets() {
254
- try {
255
- const raw = JSON.parse(webStorage("local")?.getItem(PRESETS_KEY) ?? "null");
256
- return newer(raw, PRESETS_VERSION) ? [] : list(fields(raw).presets);
257
- } catch {
258
- return [];
259
- }
260
- }
261
- function cookieText(entry) {
262
- let text = `${String(entry.name)}=${String(entry.value)}`;
263
- text += `; path=${typeof entry.path === "string" ? entry.path : "/"}`;
264
- if (typeof entry.domain === "string")
265
- text += `; domain=${entry.domain}`;
266
- if (typeof entry.maxAge === "number")
267
- text += `; max-age=${entry.maxAge}`;
268
- if (typeof entry.expires === "string")
269
- text += `; expires=${entry.expires}`;
270
- if (typeof entry.sameSite === "string")
271
- text += `; samesite=${entry.sameSite}`;
272
- if (entry.secure === true)
273
- text += "; secure";
274
- return text;
275
- }
276
- function empty(storage) {
277
- const keys = [];
278
- for (let index = 0;index < storage.length; index++) {
279
- const key = storage.key(index);
280
- if (key !== null && key !== "devknobs" && !key.startsWith("devknobs:"))
281
- keys.push(key);
282
- }
283
- for (const key of keys)
284
- storage.removeItem(key);
285
- }
286
- function put(target, preset, clear) {
287
- const failed = [];
288
- for (const kind of ["local", "session"]) {
289
- try {
290
- const storage = kind === "local" ? target.localStorage : target.sessionStorage;
291
- if (clear)
292
- empty(storage);
293
- for (const entry of list(preset[kind])) {
294
- try {
295
- if (typeof entry.name === "string" && typeof entry.value === "string") {
296
- storage.setItem(entry.name, entry.value);
297
- }
298
- } catch {
299
- failed.push(String(entry.name));
300
- }
301
- }
302
- } catch {
303
- failed.push(`${kind}Storage`);
304
- }
305
- }
306
- for (const entry of list(preset.cookies)) {
307
- try {
308
- if (typeof entry.name === "string" && typeof entry.value === "string") {
309
- target.document.cookie = cookieText(entry);
310
- }
311
- } catch {
312
- failed.push(String(entry.name));
313
- }
314
- }
315
- return failed;
316
- }
317
- function applyOnLoad() {
318
- if (typeof window === "undefined")
319
- return 0;
320
- const known = Reflect.get(window, DONE);
321
- if (typeof known === "number")
322
- return known;
323
- let count = 0;
324
- try {
325
- if (!isDevknobsFrame()) {
326
- for (const preset of storedPresets()) {
327
- if (preset.onLoad !== true)
328
- continue;
329
- put(window, preset, preset.clearFirst === true);
330
- count++;
331
- }
332
- }
333
- } catch {}
334
- Reflect.set(window, DONE, count);
335
- return count;
336
- }
337
- function appliedOnLoad() {
338
- if (typeof window === "undefined")
339
- return 0;
340
- const known = Reflect.get(window, DONE);
341
- return typeof known === "number" ? known : 0;
342
- }
343
- function forgetApplied() {
344
- if (typeof window !== "undefined")
345
- Reflect.set(window, DONE, 0);
346
- }
347
- function stopOnLoad() {
348
- try {
349
- const presets = storedPresets();
350
- if (presets.some((preset) => preset.onLoad === true)) {
351
- const off = presets.map((preset) => ({ ...preset, onLoad: false }));
352
- webStorage("local")?.setItem(PRESETS_KEY, JSON.stringify({ v: PRESETS_VERSION, presets: off }));
353
- }
354
- } catch {}
355
- forgetApplied();
356
- }
357
-
358
- export { PRESETS_KEY, PRESETS_VERSION, storedPresets, cookieText, put, applyOnLoad, appliedOnLoad, stopOnLoad, PANE_WIDTH, openPane, closePane, paneView, showPane, retitlePane, onPane, viewHead, createPane, STORAGE_VIEW, createStorageControl };