@kgdiff/viewer 0.4.0 → 0.6.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 +43 -16
- package/custom-elements.json +2347 -0
- package/dist/bind.d.ts +41 -0
- package/dist/bind.d.ts.map +1 -0
- package/dist/bind.js +47 -0
- package/dist/bind.js.map +1 -0
- package/dist/context.d.ts +42 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +87 -0
- package/dist/context.js.map +1 -0
- package/dist/controller.d.ts +26 -237
- package/dist/controller.d.ts.map +1 -1
- package/dist/controller.js +33 -1484
- package/dist/controller.js.map +1 -1
- package/dist/dom.d.ts +10 -0
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +29 -0
- package/dist/dom.js.map +1 -1
- package/dist/element.d.ts +51 -42
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +381 -602
- package/dist/element.js.map +1 -1
- package/dist/elements/actions.d.ts +27 -0
- package/dist/elements/actions.d.ts.map +1 -0
- package/dist/elements/actions.js +81 -0
- package/dist/elements/actions.js.map +1 -0
- package/dist/elements/bound.d.ts +63 -0
- package/dist/elements/bound.d.ts.map +1 -0
- package/dist/elements/bound.js +213 -0
- package/dist/elements/bound.js.map +1 -0
- package/dist/elements/change-detail.d.ts +25 -0
- package/dist/elements/change-detail.d.ts.map +1 -0
- package/dist/elements/change-detail.js +19 -0
- package/dist/elements/change-detail.js.map +1 -0
- package/dist/elements/change-list.d.ts +27 -0
- package/dist/elements/change-list.d.ts.map +1 -0
- package/dist/elements/change-list.js +29 -0
- package/dist/elements/change-list.js.map +1 -0
- package/dist/elements/filters.d.ts +25 -0
- package/dist/elements/filters.d.ts.map +1 -0
- package/dist/elements/filters.js +19 -0
- package/dist/elements/filters.js.map +1 -0
- package/dist/elements/legend.d.ts +40 -0
- package/dist/elements/legend.d.ts.map +1 -0
- package/dist/elements/legend.js +87 -0
- package/dist/elements/legend.js.map +1 -0
- package/dist/elements/minimap.d.ts +38 -0
- package/dist/elements/minimap.d.ts.map +1 -0
- package/dist/elements/minimap.js +59 -0
- package/dist/elements/minimap.js.map +1 -0
- package/dist/elements/root.d.ts +40 -0
- package/dist/elements/root.d.ts.map +1 -0
- package/dist/elements/root.js +67 -0
- package/dist/elements/root.js.map +1 -0
- package/dist/elements/search.d.ts +29 -0
- package/dist/elements/search.d.ts.map +1 -0
- package/dist/elements/search.js +23 -0
- package/dist/elements/search.js.map +1 -0
- package/dist/elements/stage-context.d.ts +31 -0
- package/dist/elements/stage-context.d.ts.map +1 -0
- package/dist/elements/stage-context.js +4 -0
- package/dist/elements/stage-context.js.map +1 -0
- package/dist/elements/stage.d.ts +65 -0
- package/dist/elements/stage.d.ts.map +1 -0
- package/dist/elements/stage.js +259 -0
- package/dist/elements/stage.js.map +1 -0
- package/dist/elements/title.d.ts +25 -0
- package/dist/elements/title.d.ts.map +1 -0
- package/dist/elements/title.js +19 -0
- package/dist/elements/title.js.map +1 -0
- package/dist/elements/transport.d.ts +29 -0
- package/dist/elements/transport.d.ts.map +1 -0
- package/dist/elements/transport.js +24 -0
- package/dist/elements/transport.js.map +1 -0
- package/dist/elements/view-bound.d.ts +39 -0
- package/dist/elements/view-bound.d.ts.map +1 -0
- package/dist/elements/view-bound.js +88 -0
- package/dist/elements/view-bound.js.map +1 -0
- package/dist/elements/view-dock.d.ts +28 -0
- package/dist/elements/view-dock.d.ts.map +1 -0
- package/dist/elements/view-dock.js +28 -0
- package/dist/elements/view-dock.js.map +1 -0
- package/dist/elements/zoom.d.ts +28 -0
- package/dist/elements/zoom.d.ts.map +1 -0
- package/dist/elements/zoom.js +22 -0
- package/dist/elements/zoom.js.map +1 -0
- package/dist/i18n.d.ts +10 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +20 -0
- package/dist/i18n.js.map +1 -1
- package/dist/icons.d.ts +1 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +1 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +331 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/keyboard.d.ts +39 -2
- package/dist/keyboard.d.ts.map +1 -1
- package/dist/keyboard.js +145 -62
- package/dist/keyboard.js.map +1 -1
- package/dist/layout-store.d.ts +26 -0
- package/dist/layout-store.d.ts.map +1 -0
- package/dist/layout-store.js +46 -0
- package/dist/layout-store.js.map +1 -0
- package/dist/panel-levels.d.ts +18 -0
- package/dist/panel-levels.d.ts.map +1 -0
- package/dist/panel-levels.js +41 -0
- package/dist/panel-levels.js.map +1 -0
- package/dist/panels.d.ts +28 -0
- package/dist/panels.d.ts.map +1 -0
- package/dist/panels.js +73 -0
- package/dist/panels.js.map +1 -0
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +3 -2
- package/dist/pipeline.js.map +1 -1
- package/dist/prefs.d.ts +5 -2
- package/dist/prefs.d.ts.map +1 -1
- package/dist/prefs.js +12 -3
- package/dist/prefs.js.map +1 -1
- package/dist/react.d.ts +460 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +2 -0
- package/dist/react.js.map +1 -0
- package/dist/root-element.d.ts +122 -0
- package/dist/root-element.d.ts.map +1 -0
- package/dist/root-element.js +541 -0
- package/dist/root-element.js.map +1 -0
- package/dist/root.d.ts +54 -0
- package/dist/root.d.ts.map +1 -0
- package/dist/root.js +288 -0
- package/dist/root.js.map +1 -0
- package/dist/schedule.d.ts +22 -0
- package/dist/schedule.d.ts.map +1 -0
- package/dist/schedule.js +41 -0
- package/dist/schedule.js.map +1 -0
- package/dist/session.d.ts +269 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +1237 -0
- package/dist/session.js.map +1 -0
- package/dist/standalone/kgdiff-viewer-compute.js +1 -1
- package/dist/standalone/kgdiff-viewer.js +4 -4
- package/dist/styles.d.ts +17 -6
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +367 -258
- package/dist/styles.js.map +1 -1
- package/dist/theme.d.ts +32 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +152 -0
- package/dist/theme.js.map +1 -0
- package/dist/topics.d.ts +8 -0
- package/dist/topics.d.ts.map +1 -0
- package/dist/topics.js +18 -0
- package/dist/topics.js.map +1 -0
- package/dist/ui/change-list.d.ts +18 -0
- package/dist/ui/change-list.d.ts.map +1 -0
- package/dist/ui/change-list.js +331 -0
- package/dist/ui/change-list.js.map +1 -0
- package/dist/ui/context.d.ts +34 -7
- package/dist/ui/context.d.ts.map +1 -1
- package/dist/ui/context.js.map +1 -1
- package/dist/ui/filters.d.ts +9 -0
- package/dist/ui/filters.d.ts.map +1 -0
- package/dist/ui/filters.js +68 -0
- package/dist/ui/filters.js.map +1 -0
- package/dist/ui/header.d.ts +41 -3
- package/dist/ui/header.d.ts.map +1 -1
- package/dist/ui/header.js +101 -36
- package/dist/ui/header.js.map +1 -1
- package/dist/ui/legend.d.ts +15 -0
- package/dist/ui/legend.d.ts.map +1 -0
- package/dist/ui/legend.js +68 -0
- package/dist/ui/legend.js.map +1 -0
- package/dist/ui/popovers.d.ts +3 -1
- package/dist/ui/popovers.d.ts.map +1 -1
- package/dist/ui/popovers.js +62 -23
- package/dist/ui/popovers.js.map +1 -1
- package/dist/ui/search.d.ts +13 -0
- package/dist/ui/search.d.ts.map +1 -0
- package/dist/ui/search.js +192 -0
- package/dist/ui/search.js.map +1 -0
- package/dist/ui/sidebar.d.ts +32 -17
- package/dist/ui/sidebar.d.ts.map +1 -1
- package/dist/ui/sidebar.js +327 -519
- package/dist/ui/sidebar.js.map +1 -1
- package/dist/ui/stage.d.ts +56 -1
- package/dist/ui/stage.d.ts.map +1 -1
- package/dist/ui/stage.js +244 -256
- package/dist/ui/stage.js.map +1 -1
- package/dist/ui/swatch.js +1 -1
- package/dist/ui/swatch.js.map +1 -1
- package/dist/ui/transport.d.ts +12 -0
- package/dist/ui/transport.d.ts.map +1 -0
- package/dist/ui/transport.js +198 -0
- package/dist/ui/transport.js.map +1 -0
- package/dist/ui/zoom.d.ts +15 -0
- package/dist/ui/zoom.d.ts.map +1 -0
- package/dist/ui/zoom.js +30 -0
- package/dist/ui/zoom.js.map +1 -0
- package/dist/view.d.ts +94 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +441 -0
- package/dist/view.js.map +1 -0
- package/package.json +95 -12
- package/src/bind.ts +80 -0
- package/src/context.ts +106 -0
- package/src/controller.ts +52 -1630
- package/src/dom.ts +30 -0
- package/src/element.ts +386 -619
- package/src/elements/actions.ts +94 -0
- package/src/elements/bound.ts +247 -0
- package/src/elements/change-detail.ts +34 -0
- package/src/elements/change-list.ts +51 -0
- package/src/elements/filters.ts +34 -0
- package/src/elements/legend.ts +103 -0
- package/src/elements/minimap.ts +75 -0
- package/src/elements/root.ts +86 -0
- package/src/elements/search.ts +38 -0
- package/src/elements/stage-context.ts +34 -0
- package/src/elements/stage.ts +285 -0
- package/src/elements/title.ts +34 -0
- package/src/elements/transport.ts +39 -0
- package/src/elements/view-bound.ts +118 -0
- package/src/elements/view-dock.ts +43 -0
- package/src/elements/zoom.ts +38 -0
- package/src/i18n.ts +20 -0
- package/src/icons.ts +1 -0
- package/src/index.ts +350 -35
- package/src/keyboard.ts +188 -61
- package/src/layout-store.ts +71 -0
- package/src/panel-levels.ts +53 -0
- package/src/panels.ts +81 -0
- package/src/pipeline.ts +4 -1
- package/src/prefs.ts +12 -4
- package/src/react.ts +459 -0
- package/src/root-element.ts +624 -0
- package/src/root.ts +335 -0
- package/src/schedule.ts +43 -0
- package/src/session.ts +1375 -0
- package/src/styles.ts +396 -263
- package/src/theme.ts +170 -0
- package/src/topics.ts +37 -0
- package/src/ui/change-list.ts +405 -0
- package/src/ui/context.ts +36 -7
- package/src/ui/filters.ts +79 -0
- package/src/ui/header.ts +129 -58
- package/src/ui/legend.ts +112 -0
- package/src/ui/popovers.ts +68 -25
- package/src/ui/search.ts +225 -0
- package/src/ui/sidebar.ts +362 -639
- package/src/ui/stage.ts +267 -331
- package/src/ui/swatch.ts +1 -1
- package/src/ui/transport.ts +240 -0
- package/src/ui/zoom.ts +45 -0
- package/src/view.ts +516 -0
- package/vscode.html-custom-data.json +726 -0
package/dist/bind.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Keymap } from './keyboard.js';
|
|
2
|
+
import type { DiffSession, Topic } from './session.js';
|
|
3
|
+
import type { FocusTarget, UiActions, UiContext } from './ui/context.js';
|
|
4
|
+
/** Something the root renders: a region, or the layout itself. */
|
|
5
|
+
export interface Region {
|
|
6
|
+
update(topics: ReadonlySet<Topic>): void;
|
|
7
|
+
}
|
|
8
|
+
/** What a root provides to the regions that bind to it. */
|
|
9
|
+
export interface ViewerContext {
|
|
10
|
+
readonly controller: DiffSession;
|
|
11
|
+
readonly actions: UiActions;
|
|
12
|
+
/** The element the root's events are dispatched on and its tokens are set on. */
|
|
13
|
+
readonly host: HTMLElement;
|
|
14
|
+
/** Render `region` on every notification (in binding order); returns the detach. */
|
|
15
|
+
attach(region: Region): () => void;
|
|
16
|
+
target(name: FocusTarget, focus: () => void, available?: () => boolean): () => void;
|
|
17
|
+
focus(name: FocusTarget): boolean;
|
|
18
|
+
/** The keys bound over the default map (the root's `keymap`), or null for the default. */
|
|
19
|
+
readonly keymap: Keymap | null;
|
|
20
|
+
/** The keyboard map, for a key event that reached the root. */
|
|
21
|
+
handleKey(e: KeyboardEvent): void;
|
|
22
|
+
/** A key pressed in an element bound with `for` (outside the root): the root's rules apply. */
|
|
23
|
+
forwardKey(e: KeyboardEvent): void;
|
|
24
|
+
/** The root's token set as a sheet of `doc` (for elements outside the root's subtree). */
|
|
25
|
+
tokens(doc: Document): CSSStyleSheet;
|
|
26
|
+
/** The pointer entered or left the graph (holds a looping replay with `pause-on-hover`). */
|
|
27
|
+
hover(over: boolean): void;
|
|
28
|
+
}
|
|
29
|
+
export declare const viewerContext: import("./context.js").Context<ViewerContext>;
|
|
30
|
+
/** Forward `e` to `ctx`'s root; no other root acts on it, whether it was handled or not. */
|
|
31
|
+
export declare function forwardKey(ctx: ViewerContext, e: KeyboardEvent): void;
|
|
32
|
+
/** Whether `e` was forwarded to a root by an element bound with `for`. */
|
|
33
|
+
export declare function wasForwarded(e: Event): boolean;
|
|
34
|
+
/** The UI context of a region placed in `root` (its shadow tree), bound to `ctx`. */
|
|
35
|
+
export declare function uiContext(ctx: ViewerContext, root: ShadowRoot): UiContext;
|
|
36
|
+
/**
|
|
37
|
+
* Bind a region to the root nearest `anchor` (an element where the region is placed): `make`
|
|
38
|
+
* builds it once the root answers, and the root renders it from then on.
|
|
39
|
+
*/
|
|
40
|
+
export declare function bindRegion<R extends Region>(anchor: Element, make: (ui: UiContext) => R): R;
|
|
41
|
+
//# sourceMappingURL=bind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../src/bind.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzE,kEAAkE;AAClE,MAAM,WAAW,MAAM;IACrB,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;CAC1C;AAED,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,oFAAoF;IACpF,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC;IACpF,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC;IAClC,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,+DAA+D;IAC/D,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAClC,+FAA+F;IAC/F,UAAU,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACnC,0FAA0F;IAC1F,MAAM,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa,CAAC;IACrC,4FAA4F;IAC5F,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CAC5B;AAED,eAAO,MAAM,aAAa,+CAAkD,CAAC;AAK7E,4FAA4F;AAC5F,wBAAgB,UAAU,CAAC,GAAG,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,IAAI,CAGrE;AAED,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO,CAE9C;AAED,qFAAqF;AACrF,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS,CASzE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,CAU3F"}
|
package/dist/bind.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How regions and elements find the root whose session they show (RFC 0001 §2): the context
|
|
3
|
+
* the root provides (`kgdiff.viewer/1`), what it provides, and the binding helpers. Type-only
|
|
4
|
+
* imports of the session: an element's subpath does not pull the session in through here.
|
|
5
|
+
*/
|
|
6
|
+
import { createContext, requestContext } from './context.js';
|
|
7
|
+
export const viewerContext = createContext('kgdiff.viewer/1');
|
|
8
|
+
/** Key events an element forwarded to its root: they belong to that root alone. */
|
|
9
|
+
const forwarded = new WeakSet();
|
|
10
|
+
/** Forward `e` to `ctx`'s root; no other root acts on it, whether it was handled or not. */
|
|
11
|
+
export function forwardKey(ctx, e) {
|
|
12
|
+
forwarded.add(e);
|
|
13
|
+
ctx.forwardKey(e);
|
|
14
|
+
}
|
|
15
|
+
/** Whether `e` was forwarded to a root by an element bound with `for`. */
|
|
16
|
+
export function wasForwarded(e) {
|
|
17
|
+
return forwarded.has(e);
|
|
18
|
+
}
|
|
19
|
+
/** The UI context of a region placed in `root` (its shadow tree), bound to `ctx`. */
|
|
20
|
+
export function uiContext(ctx, root) {
|
|
21
|
+
return {
|
|
22
|
+
...ctx.actions,
|
|
23
|
+
controller: ctx.controller,
|
|
24
|
+
root,
|
|
25
|
+
target: (name, focus, available) => ctx.target(name, focus, available),
|
|
26
|
+
focus: (name) => ctx.focus(name),
|
|
27
|
+
keymap: () => ctx.keymap,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Bind a region to the root nearest `anchor` (an element where the region is placed): `make`
|
|
32
|
+
* builds it once the root answers, and the root renders it from then on.
|
|
33
|
+
*/
|
|
34
|
+
export function bindRegion(anchor, make) {
|
|
35
|
+
const bound = {};
|
|
36
|
+
requestContext(anchor, viewerContext, (ctx) => {
|
|
37
|
+
if (bound.region)
|
|
38
|
+
return;
|
|
39
|
+
bound.region = make(uiContext(ctx, anchor.getRootNode()));
|
|
40
|
+
ctx.attach(bound.region);
|
|
41
|
+
});
|
|
42
|
+
// The default layout binds its regions to the root it owns, which answers at once.
|
|
43
|
+
if (!bound.region)
|
|
44
|
+
throw new Error('[kgdiff] a region found no root to bind to.');
|
|
45
|
+
return bound.region;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=bind.js.map
|
package/dist/bind.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b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M,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,EAAgB,CAAC,CAAC,CAAC;QACxE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,mFAAmF;IACnF,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAClF,OAAO,KAAK,CAAC,MAAM,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Web Components community context protocol
|
|
3
|
+
* (https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md),
|
|
4
|
+
* without dependencies: how the viewer's regions find the root whose session they show
|
|
5
|
+
* (RFC 0001 §2).
|
|
6
|
+
*
|
|
7
|
+
* A consumer dispatches a `context-request` event (bubbling, composed: it crosses shadow roots
|
|
8
|
+
* on its way up); the nearest provider of that context answers through the callback and stops
|
|
9
|
+
* the event. Requests nobody answered reach `document`, where they wait; a provider that
|
|
10
|
+
* connects later announces itself with `context-provider` and the waiting requests are sent
|
|
11
|
+
* again, so definition and connection order do not matter. A consumer outside the provider's
|
|
12
|
+
* subtree sends its request through an element inside it (`via`: the root named by `for`).
|
|
13
|
+
*/
|
|
14
|
+
export interface Context<T> {
|
|
15
|
+
/**
|
|
16
|
+
* `Symbol.for(name)`: equal across copies of the library on one page (an IIFE report bundle
|
|
17
|
+
* next to an ESM build), so a component of one copy finds the root of another. The name is
|
|
18
|
+
* versioned when the provided value changes incompatibly.
|
|
19
|
+
*/
|
|
20
|
+
readonly key: symbol;
|
|
21
|
+
/** Carries the value type only. */
|
|
22
|
+
readonly __value?: T;
|
|
23
|
+
}
|
|
24
|
+
export declare const createContext: <T>(name: string) => Context<T>;
|
|
25
|
+
export declare class ContextRequestEvent<T> extends Event {
|
|
26
|
+
readonly context: Context<T>;
|
|
27
|
+
/** The consumer, which may differ from the element the event is dispatched on (`via`). */
|
|
28
|
+
readonly consumer: Element;
|
|
29
|
+
readonly callback: (value: T) => void;
|
|
30
|
+
constructor(context: Context<T>,
|
|
31
|
+
/** The consumer, which may differ from the element the event is dispatched on (`via`). */
|
|
32
|
+
consumer: Element, callback: (value: T) => void);
|
|
33
|
+
}
|
|
34
|
+
export declare class ContextProviderEvent<T> extends Event {
|
|
35
|
+
readonly context: Context<T>;
|
|
36
|
+
constructor(context: Context<T>);
|
|
37
|
+
}
|
|
38
|
+
/** Ask for `context` for `consumer`, through `via` (an element of the provider's subtree). */
|
|
39
|
+
export declare function requestContext<T>(consumer: Element, context: Context<T>, callback: (value: T) => void, via?: Element | null): void;
|
|
40
|
+
/** Answer requests for `context` reaching `host`; returns the function that stops answering. */
|
|
41
|
+
export declare function provideContext<T>(host: Element, context: Context<T>, value: () => T): () => void;
|
|
42
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,QAAQ,MAAM,KAAG,OAAO,CAAC,CAAC,CAAgC,CAAC;AAE1F,qBAAa,mBAAmB,CAAC,CAAC,CAAE,SAAQ,KAAK;IAE7C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5B,0FAA0F;IAC1F,QAAQ,CAAC,QAAQ,EAAE,OAAO;IAC1B,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI;IAJvC,YACW,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5B,0FAA0F;IACjF,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAGtC;CACF;AAED,qBAAa,oBAAoB,CAAC,CAAC,CAAE,SAAQ,KAAK;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAAxC,YAAqB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAEvC;CACF;AAwCD,8FAA8F;AAC9F,wBAAgB,cAAc,CAAC,CAAC,EAC9B,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAC5B,GAAG,GAAE,OAAO,GAAG,IAAW,GACzB,IAAI,CAGN;AAED,gGAAgG;AAChG,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,MAAM,IAAI,CAWhG"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Web Components community context protocol
|
|
3
|
+
* (https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md),
|
|
4
|
+
* without dependencies: how the viewer's regions find the root whose session they show
|
|
5
|
+
* (RFC 0001 §2).
|
|
6
|
+
*
|
|
7
|
+
* A consumer dispatches a `context-request` event (bubbling, composed: it crosses shadow roots
|
|
8
|
+
* on its way up); the nearest provider of that context answers through the callback and stops
|
|
9
|
+
* the event. Requests nobody answered reach `document`, where they wait; a provider that
|
|
10
|
+
* connects later announces itself with `context-provider` and the waiting requests are sent
|
|
11
|
+
* again, so definition and connection order do not matter. A consumer outside the provider's
|
|
12
|
+
* subtree sends its request through an element inside it (`via`: the root named by `for`).
|
|
13
|
+
*/
|
|
14
|
+
export const createContext = (name) => ({ key: Symbol.for(name) });
|
|
15
|
+
export class ContextRequestEvent extends Event {
|
|
16
|
+
context;
|
|
17
|
+
consumer;
|
|
18
|
+
callback;
|
|
19
|
+
constructor(context,
|
|
20
|
+
/** The consumer, which may differ from the element the event is dispatched on (`via`). */
|
|
21
|
+
consumer, callback) {
|
|
22
|
+
super('context-request', { bubbles: true, composed: true });
|
|
23
|
+
this.context = context;
|
|
24
|
+
this.consumer = consumer;
|
|
25
|
+
this.callback = callback;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class ContextProviderEvent extends Event {
|
|
29
|
+
context;
|
|
30
|
+
constructor(context) {
|
|
31
|
+
super('context-provider', { bubbles: true, composed: true });
|
|
32
|
+
this.context = context;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const waiting = new Set();
|
|
36
|
+
let collecting = false;
|
|
37
|
+
/** Keep the requests nobody answered, and send them again when a provider connects. */
|
|
38
|
+
function collect() {
|
|
39
|
+
if (collecting || typeof document === 'undefined')
|
|
40
|
+
return;
|
|
41
|
+
collecting = true;
|
|
42
|
+
document.addEventListener('context-request', (e) => {
|
|
43
|
+
// Consumers that left the document since they asked are forgotten, closures and all.
|
|
44
|
+
for (const w of waiting)
|
|
45
|
+
if (!w.consumer.isConnected)
|
|
46
|
+
waiting.delete(w);
|
|
47
|
+
const r = e;
|
|
48
|
+
waiting.add({
|
|
49
|
+
context: r.context,
|
|
50
|
+
consumer: r.consumer,
|
|
51
|
+
via: e.composedPath()[0] ?? r.consumer,
|
|
52
|
+
callback: r.callback,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
document.addEventListener('context-provider', (e) => {
|
|
56
|
+
const key = e.context.key;
|
|
57
|
+
for (const w of [...waiting]) {
|
|
58
|
+
if (w.context.key !== key)
|
|
59
|
+
continue;
|
|
60
|
+
waiting.delete(w);
|
|
61
|
+
// Unanswered again: it waits again on its way through `document`.
|
|
62
|
+
if (w.consumer.isConnected) {
|
|
63
|
+
w.via.dispatchEvent(new ContextRequestEvent(w.context, w.consumer, w.callback));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** Ask for `context` for `consumer`, through `via` (an element of the provider's subtree). */
|
|
69
|
+
export function requestContext(consumer, context, callback, via = null) {
|
|
70
|
+
collect();
|
|
71
|
+
(via ?? consumer).dispatchEvent(new ContextRequestEvent(context, consumer, callback));
|
|
72
|
+
}
|
|
73
|
+
/** Answer requests for `context` reaching `host`; returns the function that stops answering. */
|
|
74
|
+
export function provideContext(host, context, value) {
|
|
75
|
+
collect();
|
|
76
|
+
const answer = (e) => {
|
|
77
|
+
const r = e;
|
|
78
|
+
if (r.context?.key !== context.key)
|
|
79
|
+
return;
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
r.callback(value());
|
|
82
|
+
};
|
|
83
|
+
host.addEventListener('context-request', answer);
|
|
84
|
+
host.dispatchEvent(new ContextProviderEvent(context));
|
|
85
|
+
return () => host.removeEventListener('context-request', answer);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAaH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAI,IAAY,EAAc,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAE1F,MAAM,OAAO,mBAAuB,SAAQ,KAAK;IAEpC,OAAO;IAEP,QAAQ;IACR,QAAQ;IAJnB,YACW,OAAmB;IAC5B,0FAA0F;IACjF,QAAiB,EACjB,QAA4B;QAErC,KAAK,CAAC,iBAAiB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;uBALnD,OAAO;wBAEP,QAAQ;wBACR,QAAQ;IAGnB,CAAC;CACF;AAED,MAAM,OAAO,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
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* review progress;
|
|
7
|
-
* - the `changes` scope's focus with expandable collapsed groups (`extendLayout` + scene rebuild);
|
|
8
|
-
* - replay clock driven by one requestAnimationFrame loop that sleeps when idle, with a camera
|
|
9
|
-
* that follows the playing hunk / chapter unless the user moved it in the last 2 s;
|
|
10
|
-
* - swipe position, hover, theme / palette / locale (rebuilding the scene when they change).
|
|
11
|
-
*
|
|
12
|
-
* The UI subscribes to topic notifications (batched per microtask) and reads public fields.
|
|
2
|
+
* The session of `<kgdiff-viewer>`: a `DiffSession` (state, commands, events; `session.ts`) with
|
|
3
|
+
* the one view of the default layout's canvas (`StageView`, `view.ts`: renderer, camera,
|
|
4
|
+
* framing, minimap) built in, so the layout and its tests address both as one object. A
|
|
5
|
+
* `<kgdiff-stage>` bound to the viewer adds a view of its own; `fit()` and `zoom()` reach all.
|
|
13
6
|
*/
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
16
|
-
import { type
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
replayEnd(loop: boolean): void;
|
|
37
|
-
}
|
|
38
|
-
export interface FitOptions {
|
|
39
|
-
readonly animate?: boolean;
|
|
40
|
-
/** Room around the content, px (default `FRAME_PADDING`); kept for later automatic fits. */
|
|
41
|
-
readonly padding?: number;
|
|
42
|
-
}
|
|
43
|
-
export interface ControllerDeps {
|
|
44
|
-
readonly now: () => number;
|
|
45
|
-
readonly requestFrame: (cb: (time: number) => void) => number;
|
|
46
|
-
readonly cancelFrame: (id: number) => void;
|
|
47
|
-
/** Resolves once the browser had a chance to paint (between loading steps). */
|
|
48
|
-
readonly yieldToPaint: () => Promise<void>;
|
|
49
|
-
readonly storage: StorageLike | null;
|
|
50
|
-
}
|
|
51
|
-
export type Preference = 'mode' | 'scope' | 'theme' | 'palette' | 'locale';
|
|
52
|
-
/** Camera follow is suppressed this long after the user moved the camera (ms). */
|
|
53
|
-
export declare const USER_CAMERA_GRACE = 2000;
|
|
54
|
-
/** The camera follows when less than this share of the target bounds is in view. */
|
|
55
|
-
export declare const FOLLOW_COVERAGE = 0.7;
|
|
56
|
-
/** Flights to a change never zoom in further, so its neighbourhood stays readable. */
|
|
57
|
-
export declare const FLY_MAX_ZOOM = 1.8;
|
|
58
|
-
/** Fitting everything never zooms in further (the renderer's default). */
|
|
59
|
-
export declare const FIT_MAX_ZOOM = 2.5;
|
|
60
|
-
/** Everything counts as in view (the minimap hides) from this share of the content bounds on. */
|
|
61
|
-
export declare const OVERVIEW_COVERAGE = 0.98;
|
|
62
|
-
/** Share of `bounds` inside `view`, in [0, 1]. */
|
|
63
|
-
export declare function coverage(bounds: Rect, view: Rect): number;
|
|
64
|
-
export declare class ViewerController {
|
|
65
|
-
#private;
|
|
66
|
-
status: Status;
|
|
67
|
-
/** Steps of the current load, in order; `step` is the running one. */
|
|
68
|
-
steps: LoadStep[];
|
|
69
|
-
step: LoadStep | null;
|
|
70
|
-
error: Error | null;
|
|
71
|
-
data: LoadedDiff | null;
|
|
72
|
-
layout: LayoutResult | null;
|
|
73
|
-
scene: Scene | null;
|
|
74
|
-
resolver: VisualResolver | null;
|
|
75
|
-
list: ListModel;
|
|
76
|
-
mode: ViewerMode;
|
|
77
|
-
scope: ViewerScope;
|
|
78
|
-
themePreference: ThemePreference;
|
|
79
|
-
palette: PaletteName;
|
|
80
|
-
locale: Locale;
|
|
81
|
-
systemDark: boolean;
|
|
82
|
-
reducedMotion: boolean;
|
|
83
|
-
/** Preferences set explicitly by the embedder (a report's `view` does not override them). */
|
|
84
|
-
readonly explicit: Set<Preference>;
|
|
85
|
-
selectedHunk: number;
|
|
86
|
-
selectedNode: number;
|
|
87
|
-
/** An edge emphasized from the detail panel (drawn as hovered). */
|
|
88
|
-
pinnedEdge: number;
|
|
89
|
-
hoverNode: number;
|
|
90
|
-
hoverEdge: number;
|
|
91
|
-
hoverGroup: number;
|
|
92
|
-
readonly families: Set<ChangeFamily>;
|
|
93
|
-
hops: number;
|
|
94
|
-
readonly expanded: Set<string>;
|
|
95
|
-
focus: FocusState | null;
|
|
96
|
-
clock: ReplayClock | null;
|
|
97
|
-
split: number;
|
|
98
|
-
emphasis: number;
|
|
99
|
-
/**
|
|
100
|
-
* Keep the view fitted (embeds without controls): fit again when the canvas is resized unless
|
|
101
|
-
* the user moved the camera since, and at the start of every loop.
|
|
102
|
-
*/
|
|
103
|
-
autoFit: boolean;
|
|
104
|
-
/** Canvas clicks select (and double clicks fly); off for embeds without controls. */
|
|
105
|
-
selectOnClick: boolean;
|
|
106
|
-
/** The whole content is in view (the minimap has nothing to add). */
|
|
107
|
-
overview: boolean;
|
|
108
|
-
constructor(host: ControllerHost, deps: ControllerDeps);
|
|
109
|
-
subscribe(listener: (topics: ReadonlySet<Topic>) => void): () => void;
|
|
110
|
-
/** Deliver pending notifications now (also used by tests). */
|
|
111
|
-
flush(): void;
|
|
112
|
-
get themeName(): ThemeName;
|
|
113
|
-
get theme(): Theme;
|
|
114
|
-
get diff(): DiffResult | null;
|
|
115
|
-
get hunkCount(): number;
|
|
116
|
-
isReviewed(hunkId: string): boolean;
|
|
117
|
-
reviewState(): ReviewState;
|
|
118
|
-
search(query: string, limit?: number): SearchHit[];
|
|
119
|
-
load(options: LoadOptions): Promise<void>;
|
|
120
|
-
loadPayload(payload: ReportPayload): Promise<void>;
|
|
121
|
-
/** Show an error state (bad payload, failed load). */
|
|
122
|
-
fail(error: Error): void;
|
|
7
|
+
import type { Camera } from '@kgdiff/renderer';
|
|
8
|
+
import type { ChromeLayout } from './framing.js';
|
|
9
|
+
import { DiffSession, type SessionDeps, type SessionHost } from './session.js';
|
|
10
|
+
import { StageView } from './view.js';
|
|
11
|
+
export type { Preference, Status, Topic } from './session.js';
|
|
12
|
+
export type { FitOptions } from './view.js';
|
|
13
|
+
export { coverage, FIT_MAX_ZOOM, FLY_MAX_ZOOM, FOLLOW_COVERAGE, OVERVIEW_COVERAGE, USER_CAMERA_GRACE, } from './view.js';
|
|
14
|
+
export type ControllerHost = SessionHost;
|
|
15
|
+
export type ControllerDeps = SessionDeps;
|
|
16
|
+
export declare class ViewerController extends DiffSession {
|
|
17
|
+
/** The default layout's canvas. */
|
|
18
|
+
readonly view: StageView;
|
|
19
|
+
constructor(host: SessionHost, deps: SessionDeps);
|
|
20
|
+
/** Keep the canvas fitted (`StageView.autoFit`). */
|
|
21
|
+
get autoFit(): boolean;
|
|
22
|
+
set autoFit(value: boolean);
|
|
23
|
+
/** Canvas clicks select (`StageView.selectOnClick`). */
|
|
24
|
+
get selectOnClick(): boolean;
|
|
25
|
+
set selectOnClick(value: boolean);
|
|
26
|
+
/** The whole content is in the canvas's view (the minimap has nothing to add). */
|
|
27
|
+
get overview(): boolean;
|
|
28
|
+
get camera(): Camera | null;
|
|
123
29
|
attach(stage: HTMLElement, minimapHost: HTMLElement | null): void;
|
|
124
30
|
detach(): void;
|
|
125
31
|
destroy(): void;
|
|
126
|
-
get camera(): Camera | null;
|
|
127
|
-
/**
|
|
128
|
-
* Where floating chrome covers the canvas (measured by the element at fit / flight time).
|
|
129
|
-
* Every fit and flight frames its target in the free part of the canvas (`framing.ts`).
|
|
130
|
-
*/
|
|
131
32
|
setChrome(provider: (() => ChromeLayout) | null): void;
|
|
132
|
-
/**
|
|
133
|
-
* Keep labels whole inside the canvas (embeds without camera controls): a label pushed from
|
|
134
|
-
* its spot by a neighbour moves inside or is left out, never cut at the edge.
|
|
135
|
-
*/
|
|
136
33
|
setLabelsInside(inside: boolean): void;
|
|
137
|
-
/**
|
|
138
|
-
* The canvas was laid out or resized: run the initial fit a new diff is waiting for, or (with
|
|
139
|
-
* `autoFit`) fit again unless the user moved the camera since the last fit.
|
|
140
|
-
*/
|
|
141
34
|
layoutChanged(): void;
|
|
142
|
-
/** The user panned / zoomed: suspend replay camera follow for `USER_CAMERA_GRACE`. */
|
|
143
35
|
noteUserCamera(): void;
|
|
144
|
-
/** Redraw on the next animation frame. */
|
|
145
|
-
invalidate(): void;
|
|
146
|
-
/** Resolve the current view and hand it to the renderer (and the minimap). */
|
|
147
|
-
draw(now?: number): void;
|
|
148
|
-
/** Whether the scope is fixed to `changes` (the layout covers only the changes). */
|
|
149
|
-
get scopeLocked(): boolean;
|
|
150
|
-
/** Switch how the versions are compared. The legacy `changes` means overlay + `changes` scope. */
|
|
151
|
-
setMode(value: ViewerMode | typeof LEGACY_CHANGES_MODE): void;
|
|
152
|
-
/** Show the whole graph or only the changes, in any mode. */
|
|
153
|
-
setScope(value: ViewerScope): void;
|
|
154
|
-
/** Toggle the `changes` scope (key `4`); says why when the scope is locked. */
|
|
155
|
-
toggleScope(): void;
|
|
156
|
-
/** Set mode and scope together (one notification, one `kgdiff-mode` event). */
|
|
157
|
-
setView(mode: ViewerMode, scope: ViewerScope): void;
|
|
158
|
-
selectHunkById(id: string | null, options?: {
|
|
159
|
-
fly?: boolean;
|
|
160
|
-
}): void;
|
|
161
|
-
/**
|
|
162
|
-
* Select hunk `h` (scene index; -1 clears). `node` focuses one of its nodes in the detail
|
|
163
|
-
* panel. `fly` (default true) brings it into view. In replay, seeks to the end of its window.
|
|
164
|
-
*/
|
|
165
|
-
selectHunk(h: number, options?: {
|
|
166
|
-
fly?: boolean;
|
|
167
|
-
node?: number;
|
|
168
|
-
}): void;
|
|
169
|
-
/** Select a node: its hunk when it has one, else the node itself. */
|
|
170
|
-
selectNode(i: number, options?: {
|
|
171
|
-
fly?: boolean;
|
|
172
|
-
}): void;
|
|
173
|
-
clearSelection(): void;
|
|
174
|
-
next(): void;
|
|
175
|
-
prev(): void;
|
|
176
|
-
first(): void;
|
|
177
|
-
last(): void;
|
|
178
|
-
/** Emphasize an edge (from the detail panel) and fly to it. */
|
|
179
|
-
pinEdge(j: number): void;
|
|
180
|
-
flyToHunk(h: number): void;
|
|
181
|
-
flyToNode(i: number): void;
|
|
182
|
-
flyToSelection(): void;
|
|
183
|
-
/**
|
|
184
|
-
* Fit everything visible (the focus in changes-only mode), labels included, into the free part
|
|
185
|
-
* of the canvas. Before the canvas is laid out it falls back to the renderer's own fit.
|
|
186
|
-
*/
|
|
187
|
-
fit(options?: FitOptions): Promise<void>;
|
|
188
|
-
zoom(direction: 1 | -1): void;
|
|
189
|
-
/** Clear hover state (pointer left the canvas). */
|
|
190
|
-
clearHover(): void;
|
|
191
|
-
toggleFamily(family: ChangeFamily): void;
|
|
192
|
-
/** Replace the family filter (empty = all). Setting the current set again clears it. */
|
|
193
|
-
setFamilies(families: readonly ChangeFamily[]): void;
|
|
194
|
-
setHops(hops: number): void;
|
|
195
|
-
/**
|
|
196
|
-
* Expand collapsed group `index` of the current focus: its in-scene members become visible
|
|
197
|
-
* and, for a `changes`-scoped layout, the neighbours left out of the layout are placed with
|
|
198
|
-
* `extendLayout` (nothing already placed moves) and the scene is rebuilt.
|
|
199
|
-
*/
|
|
200
|
-
expandGroup(index: number): void;
|
|
201
|
-
/**
|
|
202
|
-
* The collapsed group nearest the selection (else the view center), or -1. Groups that can
|
|
203
|
-
* be expanded at least partly come first.
|
|
204
|
-
*/
|
|
205
|
-
nearestGroup(): number;
|
|
206
|
-
/** Expand the group nearest the selection (keyboard `e`); announces what happened. */
|
|
207
|
-
expandNearest(): void;
|
|
208
|
-
/**
|
|
209
|
-
* Whether collapsed group `index` can be expanded completely: always, unless some members lie
|
|
210
|
-
* outside a `changes`-scoped layout and the layout engine is known to be unavailable
|
|
211
|
-
* (standalone report without the compute add-on).
|
|
212
|
-
*/
|
|
213
|
-
canExpand(index: number): boolean;
|
|
214
|
-
/** Bring a union node into the scene and the focus (search results), then select it. */
|
|
215
|
-
revealNode(id: UnionId): Promise<void>;
|
|
216
|
-
play(): void;
|
|
217
|
-
/** Pause; a looping replay stays paused (until `play`, a new diff or loop turned on again). */
|
|
218
|
-
pause(): void;
|
|
219
|
-
togglePlay(): void;
|
|
220
|
-
/**
|
|
221
|
-
* Play the replay over and over: `delay` ms after it ends it starts again; null plays it
|
|
222
|
-
* once. Turning the loop on starts a replay that is shown but not playing.
|
|
223
|
-
*/
|
|
224
|
-
setLoop(delay: number | null): void;
|
|
225
|
-
get loopDelay(): number | null;
|
|
226
|
-
/**
|
|
227
|
-
* Hold playback while the pointer rests on the graph (`pause-on-hover`): a playing replay
|
|
228
|
-
* pauses and continues on release; a pending loop restart waits for the release, then the
|
|
229
|
-
* full loop delay.
|
|
230
|
-
*/
|
|
231
|
-
hold(held: boolean): void;
|
|
232
|
-
seek(t: number): void;
|
|
233
|
-
stepReplay(direction: 1 | -1): void;
|
|
234
|
-
restart(): void;
|
|
235
|
-
cycleSpeed(): void;
|
|
236
|
-
setSpeed(speed: number): void;
|
|
237
|
-
setSplit(split: number): void;
|
|
238
|
-
setReviewed(hunkId: string, reviewed: boolean): void;
|
|
239
|
-
/** Another tab changed review progress (`storage` event): re-read it. */
|
|
240
|
-
syncReview(key: string | null): void;
|
|
241
|
-
toggleReviewed(hunkId?: string): void;
|
|
242
|
-
setThemePreference(pref: ThemePreference): void;
|
|
243
|
-
setPalette(palette: PaletteName): void;
|
|
244
|
-
setLocale(locale: Locale): void;
|
|
245
|
-
setSystemDark(dark: boolean): void;
|
|
246
|
-
setReducedMotion(reduced: boolean): void;
|
|
247
36
|
}
|
|
248
37
|
//# sourceMappingURL=controller.d.ts.map
|
package/dist/controller.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../src/controller.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,E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